Skip to content

docs(gemini): replace type assertions with runtime narrowing in interactions examples#743

Open
harshlocham wants to merge 1 commit into
TanStack:mainfrom
harshlocham:docs/gemini-remove-type-assertions
Open

docs(gemini): replace type assertions with runtime narrowing in interactions examples#743
harshlocham wants to merge 1 commit into
TanStack:mainfrom
harshlocham:docs/gemini-remove-type-assertions

Conversation

@harshlocham

@harshlocham harshlocham commented Jun 10, 2026

Copy link
Copy Markdown

Remove the GeminiInteractionsCustomEventValue and inline { interactionId }
casts from the Interactions API examples, narrowing the custom-event payload
with typeof/in checks instead, per the repo's no-as-in-docs convention. Also
drops the now-unused type imports.

Summary by CodeRabbit

  • Documentation
    • Updated Gemini adapter documentation for the Stateful Conversations — Interactions API (Experimental) with refined import guidance and improved usage examples. Documentation now provides clearer patterns for extracting and working with interaction IDs in React components and streaming workflows.

…actions examples

Remove the `GeminiInteractionsCustomEventValue` and inline `{ interactionId }`
casts from the Interactions API examples, narrowing the custom-event payload
with typeof/in checks instead, per the repo's no-`as`-in-docs convention. Also
drops the now-unused type imports.
Copilot AI review requested due to automatic review settings June 10, 2026 11:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ec3860d9-c9a2-47e7-af1f-bae48183a34a

📥 Commits

Reviewing files that changed from the base of the PR and between ff267a5 and 325ab88.

📒 Files selected for processing (1)
  • docs/adapters/gemini.md

📝 Walkthrough

Walkthrough

This PR updates the Gemini adapter documentation to use defensive runtime parsing for interaction ID extraction. The import statement is simplified, and two code examples are revised to add shape verification guards before accessing the interaction ID from CUSTOM events.

Changes

Gemini Interaction ID Defensive Parsing

Layer / File(s) Summary
Basic usage import simplification
docs/adapters/gemini.md
The experimental interactions adapter import is changed to a direct geminiTextInteractions import in the Basic Usage code snippet.
Runtime guards in useChat and streaming handlers
docs/adapters/gemini.md
The useChat onCustomEvent handler and the streaming "Reading the interaction id" example both add runtime checks (eventType, typeof data, data !== null, and "interactionId" in data) before reading interactionId from data or chunk.value.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • TanStack/ai#502: Both PRs involve the Gemini Interactions CUSTOM event and gemini.interactionId handling, with this PR documenting the defensive consumption of the adapter's event output.

Poem

🐰 Runtime checks bloom bright and strong,
Guard the data, right from wrong,
Gemini's events, now safe to read,
Defensive parsing — exactly what we need!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description explains what was changed and why, but does not follow the required template structure with the specified sections and checklist items. Reformat the description to include the required template sections (🎯 Changes, ✅ Checklist with contribution steps and local testing, 🚀 Release Impact) to match repository conventions.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: replacing type assertions with runtime narrowing in the Gemini interactions examples documentation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

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.

2 participants