Skip to content

feat(tui): copy exactly what you selected - #522

Merged
lg2m merged 8 commits into
mainfrom
feat/eng-1105-tui-copy
Nov 1, 2026
Merged

lg2m merged 8 commits into
mainfrom
feat/eng-1105-tui-copy

Conversation

@lg2m

@lg2m lg2m commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator

Change

Copy in the TUI now copies exactly what you selected (plan 0.1.11 § A). Closes ENG-1105.

  • QQ runs in the alternate screen. On exit it prints the focused session's last answer, with escapes stripped, followed by the resume line, into normal scrollback.
  • Mouse selection works inside a transcript pane:
    • A drag copies on release. Double-click takes a word; triple-click takes a paragraph, code block or tool output.
    • Text comes from the laid-out rows: rails, gutters, list and quote markers and panel fill are left out, and soft wraps are rejoined. Wide and joined glyphs stay whole.
    • Any key, a new click, a resize, or the rows changing clears the selection. Shift-drag is still the terminal's own selection.
  • The Ctrl-Up/Ctrl-Down cursor now covers prompts, answers, code blocks and tool calls. y copies the block: an answer as Markdown source, code as raw code, a tool call as its command and output.
  • New commands /copy and /copy code. Ctrl-C copies instead of quitting while a selection or the block cursor is active.
  • Clipboard writes:
    • OSC 52 is always sent, with tmux DCS passthrough inside tmux.
    • QQ also tries a local helper (pbcopy, wl-copy, xclip, xsel, clip.exe; none over SSH), then tmux load-buffer -w -, off the event loop with a 1.5 s timeout each.
    • The notice says copied N lines only when a helper confirmed the write. Otherwise it says sent N lines to the terminal clipboard.
    • Copies are capped at 1 MiB and have escape sequences stripped. An empty selection copies nothing and says so.
  • /mouse off hides the sessions column and draws the transcript flush left, so a native row selection is clean. Each state's notice says what it does.
  • Docs: docs/guide/tui.md has a new Copying section and an updated command table; docs/design/layout.md covers the flush pref; docs/design/transcript.md covers row metadata and the block cursor; the QA runbook gains a copy checklist.
  • /copy is added to RESERVED_CLIENT_SLASH_COMMANDS, following earlier additions that did not bump PROTOCOL_VERSION.

Verification

  • cargo nextest run -p qq-tui: 471 passed. New tests cover:
    • selection: chrome per prefix kind, wrap rejoin, wide/ZWJ glyphs, the cap, escape stripping, the clearing rules;
    • the app: drags in both directions, double/triple-click with an injected clock, y on each block kind, /copy, Ctrl-C, /mouse flush;
    • the loop: exact OSC 52 bytes plain and inside tmux, the unconfirmed notice, an empty selection, and mouse capture staying off after the external editor.
  • The review fixes each have a test that failed before the fix: blank code rows in triple-click, code fill beside the sessions column, the code-block index in a truncated streaming answer, the empty selection, and the editor restore.
  • cargo xtask check: passed on fb148ab.
  • Render bench: 8 interleaved, pinned pairs against origin/main (a7a9495). Every gate is within 5%; the worst is wide_160x48_full_frame at +2.3%, and resize_ultra is −12%. The new selection_drag_27_rows_to_frame scene takes 51.5 µs. A first cut was up to 11% slower; callgrind traced that to extra SipHash and allocations from block-range tracking, fixed by reusing the block vector between frames and having tool rendering write ranges straight into it.

Known impact

  • The QA runbook copy checks in real terminals (Ghostty, kitty, WezTerm, Alacritty, GNOME Terminal, Windows Terminal, tmux, SSH) have not been run. The table records them as not run.
  • Exit no longer leaves the last TUI frame in scrollback. The answer and resume line are printed instead.

lg2m added 2 commits October 31, 2026 22:14
Keep the alternate screen and mouse state across the external editor, skip empty selections, keep code-panel fill out of copies beside side columns, take blank code rows into a triple-click block, index code blocks from the end so a truncated live answer copies the right one, and inject the click clock so multi-click tests do not depend on wall time.
@lg2m

lg2m commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 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-11-01T07:19:43.661593Z aa825f3 Manual request
ℹ️ 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: fb148ab758

ℹ️ 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".

Comment thread crates/qq-tui/src/selection.rs Resolved
Comment thread crates/qq-tui/src/app.rs Resolved
Comment thread crates/qq-tui/src/app.rs Resolved
Comment thread crates/qq-tui/src/app.rs Resolved
Comment thread crates/qq-tui/src/terminal.rs Resolved
Comment thread crates/qq-tui/src/view/wrap.rs Resolved
Measure joined graphemes by display width, keep folded tool calls on the block cursor, copy refusals and live tool output, serialize clipboard helper writes so a newer copy wins, and keep the separating space before a long wrapped token.
@lg2m

lg2m commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@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: 7f26d3b633

ℹ️ 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".

Comment thread crates/qq-tui/src/terminal.rs Resolved
@lg2m

lg2m commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@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: a76254f8e4

ℹ️ 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".

Comment thread crates/qq-tui/src/view.rs Resolved
Comment thread crates/qq-tui/src/view/tools.rs Resolved
@lg2m

lg2m commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@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: 3884f3d5fd

ℹ️ 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".

Comment thread crates/qq-tui/src/view/transcript.rs Resolved
Comment thread crates/qq-tui/src/view.rs Resolved
@lg2m

lg2m commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@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: 2808f1e8f4

ℹ️ 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".

Comment thread crates/qq-tui/src/selection.rs Resolved
Comment thread crates/qq-tui/src/selection.rs Resolved
@lg2m

lg2m commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@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: 1be9eee353

ℹ️ 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".

Comment thread crates/qq-tui/src/terminal.rs Resolved
@lg2m

lg2m commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: aa825f3dd3

ℹ️ 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".

@lg2m
lg2m merged commit 4ea44ca into main Nov 1, 2026
11 checks passed
@lg2m
lg2m deleted the feat/eng-1105-tui-copy branch November 1, 2026 07:25
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