feat: make MCP restore command always available in Cmd+K

The "Install MCP Server" command was only enabled when status was
"not_installed", preventing users from re-registering when MCP got
removed or broken. Now the command is always available:
- Shows "Install MCP Server" when not installed
- Shows "Restore MCP Server" when already installed
- Added restore/fix/repair keywords for discoverability
- Context-aware toast: "installed" vs "restored"
- Menu bar label updated to "Restore MCP Server"

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
lucaronin
2026-03-07 11:33:18 +01:00
parent 0d4ca63ec8
commit f2ec2ab55c
5 changed files with 95 additions and 7 deletions

View File

@@ -197,6 +197,64 @@ describe('groupSortKey', () => {
})
})
describe('install-mcp command', () => {
it('is enabled when mcpStatus is not_installed and handler provided', () => {
const config = makeConfig({ mcpStatus: 'not_installed', onInstallMcp: vi.fn() })
const { result } = renderHook(() => useCommandRegistry(config))
const cmd = findCommand(result.current, 'install-mcp')
expect(cmd).toBeDefined()
expect(cmd!.enabled).toBe(true)
expect(cmd!.label).toBe('Install MCP Server')
})
it('is enabled when mcpStatus is installed and handler provided (restore use case)', () => {
const config = makeConfig({ mcpStatus: 'installed', onInstallMcp: vi.fn() })
const { result } = renderHook(() => useCommandRegistry(config))
const cmd = findCommand(result.current, 'install-mcp')
expect(cmd!.enabled).toBe(true)
expect(cmd!.label).toBe('Restore MCP Server')
})
it('is disabled when mcpStatus is checking', () => {
const config = makeConfig({ mcpStatus: 'checking', onInstallMcp: vi.fn() })
const { result } = renderHook(() => useCommandRegistry(config))
const cmd = findCommand(result.current, 'install-mcp')
expect(cmd!.enabled).toBe(false)
})
it('is disabled when no handler provided', () => {
const config = makeConfig({ mcpStatus: 'not_installed' })
const { result } = renderHook(() => useCommandRegistry(config))
const cmd = findCommand(result.current, 'install-mcp')
expect(cmd!.enabled).toBe(false)
})
it('has restore keyword for discoverability', () => {
const config = makeConfig({ mcpStatus: 'installed', onInstallMcp: vi.fn() })
const { result } = renderHook(() => useCommandRegistry(config))
const cmd = findCommand(result.current, 'install-mcp')
expect(cmd!.keywords).toContain('restore')
expect(cmd!.keywords).toContain('mcp')
expect(cmd!.keywords).toContain('claude')
})
it('executes onInstallMcp callback', () => {
const onInstallMcp = vi.fn()
const config = makeConfig({ mcpStatus: 'installed', onInstallMcp })
const { result } = renderHook(() => useCommandRegistry(config))
const cmd = findCommand(result.current, 'install-mcp')
cmd!.execute()
expect(onInstallMcp).toHaveBeenCalled()
})
it('is in Settings group', () => {
const config = makeConfig({ mcpStatus: 'installed', onInstallMcp: vi.fn() })
const { result } = renderHook(() => useCommandRegistry(config))
const cmd = findCommand(result.current, 'install-mcp')
expect(cmd!.group).toBe('Settings')
})
})
describe('buildTypeCommands', () => {
it('creates new and list commands for each type', () => {
const onCreateNoteOfType = vi.fn()