fix(commands): decide whether a deleted command was in use when the delete commits, not when it was clicked

Picking another command during the undo window was overwritten with 'raw'
five seconds later because the selection was captured at click time.
This commit is contained in:
Yun Chan 2026-10-20 22:49:11 +09:00
parent ce8d603b4a
commit b961dfd999
3 changed files with 28 additions and 3 deletions

View file

@ -15,6 +15,7 @@ import {
llmActionLabelKey,
resolveCommandPipeline,
withoutHidden,
isInstructionInUse,
} from '../../src/renderer/pages/tools/tools-model'
const polish = { id: 'i1', name: '정중하게', prompt: '{{text}} 를 정중하게' }
@ -95,3 +96,13 @@ describe('withoutHidden / documentIndexLabelKey', () => {
expect(documentIndexLabelKey({ id: 'd', indexed: true }, null)).toBe('rag.indexed')
})
})
describe('isInstructionInUse — 명령 삭제 확정 시점의 설정으로 판단', () => {
it('지운 명령이 아직 선택돼 있을 때만 true', () => {
expect(isInstructionInUse({ defaultLLMAction: 'custom', activeInstructionId: 'x' }, 'x')).toBe(true)
// 되돌리기 알림 동안 다른 명령을 골랐다 — 덮으면 안 된다
expect(isInstructionInUse({ defaultLLMAction: 'custom', activeInstructionId: 'y' }, 'x')).toBe(false)
expect(isInstructionInUse({ defaultLLMAction: 'refine', activeInstructionId: 'x' }, 'x')).toBe(false)
expect(isInstructionInUse(null, 'x')).toBe(false)
})
})