Skip to content

fix(create): repair example assistant lifecycle - #446

Merged
tannerlinsley merged 5 commits into
TanStack:mainfrom
killerfrienddk:patch-1
Nov 2, 2026
Merged

tannerlinsley merged 5 commits into
TanStack:mainfrom
killerfrienddk:patch-1

Conversation

@killerfrienddk

@killerfrienddk killerfrienddk commented May 6, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for tracking down the navigation crash. This continues @killerfrienddk's fix, covers the same failure reported by @vilindh in #416, and repairs both Events and Resume examples with current dependencies.

AI review notes:
Both assistants now use React's external-store subscription API and return the store subscription's cleanup function. Header buttons use the current store updater API, and navigation no longer returns a subscription object as a React effect disposer.
Current TanStack AI requires thread IDs. Both examples provide them, reject missing IDs before calling a provider, forward IDs to chat, and infer message types from the actual hook. Generated content collection aliases and typed route parameters also make both examples compile with their current dependencies.
Validation: Agent-run Node 24 build and 471 unit tests pass. Both configured Chrome matrix cases pass: Events/npm and Resume/pnpm install, build, type-check, reject missing thread IDs with 400, stream a local mocked reply, and survive client navigation and remount. All eight existing blocking e2e tests pass. The normal commit hooks pass and reuse the matching Nx blocking-test result. Local Chrome teardown accounts for much of the 10.8/11.5 minute runner times. No live AI or deployment providers were called. The existing CLI lint errors in unchanged ui-prompts.ts lines 108 and 126 remain; lint is separate from the normal commit/CI gates.
The 13 affected source templates total 49,888 bytes before and 50,410 bytes after, an increase of 522 bytes. There are no dependency changes or changes to core CLI or generator logic. This is source byte accounting, not a startup or heap benchmark.

Summary by CodeRabbit

  • Bug Fixes
    • Improved assistant behavior in the Events and Resume examples: assistants stay in sync with their open or closed state and can be reopened after navigating between pages.
    • Chat requests without a valid thread ID now receive a clear error response instead of being processed.
    • Updated speaker and talk links to navigate to the correct detail pages.
  • Tests
    • Added end-to-end checks for assistant replies, theme display, navigation, and reopening in both examples.

@coderabbitai

coderabbitai Bot commented May 6, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Walkthrough

The Events and Resume examples now use store-backed assistant visibility, explicit chat thread IDs, validated chat requests, and parameterized route links. The pull request also updates generated TypeScript configuration and adds end-to-end assistant lifecycle tests.

Changes: Events and Resume assistant examples

