mirror of
https://github.com/bitbaum/openclaw.git
synced 2026-12-03 19:47:23 +01:00
feat(ui): render queued follow-ups as transcript bubbles (#131909)
* feat(ui): render queued follow-ups as transcript bubbles
A follow-up sent during an active run previously appeared only as a
composer-attached queue card until it started; the transcript gave no
immediate acknowledgment and the reply appeared to ignore the send.
Queued messages now render as real user bubbles at the transcript tail,
one bubble per submit in queue order, with the live stream continuing
above them. The bubble keeps one stable identity from submit through
queue reorder, admission, and durable-history handoff, so nothing
remounts or jumps. The existing queue controls (steer now, edit,
reorder, remove, retry) attach beneath the queued bubble; the
composer-attached cards no longer duplicate message content and keep
only local-command cards. Supersedes the ordinary-message placement
half of #127823.
* test(ui): find recovered queued messages in transcript bubbles
CI run 33212031042 exposed three recovery cases still looking for message text inside the old composer queue item. Assert the user bubble and its attached reconnect state while retaining all recovery and exact-send assertions. The old selector fails locally; all eight recovery cases pass with the update. No production, mock, or timeout changes.
* build(ui): refresh startup budget for queued-send bubbles
Replace the conflicting budget adjustment with a fresh production build on
main a79e6517be. Startup JS measures 345371 B; an independent verification
rebuild measures 345335 B. Record the measured 345371 B baseline rather
than either conflicting value.
This lowers main's 348449 B baseline by 3078 B and raises the superseded
branch measurement by 232 B after upstream changes. The feature and
recovery-test patches are unchanged by the mechanical rebase.
Keep the existing 512 B growth allowance and 64 B build variance, yielding
a 345947 B enforcement limit and 576 B measured headroom. The 350 KiB
baseline ceiling and all other performance budgets remain unchanged.
Immediate queued-send acknowledgment and restored offline/error controls
retain their existing synchronous renderer. No unrelated boot splitting,
new lazy-render architecture, or gate-logic change is introduced here.
This commit is contained in:
1 parent
62134f2c00
commit
b0cb107c82
25 files changed
+577
-219
No files matched your search
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"startupJsGzipBytes": 348449,
|
||||
"reason": "Gateway credential re-scoping across login, startup, connection, and final client construction; rebased over the 347255 B main baseline using the exact-head CI-observed 1194 B delta",
|
||||
"startupJsGzipBytes": 345371,
|
||||
"reason": "Queued-send transcript bubbles (#131909), rebuilt on main a79e6517be8: measured 345371 B. Replace the conflicting 348449 B main baseline with this fresh measurement; retain the 512 B growth allowance, 64 B build variance, and 350 KiB ceiling.",
|
||||
"updatedAt": "2026-08-28"
|
||||
}
|
||||
@@ -614,8 +614,9 @@ Chat error banners, including cloud runner failures, keep a compact preview. Ope
|
||||
- Click **Stop**. Runs with an exact local run ID call `chat.abort`; when selected-session state reports active work but the Control UI has no local run ID, it calls `sessions.abort` instead. For non-global sessions, that selected-session path also discards queued follow-ups so they cannot restart work after the stop.
|
||||
- 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. Steering rejection also falls back to that queue. Click **Steer** on a queued message to inject it manually. Text already streamed in an open chat stays before the steering message across history refreshes and reconnects; subsequent updates show only the continuation below it.
|
||||
- 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; 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.
|
||||
- Queued follow-ups appear immediately as user bubbles at the end of the transcript, after the current run’s content. Their queued status and controls stay beside the bubble until delivery starts; the composer does not repeat their content. Queued local commands remain attached to the composer.
|
||||
- Reorder the queue from the handle beneath a queued bubble: 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 from its **More queued message actions** menu, or by double-clicking the bubble. The bubble 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; 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.
|
||||
- **Settings → Appearance → Chat → Follow-ups while the agent is working** can override that server default for the current browser. The page marks an override explicitly and offers **Reset to server default**. `Steer into the active run` sends follow-ups immediately, while `Queue until the run ends` holds them until the run finishes.
|
||||
- Type `/stop` (or standalone abort phrases like `stop`, `stop action`, `stop run`, `stop openclaw`, `please stop`) to abort out-of-band.
|
||||
- `chat.abort` supports `{ sessionKey }` (no `runId`) to abort all active runs for that session. The Control UI uses `sessions.abort` when it has no local run ID.
|
||||
|
||||
@@ -642,7 +642,7 @@ suite.define(() => {
|
||||
await composer.fill(queuedText);
|
||||
await composer.press("Control+Enter");
|
||||
|
||||
const queuedRow = page.locator(".chat-queue__item", { hasText: queuedText });
|
||||
const queuedRow = page.locator(".chat-group.user", { hasText: queuedText });
|
||||
await queuedRow.waitFor({ timeout: 10_000 });
|
||||
await expectRequestCountStable(gateway, "chat.send", 1);
|
||||
} finally {
|
||||
@@ -688,9 +688,16 @@ suite.define(() => {
|
||||
}
|
||||
});
|
||||
|
||||
it("sends a queued follow-up after an exact terminal session publication", async () => {
|
||||
it("keeps two distinct queued bubbles below streaming and admits the first in place", async () => {
|
||||
const artifactDir = process.env.OPENCLAW_UI_E2E_ARTIFACT_DIR?.trim();
|
||||
if (artifactDir) {
|
||||
await mkdir(artifactDir, { recursive: true });
|
||||
}
|
||||
const context = await suite.newBrowserContext({
|
||||
locale: "en-US",
|
||||
...(artifactDir
|
||||
? { recordVideo: { dir: artifactDir, size: { height: 900, width: 1280 } } }
|
||||
: {}),
|
||||
serviceWorkers: "block",
|
||||
viewport: { height: 900, width: 1280 },
|
||||
});
|
||||
@@ -714,12 +721,78 @@ suite.define(() => {
|
||||
const activeSessionKey = requireString(initialSendParams.sessionKey, "active session key");
|
||||
await page.getByRole("button", { name: "Stop generating" }).waitFor({ timeout: 10_000 });
|
||||
|
||||
const transcript = page.locator(".chat-thread-inner");
|
||||
const streamText = "The current response is still streaming.";
|
||||
const emitStream = (text: string) =>
|
||||
gateway.emitGatewayEvent("chat", {
|
||||
message: { role: "assistant", content: [{ type: "text", text }] },
|
||||
runId: activeRunId,
|
||||
sessionKey: activeSessionKey,
|
||||
state: "delta",
|
||||
});
|
||||
const capture = async (name: string) => {
|
||||
if (artifactDir) {
|
||||
await page.screenshot({ fullPage: true, path: path.join(artifactDir, name) });
|
||||
}
|
||||
};
|
||||
await emitStream(streamText);
|
||||
await transcript.getByText(streamText, { exact: true }).waitFor();
|
||||
const followUp = "send after the missed terminal event";
|
||||
const secondFollowUp = "then review the next result";
|
||||
const rowKey = (bubble: Element) =>
|
||||
bubble.closest("[data-virtual-row-key]")?.getAttribute("data-virtual-row-key");
|
||||
const sameBubble = (bubble: Element, original: Element | null) => bubble === original;
|
||||
const firstBubble = transcript
|
||||
.locator(".chat-group.user", { hasText: followUp })
|
||||
.locator(".chat-bubble");
|
||||
await composer.fill(followUp);
|
||||
await page.getByRole("button", { name: "Queue message" }).click();
|
||||
const queuedRow = page.locator(".chat-queue__item", { hasText: followUp });
|
||||
await queuedRow.waitFor({ timeout: 10_000 });
|
||||
await page.getByText(followUp, { exact: true }).waitFor();
|
||||
await capture("queued-00-submitted.png");
|
||||
await firstBubble.waitFor({ timeout: 10_000 });
|
||||
expect(await firstBubble.count()).toBe(1);
|
||||
const firstElement = await firstBubble.elementHandle();
|
||||
expect(firstElement).not.toBeNull();
|
||||
const firstRowKey = await firstBubble.evaluate(rowKey);
|
||||
expect(firstRowKey).toBeTruthy();
|
||||
await capture("queued-01-first-follow-up.png");
|
||||
|
||||
await composer.fill(secondFollowUp);
|
||||
await page.getByRole("button", { name: "Queue message" }).click();
|
||||
const secondGroup = transcript.locator(".chat-group.user", { hasText: secondFollowUp });
|
||||
const secondBubble = secondGroup.locator(".chat-bubble");
|
||||
await secondBubble.waitFor({ timeout: 10_000 });
|
||||
expect(await secondBubble.count()).toBe(1);
|
||||
const secondElement = await secondBubble.elementHandle();
|
||||
expect(secondElement).not.toBeNull();
|
||||
const secondRowKey = await secondBubble.evaluate(rowKey);
|
||||
expect(secondRowKey).toBeTruthy();
|
||||
expect(secondRowKey).not.toBe(firstRowKey);
|
||||
const expectSecondQueuedAtTail = async () => {
|
||||
await secondGroup.getByText("Queued", { exact: true }).waitFor();
|
||||
expect(await transcript.locator(".chat-group.user .chat-queue__item").count()).toBe(1);
|
||||
const tail = transcript.locator(".chat-bubble").last();
|
||||
expect(await tail.evaluate(sameBubble, secondElement)).toBe(true);
|
||||
expect(await secondBubble.evaluate(rowKey)).toBe(secondRowKey);
|
||||
};
|
||||
await emitStream(`${streamText} More text arrives after both follow-ups.`);
|
||||
await expect
|
||||
.poll(() =>
|
||||
transcript
|
||||
.locator(".chat-bubble .chat-text")
|
||||
.evaluateAll((bubbles) => bubbles.map((bubble) => bubble.textContent?.trim() ?? "")),
|
||||
)
|
||||
.toEqual([
|
||||
initialText,
|
||||
`${streamText} More text arrives after both follow-ups.`,
|
||||
followUp,
|
||||
secondFollowUp,
|
||||
]);
|
||||
expect(await firstBubble.evaluate(sameBubble, firstElement)).toBe(true);
|
||||
expect(await page.locator(".chat-queue").count()).toBe(0);
|
||||
expect(await transcript.locator(".chat-group.user .chat-queue__item").count()).toBe(2);
|
||||
await expectRequestCountStable(gateway, "chat.send", 1);
|
||||
await capture("queued-02-stream-above-follow-ups.png");
|
||||
|
||||
await gateway.setHistoryMessages([
|
||||
{
|
||||
@@ -745,6 +818,7 @@ suite.define(() => {
|
||||
await expect
|
||||
.poll(async () => (await gateway.getRequests("sessions.list")).length)
|
||||
.toBeGreaterThan(sessionListsBeforeTerminal);
|
||||
await gateway.deferNext("chat.send");
|
||||
await gateway.resolveDeferred(
|
||||
"sessions.list",
|
||||
chatSessionListResponse([
|
||||
@@ -762,8 +836,50 @@ suite.define(() => {
|
||||
);
|
||||
|
||||
const sends = await waitForRequests(gateway, "chat.send", 2);
|
||||
expect(requireRecord(sends[1]?.params)).toMatchObject({ message: followUp });
|
||||
await queuedRow.waitFor({ state: "detached", timeout: 10_000 });
|
||||
const admitted = requireRecord(sends[1]?.params);
|
||||
expect(admitted).toMatchObject({ message: followUp });
|
||||
const admittedRunId = requireString(admitted.idempotencyKey, "admitted queued run id");
|
||||
expect(await firstBubble.evaluate(sameBubble, firstElement)).toBe(true);
|
||||
expect(await firstBubble.evaluate(rowKey)).toBe(firstRowKey);
|
||||
await gateway.resolveDeferred("chat.send", { runId: admittedRunId, status: "started" });
|
||||
await transcript
|
||||
.locator(".chat-group.user", { hasText: followUp })
|
||||
.locator(".chat-queue__item")
|
||||
.waitFor({ state: "detached" });
|
||||
expect(await firstBubble.evaluate(sameBubble, firstElement)).toBe(true);
|
||||
await expectSecondQueuedAtTail();
|
||||
await capture("queued-03-admitted-in-place.png");
|
||||
|
||||
await gateway.emitGatewayEvent("session.message", {
|
||||
activeRunIds: [admittedRunId],
|
||||
clientRunId: admittedRunId,
|
||||
hasActiveRun: true,
|
||||
message: {
|
||||
__openclaw: {
|
||||
id: "queued-follow-up-user",
|
||||
idempotencyKey: `${admittedRunId}:user`,
|
||||
seq: 2,
|
||||
},
|
||||
role: "user",
|
||||
content: [{ type: "text", text: followUp }],
|
||||
timestamp: Date.now(),
|
||||
},
|
||||
messageId: "queued-follow-up-user",
|
||||
messageSeq: 2,
|
||||
runId: admittedRunId,
|
||||
sessionKey: activeSessionKey,
|
||||
});
|
||||
await expect
|
||||
.poll(() => firstBubble.getAttribute("data-entry-id"))
|
||||
.toBe("queued-follow-up-user");
|
||||
expect(await firstBubble.count()).toBe(1);
|
||||
expect(await firstBubble.evaluate(sameBubble, firstElement)).toBe(true);
|
||||
expect(await firstBubble.evaluate(rowKey)).toBe(firstRowKey);
|
||||
await expectSecondQueuedAtTail();
|
||||
await expectRequestCountStable(gateway, "chat.send", 2);
|
||||
await capture("queued-04-history-handoff.png");
|
||||
await firstElement?.dispose();
|
||||
await secondElement?.dispose();
|
||||
} finally {
|
||||
await suite.closeBrowserContext(context);
|
||||
}
|
||||
@@ -887,7 +1003,9 @@ suite.define(() => {
|
||||
const queuedPrompt = "steer this after restoring the queue";
|
||||
await page.locator(".agent-chat__composer-combobox textarea").fill(queuedPrompt);
|
||||
await page.getByRole("button", { name: "Queue message" }).click();
|
||||
await page.locator(".chat-queue").getByText(queuedPrompt).waitFor({ timeout: 10_000 });
|
||||
await page
|
||||
.locator(".chat-group.user", { hasText: queuedPrompt })
|
||||
.waitFor({ timeout: 10_000 });
|
||||
|
||||
await gateway.setMethodResponse(
|
||||
"sessions.list",
|
||||
@@ -915,7 +1033,7 @@ suite.define(() => {
|
||||
await page.reload();
|
||||
await gateway.waitForRequest("sessions.list");
|
||||
|
||||
const queue = page.locator(".chat-queue");
|
||||
const queue = page.locator(".chat-group.user", { hasText: queuedPrompt });
|
||||
await queue.getByText(queuedPrompt).waitFor({ timeout: 10_000 });
|
||||
await queue.getByRole("button", { name: "Steer" }).click();
|
||||
|
||||
|
||||
@@ -74,7 +74,9 @@ suite.define(() => {
|
||||
await composer.press("Control+Enter");
|
||||
|
||||
if (followUpMode === "steer") {
|
||||
const queuedRow = page.locator(".chat-queue__item", { hasText: followUpText });
|
||||
const queuedRow = page
|
||||
.locator(".chat-group.user", { hasText: followUpText })
|
||||
.locator(".chat-queue__item");
|
||||
await queuedRow.waitFor();
|
||||
await expectRequestCountStable(gateway, "chat.send", 1);
|
||||
await gateway.setMethodResponse("chat.history", {
|
||||
|
||||
@@ -878,7 +878,7 @@ suite.define(() => {
|
||||
expect(sendEnabled).toBe(true);
|
||||
await send.click();
|
||||
|
||||
const queue = page.locator(".chat-queue");
|
||||
const queue = page.locator(".chat-group.user:has(.chat-queue__item)", { hasText: prompt });
|
||||
await queue.getByText("Waiting for reconnect").waitFor({ timeout: 10_000 });
|
||||
await queue.getByText(prompt).waitFor({ timeout: 10_000 });
|
||||
const requestsBeforeReconnect = await gateway.getRequests("chat.send");
|
||||
|
||||
@@ -838,7 +838,10 @@ suite.define(() => {
|
||||
await page.locator(".chat-queue").getByText("Applying chat settings").waitFor({
|
||||
timeout: 10_000,
|
||||
});
|
||||
await page.locator(".chat-queue").getByText(prompt).waitFor({ timeout: 10_000 });
|
||||
await page
|
||||
.locator(".chat-group.user .chat-bubble")
|
||||
.getByText(prompt)
|
||||
.waitFor({ timeout: 10_000 });
|
||||
expect(await gateway.getRequests("chat.send")).toHaveLength(0);
|
||||
|
||||
await gateway.resolveDeferred("sessions.patch", {});
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { mkdir } from "node:fs/promises";
|
||||
import { expect, it } from "vitest";
|
||||
import {
|
||||
createChatFlowE2eSuite,
|
||||
@@ -10,6 +11,8 @@ import {
|
||||
|
||||
const suite = createChatFlowE2eSuite();
|
||||
|
||||
const queuedBubbleSelector = ".chat-group.user:has(.chat-queue__item)";
|
||||
|
||||
const QUEUED = ["review the migration", "then update the docs", "finally run the smoke"] as const;
|
||||
|
||||
suite.define(() => {
|
||||
@@ -33,25 +36,31 @@ suite.define(() => {
|
||||
for (const message of QUEUED) {
|
||||
await composer.fill(message);
|
||||
await composer.press("Enter");
|
||||
await page.locator(".chat-queue__item", { hasText: message }).waitFor({ timeout: 10_000 });
|
||||
await page.locator(queuedBubbleSelector, { hasText: message }).waitFor({ timeout: 10_000 });
|
||||
}
|
||||
const queueText = () =>
|
||||
page.locator(".chat-queue__item").evaluateAll((rows) =>
|
||||
page.locator(queuedBubbleSelector).evaluateAll((rows) =>
|
||||
rows.map((row) => {
|
||||
const editor = row.querySelector(".chat-queue__edit-input");
|
||||
return editor instanceof HTMLTextAreaElement
|
||||
? editor.value
|
||||
: (row.querySelector(".chat-queue__text")?.textContent ?? "");
|
||||
: (row.querySelector(".chat-bubble .chat-text")?.textContent?.trim() ?? "");
|
||||
}),
|
||||
);
|
||||
expect(await queueText()).toEqual([...QUEUED]);
|
||||
|
||||
await composer.fill("a separate composer draft");
|
||||
|
||||
// Double-click is the shortcut; the pencil on the row is the visible path.
|
||||
await page.locator(".chat-queue__item").nth(1).dblclick();
|
||||
const queuedBubbles = page.locator(queuedBubbleSelector);
|
||||
expect(await page.locator(".chat-queue").count()).toBe(0);
|
||||
expect(await queuedBubbles.count()).toBe(3);
|
||||
await queuedBubbles.nth(1).locator(".chat-queue__more").click();
|
||||
await queuedBubbles.nth(1).locator('wa-dropdown-item[value="edit"]').click();
|
||||
|
||||
const rowEditor = page.locator(".chat-queue__item").nth(1).locator(".chat-queue__edit-input");
|
||||
const rowEditor = page
|
||||
.locator(queuedBubbleSelector)
|
||||
.nth(1)
|
||||
.locator(".chat-queue__edit-input");
|
||||
await rowEditor.waitFor({ timeout: 10_000 });
|
||||
await rowEditor.press("ControlOrMeta+A");
|
||||
expect(await rowEditor.inputValue()).toBe(QUEUED[1]);
|
||||
@@ -90,12 +99,12 @@ suite.define(() => {
|
||||
for (const message of QUEUED) {
|
||||
await composer.fill(message);
|
||||
await composer.press("Enter");
|
||||
await page.locator(".chat-queue__item", { hasText: message }).waitFor({ timeout: 10_000 });
|
||||
await page.locator(queuedBubbleSelector, { hasText: message }).waitFor({ timeout: 10_000 });
|
||||
}
|
||||
|
||||
await composer.fill("a separate composer draft");
|
||||
const row = page.locator(".chat-queue__item").nth(1);
|
||||
await row.dblclick();
|
||||
const row = page.locator(queuedBubbleSelector).nth(1);
|
||||
await row.locator(".chat-bubble").dblclick();
|
||||
const rowEditor = row.locator(".chat-queue__edit-input");
|
||||
await rowEditor.waitFor({ timeout: 10_000 });
|
||||
await rowEditor.fill("a replacement the operator abandons");
|
||||
@@ -103,9 +112,15 @@ suite.define(() => {
|
||||
await rowEditor.press("Escape");
|
||||
|
||||
await expect
|
||||
.poll(() => page.locator(".chat-queue__item .chat-queue__text").allTextContents(), {
|
||||
timeout: 10_000,
|
||||
})
|
||||
.poll(
|
||||
() =>
|
||||
page
|
||||
.locator(`${queuedBubbleSelector} .chat-bubble .chat-text`)
|
||||
.evaluateAll((bubbles) => bubbles.map((bubble) => bubble.textContent?.trim() ?? "")),
|
||||
{
|
||||
timeout: 10_000,
|
||||
},
|
||||
)
|
||||
.toEqual([...QUEUED]);
|
||||
expect(await composer.inputValue()).toBe("a separate composer draft");
|
||||
} finally {
|
||||
@@ -131,28 +146,34 @@ suite.define(() => {
|
||||
for (const message of QUEUED) {
|
||||
await composer.fill(message);
|
||||
await composer.press("Enter");
|
||||
await page.locator(".chat-queue__item", { hasText: message }).waitFor({ timeout: 10_000 });
|
||||
await page.locator(queuedBubbleSelector, { hasText: message }).waitFor({ timeout: 10_000 });
|
||||
}
|
||||
|
||||
const row = page.locator(".chat-queue__item").nth(1);
|
||||
await row.dblclick();
|
||||
const row = page.locator(queuedBubbleSelector).nth(1);
|
||||
await row.locator(".chat-bubble").dblclick();
|
||||
const rowEditor = row.locator(".chat-queue__edit-input");
|
||||
await rowEditor.waitFor({ timeout: 10_000 });
|
||||
await composer.fill("a separate composer send");
|
||||
await composer.press("Enter");
|
||||
|
||||
await page
|
||||
.locator(".chat-queue__item", { hasText: "a separate composer send" })
|
||||
.locator(queuedBubbleSelector, { hasText: "a separate composer send" })
|
||||
.waitFor({ timeout: 10_000 });
|
||||
await expect.poll(() => rowEditor.inputValue(), { timeout: 10_000 }).toBe(QUEUED[1]);
|
||||
expect(await composer.inputValue()).toBe("");
|
||||
expect(await page.locator(".chat-queue__item").count()).toBe(4);
|
||||
expect(await page.locator(queuedBubbleSelector).count()).toBe(4);
|
||||
|
||||
await rowEditor.press("Escape");
|
||||
await expect
|
||||
.poll(() => page.locator(".chat-queue__item .chat-queue__text").allTextContents(), {
|
||||
timeout: 10_000,
|
||||
})
|
||||
.poll(
|
||||
() =>
|
||||
page
|
||||
.locator(`${queuedBubbleSelector} .chat-bubble .chat-text`)
|
||||
.evaluateAll((bubbles) => bubbles.map((bubble) => bubble.textContent?.trim() ?? "")),
|
||||
{
|
||||
timeout: 10_000,
|
||||
},
|
||||
)
|
||||
.toEqual([...QUEUED, "a separate composer send"]);
|
||||
} finally {
|
||||
await suite.closeBrowserContext(context);
|
||||
@@ -161,6 +182,9 @@ suite.define(() => {
|
||||
|
||||
it("keeps edit, remove, and reorder outcomes exact through reconnect", async () => {
|
||||
const artifactDir = process.env.OPENCLAW_UI_E2E_ARTIFACT_DIR?.trim();
|
||||
if (artifactDir) {
|
||||
await mkdir(artifactDir, { recursive: true });
|
||||
}
|
||||
const context = await suite.newBrowserContext({
|
||||
locale: "en-US",
|
||||
...(artifactDir
|
||||
@@ -196,7 +220,13 @@ suite.define(() => {
|
||||
for (const message of ["send first", "edit before send", "remove me", "send last"]) {
|
||||
await composer.fill(message);
|
||||
await page.getByRole("button", { name: "Queue message" }).click();
|
||||
await page.locator(".chat-queue__item", { hasText: message }).waitFor({ timeout: 10_000 });
|
||||
await page.locator(queuedBubbleSelector, { hasText: message }).waitFor({ timeout: 10_000 });
|
||||
}
|
||||
expect(await page.locator(".chat-queue").count()).toBe(0);
|
||||
expect(await page.locator(queuedBubbleSelector).count()).toBe(4);
|
||||
await composer.fill("keep this composer draft while editing and reordering");
|
||||
if (artifactDir) {
|
||||
await page.screenshot({ path: `${artifactDir}/queue-controls-before.png`, fullPage: true });
|
||||
}
|
||||
await gateway.setOnline(false);
|
||||
await gateway.closeLatest();
|
||||
@@ -206,18 +236,17 @@ suite.define(() => {
|
||||
)
|
||||
.waitFor({ timeout: 10_000 });
|
||||
|
||||
const editRow = page.locator(".chat-queue__item", { hasText: "edit before send" });
|
||||
await editRow.dblclick();
|
||||
// `hasText` stops matching once the row text becomes a textarea value.
|
||||
const editRow = page.locator(queuedBubbleSelector, { hasText: "edit before send" });
|
||||
await editRow.locator(".chat-bubble").dblclick();
|
||||
const inlineEditor = page.locator(".chat-queue__edit-input");
|
||||
await inlineEditor.waitFor({ timeout: 10_000 });
|
||||
await inlineEditor.press("ControlOrMeta+A");
|
||||
await page.keyboard.insertText("edited before send");
|
||||
await inlineEditor.press("Control+Enter");
|
||||
await page.locator(".chat-queue__item", { hasText: "edited before send" }).waitFor();
|
||||
await page.locator(queuedBubbleSelector, { hasText: "edited before send" }).waitFor();
|
||||
|
||||
const lastGrip = page
|
||||
.locator(".chat-queue__item", { hasText: "send last" })
|
||||
.locator(queuedBubbleSelector, { hasText: "send last" })
|
||||
.locator(".chat-queue__grip");
|
||||
await lastGrip.focus();
|
||||
for (const expected of [
|
||||
@@ -227,11 +256,24 @@ suite.define(() => {
|
||||
]) {
|
||||
await page.keyboard.press("ArrowUp");
|
||||
await expect
|
||||
.poll(() => page.locator(".chat-queue__item .chat-queue__text").allTextContents())
|
||||
.poll(() =>
|
||||
page
|
||||
.locator(`${queuedBubbleSelector} .chat-bubble .chat-text`)
|
||||
.evaluateAll((bubbles) => bubbles.map((bubble) => bubble.textContent?.trim() ?? "")),
|
||||
)
|
||||
.toEqual(expected);
|
||||
}
|
||||
|
||||
const row = page.locator(".chat-queue__item", {
|
||||
expect(await composer.inputValue()).toBe(
|
||||
"keep this composer draft while editing and reordering",
|
||||
);
|
||||
if (artifactDir) {
|
||||
await page.screenshot({
|
||||
path: `${artifactDir}/queue-controls-reordered.png`,
|
||||
fullPage: true,
|
||||
});
|
||||
}
|
||||
const row = page.locator(queuedBubbleSelector, {
|
||||
hasText: "remove me",
|
||||
});
|
||||
|
||||
@@ -287,8 +329,10 @@ suite.define(() => {
|
||||
const target = event.target instanceof Element ? event.target : null;
|
||||
trace.push({
|
||||
detail: (event as MouseEvent).detail,
|
||||
rowText: target?.closest(".chat-queue__item")?.querySelector(".chat-queue__text")
|
||||
?.textContent,
|
||||
rowText: target
|
||||
?.closest(".chat-group.user")
|
||||
?.querySelector(".chat-bubble .chat-text")
|
||||
?.textContent?.trim(),
|
||||
});
|
||||
},
|
||||
{ capture: true },
|
||||
@@ -311,14 +355,18 @@ suite.define(() => {
|
||||
await row.waitFor({ state: "detached", timeout: 10_000 });
|
||||
await page.getByRole("alert").waitFor({ state: "detached", timeout: 10_000 });
|
||||
await expect
|
||||
.poll(() => page.locator(".chat-queue__item .chat-queue__text").allTextContents())
|
||||
.poll(() =>
|
||||
page
|
||||
.locator(`${queuedBubbleSelector} .chat-bubble .chat-text`)
|
||||
.evaluateAll((bubbles) => bubbles.map((bubble) => bubble.textContent?.trim() ?? "")),
|
||||
)
|
||||
.toEqual(["send last", "send first", "edited before send"]);
|
||||
expect(await gateway.getRequests("chat.send")).toHaveLength(1);
|
||||
|
||||
const queueDisposable = async (text: string) => {
|
||||
await composer.fill(text);
|
||||
await composer.press("Enter");
|
||||
const disposable = page.locator(".chat-queue__item", { hasText: text });
|
||||
const disposable = page.locator(queuedBubbleSelector, { hasText: text });
|
||||
await disposable.waitFor({ timeout: 10_000 });
|
||||
return disposable;
|
||||
};
|
||||
@@ -382,7 +430,7 @@ suite.define(() => {
|
||||
]);
|
||||
expect(new Set(params.map((entry) => entry.idempotencyKey)).size).toBe(4);
|
||||
await expectRequestCountStable(gateway, "chat.send", 4);
|
||||
await page.locator(".chat-queue").waitFor({ state: "detached", timeout: 10_000 });
|
||||
await page.locator(queuedBubbleSelector).waitFor({ state: "detached", timeout: 10_000 });
|
||||
if (artifactDir) {
|
||||
await page.screenshot({ path: `${artifactDir}/03-exact-drain.png`, fullPage: true });
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ import {
|
||||
|
||||
const suite = createChatFlowE2eSuite();
|
||||
|
||||
const queuedBubbleSelector = ".chat-group.user:has(.chat-queue__item)";
|
||||
|
||||
const QUEUED = ["review the migration", "then update the docs", "finally run the smoke"] as const;
|
||||
const failureReloadProofDir = path.join(
|
||||
process.cwd(),
|
||||
@@ -39,10 +41,13 @@ suite.define(() => {
|
||||
for (const message of QUEUED) {
|
||||
await composer.fill(message);
|
||||
await composer.press("Enter");
|
||||
await page.locator(".chat-queue__item", { hasText: message }).waitFor({ timeout: 10_000 });
|
||||
await page.locator(queuedBubbleSelector, { hasText: message }).waitFor({ timeout: 10_000 });
|
||||
}
|
||||
|
||||
const queueText = () => page.locator(".chat-queue__item .chat-queue__text").allTextContents();
|
||||
const queueText = () =>
|
||||
page
|
||||
.locator(`${queuedBubbleSelector} .chat-bubble .chat-text`)
|
||||
.evaluateAll((bubbles) => bubbles.map((bubble) => bubble.textContent?.trim() ?? ""));
|
||||
expect(await queueText()).toEqual([...QUEUED]);
|
||||
|
||||
// One handle per movable row, and it is the whole reorder surface.
|
||||
@@ -85,10 +90,13 @@ suite.define(() => {
|
||||
for (const message of QUEUED) {
|
||||
await composer.fill(message);
|
||||
await composer.press("Enter");
|
||||
await page.locator(".chat-queue__item", { hasText: message }).waitFor({ timeout: 10_000 });
|
||||
await page.locator(queuedBubbleSelector, { hasText: message }).waitFor({ timeout: 10_000 });
|
||||
}
|
||||
|
||||
const queueText = () => page.locator(".chat-queue__item .chat-queue__text").allTextContents();
|
||||
const queueText = () =>
|
||||
page
|
||||
.locator(`${queuedBubbleSelector} .chat-bubble .chat-text`)
|
||||
.evaluateAll((bubbles) => bubbles.map((bubble) => bubble.textContent?.trim() ?? ""));
|
||||
expect(await queueText()).toEqual([...QUEUED]);
|
||||
if (captureUiProofEnabled) {
|
||||
await page.screenshot({ path: `${failureReloadProofDir}/01-queued-before-failure.png` });
|
||||
@@ -156,7 +164,7 @@ suite.define(() => {
|
||||
// order can be confirmed rendered, not just stored.
|
||||
await gateway.setOnline(true);
|
||||
await page.locator("openclaw-chat-pane").waitFor({ state: "attached", timeout: 15_000 });
|
||||
await page.locator(".chat-queue__item", { hasText: QUEUED[0] }).waitFor({ timeout: 10_000 });
|
||||
await page.locator(queuedBubbleSelector, { hasText: QUEUED[0] }).waitFor({ timeout: 10_000 });
|
||||
expect(await queueText()).toEqual([...QUEUED]);
|
||||
if (captureUiProofEnabled) {
|
||||
await page.screenshot({
|
||||
|
||||
@@ -100,7 +100,7 @@ suite.define(() => {
|
||||
const prompt = "deliver the work outbox independently";
|
||||
await composer.fill(prompt);
|
||||
await page.getByRole("button", { name: "Send message" }).click();
|
||||
const queue = page.locator(".chat-queue");
|
||||
const queue = page.locator(".chat-group.user:has(.chat-queue__item)", { hasText: prompt });
|
||||
await queue.getByText("Waiting for reconnect").waitFor({ timeout: 10_000 });
|
||||
if (artifactDir) {
|
||||
await page.screenshot({
|
||||
|
||||
@@ -336,7 +336,12 @@ suite.define(() => {
|
||||
.toBe(false);
|
||||
await composer.fill("queued while offline");
|
||||
await composer.press("Enter");
|
||||
await page.locator(".chat-queue__item", { hasText: "queued while offline" }).waitFor();
|
||||
const queuedGroup = page.locator(".chat-group.user", { hasText: "queued while offline" });
|
||||
await queuedGroup.locator(".chat-bubble").waitFor();
|
||||
await queuedGroup
|
||||
.locator(".chat-queue__item")
|
||||
.getByText("Waiting for reconnect", { exact: true })
|
||||
.waitFor();
|
||||
expect(await composer.inputValue()).toBe("");
|
||||
if (recoveryKind !== "none") {
|
||||
// Accepted retirement can fail to remove its sending row after the map owner
|
||||
|
||||
@@ -5801,6 +5801,7 @@ export const en: TranslationMap = {
|
||||
moreActions: "More queued message actions",
|
||||
cancelEdit: "Cancel editing and keep the queued message",
|
||||
states: {
|
||||
queued: "Queued",
|
||||
applyingSettings: "Applying chat settings",
|
||||
runningCommand: "Running command",
|
||||
waitingForReconnect: "Waiting for reconnect",
|
||||
|
||||
@@ -287,31 +287,6 @@ describe("renderChatComposer controls", () => {
|
||||
expect(onAbort).toHaveBeenCalledOnce();
|
||||
});
|
||||
|
||||
it("offers Steer only for eligible queued messages during an active run", () => {
|
||||
const onQueueSteer = vi.fn();
|
||||
const { container } = renderComposer({
|
||||
canAbort: true,
|
||||
onAbort: vi.fn(),
|
||||
onQueueSteer,
|
||||
queue: [
|
||||
{ id: "queued-1", text: "tighten the plan", createdAt: 1 },
|
||||
{ id: "pending-1", text: "already sent", createdAt: 2, pendingRunId: "run-1" },
|
||||
{ id: "local-1", text: "/status", createdAt: 3, localCommandName: "status" },
|
||||
{
|
||||
id: "waiting-idle-1",
|
||||
text: "queued during the run",
|
||||
createdAt: 4,
|
||||
sendState: "waiting-idle",
|
||||
},
|
||||
],
|
||||
});
|
||||
const steer = [...container.querySelectorAll<HTMLButtonElement>(".chat-queue__action")];
|
||||
expect(steer).toHaveLength(2);
|
||||
steer[0]?.click();
|
||||
steer[1]?.click();
|
||||
expect(onQueueSteer.mock.calls).toEqual([["queued-1"], ["waiting-idle-1"]]);
|
||||
});
|
||||
|
||||
it("steers the oldest visible-queue message when Enter is pressed on empty", () => {
|
||||
const onQueueSteer = vi.fn();
|
||||
const onSend = vi.fn();
|
||||
@@ -641,57 +616,15 @@ describe("renderChatComposer controls", () => {
|
||||
expect(onAbort).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("renders the queued author's avatar before the turn is submitted", async () => {
|
||||
const { container } = renderComposer({
|
||||
queue: [
|
||||
{
|
||||
id: "waiting-idle-1",
|
||||
text: "queued during the run",
|
||||
createdAt: 4,
|
||||
sendState: "waiting-idle",
|
||||
sender: { id: "profile_123", name: "Alice Example" },
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
await vi.waitFor(() => {
|
||||
expect(
|
||||
container.querySelector(".chat-queue__item .chat-author-avatar__initials")?.textContent,
|
||||
).toContain("AE");
|
||||
});
|
||||
});
|
||||
|
||||
it("renders reconnect waits as compact badges without the raw transport error", () => {
|
||||
const { container } = renderComposer({
|
||||
queue: [
|
||||
{
|
||||
id: "reconnect-1",
|
||||
text: "send me once the gateway is back",
|
||||
createdAt: 1,
|
||||
sendError: "chat.send unavailable during gateway restart",
|
||||
sendState: "waiting-reconnect",
|
||||
},
|
||||
],
|
||||
});
|
||||
const item = container.querySelector(".chat-queue__item");
|
||||
expect(item?.classList.contains("chat-queue__item--reconnect")).toBe(true);
|
||||
expect(
|
||||
item?.querySelector('.chat-queue__icon path[d="M21 5v12a2 2 0 0 1-2 2h-6"]'),
|
||||
).not.toBeNull();
|
||||
expect(item?.querySelector(".chat-queue__error")).toBeNull();
|
||||
const state = item?.querySelector(".chat-queue__badge--reconnect");
|
||||
expect(state?.textContent?.trim()).toBe("Waiting for reconnect");
|
||||
expect(state?.getAttribute("title")).toBe("chat.send unavailable during gateway restart");
|
||||
});
|
||||
|
||||
it("renders failed sends as retryable and running commands as inert", () => {
|
||||
it("renders failed local commands as retryable and running commands as inert", () => {
|
||||
const onQueueRetry = vi.fn();
|
||||
let view = renderComposer({
|
||||
onQueueRetry,
|
||||
queue: [
|
||||
{
|
||||
id: "failed-1",
|
||||
text: "still recoverable",
|
||||
localCommandName: "compact",
|
||||
text: "/compact",
|
||||
createdAt: 1,
|
||||
sendError: "send blocked by session policy",
|
||||
sendRunId: "run-failed-1",
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
/* @vitest-environment jsdom */
|
||||
|
||||
import { render } from "lit";
|
||||
import { html, render } from "lit";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { i18n, t } from "../../i18n/index.ts";
|
||||
import { renderChatQueue } from "./components/chat-composer-queue.ts";
|
||||
import { shouldRenderQueuedSendInThread } from "./chat-progress.ts";
|
||||
import { renderChatQueue, renderQueuedSendControls } from "./components/chat-composer-queue.ts";
|
||||
|
||||
afterEach(async () => {
|
||||
document.body.replaceChildren();
|
||||
@@ -13,6 +14,72 @@ afterEach(async () => {
|
||||
});
|
||||
|
||||
describe("chat composer steering queue", () => {
|
||||
it("leaves only local command content at the composer", () => {
|
||||
const container = document.createElement("div");
|
||||
render(
|
||||
renderChatQueue({
|
||||
queue: [
|
||||
{ ...waiting("future prompt", 1), sendRunId: "future-send" },
|
||||
{ ...waiting("/compact", 2), localCommandName: "compact" },
|
||||
],
|
||||
onQueueRemove: vi.fn(),
|
||||
}),
|
||||
container,
|
||||
);
|
||||
expect(container.textContent).not.toContain("future prompt");
|
||||
expect(container.querySelectorAll(".chat-queue__item")).toHaveLength(1);
|
||||
expect(container.querySelector(".chat-queue__text")?.textContent).toBe("/compact");
|
||||
});
|
||||
|
||||
it("offers Steer only for eligible queued messages during an active run", () => {
|
||||
const onQueueSteer = vi.fn();
|
||||
const container = renderQueue({
|
||||
canAbort: true,
|
||||
onQueueSteer,
|
||||
onQueueRemove: vi.fn(),
|
||||
queue: [
|
||||
{ id: "queued-1", text: "tighten the plan", createdAt: 1 },
|
||||
{ id: "pending-1", text: "already sent", createdAt: 2, pendingRunId: "run-1" },
|
||||
{ id: "local-1", text: "/status", createdAt: 3, localCommandName: "status" },
|
||||
{
|
||||
id: "waiting-idle-1",
|
||||
text: "queued during the run",
|
||||
createdAt: 4,
|
||||
sendState: "waiting-idle",
|
||||
},
|
||||
],
|
||||
});
|
||||
const steer = [...container.querySelectorAll<HTMLButtonElement>(".chat-queue__action")];
|
||||
expect(steer).toHaveLength(2);
|
||||
steer[0]?.click();
|
||||
steer[1]?.click();
|
||||
expect(onQueueSteer.mock.calls).toEqual([["queued-1"], ["waiting-idle-1"]]);
|
||||
});
|
||||
|
||||
it("renders reconnect waits as compact badges without the raw transport error", () => {
|
||||
const container = renderQueue({
|
||||
onQueueRemove: vi.fn(),
|
||||
queue: [
|
||||
{
|
||||
id: "reconnect-1",
|
||||
text: "send me once the gateway is back",
|
||||
createdAt: 1,
|
||||
sendError: "chat.send unavailable during gateway restart",
|
||||
sendState: "waiting-reconnect",
|
||||
},
|
||||
],
|
||||
});
|
||||
const item = container.querySelector(".chat-queue__item");
|
||||
expect(item?.classList.contains("chat-queue__item--reconnect")).toBe(true);
|
||||
expect(
|
||||
item?.querySelector('.chat-queue__icon path[d="M21 5v12a2 2 0 0 1-2 2h-6"]'),
|
||||
).not.toBeNull();
|
||||
expect(item?.querySelector(".chat-queue__error")).toBeNull();
|
||||
const state = item?.querySelector(".chat-queue__badge--reconnect");
|
||||
expect(state?.textContent?.trim()).toBe("Waiting for reconnect");
|
||||
expect(state?.getAttribute("title")).toBe("chat.send unavailable during gateway restart");
|
||||
});
|
||||
|
||||
it("keeps attempted unconfirmed messages inline while local commands retain retry and discard", () => {
|
||||
const onQueueRetry = vi.fn();
|
||||
const onQueueRemove = vi.fn();
|
||||
@@ -55,7 +122,7 @@ describe("chat composer steering queue", () => {
|
||||
const container = document.createElement("div");
|
||||
document.body.append(container);
|
||||
render(
|
||||
renderChatQueue({
|
||||
renderQueueSurfaces({
|
||||
queue: [
|
||||
{
|
||||
id: "steer-1",
|
||||
@@ -85,7 +152,7 @@ describe("chat composer steering queue", () => {
|
||||
const container = document.createElement("div");
|
||||
document.body.append(container);
|
||||
render(
|
||||
renderChatQueue({
|
||||
renderQueueSurfaces({
|
||||
queue: [
|
||||
{
|
||||
id: "failed-steer",
|
||||
@@ -123,10 +190,16 @@ describe("chat composer steering queue", () => {
|
||||
});
|
||||
});
|
||||
|
||||
function renderQueueSurfaces(props: Parameters<typeof renderChatQueue>[0]) {
|
||||
return html`${renderChatQueue(props)}${props.queue
|
||||
.filter(shouldRenderQueuedSendInThread)
|
||||
.map((item) => renderQueuedSendControls(item, props))}`;
|
||||
}
|
||||
|
||||
function renderQueue(props: Parameters<typeof renderChatQueue>[0]) {
|
||||
const container = document.createElement("div");
|
||||
document.body.append(container);
|
||||
render(renderChatQueue(props), container);
|
||||
render(renderQueueSurfaces(props), container);
|
||||
return container;
|
||||
}
|
||||
|
||||
@@ -161,7 +234,9 @@ describe("chat composer queue reordering", () => {
|
||||
|
||||
it("caps long queues and records both scroll boundaries", () => {
|
||||
const container = renderQueue({
|
||||
queue: [waiting("a", 1), waiting("b", 2), waiting("c", 3), waiting("d", 4)],
|
||||
queue: [waiting("a", 1), waiting("b", 2), waiting("c", 3), waiting("d", 4)].map((item) =>
|
||||
Object.assign(item, { localCommandName: "compact" }),
|
||||
),
|
||||
onQueueRemove: vi.fn(),
|
||||
});
|
||||
const scroll = container.querySelector<HTMLElement>(".chat-queue__scroll")!;
|
||||
@@ -192,7 +267,9 @@ describe("chat composer queue reordering", () => {
|
||||
vi.stubGlobal("requestAnimationFrame", requestFrame);
|
||||
vi.stubGlobal("cancelAnimationFrame", cancelFrame);
|
||||
const container = renderQueue({
|
||||
queue: [waiting("a", 1), waiting("b", 2), waiting("c", 3), waiting("d", 4)],
|
||||
queue: [waiting("a", 1), waiting("b", 2), waiting("c", 3), waiting("d", 4)].map((item) =>
|
||||
Object.assign(item, { localCommandName: "compact" }),
|
||||
),
|
||||
onQueueMove: vi.fn(),
|
||||
onQueueRemove: vi.fn(),
|
||||
});
|
||||
@@ -473,7 +550,9 @@ describe("chat composer queue reordering", () => {
|
||||
expect(container.querySelector(".chat-queue__global-state")?.textContent?.trim()).toBe(
|
||||
t("chat.queue.states.applyingSettings"),
|
||||
);
|
||||
expect(container.querySelectorAll(".chat-queue__state")).toHaveLength(0);
|
||||
expect(
|
||||
[...container.querySelectorAll(".chat-queue__state")].map((node) => node.textContent),
|
||||
).toEqual([t("chat.queue.states.queued"), t("chat.queue.states.queued")]);
|
||||
const steerButtons = [...container.querySelectorAll<HTMLButtonElement>(".chat-queue__steer")];
|
||||
expect(steerButtons).toHaveLength(2);
|
||||
expect(steerButtons.every((button) => button.disabled)).toBe(true);
|
||||
|
||||
@@ -152,29 +152,6 @@ describe("renderChatComposer controls", () => {
|
||||
expect(textarea.matches(":placeholder-shown")).toBe(true);
|
||||
});
|
||||
|
||||
it("keeps an unsaved queued-row edit open when normal composer text is double-clicked", () => {
|
||||
const onCancel = vi.fn();
|
||||
const { container } = renderComposer({
|
||||
draft: "select this composer text",
|
||||
queue: [{ id: "queued", text: "original queued text", createdAt: 1 }],
|
||||
queuedEdit: {
|
||||
editingId: "queued",
|
||||
editingText: "unsaved queued edit",
|
||||
onCancel,
|
||||
},
|
||||
});
|
||||
const composer = container.querySelector<HTMLTextAreaElement>(
|
||||
".agent-chat__composer-combobox textarea",
|
||||
);
|
||||
|
||||
composer?.dispatchEvent(new MouseEvent("dblclick", { bubbles: true }));
|
||||
|
||||
expect(onCancel).not.toHaveBeenCalled();
|
||||
expect(container.querySelector<HTMLTextAreaElement>(".chat-queue__edit-input")?.value).toBe(
|
||||
"unsaved queued edit",
|
||||
);
|
||||
});
|
||||
|
||||
it("keeps composing enabled and explains queued delivery while offline", () => {
|
||||
const { container } = renderComposer({
|
||||
offline: true,
|
||||
|
||||
@@ -174,6 +174,10 @@ export function isQueuedSendInlineState(item: ChatQueueItem): boolean {
|
||||
}
|
||||
|
||||
export function shouldRenderQueuedSendInThread(item: ChatQueueItem): boolean {
|
||||
return !item.localCommandName && !item.pendingRunId;
|
||||
}
|
||||
|
||||
function isStartedQueuedSend(item: ChatQueueItem): boolean {
|
||||
// Page-local submit timing is not persisted; durable attempts keep restored prompts visible.
|
||||
return (
|
||||
queuedSendStarted(item) &&
|
||||
@@ -193,8 +197,8 @@ export function resolveWorkingProgress(
|
||||
toolMessages: unknown[],
|
||||
): WorkingProgress {
|
||||
const queuedProgress =
|
||||
queue.find((item) => item.sendState === "sending" && shouldRenderQueuedSendInThread(item)) ??
|
||||
queue.find(shouldRenderQueuedSendInThread);
|
||||
queue.find((item) => item.sendState === "sending" && isStartedQueuedSend(item)) ??
|
||||
queue.find(isStartedQueuedSend);
|
||||
const queuedRunId = queuedProgress?.sendRunId ?? queuedProgress?.pendingRunId;
|
||||
const segmentRunId = streamSegments
|
||||
.map((segment) => segment.runId)
|
||||
@@ -216,7 +220,7 @@ export function resolveWorkingProgress(
|
||||
compatibleCached?.startedAt,
|
||||
streamStartedAt,
|
||||
...queue
|
||||
.filter(shouldRenderQueuedSendInThread)
|
||||
.filter(isStartedQueuedSend)
|
||||
// Send performance fields use performance.now(); the elapsed timer renders against Date.now().
|
||||
.map((item) => item.createdAt),
|
||||
...streamSegments.map((segment) => segment.ts),
|
||||
|
||||
@@ -9,7 +9,7 @@ import { extractTextCached } from "../../lib/chat/message-extract.ts";
|
||||
import { normalizeMessage, normalizeRoleForGrouping } from "../../lib/chat/message-normalizer.ts";
|
||||
import { senderIdentityKey } from "../../lib/chat/sender-label.ts";
|
||||
import { isContextCompactionActivity } from "./chat-progress.ts";
|
||||
import { userTurnSendIdentity } from "./chat-thread-items.ts";
|
||||
import { isPendingSendMessage, userTurnSendIdentity } from "./chat-thread-items.ts";
|
||||
import {
|
||||
isKeyedAssistantStreamFallbackMessage,
|
||||
streamPartBoundaryId,
|
||||
@@ -55,10 +55,17 @@ function stampReplyAttribution(
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
function userTurnGroupingIdentity(message: unknown): string | null {
|
||||
// Independent sends own elapsed boundaries; admitted same-run steers keep
|
||||
// their target's original start. User group runIds stay unset for activity pooling.
|
||||
const steerTarget = persistedSteerTargetRunId(message);
|
||||
return steerTarget ? `send:${steerTarget}` : userTurnSendIdentity(message);
|
||||
}
|
||||
|
||||
export function groupMessages(items: ChatItem[]): Array<ChatItem | MessageGroup> {
|
||||
const result: Array<ChatItem | MessageGroup> = [];
|
||||
let currentGroup: MessageGroup | null = null;
|
||||
let currentUserTurnIdentity: string | null = null;
|
||||
|
||||
for (const item of items) {
|
||||
if (item.kind !== "message") {
|
||||
@@ -78,19 +85,16 @@ export function groupMessages(items: ChatItem[]): Array<ChatItem | MessageGroup>
|
||||
const timestamp = normalized.timestamp || Date.now();
|
||||
const runId =
|
||||
role === "assistant" || role === "tool" ? transcriptRunId(item.message) : undefined;
|
||||
// Independent sends own separate elapsed boundaries; consecutive steers
|
||||
// before any output keep their target run's original start. Do not stamp
|
||||
// user runIds onto groups: reply-less activity pooling uses that field.
|
||||
const steerTarget = role === "user" ? persistedSteerTargetRunId(item.message) : null;
|
||||
const userTurnIdentity =
|
||||
role === "user"
|
||||
? steerTarget
|
||||
? `send:${steerTarget}`
|
||||
: userTurnSendIdentity(item.message)
|
||||
: null;
|
||||
const shouldSplitBySender = role === "user" || role === "assistant";
|
||||
const startsProjectedTurn =
|
||||
asRecord(asRecord(item.message)?.["__openclaw"])?.turnBoundary === true;
|
||||
// Pending sends always own a bubble; admitted sends use normalized turn
|
||||
// identity so same-run steers do not reset the elapsed boundary.
|
||||
const startsUserSend =
|
||||
role === "user" &&
|
||||
(isPendingSendMessage(item.message) ||
|
||||
userTurnGroupingIdentity(item.message) !==
|
||||
userTurnGroupingIdentity(currentGroup?.messages.at(-1)?.message));
|
||||
const splitsAssistantCommentary =
|
||||
role === "assistant" &&
|
||||
currentGroup?.role === "assistant" &&
|
||||
@@ -105,9 +109,9 @@ export function groupMessages(items: ChatItem[]): Array<ChatItem | MessageGroup>
|
||||
if (
|
||||
!currentGroup ||
|
||||
startsProjectedTurn ||
|
||||
startsUserSend ||
|
||||
currentGroup.role !== role ||
|
||||
currentGroup.runId !== runId ||
|
||||
currentUserTurnIdentity !== userTurnIdentity ||
|
||||
splitsAssistantCommentary ||
|
||||
splitsRuntimeActivity ||
|
||||
(shouldSplitBySender &&
|
||||
@@ -117,7 +121,6 @@ export function groupMessages(items: ChatItem[]): Array<ChatItem | MessageGroup>
|
||||
if (currentGroup) {
|
||||
result.push(currentGroup);
|
||||
}
|
||||
currentUserTurnIdentity = userTurnIdentity;
|
||||
currentGroup = {
|
||||
kind: "group",
|
||||
key: `group:${role}:${item.key}`,
|
||||
|
||||
@@ -3876,12 +3876,7 @@ describe("buildCachedChatItems", () => {
|
||||
sendAttempts: 1,
|
||||
};
|
||||
|
||||
expect(
|
||||
messageGroups({
|
||||
queue: [{ ...restored, sendAttempts: 0, sendState: "waiting-reconnect" }],
|
||||
}),
|
||||
).toStrictEqual([]);
|
||||
for (const sendState of ["waiting-reconnect", "sending"] as const) {
|
||||
for (const sendState of ["waiting-idle", "waiting-reconnect", "sending"] as const) {
|
||||
const groups = messageGroups({ queue: [{ ...restored, sendState }] });
|
||||
expect(groups).toHaveLength(1);
|
||||
expect(messageRecord(groupAt(groups, 0)).content).toStrictEqual([
|
||||
@@ -3890,21 +3885,68 @@ describe("buildCachedChatItems", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("keeps steerable queued sends out of the thread until sending starts", () => {
|
||||
const queued = {
|
||||
id: "pending-send-1",
|
||||
text: "wait above the composer",
|
||||
createdAt: 2,
|
||||
sendSubmittedAtMs: 10,
|
||||
};
|
||||
|
||||
expect(messageGroups({ queue: [{ ...queued, sendState: "waiting-idle" }] })).toStrictEqual([]);
|
||||
|
||||
const groups = messageGroups({ queue: [{ ...queued, sendState: "sending" }] });
|
||||
expect(groups).toHaveLength(1);
|
||||
expect(messageRecord(groupAt(groups, 0)).content).toStrictEqual([
|
||||
{ type: "text", text: "wait above the composer" },
|
||||
it("keeps future queued bubbles at the tail with stable keys through extension and admission", () => {
|
||||
const first = queuedSend("first", "First follow-up", 3_000, "waiting-idle", {
|
||||
sendRunId: "first-run",
|
||||
sendAttempts: 0,
|
||||
});
|
||||
const second = queuedSend("second", "Second follow-up", 2_000, "waiting-idle", {
|
||||
sendRunId: "second-run",
|
||||
sendAttempts: 0,
|
||||
});
|
||||
const active = userMessage("Active prompt", 1_000, {
|
||||
__openclaw: { idempotencyKey: "active-run:user" },
|
||||
});
|
||||
const build = (
|
||||
queue: ChatQueueItem[],
|
||||
messages = [active],
|
||||
stream: string | null = "Still working",
|
||||
) =>
|
||||
buildCachedChatItems(
|
||||
createProps({
|
||||
paneId: "future-queue-handoff",
|
||||
runId: "active-run",
|
||||
messages,
|
||||
queue,
|
||||
stream,
|
||||
streamStartedAt: 9_000,
|
||||
runWorking: stream !== null,
|
||||
}),
|
||||
);
|
||||
const initial = build([first, second]);
|
||||
expect(initial.map((item) => (item.kind === "group" ? item.role : item.kind))).toEqual([
|
||||
"user",
|
||||
"stream",
|
||||
"reading-indicator",
|
||||
"user",
|
||||
"user",
|
||||
]);
|
||||
const queuedGroups = initial.slice(-2) as MessageGroup[];
|
||||
expect(queuedGroups.map((group) => messageRecord(group).content)).toEqual([
|
||||
[{ type: "text", text: first.text }],
|
||||
[{ type: "text", text: second.text }],
|
||||
]);
|
||||
const keys = queuedGroups.map((group) => [group.key, group.messages[0]?.key]);
|
||||
const extended = { ...first, text: first.text + "\nAdditional detail" };
|
||||
const grown = build([extended, second]).slice(-2) as MessageGroup[];
|
||||
expect(grown.map((group) => [group.key, group.messages[0]?.key])).toEqual(keys);
|
||||
expect(messageRecord(grown[0]!).content).toEqual([{ type: "text", text: extended.text }]);
|
||||
const reordered = build([second, extended]).slice(-2) as MessageGroup[];
|
||||
expect(reordered.map((group) => [group.key, group.messages[0]?.key])).toEqual(
|
||||
keys.toReversed(),
|
||||
);
|
||||
const sending = messageGroups({
|
||||
paneId: "future-queue-handoff",
|
||||
messages: [active],
|
||||
queue: [{ ...extended, sendState: "sending", sendAttempts: 1 }, second],
|
||||
});
|
||||
expect(sending.slice(-2).map((group) => [group.key, group.messages[0]?.key])).toEqual(keys);
|
||||
const admitted = userMessage(extended.text, 10_000, {
|
||||
__openclaw: { id: "persisted-first", seq: 10, idempotencyKey: "first-run:user" },
|
||||
});
|
||||
const history = build([second], [active, admitted], null).slice(-2) as MessageGroup[];
|
||||
expect(history.map((group) => [group.key, group.messages[0]?.key])).toEqual(keys);
|
||||
resetChatThreadState("future-queue-handoff");
|
||||
});
|
||||
|
||||
it("renders submitted queued attachment sends with attachment blocks before chat.send ACK", () => {
|
||||
@@ -3945,10 +3987,10 @@ describe("buildCachedChatItems", () => {
|
||||
],
|
||||
});
|
||||
|
||||
expect(groups).toHaveLength(1);
|
||||
expect(groupAt(groups, 0).messages).toHaveLength(2);
|
||||
expect(groups).toHaveLength(2);
|
||||
expect(groups.map((group) => group.messages.length)).toEqual([1, 1]);
|
||||
expect(messageAt(groupAt(groups, 0), 0).duplicateCount).toBeUndefined();
|
||||
expect(messageAt(groupAt(groups, 0), 1).duplicateCount).toBeUndefined();
|
||||
expect(messageAt(groupAt(groups, 1), 0).duplicateCount).toBeUndefined();
|
||||
});
|
||||
|
||||
it.each(["sending", "failed", "unconfirmed"] as const)(
|
||||
|
||||
@@ -761,11 +761,11 @@ describe("chat typing status", () => {
|
||||
expect(indicator?.textContent).toContain(expectedText);
|
||||
});
|
||||
|
||||
it("anchors the run error and queue to the composer without moving transcript presence", () => {
|
||||
it("anchors the run error and local command queue without moving transcript presence", () => {
|
||||
const container = renderChatView({
|
||||
typingActors: [{ id: "ayaan", label: "Ayaan" }],
|
||||
runError: { summary: "Gateway unavailable" },
|
||||
queue: [{ id: "queued", text: "Try again", createdAt: 1 }],
|
||||
queue: [{ id: "queued", text: "/compact", localCommandName: "compact", createdAt: 1 }],
|
||||
});
|
||||
const indicator = requireElement(
|
||||
container,
|
||||
@@ -2240,8 +2240,8 @@ describe("chat scroll-to-bottom affordance", () => {
|
||||
const container = renderChatView({
|
||||
showNewMessages: true,
|
||||
queue: [
|
||||
{ id: "queued-1", text: "first queued message", createdAt: 1 },
|
||||
{ id: "queued-2", text: "second queued message", createdAt: 2 },
|
||||
{ id: "queued-1", text: "/compact", localCommandName: "compact", createdAt: 1 },
|
||||
{ id: "queued-2", text: "/reset", localCommandName: "reset", createdAt: 2 },
|
||||
],
|
||||
});
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@ import {
|
||||
} from "./chat-view-notices.ts";
|
||||
import { createChatAttachmentDropHandlers } from "./components/chat-attachments.ts";
|
||||
import type { BackgroundTasksProps } from "./components/chat-background-tasks.types.ts";
|
||||
import { hasTerminalRunStatus } from "./components/chat-composer-state.ts";
|
||||
import type {
|
||||
CapabilityMenuProps,
|
||||
ChatComposerDisabledBanner,
|
||||
@@ -57,6 +58,7 @@ import type {
|
||||
} from "./components/chat-composer-types.ts";
|
||||
import { isChatRunWorking, renderChatComposer } from "./components/chat-composer.ts";
|
||||
import { isImageLightboxEvent, openInlineChatImage } from "./components/chat-image-lightbox.ts";
|
||||
import type { MessageReplyTarget } from "./components/chat-message-markdown.ts";
|
||||
import type { ArtifactDownloadResolver } from "./components/chat-message-media.ts";
|
||||
import type { ChatPermissionPickerProps } from "./components/chat-permission-picker.ts";
|
||||
import { renderChatPullRequests } from "./components/chat-pull-requests.ts";
|
||||
@@ -82,12 +84,6 @@ import type { ChatRunUiStatus } from "./run-lifecycle.ts";
|
||||
import type { CompactionStatus, FallbackStatus } from "./tool-stream.ts";
|
||||
import type { WorkspaceResultConflict } from "./workspace-conflict.ts";
|
||||
import "../../components/resizable-divider.ts";
|
||||
type ChatReplyTarget = {
|
||||
messageId: string;
|
||||
text: string;
|
||||
senderLabel?: string | null;
|
||||
sourceMessageId?: string | null;
|
||||
};
|
||||
export type ChatProps = ChatTaskSuggestionTrayProps &
|
||||
ChatPlacementStartupNoticeProps & {
|
||||
transcript: ChatTranscriptController;
|
||||
@@ -271,9 +267,9 @@ export type ChatProps = ChatTaskSuggestionTrayProps &
|
||||
resourceBasePath?: string;
|
||||
composerControls?: TemplateResult | typeof nothing;
|
||||
permissionPicker?: ChatPermissionPickerProps;
|
||||
replyTarget?: ChatReplyTarget | null;
|
||||
replyTarget?: MessageReplyTarget | null;
|
||||
onClearReply?: () => void;
|
||||
onSetReply?: (target: ChatReplyTarget) => void;
|
||||
onSetReply?: (target: MessageReplyTarget) => void;
|
||||
replyMessageAccess?: ReplyMessageAccess;
|
||||
onRewindMessage?: (entryId: string) => Promise<boolean> | boolean;
|
||||
onForkMessage?: (entryId: string) => Promise<void> | void;
|
||||
@@ -349,6 +345,22 @@ export function renderChat(props: ChatProps) {
|
||||
runOutputTokens: props.runOutputTokens,
|
||||
runStatus: props.runStatus,
|
||||
queue,
|
||||
queueControls: {
|
||||
queue: props.queue,
|
||||
offline: props.offline,
|
||||
canAbort:
|
||||
Boolean(props.canAbort && props.onAbort) && !hasTerminalRunStatus(props.runStatus),
|
||||
onQueueRetry: props.connected && canCompose ? props.onQueueRetry : undefined,
|
||||
onQueueSteer: props.connected && canCompose ? props.onQueueSteer : undefined,
|
||||
onQueueMove: props.onQueueMove,
|
||||
onQueueEdit: props.queuedEdit?.onEdit,
|
||||
onQueueEditChange: props.queuedEdit?.onEditChange,
|
||||
onQueueEditSubmit: props.queuedEdit?.onEditSubmit,
|
||||
onQueueEditCancel: props.queuedEdit?.onCancel,
|
||||
editingId: props.queuedEdit?.editingId ?? null,
|
||||
editingText: props.queuedEdit?.editingText,
|
||||
onQueueRemove: props.onQueueRemove,
|
||||
},
|
||||
showThinking: props.showThinking,
|
||||
showToolCalls: props.showToolCalls,
|
||||
persistCommentary: props.persistCommentary,
|
||||
|
||||
@@ -10,11 +10,11 @@ import {
|
||||
isMovableChatQueueItem,
|
||||
} from "../../../lib/chat/chat-queue-order.ts";
|
||||
import type { ChatQueueItem } from "../../../lib/chat/chat-types.ts";
|
||||
import { isQueuedSendInlineState } from "../chat-progress.ts";
|
||||
import { isQueuedSendInlineState, shouldRenderQueuedSendInThread } from "../chat-progress.ts";
|
||||
import { isSteerableQueuedMessage } from "../chat-queue.ts";
|
||||
import { renderChatAuthorAvatar } from "./chat-author-avatar.ts";
|
||||
|
||||
type ChatQueueProps = {
|
||||
export type ChatQueueProps = {
|
||||
queue: ChatQueueItem[];
|
||||
offline?: boolean;
|
||||
canAbort?: boolean;
|
||||
@@ -152,13 +152,10 @@ function sendStateLabel(item: ChatQueueItem, offline: boolean): string | null {
|
||||
}
|
||||
}
|
||||
|
||||
export function renderChatQueue(props: ChatQueueProps) {
|
||||
function queueReorder(props: ChatQueueProps): ChatQueueReorder {
|
||||
const visibleQueue = props.queue.filter(
|
||||
(item) => item.sendState !== "sending" && !isQueuedSendInlineState(item),
|
||||
);
|
||||
if (!visibleQueue.length) {
|
||||
return nothing;
|
||||
}
|
||||
// Move positions address one movable segment, matching what the reorder owner
|
||||
// permutes. A row attached to a run keeps its place and ends the segment, so
|
||||
// the handle never offers a move across it. An edited row holds the queue
|
||||
@@ -167,18 +164,32 @@ export function renderChatQueue(props: ChatQueueProps) {
|
||||
visibleQueue,
|
||||
(item) => isMovableChatQueueItem(item) && item.id !== props.editingId,
|
||||
).map((rows) => rows.map((row) => row.id));
|
||||
const reorder: ChatQueueReorder = {
|
||||
return {
|
||||
segments: movableSegments,
|
||||
// Whether this queue reorders at all, which is a queue-level fact: an open
|
||||
// edit shrinks the segments but must not retract the handle column.
|
||||
offered: visibleQueue.filter(isMovableChatQueueItem).length > 1,
|
||||
};
|
||||
}
|
||||
|
||||
export function renderQueuedSendControls(item: ChatQueueItem, props: ChatQueueProps) {
|
||||
return item.sendState === "sending" || isQueuedSendInlineState(item)
|
||||
? nothing
|
||||
: renderChatQueueItem(item, props, queueReorder(props), true);
|
||||
}
|
||||
|
||||
export function renderChatQueue(props: ChatQueueProps) {
|
||||
const visibleQueue = props.queue.filter((item) => !shouldRenderQueuedSendInThread(item));
|
||||
const reorder = queueReorder(props);
|
||||
// Applying settings belongs to the queue as a whole. Connection loss is the
|
||||
// exceptional per-item delivery state operators need to see on every row.
|
||||
const globalState =
|
||||
visibleQueue.some((item) => item.sendState === "waiting-model") && !props.offline
|
||||
props.queue.some((item) => item.sendState === "waiting-model") && !props.offline
|
||||
? { label: t("chat.queue.states.applyingSettings"), tone: "settings" }
|
||||
: null;
|
||||
if (!visibleQueue.length && !globalState) {
|
||||
return nothing;
|
||||
}
|
||||
// Keyed rows so a reorder moves the existing DOM node instead of rewriting
|
||||
// it in place; that is what keeps focus on the handle the operator is using.
|
||||
return html`
|
||||
@@ -248,8 +259,9 @@ function renderChatQueueItem(
|
||||
item: ChatQueueItem,
|
||||
props: ChatQueueProps,
|
||||
reorder: ChatQueueReorder,
|
||||
inThread = false,
|
||||
) {
|
||||
const authorAvatar = renderChatAuthorAvatar(item.sender);
|
||||
const authorAvatar = inThread ? nothing : renderChatAuthorAvatar(item.sender);
|
||||
const hasAuthorAvatar = authorAvatar !== nothing;
|
||||
const failed = item.sendState === "failed" || item.sendState === "unconfirmed";
|
||||
const reconnecting = !failed && (props.offline || item.sendState === "waiting-reconnect");
|
||||
@@ -285,7 +297,7 @@ function renderChatQueueItem(
|
||||
// The leading glyph identifies the object, not its transient delivery state.
|
||||
// Row tone, badges, and actions carry failure, review, reconnect, and steer.
|
||||
const leadingIcon = queueWaitingIcon;
|
||||
const itemClass = `chat-queue__item${hasAuthorAvatar ? "" : " chat-queue__item--no-avatar"}${steered ? " chat-queue__item--steered" : ""}${
|
||||
const itemClass = `chat-queue__item${inThread ? " chat-queue__item--in-thread" : ""}${hasAuthorAvatar ? "" : " chat-queue__item--no-avatar"}${steered ? " chat-queue__item--steered" : ""}${
|
||||
failed ? " chat-queue__item--failed" : ""
|
||||
}${reconnecting ? " chat-queue__item--reconnect" : ""}${
|
||||
editing ? " chat-queue__item--editing" : ""
|
||||
@@ -420,7 +432,11 @@ function renderChatQueueItem(
|
||||
}}
|
||||
></textarea>`
|
||||
: html`<span class="chat-queue__copy">
|
||||
<span class="chat-queue__text" title=${text}>${text}</span>
|
||||
${inThread
|
||||
? stateLabel || steered
|
||||
? nothing
|
||||
: html`<span class="chat-queue__state">${t("chat.queue.states.queued")}</span>`
|
||||
: html`<span class="chat-queue__text" title=${text}>${text}</span>`}
|
||||
${steered
|
||||
? html`<span class="chat-queue__badge chat-queue__badge--steered"
|
||||
>${t("chat.queue.steer")}</span
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { asNullableRecord as asRecord } from "@openclaw/normalization-core/record-coerce";
|
||||
import { html, nothing } from "lit";
|
||||
import { resolveLocalUserName } from "../../../app/user-identity.ts";
|
||||
import { icons } from "../../../components/icons.ts";
|
||||
@@ -9,6 +10,7 @@ import {
|
||||
} from "../../../components/person-activity-link.ts";
|
||||
import { t } from "../../../i18n/index.ts";
|
||||
import type { BoardProvider } from "../../../lib/board/provider.ts";
|
||||
import { isMovableChatQueueItem } from "../../../lib/chat/chat-queue-order.ts";
|
||||
import type { MessageGroup } from "../../../lib/chat/chat-types.ts";
|
||||
import { normalizeRoleForGrouping } from "../../../lib/chat/message-normalizer.ts";
|
||||
import { formatSenderLabel } from "../../../lib/chat/sender-label.ts";
|
||||
@@ -33,6 +35,7 @@ import {
|
||||
import type { LinkFaviconFetcher } from "../link-favicon-loader.ts";
|
||||
import { workspaceResultConflictFromTranscript } from "../workspace-conflict.ts";
|
||||
import { renderChatAuthorAvatar } from "./chat-author-avatar.ts";
|
||||
import { renderQueuedSendControls, type ChatQueueProps } from "./chat-composer-queue.ts";
|
||||
import { renderGroupedMessage } from "./chat-message-bubble.ts";
|
||||
import { renderRewindButton } from "./chat-message-confirmation.ts";
|
||||
import {
|
||||
@@ -113,6 +116,7 @@ type RenderMessageGroupOptions = {
|
||||
onReply?: (target: MessageReplyTarget) => void;
|
||||
onRetryQueuedMessage?: (id: string) => void;
|
||||
queuedMessageAction?: { id: string; label?: string; onAction?: () => void };
|
||||
queueControls?: ChatQueueProps;
|
||||
resolveReplyPreview?: (replyToId: string) => ReplyPreview | undefined;
|
||||
onResolveReply?: (replyToId: string) => void;
|
||||
onOpenReply?: (replyToId: string) => void;
|
||||
@@ -550,6 +554,22 @@ export function renderMessageGroup(group: MessageGroup, opts: RenderMessageGroup
|
||||
: " chat-group--sender-tint"}"
|
||||
style=${senderHue === null ? nothing : `--chat-sender-hue: ${senderHue}`}
|
||||
data-chat-row-key=${group.key}
|
||||
@dblclick=${(event: MouseEvent) => {
|
||||
const target = event.target;
|
||||
if (
|
||||
!(target instanceof Element) ||
|
||||
!target.closest(".chat-bubble") ||
|
||||
target.closest("a, button, input, select, textarea") ||
|
||||
!isPendingSendMessage(group.messages[0]?.message)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
const pendingId = asRecord(asRecord(group.messages[0]?.message)?.["__openclaw"])?.id;
|
||||
const queued = opts.queueControls?.queue.find((entry) => entry.id === pendingId);
|
||||
if (queued && isMovableChatQueueItem(queued) && !opts.queueControls?.editingId) {
|
||||
opts.queueControls?.onQueueEdit?.(queued.id);
|
||||
}
|
||||
}}
|
||||
>
|
||||
${normalizedRole !== "tool" &&
|
||||
showAvatarGutter &&
|
||||
@@ -583,6 +603,11 @@ export function renderMessageGroup(group: MessageGroup, opts: RenderMessageGroup
|
||||
${opts.frameContent ??
|
||||
group.messages.map((item, index) => {
|
||||
const actionDetails = messageActionDetails[index];
|
||||
const queued = isPendingSendMessage(item.message)
|
||||
? opts.queueControls?.queue.find(
|
||||
(entry) => entry.id === asRecord(asRecord(item.message)?.["__openclaw"])?.id,
|
||||
)
|
||||
: undefined;
|
||||
return html`
|
||||
${renderGroupedMessage(
|
||||
item.message,
|
||||
@@ -590,6 +615,9 @@ export function renderMessageGroup(group: MessageGroup, opts: RenderMessageGroup
|
||||
buildGroupedMessageRenderOptions(group, item, index, opts, actionDetails),
|
||||
opts.onOpenSidebar,
|
||||
)}
|
||||
${queued && opts.queueControls
|
||||
? renderQueuedSendControls(queued, opts.queueControls)
|
||||
: nothing}
|
||||
${actionDetails && index < lastMessageIndex && !ownsRunFrame
|
||||
? html`
|
||||
<div class="chat-message-actions-row" data-message-actions-for=${item.key}>
|
||||
|
||||
@@ -867,6 +867,47 @@ describe("grouped chat rendering", () => {
|
||||
expect(order).toEqual(["Reply to message", "Rewind", "name", "time"]);
|
||||
});
|
||||
|
||||
it("exposes queued editing and removal beside the user bubble without repeating its text", () => {
|
||||
const container = document.createElement("div");
|
||||
const onQueueEdit = vi.fn();
|
||||
const onQueueRemove = vi.fn();
|
||||
const queued = {
|
||||
id: "future-send",
|
||||
text: "Future prompt",
|
||||
createdAt: 1,
|
||||
sendState: "waiting-idle" as const,
|
||||
};
|
||||
renderGroupedMessage(
|
||||
container,
|
||||
createUserMessage(queued.text, {
|
||||
__openclaw: { id: queued.id, kind: "pending-send", state: queued.sendState },
|
||||
}),
|
||||
"user",
|
||||
{ queueControls: { queue: [queued], onQueueEdit, onQueueRemove } },
|
||||
);
|
||||
const bubble = expectElement(container, ".chat-group.user .chat-bubble", HTMLElement);
|
||||
const controls = expectElement(container, ".chat-group.user .chat-queue__item", HTMLElement);
|
||||
expect(bubble.textContent).toContain(queued.text);
|
||||
expect(controls.textContent).toContain("Queued");
|
||||
expect(controls.textContent).not.toContain(queued.text);
|
||||
controls.querySelector("wa-dropdown")?.dispatchEvent(
|
||||
new CustomEvent("wa-select", {
|
||||
detail: {
|
||||
item: Object.assign(document.createElement("wa-dropdown-item"), { value: "edit" }),
|
||||
},
|
||||
}),
|
||||
);
|
||||
expect(onQueueEdit).toHaveBeenCalledWith(queued.id);
|
||||
const link = document.createElement("a");
|
||||
bubble.append(link);
|
||||
link.dispatchEvent(new MouseEvent("dblclick", { bubbles: true }));
|
||||
expect(onQueueEdit).toHaveBeenCalledOnce();
|
||||
bubble.dispatchEvent(new MouseEvent("dblclick", { bubbles: true }));
|
||||
expect(onQueueEdit).toHaveBeenCalledTimes(2);
|
||||
controls.querySelector<HTMLButtonElement>(".chat-queue__remove")?.click();
|
||||
expect(onQueueRemove).toHaveBeenCalledWith(queued.id);
|
||||
});
|
||||
|
||||
it.each([
|
||||
{ state: "failed", label: "Not sent", actionLabel: undefined },
|
||||
{ state: "unconfirmed", label: "Delivery unconfirmed", actionLabel: undefined },
|
||||
|
||||
@@ -29,6 +29,7 @@ import type { LinkFaviconFetcher } from "../link-favicon-loader.ts";
|
||||
import type { RealtimeTalkConversationEntry } from "../realtime-talk-conversation.ts";
|
||||
import type { ChatRunUiStatus } from "../run-lifecycle.ts";
|
||||
import type { BackgroundTasksProps } from "./chat-background-tasks.types.ts";
|
||||
import type { ChatQueueProps } from "./chat-composer-queue.ts";
|
||||
import type { ArtifactDownloadResolver } from "./chat-message-media.ts";
|
||||
import {
|
||||
dismissConfirmedActionPopovers,
|
||||
@@ -78,6 +79,7 @@ export type ChatThreadProps = {
|
||||
runOutputTokens?: number | null;
|
||||
runStatus?: ChatRunUiStatus | null;
|
||||
queue: ChatQueueItem[];
|
||||
queueControls?: ChatQueueProps;
|
||||
showThinking: boolean;
|
||||
showToolCalls: boolean;
|
||||
persistCommentary?: boolean;
|
||||
|
||||
@@ -365,6 +365,7 @@ export function projectChatTranscript(
|
||||
userAvatar: props.userAvatar ?? null,
|
||||
onRetryQueuedMessage: props.onRetryQueuedMessage,
|
||||
queuedMessageAction: props.queuedMessageAction,
|
||||
queueControls: props.queueControls,
|
||||
personActivity: props.personActivity,
|
||||
showAvatarGutter: !isDirectThread,
|
||||
contextWindow: threadContextWindow,
|
||||
@@ -700,6 +701,11 @@ export function projectChatTranscript(
|
||||
props.queuedMessageAction?.id,
|
||||
props.queuedMessageAction?.label,
|
||||
props.queuedMessageAction?.onAction,
|
||||
props.queue.length ? props.queue : undefined,
|
||||
props.queueControls?.offline,
|
||||
props.queueControls?.editingId,
|
||||
props.queueControls?.editingText,
|
||||
Boolean(props.queueControls?.onQueueSteer),
|
||||
props.replyMessageAccess?.revision ?? 0,
|
||||
props.replyMessageAccess?.navigationId ?? "",
|
||||
turnRecap === null ? "" : `${turnRecap.runtimeMs}:${turnRecap.outputTokens ?? ""}`,
|
||||
|
||||
@@ -157,6 +157,35 @@
|
||||
grid-template-columns: var(--chat-stack-icon-size) minmax(0, 1fr) auto;
|
||||
}
|
||||
|
||||
.chat-queue__item--in-thread {
|
||||
--chat-stack-icon-size: 14px;
|
||||
--chat-queue-row-height: 28px;
|
||||
--chat-stack-leading-inset: 0px;
|
||||
--chat-stack-trailing-inset: 0px;
|
||||
|
||||
width: fit-content;
|
||||
max-width: 100%;
|
||||
padding-block: 0;
|
||||
border: 0;
|
||||
background: none;
|
||||
}
|
||||
|
||||
.chat-queue__item--in-thread::after {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.chat-queue__item--in-thread .chat-queue__copy {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.chat-queue__item--in-thread.chat-queue__item--editing {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.chat-group-messages:has(> .chat-queue__item--editing) > .chat-bubble {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.chat-queue__item--no-avatar .chat-queue__copy,
|
||||
.chat-queue__item--no-avatar .chat-queue__edit-input {
|
||||
grid-column: 2;
|
||||
|
||||
Reference in new issue
Block a user