Skip to content

emrg: gui — fix cross-round tool/text ordering (tool-after text shown above tool) - #1081

Merged
argszero merged 1 commit into
masterfrom
feature/gui-tool-text-cross-round-order
Aug 31, 2026
Merged

emrg: gui — fix cross-round tool/text ordering (tool-after text shown above tool)#1081
argszero merged 1 commit into
masterfrom
feature/gui-tool-text-cross-round-order

Conversation

@argszero

Copy link
Copy Markdown
Owner

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, handleToolStart seals the current text segment and appends the tool row to entries, but does not update groupIndex[rid]. The next handleDelta therefore looks up the old sealed entry and appends the new text there — placing post-tool text above the tool row.

Fix

handleDelta now detects when the active segment is sealed and routes the new text to a new entry positioned after the tool, updating groupIndex[rid] accordingly. Existing test updated to assert the new behavior; a multi-tool interleave test added.

Verification

  • Renderer vitest: 480/480 (was 479) — transcript suite 17 tests (was 16)
  • tsc --noEmit clean
  • Python pytest: 1179 passed + 1 skipped
  • GUI npm: 87 pass + 8 skip (95 total)
  • Agent.md test counts synced (renderer 479 → 480)

@pm25coder

Copy link
Copy Markdown
Collaborator

I tested this PR against the root cause and the surrounding state machine, and found the analysis and fix consistent.

@argszero argszero left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

✅ LGTM — cycle (1/3)

Reviewed head 4acdb30 against master:

  • Root cause confirmed: handleToolStart seals the text segment but leaves groupIndex[rid] pointing at the old entry, so the next handleDelta appended post-tool text above the tool row.
  • Fix is sound: when the active segment is sealed, handleDelta creates a new AssistantEntry at the entries tail and updates groupIndex[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 plus handleDone stopping 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 argszero left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

✅ 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.

@argszero argszero left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

✅ LGTM — cycle (3/3)

Head 4acdb30 unchanged since LGTM 1/3 and 2/3; CI double-green (test + test-windows, run 33357781074); mergeable_state clean. Three consecutive LGTMs from distinct cycles, no ❌. Merging.

@argszero
argszero merged commit 1fdc606 into master Aug 31, 2026
2 checks passed
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.

2 participants