Skip to content

Conversation

@wan-kong
Copy link

@wan-kong wan-kong commented Dec 9, 2025

🎯 Changes

βœ… Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm run test:pr.

πŸš€ Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

add docs for @tanstack/ai-vue

Summary by CodeRabbit

Release Notes

  • Documentation
    • Added comprehensive TanStack AI Vue API documentation covering installation, the useChat composable with full type safety, usage examples, connection adapters, and available types for building AI-powered Vue applications.

✏️ Tip: You can customize this high-level summary in your review settings.

<div v-for="part in message.parts" :key="part.id">
<span v-if="part.type === 'text'">{{ part.content }}</span>
<div v-else-if="part.type === 'thinking'">
<div class="text-sm text-gray-500 italic">πŸ’­ Thinking: {{ part.content }}</div>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could potentially be merged with wrapper div

const handleSubmit = (e: Event) => {
const val = input.value.trim()
if (((val ?? '') !== '') && !isLoading) {
sendMessage(input.value);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we would need e.target.reset() as well to clear the form on submit.

const notification = ref<string | null>(null);

// Create client tool implementations,
const updateUI = updateUIDef.client((input) => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what is the purpose of this tool. Maybe it makes sense in React to set state causing a re-render, but in Vue it would do nothing as notification ref is not used anywhere.

@AlemTuzlak Was original React intention just to cause a re-render?

createChatClientOptions,
type InferChatMessages
} from "@tanstack/ai-client";
import { updateUIDef } from "@/tools/definitions";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This tool def seems to be buried in one of the other pages, maybe in-lining it would be wise?
Or at least a link to this tool definition?
@AlemTuzlak


```typescript
interface UseChatReturn {
messages: UIMessage[];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually a DeepReadonly<ShallowRef<Array<UIMessage>>>

}) => Promise<void>;
reload: () => Promise<void>;
stop: () => void;
isLoading: boolean;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isLoading: DeepReadonly<ShallowRef<boolean>>

reload: () => Promise<void>;
stop: () => void;
isLoading: boolean;
error: Error | undefined;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error: DeepReadonly<ShallowRef<Error | undefined>>

} from "@tanstack/ai-client";
import { updateUIDef, saveToStorageDef } from "@/tools/definitions";

const notification = ref<{message: string; type: 'success' | 'error'}>(null);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what for notification is used in this example

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 5, 2026

πŸ“ Walkthrough

Walkthrough

A new API documentation file for TanStack AI Vue is added, detailing the useChat composable, connection adapters, usage examples, and type exports. The documentation configuration is updated to reference this new API documentation entry.

Changes

Cohort / File(s) Summary
Documentation Addition
docs/api/ai-vue.md
New comprehensive API documentation covering TanStack AI Vue: useChat composable, installation, type safety, extension points, connection adapters, multiple usage examples (basic chat, tool approval, client tools), createChatClientOptions, and public API surface including UIMessage, MessagePart, ChatClientOptions, ConnectionAdapter, and InferChatMessages.
Configuration Update
docs/config.json
Added new API entry for @tanstack/ai-vue with path api/ai-vue under the API section.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Suggested reviewers

  • tannerlinsley
  • jherr
  • LadyBluenotes

Poem

A new guide hops into view, 🐰
For Vue developers, shiny and new,
With types and examples so clear,
The AI adapters appear!
Documentation completeβ€”hooray for you!

Pre-merge checks

βœ… Passed checks (3 passed)
Check name Status Explanation
Title check βœ… Passed The title clearly summarizes the main change: adding documentation for the ai-vue package, which aligns with the PR's primary objective.
Description check βœ… Passed The description follows the template structure with all required sections completed, including filled checklist items and release impact classification.
Docstring Coverage βœ… Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❀️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Fix all issues with AI Agents πŸ€–
In @docs/api/ai-vue.md:
- Line 198: The type for the reactive "notification" ref doesn't allow null
despite being initialized to null; update the declaration of notification so its
generic includes null (i.e., make the ref type `{ message: string; type:
'success' | 'error' } | null`) so the initial null value is type-safe while
preserving the original object shape.
- Around line 127-132: handleSubmit uses a Ref incorrectly and has redundant
parentheses; compute val as a trimmed string (e.g., const val =
input.value?.trim() ?? ''), check if val !== '' && !isLoading.value, and call
sendMessage(val) (not sendMessage(input.value)) before clearing input.value = ''
so you pass the trimmed text and properly access the ShallowRef isLoading via
.value.
- Line 151: Replace the incorrect opening "<div>" tag at the end of the block
with the proper closing "</div>" tag; locate the stray "<div>" (the unmatched
tag) and change it to "</div>" so the HTML structure is properly closed.
♻️ Duplicate comments (2)
docs/api/ai-vue.md (2)

198-209: Consider removing or utilizing the unused notification ref.

The notification ref is created and updated by the client tools but is never rendered in the template, making this part of the example incomplete. Consider either:

  1. Adding template code to display the notification
  2. Removing the notification ref if it's not needed for this example

28-36: Clarify or inline the tool definition to avoid confusion.

The import from "@/tools/definitions" references a non-existent path in the documentation. While the comment on line 27 links to the client-tools guide, consider either:

  1. Inlining the tool definition directly in the example
  2. Adding a clear note that this is a placeholder path users should replace

Additionally, the notification ref created on line 30 is never used in the template (lines 52-54), making the client tool example incomplete.

Suggested improvement to inline the tool definition
-// see more in https://tanstack.com/ai/latest/docs/guides/client-tools#defining-client-tools
-import { updateUIDef } from "@/tools/definitions";
+import { toolDefinition } from "@tanstack/ai";
+
+// Define the tool inline for clarity
+const updateUIDef = toolDefinition({
+  name: 'updateUI',
+  description: 'Updates the UI with a notification',
+  parameters: z.object({
+    message: z.string(),
+  }),
+});
πŸ“œ Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 7a22c2c and b7a7d49.

πŸ“’ Files selected for processing (2)
  • docs/api/ai-vue.md
  • docs/config.json
🧰 Additional context used
🧠 Learnings (4)
πŸ““ Common learnings
Learnt from: CR
Repo: TanStack/ai PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-13T17:09:09.794Z
Learning: Implement framework integrations using the headless `tanstack/ai-client` for state management with framework-specific hooks (useChat) on top
πŸ“š Learning: 2025-12-13T17:09:09.794Z
Learnt from: CR
Repo: TanStack/ai PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-13T17:09:09.794Z
Learning: Implement framework integrations using the headless `tanstack/ai-client` for state management with framework-specific hooks (useChat) on top

Applied to files:

  • docs/api/ai-vue.md
πŸ“š Learning: 2025-12-13T17:09:09.794Z
Learnt from: CR
Repo: TanStack/ai PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-13T17:09:09.794Z
Learning: Applies to **/*.{ts,tsx} : Implement isomorphic tool system using `toolDefinition()` with `.server()` and `.client()` implementations for dual-environment execution

Applied to files:

  • docs/api/ai-vue.md
πŸ“š Learning: 2025-12-13T17:09:09.794Z
Learnt from: CR
Repo: TanStack/ai PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-13T17:09:09.794Z
Learning: Applies to packages/typescript/*/src/index.ts : Export tree-shakeable adapters with clear subpath exports in package.json (e.g., `tanstack/ai/adapters`, `tanstack/ai-openai/adapters`) to minimize bundle size

Applied to files:

  • docs/config.json
πŸ”‡ Additional comments (1)
docs/config.json (1)

125-129: LGTM!

The new API entry for @tanstack/ai-vue follows the correct structure and is properly integrated into the configuration.

Comment on lines +127 to +132
const handleSubmit = (e: Event) => {
const val = input.value.trim()
if (((val ?? '') !== '') && !isLoading) {
sendMessage(input.value);
input.value = '';
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | πŸ”΄ Critical

Fix ref access and simplify condition.

The condition on line 129 should use !isLoading.value since isLoading is a ShallowRef<boolean> and requires explicit .value access in the script section (Vue only auto-unwraps refs in templates).

Additionally, the condition on line 128 has unnecessary nested parentheses.

πŸ”Ž Proposed fix
 const handleSubmit = (e: Event) => {
   const val = input.value.trim()
-  if (((val ?? '') !== '') && !isLoading) {
+  if (val !== '' && !isLoading.value) {
     sendMessage(input.value);
     input.value = '';
   }
 };
πŸ€– Prompt for AI Agents
In @docs/api/ai-vue.md around lines 127-132, handleSubmit uses a Ref incorrectly
and has redundant parentheses; compute val as a trimmed string (e.g., const val
= input.value?.trim() ?? ''), check if val !== '' && !isLoading.value, and call
sendMessage(val) (not sendMessage(input.value)) before clearing input.value = ''
so you pass the trimmed text and properly access the ShallowRef isLoading via
.value.

Send
</button>
</form>
<div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | πŸ”΄ Critical

Fix closing tag syntax error.

Line 151 has a syntax error - it should be a closing </div> tag, not an opening <div> tag.

πŸ”Ž Proposed fix
     </form>
-  <div>
+  </div>
 </template>
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<div>
</form>
</div>
</template>
πŸ€– Prompt for AI Agents
In @docs/api/ai-vue.md around line 151, Replace the incorrect opening "<div>"
tag at the end of the block with the proper closing "</div>" tag; locate the
stray "<div>" (the unmatched tag) and change it to "</div>" so the HTML
structure is properly closed.

} from "@tanstack/ai-client";
import { updateUIDef, saveToStorageDef } from "@/tools/definitions";

const notification = ref<{message: string; type: 'success' | 'error'}>(null);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | πŸ”΄ Critical

Fix type definition to include null.

The ref is initialized with null but the type definition doesn't include null in the union, which is a type error.

πŸ”Ž Proposed fix
-const notification = ref<{message: string; type: 'success' | 'error'}>(null);
+const notification = ref<{message: string; type: 'success' | 'error'} | null>(null);
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const notification = ref<{message: string; type: 'success' | 'error'}>(null);
const notification = ref<{message: string; type: 'success' | 'error'} | null>(null);
πŸ€– Prompt for AI Agents
In @docs/api/ai-vue.md around line 198, The type for the reactive "notification"
ref doesn't allow null despite being initialized to null; update the declaration
of notification so its generic includes null (i.e., make the ref type `{
message: string; type: 'success' | 'error' } | null`) so the initial null value
is type-safe while preserving the original object shape.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants