fix(frontend): stop in-app template picks looping agent creation - #5832
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe agent-home create surface now takes precedence over first-run redirects and onboarding loading. Template deep-link capture skips create-surface URLs, while pending templates are cleared when another consumer wins the claim. ChangesAgent-home create flow
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@coderabbitai review |
The create surface (?new=1&template=...) reuses the template param to pre-select a template in its composer. The website deep-link capture treated those URLs as deep links, so every arrival stored a pending create; the consumer hook then minted an agent and redirected to its playground, and a lost claim never cleared the stored key, re-arming the loop on every page. Ignore create-surface URLs in capture, drop the key when the claim is lost, and let ?new=1 outrank the first-run playground redirect.
3ad365f to
829599c
Compare
There was a problem hiding this comment.
Actionable comments posted: 4
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: a1425c15-bf09-4ef8-ac4b-9250611d5c36
📒 Files selected for processing (4)
web/oss/src/components/pages/agent-home/OnboardingEntry.tsxweb/oss/src/components/pages/agent-home/hooks/useConsumePendingTemplate.tsweb/oss/src/state/url/template.test.tsweb/oss/src/state/url/template.ts
CodeRabbit caught a race in the lost-claim branch: setHolding(false) fired unconditionally, so an older in-flight claim could drop the onboarding loader that a newer capture had just raised. Clear holding only when this generation is still the current one - the discipline the success path already follows.
Railway Preview Environment
Updated at 2026-08-09T21:17:59.650Z |
…its test Two more CodeRabbit findings: the new test asserted on a detached URL object nothing could mutate (now asserts on the installed window's real location, like the neighbouring stale-key test), and isCreateSurfaceUrl accepted any non-empty ?new= while useAgentHomeVariants accepts only 1/true - ?new=0 would have skipped capture yet rendered Home, silently losing the key. Both sites now agree on the two values and name each other as the constraint. 18/18 tests pass.
…red template Codex P1: a record another tab stored from a real deep link was still restored into activeTemplateAtom on ?new=1 URLs, re-arming the consumer - the side door to the exact create+redirect this branch closes. Create- surface loads now clear the active atom and return early; the stored record stays (that tab's intent is its own, the TTL bounds it) so a later non-create load still honours it. Two new tests; 20/20 pass.
What happened
Creating an app from a template threw the user into a loop: every visit to the site redirected to the newest changelog-writer playground, every UI action created yet another agent (15 duplicates in the QA database, eleven of them in a one-minute burst), and new sessions/chats got stuck.
Root cause
The in-app create surface (
?new=1&template=...) reuses thetemplatequery param to pre-select a template in its composer. The website deep-link capture (captureTemplateFromUrl) treated those in-app URLs as deep links, so each arrival persisted a pending-template key to localStorage.useConsumePendingTemplatethen minted an agent from it and redirected to its playground. When the claim raced and lost, the stored key was never cleared, so the loop re-armed on every page load.The fix
captureTemplateFromUrlignores create-surface URLs (?new=1), so an in-app template pick never registers as a deep link.OnboardingEntrystands down from its first-run playground redirect when the user asked for the create surface by name (?new=1).Verification
web/oss/src/state/url/template.test.ts, including new cases for the create-surface URLs.