Skip to content

Terminal: find in output, clear display, copy/send selection to composer - #1638

Merged
currentbits merged 1 commit into
mainfrom
coder/p2-search-terminal-output-and-send-selec-4997be
Oct 15, 2026
Merged

currentbits merged 1 commit into
mainfrom
coder/p2-search-terminal-output-and-send-selec-4997be

Conversation

@currentbits

Copy link
Copy Markdown
Owner

Adds four actions to the terminal pane's toolbar (#1185), so you can work with shell output without leaving the thread.

What changed

Find (TerminalPane.tsx)

  • A new Find button opens a find bar. Enter searches up from the newest output, Shift+Enter searches down, the ↑/↓ buttons do the same, and Escape or × closes the bar.
  • Matching ignores case and wraps around at either end. Each match is selected and scrolled to the middle of the view. When nothing matches, the pane shows "No matches".
  • The matching logic is a pure, exported findMatch(lines, query, from, back) function, so it can be tested without xterm.
  • Known limits, noted in a ponytail: comment: the search reads one buffer row at a time, so it misses matches that run across a soft wrap, and match positions can be off after wide (CJK) characters. @xterm/addon-search handles both if that ever matters.

Clear

  • Clears what's shown on screen only. The shell, any command it's running, and the main process's scrollback are left alone, so new output isn't shown twice.

Copy / To composer

  • Both buttons stay disabled until there's a selection, which is tracked through a new onSelectionChange on XtermLike.
  • Copy writes the selection to the clipboard.
  • To composer adds the selection as a terminal context chip beside the thread's draft, so you can review it before sending. It only ever sends the selection, never the whole buffer.
  • TerminalPane accepts a new optional onAddToPrompt prop and passes it to each split. ThreadView wires it to setContextChips and leaves it out for archived threads, which hides the button there.

Status messages

  • "No matches", "Copied" and "Added to composer" all appear in one role="status" live region. It floats over the pane rather than taking up space in the layout, because a bar that changes size resizes xterm, which drops the selection.

Styles: TerminalPane.module.css adds styles for the find bar, its input and the floating status.

Tests

test/terminalPane.test.tsx adds 127 lines of tests covering the new terminal actions.

🤖 Generated with Claude Code

…1185)

Toolbar on each terminal split. Find scans the retained xterm buffer
(Enter up, Shift+Enter down, Escape closes, reports no matches). Clear
wipes the display only; the shell and its scrollback are untouched.
Copy and To composer act on the selection only and are disabled
without one. To composer adds a typed terminal context chip
(setContextChips, #1526) beside the draft; it never sends or starts a run.

The status live region floats over the screen: in the wrapping bar it
reflowed the layout, xterm refit, and the resize dropped the selection.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-15T15:29:20.358471Z a9faa81 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a9faa81018

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

const find = (query: string, back: boolean) => {
const buf = term.buffer.active;
const lines = Array.from({ length: buf.length }, (_, y) => buf.getLine(y)?.translateToString() ?? "");
last = findMatch(lines, query, last, back);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reset the find cursor when the query changes

The last match is shared across every query, so after finding one term and editing the field to a different term, the first search starts relative to the old term's coordinates rather than from the newest output (or the top for forward search). If the new term has matches on both sides of that stale position, the first result skips the newer matches until the user cycles around; track the query alongside last or clear last whenever the query changes.

Useful? React with 👍 / 👎.

Comment on lines +3853 to +3854
kind: "terminal",
text,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Cap terminal selections before storing context chips

A terminal selection can contain the full 5,000-line scrollback, and this stores that text verbatim even though terminal context is truncated to 8,000 characters when expanded. These raw chips are included in composer-session serialization, but its 1 MB budget only evicts paste cards and history; selecting enough output can therefore make every subsequent localStorage.setItem exceed quota, silently preventing draft and chip updates from surviving a restart. Truncate the selection before adding the chip, as is already done for command-output terminal chips.

Useful? React with 👍 / 👎.

@currentbits
currentbits merged commit ad0de94 into main Oct 15, 2026
6 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.

1 participant