feat(desktop): propose typo fixes inside the suggestion popup and make suggestions snappier
While suggestions are on, typos are no longer replaced silently. The popup shows the fix next to the candidate and applies it only when the candidate is accepted. The per-minute request cap rises from 6 to 20 so suggestions keep appearing after accepting one and continuing to type.
This commit is contained in:
parent
d63854db67
commit
f5ae4c8c04
38 changed files with 1239 additions and 660 deletions
|
|
@ -185,7 +185,8 @@ end-to-end behaviour has **not been verified by typing in a real app** (`11` GAP
|
|||
| 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). |
|
||||
| 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, prefill only (the 2026-10-17 change removed the alternating instruction prompt — see INPUT-22). 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). |
|
||||
| INPUT-22 | Typo fixes proposed inside the suggestion popup + snappier suggestions | [~] | [-] | [-] | [-] | **2026-10-17.** While suggestions are on, typos are no longer replaced silently: `TypoCorrectionService.propose()` builds a plan without applying it and `SuggestionService` shows it in the popup as a `오타 고침` row (`del` struck-through original → `ins` fix) with the corrected tail prefixed to every candidate; the model continues from the corrected text. Accept = backspace the typo span + paste fix + candidate in one `replaceBeforeCaret` (if the caret char is still IME-composing, a real Space commits it first and is deleted too); if the text before the caret no longer ends with the typo span, only the candidate is inserted. Silent auto-correct (INPUT-19) still runs when suggestions are off. New core rule `detectJamoNoise`: a lone stray jamo inside/before Hangul syllables (`그ㅓ런`, `ㅇ다른`, `가쓴ㄷ거`) or a lone jamo word mid-sentence is removed; `ㅋㅋ`/`ㅠㅠ`/trailing `ㅎ`/first-word `ㅇ` are kept. Model typo check runs before the first candidate only when `hasSuspiciousTypo` (stray jamo, rare syllable); otherwise once in the background after the first candidate (`thorough`, ≥2 words) and the row is attached late. Proposals also work in learning-excluded apps (agent windows) but not terminals/excluded apps. Responsiveness: `minIntervalMs` 5000→1200, per-minute cap 6→20 (config migration rev 7, IPC clamp 30), composing idle ×1.5→×1.2, settle snapshot fires right after the required idle (≈780 ms instead of 1 s), accept relaxes the interval so the next pause after Space suggests again, visible TTL 20→45 s. Fill loop no longer mixes instruction prompts (instruction-path gemma *answered* the user: "설명해 주실 수 있을까요?"). **Round 2 (same day, live test: "panel should appear the moment I pause; it still closes mid-generation / flashes"):** 15 of 18 first requests returned an empty model output — a prefill ending mid-sentence with no trailing space (`…잠시 쉬면`) makes gemma close its turn at once; each empty result closed the panel and the next snapshot regenerated the same text ~1 s later (flash loop). Fixes: empty raw output → one retry with a trailing space appended to the prefill (`ModelRequest.spaced`, output re-parsed with a leading space so the joint is separate; probe: 4/4 sentences continue; fills reuse the spaced variant); a prefix whose first request failed is not regenerated until the text changes (`_failedPrefix`); a lone trailing jamo is removed with the *following* space so the text still ends "word + space"; snapshot debounce 700→380 ms and a "생성 중" placeholder (`presenceDelayMs` 350, self-clears after `presenceMaxMs` 3 s or when typing resumes, only when a request will follow — warm model, budget, not dismissed, not a failed prefix) shown before generation starts; it is not counted as "visible" by the policy. Tests: `suggestion-presence.test.ts` 5. Recent same-window writes are observed even while IME-composing (Korean chat boxes are almost always composing, so sent messages were never remembered). Diagnosis (installed v1.9.0 log + history DB, 1,122 suggestions / 11 accepted): v1.9.0 predates INPUT-19/21 and cleared a visible popup once `typedRecently` expired 8 s after the last key — ≈ the time the 12-candidate fill takes ("closes by itself when all candidates are done"). Evidence: real `gemma4:e4b` — `안ㄴ뇽하세여.?`→`안녕하세요.?` (1.1 s), `회으에서`→`회의에서`, `괜찬으세요`→`괜찮으세요`, `ㅇ다른`/`그ㅓ런` (0.8 s); desktop `suggestion-typo-correction.test.ts` 7, `TypoCorrectionService.test.ts` +4, core `typo-correction.test.ts` +4; desktop 2556 pass (2 known caption-env failures). Real-app check pending (GAP-INPUT-10). |
|
||||
|
||||
---
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue