fix: update settings and skills handling with assistant redirect (#220)

* fix: enable swipe-back suspension on more drawer and remove unused variable

* refactor(frontend): improve dialog component and settings navigation

* fix: disable route swipe suspension in MoreDrawer to prevent unintended navigation

* fix(frontend): enable swipe-back suspension on more drawer route

* refactor(frontend): improve mobile navigation drawer and tab bar

* feat: add schedules service and workspace hook with navigation updates

* chore: add workspace hook, schedules library, and tests

* fix: prevent MoreDrawer sentinel from undoing navigation

* feat: per-agent model selection and UI refinements (#217)

* feat: per-agent model selection and UI refinements

- Add agentModels store with setAgentModel/getAgentModel
- PromptInput uses session model priority and stores agent model on change
- useContextUsage derives model from assistant message instead of global
- Migrate sub-agent/subtask badges from purple to blue with refined styling
- Fix MoreDrawer sentinel to skip history-back on navigation

* refactor: improve per-agent model selection and task tool call status indicators

* feat: add repo management skill and internal repos API

* fix: improve assistant session launcher and UI components

* fix: update atomic-json test assertions

* refactor: split Assistant Mode instructions between AGENTS.md and assistant.md

* loop: todo-header-mobile completed after 3 iterations (#218)

* loop: stt-perf-1 completed after 5 iterations

* fix: load audio worklet per recording context

* fix: canonicalize assistant navigation routes

* fix: adjust scroll-up threshold for header visibility

* fix: update settings and skills handling with assistant redirect

* refactor: simplify context usage indicator and extract token sum helper

* feat: add currently selected model row to popover and fix responsive truncate
This commit is contained in:
Chris Scott authored and GitHub committed 2026-05-07 18:36:03 -04:00
1 parent c7291518c8
commit 74cdeb3926
73 files changed
+4073 -632

No files matched your search

@@ -7,7 +7,7 @@ import { initializeAssistantMode } from '@/api/repos'
const mocks = vi.hoisted(() => ({
listSessions: vi.fn(),
createSession: vi.fn(),
sendPrompt: vi.fn(),
sendPromptAsync: vi.fn(),
initializeAssistantMode: vi.fn(),
}))
@@ -19,10 +19,14 @@ vi.mock('@/api/opencode', () => ({
OpenCodeClient: vi.fn(() => ({
listSessions: mocks.listSessions,
createSession: mocks.createSession,
sendPrompt: mocks.sendPrompt,
sendPromptAsync: mocks.sendPromptAsync,
})),
}))
beforeEach(() => {
mocks.sendPromptAsync.mockResolvedValue(undefined)
})
describe('useAssistantSessionLauncher', () => {
beforeEach(() => {
vi.clearAllMocks()
@@ -51,6 +55,45 @@ describe('useAssistantSessionLauncher', () => {
expect(OpenCodeClient).toHaveBeenCalledWith('http://localhost:5551', '/assistant')
expect(onNavigate).toHaveBeenCalledWith('newest')
expect(mocks.createSession).not.toHaveBeenCalled()
expect(mocks.sendPromptAsync).not.toHaveBeenCalled()
})
it('notifies an existing assistant session when some generated updates were preserved', async () => {
mocks.initializeAssistantMode.mockResolvedValue({
directory: '/assistant',
warnings: [
{
code: 'assistant-agents-md-preserved',
path: '/assistant/AGENTS.md',
message: 'Some Assistant Mode instruction updates were not applied because AGENTS.md appears to contain customized legacy assistant instructions. To regenerate the default workspace explanation, manually delete AGENTS.md and initialize Assistant Mode again.',
},
],
})
mocks.listSessions.mockResolvedValue([
{ id: 'existing', directory: '/assistant', time: { updated: 10 } },
])
const onNavigate = vi.fn()
const { result } = renderHook(() => useAssistantSessionLauncher({
repoId: 123,
opcodeUrl: 'http://localhost:5551',
onNavigate,
}))
await act(async () => {
await result.current.openAssistant()
})
expect(onNavigate).toHaveBeenCalledWith('existing')
expect(mocks.sendPromptAsync).toHaveBeenCalledWith('existing', {
parts: [
expect.objectContaining({
type: 'text',
text: expect.stringContaining('some generated instruction changes were not applied'),
}),
],
})
const promptText = mocks.sendPromptAsync.mock.calls[0][1].parts[0].text as string
expect(promptText).toContain('manually delete AGENTS.md')
})
it('creates a session when the assistant directory has no root sessions', async () => {
@@ -70,7 +113,7 @@ describe('useAssistantSessionLauncher', () => {
})
expect(mocks.createSession).toHaveBeenCalledWith({ title: 'Assistant' })
expect(mocks.sendPrompt).toHaveBeenCalledWith('created', {
expect(mocks.sendPromptAsync).toHaveBeenCalledWith('created', {
parts: [
expect.objectContaining({
type: 'text',
@@ -79,5 +122,66 @@ describe('useAssistantSessionLauncher', () => {
],
})
expect(onNavigate).toHaveBeenCalledWith('created')
const promptCall = mocks.sendPromptAsync.mock.calls[0]
const promptText = promptCall[1].parts[0].text as string
expect(promptText).toContain('.opencode/agents/assistant.md')
expect(promptText).toContain('AGENTS.md')
expect(promptText).toContain('.opencode/skills/')
expect(promptText).toContain('directory')
expect(promptText).toContain('durable preferences')
expect(promptText).toContain('self-editing rules')
expect(promptText).not.toContain('v file')
expect(promptText).not.toMatch(/AGENTS\.md contains workspace-level instructions, durable preferences, and self-editing rules/)
})
it('navigates after creating a session without waiting for the welcome prompt to complete', async () => {
mocks.listSessions.mockResolvedValue([])
let resolvePrompt: () => void
const promptPromise = new Promise<void>((resolve) => {
resolvePrompt = resolve
})
mocks.createSession.mockResolvedValue({ id: 'created' })
mocks.sendPromptAsync.mockImplementation(() => promptPromise)
const onNavigate = vi.fn()
const { result } = renderHook(() => useAssistantSessionLauncher({
repoId: 123,
opcodeUrl: 'http://localhost:5551',
onNavigate,
}))
await act(async () => {
await result.current.openAssistant()
})
expect(onNavigate).toHaveBeenCalledWith('created')
expect(mocks.sendPromptAsync).toHaveBeenCalledWith('created', {
parts: [
expect.objectContaining({
type: 'text',
text: expect.stringContaining('Welcome to OpenCode Manager!'),
}),
],
})
resolvePrompt!()
})
it('navigates even when welcome prompt fails', async () => {
mocks.listSessions.mockResolvedValue([])
mocks.createSession.mockResolvedValue({ id: 'created' })
mocks.sendPromptAsync.mockRejectedValueOnce(new Error('provider unavailable'))
const onNavigate = vi.fn()
const { result } = renderHook(() => useAssistantSessionLauncher({
repoId: 123,
opcodeUrl: 'http://localhost:5551',
onNavigate,
}))
await act(async () => {
await result.current.openAssistant()
})
expect(onNavigate).toHaveBeenCalledWith('created')
expect(mocks.sendPromptAsync).toHaveBeenCalled()
})
})