Skip to content

[fix] Keep Home on Home after creating your first agent - #5525

Open
ashrafchowdury wants to merge 2 commits into
mainfrom
fix/agent-onboarding-playground-related-issues
Open

[fix] Keep Home on Home after creating your first agent#5525
ashrafchowdury wants to merge 2 commits into
mainfrom
fix/agent-onboarding-playground-related-issues

Conversation

@ashrafchowdury

Copy link
Copy Markdown
Contributor

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.

/apps decides 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 /apps replayed 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:

component:  agents=0, settled=true   -> redirect
query cache: rows=1, status=success, age=3s

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:

  • Enable the agents page option on the sidebar after creating an agent
  • After creating an agent, navigating to the home page should never redirect us to the onboarding playground again
  • Switching orgs that have agents on their project was showing the agent onboarding playground - fixed it

Changes

OnboardingEntry now reads useAgentsFirstRun(), a useQuery hook 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.

useCreateAgent calls registerCreatedAgent(), which seeds the known row into the cached list, refetches with refetchType: "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 second staleTime.

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

  • Playwright ran the reported flow end to end (land on an empty project, describe an agent, create it, click Home once). It failed on every run before the change and passes after. The spec is not included in this branch.
  • tsc --noEmit and pnpm lint-fix are clean.
  • Not fixed here: the in-place commit updates the URL with window.history.replaceState, so Next's router still believes it is on /w/../p/../playground while the address bar shows /apps/<id>/playground. Worth its own pass.

What to QA

  • Fresh project with no agents. Landing on it sends you to the onboarding playground. Describe an agent, create it, then click Home once. You land on the agents home and stay there.
  • During onboarding, before the agent commits: Home is inert and the agent-dependent sidebar links are disabled. Right after the commit: Home is clickable and those links are live.
  • Regression: open a project that already has agents. /apps shows the list straight away, with no loader flash and no redirect.
  • Regression: on /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.

@vercel

vercel Bot commented Jul 27, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agenta-documentation Ready Ready Preview, Comment Jul 27, 2026 12:18pm

Request Review

@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. Bug Report Something isn't working Frontend labels Jul 27, 2026
@ashrafchowdury

Copy link
Copy Markdown
Contributor Author

Let me know if the fix is not clear, I will record a video with an explanation

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 03a42489-9863-43c9-9321-74ecc9498dc9

📥 Commits

Reviewing files that changed from the base of the PR and between 4d4a275 and a74f006.

📒 Files selected for processing (3)
  • web/oss/src/components/pages/agent-home/OnboardingEntry.tsx
  • web/oss/src/components/pages/agent-home/hooks/useCreateAgent.ts
  • web/oss/src/components/pages/agents/store.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • web/oss/src/components/pages/agent-home/OnboardingEntry.tsx
  • web/oss/src/components/pages/agent-home/hooks/useCreateAgent.ts
  • web/oss/src/components/pages/agents/store.ts

📝 Walkthrough

Summary by CodeRabbit

  • New Features
    • Improved first-run onboarding detection for projects with no agents.
    • Newly created agents now show up in agent lists immediately.
  • Bug Fixes
    • Prevented incorrect redirects while agent data is still loading.
    • Adjusted onboarding navigation controls so they apply only during the initial setup experience.
    • Improved navigation behavior after onboarding completes and during list refreshes.

Walkthrough

The 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.

Changes

Agent onboarding flow

Layer / File(s) Summary
Shared agent query and first-run detection
web/oss/src/components/pages/agents/store.ts
Shared query options now serve the Jotai query atom and useAgentsFirstRun, which derives settled empty-list and first-run state.
Created-agent cache registration
web/oss/src/components/pages/agents/store.ts, web/oss/src/components/pages/agent-home/hooks/useCreateAgent.ts
Created agents are seeded into project-scoped unfiltered cached results, matching queries are invalidated and reseeded, and agent creation invokes registration before navigation.
First-run onboarding rendering and navigation
web/oss/src/components/pages/agent-home/OnboardingEntry.tsx, web/oss/src/state/onboarding/selectors.ts
Agent-home redirect and loading conditions use first-run state, while navigation atoms apply restrictions only during first-run onboarding.

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
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: keeping Home from redirecting back to onboarding after the first agent is created.
Description check ✅ Passed The description is detailed and directly describes the onboarding, first-run, and agent-creation fixes in the changeset.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/agent-onboarding-playground-related-issues

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.

@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: 3


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: de8ea68c-1aaa-452a-bcf0-fe24cbde8d09

📥 Commits

Reviewing files that changed from the base of the PR and between cb095f7 and 4d4a275.

📒 Files selected for processing (4)
  • web/oss/src/components/pages/agent-home/OnboardingEntry.tsx
  • web/oss/src/components/pages/agent-home/hooks/useCreateAgent.ts
  • web/oss/src/components/pages/agents/store.ts
  • web/oss/src/state/onboarding/selectors.ts

Comment thread web/oss/src/components/pages/agent-home/hooks/useCreateAgent.ts
Comment thread web/oss/src/components/pages/agents/store.ts
Comment thread web/oss/src/components/pages/agents/store.ts
@github-actions

github-actions Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Railway Preview Environment

Preview URL https://gateway-production-e3d7.up.railway.app/w
Project agenta-oss-pr-5525
Image tag pr-5525-d10eaa4
Status Deployed
Railway logs Open logs
Workflow logs View workflow run
Updated at 2026-07-27T12:29:48.422Z

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Report Something isn't working Frontend size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant