Repository navigation
feat(ai): structured tool-call display (AI Elements–style) - #99
Merged
Merged
Conversation
Replaces the one-line "Ran query_data" caption with a collapsible,
structured tool block — a React Native take on Vercel AI Elements' Tool
component (which is web/DOM-only, so it can't be ported directly).
- lib/ai-chat.ts: the SSE parser now captures rich ToolInvocation objects
({ id, name, input, output, state }) by merging tool-input-available +
tool-output-available events keyed by toolCallId (was: just names).
onUpdate streams the live tools; `toolCalls: string[]` kept for back-compat.
- components/ui/ToolInvocations.tsx: per-tool collapsible row — name +
running/done status, expanding to show input args and the result.
- store message carries `tools: ToolInvocation[]`; app/ai.tsx renders the
block under assistant turns.
Tested against the real captured SSE tool format (input/output/state by
toolCallId) + component + screen integration. Suite 1255/1255, lint clean.
Context: confirmed objectui's chat UI is Vercel AI Elements (vendored MIT,
shadcn/DOM) + @ai-sdk/react useChat — neither ports to RN (Elements is
web-only; useChat hits a React 19.2.0 peer gap on Expo 55). So we mirror
the *design* in custom RN components instead.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
What
Replaces the one-line
Ran query_datacaption with a collapsible, structured tool block — a React Native take on Vercel AI Elements'Toolcomponent (which is web/DOM-only, so it can't be ported directly).lib/ai-chat.ts— the SSE parser now captures richToolInvocationobjects ({ id, name, input, output, state }) by mergingtool-input-available+tool-output-availableevents keyed bytoolCallId(was: just names).onUpdatestreams the live tools;toolCalls: string[]kept for back-compat.components/ui/ToolInvocations.tsx— per-tool collapsible row: tool name + running/done status, expanding to reveal the input args and the result (mono, scrollable).tools: ToolInvocation[];app/ai.tsxrenders the block under assistant turns.Why custom (not the library objectui uses)
Confirmed from objectui's source: its chat UI is Vercel AI Elements (vendored MIT, shadcn/DOM) on top of
@ai-sdk/reactuseChat. Neither ports to React Native — AI Elements is web-only (<div>/Radix/streamdown/shiki), anduseChathits a React 19.2.0 peer gap on Expo 55. So we mirror the design in custom RN components.Tests
{input, output, state}keyed bytoolCallId— asserted against the real captured SSE tool format.ToolInvocationscomponent: collapsed-by-default, expand reveals input/result, running hides result, one row per tool.npm run lint0 errors;jest1255/1255 (153 suites).🤖 Generated with Claude Code