[fix] Keep Home on Home after creating your first agent - #5525
[fix] Keep Home on Home after creating your first agent#5525ashrafchowdury wants to merge 2 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Let me know if the fix is not clear, I will record a video with an explanation |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe change centralizes agent-list querying, adds settled first-run detection and created-agent cache registration, and updates agent-home redirects, loading, and onboarding navigation gates to use first-run state. ChangesAgent onboarding flow
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant AgentHome
participant useAgentsFirstRun
participant AgentQueries
participant OnboardingNavigation
AgentHome->>useAgentsFirstRun: Read resolving and firstRun
useAgentsFirstRun->>AgentQueries: Fetch unfiltered project agents
AgentQueries-->>useAgentsFirstRun: Return settled empty-list state
useAgentsFirstRun-->>AgentHome: Render loader or redirect
AgentHome->>OnboardingNavigation: Evaluate first-run navigation gates
OnboardingNavigation-->>AgentHome: Apply or remove navigation restrictions
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 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 |
There was a problem hiding this comment.
Actionable comments posted: 3
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: de8ea68c-1aaa-452a-bcf0-fe24cbde8d09
📒 Files selected for processing (4)
web/oss/src/components/pages/agent-home/OnboardingEntry.tsxweb/oss/src/components/pages/agent-home/hooks/useCreateAgent.tsweb/oss/src/components/pages/agents/store.tsweb/oss/src/state/onboarding/selectors.ts
Railway Preview Environment
|
Address CodeRabbit review on #5525. The seed/invalidate predicate only checked the search-term slot of the query key, so creating an agent prepended its row into every cached project's list and refetched all of them. It now matches the project id too, carried on CreatedAgentSeed. A failed agents-list fetch also counted as a confirmed empty list, which could send someone who already has agents into onboarding. First-run now requires a successful, fresh, empty result; an error falls through to agent-home instead of holding the loader forever. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Context
After creating your first agent from the onboarding playground, the first click on Home bounced you straight back into onboarding. The second click worked.
/appsdecides whether a project is "first run" (no agents, so redirect into onboarding) by reading the agents list. It read that list through a jotai query atom. Jotai keeps an unmounted atom's last computed value and only recomputes it when a dependency changes, so remounting/appsreplayed the snapshot from the previous visit: an empty list whose own freshness flags (isFetching,isStale) also came from that snapshot. The redirect fired on that stale copy, before the query observer re-subscribed and pushed the real list in.Instrumented run at the moment of the decision:
A second cause sat underneath it. Committing an agent busts the entities-level workflows cache, but the agents list is a separate query, so nothing refreshed it on create.
In short, fixed:
Changes
OnboardingEntrynow readsuseAgentsFirstRun(), auseQueryhook whose observer attaches during the mount render and therefore always reflects the current cache. The atoms stay as they are for the surfaces that only render the list.useCreateAgentcallsregisterCreatedAgent(), which seeds the known row into the cached list, refetches withrefetchType: "all"(nothing is subscribed to that query at commit time), then seeds again. The second seed matters because the refetch can return before the backend classifies the new revision, which would otherwise cache an empty list as fresh for the full 30 secondstaleTime.The first-run query is deliberately unfiltered. It previously inherited
agentsSearchTermAtom, which only the agents table writes and never resets, so the redirect could hinge on whatever was last typed into a search box on another page.Sidebar gating moved from "onboarding is active" to "onboarding is active and the project has no agents". Once your first agent exists, Home is a real destination and the agent-dependent links have content, so they stay clickable.
Tests
tsc --noEmitandpnpm lint-fixare clean.window.history.replaceState, so Next's router still believes it is on/w/../p/../playgroundwhile the address bar shows/apps/<id>/playground. Worth its own pass.What to QA
/appsshows the list straight away, with no loader flash and no redirect./agents, type a search term, then create an agent from Home. The table filter still works, and the new agent shows up in the unfiltered list.