diff --git a/packages/session-ui/component-tests/session-message-projection.spec.ts b/packages/session-ui/component-tests/session-message-projection.spec.ts index c51e6c08ad6..f0313406110 100644 --- a/packages/session-ui/component-tests/session-message-projection.spec.ts +++ b/packages/session-ui/component-tests/session-message-projection.spec.ts @@ -1,14 +1,14 @@ import { expect, story } from "../../storybook/playwright/story" -story("badges pending steers without marking delivered, starting, or queued prompts", async ({ mount }) => { +story("marks pending metadata without badging delivered, starting, or queued prompts", async ({ mount, page }) => { const timeline = await mount("current-prompt-message--pending") - const badge = timeline.getByRole("img", { name: "Pending", exact: true }) + const indicator = timeline.locator('[data-slot="user-message-meta"] [data-slot="user-message-pending"]') const text = timeline.locator('[data-slot="user-message-text"]') for (const status of ["steering", "stranded", "starting", "queued", "delivered"]) { await timeline.getByLabel("Delivery state").selectOption(status) const pending = status === "steering" || status === "stranded" - await expect(badge).toHaveCount(pending ? 1 : 0) + await expect(indicator).toHaveCount(pending ? 1 : 0) const colors = await timeline.evaluate((element, pending) => { const probe = document.createElement("span") @@ -29,38 +29,44 @@ story("badges pending steers without marking delivered, starting, or queued prom await timeline.getByLabel("Voice message", { exact: true }).check() const voice = timeline.getByRole("img", { name: "Voice", exact: true }) await expect(voice).toBeVisible() - await expect(badge).toBeVisible() + await expect(indicator).toBeVisible() + await expect(indicator).toHaveAttribute("aria-hidden", "true") await expect(voice.locator("use")).toHaveAttribute("href", "#opencode-v2-icon-outline-wave-audio") - await expect(badge.locator("use")).toHaveAttribute("href", "#opencode-v2-icon-outline-steer") + await expect(indicator.locator("use")).toHaveAttribute("href", "#opencode-v2-icon-outline-steer") - for (const marker of [voice, badge]) { - await expect(marker).toHaveCSS("width", "20px") - await expect(marker).toHaveCSS("height", "20px") - await expect(marker.locator('[data-slot="icon-svg"]')).toHaveCSS("width", "14px") - await expect(marker.locator('[data-slot="icon-svg"]')).toHaveCSS("height", "14px") - } + await expect(voice).toHaveCSS("width", "20px") + await expect(voice).toHaveCSS("height", "20px") + await expect(voice.locator('[data-slot="icon-svg"]')).toHaveCSS("width", "14px") + await expect(voice.locator('[data-slot="icon-svg"]')).toHaveCSS("height", "14px") - const badgeColors = await badge.evaluate((element) => { + const faint = await indicator.evaluate((element) => { const probe = document.createElement("span") - probe.style.color = "var(--v2-icon-icon-muted)" - probe.style.backgroundColor = "var(--v2-background-bg-layer-02)" + probe.style.color = "var(--v2-icon-icon-faint)" element.append(probe) - const colors = { color: getComputedStyle(probe).color, background: getComputedStyle(probe).backgroundColor } + const color = getComputedStyle(probe).color probe.remove() - return colors + return color }) - await expect(badge).toHaveCSS("color", badgeColors.color) - await expect(badge).toHaveCSS("background-color", badgeColors.background) - const boxes = await Promise.all([voice.boundingBox(), badge.boundingBox()]) - expect(boxes[0]!.x + boxes[0]!.width).toBeLessThanOrEqual(boxes[1]!.x) + await expect(indicator).toHaveCSS("color", faint) + await expect(timeline.locator('[data-slot="user-message-meta"]')).toHaveText(/^Pending/) + await timeline.getByLabel("Grouped prompts", { exact: true }).check() + await expect(timeline.locator('[data-run-folded] [data-slot="user-message-copy-wrapper"]')).toBeHidden() + await expect( + timeline.locator('[data-component="user-message"]:not([data-run-folded]) [data-slot="user-message-pending"]'), + ).toBeVisible() + await expect(timeline.getByRole("img", { name: "Pending", exact: true })).toHaveCount(0) + await timeline.getByLabel("Grouped prompts", { exact: true }).uncheck() + await page.setViewportSize({ width: 390, height: 844 }) + await expect(indicator).toBeVisible() + await expect(timeline.locator('[data-slot="user-message-meta"]')).toHaveText("Pending") await timeline.getByLabel("Prompt text", { exact: true }).uncheck() await expect(timeline.getByText("notes.json", { exact: true })).toBeVisible() - await expect(badge).toBeVisible() + await expect(indicator).toBeVisible() await timeline.getByRole("button", { name: "Move to queue", exact: true }).click() - await expect(badge).toHaveCount(0) + await expect(indicator).toHaveCount(0) }) // Moved from packages/app/e2e/regression/session-timeline-collapse-state.spec.ts diff --git a/packages/session-ui/src/components/message-part.css b/packages/session-ui/src/components/message-part.css index 9c9b531efe5..1f8eb6d54e0 100644 --- a/packages/session-ui/src/components/message-part.css +++ b/packages/session-ui/src/components/message-part.css @@ -139,8 +139,7 @@ margin-top: 8px; } - [data-slot="user-message-voice"], - [data-slot="user-message-pending"] { + [data-slot="user-message-voice"] { position: absolute; top: -8px; inset-inline-start: -8px; @@ -170,21 +169,10 @@ } [data-slot="user-message-pending"] { - color: var(--v2-icon-icon-muted); - background: var(--v2-background-bg-layer-02); - } - - /* A run of waiting steers wears one badge, on its first bubble. It fades as the steer joins a run or delivers, - and its room springs with it. */ - &:has([data-slot="user-message-pending"]) { - position: relative; - margin-block-start: calc(8px * var(--user-run-badge, 0)); - - [data-slot="user-message-pending"] { - inset-inline-start: auto; - inset-inline-end: -8px; - opacity: var(--user-run-badge, 0); - } + display: inline-flex; + vertical-align: middle; + margin-inline-end: 4px; + color: var(--v2-icon-icon-faint); } [data-slot="user-message-text"] { diff --git a/packages/session-ui/src/message/message-content.tsx b/packages/session-ui/src/message/message-content.tsx index 96ecf09d079..c6dbdfaa69a 100644 --- a/packages/session-ui/src/message/message-content.tsx +++ b/packages/session-ui/src/message/message-content.tsx @@ -311,16 +311,10 @@ export function CurrentUserMessageDisplay(props: { () => !!props.run?.above && !!props.text && attachments().length === 0 && references().length === 0, ) - // A run of waiting steers wears one badge, on its first steer. - const badge = createMemo(() => waiting() && !props.run?.above) - // Once shown, the badge stays mounted so it can fade out on delivery. - const badged = createMemo((shown: boolean) => shown || badge(), false) - const runPose = () => ({ meta: folded() ? 0 : 1, top: meetsAbove() ? 1 : 0, bottom: folded() ? 1 : 0, - badge: badge() ? 1 : 0, }) // The first paint is the resting pose; the spring's first write lands a frame later. @@ -334,7 +328,6 @@ export function CurrentUserMessageDisplay(props: { el.style.setProperty("--user-run-meta", `${value.meta}`) el.style.setProperty("--user-run-top", `${value.top}`) el.style.setProperty("--user-run-bottom", `${value.bottom}`) - el.style.setProperty("--user-run-badge", `${value.badge}`) el.toggleAttribute("data-run-meta-hidden", value.meta === 0) }, userRunSpring, @@ -521,23 +514,9 @@ export function CurrentUserMessageDisplay(props: { "--user-run-meta": `${restingPose.meta}`, "--user-run-top": `${restingPose.top}`, "--user-run-bottom": `${restingPose.bottom}`, - "--user-run-badge": `${restingPose.badge}`, }} data-timeline-part-id={props.text ? `${props.message.id}:text:0` : undefined} > - -
- - - -
-
{renderAttachments()} + + + {metaHead()} diff --git a/packages/session-ui/src/message/prompt-message.stories.tsx b/packages/session-ui/src/message/prompt-message.stories.tsx index 4765f804206..faf6ed04df9 100644 --- a/packages/session-ui/src/message/prompt-message.stories.tsx +++ b/packages/session-ui/src/message/prompt-message.stories.tsx @@ -1,4 +1,4 @@ -import { createMemo, For } from "solid-js" +import { createMemo, For, Show } from "solid-js" import { createStore } from "solid-js/store" import type { SessionMessageUser } from "@opencode/client/promise" import type { SessionUserActions } from "../actions" @@ -16,10 +16,16 @@ export const Pending = { render: () => { const statuses = ["delivered", "starting", "steering", "stranded", "queued"] as const - const [state, setState] = createStore<{ status: (typeof statuses)[number]; voice: boolean; text: boolean }>({ + const [state, setState] = createStore<{ + status: (typeof statuses)[number] + voice: boolean + text: boolean + grouped: boolean + }>({ status: "steering", voice: false, text: true, + grouped: false, }) const message = createMemo(() => ({ @@ -86,8 +92,27 @@ export const Pending = { />{" "} Prompt text + + + +