Repository navigation
feat(ui): route every new chat to the flagship agent - #4187
Conversation
Opening an old document or code chat quietly changed what the next new chat would be. The agent picker syncs itself to whichever session you are viewing, and "New Task" read the picker, so the agent of the conversation you just left became the agent of the one you started. New chats now ask for `gaia` unless an agent was chosen deliberately, and existing conversations keep the agent they were created with -- nothing is rewritten or rerouted on the way past. The decision moves out of the shell into `planNewTask`, so the rule can be tested without mounting App. Two layers of test: the planner's contract, and a rendered-App check that the shell actually sends `gaia`. The second one is the guard that matters -- the planner can be perfect while the call site still hands it the picker's id, which is exactly how the bug worked. `FLAGSHIP_AGENT_ID` stays separate from `DEFAULT_AGENT_ID`. They answer different questions -- "what does a new chat get?" versus "who owns a row with no agent_type?" -- and the latter has to keep matching the backend's legacy backfill. Collapsing them breaks one side or the other.
Verdict: Request changesGood fix for the reported bug, but it breaks the other half of the same feature: picking an agent on the welcome screen and starting a chat now lands you on the flagship instead of the agent you picked. The blocking issue. The welcome screen has its own copy of the Agent Hub. Choosing an agent there and hitting "Start chat" — or clicking one of that agent's suggested prompts — used to create a session with that agent, because the old code read the picker. Now the picker is ignored everywhere, and this path was never switched over to pass the chosen agent explicitly, so a deliberate choice silently becomes a flagship chat. The Agent Hub page (the full-screen one) was updated correctly; the welcome-screen copy was missed. The test-plan item "pick an agent from the Agent Hub and start a task — it still gets that agent" passes on one screen and fails on the other. Fix is small: route the welcome screen's agent-start through the same deliberate-choice path the Hub page already uses, and add one App-level test for it — the new App test file is the right place, and it is exactly the kind of regression that file was written to catch. Everything else reads well. Pulling the decision into a pure planner with its own tests, plus App-level tests that assert what actually gets sent, is the right shape — the PR is explicit that the planner tests alone would be tautological, and that's correct. Real-world evidenceThe evidence bundle exercised the HTTP layer under the changed code live on a no-inference runner: Important caveat: the evidence covers the backend contract, not the button wiring. The welcome-screen regression above lives entirely in the frontend and is not something this lane could have caught — that finding rests on static review. 🔍 Technical details🔴 Critical — the welcome screen's agent picker no longer routes (
|
|
Verdict: Approve 🟢 Fixes a genuine regression cleanly: new chats silently inherited the agent of whatever conversation you last opened, because No correctness issues found. Logic, model-tier resolution, draft-reuse guard, and the 🟢 Nit — screenshot deferred: the test plan shows vitest + CLI evidence but no rendered before/after screenshot in the PR body. That's adequate for CI-lane merge per the rubric; a screenshot in the strix-halo lane (or a follow-up on this PR once available) would complete the evidence. Not a blocker. 🔍 Technical detailsOne minor style duplication: the
|
|
Confirmed and fixed — this landed after the squash-merge, so the fix is on the base PR (#4186) as The review was right: picking an agent on the welcome screen, either from its hub card or from one of its own suggestion chips, started a flagship chat instead. Both controls were carrying the choice through the agent picker, which this PR had just stopped reading. 🔍 Technical details
The gap that let it through: |
Opening an old document or code chat quietly changed what your next chat would be. The agent picker syncs itself to whichever session you are viewing, and "New Task" read the picker — so the agent of the conversation you just left became the agent of the one you started. Now a new chat always runs the flagship
gaiaagent unless you deliberately pick something else, and the conversation you navigated away from keeps the agent it was created with.This is the routing half of milestone 2 in the UI redesign plan. The shell simplification (welcome screen, sidebar, settings reachability) follows in a separate PR so each is reviewable on its own.
Stacked on #4186 — review that one first.
Test plan
cd src/gaia/apps/webui && npx vitest run— 514 pass, 53 filesnpm run build—tscclean, build succeedsdocorcodesession), click New Task, confirm the new session runsgaiagaia🔍 Technical details
The fix.
handleNewTaskpassedstore.activeAgentIdas the new session'sagent_type. An effect inApp.tsxsetsactiveAgentIdfrom the selected session'sagent_type, so after opening a legacy chat the picker — and therefore the next create — carried that agent. The create path now takes an explicitexplicitAgentId?: string; omitting it means the flagship. Only the deliberate entry points (Agent Hub launch, agent switch) pass one.That effect is left alone on purpose: after this change it only drives picker display, not routing.
Why a separate module. The decision lives in
utils/newTask.tsas a pureplanNewTask, so it can be tested without mounting the shell (polling, SSE, onboarding fetches and all).Two test layers, and why the second is the one that matters.
newTask.test.ts(14 cases) pins the planner's contract.App.newTask.test.tsx(3 cases) renders<App />, clicks the real button, and asserts whatcreateSessionwas actually called with. The planner tests alone would be tautological — they can't stop someone re-addingexplicitAgentId: activeAgentIdat the call site, which is precisely how the bug worked. Verified by mutation: restoring the old line fails 2 of the 3 App tests and none of the 14 planner tests.FLAGSHIP_AGENT_IDvsDEFAULT_AGENT_ID. Kept separate, with a test asserting they differ.DEFAULT_AGENT_ID(chat) answers "who owns a session row with noagent_type?" and has to keep matching the backend's legacy backfill (database.py,sessions.py).FLAGSHIP_AGENT_ID(gaia) answers "what does a new chat get?". Collapsing them would either reroute existing conversations or stop new ones reaching the flagship.Backend untouched. The server's
chatdefault still applies to rows that arrive without an agent — the frontend just stops relying on it for new chats.Known gap, deferred: undo-delete in
Sidebar.tsxre-creates the session without itsagent_type, so undoing a deleteddocchat resurrects it aschat. Pre-existing onmainand untouched here; it belongs with the sidebar PR, which needs a test harness for that file anyway.