tui: skip abort on mini session close (#39067)
This commit is contained in:
parent
0261f04b90
commit
f14d78afeb
2 changed files with 26 additions and 2 deletions
|
|
@ -75,7 +75,8 @@ export async function runPromptQueue(input: QueueInput): Promise<void> {
|
||||||
|
|
||||||
state.closed = true
|
state.closed = true
|
||||||
state.queue.length = 0
|
state.queue.length = 0
|
||||||
state.ctrl?.abort()
|
// Ordinary turn signals map to session.interrupt; exiting should only detach the TUI.
|
||||||
|
if (state.active?.mode === "shell") state.ctrl?.abort()
|
||||||
admissionController.abort()
|
admissionController.abort()
|
||||||
stop.resolve({ type: "closed" })
|
stop.resolve({ type: "closed" })
|
||||||
finish()
|
finish()
|
||||||
|
|
@ -198,7 +199,6 @@ export async function runPromptQueue(input: QueueInput): Promise<void> {
|
||||||
|
|
||||||
const next = await Promise.race([task, stop.promise])
|
const next = await Promise.race([task, stop.promise])
|
||||||
if (next.type === "closed") {
|
if (next.type === "closed") {
|
||||||
ctrl.abort()
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -338,6 +338,30 @@ describe("run runtime queue", () => {
|
||||||
expect(admissionHit).toBe(true)
|
expect(admissionHit).toBe(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test.each([
|
||||||
|
["session", undefined, false],
|
||||||
|
["shell", "shell", true],
|
||||||
|
] as const)("close handles an active %s turn", async (_name, mode, aborted) => {
|
||||||
|
const ui = createFooterApiFixture()
|
||||||
|
const started = Promise.withResolvers<AbortSignal>()
|
||||||
|
const active = Promise.withResolvers<void>()
|
||||||
|
const task = runPromptQueue({
|
||||||
|
footer: ui.api,
|
||||||
|
run: async (_input, signal) => {
|
||||||
|
started.resolve(signal)
|
||||||
|
await active.promise
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
ui.submit("one", mode)
|
||||||
|
const signal = await started.promise
|
||||||
|
ui.api.close()
|
||||||
|
await task
|
||||||
|
|
||||||
|
expect(signal.aborted).toBe(aborted)
|
||||||
|
active.resolve()
|
||||||
|
})
|
||||||
|
|
||||||
test("propagates run errors", async () => {
|
test("propagates run errors", async () => {
|
||||||
const ui = createFooterApiFixture()
|
const ui = createFooterApiFixture()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue