feat(desktop): typo auto-correct and context-aware sentence prediction
Some checks failed
ci / 정본·보안·린트·타입·테스트 (push) Has been cancelled
deploy-site / deploy (push) Has been cancelled
ci / 워크스페이스 빌드 검증 (push) Has been cancelled
ci / 모바일 린트·타입·Jest (push) Has been cancelled
ci / Supabase Edge Functions + Cloudflare Worker (push) Has been cancelled
ci / .NET API 서버 테스트 (push) Has been cancelled
Some checks failed
ci / 정본·보안·린트·타입·테스트 (push) Has been cancelled
deploy-site / deploy (push) Has been cancelled
ci / 워크스페이스 빌드 검증 (push) Has been cancelled
ci / 모바일 린트·타입·Jest (push) Has been cancelled
ci / Supabase Edge Functions + Cloudflare Worker (push) Has been cancelled
ci / .NET API 서버 테스트 (push) Has been cancelled
Typo auto-correct (INPUT-19) - TypoCorrectionService + core typo-correction: 2-set Korean layout mistypes both ways, always-wrong spellings, near-misses of the user's frequent words, optional model check re-validated in core; applied by backspace N + paste and cancelled on new keys or window change. Prediction quality (INPUT-20/21) - gemma models are sent raw with the user's unfinished sentence pre-filled into the model turn, so the model truly continues the text (mid-word joins and spacing exact). Other models keep the instruction prompt. - Context: text before the caret (opening lines and a fact list of names, dates, amounts outside the 400-char window), messages just sent in the same chat window (memory only, 30 min), personal-graph follow-ups and IDF-ranked related sentences with Korean stemming. - Guards: first sentence only, restated-prefix stripping (also fixes the instruction path), repeat drop, no invented dates/names/numbers (one retry), plain -다 register, no emoji unless the user uses them, search-box keywords. Fill loop mixes instruction prompts for variety. - Opt-in real-model probe: tests/integration/suggestion-quality.ollama.test.ts Suggestions now actually show up - Terminal (Claude Code): caret trust from the input line, not the whole screen (status line below the box blocked every keystroke); Korean composition counts as typing at the end; a grey placeholder filling the empty box at once is not user text. - Chrome: UIA focus flicker while typing no longer resets "edited". - KakaoTalk/RichEdit: trailing paragraph mark ignored for edit position and stripped so accepted text keeps its separating space. - While the overlay is visible the suggestion shortcuts are captured so Ctrl+Alt+Enter no longer also types a newline; released when hidden. - nut-js preloaded after boot (first accept waited 4.8 s).
This commit is contained in:
parent
5ca3709b32
commit
3cac14f668
56 changed files with 4700 additions and 258 deletions
|
|
@ -30,7 +30,7 @@ vi.mock('../../../src/main/services/LocalLLMService', () => ({
|
|||
getLocalLLMService: () => localLlm
|
||||
}))
|
||||
vi.mock('../../../src/main/services/InputTelemetryService', () => ({
|
||||
getInputTelemetryService: () => ({ listPhrases: vi.fn(() => []), recordExternalText: vi.fn() })
|
||||
getInputTelemetryService: () => ({ listPhrases: vi.fn(() => []), listRecentWrites: vi.fn(() => []), recordExternalText: vi.fn() })
|
||||
}))
|
||||
vi.mock('../../../src/main/services/PersonalGraphService', () => ({
|
||||
getPersonalGraphService: () => ({ retrieveContext: vi.fn(() => ({ continuations: [], related: [] })) })
|
||||
|
|
@ -115,7 +115,7 @@ afterEach(async () => {
|
|||
})
|
||||
|
||||
describe('SuggestionService warm-up', () => {
|
||||
it('동시 warm-up 호출을 하나의 1토큰 요청으로 합치고 10분간 유지한다', async () => {
|
||||
it('동시 warm-up 호출을 하나의 1토큰 요청으로 합치고 30분간 유지한다', async () => {
|
||||
localLlm.streamGenerate.mockImplementation(async function* () {
|
||||
yield 'ok'
|
||||
})
|
||||
|
|
@ -129,7 +129,7 @@ describe('SuggestionService warm-up', () => {
|
|||
expect(localLlm.streamGenerate).toHaveBeenCalledTimes(1)
|
||||
expect(localLlm.streamGenerate).toHaveBeenCalledWith(
|
||||
'hi',
|
||||
expect.objectContaining({ maxTokens: 1, keepAlive: '10m' })
|
||||
expect.objectContaining({ maxTokens: 1, keepAlive: '30m' })
|
||||
)
|
||||
expect(warmingStates).toEqual([true, false])
|
||||
})
|
||||
|
|
@ -156,6 +156,25 @@ describe('SuggestionService warm-up', () => {
|
|||
await internal._warmUpPromise
|
||||
})
|
||||
|
||||
it('타이핑 중이면(아직 멈추지 않았어도) 식은 모델을 "준비 중" 표시 없이 미리 올린다', async () => {
|
||||
localLlm.streamGenerate.mockImplementation(async function* () {
|
||||
yield 'ok'
|
||||
})
|
||||
const { getSuggestionService } = await import('../../../src/main/services/SuggestionService')
|
||||
const service = getSuggestionService()
|
||||
const internal = service as unknown as InternalSuggestionService & {
|
||||
_warmUpPromise: Promise<void> | null
|
||||
}
|
||||
|
||||
// 치는 중(유휴 100ms) — 정책상 아직 제안할 때가 아니다
|
||||
service.handleTypingContext({ ...context, idleMs: 100 })
|
||||
|
||||
expect(localLlm.streamGenerate).toHaveBeenCalledWith('hi', expect.objectContaining({ maxTokens: 1 }))
|
||||
expect(service.getState().warmingUp).toBe(false)
|
||||
expect(service.isPresentationActive).toBe(false)
|
||||
await internal._warmUpPromise
|
||||
})
|
||||
|
||||
it('dismiss(stale)는 진행 중인 워밍업을 취소하지 않는다', async () => {
|
||||
let resolveChunk: (() => void) | null = null
|
||||
localLlm.streamGenerate.mockImplementation((_text: string, options: { signal?: AbortSignal }) => {
|
||||
|
|
@ -413,7 +432,8 @@ describe('SuggestionService 세션 채우기 (최대 12개, 순차 · 페이지)
|
|||
it('첫 요청은 1개만 청하고, 성공하면 채우기 루프가 하나씩 최대 12개까지 채운다', async () => {
|
||||
// 접두/확장 중복 판정 때문에 숫자 접미사(1, 10, 11…)는 서로를 중복으로 오판한다
|
||||
// ("이어지는 문장 1" 이 "이어지는 문장 10" 의 접두이므로) — 서로소인 글자를 쓴다.
|
||||
const LETTERS = 'ABCDEFGHIJKL'
|
||||
// 영문 한 글자("A")는 원문에 없는 식별자로 보고 사실 검사가 버리므로 한글을 쓴다.
|
||||
const LETTERS = '가나다라마바사아자차카타'
|
||||
let call = 0
|
||||
localLlm.streamGenerate.mockImplementation(async function* () {
|
||||
const letter = LETTERS[call % LETTERS.length]
|
||||
|
|
@ -426,9 +446,10 @@ describe('SuggestionService 세션 채우기 (최대 12개, 순차 · 페이지)
|
|||
|
||||
await internal._generate(PREFIX, context, 3, 240)
|
||||
// 세션의 첫 요청은 정확히 1개만 청한다 (한꺼번에 여러 개를 청하면 느리다 — 사용자 요청).
|
||||
// gemma 는 원형 템플릿 prefill 이어 쓰기 — 모델 차례에 사용자 글을 넣어 한 문장만 잇게 한다.
|
||||
expect(localLlm.streamGenerate).toHaveBeenCalledWith(
|
||||
expect.stringContaining('1개'),
|
||||
expect.anything()
|
||||
expect.stringContaining('<|turn>model\n'),
|
||||
expect.objectContaining({ raw: true, stop: expect.arrayContaining(['<turn|>']) })
|
||||
)
|
||||
|
||||
await vi.waitFor(() => {
|
||||
|
|
@ -508,7 +529,7 @@ describe('SuggestionService 세션 채우기 (최대 12개, 순차 · 페이지)
|
|||
})
|
||||
|
||||
it('세션의 첫 요청만 분당/일일 예산을 쓴다 — 채우기 요청은 쓰지 않는다', async () => {
|
||||
const LETTERS = 'ABCDEFGHIJKL'
|
||||
const LETTERS = '가나다라마바사아자차카타'
|
||||
let call = 0
|
||||
localLlm.streamGenerate.mockImplementation(async function* () {
|
||||
const letter = LETTERS[call % LETTERS.length]
|
||||
|
|
@ -570,3 +591,57 @@ describe('SuggestionService 세션 채우기 (최대 12개, 순차 · 페이지)
|
|||
expect(cleared).not.toContain('stale')
|
||||
})
|
||||
})
|
||||
|
||||
describe('SuggestionService 터미널 문맥 (Claude Code 입력 상자)', () => {
|
||||
const screen = (input: string): string =>
|
||||
['● 이전 답변 출력', '╭──────────────╮', `│ > ${input}`, '╰──────────────╯', ' ⏵⏵ bypass permissions on · 1 shell'].join('\n')
|
||||
|
||||
it('입력 상자 아래 상태줄 때문에 텔레메트리가 caret 미상이라 해도, 입력 줄 끝에서 치는 중이면 커서를 믿는다', async () => {
|
||||
const { getSuggestionService } = await import('../../../src/main/services/SuggestionService')
|
||||
const internal = getSuggestionService() as unknown as {
|
||||
_terminalContext(input: typeof context & { caretReliable?: boolean }): typeof context & { caretReliable?: boolean }
|
||||
}
|
||||
const base = { ...context, appName: 'WindowsTerminal.exe', caretReliable: false }
|
||||
const first = internal._terminalContext({ ...base, fullText: screen('제안 창이 왜') })
|
||||
expect(first.prefix).toBe('제안 창이 왜')
|
||||
expect(first.caretReliable).toBe(true)
|
||||
// 끝에서 더 침 / 끝에서 지움 → 믿는다
|
||||
expect(internal._terminalContext({ ...base, fullText: screen('제안 창이 왜 잘') }).caretReliable).toBe(true)
|
||||
expect(internal._terminalContext({ ...base, fullText: screen('제안 창이 왜') }).caretReliable).toBe(true)
|
||||
// 중간을 고친 모양 → 막는다
|
||||
expect(internal._terminalContext({ ...base, fullText: screen('추천 창이 왜') }).caretReliable).toBe(false)
|
||||
// 입력 줄을 못 찾으면 제안하지 않는다
|
||||
expect(internal._terminalContext({ ...base, fullText: '빌드 출력만 있음' }).caretReliable).toBe(false)
|
||||
})
|
||||
|
||||
it('빈 입력칸에 한꺼번에 나타난 회색 추천 문구는 사용자 글로 보지 않는다 — 치기 시작하면 다시 믿는다', async () => {
|
||||
const { getSuggestionService } = await import('../../../src/main/services/SuggestionService')
|
||||
const internal = getSuggestionService() as unknown as {
|
||||
_terminalContext(input: typeof context & { caretReliable?: boolean }): typeof context & { caretReliable?: boolean }
|
||||
}
|
||||
const base = { ...context, appName: 'WindowsTerminal.exe', caretReliable: false }
|
||||
expect(internal._terminalContext({ ...base, fullText: screen('') }).caretReliable).toBe(true)
|
||||
// 빈 칸 → 29자 추천 문구가 한 번에 (그대로 머물러도 계속 믿지 않는다)
|
||||
expect(internal._terminalContext({ ...base, fullText: screen('run the full desktop test suite') }).caretReliable).toBe(false)
|
||||
expect(internal._terminalContext({ ...base, fullText: screen('run the full desktop test suite') }).caretReliable).toBe(false)
|
||||
// 사용자가 치기 시작하면 추천 문구가 사라지고 친 글만 남는다
|
||||
expect(internal._terminalContext({ ...base, fullText: screen('해') }).caretReliable).toBe(true)
|
||||
expect(internal._terminalContext({ ...base, fullText: screen('해봤어') }).caretReliable).toBe(true)
|
||||
})
|
||||
|
||||
it('한글 조합으로 마지막 글자가 바뀌어도(늘지 않아도) 끝에서 치는 중으로 보고, 멈춘 뒤에도 유지한다', async () => {
|
||||
const { getSuggestionService } = await import('../../../src/main/services/SuggestionService')
|
||||
const internal = getSuggestionService() as unknown as {
|
||||
_terminalContext(input: typeof context & { caretReliable?: boolean }): typeof context & { caretReliable?: boolean }
|
||||
}
|
||||
const base = { ...context, appName: 'WindowsTerminal.exe', caretReliable: false }
|
||||
internal._terminalContext({ ...base, fullText: screen('') })
|
||||
expect(internal._terminalContext({ ...base, fullText: screen('오늘 회의 자') }).caretReliable).toBe(true)
|
||||
expect(internal._terminalContext({ ...base, fullText: screen('오늘 회의 잘') }).caretReliable).toBe(true)
|
||||
expect(internal._terminalContext({ ...base, fullText: screen('오늘 회의 자료') }).caretReliable).toBe(true)
|
||||
// 멈춤 — 같은 입력 줄이 계속 와도 믿음을 유지한다
|
||||
expect(internal._terminalContext({ ...base, fullText: screen('오늘 회의 자료') }).caretReliable).toBe(true)
|
||||
// 긴 글 붙여넣기(빈 칸이 아닌 곳에서 끝에 덧붙임)도 끝에서 친 것이다
|
||||
expect(internal._terminalContext({ ...base, fullText: screen('오늘 회의 자료 정리해서 내일 오전까지 공유') }).caretReliable).toBe(true)
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue