mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 20:34:18 +01:00
* 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
73 lines
2.0 KiB
JavaScript
73 lines
2.0 KiB
JavaScript
class RecorderProcessor extends AudioWorkletProcessor {
|
|
constructor(options) {
|
|
super()
|
|
this._targetSampleRate = options?.processorOptions?.targetSampleRate ?? 16000
|
|
this._inputSampleRate = sampleRate
|
|
this._ratio = this._inputSampleRate / this._targetSampleRate
|
|
this._fraction = 0
|
|
this._lastSample = 0
|
|
this._active = true
|
|
this._buffer = []
|
|
this.port.onmessage = (e) => {
|
|
if (e.data === 'stop') {
|
|
this._active = false
|
|
}
|
|
}
|
|
}
|
|
|
|
process(inputs) {
|
|
if (!this._active) {
|
|
if (this._buffer.length > 0) {
|
|
this._flushBuffer()
|
|
}
|
|
return false
|
|
}
|
|
|
|
const input = inputs[0]?.[0]
|
|
if (!input || input.length === 0) {
|
|
return true
|
|
}
|
|
|
|
const outputLength = Math.floor((input.length - this._fraction) / this._ratio)
|
|
for (let i = 0; i < outputLength; i++) {
|
|
const index = i * this._ratio + this._fraction
|
|
const sample = this._interpolate(input, index)
|
|
this._buffer.push(sample)
|
|
}
|
|
this._fraction = (outputLength * this._ratio) + this._fraction - input.length
|
|
this._lastSample = input[input.length - 1]
|
|
|
|
if (this._buffer.length >= 1024) {
|
|
this._flushBuffer()
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
_interpolate(input, index) {
|
|
if (index < 0) {
|
|
const t = (index % 1) + 1
|
|
return this._lastSample * (1 - t) + input[0] * t
|
|
}
|
|
const prevIndex = Math.floor(index)
|
|
const nextIndex = prevIndex + 1
|
|
if (nextIndex >= input.length) {
|
|
return input[prevIndex]
|
|
}
|
|
const t = index - prevIndex
|
|
return input[prevIndex] * (1 - t) + input[nextIndex] * t
|
|
}
|
|
|
|
_flushBuffer() {
|
|
const int16 = new Int16Array(this._buffer.length)
|
|
for (let i = 0; i < this._buffer.length; i++) {
|
|
const sample = Math.max(-1, Math.min(1, this._buffer[i]))
|
|
int16[i] = sample < 0 ? sample * 32768 : sample * 32767
|
|
}
|
|
this.port.postMessage(int16, [int16.buffer])
|
|
this._buffer = []
|
|
}
|
|
}
|
|
|
|
registerProcessor('recorder-processor', RecorderProcessor)
|