fix(suggestion): insert accepted suggestions reliably and learn typing as whole sentences
Acceptance waited for modifiers using only the uiohook-tracked set; a missed keyup made it time out after 1.5 s and paste while Ctrl/Alt counted as held, so nothing was inserted. Trust GetAsyncKeyState instead, and suppress new suggestions while an accept is in flight. Typed deltas were saved per snapshot (every 0.4-0.8 s), storing mid-word fragments. Buffer them per field and save one diff on idle, sentence end, send or focus change; drop short pieces, URLs, trailing jamo and truncated emoji.
This commit is contained in:
parent
006909065f
commit
cdeeff4c11
7 changed files with 341 additions and 23 deletions
|
|
@ -304,6 +304,8 @@ export class SuggestionService extends EventEmitter {
|
|||
private _lastRequestedPrefix = ''
|
||||
/** 사용자가 X 로 닫은 뒤 재표시를 막는 시각 (ms) */
|
||||
private _userDismissedUntil = 0
|
||||
/** 수락 삽입이 진행 중이다(수정자 키 떼기 대기 포함) — 그사이 같은 글로 새 제안 창이 다시 뜨지 않게 한다. */
|
||||
private _acceptInFlight = false
|
||||
/** 스트리밍 누적 텍스트 */
|
||||
private _partialText = ''
|
||||
/** 마지막 스트리밍 방출 시각 (IPC 과다 방출 방지) */
|
||||
|
|
@ -646,6 +648,7 @@ export class SuggestionService extends EventEmitter {
|
|||
this._lastContext = context
|
||||
const now = Date.now()
|
||||
this._lastContextAt = now
|
||||
if (this._acceptInFlight) return
|
||||
this._watchdog()
|
||||
|
||||
const config = this.readPolicyConfig()
|
||||
|
|
@ -1939,6 +1942,34 @@ export class SuggestionService extends EventEmitter {
|
|||
|
||||
// 단축키로 수락했다면 사용자가 아직 Ctrl+Alt 를 쥐고 있다. 그대로 Ctrl+V 를 보내면
|
||||
// 대상 앱에 Ctrl+Alt+V 가 들어가 붙여넣기가 되지 않는다(실측) — 뗄 때까지 기다린다.
|
||||
this._acceptInFlight = true
|
||||
try {
|
||||
return await this._insertAccepted({
|
||||
text,
|
||||
deleteCount,
|
||||
composing,
|
||||
appName,
|
||||
windowTitle,
|
||||
targetWindow,
|
||||
sessionRecordId,
|
||||
candidateText: candidate.text
|
||||
})
|
||||
} finally {
|
||||
this._acceptInFlight = false
|
||||
}
|
||||
}
|
||||
|
||||
private async _insertAccepted(params: {
|
||||
text: string
|
||||
deleteCount: number
|
||||
composing: boolean
|
||||
appName: string | null
|
||||
windowTitle: string | null
|
||||
targetWindow: number | null
|
||||
sessionRecordId: string | null
|
||||
candidateText: string
|
||||
}): Promise<SuggestionRequestResult> {
|
||||
const { text, deleteCount, composing, appName, windowTitle, targetWindow, sessionRecordId, candidateText } = params
|
||||
const modifierWaitStartedAt = Date.now()
|
||||
if (!(await waitForModifiersReleased())) {
|
||||
logger.warn('수정자 키가 떼어지지 않은 채 제안을 삽입한다 (1.5초 초과)')
|
||||
|
|
@ -1995,12 +2026,12 @@ export class SuggestionService extends EventEmitter {
|
|||
// 세션 행을 알면 그 행을 수락으로 표시한다 — 텍스트로 찾으면 로컬 기억의 2번째 이후 후보는
|
||||
// 행이 없어 사라지거나 같은 문구의 옛 행(다른 앱·다른 날)이 수락으로 잡혔다.
|
||||
if (sessionRecordId && this._repository.markSessionAccepted) {
|
||||
this._repository.markSessionAccepted(sessionRecordId, candidate.text)
|
||||
this._repository.markSessionAccepted(sessionRecordId, candidateText)
|
||||
} else {
|
||||
this._repository.markAccepted(candidate.text)
|
||||
this._repository.markAccepted(candidateText)
|
||||
}
|
||||
// 수락한 문장은 사용자 문체의 확실한 표본이다 (학습 동의 시에만 저장됨).
|
||||
this._learning.recordAccepted(candidate.text, { appName, windowTitle })
|
||||
this._learning.recordAccepted(candidateText, { appName, windowTitle })
|
||||
return { ok: true }
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue