Repository navigation
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4459 +/- ##
=======================================
Coverage 92.43% 92.44%
=======================================
Files 366 366
Lines 12688 12700 +12
Branches 3457 3460 +3
=======================================
+ Hits 11728 11740 +12
Misses 838 838
Partials 122 122 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
c02fc99 to
95f464f
Compare
#### Which problem is this PR solving? jaegertracing#4425 gave each message its own collapse toggle, which covers the case where the reader already knows which message is in the way. It left no way to act on the section as a whole: returning a folded conversation to normal means expanding message after message, and folding a long one means the work scales with the size of the problem. Part of jaegertracing#4427. #### Description of the changes The Conversation section header gains a Collapse all / Expand all pair, shown once there are at least two messages for it to act on. Below that the message's own toggle already is the pair. Both controls are absolute: each writes every message, so the section afterwards is entirely folded or entirely open rather than partly either. Making that possible moves the folded flag out of MessageBlock and into ConversationDetails, held as a record keyed by the key each row already carries (system, input-N, output-N). A message still owns its toggle, it just no longer owns the answer, so the section's control and the per-message button cannot disagree. MessageBlock's button, its aria-expanded contract and its collapsed preview branch are otherwise unchanged. The record is seeded in a lazy initializer rather than an effect. The messages array is rebuilt on every render, so an effect keyed on it would refire on each new array identity and discard whatever the reader had folded. Neither bulk control reports aria-expanded. Neither owns a region of its own, and a third expandable button would also make the per-message expanded counts ambiguous to a screen reader. Nothing is persisted. The state lives with the mounted tab, the same as the per-message toggle and the format choice beside it. Left out deliberately, and still open in jaegertracing#4427: any size threshold or auto-collapse for a long conversation. That needs a decision about what counts as long and which messages should start folded, and it is a separate change. #### How was this change tested? Five tests added to the existing collapsing block: collapse all folds every message, expand all opens every message including ones folded individually, an individual toggle still works after each bulk action, and the pair is absent for a single-message conversation. The existing per-message assertions, which count buttons by aria-expanded, still hold unchanged. Full suite 3822 passing across 280 files, up 5 from 3817 on main. oxlint exits 0 with the same 311 pre-existing warnings, and tsc-lint is clean. Claude-Session: https://claude.ai/code/session_01WPkifMsD3qrCAjZ5gLidPZ Signed-off-by: Utkarsh Bahuguna <utkarshbahuguna10@gmail.com>
Lifting the folded state into ConversationDetails made the two sets of controls agree, at the cost of turning a chevron click into a re-render of every message in the conversation: the section re-renders, the message list is rebuilt, and each MessageBlock re-serializes its JSON and recompiles its Markdown for a fold it had no part in. On a conversation of 40 messages averaging 20KB that is the whole transcript per click, and again per Collapse all. Memoize the list so the message objects keep their identity, memoize each message's JSON, and wrap MessageBlock in React.memo. The callbacks now take the message's key rather than closing over it, so they stay stable across a re-render and the memo actually holds. No behavior change; the collapse tests cover it unchanged. Signed-off-by: Utkarsh Bahuguna <utkarshbahuguna10@gmail.com>
Collapse all and Expand all took --text-muted from the labels next to them, but a label is read where a control is used. That token is half-transparent text, roughly 3.2:1 over the panel, so at 12px the two controls sat under the 4.5:1 AA threshold until hovered - and hover is a state a keyboard or touch reader never reaches. Use --text-secondary, which keeps them visibly secondary to the heading without resting below AA. Signed-off-by: Utkarsh Bahuguna <utkarshbahuguna10@gmail.com>
e4a8e5e to
c103ec5
Compare
|
Rebased onto The one conflict was in Verified on the rebase: |
Which problem is this PR solving?
#4425 added per-message collapse toggles, but there was no way to collapse or expand the whole conversation at once. For longer conversations, that meant clicking through every message.
Part of #4427.
Description of the changes
The Conversation header now has Collapse all / Expand all controls when there are at least two messages.
The bulk controls and per-message toggles all update the same state, so they can't get out of sync. The collapsed state was also moved from MessageBlock into ConversationDetails, keyed by the existing message keys (system, input-N, output-N).
The initial state is set with a lazy initializer instead of an effect. Since the messages array gets recreated on each render, using an effect here would reset the collapsed state unnecessarily.
The bulk buttons don't use aria-expanded since they don't control a single region. The existing per-message accessibility behavior stays unchanged.
Nothing is persisted. The state only lasts for the mounted tab, same as the existing collapse state and format choice.
Auto-collapsing long conversations is intentionally left out for #4427. That needs a separate decision on what counts as "long" and which messages should be collapsed.
How was this change tested?
Added 5 tests covering:
Full suite: 3822 passing across 280 files (3817 on main).
oxlintexits 0 with the same 311 pre-existing warnings, andtsc-lintis clean.