mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-20 18:57:17 +03:00
fix(session-ui): show subagent status as a colored bar and word in the New timeline (#65164)
This commit is contained in:
committed by
GitHub
Unverified
parent
80d7c17d8e
commit
85951cb086
@@ -2,7 +2,7 @@ import { expect, story } from "../../stories/playwright/story"
|
||||
|
||||
const playground = "timeline-playground--playground"
|
||||
|
||||
story("a subagent row leads with its status chip", async ({ mount }) => {
|
||||
story("a subagent row leads with its status", async ({ mount }) => {
|
||||
const timeline = await mount(playground, { args: { scenario: "Background work", activity: true } })
|
||||
const rows = timeline.locator('[data-component="timeline-subagent"] > [data-slot="timeline-event-item"]')
|
||||
|
||||
@@ -21,12 +21,13 @@ story("a subagent row leads with its status chip", async ({ mount }) => {
|
||||
await expect(rows.nth(3).locator("> *")).toHaveText(["Completed", "review Agent", "Review the theme store"])
|
||||
})
|
||||
|
||||
// The timeline is a list of events: a start keeps its ring even while its subagent has not reported back.
|
||||
// The timeline is a list of events: a start stays a plain status even while its subagent has not reported back.
|
||||
story("a started subagent never spins", async ({ mount }) => {
|
||||
const timeline = await mount(playground, { args: { scenario: "Subagent between tools", activity: true } })
|
||||
const status = timeline.locator('[data-component="timeline-subagent"] [data-slot="timeline-event-item-status"]')
|
||||
|
||||
await expect(status).toHaveText("Started")
|
||||
await expect(status.locator('svg[data-slot="timeline-event-item-glyph"] circle')).toHaveCount(1)
|
||||
await expect(status).toHaveAttribute("data-state", "started")
|
||||
await expect(status.locator("svg")).toHaveCount(0)
|
||||
await expect(status.locator('[data-component="session-progress-indicator-v2"]')).toHaveCount(0)
|
||||
})
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Badge } from "@opencode/ui/badge"
|
||||
import { useI18n } from "@opencode/ui/context/i18n"
|
||||
import { For, Match, Show, Switch, createMemo } from "solid-js"
|
||||
import { For, Show, createMemo } from "solid-js"
|
||||
import { BasicTool } from "../components/basic-tool"
|
||||
import { useData } from "../context/data"
|
||||
import { taskAgentName } from "../tools/tool-renderer"
|
||||
@@ -134,10 +134,9 @@ export function TimelineEventItem(props: { event: TimelineEvent; onRevealShell?:
|
||||
open()
|
||||
}}
|
||||
>
|
||||
{/* A subagent leads with its status chip. */}
|
||||
{/* A subagent leads with its status. */}
|
||||
<Show when={props.event.kind === "subagent"}>
|
||||
<span data-slot="timeline-event-item-status" data-state={state()}>
|
||||
<StatusGlyph state={state()} />
|
||||
{i18n.t(statusKeys[state()])}
|
||||
</span>
|
||||
</Show>
|
||||
@@ -153,40 +152,3 @@ export function TimelineEventItem(props: { event: TimelineEvent; onRevealShell?:
|
||||
</a>
|
||||
)
|
||||
}
|
||||
|
||||
/** The status chip's glyph: ring, ↻, ✓, ✕ or ■, drawn at 12px in the chip's text color. */
|
||||
function StatusGlyph(props: { state: SubagentState }) {
|
||||
return (
|
||||
<svg data-slot="timeline-event-item-glyph" viewBox="0 0 16 16" fill="none" aria-hidden="true">
|
||||
<Switch>
|
||||
<Match when={props.state === "started"}>
|
||||
<circle cx="8" cy="8" r="4.5" stroke="currentColor" stroke-width="1.4" />
|
||||
</Match>
|
||||
<Match when={props.state === "updated"}>
|
||||
<path
|
||||
d="M12.5 8a4.5 4.5 0 1 1-1.4-3.25M12.5 3v2.5H10"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.6"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
/>
|
||||
</Match>
|
||||
<Match when={props.state === "completed"}>
|
||||
<path
|
||||
d="M3.8 8.3l2.7 2.7 5.7-6"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.6"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
/>
|
||||
</Match>
|
||||
<Match when={props.state === "failed"}>
|
||||
<path d="M5 5l6 6M11 5l-6 6" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" />
|
||||
</Match>
|
||||
<Match when={props.state === "stopped"}>
|
||||
<rect x="4.75" y="4.75" width="6.5" height="6.5" rx="1.2" fill="currentColor" />
|
||||
</Match>
|
||||
</Switch>
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
import { For, type JSX } from "solid-js"
|
||||
import { CurrentSessionProviders } from "../../storybook/current-session-story"
|
||||
import { storyDocument } from "../../storybook/current-session-scenarios"
|
||||
import { TimelineEventItem } from "../event-row"
|
||||
import type { TimelineEvent } from "../events"
|
||||
|
||||
/**
|
||||
* The status a subagent row in the New timeline leads with, in each state it can show: started, updated (a
|
||||
* follow-up to a running task), completed, failed and stopped.
|
||||
*/
|
||||
export default {
|
||||
title: "OpenCode/Timeline/Subagent status",
|
||||
id: "timeline-subagent-status",
|
||||
parameters: { layout: "fullscreen" },
|
||||
}
|
||||
|
||||
const subagent = (event: Omit<TimelineEvent, "kind">): TimelineEvent => ({ kind: "subagent", ...event })
|
||||
|
||||
const states = [
|
||||
{
|
||||
label: "Started",
|
||||
event: subagent({ verb: "started", failed: false, agent: "explore", title: "Map the timeline grouping rules" }),
|
||||
},
|
||||
{
|
||||
label: "Updated",
|
||||
event: subagent({ verb: "updated", failed: false, agent: "review", title: "Also check the RTL layout" }),
|
||||
},
|
||||
{
|
||||
label: "Completed (background)",
|
||||
event: subagent({ verb: "finished", failed: false, agent: "test", title: "Run the focused timeline tests" }),
|
||||
},
|
||||
{
|
||||
label: "Completed (foreground)",
|
||||
event: subagent({ verb: "ran", failed: false, agent: "build", title: "Regenerate the SDK" }),
|
||||
},
|
||||
{
|
||||
label: "Failed",
|
||||
event: subagent({ verb: "finished", failed: true, agent: "test", title: "Run the e2e suite" }),
|
||||
},
|
||||
{
|
||||
label: "Stopped",
|
||||
event: subagent({ verb: "stopped", failed: false, agent: "explore", title: "Search for unused exports" }),
|
||||
},
|
||||
]
|
||||
|
||||
const edges = [
|
||||
{
|
||||
label: "Long title",
|
||||
event: subagent({
|
||||
verb: "started",
|
||||
failed: false,
|
||||
agent: "explore",
|
||||
title:
|
||||
"Find every place the timeline projection groups tool calls, including the legacy renderer and the replay fixtures, and summarize how each handles background work",
|
||||
}),
|
||||
},
|
||||
{ label: "No agent", event: subagent({ verb: "finished", failed: false, title: "Summarize the open issues" }) },
|
||||
{ label: "No title", event: subagent({ verb: "stopped", failed: false, agent: "review" }) },
|
||||
{
|
||||
label: "Right-to-left title",
|
||||
event: subagent({ verb: "finished", failed: true, agent: "translator", title: "ترجمة سلاسل الواجهة إلى العربية" }),
|
||||
},
|
||||
]
|
||||
|
||||
function Timeline(props: { children: JSX.Element }) {
|
||||
return (
|
||||
<CurrentSessionProviders document={storyDocument([])}>
|
||||
<div data-timeline="next" class="mx-auto flex w-full max-w-[720px] flex-col gap-8 px-6 py-8">
|
||||
{props.children}
|
||||
</div>
|
||||
</CurrentSessionProviders>
|
||||
)
|
||||
}
|
||||
|
||||
function Section(props: { title: string; children: JSX.Element }) {
|
||||
return (
|
||||
<section class="flex flex-col gap-3">
|
||||
<h2 class="text-[13px] leading-text-compact font-[530] text-v2-text-text-muted">{props.title}</h2>
|
||||
{props.children}
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
function Rows(props: { items: { label: string; event: TimelineEvent }[] }) {
|
||||
return (
|
||||
<div class="grid grid-cols-[max-content_minmax(0,1fr)] items-center gap-x-6 gap-y-3">
|
||||
<For each={props.items}>
|
||||
{(item) => (
|
||||
<>
|
||||
<span class="text-[12px] leading-text-compact text-v2-text-text-faint">{item.label}</span>
|
||||
<div data-component="timeline-subagent">
|
||||
<TimelineEventItem event={item.event} />
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</For>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export const AllStates = {
|
||||
render: () => (
|
||||
<Timeline>
|
||||
<Section title="States">
|
||||
<Rows items={states} />
|
||||
</Section>
|
||||
<Section title="Edge cases">
|
||||
<Rows items={edges} />
|
||||
</Section>
|
||||
</Timeline>
|
||||
),
|
||||
}
|
||||
|
||||
export const Narrow = {
|
||||
render: () => (
|
||||
<div class="max-w-[360px]">
|
||||
<Timeline>
|
||||
<Section title="States at 360px">
|
||||
<div class="flex flex-col gap-4">
|
||||
<For each={[...states, ...edges]}>
|
||||
{(item) => (
|
||||
<div data-component="timeline-subagent">
|
||||
<TimelineEventItem event={item.event} />
|
||||
</div>
|
||||
)}
|
||||
</For>
|
||||
</div>
|
||||
</Section>
|
||||
</Timeline>
|
||||
</div>
|
||||
),
|
||||
}
|
||||
@@ -261,12 +261,6 @@
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
&:hover [data-slot="timeline-event-item-title"] {
|
||||
text-decoration: underline;
|
||||
text-decoration-color: color-mix(in oklch, currentColor 40%, transparent);
|
||||
text-underline-offset: 2px;
|
||||
}
|
||||
|
||||
&:focus-visible {
|
||||
outline: 2px solid var(--v2-border-border-focus);
|
||||
outline-offset: 2px;
|
||||
@@ -294,54 +288,42 @@
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* A subagent's status chip: its outline, fill and glyph say what happened, so no status word follows the title.
|
||||
Updated is info blue softened toward muted; the others use their state colors as they are. */
|
||||
/* A subagent's status: a bar and word, in the state's color, say what happened, so no status word follows the
|
||||
title. Updated is info blue softened toward muted; the others use their state colors as they are. */
|
||||
[data-slot="timeline-event-item-status"] {
|
||||
box-sizing: border-box;
|
||||
display: inline-flex;
|
||||
flex-shrink: 0;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
height: 18px;
|
||||
padding: 0 6px;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 4px;
|
||||
font-size: 12px;
|
||||
gap: 6px;
|
||||
font-weight: 530;
|
||||
line-height: 16px;
|
||||
white-space: nowrap;
|
||||
|
||||
[data-slot="timeline-event-item-glyph"] {
|
||||
&::before {
|
||||
content: "";
|
||||
flex-shrink: 0;
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
margin-left: -1px;
|
||||
color: currentColor;
|
||||
width: 3px;
|
||||
height: 10px;
|
||||
border-radius: 999px;
|
||||
background: currentColor;
|
||||
}
|
||||
|
||||
&[data-state="started"] {
|
||||
border-color: color-mix(in srgb, var(--v2-text-text-muted) 35%, transparent);
|
||||
color: var(--v2-text-text-faint);
|
||||
}
|
||||
|
||||
&[data-state="updated"] {
|
||||
border-style: dashed;
|
||||
border-color: color-mix(in srgb, var(--v2-state-fg-info) 50%, transparent);
|
||||
color: color-mix(in srgb, var(--v2-state-fg-info) 70%, var(--v2-text-text-muted));
|
||||
}
|
||||
|
||||
&[data-state="completed"] {
|
||||
background: color-mix(in srgb, var(--v2-state-fg-success) 16%, transparent);
|
||||
color: var(--v2-state-fg-success);
|
||||
}
|
||||
|
||||
&[data-state="failed"] {
|
||||
background: var(--v2-state-bg-danger);
|
||||
color: var(--v2-state-fg-danger);
|
||||
}
|
||||
|
||||
&[data-state="stopped"] {
|
||||
border-color: color-mix(in srgb, var(--v2-text-text-muted) 55%, transparent);
|
||||
color: var(--v2-text-text-muted);
|
||||
}
|
||||
}
|
||||
@@ -377,16 +359,6 @@
|
||||
|
||||
> [data-slot="timeline-event-item"] {
|
||||
gap: 8px;
|
||||
margin-inline: -6px;
|
||||
padding-inline: 6px;
|
||||
border-radius: var(--radius-sm);
|
||||
|
||||
@media (hover: hover) {
|
||||
&:hover:not([aria-disabled]) {
|
||||
cursor: pointer;
|
||||
background-color: var(--v2-overlay-simple-overlay-hover);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user