fix(session-ui): move steering icon beside pending label (#57699)

This commit is contained in:
usrnk1
2026-10-21 11:05:51 +02:00
committed by GitHub
Unverified
parent 4a0f8c8e23
commit 46dd7715e6
4 changed files with 66 additions and 62 deletions
@@ -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
@@ -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"] {
@@ -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}
>
<Show when={badged()}>
<div
data-slot="user-message-pending"
role="img"
aria-label={i18n.t("ui.message.pending")}
aria-hidden={badge() ? undefined : "true"}
style={{ "pointer-events": badge() ? undefined : "none" }}
>
<Tooltip appearance="compact" value={i18n.t("ui.message.pending")} placement="top" gutter={4}>
<Icon name="outline-steer" size="small" />
</Tooltip>
</div>
</Show>
{renderAttachments()}
<Show
when={props.text}
@@ -572,6 +551,11 @@ export function CurrentUserMessageDisplay(props: {
<span data-slot="user-message-meta-wrap">
<Show when={metaHead()}>
<span data-slot="user-message-meta" class="text-12-regular text-text-weak cursor-default">
<Show when={waiting()}>
<span data-slot="user-message-pending" aria-hidden="true">
<Icon name="outline-steer" size="small" />
</span>
</Show>
{metaHead()}
</span>
</Show>
@@ -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<SessionMessageUser>(() => ({
@@ -86,8 +92,27 @@ export const Pending = {
/>{" "}
Prompt text
</label>
<label>
<input
type="checkbox"
checked={state.grouped}
onChange={(event) => setState("grouped", event.currentTarget.checked)}
/>{" "}
Grouped prompts
</label>
</div>
<CurrentSessionProviders document={document()}>
<Show when={state.grouped && state.text}>
<CurrentUserMessageDisplay
sessionID={CURRENT_SESSION_ID}
message={{ ...message(), id: "msg_pending_prompt_above" }}
text="Keep the earlier prompt in the same run."
agent="build"
model={STORY_MODEL}
actions={actions}
run={{ above: false, below: true }}
/>
</Show>
<CurrentUserMessageDisplay
sessionID={CURRENT_SESSION_ID}
message={message()}
@@ -96,6 +121,7 @@ export const Pending = {
model={STORY_MODEL}
voice={state.voice}
actions={actions}
run={{ above: state.grouped && state.text, below: false }}
/>
</CurrentSessionProviders>
</section>