Repository navigation
Terminal: find in output, clear display, copy/send selection to composer - #1638
Conversation
…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]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 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); |
There was a problem hiding this comment.
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 👍 / 👎.
| kind: "terminal", | ||
| text, |
There was a problem hiding this comment.
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 👍 / 👎.
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)findMatch(lines, query, from, back)function, so it can be tested without xterm.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-searchhandles both if that ever matters.Clear
Copy / To composer
onSelectionChangeonXtermLike.terminalcontext chip beside the thread's draft, so you can review it before sending. It only ever sends the selection, never the whole buffer.TerminalPaneaccepts a new optionalonAddToPromptprop and passes it to each split.ThreadViewwires it tosetContextChipsand leaves it out for archived threads, which hides the button there.Status messages
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.cssadds styles for the find bar, its input and the floating status.Tests
test/terminalPane.test.tsxadds 127 lines of tests covering the new terminal actions.🤖 Generated with Claude Code