Repository navigation
fix(tui): show tool details for replayed history messages - #546
Merged
Merged
Conversation
Reopening a session rendered tool calls as their raw call id (`call_00_...`) instead of the usual `read <path>` / `$ <cmd>` form. `apply_messages` picked the display name and arguments from the first `tool_call | tool_result` block. In a session history the tool entry is a `tool_result` block, which carries only `toolCallId` — the name and arguments live on the paired `tool_call` block in the preceding assistant entry. With `name` unset, `render_tool_message` fell back to `msg.name.or(msg.tool)`, i.e. the call id. Live streaming never hit this because `tool_start` events carry `tool_name` / `tool_args` directly. Index the `tool_call` blocks by call id first, then resolve a replayed tool message's name and arguments through its `toolCallId`. Also avoid double-encoding arguments that already arrive as a JSON string.
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.
Problem
Reopening a session in the TUI rendered every past tool call as its raw call id —
call_00_xxxxxxxx— instead of the usualread <path>/$ <cmd>/write <path>form.Root cause
apply_messages(theget_messagesreplay path) resolved a tool message's display name and arguments from the firsttool_call | tool_resultblock:In a persisted history the tool entry is a
tool_resultblock, which carries onlytoolCallId—nameandargumentslive on the pairedtool_callblock in the preceding assistant entry (MessageBlock::from_modelinpackages/rpc). Withnameunset,render_tool_messagefell back tomsg.name.or(msg.tool), i.e. the call id. This only affected history; live streaming is fine becausetool_startevents carrytool_name/tool_argsdirectly.Fix
Index all
tool_callblocks bytoolCallIdup front, then resolve a replayed tool message's name/arguments through its call id, falling back to the block's own fields when present. Also stops double-encoding arguments that already arrive as a JSON string (Value::to_stringon aValue::String).Tests
Extended
welcome_variants_and_messageswith a pairedtool_call+tool_resulthistory and asserted the rendered frame containsread /tmp/notes.txtand no bare call id.cargo test -p future-tui— 842 + 5 passedcargo fmt -p future-tui --check,cargo clippy -p future-tui --all-targets -- -D warnings— clean