|
| 1 | +#!/bin/bash |
| 2 | +# Test AgentClick code review — mind-map file tree + diff viewer |
| 3 | + |
| 4 | +AGENTCLICK_URL="http://localhost:3001" |
| 5 | + |
| 6 | +echo "Creating code review session..." |
| 7 | + |
| 8 | +SESSION_PAYLOAD='{ |
| 9 | + "type": "code_review", |
| 10 | + "sessionKey": "main-session", |
| 11 | + "payload": { |
| 12 | + "command": "git apply feature/retry-client.patch", |
| 13 | + "cwd": "/project/src", |
| 14 | + "explanation": "Introduces a generic retry helper and updates the API client to use it. Removes the deprecated legacy client module.", |
| 15 | + "risk": "medium", |
| 16 | + "affectedFiles": [ |
| 17 | + { |
| 18 | + "path": "src/utils/retry.ts", |
| 19 | + "status": "added", |
| 20 | + "diff": "@@ -0,0 +1,14 @@\n+/**\n+ * Retries an async function up to `times` attempts.\n+ */\n+export async function retry<T>(\n+ fn: () => Promise<T>,\n+ times = 3,\n+ delayMs = 200,\n+): Promise<T> {\n+ let last: unknown\n+ for (let i = 0; i < times; i++) {\n+ try { return await fn() } catch (e) { last = e }\n+ if (i < times - 1) await new Promise(r => setTimeout(r, delayMs))\n+ }\n+ throw last\n+}" |
| 21 | + }, |
| 22 | + { |
| 23 | + "path": "src/api/client.ts", |
| 24 | + "status": "modified", |
| 25 | + "diff": "@@ -1,10 +1,11 @@\n import axios from 'axios'\n+import { retry } from '../utils/retry'\n \n-export async function fetchUser(id: string) {\n- return axios.get(`/users/${id}`)\n+export async function fetchUser(id: string) {\n+ return retry(() => axios.get(`/users/${id}`))\n }\n \n-export async function updateUser(id: string, data: object) {\n- return axios.put(`/users/${id}`, data)\n+export async function updateUser(id: string, data: object) {\n+ return retry(() => axios.put(`/users/${id}`, data))\n }" |
| 26 | + }, |
| 27 | + { |
| 28 | + "path": "src/api/legacyClient.ts", |
| 29 | + "status": "deleted", |
| 30 | + "diff": "@@ -1,7 +0,0 @@\n-// Deprecated — use client.ts\n-import axios from 'axios'\n-\n-export const get = (url: string) => axios.get(url)\n-export const post = (url: string, body: object) => axios.post(url, body)\n-export const del = (url: string) => axios.delete(url)" |
| 31 | + }, |
| 32 | + { |
| 33 | + "path": "src/api/index.ts", |
| 34 | + "status": "renamed", |
| 35 | + "oldPath": "src/api/exports.ts", |
| 36 | + "diff": "@@ -1,3 +1,3 @@\n-export * from '\''./legacyClient'\''\n+export * from '\''./client'\''\n export * from '\''./types'\''" |
| 37 | + }, |
| 38 | + { |
| 39 | + "path": "src/config/constants.ts", |
| 40 | + "status": "modified" |
| 41 | + }, |
| 42 | + { |
| 43 | + "path": "tests/api/client.test.ts", |
| 44 | + "status": "added" |
| 45 | + } |
| 46 | + ] |
| 47 | + } |
| 48 | +}' |
| 49 | + |
| 50 | +RESPONSE=$(curl -s -X POST "$AGENTCLICK_URL/api/review" \ |
| 51 | + -H "Content-Type: application/json" \ |
| 52 | + -d "$SESSION_PAYLOAD") |
| 53 | + |
| 54 | +SESSION_ID=$(echo "$RESPONSE" | grep -o '"sessionId":"[^"]*"' | cut -d'"' -f4) |
| 55 | +URL=$(echo "$RESPONSE" | grep -o '"url":"[^"]*"' | cut -d'"' -f4) |
| 56 | + |
| 57 | +if [ -z "$SESSION_ID" ]; then |
| 58 | + echo "❌ Failed to create session. Is AgentClick running?" |
| 59 | + echo " Start it with: npm run dev" |
| 60 | + echo " Response: $RESPONSE" |
| 61 | + exit 1 |
| 62 | +fi |
| 63 | + |
| 64 | +echo "" |
| 65 | +echo "✅ Code review session created!" |
| 66 | +echo " Session ID: $SESSION_ID" |
| 67 | +echo " Review URL: $URL" |
| 68 | +echo "" |
| 69 | +echo "What to check in the UI:" |
| 70 | +echo " • Mind-map file tree — pills connected by spine + arms" |
| 71 | +echo " • src/ directory auto-expanded (all files are on-path)" |
| 72 | +echo " • Diffs shown below the tree for 4 files" |
| 73 | +echo " • Added file (retry.ts) → green pill" |
| 74 | +echo " • Modified files → blue pill" |
| 75 | +echo " • Deleted file → red pill" |
| 76 | +echo " • Renamed file → amber pill with '← exports.ts'" |
| 77 | +echo " • Two entries without diffs (constants.ts, client.test.ts) show in tree only" |
| 78 | +echo "" |
| 79 | + |
| 80 | +# Open browser (macOS) |
| 81 | +open "$URL" 2>/dev/null || echo "Open in browser: $URL" |
0 commit comments