Skip to content

fix(native-chat): let the "Asked" row unfold a long question - #22941

Merged
brennanb2025 merged 2 commits into
mainfrom
brennanb2025/native-chat-expandable-ask-row
Sep 27, 2026
Merged

brennanb2025 merged 2 commits into
mainfrom
brennanb2025/native-chat-expandable-ask-row

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​31 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​29
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​55 $\color{#cf222e}{\Huge{\mathbf{−}}}$​7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​48

ELI5

When an agent asks you a question in a chat, the chat keeps a one-line "Asked: …" record of it. A long question was cut off with "…" and there was no way to read the rest. Now, when a question is cut off, you can click the row to show the whole question underneath, where you can read, select and copy it. Click again to fold it back.

What Changed

Before: the "Asked:" / "Awaiting user input:" row always showed the question on one line and cut off anything past the width of the pane.

After: when the question does not fit on the line, the row becomes a button (chevron on hover or keyboard focus). Clicking it shows the full question in a wrapped paragraph under the row and turns the row into "Asked:" with a downward chevron; clicking the row again folds it. A question that already fits stays plain text exactly as before, and a row that only says "N questions" is never a toggle. An opened question stays open when you scroll it out of view and back, and when you answer it.

Mechanism:

  • The full question is drawn in a paragraph below the button, not inside it. Chromium does not select text inside a <button>: a drag or double-click there selects nothing and fires a click, so a question drawn inside the toggle could be read but not copied.
  • NativeChatAwaitingInputRow measures its question (scrollWidth > clientWidth, re-checked by a ResizeObserver while the question sits on the line, the same check the sidebar's truncated labels use) and only offers the toggle when the question is actually clipped.
  • The open/closed state lives in the transcript's existing disclosure store (useNativeChatDisclosure), keyed ask:<message id> from both the tool run and the question receipt, the same way tool runs and tool lines remember their state. The transcript is windowed, so state kept inside the row was lost whenever the row scrolled out of view; the receipt also remounts when the question is answered.

Why

After a question is answered, this row is the only place in the transcript that still shows it, so a question that was cut off could not be read again. Click-to-expand over a tooltip: a tooltip cannot be selected or read comfortably when the question runs to several lines. Body-below-the-toggle over unfolding the text inside the toggle: the text must stay selectable (drag, double-click, triple-click), and keeping it out of the button gives that with a plain native button and no selection special-casing. It is also how the tool-run rows in the same transcript work: a one-line header button with its content below. The cost is that the chevron moves from the end of the clipped line to just after "Asked:" when the row opens. Measuring only the few question rows that are mounted is cheap, and it avoids a toggle that does nothing on a short question, which would also have made that short question unselectable.

Linked Issue

None. Reported directly from a screenshot of a settled Claude question.

Visual Proof

Checked live in a background dev build of this branch (head 24e63adb2a) on a second Mac, with an isolated profile and a seeded Claude transcript. After shots only: before this change the same row is the clipped one-line version with no way to open it.

Clipped question, collapsed, with the chevron on hover:
collapsed hover chevron

Opened: the full question below the header, and a drag-selection inside it that leaves the row open:
opened selection

A question that fits stays plain text with no chevron; an "N questions" row never toggles:
short multi

Keyboard focus shows the ring and chevron:
focus

Still open after scrolling far enough to unmount the row and back:
still open after scroll

The same medium question is plain text in a wide pane and becomes a toggle in a narrow one:
wide narrow

Opened while pending, then still open once the answer lands and the label becomes "Asked:":
pending open still open as Asked

Testing

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

  • NativeChatToolRun.ask-row.test.tsx: a question that fits stays plain text with no button; a clipped question opens below the button (outside it), a click in the opened text does not fold it, and the button folds it back; an opened question stays open across an unmount/remount through the disclosure store, and folding it keeps keyboard focus on the same button; an "N questions" row never toggles.

  • NativeChatResolutionReceipt.test.tsx: a question opened while pending is still open after it is answered.

  • Each new test fails with its mechanism removed (store key dropped, clipping check dropped, remount seed dropped).

  • All native-chat renderer tests pass. pnpm tc:web, check:code-quality:changed (including React Doctor and the design system check), check:react-doctor:changed, check:dead-classes and oxlint on the touched folder pass.

  • In headless Chrome: text inside a <button> selects nothing on drag, double-click or triple-click, and the drag fires a click; the same text outside a button selects normally.

  • Live check in the running app (dev build, background, isolated profile): every scenario shown under Visual Proof passed, covering clipped/open/select/fold, short and multi-question rows staying plain, keyboard (Tab, Enter, Space), scroll-away-and-back, pane resize, and pending to answered.

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Renderer-only presentation change. No wire, SSH or platform-specific behavior. Mobile draws its own row and is unchanged; the shared ask-row copy and subject types are untouched.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

The question row clipped long questions to one line with no way to read
the rest. The row is now a toggle that wraps the full question in place.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ No critical issues — one rough edge worth a look.

Reviewed changes

  • Expandable single-question row — NativeChatAwaitingInputRow now renders a subject.kind === 'question' row as a <button> toggling the text between truncate and whitespace-pre-wrap break-words, with aria-expanded, a hover chevron (group/ask-row), and the same focus ring as the tool-run header; count and subject-null rows stay a plain <div>.
  • Tests — added an unfold/fold test (aria-expanded + truncate class swap) and a "count row offers no toggle" test; the settled-ask header check now targets [data-native-chat-tool-run-state] because the ask row is itself a button.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@coderabbitai

coderabbitai Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

📝 Walkthrough

Walkthrough

Question rows measure whether their text is clipped and show a disclosure toggle when needed. Opening a row displays the full question below the header. Stable disclosure keys preserve open state across remounts and pending-to-resolved receipt updates. Non-question rows remain non-interactive.

Priority: ⬇️ Low

Merge Risk: 🔵 Low · up to 24e63

Screen-reader users may have difficulty distinguishing open question controls. The issue is localized and can be fixed before merge or accepted as a bounded follow-up.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 24e63

Questions remain in the same chat, but their open state now survives row replacement. It is not established whether that state always resets when a different conversation is shown.

Retained concerns

  • Low · security · inferred: If a message-list instance survives a conversation change and a receipt ID is reused, its new question can inherit an earlier question's open state. Provider reset and ID uniqueness have not been established.
Security review details

Security Blast Radius

  • inferred — The plausible exposure is an unexpectedly open question within a reused renderer message-list instance, not transfer of stored question content to another service or data store. Actual cross-conversation reachability is unverified.

Security Findings and Attack Paths

  • inferred — No verified attacker-controlled path to a new authority or sink was identified. Carry-over would require both a surviving store and a reused disclosure ID; neither condition is established for a production conversation switch.

Trust Boundaries and Controls

  • observed — The ask prefix separates question keys from other disclosure keys, while the store retains only boolean state. Those controls do not themselves establish isolation between sessions using the same message ID.

Hardening Proposals

  • proposed — Confirm that the message-list store resets on conversation changes or namespace question disclosure keys by conversation identity, and cover a session switch with a reused receipt ID.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 6 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the main change: allowing the native-chat “Asked” row to expand long questions.
Description check ✅ Passed The description is detailed and covers the user-visible behavior, implementation, rationale, testing, visual proof, scope, and checklist. It does not provide the required linked issue and leaves the A…
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

The first cut put the whole question inside the toggle button, where
Chromium will not select text: dragging or double-clicking in it selected
nothing and toggled the row instead. The open state also lived in the row,
so scrolling the row out of the windowed transcript, or answering the
question, folded it again.

- The full question now opens in a paragraph below the button, outside it,
  so it selects and copies like any other prose.
- The toggle is offered only when the question is actually clipped; a
  question that fits stays plain, selectable text as before.
- Open state is kept in the transcript's disclosure store, keyed by the
  message, so it survives windowing and the pending-to-answered remount.
- The chevron also shows on keyboard focus and on touch screens.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 612ca67f-cde2-4a05-b5ad-ae604f360bbe

📥 Commits

Reviewing files that changed from the base of the PR and between b287726 and 24e63ad.

📒 Files selected for processing (6)
  • src/renderer/src/components/native-chat/NativeChatAwaitingInputRow.tsx
  • src/renderer/src/components/native-chat/NativeChatResolutionReceipt.test.tsx
  • src/renderer/src/components/native-chat/NativeChatResolutionReceipt.tsx
  • src/renderer/src/components/native-chat/NativeChatToolRun.ask-row.test.tsx
  • src/renderer/src/components/native-chat/NativeChatToolRun.tsx
  • src/renderer/src/components/native-chat/NativeChatTranscriptRow.tsx

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

<span className={cn('shrink-0', pending && 'animate-pulse motion-reduce:animate-none')}>
{label}
</span>
{toggles && open ? null : (

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Keep the question in the toggle’s accessible name.

When the row opens, this branch removes the question from the button. Multiple open rows then expose identical “Asked:” buttons to screen-reader button navigation. Give the button a localized accessible name that retains question in both states, while keeping the visible full text outside the button.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ No critical issues — one focus rough edge inline.

Reviewed changes

  • Open below the toggle — NativeChatAwaitingInputRow now draws the full question in a <p> under the row instead of unfolding it inside the button, so the text stays selectable and copyable while the toggle keeps its identity.
  • Measured clipping — the row measures its question (scrollWidth > clientWidth, re-checked by a ResizeObserver) so only a genuinely clipped question becomes a toggle; a question that fits stays plain text.
  • Persistent disclosure — open state moved from local useState into useNativeChatDisclosure, keyed ask:<messageId> from both NativeChatToolRun and NativeChatResolutionReceipt, so an opened question survives windowing remounts and the pending-to-answered remount.
  • Tests — added clipped open/fold, remount persistence, short-question plain-text, and receipt pending→answered persistence cases; the receipt suite drives the real disclosure provider.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

}, [])

const question = subject?.kind === 'question' ? subject.text : null
const toggles = question !== null && (open || clipped)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

An open row stops measuring — the question span and its ResizeObserver unmount while open is true — so clipped goes stale. If the pane grows enough that the question would now fit, folding re-measures clipped as false and swaps the button for a <div> in the same commit; because the fold click is what focused it, the focused button unmounts and focus falls to <body>. I reproduced this with the file's own harness (stub widths to clip, open, widen, fold → activeElement is body), which contradicts the intent noted on line 40.

Technical details
# Focus is lost when a widened question is folded

## Affected sites
- `src/renderer/src/components/native-chat/NativeChatAwaitingInputRow.tsx:61` — `toggles = question !== null && (open || clipped)`; `clipped` is never re-measured while open because the span (and observer) are unmounted.
- `src/renderer/src/components/native-chat/NativeChatAwaitingInputRow.tsx:45-58` — `measureLine` runs only while the span is mounted (i.e. collapsed).

## Required outcome
- Folding an open, previously-clipped question does not move keyboard focus off the control when the question has since stopped being clipped.

## Suggested approach
- Keep the toggle when the row currently holds focus, or re-measure on fold before demoting to plain text, so the swap cannot race the fold click.

## Open questions for the human
- Acceptable as-is given the narrow trigger (pane must widen while the question is open), or worth the guard?

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review status: ready for review

Head: 24e63adb2a. CI is green: 18 passed, 12 skipped, 0 failed.

What changed during review. The first version wrapped the whole question inside the toggle button. Chromium does not select text inside a <button>: a drag or double-click there selects nothing and fires a click. So a long question could be read but not copied. Its open/closed state also lived inside the row, so it was lost whenever the windowed transcript scrolled the row away, and again when the question was answered. The redesign in 24e63adb2a:

  • The toggle only appears when the question is actually cut off. A question that fits stays plain, selectable text, exactly as on main.
  • Opening the toggle shows the full question in a paragraph below the header, outside the button, where it can be selected and copied.
  • The open state is kept in the transcript's existing disclosure store under ask:<message id>, so it survives scrolling away and back, and survives the question being answered.
  • The chevron also appears on keyboard focus.

Review loops. Loop 1 found the three problems above and made the redesign. Loop 2 reviewed the redesign independently and came back clean. That loop checked:

  • the observer lifecycle and cleanup
  • whether the state update in the ref callback could loop
  • resize, font change and explicit newlines
  • whether two rows could share a key
  • the pending-to-answered transition
  • the re-render cost

A separate architecture challenge was not needed, because review converged in two loops without repeated issues.

Readiness checks. Both passed with no P0 or P1 issues. The two P2s from the first check are fixed: text inside the button could not be selected, and short questions got a toggle that did nothing.

Live QA. Run against a background dev build of this head on a second Mac, with an isolated profile. Everything passed:

  • clipped, open, select (drag, double- and triple-click) and fold
  • a question with a newline
  • short and multi-question rows staying plain
  • keyboard (Tab, Enter, Space)
  • scroll away and back
  • pane resize re-measuring
  • pending to answered staying open

Screenshots are in the PR body under Visual Proof.

Known and accepted:

  • Opening moves the question from the header line to a paragraph below it, so the chevron moves from the end of the clipped line to just after "Asked:".
  • A collapsed, clipped question can't be selected until it is opened. Opening it is one click.
  • Keyboard focus is dropped when a folded question now fits, so the toggle disappears. This happens after the pane is widened while the row is open, or when a question opened while pending is folded after it is answered, because "Asked:" is shorter than "Awaiting user input:". Covering it would need a focus guard for a rare path, and a mouse user sees the full question on one line either way.

Not caused by this PR (possible follow-ups):

  • A question row that says "N questions" on the tool-run path doesn't list the individual questions anywhere. The answered receipt does list them.
  • The dev console logs "flushSync was called from inside a lifecycle method" when a transcript first attaches. It comes from the transcript's row virtualizer, which calls flushSync by default. Nothing in this diff calls it, and the count did not change during any ask-row interaction.
  • The floating "Jump to latest" button can cover a transcript line while you are scrolled up.

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