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
|
|
@ -22,6 +22,9 @@ import { getCustomInstructionService } from './services/CustomInstructionService
|
|||
import { getVoiceCommandService } from './services/VoiceCommandService'
|
||||
import { getInputTelemetryService } from './services/InputTelemetryService'
|
||||
import { getSuggestionService, hasInputContextConsent } from './services/SuggestionService'
|
||||
import { initTypoCorrectionService } from './services/TypoCorrectionService'
|
||||
import { getPersonalGraphService } from './services/PersonalGraphService'
|
||||
import { getForegroundWindowInfo } from './utils/win32-foreground'
|
||||
import { getSoundEffectService } from './services/SoundEffectService'
|
||||
import { getAutoLaunchService } from './services/AutoLaunchService'
|
||||
import { getAudioCaptureService } from './services/AudioCaptureService'
|
||||
|
|
@ -199,7 +202,44 @@ async function initInputIntelligence(): Promise<void> {
|
|||
const telemetry = getInputTelemetryService()
|
||||
const suggestion = getSuggestionService()
|
||||
|
||||
telemetry.on('typed-context', (context) => suggestion.handleTypingContext(context))
|
||||
// 첫 제안 수락·받아쓰기 삽입이 키 입력 모듈 로딩(수 초)을 기다리지 않게, 부팅이 끝난 뒤 미리 불러 둔다.
|
||||
setTimeout(() => {
|
||||
void getTextInsertService().preload()
|
||||
}, 5_000).unref?.()
|
||||
|
||||
// 오타 교정이 먼저 본다 — 고치는 중이면 텍스트가 곧 바뀌니 제안으로 넘기지 않고(교정 뒤 새
|
||||
// 스냅샷이 온다), 모델로 검사 중이면 끝날 때('settled') 넘긴다. 제안이 고친 문장을 기준으로
|
||||
// 만들어지고, 두 요청이 같은 모델을 두고 경쟁하지 않는다.
|
||||
const typo = initTypoCorrectionService({
|
||||
replaceBeforeCaret: async (deleteCount, text) => {
|
||||
const method = configGet('insertMethod') === 'keyboard' ? 'keyboard' : 'clipboard'
|
||||
const result = await getTextInsertService().replaceBeforeCaret(deleteCount, text, method)
|
||||
return result.success
|
||||
},
|
||||
lastKeyAt: () => telemetry.lastKeyAt,
|
||||
expectProgrammaticKeys: (count) => telemetry.expectProgrammaticKeys(count),
|
||||
expectProgrammaticInsert: (text) => telemetry.expectProgrammaticInsert(text),
|
||||
foregroundHandle: () => getForegroundWindowInfo()?.hwnd ?? null,
|
||||
recentTexts: () => getPersonalGraphService().listRecentTexts(),
|
||||
warmModel: () => suggestion.warmModel(),
|
||||
generate: (prompt, options) =>
|
||||
getLocalLLMService().streamGenerate(prompt, {
|
||||
model: options.model,
|
||||
systemPrompt: options.systemPrompt,
|
||||
temperature: 0,
|
||||
maxTokens: options.maxTokens,
|
||||
signal: options.signal,
|
||||
keepAlive: '10m'
|
||||
})
|
||||
})
|
||||
typo.on('settled', ({ context }) => suggestion.handleTypingContext(context))
|
||||
typo.on('corrected', () => {
|
||||
if (suggestion.isPresentationActive) suggestion.dismiss('stale')
|
||||
})
|
||||
telemetry.on('typed-context', (context) => {
|
||||
const verdict = typo.handleTypingContext(context)
|
||||
if (verdict === 'pass') suggestion.handleTypingContext(context)
|
||||
})
|
||||
telemetry.on('state-changed', (state) =>
|
||||
sendToMainWindow(IPC_CHANNELS.INPUT_TELEMETRY.STATE_CHANGED, state)
|
||||
)
|
||||
|
|
@ -214,17 +254,24 @@ async function initInputIntelligence(): Promise<void> {
|
|||
setPresentationActive: (active) => telemetry.setSuggestionPresentationActive(active),
|
||||
warn: (message) => logger.warn(message),
|
||||
})
|
||||
// 제안 창이 떠 있는 동안만 제안 단축키를 OS 에서 잡는다 — Ctrl+Alt+Enter 가 앱에도 전달돼
|
||||
// 개행이 들어가던 문제(2026-10-03). 창이 사라지면 바로 푼다.
|
||||
const syncSuggestionKeyCapture = (): void =>
|
||||
getKeyBindingService().setSuggestionCaptureActive(suggestion.isPresentationActive)
|
||||
suggestion.on('updated', (state) => {
|
||||
overlay.onUpdated(state)
|
||||
syncSuggestionKeyCapture()
|
||||
sendToMainWindow(IPC_CHANNELS.SUGGESTION.UPDATED, state)
|
||||
})
|
||||
suggestion.on('cleared', (payload) => {
|
||||
overlay.onCleared()
|
||||
syncSuggestionKeyCapture()
|
||||
sendToMainWindow(IPC_CHANNELS.SUGGESTION.CLEARED, payload)
|
||||
})
|
||||
suggestion.on('state-changed', (state) =>
|
||||
suggestion.on('state-changed', (state) => {
|
||||
syncSuggestionKeyCapture()
|
||||
sendToMainWindow(IPC_CHANNELS.SUGGESTION.STATE_CHANGED, state)
|
||||
)
|
||||
})
|
||||
|
||||
// 제안 수락/순환/닫기는 전역 키바인딩으로만 들어온다 — 오버레이는 포커스를 갖지 않는다.
|
||||
getKeyBindingService().on('triggered', (payload) => {
|
||||
|
|
@ -274,6 +321,7 @@ async function initInputIntelligence(): Promise<void> {
|
|||
|
||||
// 전역 입력 훅·제안 타이머는 종료 시 풀어야 한다
|
||||
const registry = getShutdownRegistry()
|
||||
registry.register({ name: 'typo-correction', dispose: () => typo.dispose() })
|
||||
registry.register({ name: 'suggestion', dispose: () => suggestion.dispose() })
|
||||
registry.register({ name: 'input-telemetry', dispose: () => telemetry.dispose() })
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue