fix(cli): reload MCP servers and skills after project change in picker - #1328
fix(cli): reload MCP servers and skills after project change in picker#1328sohailnajar147 wants to merge 1 commit into
Conversation
|
Good bug fix with a clear root cause: The new integration test A couple of things worth double-checking before porting:
Overall: correct diagnosis, minimal fix, in-scope files, good tests. Recommending as a port candidate. |
Summary
Fixes #957.
When the CLI is started outside a project (such as in
~) and a project is selected through the Project Picker, project-specific MCP servers and skills were not loaded because the registries remained initialized from the original working directory.This fix reloads both
initializeAgentRegistry()andinitializeSkillRegistry()after changing projects, adds debug logging, and clears the cached local-agent state so the new project's.agents/configuration is picked up correctly.Changes
Reload registries: In
cli/src/index.tsx, invokeinitializeAgentRegistry()andinitializeSkillRegistry()after updating the project root inhandleProjectChange.Cache invalidation: In
cli/src/utils/local-agent-registry.ts, resetcachedAgentsDirandcachedAgentsByModewhen reinitializing so directory lookups and the@menu don't serve stale cache from the launch directory.Observability: Added a debug log confirming MCP servers and skills were reloaded for the project.
Regression tests: Added
cli/src/__tests__/integration/project-change-reload.test.tscovering bug reproduction, MCP and skill reloading, project-to-project switching, and cache clearing.Testing
Ran the new and affected test suites:
Result: 58 tests passed.
Also manually verified the original issue before and after the fix, including switching between projects with different
.agents/configurations.