Repository navigation
feat: require restart approval when agents are running - #4
ivanmilevtues wants to merge 6 commits into
Conversation
(cherry picked from commit 3f47f52) Co-authored-by: Ivan Milev <[email protected]>
(cherry picked from commit 87a27cf) Co-authored-by: Ivan Milev <[email protected]>
(cherry picked from commit b68002d) Co-authored-by: Ivan Milev <[email protected]>
(cherry picked from commit 9152632) Co-authored-by: Ivan Milev <[email protected]>
- Release pending intents: CLI posts cancel on timeout and disconnect so connected TUIs never stay stuck on a dead request. - Resolve only broadcasts on a fresh settlement; late resolvers replay the winner without re-emitting, and nothing pending returns 400. - Subscribe to the resolved event before requesting an intent in both the CLI and the TUI, so a fast decision cannot be missed. - Exclude the requesting session from the idle wait; it blocks on this command and could never drain. - Keep the --force hint out of the non-interactive path so a blocked agent is not handed its own bypass. (cherry picked from commit 80b3628) Co-authored-by: Ivan Milev <[email protected]>
A requester that is interrupted or SIGKILLed (for example by the agent shell tool's own timeout) never reaches its release path, so the pending intent lived forever and every approver dialog stayed open, with a later decision broadcast to nobody. The server now owns release: each request schedules a detached expiry that clears the intent and emits server.restart.expired, which approvers treat as a dismissal. Generation tokens keep a stale timer from expiring a newer request. The CLI no longer posts its own cancel; expiry is the single release path, and its local wait is longer than the server TTL so the server always ends an unanswered wait. (cherry picked from commit 8a5d47c) Co-authored-by: Ivan Milev <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 72 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
CodeBoarding reviewStatus: 10 changed components See the full change in CodeBoarding. graph LR
n_Frontend_Applications_and_UI_Clients["Frontend Applications and UI Clients"]
n_Core_Agent_Engine_and_Runtime["Core Agent Engine and Runtime"]
n_Terminal_User_Interface["Terminal User Interface"]
n_AI_Provider_Integrations_and_Protocols["AI Provider Integrations and Protocols"]
n_CLI_Application_and_Scripts["CLI Application and Scripts"]
n_Server_and_Plugin_Runtime_Services["Server and Plugin Runtime Services"]
n_Domain_Schemas_and_Data_Models["Domain Schemas and Data Models"]
n_Protocol_Route_Specifications["Protocol Route Specifications"]
n_Infrastructure_and_Cloud_Services["Infrastructure and Cloud Services"]
n_Web_Share_Viewer["Web Share Viewer"]
n_Provider_and_UI_Simulation["Provider and UI Simulation"]
n_LaTeX_Parser_and_Renderer["LaTeX Parser and Renderer"]
n_Terminal_UI_Themes["Terminal UI Themes"]
n_Storybook_and_Package_Utilities["Storybook and Package Utilities"]
n_Frontend_Applications_and_UI_Clients -- "utilizes core utility helpers" --> n_Core_Agent_Engine_and_Runtime
n_Frontend_Applications_and_UI_Clients -- "imports session transfer schema" --> n_Domain_Schemas_and_Data_Models
n_Frontend_Applications_and_UI_Clients -- "proxies browser network calls" --> n_Server_and_Plugin_Runtime_Services
n_CLI_Application_and_Scripts -- "renders overlay and dialog UI" --> n_Terminal_User_Interface
n_Protocol_Route_Specifications -- "references schema types in protocol definitions" --> n_Domain_Schemas_and_Data_Models
classDef added fill:#1f883d,stroke:#0b5d23,color:#ffffff;
classDef modified fill:#bf8700,stroke:#7d4e00,color:#ffffff;
classDef deleted fill:#cf222e,stroke:#82071e,color:#ffffff,stroke-dasharray:5 3;
class n_Frontend_Applications_and_UI_Clients,n_Terminal_User_Interface,n_CLI_Application_and_Scripts,n_Server_and_Plugin_Runtime_Services,n_Protocol_Route_Specifications modified;
|
Issue for this PR
Demonstrates a real cross-component feature from upstream anomalyco/opencode#55967, addressing upstream #43415 and #46322: restarting the background service can interrupt running agents without approval.
This is a runnable demo port for the CodeBoarding fork, not a claim of original authorship or a request to merge upstream work. Leave open for the architecture demo. Upstream is still under review.
Type of change
What does this PR do?
Ask before restarting a server with active agents. The CLI requests approval, the server coordinates the decision, and the TUI offers Restart now, When idle, or Cancel restart. First resolution wins; unanswered requests expire so dialogs do not remain stuck. The CLI retains an explicit
--forceoption.Why this makes a useful architecture demo
19 files, +1,346 / −16, including 674 lines of tests. No dependency, lockfile, workflow, or baseline changes.
Verified generated result: open the architecture diff. CodeBoarding analysis succeeded.
Five top-level components are modified (10 components counting their five changed children):
Comparing the exact base and head artifacts confirms two affected component relationships, both inside TUI:
RestartApprovalDialogcalling the existingSessionQuestionUI.There are no added or removed component boxes. New modules include
server/src/restart-intent.ts,tui/src/context/restart-approval.tsx, andschema/src/service-event.ts, but CodeBoarding groups them within existing responsibilities. This is a cross-component change demo, not a new-component demo.Demo walkthrough: start with the cross-component diff, follow the CLI request into the server's new intent service, inspect the TUI approval dependency, and explain how the selected decision returns through the shared API/events. Drill into the server and TUI rather than displaying every unrelated component.
Provenance
All six commits from upstream anomalyco#55967 were replayed with
git cherry-pick -x, preserving @agustif's authorship and original commit references. Includes the upstream location-error prerequisite and follow-up expiry/race fixes. The patch applies cleanly to this fork's existingdev; no base-branch update is needed.How did you verify your code works?
bun run check: lint passed (warnings, no errors), all 36 typecheck tasks passed.bun run generateinpackages/client: no changes, confirming the checked-in generated contract matches.git diff --check: passed.Broader client tests (
bun test test/effect.test.ts test/promise.test.ts) produce 46 passed / 3 failed, identically on unchangedorigin/devand this branch. The existing failures concern the Effect idle-date fixture, the integration API group inventory, and the session interrupt URL expectation. They are not introduced by this port; this PR does not claim the full test suite is green.Tests exercise first-wins settlement, expiry, stale expiry tokens, cancellation, force bypass, waiting for idle, excluding the requesting session from the idle wait, disconnects during idle polling, and remote dismissal of TUI approval.
Screenshots / recordings
The production TUI dialog was rendered through the upstream fixture harness at 100×30 and 60×24 terminal sizes. This is fixture validation, not a claim of a live-server end-to-end restart test.
Checklist