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
|
|
@ -183,6 +183,9 @@ end-to-end behaviour has **not been verified by typing in a real app** (`11` GAP
|
|||
| INPUT-16 | Memory Decay | [~] | [-] | [-] | [-] | Phrase ranking combines a 30-day half-life, frequency and the App DNA 1.75× same-app bonus. |
|
||||
| INPUT-17 | Instant Recall | [~] | [-] | [-] | [-] | Local-memory fallback (`provenance=local-memory`) occurs only for unavailable model, non-cancellation error, actual timeout or empty model result; it spends no additional model budget and is blocked on dismiss, new typing, token/context mismatch or staleness. |
|
||||
| INPUT-18 | Shortcut Safety Audit | [~] | [-] | [-] | [-] | Settings UI applies core `auditKeyBindingMap` to surface invalid/conflict issues while hold/double-press exceptions remain unchanged. |
|
||||
| INPUT-19 | Typo auto-correct while typing | [~] | [-] | [-] | [-] | **2026-10-03.** `TypoCorrectionService` (main, singleton + EventEmitter) runs on each `typed-context` before `SuggestionService`. Only after a pause (`TYPO_MIN_IDLE_MS` 600 ms), only in the 120-char/last-line region before the caret, only in fields the user just edited (`editedSinceFocus` + `typedRecently`); never in password/selection/IME-composing/caret-unknown fields, terminals, code editors (`shouldLearnFromApp`) or user-excluded apps. Layer 1 (core `typo-correction.ts`, pure): 2-set Korean layout mistypes both ways (`dkssudgktpdy`→`안녕하세요`, `솓`→`the`; conversion must compose fully into KS X 1001 common syllables — `hangul-common-syllables.ts`), always-wrong spellings (됬→됐, ㄹ께→ㄹ게, 몇일→며칠, teh→the, dont→don't …), and 1-edit near-misses of the user's frequent English words. Layer 2: if the suggestion model is already warm, a 2.5 s / 48-token sentence check (`buildTypoCheckPrompt`, `틀린말 => 고친말`) whose output is re-validated by `validateModelCorrections` (whole-eojeol or stem match, jamo-level edit distance, no spacing/case/word swaps, no abbreviation expansion like 넘→너무, user's repeated words exempt). Apply = backspace N + paste the corrected span (`TextInsertService.replaceBeforeCaret`, serialized with other inserts); cancelled if any key arrived after the decision or the foreground window changed. Programmatic keys are excluded from input stats. Reverting a fix within 30 s puts the word in `typoIgnoredWords`. While the model check runs the suggestion is deferred (`settled`) so it is generated from the corrected text and the two requests never race on the same model. Toggle: Settings → Input (`typoAutoCorrectEnabled`, default on; `typoAutoCorrectUseModel`). Logs record counts/sources only, never the words. Evidence: core 478 tests, desktop `TypoCorrectionService.test.ts` 14; real `gemma4:e4b` probe ≈0.5–0.8 s per check, 0 false fixes on slang/proper-noun samples. Not yet verified by typing in a real external app (GAP-INPUT-08). |
|
||||
| INPUT-20 | Context-aware suggestion prompt & graph retrieval | [~] | [-] | [-] | [-] | **2026-10-03.** Prompt (`buildSuggestionPrompt`) now splits the prefix with core `writing-context.ts` into earlier text / last sentence / unfinished current sentence and states the mode (finish this sentence vs. write the next one), language and Korean register (formal/polite/casual); adds the text after the caret (no overlap) and fixes dropped characters that had leaked into the old prompt ("[지금까지 텍스트]", "사용자가 언어"). Graph (`PersonalGraphService.retrieveContext`): `followUps` = what the user actually wrote after the same (or near-identical) last sentence via `follows` edges; continuations fall back from 14- to 10- to 7-char word-boundary tails; related sentences ranked by IDF-weighted term overlap (`scoreRelatedNodes`) with same-app/recency boosts plus a one-hop `follows` expansion. Korean terms are stemmed (`stemTerm`: particles and common 하다 endings) so "회의에서"/"회의는" match; stored old terms are re-stemmed at query time. Phrase hints for the prompt keep only phrases sharing terms with the current text (or same app); unfiltered phrases remain for the no-model local-memory fallback. Evidence: `personal-graph-context.test.ts` (real SQLite) 5, `llm-prompts.test.ts` +5, core `writing-context.test.ts` 8; real `gemma4:e4b` probe keeps register and follows graph hints (~0.55 s). |
|
||||
| INPUT-21 | Prefill continuation + document/conversation context for suggestions | [~] | [-] | [-] | [-] | **2026-10-03.** For models whose chat template we know (gemma 4 `<\|turn>`, gemma 2/3 `<start_of_turn>`; core `chat-template.ts`), the suggestion request is sent `raw` with the user's own unfinished sentence (or last sentence) pre-filled into the model turn, so the model literally continues the text: mid-word joins (`회의실`+`에서`) and spacing come out exact (`extractContinuation` keeps joint `attach`/`separate`; trailing space is not pre-filled — it destabilised output — and an attach after a finished word is rejected). Ollama's chat-API prefill was measured and rejected (drops the leading space, closes the turn: `검토해 보시`→`부탁드립니다.`). Other models keep the instruction prompt. Context added to both paths: whole text before the caret (`TypingContext.documentBefore`, ≤6000 chars; null for document-like/terminal/password) → opening lines outside the 1,200-char window and a fact list (names+titles, attendee lines, dates, times, amounts, versions, acronyms, quoted terms — `analyzeDocumentContext`); **same-window messages the user just sent** (chat boxes empty on send — `RecentWritesBuffer`, memory only, 30 min, cleared when input observation stops, terminals excluded); search-box detection (keywords, not sentences); plain `-다` register split from casual `-어`; no emoji unless the user uses them. Output guards: first sentence/line only, stream cut as soon as it ends, restated-prefix stripping (also fixes the instruction path, where `CI는 통과했고…` was inserted after `CI는`), repeat-of-written-sentence drop, and **unsupported-fact rejection** (`findUnsupportedFacts`: dates/numbers/names+titles/lone Latin identifiers absent from document, window title, recent messages and personal hints) with one retry for the first candidate. Fill loop: temperature 1.0; in next-sentence mode every other fill uses the instruction prompt (prefill alone repeated the first candidate). Evidence: real `gemma4:e4b` probe `tests/integration/suggestion-quality.ollama.test.ts` (15 scenarios, opt-in `D3RO_SUGGESTION_PROBE=1`) — first-candidate warnings 0/15 vs 1/15 for the old path (old path invented a launch date instead of the 11월 15일 stated 1,200 chars earlier), mean ≈0.68 s both; core `suggestion-continuation.test.ts` 25, `llm-prompts.test.ts` +7. Not yet verified by typing in a real app (GAP-INPUT-09). |
|
||||
|
||||
---
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue