Skip to content

fix(guid): use effective backend type for preset agent config lookups#1711

Merged
IceyLiu merged 1 commit intomainfrom
fix/guid-preset-agent-config
Mar 25, 2026
Merged

fix(guid): use effective backend type for preset agent config lookups#1711
IceyLiu merged 1 commit intomainfrom
fix/guid-preset-agent-config

Conversation

@kaizhou-lab
Copy link
Copy Markdown
Collaborator

Summary

  • Fix preset assistant selection using 'custom' as config key instead of the effective backend type (e.g. 'claude'), causing mode preferences not loading/saving and model list not displaying
  • Move currentEffectiveAgentInfo memo before dependent effects to resolve the lookup correctly
  • Add unit tests for agentSelectionUtils and hook behavior tests for preset agent config resolution

Changes

useGuidAgentSelection.ts

  • Mode loading effect: use currentEffectiveAgentInfo.agentType as config key for preset agents instead of selectedAgent ('custom'), removing the selectedAgent !== 'custom' skip condition
  • ACP model reset effect: resolve to effective backend type for acp.config preference lookup
  • currentAcpCachedModelInfo memo: look up cached models by effective backend type
  • currentEffectiveAgentInfo memo: moved before the effects that depend on it

Tests

  • agentSelectionUtils.test.ts — unit tests for savePreferredMode, savePreferredModelId, getAgentKey
  • guidAgentSelection.dom.test.ts — hook behavior tests verifying preset agent mode loading, mode saving, and model cache resolution

Related Issue

Closes #1710

Test Plan

  • Select a preset assistant (e.g. Cowork) → verify mode selector shows saved preference
  • Switch mode on a preset assistant → create conversation → verify mode is carried over
  • Select a preset assistant that maps to Claude → verify model list displays Claude models
  • Select agent from PillBar directly → verify mode and model list still work as before
  • bun run test passes (17 new tests added)

When selecting a preset assistant via AssistantSelectionArea,
selectedAgent was set to 'custom', causing mode loading, mode saving,
and ACP model cache lookups to use 'custom' as the config key instead
of the actual backend type (e.g. 'claude'). This resulted in:

- Mode preference not loading from saved config
- Mode changes not persisting across sessions
- Model list not displaying (cache lookup under wrong key)

Fix: resolve the effective backend type via currentEffectiveAgentInfo
and use it for all config/cache lookups when a preset agent is selected.
Move currentEffectiveAgentInfo memo before dependent effects.

Add unit tests for agentSelectionUtils and hook behavior tests verifying
preset agent config resolution for mode and model cache.
@IceyLiu IceyLiu merged commit bb9a942 into main Mar 25, 2026
13 of 17 checks passed
@piorpua piorpua deleted the fix/guid-preset-agent-config branch March 25, 2026 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(guid): preset agent mode and model config lookup uses wrong key

2 participants