Fix Command Code smart-sort bump on new prompt while working (STA-350) (#5286)

Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
Brennan Benson
2026-07-12 18:05:11 -07:00
committed by GitHub
co-authored by Orca
parent d5627638ab
commit 3c87873dca
13 changed files with 443 additions and 14 deletions
@@ -0,0 +1,71 @@
import { describe, expect, it } from 'vitest'
import { isCommandCodeNewTurnWhileWorking } from './command-code-turn-boundary'
describe('isCommandCodeNewTurnWhileWorking', () => {
it('returns true when Command Code gets a new transcript prompt while still working', () => {
expect(
isCommandCodeNewTurnWhileWorking({
agentType: 'command-code',
previousState: 'working',
incomingState: 'working',
previousPrompt: 'first task',
incomingPrompt: 'second task',
hasExplicitPrompt: true
})
).toBe(true)
})
it('returns true when the prompt interaction key changes', () => {
expect(
isCommandCodeNewTurnWhileWorking({
agentType: 'command-code',
previousState: 'working',
incomingState: 'working',
previousPrompt: 'same text',
incomingPrompt: 'same text',
hasExplicitPrompt: true,
previousPromptInteractionKey: 'command-code-transcript-a',
incomingPromptInteractionKey: 'command-code-transcript-b'
})
).toBe(true)
})
it('returns false for same-turn tool pings that keep the same prompt', () => {
expect(
isCommandCodeNewTurnWhileWorking({
agentType: 'command-code',
previousState: 'working',
incomingState: 'working',
previousPrompt: 'run pwd',
incomingPrompt: 'run pwd',
hasExplicitPrompt: true
})
).toBe(false)
})
it('returns false when main-process hooks explicitly deny prompt evidence', () => {
expect(
isCommandCodeNewTurnWhileWorking({
agentType: 'command-code',
previousState: 'working',
incomingState: 'working',
previousPrompt: 'first',
incomingPrompt: 'second',
hasExplicitPrompt: false
})
).toBe(false)
})
it('returns false for non-Command Code agents', () => {
expect(
isCommandCodeNewTurnWhileWorking({
agentType: 'codex',
previousState: 'working',
incomingState: 'working',
previousPrompt: 'first',
incomingPrompt: 'second',
hasExplicitPrompt: true
})
).toBe(false)
})
})