Skip to content

feat(server): add /api/decision poll + SSE endpoints for remote clients#750

Open
buihongduc132 wants to merge 1 commit into
backnotprop:mainfrom
buihongduc132:upstream/feat-decision-endpoints
Open

feat(server): add /api/decision poll + SSE endpoints for remote clients#750
buihongduc132 wants to merge 1 commit into
backnotprop:mainfrom
buihongduc132:upstream/feat-decision-endpoints

Conversation

@buihongduc132
Copy link
Copy Markdown

What

Two new endpoints that let remote clients (SSH, devcontainer, Docker) check the plan decision status over HTTP.

Why

When the server runs locally, the CLI process calls server.waitForDecision() directly — works great. But when running remotely (e.g., PLANNOTATOR_REMOTE=1 or behind a proxy), the client connecting via HTTP has no way to know when the user approved or denied the plan. It just has to... guess? Or poll the /api/plan response and look for changes? Neither is great.

Changes

GET /api/decision

Simple polling endpoint. Returns { pending: true } until the user decides, then returns the full decision result ({ approved, feedback, savedPath, ... }).

GET /api/decision/stream

SSE stream that pushes the decision result as soon as it happens. More efficient than polling — especially over slow connections. If the decision was already made before connecting, it sends the result immediately and closes.

Implementation

  • Added decisionResult variable that stores the resolved decision (was previously only available via Promise)
  • Both endpoints are purely additive — no change to existing approve/deny flows

Testing

3 new tests covering pending state, resolved state, and SSE stream behavior.

Backwards Compatibility

100% — these are new endpoints that don't affect anything existing.

When the server runs remotely (SSH, devcontainer, Docker), the CLI
process that started it can call waitForDecision() directly. But remote
clients connecting via HTTP have no way to poll the decision status.

Two new endpoints:

1. GET /api/decision — Returns { pending: true } until the user
   approves/denies, then returns the full decision result.
   Simple polling for clients that prefer REST.

2. GET /api/decision/stream — SSE stream that sends the decision
   result as soon as it happens. More efficient than polling.
   Sends the result immediately if already decided.

Both are purely additive — existing approve/deny flows unchanged.
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.

1 participant