refactor(desktop): structure suggestion pipeline and restore test gates

This commit is contained in:
Yun Chan 2026-10-31 23:14:11 +09:00
parent fe0989c456
commit 1d4f8d8401
17 changed files with 813 additions and 569 deletions

View file

@ -91,6 +91,8 @@ Singleton + `EventEmitter` pattern (`getXService()` accessors).
| `utils/win32-foreground.ts` | Foreground window title/pid/exe/bounds and active thread Korean IME state (`isForegroundKoreanIme` via `GetGUIThreadInfo` + `ImmGetDefaultIMEWnd` + `SendMessageTimeoutW(WM_IME_CONTROL)`) via `koffi` FFI into user32/kernel32/imm32 (chosen over `get-windows`, which needs an install script this repo does not run). |
| `sidecar/uia_bridge.py` | Windows UIA snapshot (`uiautomation` 2.0.29, comtypes) on a dedicated COM-initialised thread with a 1.5 s budget; never walks the UIA tree (Chrome/VS Code tree walks take 10-30 s). Uses `GetVisibleRanges()` / tail slicing `[-MAX_TEXT_CHARS:]` for large terminal scrollback buffers and `ExpandToEnclosingUnit(..., waitTime=0)` to avoid `uiautomation.py`'s default 500 ms sleep on Windows Terminal. Warm calls measure 0-15 ms. |
**2026-10-31 구조 경계:** `suggestion/SuggestionModelRequest.ts`가 prefill/지시형 모델 요청 구성, 후보 파싱, 지어낸 사실·문맥 복사 검증을 소유한다. `suggestion/FirstCandidateRunner.ts`는 첫 후보의 최대 2회 요청, 빈 prefill·사실 검증 재시도와 내용을 노출하지 않는 진단 로그를 담당한다. `_handleGenerationFailure`는 오류·시간 초과·빈 후보의 개인 후보 유지 → 로컬 기억 폭백 → 실패 종료 순서를 한 곳에서 보장한다. `_startGenerationSession`은 취소기·세대 토큰·타임아웃을 포함한 `GenerationSession`을 반환하고, `_prepareFirstCandidate`는 기억 수집·오타 교정·모델 요청과 첫 응답을 `FirstCandidatePreparation`으로 반환하며 실패 시에도 폭백용 기억 문맥을 보존한다. `_isGenerationResultCurrent`는 세대 불일치·문맥 경과·접두 변경을 순서대로 검사하고, `_publishFirstCandidate`는 개인 후보 병합·성공 기록·후속 채우기 시작을 담당하고, `_appendFilledCandidate`는 후속 후보의 추가·개인화 재정렬·표시·세션 행 후보 수 갱신을 한 곳에서 처리한다. `SuggestionService`는 입력 정책, 세대/취소, 표시, 수락만 조율한다. 모델 요청과 로컬 기억 게시는 각각 `SuggestionModelRequestInput`·`LocalMemoryPublication` 객체를 사용하며, 동작 변경 없는 순수 리팩토링이다.
The existing `input-telemetry-handlers` and `suggestion-handlers` IPC extensions expose the receipt and the flow/suggestion summaries. Receipt reads or deletes report an IPC error when storage access fails; they do not return invented counts or claim a purge succeeded. The receipt is local-only: `input_activity`, `typing_samples`, and `suggestions` retain 30 days; `personal_phrases` has no age-based automatic expiry and is removed by individual deletion, delete-all, or consent withdrawal. Smart Exclusion never records password evidence and recommends only the current app after at least four observations, zero readable results, and a problematic ratio of at least 75%; its one-click action adds an exclusion and never auto-excludes. Shortcut Safety Audit is core `auditKeyBindingMap` applied by the Settings UI; it surfaces invalid/conflict issues while preserving the existing hold/double-press exceptions.
### Account / infra / monetization