Files
windmill/frontend/src/lib/aiStore.test.ts
T
Ruben FiszelandClaude Fable 5.1 fdd3b36423 feat: workspace setting to hide the AI assistant, agent steps unaffected (#10941)
* feat: workspace setting to hide the AI assistant, agent steps unaffected

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011eNweUugVqerex6MLxjbeL

* fix: load workspace AI config on cold /sessions load and say hidden, not disabled

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011eNweUugVqerex6MLxjbeL

* fix: follow workspace switches on /sessions gate and drop deprecated button size

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011eNweUugVqerex6MLxjbeL

* fix: key the /sessions hidden-assistant gate on the acting workspace's own config

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011eNweUugVqerex6MLxjbeL

* fix: tag the /sessions hidden-assistant verdict with its workspace and drop superseded reads

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011eNweUugVqerex6MLxjbeL

* fix: overlay the /sessions hidden-assistant gate so warm sessions survive workspace switches

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011eNweUugVqerex6MLxjbeL

* fix: hide the pipeline insert menu AI prompt and refuse chat turns where the assistant is hidden

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011eNweUugVqerex6MLxjbeL

* fix: shrink the home Build with AI / CLI / Hub line to a flush hint row

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011eNweUugVqerex6MLxjbeL

* fix: frame the workspace toggle as hide AI sessions at the bottom of the AI settings

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011eNweUugVqerex6MLxjbeL

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-02 17:21:10 +02:00

75 lines
2.4 KiB
TypeScript

import { describe, expect, it, vi } from 'vitest'
import { get } from 'svelte/store'
// aiStore pulls in the (heavy) copilot lib for workspaceAIClients and the gen
// client for WorkspaceService; neither is exercised by setCopilotInfo.
vi.mock('./components/copilot/lib', () => ({
workspaceAIClients: { init: () => {} }
}))
vi.mock('./gen', () => ({
WorkspaceService: { getCopilotInfo: async () => ({}) }
}))
import { isWebSearchEnabledForProvider, setCopilotInfo, copilotInfo } from './aiStore'
describe('setCopilotInfo legacy /thinking migration', () => {
it('strips the /thinking suffix from configured model slots', () => {
setCopilotInfo({
providers: {
anthropic: {
resource_path: 'u/admin/anthropic',
models: ['claude-sonnet-4-6', 'claude-sonnet-4-6/thinking']
}
},
default_model: { model: 'claude-sonnet-4-6/thinking', provider: 'anthropic' },
metadata_model: { model: 'claude-sonnet-4-6/thinking', provider: 'anthropic' },
code_completion_model: { model: 'claude-3-5-haiku-latest', provider: 'anthropic' }
})
const info = get(copilotInfo)
// configured slots no longer carry the deprecated suffix
expect(info.defaultModel?.model).toBe('claude-sonnet-4-6')
expect(info.metadataModel?.model).toBe('claude-sonnet-4-6')
expect(info.codeCompletionModel?.model).toBe('claude-3-5-haiku-latest')
// the model list is stripped and deduped
expect(info.aiModels.map((m) => m.model)).toEqual(['claude-sonnet-4-6'])
})
it('keeps the models but turns the assistant off when the workspace disabled it', () => {
setCopilotInfo({
providers: {
anthropic: {
resource_path: 'u/admin/anthropic',
models: ['claude-sonnet-4-6']
}
},
copilot_disabled: true
})
const info = get(copilotInfo)
expect(info.enabled).toBe(false)
expect(info.workspaceDisabled).toBe(true)
// The providers still describe what AI agent steps can run on.
expect(info.aiModels.map((m) => m.model)).toEqual(['claude-sonnet-4-6'])
})
it('defaults provider web search on unless explicitly disabled', () => {
setCopilotInfo({
providers: {
openai: {
resource_path: 'u/admin/openai',
models: ['gpt-4.1'],
web_search_enabled: false
},
anthropic: {
resource_path: 'u/admin/anthropic',
models: ['claude-sonnet-4-6']
}
}
})
expect(isWebSearchEnabledForProvider('openai')).toBe(false)
expect(isWebSearchEnabledForProvider('anthropic')).toBe(true)
})
})