feat(streaming): collapse old interim progress notes after 3 visible (#2403)#3574
feat(streaming): collapse old interim progress notes after 3 visible (#2403)#3574rodboev wants to merge 1 commit into
Conversation
|
| Filename | Overview |
|---|---|
| static/messages.js | Adds interim-note collapse logic inside the interim_assistant SSE handler: marks each rendered block with data-interim="1", hides all but the last 3 via interim-collapsed, and inserts a Show N earlier updates toggle. The expanded-state guard (toggle.dataset.expanded) correctly prevents the user's expand action from being reverted on subsequent events. |
| static/style.css | Adds 11 lines for .interim-collapsed { display:none }, .interim-collapse-toggle (cursor, color, font-size, margin, display), and a :hover underline rule — clean, self-contained, no conflicts. |
| tests/test_issue2403_interim_collapse.py | 14 static-analysis tests across two classes verifying structural invariants (constant presence, attribute marking, collapse class, toggle creation, ordering of attribute-set vs flush vs reset) and CSS rule existence; follows the existing static-analysis pattern in the repo. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[interim_assistant SSE event] --> B{alreadyStreamed?}
B -- yes --> C[flush + finalize, no collapse]
B -- no --> D[push to visibleInterimSnippets\nensureAssistantRow\nset data-interim=1]
D --> E[_flushPendingSegmentRender]
E --> F{visibleInterimSnippets.length\n> THRESHOLD=3?}
F -- no --> G[recordActivityBoundary\n_resetAssistantSegment]
F -- yes --> H[query all data-interim blocks\ncompute toHide = all except last 3]
H --> I{.interim-collapse-toggle\nalready exists?}
I -- no --> J[create toggle span\nattach click handler\ninsert before toHide 0]
I -- yes --> K{toggle.dataset.expanded?}
J --> K
K -- expanded=1 --> L[skip re-collapse\nstillHidden=0\nleave toggle as Collapse]
K -- not expanded --> M[add interim-collapsed to toHide\nupdate toggle text to Show N earlier updates]
L --> G
M --> G
Reviews (6): Last reviewed commit: "feat(streaming): collapse old interim pr..." | Re-trigger Greptile
|
Heads-up: #3401 (live-to-final assistant reply redesign) shipped in v0.51.294, and we're now at v0.51.301. This PR (#2403 (collapse interim progress notes)) is on a stale base and no longer applies cleanly onto current #3401 reworked how interim process prose is rendered (folded Worklog model), so the 'collapse after 3 visible' logic needs to target the new structure. Could you rebase onto current |
Cluster review re-confirm (#3400 live-to-final) — rework (rebase), NOT supersededRe-checked this against current
No action needed beyond a rebase onto current |
bb5c5e4 to
acc6c48
Compare
|
Rebased onto current
Focused verification I ran for this localized rework:
This should be ready for the fresh re-gate you mentioned. |
…3574) (#3848) * feat(streaming): collapse old interim progress notes after 3 visible (#2403) * fix(streaming): delegated handler for interim-collapse toggle survives live-turn restore The interim-collapse toggle attached its click listener via per-element addEventListener at creation time. snapshotLiveTurnHtmlForSession / restoreLiveTurnHtmlForSession rebuild the live turn via outerHTML/innerHTML on session switch, which strips JS listeners — so a restored toggle was visible but inert and the collapsed interim notes became permanently unreachable for the rest of the turn. Replace with a stateless document-level delegated click handler (_interimCollapseDelegatedClick) that resolves the toggle via closest(), reads state from the DOM (.interim-collapsed) + data-threshold, and works on both freshly-created and innerHTML-restored toggles. Add 4 regression tests pinning the delegated-handler contract. Co-authored-by: rodboev <rodboev@users.noreply.github.com> * Release v0.51.333 — Release KW (collapse old interim progress notes, #3574) Collapse old interim progress notes after 3 visible during a live turn (#3574, @rodboev). Maintainer fix during re-gate: replaced the per-element toggle listener with a stateless document-level delegated handler so the toggle survives the live-turn DOM restore (Codex caught: innerHTML rebuild dropped the listener → collapsed notes unreachable). Full suite 8303, ESLint/scope-undef CLEAN, Opus SHIP-safe, Codex SAFE-TO-SHIP after fix, collapse + manual-expand-guard + restore-path delegated handler all live-verified. Co-authored-by: rodboev <rodboev@users.noreply.github.com> --------- Co-authored-by: Rod Boev <rod.boev@gmail.com> Co-authored-by: Hermes Agent <hermes-agent@nesquena-hermes.local> Co-authored-by: rodboev <rodboev@users.noreply.github.com>
|
Shipped in v0.51.333 (Release KW) via #3848 — thanks @rodboev! 🎉 I deep-reviewed this (Opus + Codex + live browser drive against master), rebased it onto current master, and shipped it with one fix. What landed: once more than 3 interim progress notes accumulate during a live turn, the older ones collapse behind a "Show N earlier updates" toggle so the latest note stays in view. Manual expansion is sticky — new interim events won't re-hide what you opened (I verified this live: 5 interims → 2 hidden; expand → 0 hidden; new interim while expanded → stays open). Fix I added (Codex catch): the toggle attached its click listener via per-element Gate: full suite 8303 passed, ESLint runtime + scope-undef + ruff clean, Opus SHIP-safe, Codex SAFE-TO-SHIP (after the fix), CI 11/11 green. Co-authored to you. |
Thinking Path
\n\nseparators for readability, but this increased vertical consumption on long tool-heavy turns.What Changed
static/messages.js: after the 4thinterim_assistantevent in a single turn, hide all but the last 3 rendered interim blocks and prepend a "Show N earlier updates" toggle. Clicking the toggle reveals all hidden blocks and switches to a "Collapse" toggle. Usesdata-interim="1"attribute marking and a namedINTERIM_COLLAPSE_THRESHOLDconstant.static/style.css: ~11 lines for.interim-collapse-toggleand.interim-collapsedclasses.tests/test_issue2403_interim_collapse.py: 14 static-analysis tests across 2 classes (handler structure invariants and CSS rule assertions).Why It Matters
Long tool-heavy turns with 6+ interim progress notes scroll the final answer off-screen on 14" laptops and smaller. Collapsing old notes to a summary line recovers the vertical space while keeping all notes accessible via expand.
Verification
Manual: trigger a long tool-heavy turn (e.g., a multi-step agent task). After the 4th interim progress note, verify that earlier notes collapse into an "N earlier updates" link, and clicking the link expands them.
Risks / Follow-ups
\n\nto\nin Activity groups) is orthogonal and could be done separately.Model Used
Claude Opus 4.8 via Claude Code CLI
Closes #2403