Skip to content

fix: commands you put in the terminal send their output back to the agent - #621

Merged
badcuban merged 1 commit into
mainfrom
fix/put-in-terminal-output
Oct 23, 2026
Merged

badcuban merged 1 commit into
mainfrom
fix/put-in-terminal-output

Conversation

@badcuban

Copy link
Copy Markdown
Collaborator

When an agent asked you to run a command and you used Put in terminal and pressed Enter, the output never went back to the agent. The card stopped following the command at Enter (status submitted), and only Run sent output back by itself.

What changed

  • The terminal follows an entered insert to its end (apps/server/src/terminal/Layers/Manager.ts, FollowedInsert). The run goes running → finished (no exit code, since a shell doesn't report one), with the tab's output from the insert up to the prompt that came back.
    • PowerShell: its prompt marker ends it.
    • POSIX shells that switch bracketed paste: when the line editor comes back on after Enter, a fresh process table read checks that the shell is the terminal's foreground job again (+ in its ps state). A REPL, ssh or nested shell in front keeps it going; a job left in the background doesn't.
    • A builtin waiting for input (read) isn't ended by idle polls. A line typed ahead ends it at the first prompt only when the shell takes that line right away (an ssh password doesn't count).
    • Shells that never report their line editor fall back to idle polling. Shell exit, restart or close end it as interrupted, keeping its output.
  • Request cards send output by themselves in both modes (CommandRuns.ts), behind a new capability followsInsertedCommands, so newer clients only promise it to servers that do it. Agent-facing tool text updated.
  • Card UI (CommandRuns.tsx): "fx gets the output when it finishes" on insert cards; a finished insert reads "Ran in Terminal 1 · 3s" with no pass/fail dot. "Send output so far" now shows for a running command that would send by itself, Run included, since a dev server never finishes.
  • Thread move: a submitted run is final and no longer counts as live work, which blocked moving a thread forever.
  • Docs: docs/terminal-command-runs.md, including the known limits (read -e/vared, shells without job control, a command started within the moment of the process check).

Testing

  • New terminal tests for each rule (prompt with shell in front, REPL in front, read, typed ahead with output cut at the prompt, ssh password, PowerShell marker). Each guard was broken on purpose to confirm a test fails without it.
  • Real zsh through node-pty and real ps: normal command, cd, nested shell, background job, read, typed ahead, tab closed mid-command.
  • End to end in a throwaway app with a stand-in agent: card → Put in terminal → Enter → the agent got the output as the next turn.
  • vp fmt, vp lint, vp run typecheck; full server (3,312), web unit (2,991), shared (531), contracts (109) suites, plus the CommandRuns and ChatMarkdown browser tests.
  • Not tested live: Windows/PowerShell (unit test only).

…gent

An agent's "Put in terminal" card stopped tracking the command when the user
pressed Enter, and only Run sent output back by itself, so nothing ever reached
the agent.

The terminal now follows an entered insert until the command it started ends:
PowerShell's prompt marker, or a POSIX shell's line editor coming back on while
a fresh process table shows the shell in front of its terminal again (`+` in
its ps state, so a REPL, ssh or nested shell keeps it going and a background job
doesn't). A builtin waiting for input isn't ended by idle polls, a line typed
ahead ends it at the first prompt, and the output stops where that prompt began.
Request cards now send their output by itself in both modes, behind a new
`followsInsertedCommands` capability. "Send output so far" shows for running
commands that would send by themselves, and an old "submitted" run no longer
blocks moving a thread.
@vercel

vercel Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
threadlines Ready Ready Preview Oct 23, 2026 9:06pm UTC

Request Review

@badcuban
badcuban added this pull request to the merge queue Oct 23, 2026
Merged via the queue into main with commit d0a63dc Oct 23, 2026
21 checks passed
@badcuban
badcuban deleted the fix/put-in-terminal-output branch October 23, 2026 21:17

This branch was successfully deployed

1 active deployment
Preview — 47ecaa1e Deployed Oct 23, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant