Repository navigation
fix(harness): Name the login rather than spawn it - #661
Conversation
e1151dc to
d0efdcd
Compare
|
Rebased onto The rebase was textually clean — no conflicts. Because a clean replay is not evidence the branch's claims survived, each was re-checked against the new base:
Suite against the new base:
Nothing broke, so the branch carries no rebase fixup commit. Still two commits, same content, new base. The acceptance gap disclosed in the PR body is unchanged: Chat still needs a restart to leave the not-authenticated state, and this rebase did not touch that. — Claude Code agent, on @omesser's behalf. |
Chat's Connect chained a `harness_login` that spawned the Harness's own login from the GUI process, racing the child it had just attached for `localhost:1455`. #654. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The source scan false-positived and its invariant is already false; the Settings row test fed itself the table it then found. #654. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
codex-acp opens no listener on attach. Two Connect clicks made two spawns. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
d0efdcd to
4aa4f2d
Compare
Why
Connecting an unauthenticated Harness from Chat spawned
codex loginfrom a GUI process with no terminal of its own, on inherited stdio. The browser flow reported success, but the CLI handshake and the token reached nothing Chat could use, and the Harness stayed unusable.The two
localhost:1455servers in #654's log were twocodex loginspawns: one per Connect click. The user clicked Connect, was thrown out, and clicked again. The ACP child (npx -y @agentclientprotocol/codex-acp@latest) played no part. codex-acp starts Codex's login server only when the client sendsauthenticateor whenDEFAULT_AUTH_REQUESTis set, and ai-buddy does neither.A second defect hid behind it:
select_harnesswrote settings directly and never calledharness::retarget. A Harness picked from Chat only became the Completer at the next launch, and noReloadChatwas sent, so the open window kept its stale opening. That is the other half of "the Harness stays unusable".What changed
This takes the third outcome #654 lists: Chat does not start the flow, it names the command and waits.
harness_loginis deleted, along with itsinvoke_handlerrow. Nothing in the product spawns an auth process any more.harness::login_hint, which is now the single place those strings exist.login_commandkeeps its precedence — a known fix first, then the handshake's own words, then this table.select_harnessroutes throughSettingsSession::applyinstead of writing the file, so the pick retargets the attachment now rather than at the next launch, and theReloadChatit sends carries the new state back to the window that asked. It answers with the login command.src/chat.jsshows that command instead of spawning it.Acceptance 1 is not reachable any other way from ai-buddy's side: a GUI process cannot host the terminal
codex loginexpects, and ADR-0010 / ADR-0018 / #371 forbid hosting the redirect ourselves.settings.rsalready committed this repo to naming the command rather than running it, so Chat now says the same sentence from the same table.What the user does now
The user signs in to the Harness CLI in their own terminal, with the command Chat and Settings show (for example
codex login). It can be done before or after picking the Harness in Chat. Nothing in ai-buddy has to be running for it.After signing in, ai-buddy picks it up at the next
session/newattempt. The auth retry gate is 60 seconds (AI_BUDDY_HARNESS_AUTH_RETRY_SECS), and reopening Chat re-reads login state. A CLI already signed in before ai-buddy ever ran needs nothing at all: the subprocess runs as the same user (ADR-0018).This matches the ACP spec. Clients that cannot host an interactive terminal must not spawn
terminal-type auth, and every non-terminal-hosting ACP client (JetBrains, Emacs agent-shell, Neovim plugins) tells the user to log in in their own terminal.How to verify
cargo test -p ai-buddy cargo clippy -p ai-buddy --all-targets -- -D warnings node --test tests/417 Rust tests pass, clippy clean, 108 node tests pass.
every_named_harness_documents_a_login_for_the_users_own_terminalasserts every named Harness answers Connect with a hint, and that the hint equalslogin_command(name, &Handshake::default()).That ai-buddy no longer spawns an auth process is a compile-time fact, not a test's:
harness_logindoes not exist, and a command absent from theinvoke_handlercannot be reached from the webview.Notes
chat_openingre-reads login on every opening, so reopening Chat picks up a completed sign-in without restarting the app. But nothing fires when the user finishescodex loginin their terminal minutes later. This branch adds no regression there and no trigger either. Building a poller or watcher is a design decision, not a review fix — worth its own issue if a live trigger is wanted.include_str!("main.rs")contains noCommand::new(the invariant is already false —MenuAction::OpenMemoryspawns viaplatform::open_path), a circular test that fedlogin_hintin and found it again, and a manualchat_openingre-invoke inchat.jsthat droppedshowPromptand raced the Rust-side push.src/chat.htmlships Connect buttons for only four of the six named Harnesses — nohermes, nopi. Pre-existing, not this branch's doing. Worth its own issue.login_commandprefers an auth method the handshake advertises, so an adapter answering withcodex login --device-authmakes Settings say that while Chat shows the table default. That divergence is intended — Settings has more information later — and nothing now claims otherwise.Closes #654
— Claude Code agent, on @omesser's behalf.
🤖 Generated with Claude Code