Local dictation had never produced a transcript on an installed build. The engine itself was healthy; every connection to it was broken. Installed builds shipped no speech engine at all: the packaging config had no entry for the faster-whisper sidecar and no pipeline step built one, so the app always fell back to a system Python without the runtime. Development was broken too, because the sidecar and SoX paths were resolved against the Vite output directory instead of the app root, which also meant recording failed with a SoX ENOENT. On hosts where localhost resolves only to IPv6, every local request was refused outright, which silently disabled both local transcription and the local LLM. The sidecar is now built and bundled (including the Silero VAD data it needs), gated by a packaging check that fails when the engine or its data is missing. Paths are discovered from the app root and fail loudly when the engine is absent. Local engine URLs are normalized to the IPv4 loopback, decoding is tuned so repeated hallucinations cannot compound (the same transcript now takes about a fifth of the time), the engine is warmed up at startup, and holding the hotkey now shows the text forming live in the recording tip.
54 lines
2.1 KiB
TypeScript
54 lines
2.1 KiB
TypeScript
// tests/main/utils/loopback.test.ts
|
|
// 로컬 엔진 URL 정규화 테스트.
|
|
// Windows에서 localhost가 ::1로만 해석되어 Ollama/sidecar 연결이 실패했던 회귀를 고정한다.
|
|
|
|
import { describe, it, expect } from 'vitest'
|
|
import { loopbackUrl, normalizeLoopbackUrl } from '../../../src/main/utils/loopback'
|
|
|
|
describe('normalizeLoopbackUrl', () => {
|
|
it('rewrites a bare localhost host to the IPv4 loopback', () => {
|
|
expect(normalizeLoopbackUrl('http://localhost:11434')).toBe('http://127.0.0.1:11434')
|
|
})
|
|
|
|
it('keeps the port and path', () => {
|
|
expect(normalizeLoopbackUrl('http://localhost:8000/v1')).toBe('http://127.0.0.1:8000/v1')
|
|
})
|
|
|
|
it('handles https and trailing dot host forms', () => {
|
|
expect(normalizeLoopbackUrl('https://localhost:5000/health')).toBe(
|
|
'https://127.0.0.1:5000/health',
|
|
)
|
|
expect(normalizeLoopbackUrl('http://localhost.:1234')).toBe('http://127.0.0.1:1234')
|
|
})
|
|
|
|
it('leaves remote hosts untouched', () => {
|
|
expect(normalizeLoopbackUrl('https://api.openai.com/v1')).toBe('https://api.openai.com/v1')
|
|
expect(normalizeLoopbackUrl('http://192.168.0.10:11434')).toBe('http://192.168.0.10:11434')
|
|
expect(normalizeLoopbackUrl('http://127.0.0.1:11434')).toBe('http://127.0.0.1:11434')
|
|
})
|
|
|
|
it('does not treat lookalike hostnames as loopback', () => {
|
|
expect(normalizeLoopbackUrl('http://localhost.evil.com')).toBe('http://localhost.evil.com')
|
|
})
|
|
|
|
it('falls back to a textual rewrite when the URL is not parseable', () => {
|
|
// 잘못된 포트는 URL 파서가 던진다 → 정규식 폴백 경로를 탄다.
|
|
expect(normalizeLoopbackUrl('http://localhost:99999999')).toBe(
|
|
'http://127.0.0.1:99999999',
|
|
)
|
|
})
|
|
|
|
it('passes through inputs without a recognizable host', () => {
|
|
expect(normalizeLoopbackUrl('localhost:11434')).toBe('localhost:11434')
|
|
})
|
|
|
|
it('returns empty input unchanged', () => {
|
|
expect(normalizeLoopbackUrl('')).toBe('')
|
|
})
|
|
})
|
|
|
|
describe('loopbackUrl', () => {
|
|
it('builds an IPv4 loopback URL for a port', () => {
|
|
expect(loopbackUrl(18765)).toBe('http://127.0.0.1:18765')
|
|
})
|
|
})
|