Skip to content

feat: sign in to Copilot from vibe-kanban, and restore the Sign in button - #3498

Merged
anastasiya1155 merged 12 commits into
mainfrom
feat/copilot-sign-in
Nov 11, 2026
Merged

anastasiya1155 merged 12 commits into
mainfrom
feat/copilot-sign-in

Conversation

@anastasiya1155

@anastasiya1155 anastasiya1155 commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

Why

A signed-out Copilot rejects session/new with ACP error -32000 (AuthRequired), and initialize still succeeds. The harness turned every error into a string, so users saw a generic error and had no way to sign in from vibe-kanban.

The sign-in flow for Cursor and Codex was broken too. The legacy cleanup in 139b181 (#2790) deleted NextActionCard, the only caller of runAgentSetup. Since then needs_setup was computed but never rendered. This PR brings the Sign in button back for Cursor and Codex as well.

What changed

Each commit builds on its own:

  1. UI: Sign in button (feat(ui))
    • The next-action row reaches the conversation only when needs_setup is set. It renders Sign in for agents with the SETUP_HELPER capability.
    • The button calls runAgentSetup with the failed turn's own executor profile, carried as a new optional NextAction.executor_profile_id, so a variant signs in with its own config.
    • After a successful click the button stays disabled until the setup process shows up on the stream, so a quick second click can't start a second login.
  2. Cursor detection fix (fix(cursor)): Cursor's CLI renamed cursor-agent to agent, and its sign-in message changed with it. The exact-text match missed the new wording, so the error was tagged Other and no button showed. It now matches "Authentication required" + "login".
  3. -32000 means setup required (feat(acp)): a new exit_event turns a -32000 run error into AcpEvent::AuthRequired, which normalize_logs maps to NormalizedEntryError::SetupRequired. This covers session/new (signed out) and session/prompt (token expired mid-session), since both return through run_session. Other errors are unchanged.
  4. Shared setup runner (refactor(server)): the duplicated chain-and-start code from codex_setup.rs and cursor_setup.rs moved into agent_setup.rs::start_agent_setup. No change in behaviour.
  5. Copilot sign-in (feat(copilot))
    • Copilot gets SetupHelper, and the agent setup API has a Copilot branch.
    • Copilot::login_command() builds <base> login --device-code from base_command(). That's the same registry package as a run, read from the cache with no network, and base_command_override is honoured. It drops the run args (--acp) and ignores additional_params.
    • --device-code prints a code and link we can show, needs no browser on the backend's machine, and works without a TTY. Setup scripts get stdin = null.
    • The script carries no profile env. It's saved in execution_processes.executor_action and shown in the output, and profile env can hold tokens. Copilot's sign-in doesn't depend on env.
    • On Unix the program and args are shell-quoted.
  6. Device code in the conversation (feat(ui))
    • The code and link used to be visible only in the logs panel.
    • While a script runs, a card under it shows the code and a Copy code and open button. The button copies in the user's browser, then opens the page.
    • parseDeviceCode isn't agent-specific: it looks for a link and a code on the same line. The card shows only for Tool Install Scripts (the app's own agent and gh setup), never for the user's setup or cleanup scripts, where a link next to a request ID or ticket key could look like a code.
  7. No browser tab (fix(copilot)): in device mode Copilot opens the sign-in page on the backend's machine, which took the user away before they saw the card. The login script now runs with BROWSER=true. Copilot honours BROWSER, and true does nothing.
  8. Model selector (feat(acp)): discovery also opens a session with session/new, so it gets the same -32000. It now says "Not signed in to this agent." instead of the raw message plus a stderr line. It doesn't mention a Sign in button, because registry agents share this code and don't have one. Like any failed discovery, it isn't cached.
  9. Each model once (fix(acp)): Copilot sends auto twice, as its own entry and again in the model list, so the selector showed Auto twice. Reading an agent's options now keeps the first choice for each value, and lists already saved in the disk cache drop their repeats when read.
  10. Selector refreshes after sign-in (fix(acp)): discovery ran once per stream connection, and a failure blocked a new one for 30 seconds, so after signing in the selector kept "Not signed in" and the old list until a reload.
    • When a run opens a session, the agent's failed discovery is forgotten, since the agent works now. Copilot and registry agents pass their discovery key to the harness.
    • When the dropdown opens while it shows an error, the frontend reconnects the stream (an attempt query param the backend ignores), so discovery runs again.

Also: packages/web-core/vitest.config.ts with the app's aliases. Before this, npx vitest run couldn't resolve @/ and shared/, and 2 of the 3 existing test files failed. Vitest still isn't a dependency or run in CI.

Reviewer notes

  • Who sees the button: Copilot signs in from env tokens, then its own stored copilot login, then gh auth token. Users signed in to gh, or with a token in their env, never see it.
  • Registry agents (AcpServer) show the setup-required message but no button, and the API returns SetupHelperNotSupported for them.
  • Known behaviour:
    • After a failed or cancelled login, the button doesn't come back, because the last turn is then the failed script, not an agent turn. Sending the prompt again brings it back.
    • After sign-in, start_agent_setup reruns the workspace's latest coding-agent action, in the workspace's latest session, not necessarily the session where you clicked. That was already true for Cursor and Codex; Copilot now has it too.
  • Windows: the Copilot login script is a plain, unquoted join, like Codex, and keeps Copilot's default browser opening. I couldn't compile the Windows branches here.
  • Follow-ups:
    • Send session_id in RunAgentSetupRequest, so sign-in reruns the prompt of the session you clicked in.
    • Sign-in for registry agents, below.
  • Next PR, sign-in for registry agents: Copilot's initialize offers copilot-login with no type. When we declare clientCapabilities.auth.terminal, it adds _meta["terminal-auth"] = { command, args: ["login"], label }. That's the older extension, not ACP's type: "terminal".