Layer / File(s) Summary
Chat thread contract
packages/create/src/frameworks/react/examples/{events,resume}/assets/src/lib/*, packages/create/src/frameworks/react/examples/{events,resume}/assets/src/routes/api.*-chat.ts
Both chat hooks set an explicit thread ID and derive message types from the hook return value. Both API routes reject missing or blank thread IDs and pass valid IDs to chat. The Events route also narrows the provider type.
Assistant store subscription and lifecycle
packages/create/src/frameworks/react/examples/{events,resume}/assets/src/components/*Assistant*.tsx, packages/cli/tests-e2e/assistant-examples.spec.ts, .changeset/assistant-lifecycle.md
The assistant components derive visibility from their stores with useSyncExternalStore. The buttons use updater callbacks to open the assistants. End-to-end tests exercise both assistants, and the changeset records the package update.
Parameterized example links
packages/create/src/frameworks/react/examples/events/assets/src/components/{SpeakerCard,TalkCard}.tsx, packages/create/src/frameworks/react/examples/events/assets/src/routes/{schedule.index.tsx,talks.$slug.tsx}
Speaker and talk links use parameterized routes and pass slugs through params.
Generated TypeScript configuration
packages/create/src/frameworks/react/project/base/tsconfig.json.ejs
The generated config adds the content-collections path mapping when the Events or Resume add-on is enabled.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Possibly related PRs

  • TanStack/cli#525: Updates the AI scaffold with the same chat thread ID contract and message type inference approach.

Suggested reviewers: jherr

Merge Risk: Minimal · up to 1c73a

The assistant lifecycle and chat updates have no demonstrated merge-blocking issue.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely identifies the main change: repairing the example assistant lifecycle across the Events and Resume examples.
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.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 5 functions across 13 files. (2 skipped: 2 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/cli/tests-e2e/assistant-examples.spec.ts

Parsing error: "parserOptions.project" has been provided for @typescript-eslint/parser.
The file was not found in any of the provided project(s): packages/cli/tests-e2e/assistant-examples.spec.ts

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

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@packages/create/src/frameworks/react/examples/events/assets/src/components/RemyAssistant.tsx`:
- Around line 91-94: The component currently calls
showRemyAssistant.subscribe(...) in the component body causing listener leaks
and render storms; move the subscription into a useEffect that runs on mount,
capture the returned Subscription and call subscription.unsubscribe() in the
effect cleanup, and keep setIsOpen inside the subscription callback;
alternatively (preferred) import and use the `@tanstack/react-store` useStore hook
to subscribe automatically and remove the duplicated local state and manual
subscribe/unsubscribe logic (references: showRemyAssistant, setIsOpen,
subscribe, unsubscribe, useEffect, useStore).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: de3939c1-82ac-4a01-87fa-e785d35e0ced

📥 Commits

Reviewing files that changed from the base of the PR and between 5bbccb0 and 2bcae52.

📒 Files selected for processing (1)
  • packages/create/src/frameworks/react/examples/events/assets/src/components/RemyAssistant.tsx

…use effect

I have now studied up more regarding useeffect and understand why coderabbit said what it said
@killerfrienddk
killerfrienddk marked this pull request as draft May 12, 2026 07:21
@killerfrienddk
killerfrienddk marked this pull request as ready for review May 12, 2026 07:21
@tannerlinsley tannerlinsley changed the title Fixed RemyAssistant.tsx - Where useeffect causes destroy is not a function error fix(create): repair example assistant lifecycle Nov 2, 2026
@changeset-bot

changeset-bot Bot commented Nov 2, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1c73aa1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 7 packages
Name Type
@tanstack/create Patch
create-start-app Patch
create-tanstack-app Patch
create-tanstack Patch
create-tsrouter-app Patch
@tanstack/create-start Patch
@tanstack/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai coderabbitai Bot 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.

Additional comments: 1
packages/create/src/frameworks/react/examples/events/assets/src/lib/conference-ai-hook.ts-9-9: 1

9-9: Minor · Data Integrity & Integration · Quick win

Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.

Use a distinct ID for each conversation.

Every visitor and remount sends conference-assistant, even when its messages are independent. Consumers that group events by threadId cannot distinguish those conversations. Generate an ID that stays stable for the conversation. Apply the same fix to resume-ai-hook.ts Line 9. (github.com)


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 009c2746-68ca-455f-9e48-9541cdf36715
Commits

Reviewing files that changed from the base of the PR and between d819412 and 1c73aa1.

Files selected for processing: 15
  • .changeset/assistant-lifecycle.md
  • packages/cli/tests-e2e/assistant-examples.spec.ts
  • packages/create/src/frameworks/react/examples/events/assets/src/components/RemyAssistant.tsx
  • packages/create/src/frameworks/react/examples/events/assets/src/components/RemyButton.tsx
  • packages/create/src/frameworks/react/examples/events/assets/src/components/SpeakerCard.tsx
  • packages/create/src/frameworks/react/examples/events/assets/src/components/TalkCard.tsx
  • packages/create/src/frameworks/react/examples/events/assets/src/lib/conference-ai-hook.ts
  • packages/create/src/frameworks/react/examples/events/assets/src/routes/api.remy-chat.ts
  • packages/create/src/frameworks/react/examples/events/assets/src/routes/schedule.index.tsx
  • packages/create/src/frameworks/react/examples/events/assets/src/routes/talks.$slug.tsx
  • packages/create/src/frameworks/react/examples/resume/assets/src/components/ResumeAssistant.tsx
  • packages/create/src/frameworks/react/examples/resume/assets/src/components/ResumeAssistantButton.tsx
  • packages/create/src/frameworks/react/examples/resume/assets/src/lib/resume-ai-hook.ts
  • packages/create/src/frameworks/react/examples/resume/assets/src/routes/api.resume-chat.ts
  • packages/create/src/frameworks/react/project/base/tsconfig.json.ejs

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

@tannerlinsley
tannerlinsley merged commit dbd9449 into TanStack:main Nov 2, 2026
7 checks passed
@github-actions github-actions Bot mentioned this pull request Nov 2, 2026
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