Skip to content

Commit 209809e

Browse files
committed
fix(web): clear stale verification terminal state
1 parent 03233bf commit 209809e

2 files changed

Lines changed: 31 additions & 2 deletions

File tree

web/src/stores/useRuntimeInsightStore.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,29 @@ describe('useRuntimeInsightStore', () => {
3838

3939
store.failVerification({ stop_reason: 'error', error_class: 'TestError' })
4040
expect(useRuntimeInsightStore.getState().verificationFailed?.error_class).toBe('TestError')
41+
expect(useRuntimeInsightStore.getState().verificationCompleted).toBeNull()
42+
})
43+
44+
it('clears a stale failed terminal state when verification later completes', () => {
45+
const store = useRuntimeInsightStore.getState()
46+
47+
store.failVerification({ stop_reason: 'error', error_class: 'TestError' })
48+
store.completeVerification({ stop_reason: 'accepted' })
49+
50+
const state = useRuntimeInsightStore.getState()
51+
expect(state.verificationCompleted?.stop_reason).toBe('accepted')
52+
expect(state.verificationFailed).toBeNull()
53+
})
54+
55+
it('clears a stale completed terminal state when verification later fails', () => {
56+
const store = useRuntimeInsightStore.getState()
57+
58+
store.completeVerification({ stop_reason: 'accepted' })
59+
store.failVerification({ stop_reason: 'error', error_class: 'TestError' })
60+
61+
const state = useRuntimeInsightStore.getState()
62+
expect(state.verificationFailed?.error_class).toBe('TestError')
63+
expect(state.verificationCompleted).toBeNull()
4164
})
4265

4366
it('resets all insight state', () => {

web/src/stores/useRuntimeInsightStore.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,14 @@ export const useRuntimeInsightStore = create<RuntimeInsightState>((set) => ({
8181
setCheckpointDiff: (checkpointDiff) => set({ checkpointDiff }),
8282
addCheckpointEvent: (event) => set((s) => ({ checkpointEvents: [...s.checkpointEvents, event] })),
8383
setCheckpointWarning: (checkpointWarning) => set({ checkpointWarning }),
84-
completeVerification: (verificationCompleted) => set({ verificationCompleted }),
85-
failVerification: (verificationFailed) => set({ verificationFailed }),
84+
completeVerification: (verificationCompleted) => set({
85+
verificationCompleted,
86+
verificationFailed: null,
87+
}),
88+
failVerification: (verificationFailed) => set({
89+
verificationFailed,
90+
verificationCompleted: null,
91+
}),
8692
setAcceptanceDecision: (acceptanceDecision) => set({ acceptanceDecision }),
8793
setTodoSnapshot: (todoSnapshot) => set((s) => {
8894
const items = todoSnapshot?.items ?? []

0 commit comments

Comments
 (0)