fix(create): preserve page context in events chat #550
main fromrefs/pull/550/head·merged by tannerlinsley Preserve the current speaker and talk when Remy sends them through the AI client's forwardedProps. Keep legacy top-level values working, including mixed payloads where only one slug is nested.
AI review notes: Each slug is resolved independently, with valid nested values taking priority. Non-string values are ignored, and thread validation stays intact. Eight route regression cases pass. The previous revision fails the two new mixed-payload cases. All 10 package builds, 541 unit tests and eight Chrome e2e tests passed through the normal commit hook. A generated events app outside the monorepo passed production build and type checking with this asset overlaid. The actual published AI client transport was exercised against the route with provider calls stubbed and networking disabled. No dependencies, workflows or CLI startup imports change. Includes a patch changeset for @tanstack/create.
Summary by CodeRabbit#
- Bug Fixes
- The events example chat now retains speaker and talk-page context when generating responses, helping keep replies relevant to the page being viewed.
- Existing chat payloads that provide context in the top-level fields remain supported, and forwarded context takes precedence when both formats are present.
- Invalid or missing page context is ignored, and requests with an empty thread ID are rejected without starting a chat.
- 1
No actionable comments were generated in the recent review.
Walkthrough
-
The events chat route now reads speaker and talk context from forwarded properties when available, with a top-level request-body fallback. Added tests cover context selection and missing-thread responses.
Changes: Events chat context
Layer / File(s) Summary Select and validate chat context
packages/create/src/frameworks/react/examples/events/assets/src/routes/api.remy-chat.ts,packages/create/tests/events-chat-context.test.ts,.changeset/events-forwarded-context.mdThe route selects string context values from forwardedPropswhen they are present, otherwise from top-level string values. Tests cover precedence, fallback, absent or non-string values, and missing-thread responses. A patch changeset records the change.Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Possibly related PRs
- TanStack/cli#446: This PR uses the same chat handler’s thread ID validation contract and tests the empty-thread response.
Merge Risk:
Minimal · up tobb868-
Context forwarding is covered without an identified current-head regression; the change is ready to merge.
Pre-merge checks:
4 · 1-
Failed checks: 1 warningCheck name Status Explanation Resolution Docstring Coverage 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 checks: 4 passed-
Check name Status Explanation Description Check Check skipped - CodeRabbit’s high-level summary is enabled. Title check The title clearly and concisely describes the main change: preserving page context in the events chat. Linked Issues check Check skipped because no linked issues were found for this pull request. Out of Scope Changes check 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 1 functions across 2 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches
-
Generate docstrings
-
- Commit to this branch
- Create a new PR
Generate unit tests (beta)
-
- Commit to this branch
- 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/create/tests/events-chat-context.test.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/create/tests/events-chat-context.test.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.
CodeRabbit Verify#
- Run CodeRabbit Verify to test the changes in this pull request.
Recent 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:
88f1a97c-3ebc-480e-8c35-7e12d135483f
Commits-
Reviewing files that changed from the base of the PR and between ee1b20b393cf27a8161b154eb9a11586425b9fbf and bb8683fd6a62e9f9d368d1a10ff0418fd3d26519.
Files selected for processing: 2-
packages/create/src/frameworks/react/examples/events/assets/src/routes/api.remy-chat.tspackages/create/tests/events-chat-context.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.
-
-
Additional comments: 1-
packages/create/src/frameworks/react/examples/events/assets/src/routes/api.remy-chat.ts-31-34: 1
-
31-34: Minor · Functional Correctness · Quick win **Unverified finding** Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.Apply the body fallback to each slug.
If
forwardedPropscontainsspeakerSlugbut the request body containstalkSlug, this selection discards the top-leveltalkSlug. The session context then disappears from the prompt. Select each slug fromforwardedPropswhen present, and otherwise select that slug frombody. Add a mixed-payload test. (raw.githubusercontent.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:
26215607-cc17-4975-9aa4-e22411489c9a
Commits-
Reviewing files that changed from the base of the PR and between 270f9b06fd13f12ec03cf2604922f99e86d9f9e7 and ee1b20b393cf27a8161b154eb9a11586425b9fbf.
Files selected for processing: 3-
.changeset/events-forwarded-context.mdpackages/create/src/frameworks/react/examples/events/assets/src/routes/api.remy-chat.tspackages/create/tests/events-chat-context.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.
-
-
Confirmed the mixed-payload gap. I’m keeping this as a draft until the corrected revision finishes its normal checks.
AI review notes: The local revision falls back per slug, so a nested speaker and top-level talk, or the reverse, both retain context. The two new cases fail against the current PR head and pass with the revision. All eight route cases and the generated app’s build/types passed. The unchanged full repository hook is still running; the corrected revision has not been pushed yet.
The mixed-payload case is fixed too, and this is ready for the normal checks.
AI review notes: Revision bb8683fd resolves each slug independently. Both mixed directions now have regression coverage, and both fail on the previous revision. All 10 builds, 541 unit tests and eight Chrome e2e tests passed through the normal hook. The generated events app also passed production build and type checking with the corrected asset overlaid, offline with no provider calls.
tannerlinsley merged this517c9ef
tannerlinsley closed this
The code has landed, but release verification isn’t complete yet.
AI review notes: Version PR #551 merged at 58dc7ae4. The normal publisher reported success, and six expected archives passed downloaded hash checks. Fresh official metadata and the tarball URL still return 404 for @tanstack/create 0.71.14. The published CLI and aliases depend on that version, so fresh installation may fail until it is available. A fresh consumer has not been verified. One retry of the unchanged normal release workflow is running: https://github.com/TanStack/cli/actions/runs/41673768768. Full archive, tag and public-consumer verification remains open.
Sign in to join this conversation.
🦋 Changeset detected#
Latest commit: bb8683fd6a62e9f9d368d1a10ff0418fd3d26519
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 7 packages
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