mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
chore(lint): replace ESLint with Oxlint and clear anti-slop findings
This commit is contained in:
1 parent
c6c13335e5
commit
b625acfc0c
1083 files changed
+67089
-80136
No files matched your search
@@ -1,65 +1,26 @@
|
||||
/** Storage key under which a device persists the pause-before-sending duration. */
|
||||
export const VOICE_PAUSE_STORAGE_KEY = 'voice.pauseBeforeSendingMs'
|
||||
|
||||
/**
|
||||
* Pause durations, in milliseconds, offered by the pause-before-sending picker.
|
||||
* A stored or requested value outside this list is treated as absent.
|
||||
*/
|
||||
export const VOICE_PAUSE_OPTIONS_MS = [800, 1200, 1600, 2000, 3000] as const
|
||||
|
||||
/**
|
||||
* Pause duration applied before the first stored value is hydrated, and the
|
||||
* value persisted when storage holds nothing usable.
|
||||
*/
|
||||
export const DEFAULT_VOICE_PAUSE_MS = 1200
|
||||
|
||||
/**
|
||||
* Fixed silence timeout, in milliseconds, that ends a hands-free voice turn.
|
||||
* Not user-adjustable and therefore independent of the pause preference.
|
||||
*/
|
||||
export const VOICE_NO_SPEECH_TIMEOUT_MS = 10_000
|
||||
|
||||
/**
|
||||
* Reports whether `value` is one of the selectable pause durations.
|
||||
*
|
||||
* @param value Candidate pause duration in milliseconds.
|
||||
* @returns Whether the value is offered by the pause-before-sending picker.
|
||||
*/
|
||||
const VOICE_PAUSE_OPTION_SET: ReadonlySet<number> = new Set(VOICE_PAUSE_OPTIONS_MS)
|
||||
|
||||
export function isVoicePauseOption(value: number): boolean {
|
||||
return (VOICE_PAUSE_OPTIONS_MS as readonly number[]).includes(value)
|
||||
return VOICE_PAUSE_OPTION_SET.has(value)
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a stored pause duration. A value that is not one of
|
||||
* {@link VOICE_PAUSE_OPTIONS_MS} is treated as absent, so the caller keeps
|
||||
* {@link DEFAULT_VOICE_PAUSE_MS}.
|
||||
*
|
||||
* @param raw The stored string.
|
||||
* @returns The pause duration in milliseconds, or undefined when it is unusable.
|
||||
*/
|
||||
export function parseVoicePauseMs(raw: string): number | undefined {
|
||||
const ms = Number(raw)
|
||||
return isVoicePauseOption(ms) ? ms : undefined
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes a requested pause duration. A value that is not one of
|
||||
* {@link VOICE_PAUSE_OPTIONS_MS} is rejected instead of being clamped.
|
||||
*
|
||||
* @param ms Requested pause duration in milliseconds.
|
||||
* @returns The pause duration in milliseconds, or undefined when it is unusable.
|
||||
*/
|
||||
export function normalizeVoicePauseMs(ms: number): number | undefined {
|
||||
return isVoicePauseOption(ms) ? ms : undefined
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a pause duration as the one-decimal seconds label used by the
|
||||
* pause-before-sending picker and the settings row.
|
||||
*
|
||||
* @param ms Pause duration in milliseconds.
|
||||
* @returns The label, for example `"1.2 s"` for 1200 milliseconds.
|
||||
*/
|
||||
export function formatVoicePauseMs(ms: number): string {
|
||||
return `${(ms / 1000).toFixed(1)} s`
|
||||
}
|
||||
Reference in new issue
Block a user