fix(ui): clear consumed slash-steer queue chips (#180024)

This commit is contained in:
Dallin Romney 2026-10-21 16:49:29 -07:00 • committed by GitHub
parent aff376aa64
commit 6ae895d356
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 124 additions and 78 deletions

View file

@ -648,6 +648,7 @@ Run-error banners offer **Refresh** to reload the conversation without resending
- Exact-run Stop cancels that parent's associated sub-agents and Swarm collectors, including their descendants. Successful cancellation prevents selected queued children from starting while running siblings stop; it leaves unrelated parent turns and session-wide queues alone.
- If Stop reports incomplete descendant cancellation, inspect the remaining native subagent runs with `/subagents list` and ask the agent to retry their cancellation with `subagents`. Do not treat the parent's stopped state as confirmation that every child stopped or that runtime cleanup was instantaneous. See [Sub-agent stopping](/tools/subagents#stopping) for scope details.
- While a run is active, normal follow-ups use the Gateway's effective `messages.queue` mode. `steer` injects into the running turn; other modes keep the browser's durable queued delivery. If the Gateway queues an input instead of steering it, the message appears above the composer until consumed or canceled. Reconnecting also recovers queued inputs from older history pages without changing the page you are viewing. Once the Gateway accepts input for an existing session, its database owns the approved input until it reaches the transcript. Collected messages are retired together with their combined transcript entry. Unconsumed input survives a Gateway restart as interrupted input requiring an explicit resend. Click **Steer** on a browser-owned queued message to inject it manually; removing a server-owned queued message requests its cancellation. A message you steer moves once from the queue to the bottom of the transcript when delivery starts. It stays there while acknowledgment and history catch up, until its saved copy replaces it. Accepted messages keep their saved transcript positions: earlier saved output stays above the steer and later output appears below it. This order survives history refreshes, reconnects, and reloading a finished run. Unsaved assistant text remains a single live tail after saved rows until its own transcript entries arrive.
- Type `/steer <message>` to steer explicitly. Once consumed, the message belongs in the transcript, with no separate command chip waiting for the entire run to finish. If the Gateway defers the input, its queued message remains above the composer until consumed or canceled.
- With **Settings → Appearance → Send shortcut** set to **Enter**, **Cmd/Ctrl+Enter** submits the opposite follow-up action while connected to an active run: queue when Enter steers, or steer when Enter queues (including inherited `collect` and `followup` modes). The send button tooltip shows both actions for the current follow-up setting. This affects only that message, not your saved preference. With the **Cmd/Ctrl+Enter** send shortcut selected, modified Enter remains the normal send action and plain Enter inserts a newline. Interrupt mode keeps its normal behavior.
- Reorder the queue from the handle on the left of a queued message: drag it, or focus it and press the up and down arrow keys. The position is stored with the message, so it survives a reload and decides delivery order, not just what the list looks like. Rows already handed to a run — sending, steering, running a command, awaiting settings, or waiting on an uncertain delivery — hold their place and split the queue: a message moves only among the rows between two of them, so it can never reach the Gateway ahead of work already handed over.
- Edit a queued message with the pencil on its row, or by double-clicking the row. The row becomes its own textarea and stays in place while the main composer remains independent, including any separate draft and attachments. Submit replaces the row in the same slot and preserves its attachments and delivery choice, even when the composer currently defaults to Steer or Interrupt; Cancel or Escape discards the row-local draft and restores the queued message. A normal composer send remains a separate queued item even while a row edit is open. The queue behind an edited row waits rather than delivering a message you are still rewriting, so that row splits the queue for reordering the same way an in-flight row does. Queued slash commands keep the discard-and-retype flow.

View file

@ -1,8 +1,10 @@
import fs from "node:fs/promises";
import path from "node:path";
import type { Page } from "playwright";
import { expect, it } from "vitest";
import { createControlUiE2eArtifactDir } from "../test-helpers/control-ui-e2e-artifacts.ts";
import { waitForControlUiGatewayReconnecting } from "../test-helpers/control-ui-e2e-readiness.ts";
import { takeControlUiScreenshotFrame } from "../test-helpers/control-ui-e2e-screenshot.ts";
import {
persistedText,
timedText,
@ -109,6 +111,74 @@ async function restoredSteer(name: string, age: number, offset: number, seq: num
}
suite.define(() => {
it("removes the typed /steer queue chip after consumption while the original run stays active", async () => {
const { page } = await newChatPage(suite);
const runId = "active-run";
const sessionKey = "agent:main:main";
const sessionInfo = { key: sessionKey, activeRunIds: [runId], hasActiveRun: true };
const gateway = await installMockGateway(page, {
historyMessages: [
persistedText("user", "Check how the metrics file is populated.", {
id: "original-user",
idempotencyKey: `${runId}:user`,
seq: 1,
}),
],
inFlightRun: { runId, text: "Checking the metrics pipeline." },
sessionInfo,
});
await page.goto(`${suite.server.baseUrl}chat`);
const stop = page.getByRole("button", { name: "Stop generating" });
await stop.waitFor();
const steerText = "Keep the numbers in metrics.json, not USER.md.";
await gateway.deferNext("chat.send");
await chatComposer(page).fill(`/steer ${steerText}`);
await chatComposer(page).press("Control+Enter");
const sent = await gateway.waitForRequest("chat.send");
const params = requireRecord(sent.params);
expect(params).toMatchObject({ sessionKey, message: steerText, queueMode: "steer" });
const steerRunId = requireString(params.idempotencyKey, "steer input identity");
await gateway.resolveDeferred("chat.send", { runId: steerRunId, status: "started" });
const steerMessage = persistedText("user", steerText, {
id: "consumed-steer",
idempotencyKey: `${steerRunId}:user`,
seq: 2,
steerTargetRunId: runId,
});
await gateway.emitGatewayEvent("session.message", {
...sessionInfo,
sessionKey,
clientRunId: steerRunId,
message: steerMessage,
messageId: "consumed-steer",
messageSeq: 2,
});
const reply = "Understood. I will verify metrics.json and leave USER.md unchanged.";
await gateway.emitGatewayEvent(
"chat",
chatEvent(runId, sessionKey, "delta", {
message: textMessage("assistant", reply),
}),
);
const userBubble = page.locator(".chat-group.user", { hasText: steerText });
const replyBubble = chatTranscript(page).getByText(reply, { exact: true });
await expectCount(userBubble, 1);
await replyBubble.waitFor();
await stop.waitFor();
const parent = process.env.OPENCLAW_UI_E2E_ARTIFACT_DIR?.trim();
if (parent) {
const dir = createControlUiE2eArtifactDir("consumed-slash-steer", parent);
const frame = await takeControlUiScreenshotFrame(
page,
chatTranscript(page),
[userBubble, replyBubble, stop],
{ animations: "disabled" },
);
await fs.writeFile(path.join(dir, "consumed-steer.png"), frame.png);
}
await expectCount(page.locator(".chat-queue__item"), 0);
});
it("preserves a non-steer server default for active-run follow-ups", async () => {
const { page } = await newChatPage(suite);
const runtimeConfig = {

View file

@ -601,33 +601,30 @@ describe("executeSlashCommand directives", () => {
describe("executeSlashCommand /steer (soft inject)", () => {
it.each([
[{ status: "started", runId: "run-1" }, true, "succeeded"],
[{ status: "ok", runId: "run-ok", messageSeq: 2 }, undefined, "succeeded"],
[{ status: "timeout", runId: "run-timeout", summary: "aborted" }, undefined, "timeout"],
[{ status: "error", runId: "run-error", summary: "aborted" }, undefined, "failed"],
] as const)(
"sends the selected session and settles a %j steer ACK",
async (ack, pending, key) => {
const request = mockRequests({ "chat.send": () => ack });
const result = await runCommand(request, "steer", "try a different approach");
expect(result.content).toBe(resultText(`steer.${key}`));
expect(result.pendingCurrentRun).toBe(pending);
if (key !== "succeeded") {
expect(result.content).not.toBe(resultText("steer.succeeded"));
}
const { payload } = requireRequestCall(request, "chat.send");
expect(payload).toMatchObject({
sessionKey: "agent:main:main",
message: "try a different approach",
deliver: false,
queueMode: "steer",
idempotencyKey: expect.any(String),
});
expect(payload).not.toHaveProperty("expectedRunId");
expect(payload).not.toHaveProperty("expectedLeafEntryId");
expectNoRequestCall(request, "sessions.list");
},
);
[{ status: "started", runId: "run-1" }, "succeeded"],
[{ status: "ok", runId: "run-ok", messageSeq: 2 }, "succeeded"],
[{ status: "timeout", runId: "run-timeout", summary: "aborted" }, "timeout"],
[{ status: "error", runId: "run-error", summary: "aborted" }, "failed"],
] as const)("sends the selected session and settles a %j steer ACK", async (ack, key) => {
const request = mockRequests({ "chat.send": () => ack });
const result = await runCommand(request, "steer", "try a different approach");
expect(result.content).toBe(resultText(`steer.${key}`));
expect(result.failed ?? false).toBe(key !== "succeeded");
if (key !== "succeeded") {
expect(result.content).not.toBe(resultText("steer.succeeded"));
}
const { payload } = requireRequestCall(request, "chat.send");
expect(payload).toMatchObject({
sessionKey: "agent:main:main",
message: "try a different approach",
deliver: false,
queueMode: "steer",
idempotencyKey: expect.any(String),
});
expect(payload).not.toHaveProperty("expectedRunId");
expect(payload).not.toHaveProperty("expectedLeafEntryId");
expectNoRequestCall(request, "sessions.list");
});
it("returns steer usage when no message is provided", async () => {
const request = vi.fn();

View file

@ -58,8 +58,6 @@ type SlashCommandResult = {
action?: "refresh";
/** When set, the caller should track this as the active run (enables Abort, blocks concurrent sends). */
trackRunId?: string;
/** When set, the caller should surface a visible pending item tied to the current run. */
pendingCurrentRun?: boolean;
/** The command did not complete and a durable queued invocation may be retried. */
failed?: boolean;
};
@ -617,12 +615,8 @@ async function executeRunCommand(
};
}
const result: SlashCommandResult = { content: t(`chat.commandResults.${command}.succeeded`) };
if (ackStatus === "started" || ackStatus === "in_flight") {
if (command === "steer") {
result.pendingCurrentRun = true;
} else {
result.trackRunId = typeof response?.runId === "string" ? response.runId : undefined;
}
if (command === "redirect" && (ackStatus === "started" || ackStatus === "in_flight")) {
result.trackRunId = typeof response?.runId === "string" ? response.runId : undefined;
}
return result;
} catch (err) {

View file

@ -11,7 +11,6 @@ import {
replaceSlashCommands,
type SlashCommandDef,
} from "../../lib/chat/commands.ts";
import { resolveCurrentUserIdentity } from "../../lib/chat/current-user-identity.ts";
import { formatUiError } from "../../lib/format-error.ts";
import { readSessionMethodAccess } from "../../lib/session-method-access.ts";
import {
@ -32,7 +31,6 @@ import type { executeSlashCommand } from "./chat-command-executor.ts";
import { clearChatHistory } from "./chat-history-actions.ts";
import { setChatError } from "./chat-history-state.ts";
import { chatOutboxOwner } from "./chat-outbox-owner.ts";
import { enqueuePendingRunMessage } from "./chat-queue.ts";
import { readChatSessionActionAccess } from "./chat-session-action-access.ts";
import type { ChatExportResult } from "./export.ts";
import { publishChatSessionProjectionMessages } from "./history-merge.ts";
@ -422,15 +420,6 @@ export async function dispatchChatSlashCommand(
host.chatSending = false;
}
if (result.pendingCurrentRun && host.chatRunId && targetIsCurrent()) {
enqueuePendingRunMessage(
host,
`/${name} ${args}`.trim(),
host.chatRunId,
resolveCurrentUserIdentity(host.hello, host.client?.instanceId, host.selfUser) ?? undefined,
);
}
if (result.action === "refresh" && targetIsCurrent()) {
await host.refreshCurrentChat?.();
}

View file

@ -85,28 +85,6 @@ export function enqueueChatMessage(
return keepVolatileQueuedMessage(host, host.sessionKey, item, item.agentId);
}
export function enqueuePendingRunMessage(
host: ChatQueueScopedSessionHost,
text: string,
pendingRunId: string,
sender?: SenderIdentity,
) {
const trimmed = text.trim();
if (!trimmed) {
return;
}
// Local commands join an existing run without a wire chat.send, so this
// pending row intentionally has no fake send identity.
const item: ChatQueueItem = {
id: generateUUID(),
text: trimmed,
createdAt: Date.now(),
pendingRunId,
...(sender ? { sender } : {}),
};
keepVolatileQueuedMessage(host, host.sessionKey, item);
}
export function readChatQueueForScope(
host: ChatQueueScopedSessionHost,
sessionKey: string,

View file

@ -13,7 +13,7 @@ import type { ChatHistoryResult } from "./chat-history-snapshot.ts";
import { loadChatHistory } from "./chat-history.ts";
import { findChatSendPayload, makeChatHost, makeRequestMock } from "./chat-host.test-support.ts";
import { chatOutboxOwner } from "./chat-outbox-owner.ts";
import { enqueueChatMessage, enqueuePendingRunMessage } from "./chat-queue.ts";
import { enqueueChatMessage, keepVolatileQueuedMessage } from "./chat-queue.ts";
import {
resumeStoredChatOutboxes,
retryQueuedChatMessage,
@ -121,7 +121,13 @@ it.each(
if (reconcileChatRunAfterSessionStatePublication(host) && reentrantSuccessor) {
successorStarted = true;
adoptStartedChatRun(host, "reentrant-run", 3);
enqueuePendingRunMessage(host, "Command joined to the successor", "reentrant-run");
keepVolatileQueuedMessage(host, host.sessionKey, {
id: "successor-input",
text: "Input awaiting the successor",
createdAt: 3,
sendRunId: "reentrant-run",
pendingRunId: "reentrant-run",
});
}
});
let draining: ReturnType<typeof resumeStoredChatOutboxes> | undefined;
@ -134,7 +140,13 @@ it.each(
try {
await sessions.refresh({ agentId: "main", force: true });
await handleSendChat(host, undefined, { followUpMode: "queue" });
enqueuePendingRunMessage(host, "Command joined to the current run", "finished-run");
keepVolatileQueuedMessage(host, host.sessionKey, {
id: "current-input",
text: "Input awaiting the current run",
createdAt: 1,
sendRunId: "finished-run",
pendingRunId: "finished-run",
});
expect(host.chatQueue).toHaveLength(2);
const capturedOutboxes = listStoredChatOutboxes(host);
const queuedIds = host.chatQueue.map((item) => item.id);
@ -228,7 +240,7 @@ it.each(
expect(host.chatQueue).toHaveLength(2);
expect(host.chatQueue).toContainEqual(
expect.objectContaining({
text: "Command joined to the current run",
text: "Input awaiting the current run",
pendingRunId: "finished-run",
}),
);
@ -312,7 +324,13 @@ it.each(["new run", "new session", "different terminal", "still active"])(
await handleSendChat(host, undefined, { followUpMode: "queue" });
expect(host.request.mock.calls.some(([method]) => method === "chat.send")).toBe(false);
expect(host.chatQueue).toHaveLength(1);
enqueuePendingRunMessage(host, "Command joined to the previous run", "finished-run");
keepVolatileQueuedMessage(host, host.sessionKey, {
id: "previous-input",
text: "Input awaiting the previous run",
createdAt: 1,
sendRunId: "finished-run",
pendingRunId: "finished-run",
});
const draining = resumeStoredChatOutboxes(host);
await vi.waitFor(() =>

View file

@ -3964,11 +3964,11 @@ describe("handleSendChat", () => {
expect(afterCommit).not.toHaveBeenCalled();
});
it("shows a visible pending item for /steer on the active run", async () => {
it("does not add a run-lifetime queue item for an accepted /steer", async () => {
const host = makeChatHost({
client: clientWithRequest(
makeRequestMock({
"chat.send": { status: "started", runId: "run-1", messageSeq: 2 },
"chat.send": { status: "started", runId: "steer-input", messageSeq: 2 },
}),
),
chatRunId: "run-1",
@ -3986,9 +3986,8 @@ describe("handleSendChat", () => {
await handleSendChat(host);
expect(host.chatQueue).toHaveLength(1);
expect(host.chatQueue[0]?.text).toBe("/steer tighten the plan");
expect(host.chatQueue[0]?.pendingRunId).toBe("run-1");
expect(host.chatQueue).toHaveLength(0);
expect(host.chatRunId).toBe("run-1");
});
it("sends a queued row through the generic outbox with only its durable steer mode", async () => {