th-d60a73: gated interleaved tool-activity chips in chat-widget#29
Merged
Conversation
🦋 Changeset detectedLatest commit: 7b5ed8e The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Add an opt-in showToolActivity option that renders the agent's tool activity as inline chips interleaved with its prose, mirroring the smooth daemon SPA's blocks model. - Defaults to false: the customer-facing widget is byte-for-byte unchanged (prose bubble only). Enable via show-tool-activity attr / showToolActivity. - When on, a tool-invoking turn renders an ordered strip of prose bubbles + tool chips (running…/done/error). Tools read from state.rawResponse.toolCall/.toolResult (correct nested path — reading state.toolResult leaves chips stuck 'running…'). - Tool name/args via textContent (no innerHTML) — payloads can't inject markup. - New public MessageBlock/ToolCall types; tests for the gate, interleave, wrong-path guard, and chip rendering. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
3346eb3 to
7b5ed8e
Compare
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
The embeddable
@smooai/chat-widgetonly grew a prose bubble fromstream_token— the agent's tool activity streaming over the smooth-operator protocol asstream_chunkevents was invisible (send()'s loopdefault: break'd on it). The smooth daemon SPA already renders interleaved tool chips via itsblocksmodel; this ports that to the widget.What changed — and how the gate works
Because this is a customer-facing widget, exposing raw tool calls (
grep/bash/read_file) to a support-site end-user is usually undesirable. So the feature is gated behindshowToolActivity(defaultfalse):false(default): behavior is byte-for-byte unchanged — the assistant streams a single prose bubble, noblocksare built,stream_chunkis ignored exactly as before.true: a turn that invokes a tool renders as an ordered strip of prose bubbles + inline tool chips (running…/done ✓/error), in the order the model produced them. Enable via theshow-tool-activityHTML attribute orshowToolActivity: truein the config object.Wiring:
config.ts— newshowToolActivityoption, defaultedfalseinresolveConfig.conversation.ts— newMessageBlock/ToolCalltypes +blocks?onChatMessage;send()foldsstream_tokeninto a trailing text block andstream_chunktool activity into the block list (only when gated). Prose-only turns dropblockson finalize so they render via the normal markdown path.element.ts/styles.ts—renderAssistantBlocks+ToolChip, reusing the existing rAF reveal for the live trailing text block; chip styles keyed to the theme tokens.Correctness / security
state.rawResponse.toolCall/state.rawResponse.toolResult— the correct nested path. Readingstate.toolResult(one level too high) leaves chips stuck "running…"; a test asserts the wrong-path payload does not resolve a chip.textContent(neverinnerHTML), so a tool payload can't inject markup.Protocol notes
for awaitturn loop interleavesstream_token(prose) andstream_chunk(tools) in arrival order; concurrent tools sharing a name resolve most-recent-open-first (matches the daemon).Tests / build
pnpm typecheckclean;pnpm test68 pass (10 new across gate default, interleave, error, wrong-path guard, and chip rendering);pnpm buildgreen. New publicMessageBlock/ToolCallexports; README config table updated.🤖 Generated with Claude Code