Testing

  • cargo test -p executors (118 passed) and cargo test -p server. New tests cover:
    • the -32000 code surviving with_timeout, and exit_event with and without a message;
    • normalize_logs turning AuthRequired into setup_required;
    • the Copilot login command, from the registry and with a base override;
    • quoting in the login script;
    • discovery against a fake sh agent that rejects session/new with -32000, checked to fail without the fix;
    • Cursor's old and new sign-in messages;
    • repeated choices dropped (configOptions, legacy models, and the disk cache);
    • forget_failure clearing a failure but not a recent success.
  • npx vitest run in packages/web-core: 29 passed. New tests cover the next-action filter, the executor-profile helper and parseDeviceCode.
  • pnpm run check, pnpm run lint, pnpm run generate-types:check.
  • Manual tests:
    • Cursor signed out: the button shows, and login runs.
    • Copilot signed out (fake gh on PATH, token env unset, /logout): setup-required, then the button, then the device code card. After authorising, the prompt runs again.
    • Codex couldn't be tested: its certificate was revoked, and fixing that needs a major version bump.

🤖 Generated with Claude Code

anastasiya1155 and others added 12 commits November 11, 2026 08:20
The legacy cleanup (139b181, #2790) removed NextActionCard, the only
caller of runAgentSetup, so needs_setup was computed but never shown.

The next-action row now reaches the conversation list only when
needs_setup is set, and renders a Sign in button for agents with the
SETUP_HELPER capability. It calls runAgentSetup with the failed turn's
own executor profile (carried as NextAction.executor_profile_id), so a
variant signs in with its own config.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Cursor's CLI now says "run 'agent login'" instead of
"run 'cursor-agent login'", so the exact-message match missed it and the
error was tagged Other, with no Sign in button. Match on "Authentication
required" and "login" instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A signed-out ACP agent rejects session/new with -32000 (AuthRequired),
and an expired token does the same on session/prompt. The harness
flattened every error into a string, so the user saw a generic error.

The run's exit error is now logged as AcpEvent::AuthRequired when its
code is -32000, and normalize_logs turns that into a SetupRequired error
entry, which is what offers the Sign in button. Other errors are
unchanged. Session history skips the new event, like Error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
run_codex_setup and run_cursor_setup repeated the same steps: chain the
workspace's latest coding-agent action after the setup action, ensure
the container, find or create a session, and start it as a setup
script. That's now start_agent_setup in agent_setup.rs, and each agent
keeps only its own setup action. No change in behaviour; this is so the
Copilot sign-in doesn't add a third copy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot now has the SetupHelper capability, and the agent setup API has
a Copilot branch. It runs `<copilot base> login --device-code` as a
setup script, then the failed prompt again.

- Copilot::login_command() takes the package from base_command(), so it
  matches the run (cached registry, no network) and honours
  base_command_override. It drops the run args (--acp) and ignores
  additional_params, which are run flags login would reject.
- --device-code prints a code and link in the conversation, needs no
  browser on the backend's machine, and works without a TTY.
- The script carries no env: it's saved in the database and shown in
  the output, and profile env can hold tokens. Copilot's sign-in doesn't
  depend on env.
- On Unix the program and args are shell-quoted, so paths with spaces
  work.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A login script waiting for a device code printed "visit <url> and enter
code <code>" only to its logs, so the conversation showed just
"Tool Install Script - Running".

While a script runs, its output is now checked for a link and a code on
the same line (parseDeviceCode, not agent-specific). If both are there,
a card under the script shows the code and a "Copy code and open <host>"
button. The button copies the code in the user's browser, then opens the
page, and only then says the code was copied. A CLI's own copy lands on
the backend's machine, which isn't the user's when it runs remotely.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
In device-code mode Copilot opens the sign-in page on the backend's
machine, which took the user away before they saw the code card. The
login script now runs with BROWSER=true (Copilot honours BROWSER, and
`true` does nothing), so the user stays in the conversation and opens
the page from the card. Unix only; Windows keeps Copilot's default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Option discovery opens a throwaway session with session/new, so a
signed-out agent fails it with -32000 too. The model selector then
showed the agent's message plus the last stderr line. It now shows
"Not signed in. Start a task and click Sign in." instead. The text is
agent-agnostic, and the failure is still not cached. A Unix test runs
run_live against a fake sh agent that rejects session/new with -32000.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Registry agents share the discovery code but don't get SetupHelper, so
"Start a task and click Sign in." sent their users to a button that never
appears. The model selector now says "Not signed in to this agent."

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
parseDeviceCode ran on every running script, including the user's own
setup and cleanup scripts, so a line with a link and something like a
request ID or ticket key (ABCD-1234) could show "Enter this code to sign
in" with a button opening that link. Only the app's own install/login
scripts run as Tool Install Script, so the card now needs that too. The
parser stays generic.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot sends `auto` twice: as its own entry and again in the model list.
We kept both, so the selector showed Auto twice. Keep the first choice for
each value, and drop repeats from lists already saved in the disk cache.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Discovery runs once per stream connection, and a failure is kept for 30s,
so after signing in the selector kept showing "Not signed in" and the old
list until the page was reloaded.

- When a run opens a session, forget the agent's failed discovery: the
  agent works now. Copilot and registry agents pass their discovery key.
- When the dropdown opens while it shows an error, reconnect the stream
  so discovery runs again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@anastasiya1155
anastasiya1155 merged commit 2d03b13 into main Nov 11, 2026
6 of 7 checks passed
@anastasiya1155
anastasiya1155 deleted the feat/copilot-sign-in branch November 11, 2026 11:10
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.

1 participant