fix(session-ui): render moved notice as a timeline divider (#52009)

This commit is contained in:
Luke Parker
2026-09-29 14:58:13 +10:00
committed by GitHub
Unverified
parent 293d60a89f
commit 41d4a9c45c
6 changed files with 90 additions and 32 deletions
@@ -1,7 +1,7 @@
import { expect, story } from "../../storybook/playwright/story"
// Moved from packages/app/e2e/regression/session-timeline-notices.spec.ts
story("renders the moved location notice in its compact timeline style", async ({ mount, page }) => {
story("renders the moved location notice as a timeline divider", async ({ mount, page }) => {
const directory = `/Users/usrnk1/Developer/opencode/${"nested-directory/".repeat(24)}session`
await page.setViewportSize({ width: 480, height: 720 })
const timeline = await mount("current-session-timeline-rows--conversation", { args: { scenario: "location" } })
@@ -14,12 +14,10 @@ story("renders the moved location notice in its compact timeline style", async (
await expect(value).toHaveText(directory)
await expect(notice).not.toContainText("·")
await expect(notice.locator("svg")).toHaveCount(0)
await expect(notice).toHaveCSS("height", "28px")
await expect(notice).toHaveCSS("gap", "8px")
await expect(notice).toHaveCSS("padding-top", "4px")
await expect(notice).toHaveCSS("padding-bottom", "4px")
await expect(notice).toHaveCSS("padding-top", "8px")
await expect(notice).toHaveCSS("padding-bottom", "8px")
await expect(label).toHaveCSS("font-size", "13px")
await expect(label).toHaveCSS("font-weight", "530")
await expect(label).toHaveCSS("font-weight", "440")
await expect(label).toHaveCSS("line-height", "16px")
await expect(label).toHaveCSS("color", "rgb(128, 128, 128)")
await expect(value).toHaveCSS("font-size", "13px")
@@ -1,7 +1,25 @@
import { ProviderIcon } from "@opencode/ui/provider-icon"
import { Tooltip } from "@opencode/ui/tooltip"
import { Show } from "solid-js"
export function TimelineSeparator(props: { label: string; providerID?: string; variant?: string }) {
export function TimelineSeparator(props: {
label: string
value?: string
tooltip?: string
providerID?: string
variant?: string
}) {
const label = () => (
<bdi
data-slot="session-timeline-notice-label"
dir="auto"
class="block truncate"
classList={{ "shrink-0": !!props.value }}
title={props.tooltip ? undefined : props.label}
>
{props.label}
</bdi>
)
return (
<div class="flex h-8 w-full items-center gap-3 text-v2-text-text-faint">
<span class="h-px min-w-0 flex-1 bg-v2-border-border-strong" />
@@ -10,9 +28,26 @@ export function TimelineSeparator(props: { label: string; providerID?: string; v
{(providerID) => <ProviderIcon id={providerID()} class="text-v2-icon-icon-faint" aria-hidden="true" />}
</Show>
<span class="flex min-w-0 items-center gap-1.5">
<bdi dir="auto" class="truncate" title={props.label}>
{props.label}
</bdi>
<Show when={props.tooltip} fallback={label()}>
{(tooltip) => (
<Tooltip
appearance="compact"
placement="top"
value={tooltip()}
class={props.value ? "min-w-0 shrink-0" : "min-w-0"}
triggerTabIndex={0}
>
{label()}
</Tooltip>
)}
</Show>
<Show when={props.value}>
{(value) => (
<bdi data-slot="session-timeline-notice-value" dir="ltr" class="min-w-0 truncate" title={value()}>
{value()}
</bdi>
)}
</Show>
<Show when={props.variant && props.variant !== "default" ? props.variant : undefined}>
{(variant) => (
<>
@@ -271,7 +271,12 @@ export namespace Timeline {
detail,
new Set(
messages
.filter((message) => message.type === "compaction" || message.type === "model-switched")
.filter(
(message) =>
message.type === "compaction" ||
message.type === "model-switched" ||
message.type === "location-switched",
)
.map((message) => message.id),
),
)
@@ -5,6 +5,7 @@ import type {
SessionMessageInfo,
} from "@opencode/client/promise"
import { storyDocument, storyTool } from "../storybook/current-session-scenarios"
import { timelinePresets } from "./detail"
import { createTimelineProjection, Timeline, TimelineRow } from "./projection"
describe("current session timeline rows", () => {
@@ -333,6 +334,39 @@ describe("current session timeline rows", () => {
])
})
test("keeps divider notices outside grouped context rows", () => {
const source = [
{ id: "msg_user", type: "user", text: "move", time: { created: 1 } },
{
id: "msg_assistant",
type: "assistant",
agent: "build",
model: { id: "model", providerID: "provider" },
content: [storyTool("tool_read", "read", "completed", {})],
time: { created: 2, completed: 3 },
},
{ id: "msg_moved", type: "location-switched", location: { directory: "/tmp/next" }, time: { created: 4 } },
{ id: "msg_skill", type: "skill", skill: "review", name: "Review", text: "instructions", time: { created: 5 } },
] satisfies SessionMessageInfo[]
const rows = Timeline.constructSessionMessageRows(
source,
false,
{ type: "idle" },
undefined,
false,
false,
undefined,
timelinePresets.find((preset) => preset.id === "compact")!.value,
).rows
expect(rows.map(TimelineRow.key)).toEqual([
"user-message:msg_user",
"assistant-part:context:context:msg_assistant:tool_read",
"notice:msg_moved",
"assistant-part:context:message:msg_skill",
])
})
test("keeps assistant errors and retries before later notices", () => {
const result = Timeline.constructSessionMessageRows(
[
@@ -5,7 +5,6 @@ import type {
SessionStatus,
} from "@opencode/client/promise"
import { useI18n } from "@opencode/ui/context/i18n"
import { Tooltip } from "@opencode/ui/tooltip"
import { For, Show, createMemo, type Accessor, type JSX } from "solid-js"
import { Dynamic } from "solid-js/web"
import type { SessionUserActions, SessionUserAttachmentReference, SessionUserComment } from "../actions"
@@ -522,25 +521,12 @@ export function createSessionTimelineRowRenderer(input: {
}
>
{(message) => (
<div
data-slot="session-timeline-notice"
data-type="location-switched"
class={`flex h-7 w-full min-w-0 items-center gap-2 py-1 text-[13px] leading-text-compact tracking-[-0.04px] text-v2-text-text-faint ${inset()}`}
>
<Tooltip
appearance="compact"
placement="top"
value={i18n.t("ui.sessionTimeline.notice.movedTooltip")}
class="shrink-0"
triggerTabIndex={0}
>
<bdi data-slot="session-timeline-notice-label" dir="auto" class="font-[530]">
{i18n.t("ui.sessionTimeline.notice.movedTo")}
</bdi>
</Tooltip>{" "}
<bdi data-slot="session-timeline-notice-value" dir="ltr" class="min-w-0 truncate font-[440]">
{message().location.directory}
</bdi>
<div data-slot="session-timeline-notice" data-type="location-switched" class={`w-full py-2 ${inset()}`}>
<TimelineSeparator
label={i18n.t("ui.sessionTimeline.notice.movedTo")}
value={message().location.directory}
tooltip={i18n.t("ui.sessionTimeline.notice.movedTooltip")}
/>
</div>
)}
</Show>
@@ -455,7 +455,7 @@ const MovedLocation = {
render: () => (
<CurrentSessionTimelineStory
title="Moved Session location"
description="A changed working directory stays compact, truncates, and exposes its tooltip."
description="A changed working directory renders as a timeline divider, truncates, and exposes its tooltip."
document={{
...thinkingDocument,
status: { type: "idle" },