From 61123b5ad83c665d6438835a383634dfc8f043b9 Mon Sep 17 00:00:00 2001 From: Yun Chan Date: Sat, 31 Oct 2026 03:38:56 +0900 Subject: [PATCH] fix(desktop): prevent Korean character swallowing in terminal and xterm.js surfaces (INPUT-04, INPUT-19) --- CHANGELOG.md | 12 +++ apps/desktop/sidecar/uia_bridge.py | 79 +++++++++++++++++-- .../main/services/InputTelemetryService.ts | 78 ++++++++++++------ .../src/main/services/SuggestionService.ts | 2 +- .../main/services/TypoCorrectionService.ts | 6 ++ .../services/TypoCorrectionService.test.ts | 34 ++++++++ docs/map/00-index.md | 2 +- docs/map/10-feature-catalog.md | 2 +- docs/map/11-gap-backlog.md | 2 +- .../core/__tests__/terminal-prompt.test.ts | 25 ++++++ packages/core/src/terminal-prompt.ts | 72 +++++++++++++---- 11 files changed, 264 insertions(+), 50 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 134d220..865f98b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Additional Whisper model management UI - Plugin system for custom pipelines +## [1.15.1] - 2026-10-31 + +> Published from an annotated tag. Installer and update metadata are served by the +> canonical Forgejo feed; no binaries are committed to this repository. + +### Fixed +- **Terminal & `xterm.js` Korean IME character-swallowing fix (터미널·에이전트 창 한글 타이핑 시 1글자씩 씹히는 현상 근본 해결).** + - Removes synchronous cross-process `isForegroundKoreanIme` (`SendMessageTimeoutW(WM_IME_CONTROL)`) calls from the low-level keydown hook (`InputTelemetryService._handleKeyDown`) that were disrupting Windows TSF/DefIME composition state on every keystroke in terminal windows, replacing them with a one-time idle-snapshot IME sync (`TerminalKeystrokeTracker.syncKoreanIme`). + - Adds a dedicated `xterm-helper-textarea` fast path in `sidecar/uia_bridge.py` that skips `GetTopLevelControl()` DOM tree walks and `TextPattern.GetSelection()` / `ExpandToEnclosingUnit(Character)` / `TextEditPattern.GetActiveComposition()` COM calls (which stalled Chromium's renderer thread up to 1,500 ms during Korean IME composition and left `isComposing` stuck `true`), and extends `_WAKE_TTL_SECONDS` from 60 s to 86,400 s per HWND. + - Suppresses 40 ms word-boundary UIA snapshots on normal Korean words (`_shouldRunFastTerminalBoundarySnapshot`), removes the duplicate 680 ms `_typoTimer`, and stops 800 ms `_sampleWhileTyping` polling on terminal surfaces so UIA never queries `xterm-helper-textarea` while you press the first consonant of the next word. + - Prevents `TypoCorrectionService` from injecting `commitComposition` (`VK_SPACE` + `VK_BACK`) on trailing composed Hangul syllables (`/[가-힣]$/u`) in terminals before `Space` is pressed. + ## [1.15.0] - 2026-10-31 > Published from an annotated tag. Installer and update metadata are served by the diff --git a/apps/desktop/sidecar/uia_bridge.py b/apps/desktop/sidecar/uia_bridge.py index 4a1f496..40fab41 100644 --- a/apps/desktop/sidecar/uia_bridge.py +++ b/apps/desktop/sidecar/uia_bridge.py @@ -251,7 +251,41 @@ def _caret_rect_and_offset(auto: Any, control: Any) -> tuple[Optional[dict], Opt _woken_hwnds: dict[int, float] = {} -_WAKE_TTL_SECONDS = 60.0 +_WAKE_TTL_SECONDS = 86400.0 + + +def _foreground_window_meta() -> tuple[Optional[str], Optional[dict]]: + """Win32 API 로 포그라운드 창 제목과 사각형을 즉시 읽는다 (UIA 부모 트리 순회 COM 호출 제거).""" + try: + import ctypes # noqa: PLC0415 + from ctypes import wintypes # noqa: PLC0415 + + user32 = ctypes.windll.user32 + hwnd = int(user32.GetForegroundWindow() or 0) + if not hwnd: + return (None, None) + + title: Optional[str] = None + buf = ctypes.create_unicode_buffer(302) + length = int(user32.GetWindowTextW(wintypes.HWND(hwnd), buf, 300) or 0) + if length > 0: + title = buf.value[:300] + + rect = wintypes.RECT() + rect_dict: Optional[dict] = None + if user32.GetWindowRect(wintypes.HWND(hwnd), ctypes.byref(rect)): + width = int(rect.right) - int(rect.left) + height = int(rect.bottom) - int(rect.top) + if width >= 0 and height >= 0: + rect_dict = { + "x": int(rect.left), + "y": int(rect.top), + "width": width, + "height": height, + } + return (title, rect_dict) + except Exception: + return (None, None) def _wake_chromium_accessibility(force: bool = False) -> bool: @@ -366,13 +400,29 @@ def _snapshot() -> dict: except Exception: result["processId"] = None - try: - top = control.GetTopLevelControl() - if top is not None: - result["windowTitle"] = str(top.Name or "")[:300] - result["elementRect"] = _rect_to_dict(top.BoundingRectangle) or result["elementRect"] - except Exception: - pass + fg_title, fg_rect = _foreground_window_meta() + if fg_title: + result["windowTitle"] = fg_title + if fg_rect is not None: + result["elementRect"] = fg_rect + + class_name_lower = str(result["className"] or "").lower() + control_name_lower = str(result["controlName"] or "").strip().lower() + is_xterm_helper = ( + "xterm-helper-textarea" in class_name_lower + or control_name_lower in ("terminal input", "터미널 입력") + ) + + if not is_xterm_helper and (result["windowTitle"] is None or result["elementRect"] is None): + try: + top = control.GetTopLevelControl() + if top is not None: + if result["windowTitle"] is None: + result["windowTitle"] = str(top.Name or "")[:300] + if result["elementRect"] is None: + result["elementRect"] = _rect_to_dict(top.BoundingRectangle) or result["elementRect"] + except Exception: + pass try: result["elementRect"] = _rect_to_dict(control.BoundingRectangle) or result["elementRect"] @@ -383,6 +433,19 @@ def _snapshot() -> dict: result["textSource"] = source result["text"] = text + if is_xterm_helper: + # xterm.js 의 숨김 IME 입력창(xterm-helper-textarea)에서 TextPattern 선택·문자 확장·TextEditPattern + # 조합 조회를 호출하면 Chromium 렌더러 스레드가 블로킹(최대 1500ms 타임아웃)되고 한글 조합 중인 + # 글자가 삼켜진다. ValuePattern 값과 편집 가능 여부만 즉시 반환한다. + result["isEditable"] = True + result["caretRect"] = None + result["caretOffset"] = None + result["isComposing"] = False + result["hasSelection"] = False + result["capturedAt"] = int(time.time() * 1000) + result["elapsedMs"] = int((time.monotonic() - started) * 1000) + return result + is_readonly = False try: if value_pattern is not None: diff --git a/apps/desktop/src/main/services/InputTelemetryService.ts b/apps/desktop/src/main/services/InputTelemetryService.ts index 42a6d42..4448d7a 100644 --- a/apps/desktop/src/main/services/InputTelemetryService.ts +++ b/apps/desktop/src/main/services/InputTelemetryService.ts @@ -64,6 +64,7 @@ import { type TerminalVimMode } from '@d3ro/core/input-intelligence' import { RecentWritesBuffer, type RecentWrite, type RecentWriteMeta } from '@d3ro/core/recent-writes' +import { detectTypos } from '@d3ro/core/typo-correction' import { getDatabase } from '../db' import { inputActivity, personalPhrases, suggestions as suggestionsTable, typingSamples } from '../db/schema' import { configGet, configSet } from './ConfigService' @@ -595,13 +596,10 @@ class InputTelemetryService extends EventEmitter { // 진단: 키 값이 아니라 종류·수정자만 남긴다 (typed 판정이 왜 틀리는지 로그로 보이게) this._lastKeyDiag = `${keyClass}${vk === null ? `?${event.keycode}` : ''}${this._modifiers.ctrl ? '+C' : ''}${this._modifiers.alt ? '+A' : ''}${this._modifiers.meta ? '+M' : ''}` - // 터미널·Vim·개발 표면에서는 키스트로크 버퍼와 IME 상태를 함께 추적해 - // 줄 끝 공백 손실(Windows Terminal)이나 캔버스 터미널(len=0)에서도 한영 자동 전환과 Vim 모드가 동작하게 한다. - const onTerminalSurface = isTerminalOrDeveloperSurface(this._foreground.appName) - const koreanIme = - onTerminalSurface && vk !== null && vk >= 0x41 && vk <= 0x5a - ? isForegroundKoreanIme(this._foreground.hwnd) - : undefined + // 터미널·Vim·개발 표면에서는 키스트로크 버퍼를 추적해 줄 끝 공백 손실(Windows Terminal)이나 + // 캔버스 터미널(len=0)에서도 한영 자동 전환과 Vim 모드가 동작하게 한다. + // 주의: 키다운 훅 안에서 대상 창 IME 에 동기 WM_IME_CONTROL(isForegroundKoreanIme)을 보내면 + // TSF/Cicero 조합 상태가 깨져 한글이 한 글자씩 씹히므로 훅 안에서는 절대 호출하지 않는다. this._terminalTracker.onKeyDown({ hwnd: this._foreground.hwnd, windowTitle: this._foreground.windowTitle, @@ -611,7 +609,6 @@ class InputTelemetryService extends EventEmitter { ctrl: this._modifiers.ctrl, alt: this._modifiers.alt, meta: this._modifiers.meta, - koreanIme, now: this._lastKeyAt }) @@ -769,13 +766,19 @@ class InputTelemetryService extends EventEmitter { private async _sampleWhileTyping(): Promise { if (!this._running || this._sampling) return const now = Date.now() - if (!this._suggestionPresentationActive && this._lastKeyAt > 0 && now - this._lastKeyAt < 350) { + if (this._lastKeyAt > 0 && now - this._lastKeyAt < 1000) { + return + } + if ( + !this._suggestionPresentationActive && + (isTerminalOrDeveloperSurface(this._foreground.appName) || + this._lastContext?.terminalMode === true || + this._lastKeyAt === 0 || + now - this._lastKeyAt > INPUT_TELEMETRY_DEFAULTS.sampleActiveWindowMs || + (this._lastContext !== null && this._lastContext.capturedAt >= this._lastKeyAt)) + ) { return } - const hasRecentKeyboardInput = - this._lastKeyAt > 0 && - now - this._lastKeyAt <= INPUT_TELEMETRY_DEFAULTS.sampleActiveWindowMs - if (!hasRecentKeyboardInput && !this._suggestionPresentationActive) return this._sampling = true try { @@ -785,26 +788,45 @@ class InputTelemetryService extends EventEmitter { } } + private _shouldRunFastTerminalBoundarySnapshot(): boolean { + if (!isTerminalOrDeveloperSurface(this._foreground.appName)) return true + const tracked = this._terminalTracker.currentPrefix() + if (tracked.trim().length === 0) return true + if (/[ㄱ-ㅎㅏ-ㅣA-Za-z]/u.test(tracked) || tracked.trimStart().startsWith(':')) { + return true + } + return ( + detectTypos(tracked, { + includeTrailingToken: true, + layoutOnly: true, + terminalMode: true + }).length > 0 + ) + } + private _scheduleTextSnapshot(keyClass?: KeyStrokeClass): void { // Araso 급 빠른 한영 전환: 공백·문장부호 직후에는 40ms 뒤에 즉시 스냅샷을 찍고, // 일반 글자 입력 중에는 단어를 치는 도중(예: sometime 의 some 시점) 끼어들어 글자를 삼키지 않도록 - // 680ms 유휴 뒤에 스냅샷을 찍는다(Vim 명령줄 :wq 등은 160ms). + // 700ms 디바운스 타이머(_textTimer)에 맡긴다(Vim 명령줄 :wq 등은 160ms). if (this._typoTimer) clearTimeout(this._typoTimer) if (keyClass && TYPING_KEY_CLASSES.has(keyClass) && configGet('typoAutoCorrectEnabled') !== false) { const isBoundaryKey = keyClass === 'space' || keyClass === 'symbol' || (keyClass === 'digit' && this._modifiers.shift) - const quickDelay = isBoundaryKey - ? 40 - : this._terminalTracker.vimMode === 'command' - ? 160 - : 680 - this._typoTimer = setTimeout(() => { - this._typoTimer = null - void this._captureTextSnapshot() - }, quickDelay) - this._typoTimer.unref?.() + const quickDelay = + isBoundaryKey && this._shouldRunFastTerminalBoundarySnapshot() + ? 40 + : !isBoundaryKey && this._terminalTracker.vimMode === 'command' + ? 160 + : null + if (quickDelay !== null) { + this._typoTimer = setTimeout(() => { + this._typoTimer = null + void this._captureTextSnapshot() + }, quickDelay) + this._typoTimer.unref?.() + } } if (this._textTimer) clearTimeout(this._textTimer) @@ -898,6 +920,14 @@ class InputTelemetryService extends EventEmitter { typedRecently } + if ( + !snapshot.isPassword && + isTerminalOrDeveloperSurface(this._foreground.appName) && + !this._terminalTracker.hasObservedImeForHwnd(this._foreground.hwnd) + ) { + this._terminalTracker.syncKoreanIme(isForegroundKoreanIme(this._foreground.hwnd)) + } + if (snapshot.available && isXtermHelperControl(snapshot) && !snapshot.isPassword) { const usesCaretRect = snapshot.caretRect !== null context.anchor = snapshot.caretRect ?? snapshot.elementRect diff --git a/apps/desktop/src/main/services/SuggestionService.ts b/apps/desktop/src/main/services/SuggestionService.ts index 86cb0de..c5bdf09 100644 --- a/apps/desktop/src/main/services/SuggestionService.ts +++ b/apps/desktop/src/main/services/SuggestionService.ts @@ -2145,7 +2145,7 @@ export class SuggestionService extends EventEmitter { const anchor = this._anchor const anchorKind = this._anchorKind const provenance = this._provenance - const composing = this._lastContext?.isComposing === true && /[가-힣]$/u.test(acceptPrefix) + const composing = this._lastContext?.isComposing === true const appName = this._appName const windowTitle = this._windowTitle const targetWindow = this._windowHandle diff --git a/apps/desktop/src/main/services/TypoCorrectionService.ts b/apps/desktop/src/main/services/TypoCorrectionService.ts index 6be818b..c396c78 100644 --- a/apps/desktop/src/main/services/TypoCorrectionService.ts +++ b/apps/desktop/src/main/services/TypoCorrectionService.ts @@ -225,6 +225,12 @@ export class TypoCorrectionService extends EventEmitter { // 1단계(한영 전환 layoutOnly)는 단어 경계(25ms)와 어절 끝 유휴(650ms)에서 즉시 실행하고, // 2단계(철자 사전 + Gemma 배경 오타·한영 보정)는 터미널이 아니면서 유휴 조건을 충족했을 때 실행한다. const isTerminal = context.terminalMode === true || isTerminalApp(context.appName) + // 터미널(xterm.js 등)에서 공백·문장부호 없이 완성형 한글 음절([가-힣])로 끝난 상태는 + // 아직 IME 조합 버퍼에 머물러 있어 PTY 로 전달되기 전일 수 있다. 이때 commitComposition(Space+Backspace)을 + // 주입하면 xterm.js 의 비동기 조합 확정과 백스페이스가 경합해 앞 글자를 삼키므로 단어 경계(Space 등)까지 기다린다. + if (isTerminal && !hasTrailingBoundary && !isVimCommand && /[가-힣]$/u.test(prefix)) { + return 'pass' + } const suspicious = hasSuspiciousTypo(region) const minFullCheckIdle = hasTrailingBoundary && suspicious diff --git a/apps/desktop/tests/main/services/TypoCorrectionService.test.ts b/apps/desktop/tests/main/services/TypoCorrectionService.test.ts index 34fd3e6..ed59c93 100644 --- a/apps/desktop/tests/main/services/TypoCorrectionService.test.ts +++ b/apps/desktop/tests/main/services/TypoCorrectionService.test.ts @@ -589,6 +589,40 @@ describe('TypoCorrectionService', () => { ).toBe('pass') expect(fake.replaceBeforeCaret).not.toHaveBeenCalled() }) + + it('터미널에서 공백 없이 끝난 한글 음절(예: ㅎ샤ㅗㅕㅠ에)은 조합 중 글자를 삼키지 않도록 공백 확정 전까지 치환하지 않는다', async () => { + const fake = deps({ warmModel: () => null }) + const service = new TypoCorrectionService(fake.deps) + + // 공백 전(조합 중인 마지막 음절 '에' 가 아직 xterm-helper-textarea 안에 있을 때)에는 건드리지 않는다. + expect( + service.handleTypingContext( + typingContext({ + prefix: 'ㅎ샤ㅗㅕㅠ에', + appName: 'Agent Switchboard.exe', + terminalMode: true, + isComposing: true, + idleMs: 1200 + }) + ) + ).toBe('pass') + expect(fake.replaceBeforeCaret).not.toHaveBeenCalled() + + // 공백으로 어절이 확정된 뒤('ㅎ샤ㅗㅕㅠ에 ')에는 'github에 ' 로 정상 치환한다. + expect( + service.handleTypingContext( + typingContext({ + prefix: 'ㅎ샤ㅗㅕㅠ에 ', + appName: 'Agent Switchboard.exe', + terminalMode: true, + isComposing: false, + idleMs: 80 + }) + ) + ).toBe('correcting') + await flush() + expect(fake.replaceBeforeCaret).toHaveBeenCalledWith('ㅎ샤ㅗㅕㅠ에 '.length, 'github에 ') + }) }) describe('TypoCorrectionService.propose — 제안 창에 함께 내놓을 교정 (적용하지 않음)', () => { diff --git a/docs/map/00-index.md b/docs/map/00-index.md index 63b778c..0f786a9 100644 --- a/docs/map/00-index.md +++ b/docs/map/00-index.md @@ -2,7 +2,7 @@ > Status: ACTIVE > Last full audit: 2026-09-13 -> Last update: 2026-10-31 — **v1.15.0 릴리스 + 다단계 명령 파이프라인 복수 선택·순서 조정 UI 및 단일 패스 합성 실행(`AI-05`, `AI-07`).** `@d3ro/core/instruction-template`에 복수 명령 파이프라인 직렬화·토글·순서 이동·프롬프트 합성(`parseActiveInstructionIds`, `serializeActiveInstructionIds`, `toggleInstructionInPipeline`, `moveInstructionInPipeline`, `composeInstructionPipelinePrompt`)을 추가하고, `CommandsPage.tsx`를 단일 라디오 선택에서 **순서가 있는 복수 선택(체크박스 + `1단계`/`2단계` 배지 + `↑`/`↓` 순서 이동 버튼 + 상단 단계별 파이프라인 요약 + 파이프라인 통합 테스트 실행)**으로 업그레이드했다. 예컨대 `1단계: 구어·추임새·중복 정리` → `2단계: 격식체 변환`을 함께 선택하면 후행 단계의 어투·출력 규칙이 우선 적용되는 합성 파이프라인 프롬프트로 지연 시간 증가 없이 한 번에 실행된다. +> Last update: 2026-10-31 — **v1.15.1 릴리스 + 터미널·xterm.js 환경 한글 1글자씩 씹힘 근본 해결(`INPUT-04`, `INPUT-19`, `GAP-INPUT-08`, `GAP-INPUT-11`).** 터미널(`Agent Switchboard.exe` `xterm-helper-textarea`, `WindowsTerminal.exe`, `Kitedesk.exe`, `pwsh.exe`, `cmd.exe` 등)에서 한글 연속 타이핑 시 글자가 한 글자씩 씹히던 4가지 원인을 전수 제거했다: (1) `InputTelemetryService._handleKeyDown`에서 터미널 표면일 때 매 키다운마다 호출하던 크로스-프로세스 `isForegroundKoreanIme`(`SendMessageTimeoutW(WM_IME_CONTROL)`)가 Windows TSF/DefIME 조합 상태를 흔들던 문제를 제거하고 유휴 스냅샷 시점 1회 동기화(`TerminalKeystrokeTracker.syncKoreanIme`)로 전환, (2) `sidecar/uia_bridge.py`에서 `xterm-helper-textarea` 조회 시 Chromium 렌더러 메인 스레드를 최대 1,500ms 블로킹하고 `comp=True` 고착을 유발하던 `GetTopLevelControl()`·`TextPattern.GetSelection()`·`ExpandToEnclosingUnit(Character)`·`TextEditPattern.GetActiveComposition()` 호출을 건너뛰는 고속 경로 추가 및 `_WAKE_TTL_SECONDS` 60s→86,400s 연장, (3) 일반 한글 단어(`"근데 "`, `"터미널 "` 등) 입력 중 공백 직후 40ms 경계 스냅샷·680ms 중복 타이머·800ms 타이핑 중 폴링 억제(`_shouldRunFastTerminalBoundarySnapshot`, `_sampleWhileTyping`), (4) `TypoCorrectionService`에서 터미널의 공백 전 완성형 한글 음절(`[가-힣]$`)에 대해 `commitComposition`(`VK_SPACE`+`VK_BACK`) 주입을 원천 차단. 직전 같은 날 `v1.15.0`: `CommandsPage.tsx` 다단계 명령 파이프라인 복수 선택·순서 조정 UI 및 단일 패스 합성 실행(`AI-05`, `AI-07`). > > Previous update: 2026-10-30 — **백로그 26건 일괄 해소 (`GAP-INPUT-03`, `GAP-LLM-01`, `GAP-UX-01/02/03/05/06/07`, `GAP-I18N-01`, `GAP-REL-11/14/15`, `GAP-INFRA-01/02/04/06`, `GAP-OPS-01`, `GAP-QA-02`, `GAP-KEY-01/03`, `GAP-ADS-02`, `GAP-ID-01/02`, `GAP-TEAM-02`, `GAP-SHELL-01`, `GAP-PUSH-03`, `GAP-MTG-01`, `DOC-01`) + 입력 누락 검증 인프라 및 서비스 결함 재현(`INPUT-04/19`, `INFRA-20`, `GAP-INPUT-11`).** (1) **백로그 26건 해소:** CJK 무공백 어절 집계(`countWords`), 12개 번역 대상 언어 설정(`targetLanguage`), 12개 로케일 2,716개 키 100% 동기화(`sync-i18n-locales.mjs`), 데스크톱 strict 타입체크 0 에러(`tsconfig.node.json` + `tsconfig.web.json`), Forgejo 릴리스 태그 푸시 순서·SHA 고정(`GAP-REL-14`), 포터블 워크플로 매니페스트 검증(`GAP-REL-11`), 네이티브 ABI 스위처(`rebuild:app`/`rebuild:test`), Supabase 마이그레이션 정합성 검사기(`check:migrations`), NAS 배포 런북(`nas-deploy-runbook.md`), 오프라인 격리 테스트 하네스(`GAP-QA-02`), `KeyBindingService` 단위 테스트·`command` 전용 액션 핸들러, 데스크톱 광고 보상 쿼터 연동(`grantRewardQuota`), 회의 종료 후 메모 추가·노트패드 동기화, 이력 SQLite 커서 페이지네이션·인라인 편집·전체 내보내기, 회의 요약 `[MM:SS]` 타임스탬프 인용·클릭 시크 연동(데스크톱·웹·모바일), `resolveEntitlement` 정본 통일, 통합 검색(`UnifiedSearchService`) 취소·세그먼트 검색·페이로드 경량화, 웹 팀 초대 수락(`/app/accept-invite`), 관리자 고객지원 콘솔(`/support`), Web Push 서비스워커(`sw.js`)·iOS APNs 토큰 등록을 완료했다. (2) **입력 누락 검증 인프라(`GAP-INPUT-11`):** `typing-race-proof.mjs`가 체크아웃을 바꾸지 않고 3개 서비스만 HEAD `f49acf0`와 수정본으로 바꿔 같은 현재 의존성·시험에서 비교했다: HEAD 1/17, 수정본 17/17. 3개 문자열 손상 사례와 13개 스냅샷·메타데이터·조회 병합 계약 실패를 구분했고, 정상 교정 대조군은 양쪽 모두 통과했다. `typing-fixture`(scan-code·IME·CPU 부하)와 `typing-runtime`(별도 로컬 프로필·실제 제품 번들)을 준비했으며, 실제 GUI·IME·CPU·모델 cold/warm 시험은 아직 미실행이다. 증거: `test-results/typing-load/race-proof-2026-10-30T00-50-32-284Z/report.json`; 실행 명령은 `02` §3, 검증 경계는 `04` §6과 `11` GAP-INPUT-11. > diff --git a/docs/map/10-feature-catalog.md b/docs/map/10-feature-catalog.md index 2fb0442..a700889 100644 --- a/docs/map/10-feature-catalog.md +++ b/docs/map/10-feature-catalog.md @@ -183,7 +183,7 @@ 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 (built-in automatic Han/Eng conversion) | [~] | [-] | [-] | [-] | **2026-10-03; upgraded 2026-10-26..28 (2-Stage Hybrid Auto-Correction: Araso-caliber instant layout engine + Smart Background Gemma Pass + Atomic Single-Syscall SendInput + Delta Rebasing + Terminal & Vim & xterm.js support + live Windows GUI E2E verified).** `TypoCorrectionService` (main, singleton + EventEmitter) runs on each `typed-context` before `SuggestionService`. **Active by default out of the box:** `InputTelemetryService` starts the UIA context observer whenever `typoAutoCorrectEnabled !== false` (even when `inputTelemetryEnabled` is `false`), and skips persisting `input_activity` rows to SQLite unless `inputTelemetryEnabled === true`; in Settings → Input (`InputConsentPanel.tsx`), the `typoAutoCorrect` switch works independently of telemetry consent. **2-Stage Hybrid Auto-Correction (`2026-10-27..28`):** `bootstrap.ts` calls `suggestion.ensureWarmForTyping(context)` on every `typed-context` (keeping `gemma4:e4b` warm even when `suggestionEnabled` is off) and runs the full 2-stage `typo.handleTypingContext(context)` in-place: Stage 1 (Instant `<1 ms` deterministic rule engine at 25 ms after word boundary / 650 ms at token tail) immediately converts known Han/Eng layout errors and dictionary misspellings, while Stage 2 (Background Gemma Pass at 350 ms after word boundary for suspicious tokens or 600 ms idle for general sentences, anchored to the trailing 2 words via `trailingWordOnly: true`) queries the warm local LLM (`gemma4:e4b`) with 2-set keyboard hints (`buildModelTypoHints` in `[한영 자판 변환 참고]`) and validates cross-script layout+typo fixes (`isPlausibleTypoFix` + `validateModelCorrections`, e.g. `ㅗ디ㅐ`→`hello`, `ㅡㅁ가둥`→`markdown`, `네갸ㅜㅎ에서`→`spring에서`, `dkssudgktpd`→`안녕하세요`, `회으에서`→`회의에서`, `아ㄴ녀ㅇ`→`안녕`) before handing off to `SuggestionService` via `'settled'`. **Ultra-fast atomic replacement & delta-rebasing (`2026-10-28`):** `TextInsertService.replaceBeforeCaret` (`method === 'keyboard'`) executes a single atomic `SendInput` call via `sendWin32UnicodeReplacement` (`utils/win32-unicode-input.ts`) packing `(optional VK_SPACE) + N × VK_BACK + M × KEYEVENTF_UNICODE` with `0 ms` JS sleep (`< 0.5 ms` execution, zero keystroke interleaving), and `TypoCorrectionService` uses `rebaseTypoReplacementPlan` (`packages/core/src/typo-correction.ts`) to adjust `deleteCount` and append any newly typed suffix characters (`<= 12` chars) when the user keeps typing during the 40 ms UIA verification or LLM check. **Terminal, Vim & xterm.js support (`2026-10-27`):** `TypoCorrectionService` keeps `layoutOnly: true` active inside `TERMINAL_APPS` (`WindowsTerminal`, `wt`, `pwsh`, `cmd`, `Kitedesk`, `wezterm`, `alacritty`, `kitty`, `ghostty`, `putty`, `MobaXterm`, `nvim-qt`, `neovide`, `gvim`, etc.) and developer/xterm.js surfaces (`isTerminalOrDeveloperSurface`, `isXtermHelperControl`) while keeping spelling/model corrections off. `TerminalKeystrokeTracker` (`packages/core/src/terminal-prompt.ts`) + `extractTerminalActiveContext` + `isForegroundKoreanIme` (`utils/win32-foreground.ts`, checking `IMC_GETCONVERSIONMODE` `IME_CMODE_NATIVE` on Windows TSF/Chromium) reconstruct the active line across (a) UIA screen-buffer terminals (`WindowsTerminal`/`pwsh`/`cmd`, restoring trailing spaces stripped by grid buffers and reading the bottom viewport via `GetVisibleRanges()` / `[-MAX_TEXT_CHARS:]` and `ExpandToEnclosingUnit(..., waitTime=0)` in `sidecar/uia_bridge.py`), (b) `xterm.js` hidden `