Skip to content

Commit 72fcbe4

Browse files
committed
Wire classifySubmit through the runner host and empty Enter cancel
The busy-path fix was dropped at mountRunnerHost, so typecheck failed on classifySubmit. Empty Enter also never reached exclusive hooks, so armed /feedback cancel was dead code until the shell lets blank lines through.
1 parent 11a306f commit 72fcbe4

3 files changed

Lines changed: 34 additions & 1 deletion

File tree

‎src/tui/prompt-features.test.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,20 @@ describe("image attachments", () => {
234234
expect(texts).toEqual([""])
235235
})
236236
})
237+
238+
test("empty Enter still reaches exclusive host for multi-turn cancel", async () => {
239+
await withShell(async (shell) => {
240+
const submitted: string[] = []
241+
setShellBridgeHooks(shell, {
242+
onSubmit: (text) => submitted.push(text),
243+
onInterrupt: () => {},
244+
exclusive: true,
245+
})
246+
shell.prompt.value = " "
247+
submitPrompt(shell)
248+
expect(submitted).toEqual([" "])
249+
})
250+
})
237251
})
238252

239253
/**

‎src/tui/runner-host.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@ export type RunnerHostDeps = {
5656
text: string,
5757
attachments?: readonly PendingImageAttachment[],
5858
) => void
59+
/**
60+
* Classify a submit without side effects so slash commands and multi-turn
61+
* /feedback never mark the session busy or enter the mid-run queue.
62+
*/
63+
readonly classifySubmit?: (
64+
text: string,
65+
attachments?: readonly PendingImageAttachment[],
66+
) => "agent" | "local" | "empty"
5967
readonly interrupt: () => void
6068
readonly deliver?: (
6169
text: string,
@@ -249,6 +257,9 @@ export async function mountRunnerHost(deps: RunnerHostDeps): Promise<RunnerHost>
249257
eventEmitter: deps.eventEmitter,
250258
send: deps.send,
251259
interrupt: deps.interrupt,
260+
...(deps.classifySubmit !== undefined
261+
? { classifySubmit: deps.classifySubmit }
262+
: {}),
252263
...(deps.deliver !== undefined ? { deliver: deps.deliver } : {}),
253264
...(deps.onConnectProvider !== undefined
254265
? { onConnectProvider: deps.onConnectProvider }

‎src/tui/shell.ts‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3138,7 +3138,15 @@ export function submitPrompt(
31383138
const text = shell.prompt.value
31393139
const t = text.trim()
31403140
const attachments = shell.pendingAttachments
3141-
if (t.length === 0 && attachments.length === 0) return
3141+
if (t.length === 0 && attachments.length === 0) {
3142+
// Empty Enter still reaches the exclusive host so multi-turn /feedback
3143+
// can cancel; non-exclusive shells have nothing to do with a blank line.
3144+
const hooks = getShellBridgeHooks(shell)
3145+
if (hooks?.exclusive) {
3146+
hooks.onSubmit(text, "immediate", attachments)
3147+
}
3148+
return
3149+
}
31423150
if (kind === "reinject" && shell.session.run !== "busy") return
31433151

31443152
// Shell/REPL muscle memory: a bare `exit` or `quit` quits rather than being

0 commit comments

Comments
 (0)