fix(desktop): prevent modifier key buffer resets, clipboard race on terminal accept, and redundant UIA settle snapshots

This commit is contained in:
Yun Chan 2026-10-31 04:19:53 +09:00
parent 6d909dd0e5
commit 41901c1ec5
10 changed files with 198 additions and 23 deletions

View file

@ -108,10 +108,15 @@ describe('classifyKeyStroke', () => {
expect(classifyKeyStroke(0xe5, NO_MODS)).toBe('ime')
})
it('수정자 조합은 단축키로 다', () => {
it('수정자 조합은 단축키로 분류하되, 수정자 키 자체(Ctrl/Alt/Shift/Win)는 플래그가 켜져 있어도 modifier 로 분류한다', () => {
expect(classifyKeyStroke(0x41, { ...NO_MODS, ctrl: true })).toBe('shortcut')
expect(classifyKeyStroke(0x41, { ...NO_MODS, alt: true })).toBe('shortcut')
expect(classifyKeyStroke(0x41, { ...NO_MODS, meta: true })).toBe('shortcut')
expect(classifyKeyStroke(0x11, { ...NO_MODS, ctrl: true })).toBe('modifier')
expect(classifyKeyStroke(0xa2, { ...NO_MODS, ctrl: true })).toBe('modifier')
expect(classifyKeyStroke(0x12, { ...NO_MODS, ctrl: true, alt: true })).toBe('modifier')
expect(classifyKeyStroke(0xa4, { ...NO_MODS, alt: true })).toBe('modifier')
expect(classifyKeyStroke(0x5b, { ...NO_MODS, meta: true })).toBe('modifier')
})
it('알 수 없는 키는 other 이며 키 내용을 담지 않는다', () => {

View file

@ -239,4 +239,29 @@ describe('제안 + 오타 교정', () => {
expect(options).toEqual(expect.objectContaining({ raw: true }))
}
})
it('터미널 모드(terminalMode=true)에서 수락하면 클립보드(Ctrl+V)를 건드리지 않고 keyboard 방식으로 넣으며 터미널 버퍼를 동기화한다', async () => {
const expectKeys = vi.fn()
const applyReplacement = vi.fn()
const customDeps = deps(expectKeys)
customDeps.learning.applyProgrammaticReplacement = applyReplacement
const service = new SuggestionService(customDeps)
services.push(service)
service.setTypoProposer(proposer)
const context = typingContext({ terminalMode: true })
const internal = service as unknown as Internal
internal._lastContext = context
await internal._generate(context.prefix, context, 3, 160)
const result = await service.accept()
expect(result).toEqual({ ok: true })
expect(harness.replaceBeforeCaret).toHaveBeenCalledWith(
TYPO.length,
'안녕하세요.? 오늘 회의 자료 공유드립니다.',
'keyboard',
{ commitComposition: false }
)
expect(applyReplacement).toHaveBeenCalledWith(TYPO.length, '안녕하세요.? 오늘 회의 자료 공유드립니다.')
})
})