Skip to content

feat(tui): click rail rows and copy transcript selections with OSC 52 (ENG-1072) - #363

Closed
lg2m wants to merge 34 commits into
feat/eng-1071-tui-one-placefrom
feat/eng-1072-tui-select-copy
Closed

lg2m wants to merge 34 commits into
feat/eng-1071-tui-one-placefrom
feat/eng-1072-tui-select-copy

Conversation

@lg2m

@lg2m lg2m commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator

F6: click rail rows and copy transcript selections with OSC 52

Spec: docs/plans/tui-focus.md#f6-clickable-rail-and-scoped-selection Linear: ENG-1072 (parent ENG-1067)
Stacked on #360.

What changed (user-visible)

  • Select and copy just the output. With mouse capture on, a drag in the transcript selects only the transcript pane's text — never the sidebar, inspector, borders, top row or composer, however far the pointer goes. Selected cells repaint on the selection background. Release copies to the system clipboard via OSC 52 (Codex's approach) and the rule reads copied N lines. Rows are copied without the measure inset or trailing spaces. Esc, any key, the wheel, a resize or a new press clears it; a click without a drag copies nothing. /mouse and Shift-drag still give native terminal selection.
  • Clickable rail. A left click on a session or agent row focuses it; headers and +N rows do nothing.

Design

  • src/selection.rs: FrameGeometry (transcript area, rail area, per-row click target), committed by the renderer like pane state; Selection is screen-anchored and clamped to the pane; paint runs after composition so no transcript cache sees it and frames with no selection pay nothing; text reads the last drawn frame; MAX_COPY_BYTES (1 MiB) bounds a copy.
  • sidebar returns RailFrame { rows, named, targets }.
  • Effect::CopySelection: the terminal loop resolves the text against FrameRenderer::last_frame, writes ESC ] 52 ; c ; <base64> BEL, and the app reports the count.
  • base64.workspace = true added to crates/qq-tui/Cargo.toml (already pinned in the workspace and in Cargo.lock; no new crate).
  • Rejected: per-message offsets (would touch the width-keyed caches and streaming hot path); pasting through an external clipboard helper (blocking, platform-specific).

How verified

  • cargo nextest run -p qq-tui: 418 passed. New: 6 selection::tests (pane-only text and inset, presses outside the pane, paint restyles only selected cells, 1 MiB bound, rail hit-testing, OSC 52 bytes); clicking_a_rail_row_focuses_that_session_or_agent, a_drag_in_the_transcript_selects_only_its_text_and_copies_it_on_release, a_click_without_a_drag_selects_and_copies_nothing; loop test a_drag_in_the_transcript_writes_its_text_to_the_clipboard_with_osc52 (asserts ESC]52;c;Y29weSBtZQ==BEL for "copy me" and the copied 1 line notice).
  • cargo xtask lint ok; clippy -D warnings clean for qq-tui; cargo xtask smoke: 8 passed. The Cargo.toml line widens cargo xtask check to the full workspace; that run's evidence follows in a comment.
  • Goldens unchanged.

Measurements

Same-host back-to-back A/B vs #360 (raw: target/qq-perf/tui-focus-F6-2026-10-18/{before,after}-ab.txt; load ≈16–20):

Gate Before After
steady_state_frame 22.5 µs 21.9 µs
steady_state_with_sidebar 34.3 µs 33.8 µs
streaming_focused 35.7 µs 35.2 µs
children_20_with_sidebar 54.3 µs 52.8 µs
golden_path_first_minute 40.6 µs 39.8 µs
sessions_200_with_sidebar 30.6 µs 30.4 µs

Docs

  • docs/guide/tui.md § Mouse: click, select, copy; docs/design/layout.md § Mouse; ledger receipt.

Compatibility

  • PROTOCOL / DESCRIPTOR / schema: unchanged. Cargo.lock unchanged.

lg2m added 2 commits October 18, 2026 22:26
… (ENG-1072)

