mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 12:24:30 +01:00
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:
1 parent
c7291518c8
commit
74cdeb3926
73 files changed
+4073
-632
No files matched your search
@@ -229,9 +229,12 @@ export const settingsApi = {
|
||||
return fetchWrapper(`${API_BASE_URL}/api/health/version`)
|
||||
},
|
||||
|
||||
listManagedSkills: async (repoId?: number): Promise<SkillFileInfo[]> => {
|
||||
const params = repoId ? `?repoId=${repoId}` : ''
|
||||
return fetchWrapper(`${API_BASE_URL}/api/settings/skills${params}`)
|
||||
listManagedSkills: async (repoId?: number, directory?: string): Promise<SkillFileInfo[]> => {
|
||||
const searchParams = new URLSearchParams()
|
||||
if (repoId) searchParams.set('repoId', String(repoId))
|
||||
if (directory) searchParams.set('directory', directory)
|
||||
const query = searchParams.toString() ? `?${searchParams.toString()}` : ''
|
||||
return fetchWrapper(`${API_BASE_URL}/api/settings/skills${query}`)
|
||||
},
|
||||
|
||||
getSkill: async (name: string, scope: SkillScope, repoId?: number): Promise<SkillFileInfo> => {
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
|
||||
import { sttApi } from './stt'
|
||||
|
||||
describe('WAV extension selection logic', () => {
|
||||
const originalFetch = global.fetch
|
||||
const mockFetch = vi.fn()
|
||||
|
||||
beforeEach(() => {
|
||||
vi.stubGlobal('fetch', mockFetch)
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
vi.restoreAllMocks()
|
||||
global.fetch = originalFetch
|
||||
})
|
||||
|
||||
const createMockResponse = (ok = true, data = {}) => {
|
||||
return new Response(JSON.stringify(data), {
|
||||
status: ok ? 200 : 400,
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
})
|
||||
}
|
||||
|
||||
it('should return wav for audio/wav blob', async () => {
|
||||
const blob = new Blob([], { type: 'audio/wav' })
|
||||
mockFetch.mockResolvedValueOnce(createMockResponse(true, { text: 'test' }))
|
||||
|
||||
await sttApi.transcribe(blob, 'test-user')
|
||||
|
||||
const callArgs = mockFetch.mock.calls[0]
|
||||
const formData = callArgs[1]?.body as FormData
|
||||
const audioFile = formData.get('audio') as File
|
||||
expect(audioFile.name).toBe('recording.wav')
|
||||
})
|
||||
|
||||
it('should return webm for audio/webm blob', async () => {
|
||||
const blob = new Blob([], { type: 'audio/webm' })
|
||||
mockFetch.mockResolvedValueOnce(createMockResponse(true, { text: 'test' }))
|
||||
|
||||
await sttApi.transcribe(blob, 'test-user')
|
||||
|
||||
const callArgs = mockFetch.mock.calls[0]
|
||||
const formData = callArgs[1]?.body as FormData
|
||||
const audioFile = formData.get('audio') as File
|
||||
expect(audioFile.name).toBe('recording.webm')
|
||||
})
|
||||
|
||||
it('should return ogg for audio/ogg blob', async () => {
|
||||
const blob = new Blob([], { type: 'audio/ogg' })
|
||||
mockFetch.mockResolvedValueOnce(createMockResponse(true, { text: 'test' }))
|
||||
|
||||
await sttApi.transcribe(blob, 'test-user')
|
||||
|
||||
const callArgs = mockFetch.mock.calls[0]
|
||||
const formData = callArgs[1]?.body as FormData
|
||||
const audioFile = formData.get('audio') as File
|
||||
expect(audioFile.name).toBe('recording.ogg')
|
||||
})
|
||||
|
||||
it('should return m4a for audio/mp4 blob', async () => {
|
||||
const blob = new Blob([], { type: 'audio/mp4' })
|
||||
mockFetch.mockResolvedValueOnce(createMockResponse(true, { text: 'test' }))
|
||||
|
||||
await sttApi.transcribe(blob, 'test-user')
|
||||
|
||||
const callArgs = mockFetch.mock.calls[0]
|
||||
const formData = callArgs[1]?.body as FormData
|
||||
const audioFile = formData.get('audio') as File
|
||||
expect(audioFile.name).toBe('recording.m4a')
|
||||
})
|
||||
|
||||
it('should default to wav for unknown types', async () => {
|
||||
const blob = new Blob([], { type: 'audio/unknown' })
|
||||
mockFetch.mockResolvedValueOnce(createMockResponse(true, { text: 'test' }))
|
||||
|
||||
await sttApi.transcribe(blob, 'test-user')
|
||||
|
||||
const callArgs = mockFetch.mock.calls[0]
|
||||
const formData = callArgs[1]?.body as FormData
|
||||
const audioFile = formData.get('audio') as File
|
||||
expect(audioFile.name).toBe('recording.wav')
|
||||
})
|
||||
|
||||
it('should prioritize wav over webm when both present', async () => {
|
||||
const blob = new Blob([], { type: 'audio/wav;codecs=pcm' })
|
||||
mockFetch.mockResolvedValueOnce(createMockResponse(true, { text: 'test' }))
|
||||
|
||||
await sttApi.transcribe(blob, 'test-user')
|
||||
|
||||
const callArgs = mockFetch.mock.calls[0]
|
||||
const formData = callArgs[1]?.body as FormData
|
||||
const audioFile = formData.get('audio') as File
|
||||
expect(audioFile.name).toBe('recording.wav')
|
||||
})
|
||||
|
||||
it('should include userId in request URL', async () => {
|
||||
const blob = new Blob([], { type: 'audio/wav' })
|
||||
mockFetch.mockResolvedValueOnce(createMockResponse(true, { text: 'test' }))
|
||||
|
||||
await sttApi.transcribe(blob, 'custom-user')
|
||||
|
||||
const callArgs = mockFetch.mock.calls[0]
|
||||
const url = callArgs[0] as string
|
||||
expect(url).toContain('userId=custom-user')
|
||||
})
|
||||
|
||||
it('should send FormData with audio file', async () => {
|
||||
const blob = new Blob(['audio data'], { type: 'audio/wav' })
|
||||
mockFetch.mockResolvedValueOnce(createMockResponse(true, { text: 'transcribed text' }))
|
||||
|
||||
await sttApi.transcribe(blob, 'test-user')
|
||||
|
||||
expect(mockFetch).toHaveBeenCalledWith(
|
||||
expect.stringContaining('/api/stt/transcribe'),
|
||||
expect.objectContaining({
|
||||
method: 'POST',
|
||||
body: expect.any(FormData),
|
||||
})
|
||||
)
|
||||
|
||||
const callArgs = mockFetch.mock.calls[0]
|
||||
const formData = callArgs[1]?.body as FormData
|
||||
expect(formData.get('audio')).toBeInstanceOf(File)
|
||||
})
|
||||
})
|
||||
@@ -42,9 +42,12 @@ export const sttApi = {
|
||||
): Promise<STTTranscribeResponse> => {
|
||||
const formData = new FormData()
|
||||
|
||||
const extension = audioBlob.type.includes('webm') ? 'webm' :
|
||||
audioBlob.type.includes('ogg') ? 'ogg' :
|
||||
audioBlob.type.includes('mp4') ? 'm4a' : 'webm'
|
||||
const type = audioBlob.type
|
||||
const extension =
|
||||
type.includes('wav') ? 'wav' :
|
||||
type.includes('webm') ? 'webm' :
|
||||
type.includes('ogg') ? 'ogg' :
|
||||
type.includes('mp4') ? 'm4a' : 'wav'
|
||||
formData.append('audio', audioBlob, `recording.${extension}`)
|
||||
|
||||
const urlObj = new URL(`${API_BASE_URL}/api/stt/transcribe`, window.location.origin)
|
||||
|
||||
Reference in new issue
Block a user