Skip to content

Commit 8771f41

Browse files
armanossilokoclaude
andcommitted
fix(web): the send-queued-message shortcut skips a message being edited
The shortcut sent the first queued message even while it was open in the composer, bypassing the edit hold with its original text. It now waits like that message's Send now button, which is hidden while editing. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 7ba6cf0 commit 8771f41

2 files changed

Lines changed: 26 additions & 3 deletions

File tree

‎apps/web/src/components/chat/QueuedRunsControl.browser.test.tsx‎

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { EnvironmentId, MessageId, ThreadId } from "@t3tools/contracts";
22
import { serializeAssistantCitation } from "@t3tools/shared/assistantCitations";
33
import * as DateTime from "effect/DateTime";
4-
import type { ComponentProps } from "react";
4+
import { createRef, type ComponentProps } from "react";
55
import { expect, it, vi } from "vite-plus/test";
66
import { page } from "vite-plus/test/browser";
77

@@ -42,7 +42,7 @@ vi.mock(import("../../assets/assetUrls"), async (importOriginal) => ({
4242

4343
import "~/index.css";
4444
import { render as renderUi } from "../../../test/render";
45-
import { QueuedRunsControl } from "./QueuedRunsControl";
45+
import { QueuedRunsControl, type QueuedRunsControlHandle } from "./QueuedRunsControl";
4646

4747
function setup() {
4848
state.projection = null;
@@ -203,3 +203,25 @@ it("stays inside the timeline scroller instead of growing the chat column", asyn
203203
const column = screen.getByTestId("column").element();
204204
expect(column.scrollHeight).toBe(column.clientHeight);
205205
});
206+
207+
it("does not send a queued message from the shortcut while it is open in the composer", async () => {
208+
setup();
209+
state.projection = { projection: { messages: [] } };
210+
state.workflow = {
211+
activeRun: { id: "run:active" },
212+
canPromoteToSteer: true,
213+
queuedRuns: [
214+
{
215+
run: { id: "run:edited", userMessageId: "message:edited" },
216+
text: "Edited",
217+
attachments: [],
218+
},
219+
],
220+
};
221+
const ref = createRef<QueuedRunsControlHandle>();
222+
await using screen = await renderQueue({ ref, editingRunId: "run:edited" as never });
223+
expect(ref.current?.steerNext(true)).toBe(false);
224+
225+
await screen.rerender(<QueuedRunsControl {...baseProps} ref={ref} />);
226+
expect(ref.current?.steerNext(true)).toBe(true);
227+
});

‎apps/web/src/components/chat/QueuedRunsControl.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,8 @@ export function QueuedRunsControl({
185185
useImperativeHandle(ref, () => ({
186186
steerNext(repeat) {
187187
const next = queued[0];
188-
if (!next || !canSend) return false;
188+
// Like its Send now button, a message open in the composer waits for Save or Cancel.
189+
if (!next || !canSend || next.run.id === props.editingRunId) return false;
189190
if (!repeat && busyRunId === null) void sendQueuedMessage(next.run.id);
190191
return true;
191192
},

0 commit comments

Comments
 (0)