Slice F6 of docs/plans/tui-focus.md. With mouse capture on, a drag selects only the transcript pane's cells (never the rail, inspector or chrome), paints them, and copies the text on release via OSC 52; clicking a rail row focuses that session or agent.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 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-20T08:15:15.582874Z c9a7869 New commits
ℹ️ 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.

@lg2m

lg2m commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@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: 044fd386bc

ℹ️ 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/view.rs Resolved
Comment thread crates/qq-tui/src/app.rs Resolved
Comment thread crates/qq-tui/src/selection.rs Resolved
Comment thread crates/qq-tui/src/app.rs Resolved
Comment thread crates/qq-tui/src/view.rs Resolved
@lg2m
lg2m added this pull request to stack #357 October 19, 2026 06:20
lg2m added 2 commits October 18, 2026 23:20
…ect-copy

# Conflicts:
#	docs/plans/progress/tui-focus.md
…ainst the drawn frame (ENG-1072)

Plan acceptance from the third #354 review. Merges the F1-F5 review fixes.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

1 similar comment
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@lg2m

lg2m commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

An unknown error occurred
ℹ️ 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 commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

An unknown error occurred
ℹ️ 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".

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

1 similar comment
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@lg2m

lg2m commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

An unknown error occurred
ℹ️ 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".

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@lg2m

lg2m commented Oct 19, 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: 855d073f8f

ℹ️ 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/app.rs Resolved
lg2m added 3 commits October 19, 2026 10:21
…tale selections (ENG-1072)

Addresses Codex on #363: copy strips only the pane margin, wide/combining characters snap whole, a selection whose rows changed is dropped, Shift/Alt/Ctrl mouse events pass to the terminal, clearing always repaints, a click paints nothing, and the hit map resets on every frame. Merges F1-F5 fixes and v0.1.8 from main.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

1 similar comment
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@lg2m

lg2m commented Oct 19, 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: c6c5a3b4df

ℹ️ 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/wrap.rs Resolved
Comment thread crates/qq-tui/src/selection.rs Resolved
Comment thread crates/qq-tui/src/selection.rs Resolved
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

1 similar comment
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@lg2m

lg2m commented Oct 19, 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: d2d8a26c24

ℹ️ 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
Comment thread crates/qq-tui/src/selection.rs Resolved
Comment thread crates/qq-tui/src/view.rs Resolved
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

1 similar comment
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@lg2m

lg2m commented Oct 20, 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: bbab26ae64

ℹ️ 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 added 2 commits October 19, 2026 20:54
…ect-copy

# Conflicts:
#	crates/qq-tui/src/render.rs
#	crates/qq-tui/src/view.rs
#	crates/qq-tui/src/view/wrap.rs
… clusters, skip hanging prefixes in copies (ENG-1072)

A cluster's width is the width of the whole cluster (☀️ and 👩‍💻 are two
cells), in wrapping, selection and text_width alike; truncate_line and
preview keep or drop a cluster at the ellipsis whole; a wrapped list item
or quote marks its hanging prefix as chrome so a copy joins without it;
a copy ending on a blank row counts that line.

Addresses the 11th Codex review on #363 and #354.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

1 similar comment
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@lg2m

lg2m commented Oct 20, 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: 4cedc0740e

