Openstatus www.openstatus.dev

feat: ralph (#1725)

* feat: ralph

* fix: redirect to /status-pages when user has no access to page id

Instead of throwing an error when a user navigates to /status-pages/[id]
without access, we now gracefully redirect them to the status pages list.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* chore: remove try/catch

* ci: apply automated fixes

* fix: typos

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>

authored by

Maximilian Kaske
Claude Opus 4.5
autofix-ci[bot]
and committed by
GitHub
cd59f009 3eeccd74

+96 -1
+8 -1
apps/dashboard/src/app/(dashboard)/status-pages/[id]/layout.tsx
··· 1 + import { redirect } from "next/navigation"; 2 + 1 3 import { 2 4 AppHeader, 3 5 AppHeaderActions, ··· 19 21 const { id } = await params; 20 22 const queryClient = getQueryClient(); 21 23 22 - await queryClient.prefetchQuery( 24 + const pageData = await queryClient.fetchQuery( 23 25 trpc.page.get.queryOptions({ id: Number.parseInt(id) }), 24 26 ); 27 + 28 + if (!pageData?.id) { 29 + redirect("/status-pages"); 30 + } 31 + 25 32 await queryClient.prefetchQuery(trpc.monitor.list.queryOptions()); 26 33 27 34 return (
+34
ralph/README.md
··· 1 + Ralph is a technique for running AI coding agents in a loop. Our approach is taken from Matt Pocock's [Getting Started with Ralph](https://www.aihero.dev/getting-started-with-ralph) writeup. Make sure to have everything installed. 2 + 3 + The `prd.json` file is an array of object with the following format: 4 + 5 + ``` 6 + { 7 + "category": "functional", 8 + "description": "When a user is on wrong dashboard /status-pages/[id] redirect him to /status-pages", 9 + "steps": [ 10 + "Redirect user no access for page id", 11 + "Avoid throwing an error", 12 + ], 13 + "passes": false 14 + } 15 + ``` 16 + 17 + - category: "functional" | "ui" or other categories 18 + - description: define what you are building 19 + - steps: break the task down into multiple smaller steps 20 + - passes: determines whether or not all defined steps and tests have succeed or not and makes it easier to track progress 21 + 22 + The `progress.txt` file simply keeps track of the changes and implementation decisions. 23 + 24 + You can run Ralph with a human-in-the-loop by running: 25 + 26 + ``` 27 + ./ralph-once.sh 28 + ``` 29 + 30 + Or in AFK mode within the sandbox environment by specifying the iteration number with: 31 + 32 + ``` 33 + ./afk-raph.sh 10 34 + ```
+25
ralph/afk-ralph.sh
··· 1 + #!/bin/bash 2 + set -e 3 + 4 + if [ -z "$1" ]; then 5 + echo "Usage: $0 <iterations>" 6 + exit 1 7 + fi 8 + 9 + for ((i=1; i<=$1; i++)); do 10 + result=$(docker sandbox run claude --permission-mode acceptEdits -p "@prd.json @progress.txt \ 11 + 1. Find the highest-priority task and implement it. \ 12 + 2. Run your tests and type checks. \ 13 + 3. Update the PRD with what was done. \ 14 + 4. Append your progress to progress.txt. \ 15 + 5. Commit your changes. \ 16 + ONLY WORK ON A SINGLE TASK. \ 17 + If the PRD is complete, output <promise>COMPLETE</promise>.") 18 + 19 + echo "$result" 20 + 21 + if [[ "$result" == *"<promise>COMPLETE</promise>"* ]]; then 22 + echo "PRD complete after $i iterations." 23 + exit 0 24 + fi 25 + done
+8
ralph/prd.json
··· 1 + [ 2 + { 3 + "category": "functional", 4 + "description": "When a user is on wrong dashboard /status-pages/[id] redirect him to /status-pages", 5 + "steps": ["Redirect user no access for page id", "Avoid throwing an error"], 6 + "passes": false 7 + } 8 + ]
+13
ralph/progress.txt
··· 1 + ## Completed Tasks 2 + 3 + ### Task 1: Redirect user with no access for status-pages/[id] 4 + - **PRD Item**: "When a user is on wrong dashboard /status-pages/[id] redirect him to /status-pages" 5 + - **Status**: COMPLETED 6 + - **Commit**: b72b1bf5 7 + - **Changes Made**: 8 + - Modified `apps/dashboard/src/app/(dashboard)/status-pages/[id]/layout.tsx` 9 + - Changed from `prefetchQuery` to `fetchQuery` to properly check page access 10 + - Added try-catch block to handle errors when user doesn't have access to the page 11 + - Redirects to `/status-pages` instead of throwing an error when: 12 + - Page doesn't exist 13 + - User doesn't have access to the page (wrong workspace)
+8
ralph/ralph-once.sh
··· 1 + #!/bin/bash 2 + 3 + claude --permission-mode acceptEdits "@prd.json @progress.txt \ 4 + 1. Read the PRD and progress file. \ 5 + 2. Find the next incomplete task and implement it. \ 6 + 3. Commit your changes. \ 7 + 4. Update progress.txt with what you did. \ 8 + ONLY DO ONE TASK AT A TIME."