Skip to content

Fix /restart after ACP initialization failure - #548

Open
Kai Tao (vanzue) wants to merge 3 commits into
mainfrom
dev/vanzue/fix-restart-after-acp-init-failure
Open

Fix /restart after ACP initialization failure#548
Kai Tao (vanzue) wants to merge 3 commits into
mainfrom
dev/vanzue/fix-restart-after-acp-init-failure

Conversation

@vanzue

Copy link
Copy Markdown
Contributor

Summary

  • keep /restart event forwarding alive independently of the ACP connection task
  • allow failed and degraded helpers to request restart_agent_stack after ACP initialization exits
  • cover restart forwarding without an active ACP connection

Root cause

When ACP initialization failed, run_acp_client_over_pipe returned and dropped restart_rx. The UI still changed to Connecting("Restarting agent..."), but its restart send targeted the closed channel and the error was ignored, leaving the pane stuck indefinitely.

Validation

  • cargo test --manifest-path tools\wta\Cargo.toml (1321 passed)
  • explicit-target Debug WTA build
  • hot-refreshed the loose Debug package
  • restarted from a degraded helper and confirmed OpenCode 1.18.7 initialized in 2.27s and session/new succeeded

Keep restart event forwarding independent from the ACP connection task so /restart can recover after handshake failures.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings August 6, 2026 02:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a recovery dead-end in the WTA helper when ACP initialization fails by keeping /restart forwarding alive independently of the ACP client task, allowing Windows Terminal to force-restart the entire agent stack even after the ACP task has exited.

Changes:

  • Moved /restart event forwarding out of run_acp_client_over_pipe into a dedicated forwarder task that survives ACP initialization failure.
  • Updated helper/app wiring to spawn the restart forwarder outside the ACP connection lifecycle.
  • Added a unit test ensuring restart forwarding works without an active ACP connection.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
tools/wta/src/protocol/acp/client.rs Introduces the standalone restart forwarder + adds a test; removes /restart handling from the ACP select loop.
tools/wta/src/helper/runtime.rs Spawns the restart forwarder alongside channel creation so it survives master/ACP failures.
tools/wta/src/app.rs Removes deferred restart receiver plumbing and spawns the restart forwarder when rebuilding ACP channels post-failure.
tools/wta/src/app_events.rs Drops the now-removed restart_rx field from deferred ACP parameter initialization.

Comment thread tools/wta/src/protocol/acp/client.rs Outdated
Resolve the ACP client test import conflict while retaining both restart recovery coverage and the latest model usage tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 8e3f0dba-54bd-41a6-8b79-117e2c108693
Copilot AI review requested due to automatic review settings August 6, 2026 03:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread tools/wta/src/protocol/acp/client.rs Outdated
Use a Send-capable Tokio task and avoid logging custom agent command arguments that may contain credentials.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 8e3f0dba-54bd-41a6-8b79-117e2c108693
Copilot AI review requested due to automatic review settings August 6, 2026 04:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

Suppressed comments (1)

tools/wta/src/helper/runtime.rs:461

  • The comment says the ACP client forwards /restart to C++, but restart forwarding is now handled by the independent forwarder (outside the ACP task). Updating this comment will avoid confusion about which component is responsible for publishing restart_agent_stack.
            // /restart channel: App emits a RestartRequest, the ACP client
            // forwards to C++ independently of the ACP connection. Keeping
            // this receiver outside the ACP task preserves recovery after a
            // handshake failure.

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.

2 participants