Skip to content

feat: implement status routes#110

Open
2witstudios wants to merge 4 commits intomainfrom
ppg/issue-68-status-routes
Open

feat: implement status routes#110
2witstudios wants to merge 4 commits intomainfrom
ppg/issue-68-status-routes

Conversation

@2witstudios
Copy link
Owner

Summary

  • Adds Fastify-based read-only HTTP API routes for manifest data and live agent statuses
  • GET /api/status — full manifest with refreshed agent statuses and computed lifecycle
  • GET /api/worktrees/:id — single worktree detail (resolves by ID or name)
  • GET /api/worktrees/:id/diff — branch diff in numstat format (file-level additions/deletions)
  • All routes authenticated via Bearer token
  • Routes registered as a Fastify plugin accepting projectRoot and bearerToken options

Closes #68

Test plan

  • 13 tests using Fastify inject() with mocked core functions
  • Auth: missing token → 401, wrong token → 401, valid token → 200
  • Status: returns manifest with lifecycle, calls refreshAllAgentStatuses
  • Worktree detail: valid ID → 200 with lifecycle, unknown → 404
  • Diff: numstat parsing, empty diff, binary files, correct git range, unknown worktree → 404
  • Full test suite passes (231 tests, 22 files)
  • Typecheck passes (no errors in new files)

…ent statuses

Add Fastify-based HTTP API with Bearer token auth:
- GET /api/status — full manifest with refreshed agent statuses and lifecycle
- GET /api/worktrees/:id — single worktree detail by ID or name
- GET /api/worktrees/:id/diff — branch diff in numstat format

Closes #68
@chatgpt-codex-connector
Copy link

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@coderabbitai
Copy link

coderabbitai bot commented Feb 27, 2026

Warning

Rate limit exceeded

@2witstudios has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 11 minutes and 16 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 34deb69 and 7c1a319.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (6)
  • package.json
  • src/commands/spawn.test.ts
  • src/commands/status.ts
  • src/core/lifecycle.ts
  • src/server/routes/status.test.ts
  • src/server/routes/status.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ppg/issue-68-status-routes

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

P0 — Security:
- Use crypto.timingSafeEqual for Bearer token comparison
- Return reply from auth hook to prevent handler execution after 401

P1 — Architecture:
- Extract computeLifecycle to core/lifecycle.ts (fix server→commands dependency)
- Re-export from commands/status.ts for backward compatibility
- Remove unused WorktreeNotFoundError import
- Remove redundant requireManifest call in diff route

P2 — Robustness:
- Add Fastify error handler mapping PpgError codes to HTTP status codes
- Diff route uses readManifest (no lock/write) instead of updateManifest
- Add tests: auth bypass, ManifestLockError, NotInitializedError,
  git diff failure, verify diff uses readManifest not updateManifest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement status routes

1 participant