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

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:
Yun Chan 2026-10-03 21:48:28 +09:00
parent 5ca3709b32
commit 3cac14f668
56 changed files with 4700 additions and 258 deletions

View file

@ -14,6 +14,10 @@ export interface KeyboardPort {
paste(): Promise<void>
/** 글자 단위 타이핑 (클립보드 비파괴) */
type(text: string): Promise<void>
/** 커서 앞 글자를 count 번 지운다 (오타 교정) */
backspace(count: number): Promise<void>
/** 네이티브 키 모듈을 미리 불러 둔다 — 첫 삽입이 로딩을 기다리지 않게 (선택) */
preload?(): Promise<void>
}
/**
@ -43,7 +47,7 @@ export interface NutKeyboardModule {
hasKeyboard(): boolean
getKeyboard(): NutNativeKeyboard
}
Key: Pick<typeof NutKey, 'LeftControl' | 'LeftSuper' | 'V'>
Key: Pick<typeof NutKey, 'LeftControl' | 'LeftSuper' | 'V' | 'Backspace'>
}
export type NutModuleLoader = () => Promise<NutKeyboardModule>
@ -94,6 +98,27 @@ export class NutKeyboardPort implements KeyboardPort {
await nut.native.type(text)
}
/** 백스페이스를 count 번 — 키마다 네이티브 keyTap 한 번이다. */
async backspace(count: number): Promise<void> {
if (count <= 0) return
const nut = await this._ensureNut()
for (let index = 0; index < count; index += 1) {
await nut.native.click(nut.Key.Backspace)
}
}
/**
* nut-js 를 미리 불러 둔다. 첫 로딩이 수 초 걸려(실측 2026-10-03: 재시작 뒤 첫 제안 수락이 4.9초,
* 그중 nut-js 로딩 4.8초) 사용자가 수락하고 한참 기다렸다. 실패는 여기서 삼키고 실제 삽입 때 다시 알린다.
*/
async preload(): Promise<void> {
try {
await this._ensureNut()
} catch {
// _ensureNut 이 이미 로그를 남겼다.
}
}
private async _ensureNut(): Promise<LoadedNut> {
if (this._nut) return this._nut