Repository navigation
Claude: show replies to local slash commands - #48
Open
katulevskiy wants to merge 3 commits into
Open
katulevskiy wants to merge 3 commits into
katulevskiy wants to merge 3 commits into
Conversation
Claude Code answers local commands (/usage, /context, /cost, /mcp...) without a model turn: one `<synthetic>` assistant frame carries the text, with no text deltas before it. The normalizer only took text from deltas, so these replies rendered empty. Emit an assistant frame's text blocks when none of its text was streamed, and keep the synthetic frame's zeroed usage and model out of context tracking. Fixes zeronsh#734
Source: zeronsh#787 Source revision: f4fa366
Contribution Managerneeds triage · medium risk · untriaged Open review workspace · Revision Next actions:
This summary is maintained by the review app. Decisions and test evidence are recorded in the workspace; the app does not merge PRs. |
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.
Upstream mirror
Source: zeronsh#787
Original author: @avienor
Original revision:
f4fa366e58bae5df6731420606969401d81a9946This PR is an isolated Contribution Manager pilot mirror. Its reviews, checks and merge state are separate from upstream. An empty
[skip ci]commit suppresses automatic bulk CI; the code tree matches the imported upstream revision.Fixes zeronsh#734 (the bug half; the reset-time display it also asks for is a separate feature and is not part of this PR).
Summary
/usage,/context,/cost,/mcp, …) without a model turn: a single assistant frame withmodel: "<synthetic>"carries the full text, and notext_deltastream events precede it (reproduced with Claude Code 2.1.289). The normalizer took main-thread text only from deltas and kept onlytool_useblocks from assistant frames, so these replies rendered empty.Normalizernow tracks whether main-thread text was streamed since the last assistant frame orresult. When it wasn't, the frame's text blocks are emitted verbatim asTextDeltas, in block order with tool calls and beforeAssistantMessageCompleted.result, not inrotate_for_steer: a steer echo can rotate the message id between a message's deltas and its frame. Theresultreset covers turns that end on deltas without an assistant frame (as in thesuperseded-steersfixture), which would otherwise hide the next command's reply.errorcode keep the current behavior (only the mapped error is shown), so a failure is not reported twice.<synthetic>frames no longer emitContextUsage(their usage is all zeros, which reset the context meter to 0%) and no longer replacelast_model, which the nextresultuses to look up the context window. Real zero measurements from other frames are untouched.docs/context-usage.mdnotes that local command replies are excluded from Claude's context measurement.crates/harness/src/claude/normalize.rs.Known limitations
/usagereplies are plain text with single newlines; the markdown renderer folds those into one paragraph./context(markdown) renders well. Making plain-text command output keep its line breaks is a separate change.Test plan
claude::normalize::tests(4 of them fail without the fix):local_command_replies_surface_their_texta_reply_ended_without_its_frame_does_not_hide_the_next_commandsubagent_traffic_never_gates_main_thread_textsynthetic_replies_leave_context_usage_and_model_alonestreamed_text_is_not_repeated_from_its_assistant_frame,a_steer_between_deltas_and_their_frame_does_not_repeat_text,errored_assistant_frames_keep_only_the_mapped_errorcargo test --locked -p zeron-harness(whole crate, including the live Claude fixtures undertests/) passescargo clippy --locked -p zeron-harness --all-targets: no new warnings (same warning count before and after, none in the touched file)cargo fmt -p zeron-harness --checkclean/usageand/contextwere empty onmainand show their full text with this branchScreenshots
Before (
main):/contextand/usageproduce no reply.After:
/contextreply rendered.Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.