Default composer to first agent/model without an eager probe fetch - #154
Conversation
…fetch Reinstate defaulting pendingAgent to agents[0] for draft threads so the composer opens with an agent (and once models load, a model) pre-selected. Keep the getDraftCatalog probe lazy by gating it on a new catalogArmed flag that only flips once the user actually interacts with the composer (focuses the prompt editor or opens the agent/model picker), so the default selection alone never fires the RPC. Fixes #147.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reached
Next review available in: 2 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughDraft threads now select the first available agent when no pending agent is set. Vitest tests cover explicit selection and display fallback behavior for missing, unknown, and valid IDs. ChangesAgent selection
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 |
Drop the catalogArmed interaction-gating from the previous commit: the getDraftCatalog probe's query key is scoped to (agent, projectId) with staleTime Infinity, so it's already deduped per project rather than per draft. Gating it behind first focus/interaction only delayed the model selection without avoiding any real extra network cost, and it diverged from the goal of having both the agent and its first model selected as soon as a new thread is created. catalogAgent now simply follows pendingAgent once the default-agent effect sets it, matching the pre-removal behavior.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@shared/hooks/src/agent-catalog/use-agent-catalog.ts`:
- Around line 168-174: The draft initialization effect should not call
setPendingAgent merely to arm the catalog query, because that enables
getDraftCatalog before user interaction. Introduce and use separate
catalogArmedByThread state for the draft catalog enabled condition, or remove
the default pending-agent selection from this render path while preserving
pendingAgent for actual user selection.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: b22b8a52-25fb-4bde-9109-cdfb0bd0188c
📒 Files selected for processing (2)
shared/hooks/src/agent-catalog/selectors.test.tsshared/hooks/src/agent-catalog/use-agent-catalog.ts
The composer previously revealed its real body as soon as agentsQuery resolved, so a fresh draft briefly rendered with only the default agent selected while its model was still being fetched. Latch a draftCatalogSettled flag (reset per draft/project identity) that only flips once catalog.displayAgent is set and catalog.modelsLoading is false, and hold ComposerSkeleton until then. The latch is one-way so a later agent switch mid-typing never re-hides the editor.
CI=1 keeps wrangler d1 migrations apply --local from prompting, which otherwise blocks bun dev:server in non-interactive shells.
Summary
pendingAgenttoagents[0]for draft threads so the composer opens with an agent pre-selected.catalogAgent(which gates thegetDraftCatalogprobe) simply followspendingAgentonce that default fires, so the model auto-select effect runs immediately too — both the agent and its first model are selected as soon as a new thread is created.(agentName, projectId)withstaleTime: Infinity(seeuse-draft-catalog.ts), so it's already deduped per project rather than per draft — firing it on every new draft doesn't reintroduce repeated network calls, just one legitimate fetch per project.An earlier revision of this PR gated the probe behind first focus/interaction with the composer, to avoid re-triggering the eager-fetch behavior that motivated the original default-selection removal. That turned out to only delay the model selection without avoiding any real extra cost (thanks to the query-key caching above), so it's been dropped in favor of the simpler, fully-default-on-mount behavior.
Fixes #147
Test plan
bun run check:types(typecheck)ultracite check(lint)bun test:unit— 134 passedshared/hooks/src/agent-catalog/selectors.test.ts🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests