Skip to content

fix(wta): reconnect via master pipe after FRE login (first-tab session view empty)#186

Merged
DDKinger merged 3 commits into
mainfrom
dev/yuazha/fix-pipe-mode-reconnect
Jun 5, 2026
Merged

fix(wta): reconnect via master pipe after FRE login (first-tab session view empty)#186
DDKinger merged 3 commits into
mainfrom
dev/yuazha/fix-pipe-mode-reconnect

Conversation

@DDKinger

@DDKinger DDKinger commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Symptom

After FRE, running copilot (or any agent CLI) in tab 1's shell pane produces a session that tab 1's session view never shows, even though the underlying ~/.copilot/session-state/<uuid>/ dir exists and the hook fires correctly. Tabs 2/3 (opened after login) work fine and even see tab 1's session because their helpers reach master via the standard pipe. Repro from a user log (0.1.1522.0): * wta-main_helper-16548.log (tab 1's helper): * line 19: ERROR helper: run_acp_client_over_pipe failed error=... Authentication required * line 21: AgentError auth fallback: showing setup screen * line 23-29: user does FRE login, acp: try_start_acp triggered has_event_tx=true has_deferred=true * line 33 onward (every 5s, forever): WARN agents_view: sessions/list ext-request failed error=Error { code: -32601: Method not found, message: "\"Method not found\": _intellterm.wta/sessions/list", ... } — note the underscore prefix * line 43: WARN session_hook: failed to queue session_hook event for master error=channel closed * wta-main_master.log: helper 1 connects once at 06:46:44 then never again. The session for tab 1 (sid 8514730f) only reaches master because tab 2's helper happens to forward the broadcast hook.

Root cause

In helper mode (--connect-master) the initial run_acp_client_over_pipe task fails immediately with Authentication required when the user is in FRE / not yet logged in. The post-login LoginComplete handler then fires try_start_acp, but that path was hard-wired to spawn run_acp_client (direct mode) instead of run_acp_client_over_pipe. The reconnected helper: * spawns its own copilot CLI subprocess and bypasses wta-master entirely (never re-registers with master), * every intellterm.wta/... ext-request fails with Method not found — the ACP SDK forwards unknown extensions to the agent with a leading _, and the directly-spawned agent CLI doesn't know master-side extensions, * the alive-mirror never populates → the first tab's session view stays blank for the helper's lifetime, * session_hook publishes log channel closed (the rx was consumed and dropped with the failed initial task).

Fix

Extend DeferredAcpParams with master_pipe_name and owner_tab_id (None in direct mode). * New App::set_master_pipe_acp_params, called once at boot in helper mode from main.rs to pre-stash pipe-mode params on App. * try_start_acp branches on master_pipe_name.is_some(): * pipe-mode reconnect: rebuilds the session_hook channel, re-binds self.session_hook_tx so hooks reach master again, spawns run_acp_client_over_pipe with the original pipe / owner_tab. * direct-mode: unchanged. * Existing set_acp_params and LoginComplete direct-mode synthesis paths just carry the two new fields as None. Why pre-stash instead of recreating from scratch in LoginComplete: keeps the pipe-mode discovery in main.rs alongside the rest of the helper-mode wiring (single place that knows about --connect-master), and LoginComplete's deferred_acp.is_none() synthesis path stays purely about the legacy direct-mode FRE.

Validation

Verified with a clean repro on 0.8.0.2:

Logout helper (deletes the only "logged-in state" source — Windows Credential
Manager target LegacyGeneric:target=copilot-cli/<host>:<user> — and
~/.copilot/config.json):

cmdkey /delete:LegacyGeneric:target=copilot-cli/https://github.com:<user>
Remove-Item "$env:USERPROFILE\.copilot\config.json" -Force

Repro / verify:

  1. Run logout snippet → confirm cmdkey /list | findstr copilot is empty.
  2. Launch Intelligent Terminal (FRE flag untouched) → agent pane in tab 1 shows GitHub login screen.
  3. Complete login → tab 1 chat works, a session is created.
  4. Open session view in tab 1 → new session appears.

Log signature (single line, easy to grep for future regressions):

LoginComplete received: …
Before fix (wta-main_helper-23300.log) deferred_acp=false → synthesizes direct-mode params → Spawning C:\…\copilot.exe… pid=Some(N) (own subprocess, bypasses master)
After fix (wta-main_helper-26644.log) deferred_acp=truetry_start_acp: reconnecting via master piperun_acp_client_over_pipeSession created (over pipe): <sid>alive_mirror: alive session added by master

