feat(server): add /api/decision poll + SSE endpoints for remote clients#750
Open
buihongduc132 wants to merge 1 commit into
Open
feat(server): add /api/decision poll + SSE endpoints for remote clients#750buihongduc132 wants to merge 1 commit into
buihongduc132 wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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=1or 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/planresponse and look for changes? Neither is great.Changes
GET /api/decisionSimple polling endpoint. Returns
{ pending: true }until the user decides, then returns the full decision result ({ approved, feedback, savedPath, ... }).GET /api/decision/streamSSE 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
decisionResultvariable that stores the resolved decision (was previously only available via Promise)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.