Skip to content

Open-source status page, incident response and uptime monitoring

feat: ralph (#1725)

Maximilian Kaskecd59f0092f35
diff --git a/apps/dashboard/src/app/(dashboard)/status-pages/[id]/layout.tsx b/apps/dashboard/src/app/(dashboard)/status-pages/[id]/layout.tsx
index d6b933c11..b729f3d52 100644
--- a/apps/dashboard/src/app/(dashboard)/status-pages/[id]/layout.tsx
+++ b/apps/dashboard/src/app/(dashboard)/status-pages/[id]/layout.tsx
@@ -1,3 +1,5 @@
+import { redirect } from "next/navigation";
+
import {
AppHeader,
AppHeaderActions,
@@ -19,9 +21,14 @@ export default async function Layout({
const { id } = await params;
const queryClient = getQueryClient();
- await queryClient.prefetchQuery(
+ const pageData = await queryClient.fetchQuery(
trpc.page.get.queryOptions({ id: Number.parseInt(id) }),
);
+
+ if (!pageData?.id) {
+ redirect("/status-pages");
+ }
+
await queryClient.prefetchQuery(trpc.monitor.list.queryOptions());
return (
diff --git a/ralph/README.md b/ralph/README.md
new file mode 100644
index 000000000..b54a819dd
--- /dev/null
+++ b/ralph/README.md
@@ -0,0 +1,34 @@
+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.
+
+The `prd.json` file is an array of object with the following format:
+
+```
+{
+ "category": "functional",
+ "description": "When a user is on wrong dashboard /status-pages/[id] redirect him to /status-pages",
+ "steps": [
+ "Redirect user no access for page id",
+ "Avoid throwing an error",
+ ],
+ "passes": false
+}
+```
+
+- category: "functional" | "ui" or other categories
+- description: define what you are building
+- steps: break the task down into multiple smaller steps
+- passes: determines whether or not all defined steps and tests have succeed or not and makes it easier to track progress
+
+The `progress.txt` file simply keeps track of the changes and implementation decisions.
+
+You can run Ralph with a human-in-the-loop by running:
+
+```
+./ralph-once.sh
+```
+
+Or in AFK mode within the sandbox environment by specifying the iteration number with:
+
+```
+./afk-raph.sh 10
+```
\ No newline at end of file
diff --git a/ralph/afk-ralph.sh b/ralph/afk-ralph.sh
new file mode 100644
index 000000000..e56b7116b
--- /dev/null
+++ b/ralph/afk-ralph.sh
@@ -0,0 +1,25 @@
+#!/bin/bash
+set -e
+
+if [ -z "$1" ]; then
+ echo "Usage: $0 <iterations>"
+ exit 1
+fi
+
+for ((i=1; i<=$1; i++)); do
+ result=$(docker sandbox run claude --permission-mode acceptEdits -p "@prd.json @progress.txt \
+ 1. Find the highest-priority task and implement it. \
+ 2. Run your tests and type checks. \
+ 3. Update the PRD with what was done. \
+ 4. Append your progress to progress.txt. \
+ 5. Commit your changes. \
+ ONLY WORK ON A SINGLE TASK. \
+ If the PRD is complete, output <promise>COMPLETE</promise>.")
+
+ echo "$result"
+
+ if [[ "$result" == *"<promise>COMPLETE</promise>"* ]]; then
+ echo "PRD complete after $i iterations."
+ exit 0
+ fi
+done
\ No newline at end of file
diff --git a/ralph/prd.json b/ralph/prd.json
new file mode 100644
index 000000000..e0f0b0c63
--- /dev/null
+++ b/ralph/prd.json
@@ -0,0 +1,8 @@
+[
+ {
+ "category": "functional",
+ "description": "When a user is on wrong dashboard /status-pages/[id] redirect him to /status-pages",
+ "steps": ["Redirect user no access for page id", "Avoid throwing an error"],
+ "passes": false
+ }
+]
diff --git a/ralph/progress.txt b/ralph/progress.txt
new file mode 100644
index 000000000..788ad5038
--- /dev/null
+++ b/ralph/progress.txt
@@ -0,0 +1,13 @@
+## Completed Tasks
+
+### Task 1: Redirect user with no access for status-pages/[id]
+- **PRD Item**: "When a user is on wrong dashboard /status-pages/[id] redirect him to /status-pages"
+- **Status**: COMPLETED
+- **Commit**: b72b1bf5
+- **Changes Made**:
+ - Modified `apps/dashboard/src/app/(dashboard)/status-pages/[id]/layout.tsx`
+ - Changed from `prefetchQuery` to `fetchQuery` to properly check page access
+ - Added try-catch block to handle errors when user doesn't have access to the page
+ - Redirects to `/status-pages` instead of throwing an error when:
+ - Page doesn't exist
+ - User doesn't have access to the page (wrong workspace)
diff --git a/ralph/ralph-once.sh b/ralph/ralph-once.sh
new file mode 100755
index 000000000..e157ae0e2
--- /dev/null
+++ b/ralph/ralph-once.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+claude --permission-mode acceptEdits "@prd.json @progress.txt \
+1. Read the PRD and progress file. \
+2. Find the next incomplete task and implement it. \
+3. Commit your changes. \
+4. Update progress.txt with what you did. \
+ONLY DO ONE TASK AT A TIME."
\ No newline at end of file