Open
Conversation
Author
|
@gr2m could you check this out please been a while :D |
1 task
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.
Background
Currently, the
stateproperty within UIToolInvocation and DynamicToolUIPart is typed using inline literal strings (e.g.,{ state: 'input-streaming'; ... }). While this correctly enables TypeScript's discriminated union narrowing (allowing TypeScript to knowpart.outputis available whenstate === 'output-available'), it creates a major pain point for developers using the SDK.Because the union of these literal strings is never exported as a standalone named type, developers cannot cleanly reference the possible states in their own code.
Without an exported ToolCallState type, developers are forced to use brittle workarounds when building UI components that handle tool calls. Specifically, it prevents them from doing common patterns like:
{ state: ToolCallState }).isTerminalState(state)).type MutationHandler = (state: ToolCallState) => void).Summary
uibarrel files (packages/ai/src/ui/index.ts -> packages/ai/src/index.ts).content/to document the new ToolCallState union.Manual Verification
pnpm type-check:fullacross the entire workspace to ensure no internal code breaks.import { type ToolCallState } from 'ai'works correctly in a consuming app context.--typecheckto enforce that a purposefully missing literal string from ToolCallState correctly flags a type mismatch error.Checklist
pnpm changesetin the project root)