Repository navigation
feat(apollo-react): add the Wind chat tool-call and tree renderers #1376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
BenGSchulz
merged 1 commit into
feat/wind-chat-markdown-renderer
from
feat/wind-chat-tool-call-tree-renderers
Oct 20, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
27 changes: 27 additions & 0 deletions
27
packages/apollo-react/src/chat/headless/tool-call/span-icon.test.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import { describe, expect, it } from 'vitest'; | ||
|
|
||
| import { getSpanIconSvg } from './span-icon'; | ||
| import { spanIconsMap } from './span-icons'; | ||
|
|
||
| describe('getSpanIconSvg', () => { | ||
| it('maps span types, attribute-driven types and functions to icons', () => { | ||
| expect(getSpanIconSvg({ type: 'agentRun' })).toBe(spanIconsMap.get('agent-run')); | ||
| expect(getSpanIconSvg({ type: 'toolCall', attributes: { toolType: 'Agent' } })).toBe( | ||
| spanIconsMap.get('agent-run') | ||
| ); | ||
| expect(getSpanIconSvg({ type: 'completion', attributes: { model: 'gpt-4o' } })).toBe( | ||
| spanIconsMap.get('open-ai') | ||
| ); | ||
| expect(getSpanIconSvg({ type: 'function_call_sync' })).toBe(spanIconsMap.get('function-span')); | ||
| expect(getSpanIconSvg({ type: 'something-new' })).toBe(spanIconsMap.get('default-trace-item')); | ||
| }); | ||
|
|
||
| it('copes with odd attributes', () => { | ||
| expect(getSpanIconSvg({ type: 'completion', attributes: { model: 42 } })).toBe( | ||
| spanIconsMap.get('generic-ai') | ||
| ); | ||
| expect(getSpanIconSvg({ type: 'completion', attributes: '{bad' })).toBe( | ||
| spanIconsMap.get('generic-ai') | ||
| ); | ||
| }); | ||
| }); |
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
File renamed without changes.
113 changes: 113 additions & 0 deletions
113
packages/apollo-react/src/chat/headless/tool-call/tool-call-model.test.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| import { describe, expect, it } from 'vitest'; | ||
|
|
||
| import { | ||
| getSpanAttributes, | ||
| getTaskUrls, | ||
| getToolCallDurationSeconds, | ||
| getToolCallName, | ||
| getToolCallState, | ||
| getToolCallValues, | ||
| getVisibleTraceChildren, | ||
| type ToolCallSpanNode, | ||
| } from './tool-call-model'; | ||
|
|
||
| const node = ( | ||
| id: string, | ||
| data: Partial<ToolCallSpanNode['data']> = {}, | ||
| children?: ToolCallSpanNode[] | ||
| ): ToolCallSpanNode => ({ key: id, name: id, data: { id, ...data }, children }); | ||
|
|
||
| describe('tool call model', () => { | ||
| it('reads the state from input and output first', () => { | ||
| expect(getToolCallState({ input: { q: 1 } })).toBe('loading'); | ||
| expect(getToolCallState({ input: { q: 1 }, output: 'ok' })).toBe('success'); | ||
| expect(getToolCallState({ input: { q: 1 }, isError: true })).toBe('error'); | ||
| expect(getToolCallState({ input: { q: 1 }, isError: false })).toBe('success'); | ||
| }); | ||
|
|
||
| it('reads the state from the span tree otherwise', () => { | ||
| expect(getToolCallState({ span: node('a', { status: 'unset' }) })).toBe('loading'); | ||
| expect(getToolCallState({ span: node('a', { status: 'ok' }) })).toBe('success'); | ||
| expect( | ||
| getToolCallState({ | ||
| span: node('a', { status: 'ok' }, [node('b', {}, [node('c', { status: 'error' })])]), | ||
| }) | ||
| ).toBe('error'); | ||
| expect(getToolCallState({ toolName: 'x' })).toBeNull(); | ||
| }); | ||
|
|
||
| it('names the tool and times the call as Material does', () => { | ||
| expect(getToolCallName({ toolName: 'get_weather_now' })).toBe('get weather now'); | ||
| expect(getToolCallName({ span: node('a', {}, []) })).toBe('a'); | ||
| expect(getToolCallName({ span: { ...node('a'), name: 'Tool call - Web_Search' } })).toBe( | ||
| 'Web Search' | ||
| ); | ||
| expect(getToolCallName({})).toBe('tool'); | ||
| expect( | ||
| getToolCallDurationSeconds({ | ||
| startTime: '2026-01-01T00:00:00.000Z', | ||
| endTime: '2026-01-01T00:00:02.500Z', | ||
| }) | ||
| ).toBe(2.5); | ||
| expect(getToolCallDurationSeconds({})).toBe(0); | ||
| }); | ||
|
|
||
| it('collects task links from the span and its descendants, string attributes included', () => { | ||
| const span = node('root', { attributes: { taskUrl: 'https://a.test/1' }, status: 'ok' }, [ | ||
| node('child', { | ||
| attributes: JSON.stringify({ taskUrl: 'https://a.test/2' }), | ||
| status: 'unset', | ||
| }), | ||
| ]); | ||
|
|
||
| expect(getTaskUrls(span)).toEqual([ | ||
| { taskUrl: 'https://a.test/1', status: 'ok' }, | ||
| { taskUrl: 'https://a.test/2', status: 'unset' }, | ||
| ]); | ||
| expect(getTaskUrls(undefined)).toEqual([]); | ||
| }); | ||
|
|
||
| it('takes section values from the message, then from the span attributes', () => { | ||
| expect(getToolCallValues({ input: { q: 1 }, output: 'done', isError: false })).toEqual({ | ||
| input: { q: 1 }, | ||
| error: undefined, | ||
| output: 'done', | ||
| }); | ||
| expect(getToolCallValues({ input: { q: 1 }, output: 'boom', isError: true })).toEqual({ | ||
| input: { q: 1 }, | ||
| error: 'boom', | ||
| output: undefined, | ||
| }); | ||
| expect( | ||
| getToolCallValues({ | ||
| span: node('a', { attributes: { arguments: { q: 2 }, result: { r: 1 }, error: 'e' } }), | ||
| }) | ||
| ).toEqual({ input: { q: 2 }, error: 'e', output: { r: 1 } }); | ||
| }); | ||
|
|
||
| it('leaves model calls and agent output out of the traces', () => { | ||
| const span = node('root', {}, [ | ||
| node('tool', { type: 'agentTool' }), | ||
| node('llm', { type: 'llmCall' }), | ||
| node('out', { type: 'agentOutput' }), | ||
| ]); | ||
|
|
||
| expect(getVisibleTraceChildren(span).map((child) => child.key)).toEqual(['tool']); | ||
| }); | ||
|
|
||
| it('treats malformed string attributes as none, and ignores non-string task links', () => { | ||
| expect(getSpanAttributes({ attributes: '{bad' })).toEqual({}); | ||
| expect(getTaskUrls(node('a', { attributes: '{bad' }))).toEqual([]); | ||
| expect(getTaskUrls(node('a', { attributes: { taskUrl: 42 } }))).toEqual([]); | ||
| }); | ||
|
|
||
| it('lets input and output decide over a span that failed', () => { | ||
| expect( | ||
| getToolCallState({ input: { q: 1 }, output: 'ok', span: node('a', { status: 'error' }) }) | ||
| ).toBe('success'); | ||
| }); | ||
|
|
||
| it('has no state for isError without input or span; the renderer decides', () => { | ||
| expect(getToolCallState({ toolName: 'x', isError: true })).toBeNull(); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.