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
|
|
@ -4,7 +4,7 @@
|
|||
// 상세 통계(요약/키보드/마우스/앱/문구)는 지식 베이스 화면의 "입력 인사이트" 탭에 있다.
|
||||
// 이 패널은 "무엇을 수집하고, 언제 멈추고, 어떻게 지우는가" 만 다룬다.
|
||||
|
||||
import { useCallback, useEffect, useState } from 'react'
|
||||
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
|
|
@ -52,12 +52,54 @@ export function InputConsentPanel(): React.ReactElement {
|
|||
|
||||
// 설정 파일에 굳은 실제 값을 그대로 보여준다 (하드코딩 기본값을 표시하면
|
||||
// 사용자가 보는 값과 동작이 어긋난다 — 실측: 트리거가 3008ms 로 저장돼 있었다).
|
||||
// 제안 상태는 입력 스냅샷마다(초당 여러 번) 새로 온다 — 매번 칸을 덮어쓰면 사용자가 지우고 새로
|
||||
// 치는 도중에 값이 계속 되돌아갔다(실측: 600 이 다시 채워짐). 저장된 값이 실제로 바뀐 칸만 맞춘다.
|
||||
const syncedRef = useRef<{ triggerDelayMs?: number; minPrefixChars?: number; requestTimeoutMs?: number }>({})
|
||||
const triggerDelaySaved = suggestion?.triggerDelayMs
|
||||
const minPrefixSaved = suggestion?.minPrefixChars
|
||||
const requestTimeoutSaved = suggestion?.requestTimeoutMs
|
||||
useEffect(() => {
|
||||
if (!suggestion) return
|
||||
setTriggerDelayMs(String(suggestion.triggerDelayMs))
|
||||
setMinPrefixChars(String(suggestion.minPrefixChars))
|
||||
setRequestTimeoutMs(String(suggestion.requestTimeoutMs))
|
||||
}, [suggestion])
|
||||
const synced = syncedRef.current
|
||||
if (triggerDelaySaved !== undefined && synced.triggerDelayMs !== triggerDelaySaved) {
|
||||
synced.triggerDelayMs = triggerDelaySaved
|
||||
setTriggerDelayMs(String(triggerDelaySaved))
|
||||
}
|
||||
if (minPrefixSaved !== undefined && synced.minPrefixChars !== minPrefixSaved) {
|
||||
synced.minPrefixChars = minPrefixSaved
|
||||
setMinPrefixChars(String(minPrefixSaved))
|
||||
}
|
||||
if (requestTimeoutSaved !== undefined && synced.requestTimeoutMs !== requestTimeoutSaved) {
|
||||
synced.requestTimeoutMs = requestTimeoutSaved
|
||||
setRequestTimeoutMs(String(requestTimeoutSaved))
|
||||
}
|
||||
}, [triggerDelaySaved, minPrefixSaved, requestTimeoutSaved])
|
||||
|
||||
/**
|
||||
* 숫자 칸 저장 — 비었거나 숫자가 아니면 저장하지 않고 저장된 값으로 되돌린다. 서버가 범위를 맞춰
|
||||
* 다른 값을 저장했으면(예: 최소 500ms) 칸도 그 값으로 맞춘다.
|
||||
*/
|
||||
const commitNumber = useCallback(
|
||||
async (
|
||||
raw: string,
|
||||
key: 'triggerDelayMs' | 'minPrefixChars' | 'requestTimeoutMs',
|
||||
reset: (value: string) => void
|
||||
): Promise<void> => {
|
||||
const value = Number(raw)
|
||||
const saved = syncedRef.current[key]
|
||||
if (raw.trim() === '' || !Number.isFinite(value)) {
|
||||
if (saved !== undefined) reset(String(saved))
|
||||
return
|
||||
}
|
||||
const result = await window.electronAPI.suggestion.setConfig({ [key]: Math.round(value) })
|
||||
if (result.success) {
|
||||
const stored = result.data[key]
|
||||
syncedRef.current[key] = stored
|
||||
reset(String(stored))
|
||||
}
|
||||
await refresh()
|
||||
},
|
||||
[refresh]
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
let cancelled = false
|
||||
|
|
@ -114,6 +156,14 @@ export function InputConsentPanel(): React.ReactElement {
|
|||
[refresh]
|
||||
)
|
||||
|
||||
const handleTypoAutoCorrect = useCallback(
|
||||
async (next: boolean): Promise<void> => {
|
||||
await window.electronAPI.suggestion.setConfig({ typoAutoCorrect: next })
|
||||
await refresh()
|
||||
},
|
||||
[refresh]
|
||||
)
|
||||
|
||||
const handleModel = useCallback(
|
||||
async (modelId: string): Promise<void> => {
|
||||
await window.electronAPI.suggestion.setConfig({ modelId: modelId || null })
|
||||
|
|
@ -423,11 +473,7 @@ export function InputConsentPanel(): React.ReactElement {
|
|||
label={t('input.suggestion.delay')}
|
||||
value={triggerDelayMs}
|
||||
onChange={(e) => setTriggerDelayMs(e.target.value)}
|
||||
onBlur={() =>
|
||||
void window.electronAPI.suggestion
|
||||
.setConfig({ triggerDelayMs: Number(triggerDelayMs) })
|
||||
.then(() => refresh())
|
||||
}
|
||||
onBlur={() => void commitNumber(triggerDelayMs, 'triggerDelayMs', setTriggerDelayMs)}
|
||||
sx={{ width: 150 }}
|
||||
/>
|
||||
<TextField
|
||||
|
|
@ -437,11 +483,7 @@ export function InputConsentPanel(): React.ReactElement {
|
|||
label={t('input.suggestion.minPrefix')}
|
||||
value={minPrefixChars}
|
||||
onChange={(e) => setMinPrefixChars(e.target.value)}
|
||||
onBlur={() =>
|
||||
void window.electronAPI.suggestion
|
||||
.setConfig({ minPrefixChars: Number(minPrefixChars) })
|
||||
.then(() => refresh())
|
||||
}
|
||||
onBlur={() => void commitNumber(minPrefixChars, 'minPrefixChars', setMinPrefixChars)}
|
||||
sx={{ width: 150 }}
|
||||
/>
|
||||
<TextField
|
||||
|
|
@ -451,11 +493,7 @@ export function InputConsentPanel(): React.ReactElement {
|
|||
label={t('input.suggestion.timeout')}
|
||||
value={requestTimeoutMs}
|
||||
onChange={(e) => setRequestTimeoutMs(e.target.value)}
|
||||
onBlur={() =>
|
||||
void window.electronAPI.suggestion
|
||||
.setConfig({ requestTimeoutMs: Number(requestTimeoutMs) })
|
||||
.then(() => refresh())
|
||||
}
|
||||
onBlur={() => void commitNumber(requestTimeoutMs, 'requestTimeoutMs', setRequestTimeoutMs)}
|
||||
sx={{ width: 150 }}
|
||||
/>
|
||||
<Select
|
||||
|
|
@ -491,6 +529,24 @@ export function InputConsentPanel(): React.ReactElement {
|
|||
}
|
||||
/>
|
||||
|
||||
{/* 오타 교정은 입력 맥락(수집 동의)만 있으면 제안과 따로 동작한다. */}
|
||||
<FormControlLabel
|
||||
disabled={!enabled}
|
||||
control={
|
||||
<Switch
|
||||
size="small"
|
||||
checked={suggestion?.typoAutoCorrect ?? true}
|
||||
onChange={(e) => void handleTypoAutoCorrect(e.target.checked)}
|
||||
/>
|
||||
}
|
||||
label={
|
||||
<Typography sx={{ ...typoSx('label'), color: d3roPalette.text.secondary }}>
|
||||
{t('input.suggestion.typoAutoCorrect')}
|
||||
</Typography>
|
||||
}
|
||||
/>
|
||||
<Typography sx={{ ...HINT_SX, pl: 6 }}>{t('input.suggestion.typoAutoCorrectHint')}</Typography>
|
||||
|
||||
{/* 상태 표시 — 스위치로 두면 설정처럼 보여서 "왜 못 켜지?" 가 된다. */}
|
||||
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
|
||||
<Typography sx={{ ...typoSx('label'), color: d3roPalette.text.tertiary }}>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue