emrg: gui — fix cross-round tool/text ordering (tool-after text shown above tool) - #1081
Merged
Merged
Conversation
… above tool) (rant 2026-08-31T12:30:33)
Collaborator
|
I tested this PR against the root cause and the surrounding state machine, and found the analysis and fix consistent. |
argszero
commented
Aug 31, 2026
argszero
left a comment
Owner
Author
There was a problem hiding this comment.
✅ LGTM — cycle (1/3)
Reviewed head 4acdb30 against master:
- Root cause confirmed:
handleToolStartseals the text segment but leavesgroupIndex[rid]pointing at the old entry, so the nexthandleDeltaappended post-tool text above the tool row. - Fix is sound: when the active segment is
sealed,handleDeltacreates a newAssistantEntryat the entries tail and updatesgroupIndex[rid], so post-tool text renders after the tool row — matching the TUI arrival order (text1 → tool → text2). - Tests: single interleave asserts
[assistant, tool-row, assistant]ordering; new multi-tool interleave test covers A1→T_A→A2→T_B→A3 plushandleDonestopping typing on the latest entry only. 17/17 pass on the PR head. - CI: test + test-windows both green (run 33357781074); mergeable_state clean.
argszero
commented
Aug 31, 2026
argszero
left a comment
Owner
Author
There was a problem hiding this comment.
✅ LGTM — cycle (2/3)
Head 4acdb30 unchanged since LGTM 1/3; CI double-green (test + test-windows, run 33357781074); mergeable_state clean. Diff re-verified: the sealed-segment branch in handleDelta pushes a new AssistantEntry at the entries tail and updates groupIndex[rid] — post-tool text renders after the tool row, matching TUI arrival order. Transcript suite 17/17 green on the PR head.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a GUI transcript ordering regression (rant 2026-08-31T12:30:33): text produced after a tool call was displayed above the tool row instead of below it (「文本→工具」 ordering instead of 「工具→文本」). The TUI has no such issue and serves as the control.
Root cause
In
emrg/gui/renderer/src/lib/transcript.ts,handleToolStartseals the current text segment and appends the tool row toentries, but does not updategroupIndex[rid]. The nexthandleDeltatherefore looks up the old sealed entry and appends the new text there — placing post-tool text above the tool row.Fix
handleDeltanow detects when the active segment issealedand routes the new text to a new entry positioned after the tool, updatinggroupIndex[rid]accordingly. Existing test updated to assert the new behavior; a multi-tool interleave test added.Verification
tsc --noEmitclean