ℹ️ 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 Outdated
}
_ => out.push((
offset..end,
crate::render::text_width(&text[offset..end]),

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 Account for clusters continued from a prior span

When a grapheme crosses a style-span boundary, the carried Clusters state makes continues true, but this computes the width from only the suffix in the current span. Callers have already counted the prefix, so a split ☀ / ️ undercounts the completed emoji and can emit a row wider than its pane, while a split 👩‍ / 💻 double-counts it and truncate_line can leave the dangling 👩‍ before an ellipsis. Fresh evidence beyond the settled same-span measurement case is this continuation path across spans; carry the completed cluster's width (or its width delta) across the boundary.

AGENTS.md reference: AGENTS.md:L203-L207

Useful? React with 👍 / 👎.

// The hanging indent (and a quote's repeated rail) is
// layout, not text: a copy of the wrapped item joins
// its rows without it.
continuation.chrome = hang.width;

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 Mark the first quote rail as copy chrome

When a selection begins at the pane's left edge on the first row of a blockquote, only continuation rows receive chrome; the index == 0 branch leaves the initial ▎ prefix selectable and Selection::text copies it. This makes a full-row drag copy layout decoration even though blockquote rails are defined as non-text prefixes, so the first-row quote rail needs a chrome boundary as well.

Useful? React with 👍 / 👎.

Comment thread crates/qq-tui/src/app.rs Outdated
self.selection = self.geometry.transcript.and_then(|area| {
crate::selection::Selection::start(area, self.geometry.text_x, column, row)
});
Effects::changed_now(cleared)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Snapshot a new selection on mouse-down

When streamed output arrives after an unmodified left press but before the first drag or frame, cleared is false here, so no immediate redraw records the cells under the press and the selection still has seen == None. The next frame therefore accepts the already-moved text as its baseline, allowing the drag to highlight and copy cells different from those initially clicked. Fresh evidence beyond the settled post-drag stale-frame case is this pre-first-frame window; request an immediate frame when a selection starts or fingerprint the last committed frame at mouse-down.

AGENTS.md reference: AGENTS.md:L203-L207

Useful? React with 👍 / 👎.

lg2m added 5 commits October 19, 2026 22:18
…ect-copy

# Conflicts:
#	docs/plans/progress/tui-focus.md
…ect-copy

# Conflicts:
#	crates/qq-tui/src/view.rs
#	crates/qq-tui/src/view/tests.rs
…il as chrome, fingerprint a selection on press (ENG-1072)

A cluster a style change splits (a span ending in a ZWJ, a selector or
flag half in the next) is measured once at its full width in Line::width,
wrapping, and truncation. A blockquote's first-row rail is skipped by a
copy like its continuation rails. A press fingerprints the frame it landed
on, so output streamed before the first drag or frame drops the selection.

Addresses the 11th Codex review on #363.
…ect-copy

# Conflicts:
#	crates/qq-tui/src/view.rs
#	crates/qq-tui/src/view/wrap.rs

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

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

// The quote rail before the marker is layout too; the
// marker itself is the item's text.
let mut first = prefix.clone();
first.chrome = quote_rail_width(hang.rail);

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 Mark list markers as copy chrome

When a drag starts at the pane's left edge over a Markdown list, this marks only the quote rail as chrome, leaving bullets, task boxes, and ordered-list markers in the copied text. This contradicts the F6 requirement in docs/plans/tui-focus.md:126-127 that list prefixes be dropped; use the complete hanging-prefix width for the first row, as is already done for continuation rows.

Useful? React with 👍 / 👎.

let mut panel = false;
if let Some(line) = lines.get(row) {
wrapped = line.wrapped;
panel = line.chrome > 0;

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 Distinguish blank code rows from panel padding

When a fenced code block begins or ends with an intentional blank source line and the drag spans the panel, every row has chrome > 0, so this classifies the real blank code row as synthetic panel padding. The leading or trailing cleanup then removes the selected newline from the clipboard. Fresh evidence beyond the settled ordinary-blank-row case is that content rows inside a panel share the same chrome marker as its padding; record the padding-row role explicitly instead of inferring it from chrome.

Useful? React with 👍 / 👎.

@lg2m

lg2m commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator Author

Closing in favor of the v0.1.11 TUI plan (ENG-1104, docs/plans/0.1.11.md). This PR's design is carried into section A (ENG-1105: https://linear.app/retsu-ai/issue/ENG-1105), and its unresolved review findings are listed there as required tests. The code will be redone against main, because this stack no longer merges cleanly.

@lg2m lg2m closed this Oct 29, 2026
@lg2m
lg2m deleted the feat/eng-1072-tui-select-copy branch October 29, 2026 04:35
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