feat(desktop): built-in Han/Eng layout auto-switching, terminal/Vim support, and Unicode input

This commit is contained in:
Yun Chan 2026-10-27 10:48:07 +09:00
parent 1da04b9e46
commit a3ac44da2b
109 changed files with 8234 additions and 242 deletions

View file

@ -0,0 +1,46 @@
import { describe, expect, it } from 'vitest'
import { scoreReplayCase, summarizeReplay, type ReplayCaseInput } from './replay-metrics'
function input(suggestion: string | null, truth: string, logprobs: number[] = [-0.1]): ReplayCaseInput {
return {
appName: 'Discord.exe',
prefix: '오늘 회의는 ',
truth,
raw: suggestion ?? '',
suggestion,
tokens: logprobs.map((logprob, index) => ({ token: `t${index}`, logprob })),
latencyMs: 300,
promptTokens: 100,
cachedPromptTokens: 80
}
}
describe('replay-metrics', () => {
it('맞은 어절까지 수락했다고 보고 아낀 글자를 센다', () => {
const result = scoreReplayCase(input('내일 오후 세 시에 해요', '내일 오후 네 시로 옮겼어'))
expect(result).toMatchObject({ shown: true, matchedWords: 2, firstWordHit: true, fullAccept: false })
expect(result.savedChars).toBe('내일 오후'.length - 1)
})
it('제안 전체가 실제 글 앞부분이면 통째로 수락한 것으로 본다 (끝 문장부호 무시)', () => {
const result = scoreReplayCase(input('내일 오후.', '내일 오후 세 시야'))
expect(result.fullAccept).toBe(true)
expect(result.savedChars).toBe('내일 오후'.length - 1)
})
it('첫 어절부터 다르면 아낀 글자는 0', () => {
const result = scoreReplayCase(input('다음 주에 다시 잡자', '내일 오후 세 시야'))
expect(result).toMatchObject({ firstWordHit: false, savedChars: 0 })
})
it('요약: 노출률·적중률·게이팅 곡선', () => {
const summary = summarizeReplay([
scoreReplayCase(input('내일 오후', '내일 오후 세 시야', [-0.05])),
scoreReplayCase(input('다음 주에', '내일 오후 세 시야', [-2.5])),
scoreReplayCase(input(null, '내일 오후 세 시야', []))
])
expect(summary).toMatchObject({ cases: 3, coverage: 0.667, firstWordHitAmongShown: 0.5, cachedPromptShare: 0.8 })
const strict = summary.gatingCurve.find((point) => point.minMeanLogprob === -0.1)
expect(strict).toMatchObject({ coverage: 0.333, firstWordHitAmongShown: 1 })
})
})