fix(app): no spinner on subagent rows in the new timeline (#64132)

This commit is contained in:
Dax
2026-11-15 18:00:39 -05:00
committed by GitHub
Unverified
parent b1acf7ed5c
commit 5d55571d8d
7 changed files with 13 additions and 59 deletions
@@ -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 and spins only while the work runs", async ({ mount }) => {
story("a subagent row leads with its status chip", 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"]')
@@ -19,14 +19,14 @@ story("a subagent row leads with its status chip and spins only while the work r
])
// Agent names are capitalized by CSS, so their text is as configured.
await expect(rows.nth(3).locator("> *")).toHaveText(["Completed", "review Agent", "Review the theme store"])
// Every subagent here has reported back, so no start spins.
await expect(rows.locator('[data-component="session-progress-indicator-v2"]')).toHaveCount(0)
})
story("a start whose subagent has not reported back spins", async ({ mount }) => {
// The timeline is a list of events: a start keeps its ring 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('[data-component="session-progress-indicator-v2"]')).toHaveCount(1)
await expect(status.locator('svg[data-slot="timeline-event-item-glyph"] circle')).toHaveCount(1)
await expect(status.locator('[data-component="session-progress-indicator-v2"]')).toHaveCount(0)
})
@@ -1,4 +1,3 @@
import type { SessionStatus } from "@opencode/client/promise"
import type { SessionDocument } from "../document"
import { File } from "../components/file"
import { DataProvider, type ReadMediaUrlFn, type TurnDiffSource } from "../context/data"
@@ -15,8 +14,6 @@ export function CurrentSessionProviders(props: {
backgroundCompaction?: boolean
readMedia?: ReadMediaUrlFn
turnDiff?: TurnDiffSource
/** Other sessions' statuses, such as the subagents a replay has started. */
sessionStatus?: Record<string, SessionStatus>
children: JSX.Element
}) {
return (
@@ -78,7 +75,6 @@ export function CurrentSessionProviders(props: {
[CURRENT_SESSION_ID]: props.document.status,
session_child_review: { type: "idle" },
session_child_tests: { type: "busy" },
...props.sessionStatus,
},
session_diff: { [CURRENT_SESSION_ID]: props.document.diffs },
}}
@@ -4,7 +4,6 @@ import { For, Match, Show, Switch, createMemo } from "solid-js"
import { BasicTool } from "../components/basic-tool"
import { useData } from "../context/data"
import { taskAgentName } from "../tools/tool-renderer"
import { SessionProgressIndicatorV2 } from "../v2/components/session-progress-indicator-v2"
import { summarizeShells, verbKeys, type TimelineEvent } from "./events"
/**
@@ -81,12 +80,7 @@ const statusKeys = {
} as const
/** One subagent or shell an events row or an opened activity group lists: who did it and what it was. */
export function TimelineEventItem(props: {
event: TimelineEvent
/** The subagent this start launched is still working. */
running?: boolean
onRevealShell?: (shellID: string) => void
}) {
export function TimelineEventItem(props: { event: TimelineEvent; onRevealShell?: (shellID: string) => void }) {
const i18n = useI18n()
const data = useData()
@@ -140,12 +134,10 @@ export function TimelineEventItem(props: {
open()
}}
>
{/* A subagent leads with its status chip; a still-running start spins instead of showing its ring. */}
{/* A subagent leads with its status chip. */}
<Show when={props.event.kind === "subagent"}>
<span data-slot="timeline-event-item-status" data-state={state()}>
<Show when={props.running && state() === "started"} fallback={<StatusGlyph state={state()} />}>
<SessionProgressIndicatorV2 width={12} height={12} />
</Show>
<StatusGlyph state={state()} />
{i18n.t(statusKeys[state()])}
</span>
</Show>
+2 -23
View File
@@ -50,7 +50,7 @@ import { attached } from "../components/message-file"
import { CompactionMessage, CompactionQueued } from "./compaction"
import { unwrapErrorMessage } from "./errors"
import { TimelineEventItem, TimelineEventRow } from "./event-row"
import { noticeEvent, toolEvent, type TimelineEvent } from "./events"
import { noticeEvent, toolEvent } from "./events"
import { trackNestedRails } from "./nested-rail"
import { contentEntries, createNextTimelineProjection, resolveContent, workedDuration } from "./projection"
import { contentOpens, diffOpens, goal as goalMessage, movedInPlace, thoughtOpens, toolRule } from "./rules"
@@ -119,27 +119,6 @@ export function createNextTimelineRowRenderer(input: {
}
})
// Subagents that have reported back, by their session: a finish or stop notice ends the work its start launched.
const reported = createMemo(
() =>
new Set(
turns().messages.flatMap((message) => {
const sessionID = message.type === "synthetic" ? noticeEvent(message)?.sessionID : undefined
return sessionID ? [sessionID] : []
}),
),
)
// A start spins while its subagent has not reported back and its session is still working.
const running = (event: TimelineEvent) => {
const id = event.sessionID
if (event.verb !== "started" || event.failed || !id || reported().has(id)) return false
return (data.store.session_status[id]?.type ?? "idle") !== "idle"
}
const patchOwners = createMemo(() => {
const owners = new Map<string, string>()
const rows = input.projection.rows()
@@ -462,7 +441,7 @@ export function createNextTimelineRowRenderer(input: {
<Show when={events()[0]}>
{(event) => (
<div data-component="timeline-subagent">
<TimelineEventItem event={event()} running={running(event())} />
<TimelineEventItem event={event()} />
</div>
)}
</Show>
@@ -228,7 +228,7 @@ export const Playground = {
</div>
<div class="min-h-0 flex-1 overflow-y-auto" data-scrollable>
<div class="mx-auto py-6" style={{ "max-width": `${state.width}px` }}>
<CurrentSessionProviders document={replay().document} sessionStatus={replay().children}>
<CurrentSessionProviders document={replay().document}>
<Show
when={state.activity}
fallback={
@@ -1,13 +1,11 @@
import type {
JsonValue,
SessionMessageAssistant,
SessionStatus,
SessionMessageAssistantTool,
SessionMessageInfo,
} from "@opencode/client/promise"
import { createTwoFilesPatch, diffLines } from "diff"
import type { SessionDocument } from "../../document"
import { toolEvent } from "../events"
import {
CURRENT_SESSION_ID,
STORY_MODEL,
@@ -831,8 +829,6 @@ export function replayScript(script: Beat[], limit: number, start: number) {
const messages: SessionMessageInfo[] = []
// SAFETY: no step is open yet; the assertion names the step this holds once one starts.
const state = { used: 0, busy: false, caption: "Start", assistant: undefined as SessionMessageAssistant | undefined }
// Subagent sessions the replay has started, working until they report back.
const children: Record<string, SessionStatus> = {}
const at = () => start + state.used * 1_500
const id = (prefix: string) => `${prefix}_${messages.length}_${state.used}`
@@ -911,7 +907,6 @@ export function replayScript(script: Beat[], limit: number, start: number) {
if (beat.kind === "report" && beat.source === "subagent") {
closeStep()
messages.push(subagentReport(id("msg_report"), at(), beat))
children[beat.childID] = { type: "idle" }
state.busy = true
}
@@ -951,13 +946,7 @@ export function replayScript(script: Beat[], limit: number, start: number) {
if (beat.kind === "say")
assistant().content.push({ type: "text", text: done ? beat.text : beat.text.slice(0, beat.text.length / 2) })
if (beat.kind === "tool") {
const call = tool(id("tool"), beat, done, at())
const sessionID = beat.name === "subagent" ? toolEvent(call)?.sessionID : undefined
assistant().content.push(call)
if (sessionID) children[sessionID] = { type: "busy" }
}
if (beat.kind === "tool") assistant().content.push(tool(id("tool"), beat, done, at()))
if (beat.kind === "interrupt" && state.assistant) {
state.assistant.content = state.assistant.content.map((content) =>
@@ -993,7 +982,6 @@ export function replayScript(script: Beat[], limit: number, start: number) {
status: { type: state.busy ? "busy" : "idle" },
diffs: [],
} satisfies SessionDocument,
children: { ...children },
caption: state.caption,
}
}
@@ -311,8 +311,7 @@
line-height: 16px;
white-space: nowrap;
[data-slot="timeline-event-item-glyph"],
[data-component="session-progress-indicator-v2"] {
[data-slot="timeline-event-item-glyph"] {
flex-shrink: 0;
width: 12px;
height: 12px;