Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

fix(chat): send a queued follow-up with the steer shortcut (#1921)

wojiecihuo5dfa023d8881
diff --git a/apps/desktop/src/components/Composer.tsx b/apps/desktop/src/components/Composer.tsx
index 365669947..4fd798955 100644
--- a/apps/desktop/src/components/Composer.tsx
+++ b/apps/desktop/src/components/Composer.tsx
@@ -448,6 +448,8 @@ export function Composer({
t,
sendPrompt,
steerPrompt,
+ sendQueuedNow,
+ queuedPrompts,
showToast,
recordHistory: inputHistory.record,
draft: {
diff --git a/apps/desktop/src/features/chat/composer/hooks/useComposerSubmit.ts b/apps/desktop/src/features/chat/composer/hooks/useComposerSubmit.ts
index 07a1e503d..052099ed6 100644
--- a/apps/desktop/src/features/chat/composer/hooks/useComposerSubmit.ts
+++ b/apps/desktop/src/features/chat/composer/hooks/useComposerSubmit.ts
@@ -12,6 +12,7 @@ import {
resolveSlashDispatch,
} from "../slash-dispatch";
import { readEditorValue, type ComposerFileReference } from "../editor";
+import { nextSendableQueuedPrompt, type QueuedPrompt } from "../../../../lib/queued-prompts";
import type { ComposerDraftSnapshot } from "../../../../lib/composer-smart-stop";
import type { ComposerDraftController } from "./useComposerDraft";
import { submitWithLatestDraftRestore } from "./submit-with-latest-draft-restore.mjs";
@@ -30,6 +31,9 @@ type UseComposerSubmitOptions = {
t: TFunction;
sendPrompt: AppState["sendPrompt"];
steerPrompt: AppState["steerPrompt"];
+ sendQueuedNow: AppState["sendQueuedNow"];
+ /** This session's follow-ups; the steer shortcut promotes the first one. */
+ queuedPrompts: readonly QueuedPrompt[];
showToast: AppState["showToast"];
/** Record an accepted submission for ArrowUp recall. */
recordHistory?: (snapshot: ComposerDraftSnapshot, sessionId: string) => void;
@@ -65,6 +69,8 @@ export function useComposerSubmit({
t,
sendPrompt,
steerPrompt,
+ sendQueuedNow,
+ queuedPrompts,
showToast,
recordHistory,
draft,
@@ -76,7 +82,15 @@ export function useComposerSubmit({
// arrives where the user put it instead of trailing the text.
const inlineContent = serializeInlineComposerFileReferences(rawText, activeFileReferences);
const serializedContent = serializeComposerFileReferences(rawText, activeFileReferences);
- if (!serializedContent) return;
+ // A follow-up that was queued during the turn has already left the editor,
+ // so the steer shortcut would otherwise find no draft and do nothing. With
+ // the composer empty it sends the first waiting row now instead, which is
+ // the same promotion its own Send now button performs.
+ if (!serializedContent) {
+ const waiting = steering && !sendBlocked ? nextSendableQueuedPrompt(queuedPrompts) : undefined;
+ if (waiting) await sendQueuedNow(waiting.id);
+ return;
+ }
if (sendBlocked || (steering && !steeringAllowed)) {
if (pasting) showToast(t("chat.pasteInProgress"), { variant: "info" });
return;
diff --git a/apps/desktop/src/lib/queued-prompts.ts b/apps/desktop/src/lib/queued-prompts.ts
index cb3157267..2f187fafa 100644
--- a/apps/desktop/src/lib/queued-prompts.ts
+++ b/apps/desktop/src/lib/queued-prompts.ts
@@ -62,6 +62,19 @@ export function isPromotedQueuedPrompt(
return item.priority !== undefined;
}
+/**
+ * The row Send now can still move: not awaiting Host admission, not already
+ * promoted. The queue mirrors delivery order, so this is the row that would
+ * start next anyway.
+ */
+export function nextSendableQueuedPrompt(
+ queue: readonly QueuedPrompt[],
+): QueuedPrompt | undefined {
+ return queue.find(
+ (item) => !isPendingQueuedPrompt(item) && !isPromotedQueuedPrompt(item),
+ );
+}
+
/**
* Send now: promote one row behind the already promoted block. Click order is
* priority order, and only the promoted block is ordered by priority.
diff --git a/apps/desktop/test/composer-queued-send-now-shortcut.test.mjs b/apps/desktop/test/composer-queued-send-now-shortcut.test.mjs
new file mode 100644
index 000000000..015be74f5
--- /dev/null
+++ b/apps/desktop/test/composer-queued-send-now-shortcut.test.mjs
@@ -0,0 +1,110 @@
+import assert from "node:assert/strict";
+import test from "node:test";
+import { fileURLToPath } from "node:url";
+import { createServer } from "vite";
+import { slotSsr } from "./helpers/slot-ssr.mjs";
+import {
+ readComposerModule,
+ readComposerSource,
+} from "./helpers/source-contracts.mjs";
+
+async function loadQueuedPrompts(t) {
+ const server = await createServer({
+ root: fileURLToPath(new URL("..", import.meta.url)),
+ configFile: false,
+ server: { middlewareMode: true, hmr: false, ws: false },
+ appType: "custom",
+ optimizeDeps: { noDiscovery: true, include: [] },
+ });
+ t.after(() => server.close());
+ return server.ssrLoadModule("/src/lib/queued-prompts.ts");
+}
+
+function queuedFixture(overrides) {
+ return {
+ id: "prompt-1",
+ sessionId: "session-a",
+ content: "follow up",
+ draft: { text: "", fileReferences: [] },
+ createdAt: 1,
+ ...overrides,
+ };
+}
+
+test("next sendable queued prompt skips saving and already promoted rows", async (t) => {
+ const { nextSendableQueuedPrompt } = await loadQueuedPrompts(t);
+
+ assert.equal(nextSendableQueuedPrompt([]), undefined);
+
+ const waiting = queuedFixture({ id: "prompt-waiting" });
+ assert.equal(
+ nextSendableQueuedPrompt([
+ queuedFixture({ id: "pending:1" }),
+ queuedFixture({ id: "prompt-promoted", priority: 0 }),
+ waiting,
+ ]),
+ waiting,
+ );
+
+ assert.equal(
+ nextSendableQueuedPrompt([
+ queuedFixture({ id: "pending:1" }),
+ queuedFixture({ id: "prompt-promoted", priority: 0 }),
+ ]),
+ undefined,
+ );
+});
+
+test("the composer submit path promotes a waiting row only for an empty steer", async (t) => {
+ const ssr = await slotSsr(t);
+ const { useComposerSubmit } = await ssr.load("/src/features/chat/composer/hooks/useComposerSubmit.ts");
+ const calls = [];
+ const waiting = queuedFixture({ id: "prompt-waiting" });
+ const queuedPrompts = [
+ queuedFixture({ id: "pending:1" }),
+ queuedFixture({ id: "prompt-promoted", priority: 0 }),
+ waiting,
+ ];
+ const makeSubmit = (overrides = {}) => useComposerSubmit({
+ value: "", draftKey: "session-a", activeSessionId: "session-a",
+ modelReady: true, sendBlocked: false, steeringAllowed: true,
+ invalidateComposerTransforms() {}, pasting: false, activeFileReferences: [],
+ t: (key) => key, showToast() {}, queuedPrompts,
+ sendPrompt: async (...args) => { calls.push(["prompt", ...args]); return true; },
+ steerPrompt: async (...args) => { calls.push(["steer", ...args]); return true; },
+ sendQueuedNow: async (id) => calls.push(["queued", id]),
+ draft: {
+ ref: { current: null }, draftRevision: () => 1,
+ draftSnapshot: (text) => ({ text, fileReferences: [] }),
+ clearDraftForKey: (...args) => calls.push(["clear", ...args]),
+ restoreDraftForKey: (...args) => calls.push(["restore", ...args]),
+ },
+ ...overrides,
+ });
+
+ await makeSubmit().submit(true);
+ assert.deepEqual(calls, [["queued", waiting.id]]);
+
+ calls.length = 0;
+ await makeSubmit().submit();
+ assert.deepEqual(calls, []);
+
+ calls.length = 0;
+ await makeSubmit({ sendBlocked: true }).submit(true);
+ assert.deepEqual(calls, []);
+
+ calls.length = 0;
+ await makeSubmit({ value: "draft text" }).submit(true);
+ assert.equal(calls[0]?.[0], "clear");
+ assert.equal(calls[1]?.[0], "steer");
+ assert.equal(calls.some((call) => call[0] === "queued"), false);
+});
+
+test("the composer hands the session queue and Send now to the submit hook", async () => {
+ const composer = await readComposerSource();
+ const submitOptions =
+ composer.match(/useComposerSubmit\(\{[\s\S]*?\n {2}\}\);/)?.[0] ?? "";
+ assert.ok(submitOptions.length > 0, "useComposerSubmit options not found");
+ assert.match(submitOptions, /\n {4}sendQueuedNow,\n/);
+ assert.match(submitOptions, /\n {4}queuedPrompts,\n/);
+});
diff --git a/docs/spec/04-ux/08-component-spec.md b/docs/spec/04-ux/08-component-spec.md
index feefb8530..5cf1f4f37 100644
--- a/docs/spec/04-ux/08-component-spec.md
+++ b/docs/spec/04-ux/08-component-spec.md
@@ -3202,6 +3202,8 @@ reasoning-level control.
it does not request `agent/stop`. `TaskWait` yields without canceling delegates.
Refused input or an input with a different effective permission mode retains
its durable queue entry until the next turn. When idle it starts immediately.
+ With the composer empty, the steering shortcut promotes the first waiting row
+ the same way, skipping rows that are still saving or already promoted.
- A pending queue row is locked until Host admission returns its durable id: move
up/down, Send now, edit, and remove are disabled. All five tooltips explain
that it is saving; Send now also displays the localized Saving label. Direct edit/remove actions leave the pending row and draft
diff --git a/docs/spec/04-ux/09-interaction-patterns.md b/docs/spec/04-ux/09-interaction-patterns.md
index 35b155a34..ea7245bff 100644
--- a/docs/spec/04-ux/09-interaction-patterns.md
+++ b/docs/spec/04-ux/09-interaction-patterns.md
@@ -883,7 +883,9 @@ may be retained while exactly one workspace supplies the visible shell context.
under a different permission mode stays queued for the next turn. Promoted
rows retain Remove until delivery and show Waiting to send. Removal
waits for Host acknowledgement; if delivery wins the race, report that the
- message has already started and direct the user to Stop.
+ message has already started and direct the user to Stop. With the composer
+ empty, the steering shortcut in §3.5 promotes the first waiting row the same
+ way, so Send now never requires the pointer.
- Without Send now, the next FIFO row starts automatically after the active
turn completes, fails, or is aborted. A terminal event can arrive before
persistence releases the session; finalization must wake the queue again
@@ -897,6 +899,14 @@ may be retained while exactly one workspace supplies the visible shell context.
- `Alt+Enter` submits the visible draft to the current turn immediately. On
macOS this is `Option+Enter`. It works with Enter-to-send on or off and takes
precedence over an open autocomplete menu. An idle composer sends normally.
+- With an empty composer the same shortcut sends the first waiting follow-up
+ now, exactly as that row's Send now action does, so a prompt queued during the
+ turn is not stranded above the composer. Rows still awaiting Host admission
+ and already promoted rows are skipped. A visible draft always takes
+ precedence over the queue, and a blocked composer promotes nothing. Like the
+ row action, this does not depend on the session's steering capability: where
+ steering is unavailable the Host keeps the promoted row queued, so the
+ shortcut sends the next queued follow-up as soon as the turn ends.
- `Shift+Enter` and `Alt+Shift+Enter` insert a newline. An Enter confirming an
IME candidate (`isComposing` or key code 229) never sends or steers.
- Steering appears as a user message in the current transcript, clears the
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index 5974da72a..9cd797cae 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -2499,6 +2499,11 @@ identify the platform validation still needed.
edit/remove the pending row, release admission, then edit/remove the durable
row. Repeat with a captured file-reference draft. 12) Withhold a local Host
queue-save request until its existing RPC deadline expires, then retry.
+ 13) With an empty composer and two waiting rows, press the steering shortcut
+ (`⌥/Alt+Enter`): verify the first row is promoted, press it again to promote
+ the second, then repeat with only a saving row present. 14) Repeat with a
+ draft in the composer and confirm the shortcut steers the draft and leaves
+ both rows waiting.
- **Expected**: The single submit slot contains exactly one button in every
state: disabled Send while idle and empty, enabled Send while running with
content (which queues the prompt), and Stop while running with an empty
@@ -2524,7 +2529,10 @@ identify the platform validation still needed.
on Send now, and remain visible without restoring a second draft. Once acknowledged, remove deletes the durable row and edit restores
exactly its captured draft; neither row reappears after refresh. A local Host
admission timeout clears the pending row, reports the error, and restores
- the rejected composer draft; retry can queue normally.
+ the rejected composer draft; retry can queue normally. With an empty composer
+ the steering shortcut promotes the first waiting row exactly as its Send now
+ action does, skipping rows that are saving or already promoted; with a draft
+ present it steers the draft and leaves the queue untouched.
- **Specs linked**: `03-runtime/01-ipc-protocol.md` (§5.6),
`04-ux/08-component-spec.md` (§11),
`04-ux/09-interaction-patterns.md` (§3.4), ADR 0118, ADR 0213, ADR 0265
@@ -2533,7 +2541,8 @@ identify the platform validation still needed.
- **Status**: Source-level regression and deterministic desktop finalization /
Agent Host integration covered (`queued-turn-finalization.test.mjs`);
promotion, reorder, and edit contracts covered at source level
- (`composer-send-state.test.mjs`); full UI scenario Draft
+ (`composer-send-state.test.mjs`); the empty-composer send-now shortcut is
+ covered by `composer-queued-send-now-shortcut.test.mjs`; full UI scenario Draft
#### E2E-QUEUE-promote-orders-delivery-by-click: Two Send now clicks deliver in click order