The deferred_acp=true|false boolean on the LoginComplete received line is the canonical externally-visible signature of the pre-stash — any future regression of this code path will flip it back to false.

cargo test --bin wta → 698 passed locally on x86_64-pc-windows-msvc.

Fixes #188.

In helper mode (`--connect-master`) the initial
`run_acp_client_over_pipe` task fails immediately with
`Authentication required` when the user is in FRE (not yet logged
in). The post-login `LoginComplete` handler then fires
`try_start_acp`, but that path was hard-wired to spawn
`run_acp_client` (direct mode) — spawning its own copilot CLI
subprocess and bypassing wta-master entirely. The reconnected helper
never registers with master, so:

  * every `intellterm.wta/...` ext-request fails with
    `"Method not found": _intellterm.wta/sessions/list` (the ACP
    SDK forwards unknown extensions to the agent with a leading
    underscore, and the agent CLI doesn't know master-side
    extensions);
  * the alive-mirror never populates → the first tab's session view
    stays blank for the life of the helper;
  * `session_hook` publishes log `channel closed` (the rx was
    consumed and dropped with the failed initial task).

Symptom from the field: after FRE, running `copilot` in tab 1's
shell pane produces a session that tab 1's session view never shows.
Tabs 2/3 (spawned post-login, never see `Authentication required`)
work fine and even see tab 1's session because their helpers reach
master via the standard pipe.

Fix:

  * extend `DeferredAcpParams` with `master_pipe_name` and
    `owner_tab_id`;
  * add `App::set_master_pipe_acp_params`, called once at boot in
    helper mode (main.rs) to pre-stash pipe-mode params on App;
  * route `try_start_acp` through `run_acp_client_over_pipe` when
    `master_pipe_name.is_some()`, rebuilding the `session_hook`
    channel and re-binding `self.session_hook_tx` so hooks reach
    master again;
  * direct-mode FRE (no `--connect-master`) is unchanged — existing
    `set_acp_params` and `LoginComplete` synthesis paths just
    carry the two new fields as `None`.

Verified: `cargo build --target x86_64-pc-windows-msvc` clean,
`cargo test --bin wta` 698 passed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 2, 2026 08:21
Comment thread tools/wta/src/app.rs Fixed
Comment thread tools/wta/src/app.rs Fixed

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

Fixes a helper-mode (pipe-to-master) reconnection bug after FRE login where tab 1’s helper would fall back to direct-mode ACP, bypass wta-master, and therefore fail master-only intellterm.wta/... extension methods (leaving the session management view empty in the first tab).

Changes:

  • Extend deferred ACP launch parameters to carry helper pipe-mode markers (master_pipe_name, owner_tab_id) so try_start_acp can reconnect through wta-master after login.
  • Add a boot-time “pre-stash” in helper mode so post-FRE LoginComplete -> try_start_acp uses run_acp_client_over_pipe instead of run_acp_client.
  • In try_start_acp, add a pipe-mode reconnect branch that rebuilds the session_hook channel and spawns the pipe transport.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
tools/wta/src/main.rs Pre-stashes helper pipe-mode ACP params so post-FRE reconnect uses the master pipe transport.
tools/wta/src/app.rs Adds pipe-mode fields to deferred params and branches try_start_acp to reconnect via master pipe, rebuilding hook plumbing.

Comment thread tools/wta/src/app.rs
Comment thread tools/wta/src/app.rs
@github-actions

This comment has been minimized.

@DDKinger DDKinger marked this pull request as draft June 2, 2026 08:39
@DDKinger DDKinger marked this pull request as ready for review June 5, 2026 02:22
@github-actions

This comment has been minimized.

…s PR

Follows the existing convention in tools/wta/src/app.rs where every (tx, rx)

pair from mpsc::unbounded_channel uses a short prefix + tx/rx name and is

added to allow.txt (see ptx/prx, ntx/nrx, ltx/lrx, dtx/drx, rntx/rnrx,

rtx/rrx, mrx). shtx/shrx = session_hook tx/rx, rebuilt in

App::try_start_acp's pipe-mode reconnect branch.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 5, 2026 03:00

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 3 out of 3 changed files in this pull request and generated 5 comments.

Comment thread tools/wta/src/app.rs
Comment thread tools/wta/src/app.rs
Comment thread tools/wta/src/app.rs
Comment thread tools/wta/src/app.rs
Comment thread tools/wta/src/app.rs
@DDKinger DDKinger merged commit d550368 into main Jun 5, 2026
11 checks passed
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.

First tab's session management view stays empty after FRE login

4 participants