Skip to content

Take a pasted MCP sign-in return in the TUI - #2279

Open
fazxes wants to merge 4 commits into
mainfrom
fazxes/paste-mcp-sign-in-return
Open

fazxes wants to merge 4 commits into
mainfrom
fazxes/paste-mcp-sign-in-return

Conversation

@fazxes

@fazxes fazxes commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • /mcp login in the TUI finishes a sign-in when you paste the address the browser ends on into the composer and press Enter, from a typed /mcp login or the /mcp menu. Before, only fx mcp login took a pasted return, from its own stdin loop, which the TUI can't use because the composer owns the terminal. So a TUI sign-in from a sandbox or over SSH timed out.
  • A pasted return is matched against the waiting sign-in and the last 8 that ended or were replaced, by redirect and state. A match never reaches the model, a slash command, or the prompt history, including a long one that the composer folds into a paste block. A return older than that list is treated as ordinary text. fx keeps the ended and replaced sign-ins because a person often pastes after the browser came back on its own, after a timeout, or after starting the sign-in again, and those returns would otherwise go on as a prompt.
  • fx sends a matched return on only when its sign-in is the newest for its server, because the runtime keeps one login per server and an older return would fail the newer sign-in. Otherwise it says the address is for an earlier sign-in. A return for another state stays in the composer with a warning, a repeated one says it is already finishing, and a failed one says why.
  • When fx can't open a browser, the waiting sign-in says it takes a pasted return, in the transcript and on the /mcp server screen.
  • The finish runs in a job off the UI thread, like /mcp commands, because Runtime.finishLogin waits on the host's owner thread. The job holds its own reference to the host sink, so the sink outlives destroyHost while the job runs.
  • Like VerbJob, the paste job still uses the shell's MCP state while it runs, and destroyHost waits for it at most 5 s. Fixing that for both jobs is a separate change.
  • fx-term.wasm's size budget grows to 4,290,000 bytes. The TUI code lands in it, and with main's own raise to 4,276,000 it measures 4,279,997 bytes.
  • app_mcp_runtime.zig and mcp_host_menu_presentation.zig are now in the root test block. Their tests never ran in zig build test before.
  • The new Zig tests wait for the paste job through host_verbs, the counter the exit path waits on, polled with a 2 s deadline. The job has no other signal to wait on.

Docs

fx.sh/docs/capabilities/mcp, the paragraph that starts "On a machine without a browser": replace it with

On a machine without a browser, such as over SSH or in a sandbox, open the sign-in address on any device. When the browser ends on a page that can't be reached, copy its address and paste it into fx, or run fx mcp login --no-browser prisma and paste it there.

When the browser can't reach fx's loopback listener, as in a sandbox or
over SSH, `/mcp login` in the TUI now finishes with the address the
browser ends on, pasted into the composer. It works from a typed
`/mcp login` and from the `/mcp` menu, the same way `fx mcp login`
already reads a pasted address from stdin.

The return is matched against the waiting sign-in's redirect and state,
and it never reaches the model, a slash command, or the prompt history,
including a long paste that the composer folds into a block. When fx
can't open a browser, the waiting sign-in says it takes a pasted return.

app_mcp_runtime.zig and mcp_host_menu_presentation.zig join the root
test block, so their tests run in zig build test.
@fazxes fazxes added the type: improvement Improves existing user-facing behavior label Nov 24, 2026
@vercel-internal-security-reviewer

Copy link
Copy Markdown

Security review details

A return pasted after its sign-in ended went on as a prompt. fx now keeps
the last sign-in that ended and answers such a paste with a notice. A
return pasted twice says the sign-in is already finishing, and a paste
that can't finish says why. The paste hint is defined once, in menu.zig.
fx keeps the last 8 sign-ins, including one another sign-in replaced,
and sends a pasted return on only when its sign-in is the newest for
its server, since the runtime keeps one login per server and an older
return would fail the newer one. A paste job clears only its own
sign-in's flag, and its failure notice says what went wrong.

The paste job holds its own reference to the host sink, so the sink
outlives destroyHost while a job still runs. The same sign-in posted
again keeps its paste.

fx-term.wasm's budget grows to 4,270,000 bytes for the new TUI code.
@fazxes
fazxes marked this pull request as ready for review November 24, 2026 22:26
main raised fx-term.wasm's budget to 4,276,000 for its own code. With
both changes, fx-term.wasm measures 4,279,997 bytes after optimize, so
the budget is 4,290,000.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: improvement Improves existing user-facing behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant