GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(app): keep subagent rows in order inside grouped activity in the … · dshaw/opencode@f413b30

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages/session-ui/src/timeline-next/tools
    • context-group.tsx
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/session-ui/src/timeline-next/tools/context-group.tsx‎

Copy file name to clipboardExpand all lines: packages/session-ui/src/timeline-next/tools/context-group.tsx
+20-10Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ export function ContextGroup(props: {
6262
const tools = createMemo(() => props.parts.filter((part) => part.type === "tool"))
6363
const reasoning = createMemo(() => props.parts.flatMap((part) => (part.type === "reasoning" ? [part] : [])))
6464
const thoughtsOnly = createMemo(() => reasoning().length > 0 && reasoning().length === props.parts.length)
65-
const partEvents = createMemo(() => workEvents(props.parts))
66-
const events = createMemo(() => [...partEvents().values()])
65+
const events = createMemo(() => [...workEvents(props.parts).values()])
6766

6867
// A group of only subagents and work reporting back reads as the events row it is, not a group around one. Until a
6968
// call has anything to count, it stays a group, so the row never renders empty.
@@ -97,16 +96,27 @@ export function ContextGroup(props: {
9796
const previous = groups.at(-1)
9897

9998
// Subagents started one after another, and work reporting back, read as one events row nested in the group:
100-
// "Started 3 subagents".
99+
// "Started 3 subagents". The rows keep the order things happened in, which the label does not.
101100
if (tool.type === "event" || (tool.type === "tool" && toolRule(tool).name === "subagent")) {
102-
// A subagent still being asked for has nothing to list yet, and a report its launch already says is not
103-
// listed twice.
104-
const event = partEvents().get(tool)
101+
// A subagent still being asked for has nothing to list yet.
102+
const event = tool.type === "event" ? tool.event : toolEvent(tool)
105103

106104
if (!event) return groups
105+
const run = previous && !Array.isArray(previous) && previous.type === "work" ? previous : undefined
106+
const key = tool.type === "event" ? workKey(event) : undefined
107107

108-
if (previous && !Array.isArray(previous) && previous.type === "work") {
109-
previous.events.push(event)
108+
// Work reporting back right after its launch, with nothing between, finishes the launch's row. With
109+
// anything between, the launch and the report each keep their row.
110+
const launch = key && run ? run.events.findIndex((item) => item.verb === "started" && workKey(item) === key) : -1
111+
112+
if (run && launch >= 0) {
113+
run.events[launch] = { ...run.events[launch]!, verb: event.verb, failed: event.failed }
114+
115+
return groups
116+
}
117+
118+
if (run) {
119+
run.events.push(event)
110120

111121
return groups
112122
}
@@ -534,8 +544,8 @@ function usedLabel(parts: ActivityGroupPart[], i18n: UiI18n) {
534544
}
535545

536546
/**
537-
* What each subagent or background shell in a group did, in order. Work that reports back in the group that started
538-
* it reads once, as how it ended: the launch says "Finished" and the report is not counted again.
547+
* What each subagent or background shell in a group did, for its label. Work that reports back anywhere in the group
548+
* that started it is counted once, as how it ended: "Finished", not "Started" and "Finished".
539549
*/
540550
function workEvents(parts: ActivityGroupPart[]) {
541551
const launch = (part: ActivityGroupPart) =>

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.