@sixb/app 0.1.14 → 0.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. package/dist/agent/agent-chat.d.ts +8 -1
  2. package/dist/agent/agent-chat.d.ts.map +1 -1
  3. package/dist/agent/agent-panel.d.ts +8 -1
  4. package/dist/agent/agent-panel.d.ts.map +1 -1
  5. package/dist/agent/agent-surface.d.ts +8 -1
  6. package/dist/agent/agent-surface.d.ts.map +1 -1
  7. package/dist/agent/approvals.d.ts +1 -4
  8. package/dist/agent/approvals.d.ts.map +1 -1
  9. package/dist/agent/artifact-panel.d.ts +21 -2
  10. package/dist/agent/artifact-panel.d.ts.map +1 -1
  11. package/dist/agent/components/activity-status.d.ts +1 -1
  12. package/dist/agent/components/activity-status.d.ts.map +1 -1
  13. package/dist/agent/components/agent-threads.d.ts +15 -0
  14. package/dist/agent/components/agent-threads.d.ts.map +1 -0
  15. package/dist/agent/components/approval-card.d.ts +4 -4
  16. package/dist/agent/components/approval-card.d.ts.map +1 -1
  17. package/dist/agent/components/approval-mode-chip.d.ts +4 -6
  18. package/dist/agent/components/approval-mode-chip.d.ts.map +1 -1
  19. package/dist/agent/components/auto-model-chip.d.ts +2 -3
  20. package/dist/agent/components/auto-model-chip.d.ts.map +1 -1
  21. package/dist/agent/components/composer-menu.d.ts +42 -0
  22. package/dist/agent/components/composer-menu.d.ts.map +1 -0
  23. package/dist/agent/components/composer.d.ts +8 -5
  24. package/dist/agent/components/composer.d.ts.map +1 -1
  25. package/dist/agent/components/conversation-panel.d.ts +3 -12
  26. package/dist/agent/components/conversation-panel.d.ts.map +1 -1
  27. package/dist/agent/components/dictation-bar.d.ts +13 -0
  28. package/dist/agent/components/dictation-bar.d.ts.map +1 -0
  29. package/dist/agent/components/message-parts.d.ts.map +1 -1
  30. package/dist/agent/components/message-view.d.ts +3 -1
  31. package/dist/agent/components/message-view.d.ts.map +1 -1
  32. package/dist/agent/components/model-controls.d.ts +15 -0
  33. package/dist/agent/components/model-controls.d.ts.map +1 -1
  34. package/dist/agent/components/model-picker-row.d.ts +9 -2
  35. package/dist/agent/components/model-picker-row.d.ts.map +1 -1
  36. package/dist/agent/components/participant-input.d.ts +7 -6
  37. package/dist/agent/components/participant-input.d.ts.map +1 -1
  38. package/dist/agent/components/thread-people.d.ts +4 -4
  39. package/dist/agent/components/thread-people.d.ts.map +1 -1
  40. package/dist/agent/components/threads-button.d.ts +14 -0
  41. package/dist/agent/components/threads-button.d.ts.map +1 -0
  42. package/dist/agent/conversation.d.ts +3 -1
  43. package/dist/agent/conversation.d.ts.map +1 -1
  44. package/dist/agent/delegation/child-card.d.ts +24 -11
  45. package/dist/agent/delegation/child-card.d.ts.map +1 -1
  46. package/dist/agent/delegation/child-cards.d.ts +2 -2
  47. package/dist/agent/delegation/child-cards.d.ts.map +1 -1
  48. package/dist/agent/delegation/child-group.d.ts +5 -4
  49. package/dist/agent/delegation/child-group.d.ts.map +1 -1
  50. package/dist/agent/delegation/child-parts.d.ts +17 -18
  51. package/dist/agent/delegation/child-parts.d.ts.map +1 -1
  52. package/dist/agent/delegation/child-work.d.ts +0 -13
  53. package/dist/agent/delegation/child-work.d.ts.map +1 -1
  54. package/dist/agent/delegation/interpret.d.ts +0 -5
  55. package/dist/agent/delegation/interpret.d.ts.map +1 -1
  56. package/dist/agent/delegation/model.d.ts +12 -6
  57. package/dist/agent/delegation/model.d.ts.map +1 -1
  58. package/dist/agent/dictation.d.ts +16 -0
  59. package/dist/agent/dictation.d.ts.map +1 -0
  60. package/dist/agent/hooks/use-agent-conversation.d.ts +3 -270
  61. package/dist/agent/hooks/use-agent-conversation.d.ts.map +1 -1
  62. package/dist/agent/hooks/use-people-suggestions.d.ts +21 -0
  63. package/dist/agent/hooks/use-people-suggestions.d.ts.map +1 -0
  64. package/dist/agent/hooks/use-thread-lists.d.ts +220 -0
  65. package/dist/agent/hooks/use-thread-lists.d.ts.map +1 -0
  66. package/dist/agent/i18n/en.d.ts +47 -36
  67. package/dist/agent/i18n/en.d.ts.map +1 -1
  68. package/dist/agent/i18n/fr.d.ts.map +1 -1
  69. package/dist/agent/i18n/index.d.ts +84 -72
  70. package/dist/agent/i18n/index.d.ts.map +1 -1
  71. package/dist/agent/react-router.d.ts +9 -0
  72. package/dist/agent/react-router.d.ts.map +1 -1
  73. package/dist/agent/run-presentation.d.ts +4 -1
  74. package/dist/agent/run-presentation.d.ts.map +1 -1
  75. package/dist/agent/thread-navigation.d.ts +8 -0
  76. package/dist/agent/thread-navigation.d.ts.map +1 -1
  77. package/dist/agent/thread-pages.d.ts +11 -0
  78. package/dist/agent/thread-pages.d.ts.map +1 -0
  79. package/dist/artifacts/person-avatar.d.ts +2 -2
  80. package/dist/{chunk-aes17xmx.js → chunk-12v6y89k.js} +4180 -3793
  81. package/dist/{chunk-aes17xmx.js.map → chunk-12v6y89k.js.map} +48 -42
  82. package/dist/{chunk-0yb22w6m.js → chunk-2a69ge8h.js} +1 -1
  83. package/dist/{chunk-vtp6nk44.js → chunk-bpj9mg5c.js} +1 -1
  84. package/dist/{chunk-1rhht9y0.js → chunk-hzy2g13h.js} +1 -1
  85. package/dist/createCustomApp.d.ts.map +1 -1
  86. package/dist/index.d.ts +2 -1
  87. package/dist/index.d.ts.map +1 -1
  88. package/dist/index.js +19 -6
  89. package/dist/index.js.map +6 -6
  90. package/dist/pages/home.d.ts.map +1 -1
  91. package/dist/pages/observability/ai-usage/calls.d.ts.map +1 -1
  92. package/dist/pages/settings/memory-history.d.ts.map +1 -1
  93. package/dist/pages/settings/messages.d.ts.map +1 -1
  94. package/dist/pages/values.d.ts +5 -0
  95. package/dist/pages/values.d.ts.map +1 -1
  96. package/dist/pages.d.ts +1 -1
  97. package/dist/pages.d.ts.map +1 -1
  98. package/dist/pages.js +60 -44
  99. package/dist/pages.js.map +8 -8
  100. package/dist/server.js +12 -6
  101. package/dist/server.js.map +3 -3
  102. package/dist/shell/agent-dock.d.ts.map +1 -1
  103. package/package.json +4 -4
  104. package/src/agent/agent-chat.tsx +15 -23
  105. package/src/agent/agent-panel.tsx +11 -0
  106. package/src/agent/agent-surface.tsx +11 -0
  107. package/src/agent/agent.css +33 -3
  108. package/src/agent/approvals.ts +4 -5
  109. package/src/agent/artifact-panel.tsx +113 -37
  110. package/src/agent/components/activity-status.tsx +1 -1
  111. package/src/agent/components/agent-threads.tsx +377 -0
  112. package/src/agent/components/approval-card.tsx +336 -327
  113. package/src/agent/components/approval-mode-chip.tsx +38 -145
  114. package/src/agent/components/auto-model-chip.tsx +103 -167
  115. package/src/agent/components/composer-menu.tsx +185 -0
  116. package/src/agent/components/composer.tsx +168 -103
  117. package/src/agent/components/context-chips.tsx +1 -1
  118. package/src/agent/components/conversation-panel.tsx +16 -36
  119. package/src/agent/components/dictation-bar.tsx +110 -0
  120. package/src/agent/components/file-attachment-card.tsx +5 -2
  121. package/src/agent/components/message-parts.tsx +27 -11
  122. package/src/agent/components/message-view.tsx +182 -68
  123. package/src/agent/components/model-controls.tsx +133 -125
  124. package/src/agent/components/model-picker-row.tsx +38 -17
  125. package/src/agent/components/participant-input.tsx +159 -31
  126. package/src/agent/components/reasoning-effort-slider.tsx +27 -27
  127. package/src/agent/components/shared-thread-notice.tsx +1 -1
  128. package/src/agent/components/thread-people.tsx +45 -15
  129. package/src/agent/components/threads-button.tsx +70 -0
  130. package/src/agent/components/transcript.tsx +30 -1
  131. package/src/agent/conversation.ts +25 -1
  132. package/src/agent/delegation/child-card.tsx +187 -247
  133. package/src/agent/delegation/child-cards.tsx +4 -7
  134. package/src/agent/delegation/child-group.tsx +179 -98
  135. package/src/agent/delegation/child-parts.tsx +71 -106
  136. package/src/agent/delegation/child-work.tsx +6 -52
  137. package/src/agent/delegation/interpret.ts +0 -28
  138. package/src/agent/delegation/model.ts +115 -39
  139. package/src/agent/dictation.ts +48 -0
  140. package/src/agent/hooks/use-agent-conversation.ts +10 -92
  141. package/src/agent/hooks/use-people-suggestions.ts +90 -0
  142. package/src/agent/hooks/use-thread-lists.ts +77 -0
  143. package/src/agent/i18n/en.ts +100 -83
  144. package/src/agent/i18n/fr.ts +109 -100
  145. package/src/agent/react-router.tsx +48 -5
  146. package/src/agent/run-presentation.ts +6 -2
  147. package/src/agent/thread-navigation.ts +16 -0
  148. package/src/agent/thread-pages.ts +24 -0
  149. package/src/artifacts/person-avatar.tsx +1 -1
  150. package/src/createCustomApp.ts +13 -6
  151. package/src/index.ts +7 -3
  152. package/src/pages/home.tsx +3 -1
  153. package/src/pages/observability/ai-usage/calls.tsx +2 -1
  154. package/src/pages/settings/memory-history.tsx +2 -1
  155. package/src/pages/settings/messages.ts +2 -3
  156. package/src/pages/values.tsx +23 -1
  157. package/src/pages.ts +5 -1
  158. package/src/shell/agent-dock.tsx +4 -2
  159. package/dist/agent/agents-page.d.ts +0 -4
  160. package/dist/agent/agents-page.d.ts.map +0 -1
  161. package/dist/agent/components/agent-thread-switcher.d.ts +0 -37
  162. package/dist/agent/components/agent-thread-switcher.d.ts.map +0 -1
  163. package/src/agent/agents-page.ts +0 -7
  164. package/src/agent/components/agent-thread-switcher.tsx +0 -519
  165. /package/dist/{chunk-0yb22w6m.js.map → chunk-2a69ge8h.js.map} +0 -0
  166. /package/dist/{chunk-vtp6nk44.js.map → chunk-bpj9mg5c.js.map} +0 -0
  167. /package/dist/{chunk-1rhht9y0.js.map → chunk-hzy2g13h.js.map} +0 -0
@@ -1,19 +1,24 @@
1
- import { useLocale } from "@sixb/ui/lib/i18n"
2
1
  import { cn } from "@sixb/ui/lib/utils"
3
- import { ChevronDown } from "lucide-react"
4
- import { Fragment, useCallback, useEffect, useId, useRef, useState } from "react"
2
+ import { ChevronRight } from "lucide-react"
3
+ import { Fragment, useEffect, useId, useState } from "react"
4
+ import { createPortal } from "react-dom"
5
+ import { panelTargetKey, type SlotTarget, useArtifactPanel } from "../artifact-panel"
5
6
  import { useAgentMessages } from "../i18n"
6
- import { ChildCard } from "./child-card"
7
- import { StateGlyph, WorkedFor } from "./child-parts"
8
- import { childrenCost } from "./interpret"
9
- import { type ChildModel, groupSummary, isSettled } from "./model"
7
+ import { ChildAttention, ChildDetail, ChildRow } from "./child-card"
8
+ import { AgentAvatar, WorkedFor } from "./child-parts"
9
+ import { childTitle, isActive } from "./interpret"
10
+ import { type ChildModel, isSettled, lineClauses } from "./model"
10
11
  import type { ChildrenSource } from "./use-children"
11
12
 
13
+ /** How many avatars the line stacks; the sentence names the rest. */
14
+ const STACKED = 3
15
+
12
16
  /**
13
- * Several children of one reply: a line that says how they stand, then a row for each, the ones
14
- * waiting on the reader first. It is open while any works, waits or will continue, and folds to
15
- * its line once all have settled, never while the reader has a child's work open. Something new
16
- * for the reader to do opens it again.
17
+ * The sub-agents of one reply, as one line of it: their avatars, then a sentence that names them and
18
+ * says how they stand ("Terms, History and Disputes finished · 48s"). The line opens them beside the
19
+ * conversation (over the app from the dock, as a sheet on a phone): one straight to its thread,
20
+ * several as a list that opens each. What waits on the reader, its questions and its calls held
21
+ * for approval, stays in the reply under the line.
17
22
  */
18
23
  export function ChildGroup({
19
24
  models,
@@ -26,125 +31,201 @@ export function ChildGroup({
26
31
  }) {
27
32
  const messages = useAgentMessages()
28
33
  const labels = messages.delegation
29
- const locale = useLocale()
30
- const listId = useId()
34
+ const panel = useArtifactPanel()
35
+ const inlineId = useId()
36
+ const [first] = models
37
+ const single = models.length === 1 ? first : undefined
38
+ const [chosen, setChosen] = useState<string | null>(null)
39
+ const [inlineOpen, setInlineOpen] = useState(false)
40
+
41
+ const slotId = `agents:${source.runId ?? first?.child.id ?? ""}`
42
+ const listTitle = labels.panel(models.length)
43
+ const panelOpen =
44
+ panel !== null && panel.openKey === panelTargetKey({ type: "slot", id: slotId, title: "" })
45
+ const shownId = single ? single.child.id : chosen
46
+ const shown = models.find((model) => model.child.id === shownId)
31
47
 
32
- const [choice, setChoice] = useState<boolean | null>(null)
33
- const [reading, setReading] = useState<ReadonlySet<string>>(() => new Set())
34
- const onWorkOpenChange = useCallback((childId: string, open: boolean) => {
35
- setReading((current) => {
36
- if (open === current.has(childId)) return current
37
- const next = new Set(current)
38
- if (open) next.add(childId)
39
- else next.delete(childId)
40
- return next
41
- })
42
- }, [])
48
+ const target = (childId: string | null): SlotTarget => {
49
+ const model = models.find((candidate) => candidate.child.id === childId)
50
+ return {
51
+ type: "slot",
52
+ id: slotId,
53
+ title: model ? childTitle(model.child.key) : listTitle,
54
+ ...(model && !single ? { back: { label: labels.back, onBack: () => show(null) } } : {}),
55
+ }
56
+ }
57
+ const show = (childId: string | null) => {
58
+ setChosen(childId)
59
+ if (panel) panel.open(target(childId))
60
+ else setInlineOpen(true)
61
+ }
62
+ const toggle = () => {
63
+ if (!panel) return setInlineOpen((open) => !open)
64
+ if (panelOpen) panel.close()
65
+ else show(single ? single.child.id : null)
66
+ }
43
67
 
44
- const forReader = models.filter((model) => model.needsReader).length
45
- const asked = useRef(forReader)
68
+ // A list the panel shows keeps its count as children join it.
69
+ // biome-ignore lint/correctness/useExhaustiveDependencies: the title follows the count
46
70
  useEffect(() => {
47
- if (forReader > asked.current) setChoice(null)
48
- asked.current = forReader
49
- }, [forReader])
71
+ if (panelOpen && !shown && panel) panel.open(target(null))
72
+ }, [models.length])
50
73
 
74
+ const clauses = lineClauses(models, messages)
51
75
  const settled = models.every((model) => isSettled(model.state))
52
- const open = choice ?? (!settled || reading.size > 0)
53
- const summary = groupSummary(models, messages)
54
- const cost = childrenCost(
55
- models.map((model) => model.view),
56
- locale
57
- )
58
- // The reader's own to act on come first; the rest keep the order the Agent spawned them in.
76
+ const urgent = clauses.some((clause) => clause.tone === "urgent")
77
+ const firstLive = clauses.find((clause) => clause.tone === "live")
78
+ const live = firstLive !== undefined
79
+ const sentence = clauses
80
+ .map((clause) => [clause.names, clause.verb].filter(Boolean).join(" "))
81
+ .join(" · ")
82
+ // The ones waiting on the reader lead the stack.
59
83
  const ordered = [
60
84
  ...models.filter((model) => model.needsReader),
61
85
  ...models.filter((model) => !model.needsReader),
62
86
  ]
87
+ const stack = ordered.slice(0, STACKED)
88
+ const open = panel ? panelOpen : inlineOpen
89
+
90
+ const view = shown ? (
91
+ <ChildDetail model={shown} source={source} unavailable={unavailable} />
92
+ ) : (
93
+ <ul className="flex flex-col gap-0.5 pt-1">
94
+ {ordered.map((model) => (
95
+ <li key={model.child.id}>
96
+ <ChildRow
97
+ model={model}
98
+ tint={models.indexOf(model)}
99
+ observed={source.observed}
100
+ onOpen={() => show(model.child.id)}
101
+ />
102
+ </li>
103
+ ))}
104
+ </ul>
105
+ )
63
106
 
64
107
  return (
65
108
  <section
66
109
  aria-label={labels.group}
67
110
  data-delegation-group=""
68
- className={cn(
69
- "min-w-0 overflow-hidden rounded-2xl border bg-card text-card-foreground shadow-[0_1px_2px_0_rgb(0_0_0/0.04)]",
70
- forReader > 0 ? "border-amber-500/35" : "border-border"
71
- )}
111
+ data-child-state={single?.state}
112
+ className="flex min-w-0 flex-col gap-2"
72
113
  >
114
+ {/* Said once per change of how they stand, never per step. */}
115
+ <span className="sr-only" aria-live="polite">
116
+ {sentence}
117
+ </span>
118
+
73
119
  <button
74
120
  type="button"
75
121
  aria-expanded={open}
76
- aria-controls={listId}
77
- onClick={() => setChoice(!open)}
78
- className="flex w-full min-w-0 items-center gap-3 px-4 py-3 text-left outline-none transition-colors hover:bg-muted/40 focus-visible:bg-muted/40 focus-visible:ring-2 focus-visible:ring-ring/40 focus-visible:ring-inset"
122
+ aria-controls={panel ? undefined : inlineId}
123
+ aria-label={labels.open(sentence || listTitle)}
124
+ onClick={toggle}
125
+ className={cn(
126
+ "group/line -ml-1 flex w-fit max-w-full min-w-0 items-center gap-2.5 rounded-lg px-1 py-1 text-left text-[13px] leading-normal outline-none transition-colors",
127
+ "hover:bg-muted/50 focus-visible:ring-2 focus-visible:ring-ring/40",
128
+ open && "bg-muted/50"
129
+ )}
79
130
  >
80
- <span className="flex shrink-0 -space-x-1.5" aria-hidden="true">
81
- {models.slice(0, 4).map((model) => (
82
- <StateGlyph
131
+ <span className="flex shrink-0 items-center pl-0.5">
132
+ {stack.map((model, index) => (
133
+ <AgentAvatar
83
134
  key={model.child.id}
135
+ name={childTitle(model.child.key)}
84
136
  state={model.state}
85
- calm={!model.needsReader}
86
- size="sm"
87
- ringed
137
+ needsReader={model.needsReader}
138
+ tint={models.indexOf(model)}
139
+ stacked={index > 0}
88
140
  />
89
141
  ))}
142
+ {models.length > STACKED ? (
143
+ <span
144
+ aria-hidden="true"
145
+ className="-ml-1 flex size-5 shrink-0 items-center justify-center rounded-full bg-muted text-[9px] font-semibold text-muted-foreground ring-2 ring-background"
146
+ >
147
+ +{models.length - STACKED}
148
+ </span>
149
+ ) : null}
90
150
  </span>
91
- <span className="min-w-0 flex-1 text-[13px] leading-5">
92
- <span className="font-semibold whitespace-nowrap text-foreground">
93
- {labels.count(models.length)}
94
- </span>
95
- {/* Each part wraps whole, at the separator before it. */}
96
- {summary.map((part) => (
97
- <Fragment key={part.text}>
98
- <span className="text-muted-foreground"> · </span>
99
- <span
100
- className={cn(
101
- "whitespace-nowrap text-muted-foreground",
102
- part.urgent && "font-medium text-amber-700 dark:text-amber-400"
103
- )}
104
- >
105
- {part.text}
106
- </span>
107
- </Fragment>
108
- ))}
109
- </span>
110
- <span className="shrink-0 text-xs text-muted-foreground tabular-nums max-sm:hidden">
111
- <WorkedFor views={models.map((model) => model.view)} />
112
- {cost ? ` · ${cost}` : null}
151
+ <span className="min-w-0">
152
+ {clauses.length === 0 ? (
153
+ <span className="text-muted-foreground">{listTitle}</span>
154
+ ) : (
155
+ clauses.map((clause, index) => (
156
+ <Fragment key={`${clause.tone}:${clause.verb}`}>
157
+ {index > 0 ? <span className="text-muted-foreground/60"> · </span> : null}
158
+ {clause.names ? (
159
+ <span className="font-medium text-foreground/85">{clause.names}</span>
160
+ ) : null}
161
+ {clause.names && clause.verb ? " " : null}
162
+ {clause.verb ? (
163
+ <span
164
+ className={cn(
165
+ "whitespace-nowrap",
166
+ clause.tone === "urgent" ? "text-foreground/85" : "text-muted-foreground",
167
+ clause.tone === "live" && "shimmer motion-reduce:animate-none"
168
+ )}
169
+ >
170
+ {clause.verb}
171
+ {clause.tone === "live" ? "…" : ""}
172
+ </span>
173
+ ) : null}
174
+ {/* The time belongs to who is at work, or, once all settled, to all of them. */}
175
+ {clause === firstLive ? (
176
+ <span className="whitespace-nowrap text-muted-foreground/70 tabular-nums">
177
+ <span className="text-muted-foreground/60"> · </span>
178
+ <WorkedFor
179
+ views={models
180
+ .filter((model) => isActive(model.state))
181
+ .map((model) => model.view)}
182
+ />
183
+ </span>
184
+ ) : null}
185
+ </Fragment>
186
+ ))
187
+ )}
188
+ {settled && !urgent ? (
189
+ <span className="whitespace-nowrap text-muted-foreground/70 tabular-nums">
190
+ <span className="text-muted-foreground/60"> · </span>
191
+ <WorkedFor views={models.map((model) => model.view)} />
192
+ </span>
193
+ ) : null}
113
194
  </span>
114
- <ChevronDown
195
+ <ChevronRight
115
196
  className={cn(
116
- "size-4 shrink-0 text-muted-foreground transition-transform motion-reduce:transition-none",
117
- open && "rotate-180"
197
+ "size-3.5 shrink-0 text-muted-foreground opacity-50 transition-[opacity,transform] group-hover/line:opacity-100 motion-reduce:transition-none",
198
+ !panel && inlineOpen && "rotate-90",
199
+ live && "opacity-40"
118
200
  )}
119
201
  aria-hidden="true"
120
202
  />
121
203
  </button>
122
204
 
123
- {open ? null : (
124
- <span className="sr-only" aria-live="polite">
125
- {`${labels.count(models.length)} · ${summary.map((part) => part.text).join(" · ")}`}
126
- </span>
127
- )}
205
+ {models.map((model) => (
206
+ <ChildAttention
207
+ key={model.child.id}
208
+ model={model}
209
+ observed={source.observed}
210
+ named={models.length > 1}
211
+ />
212
+ ))}
128
213
 
129
- {/* Folded, the rows stay mounted: a row keeps its open work and where the reader was. */}
130
- <ul
131
- id={listId}
132
- hidden={!open}
133
- className="divide-y divide-border/70 border-t border-border/70"
134
- >
135
- {ordered.map((model) => (
136
- <li key={model.child.id}>
137
- <ChildCard
138
- model={model}
139
- source={source}
140
- unavailable={unavailable}
141
- grouped
142
- announce={open}
143
- onWorkOpenChange={onWorkOpenChange}
144
- />
145
- </li>
146
- ))}
147
- </ul>
214
+ {panelOpen && panel?.slotHost ? createPortal(view, panel.slotHost) : null}
215
+ {!panel && inlineOpen ? (
216
+ <div id={inlineId} className="rounded-2xl bg-muted/40 px-4 py-3">
217
+ {shown && !single ? (
218
+ <button
219
+ type="button"
220
+ onClick={() => setChosen(null)}
221
+ className="mb-2 text-xs font-medium text-muted-foreground outline-none hover:text-foreground focus-visible:underline"
222
+ >
223
+ ‹ {labels.back}
224
+ </button>
225
+ ) : null}
226
+ {view}
227
+ </div>
228
+ ) : null}
148
229
  </section>
149
230
  )
150
231
  }
@@ -1,21 +1,8 @@
1
1
  import { listModelsOptions } from "@sixb/client/hooks"
2
2
  import { cn } from "@sixb/ui/lib/utils"
3
3
  import { useQuery } from "@tanstack/react-query"
4
- import {
5
- Bot,
6
- Check,
7
- CircleDashed,
8
- CirclePause,
9
- CircleSlash,
10
- Clock3,
11
- CornerDownRight,
12
- LoaderCircle,
13
- type LucideIcon,
14
- MessageCircleQuestion,
15
- Square,
16
- X,
17
- } from "lucide-react"
18
- import { type ReactNode, useEffect, useState } from "react"
4
+ import { Bot, Check, CornerDownRight, MessageCircleQuestion } from "lucide-react"
5
+ import { useEffect, useState } from "react"
19
6
  import { latestWorkLabel } from "../activity-label"
20
7
  import { ProviderLogo } from "../components/provider-logo"
21
8
  import { useAgentMessages } from "../i18n"
@@ -26,6 +13,7 @@ import {
26
13
  type ChildExchange,
27
14
  type ChildState,
28
15
  formatWorked,
16
+ isActive,
29
17
  type SpawnedChild,
30
18
  workedMs,
31
19
  } from "./interpret"
@@ -33,84 +21,71 @@ import type { ChildModel, WaitingOn } from "./model"
33
21
 
34
22
  // The pieces a sub-agent's card and its group are made of.
35
23
 
36
- const GLYPHS: Readonly<
37
- Record<
38
- ChildState,
39
- { readonly Icon: LucideIcon; readonly className: string; readonly spin?: true }
40
- >
41
- > = {
42
- starting: { Icon: CircleDashed, className: "bg-muted text-muted-foreground" },
43
- working: {
44
- Icon: LoaderCircle,
45
- className: "bg-sky-500/10 text-sky-600 dark:text-sky-400",
46
- spin: true,
47
- },
48
- asking: {
49
- Icon: MessageCircleQuestion,
50
- className: "bg-amber-500/12 text-amber-600 dark:text-amber-400",
51
- },
52
- approval: { Icon: CirclePause, className: "bg-amber-500/12 text-amber-600 dark:text-amber-400" },
53
- answer: {
54
- Icon: MessageCircleQuestion,
55
- className: "bg-amber-500/12 text-amber-600 dark:text-amber-400",
56
- },
57
- resume: { Icon: Clock3, className: "bg-muted text-muted-foreground" },
58
- done: { Icon: Check, className: "bg-emerald-500/12 text-emerald-600 dark:text-emerald-400" },
59
- failed: { Icon: X, className: "bg-muted text-muted-foreground" },
60
- stopped: { Icon: Square, className: "bg-muted text-muted-foreground/70" },
61
- ended: { Icon: CircleSlash, className: "bg-muted text-muted-foreground" },
62
- unknown: { Icon: Bot, className: "bg-muted text-muted-foreground" },
63
- }
24
+ /**
25
+ * Soft, opaque tints, given in the order a reply started its agents: two of one reply never share
26
+ * one, and each keeps its own in the line and the list.
27
+ */
28
+ const TINTS = [
29
+ "bg-sky-100 text-sky-700 dark:bg-sky-950 dark:text-sky-300",
30
+ "bg-violet-100 text-violet-700 dark:bg-violet-950 dark:text-violet-300",
31
+ "bg-emerald-100 text-emerald-700 dark:bg-emerald-950 dark:text-emerald-300",
32
+ "bg-pink-100 text-pink-700 dark:bg-pink-950 dark:text-pink-300",
33
+ ] as const
64
34
 
65
35
  /**
66
- * Where a child stands at a glance: a turning ring while it works, amber while it waits on
67
- * someone. `calm`: it waits on someone other than the reader, so it does not call for them.
36
+ * A sub-agent at a glance: its initial on a tinted disc. It breathes while it works,
37
+ * an amber dot says it waits on the reader, and one that failed or was stopped turns grey. Several
38
+ * overlap in a stack.
68
39
  */
69
- export function StateGlyph({
40
+ export function AgentAvatar({
41
+ name,
70
42
  state,
71
- size = "md",
72
- ringed = false,
73
- calm = false,
43
+ needsReader,
44
+ size = "sm",
45
+ stacked = false,
46
+ tint,
74
47
  }: {
48
+ readonly name: string
49
+ /** Its place among its reply's agents, which picks its tint. */
50
+ readonly tint: number
75
51
  readonly state: ChildState
52
+ readonly needsReader: boolean
76
53
  readonly size?: "sm" | "md"
77
- /** Overlapping others in a stack. */
78
- readonly ringed?: boolean
79
- readonly calm?: boolean
54
+ /** Overlapping the one before it in a stack. */
55
+ readonly stacked?: boolean
80
56
  }) {
81
- const { Icon, className, spin } = GLYPHS[state]
57
+ const quiet = state === "failed" || state === "stopped" || state === "ended"
82
58
  return (
83
59
  <span
84
60
  aria-hidden="true"
85
61
  className={cn(
86
- "flex shrink-0 items-center justify-center rounded-full",
87
- size === "md" ? "mt-0.5 size-7" : "size-5",
88
- ringed && "ring-2 ring-card",
89
- calm && (state === "approval" || state === "answer")
90
- ? "bg-muted text-muted-foreground"
91
- : className
62
+ "relative flex shrink-0 items-center justify-center rounded-full font-semibold ring-2 ring-background select-none",
63
+ size === "sm" ? "size-5 text-[10px]" : "size-7 text-[12px]",
64
+ stacked && (size === "sm" ? "-ml-1" : "-ml-2"),
65
+ quiet ? "bg-muted text-muted-foreground" : (TINTS[tint % TINTS.length] ?? TINTS[0]),
66
+ isActive(state) && "motion-safe:animate-pulse"
92
67
  )}
93
68
  >
94
- <Icon
95
- className={cn(
96
- size === "md" ? "size-3.5" : "size-3",
97
- state === "stopped" && "scale-75 fill-current",
98
- spin && "motion-safe:animate-spin motion-safe:[animation-duration:1.6s]",
99
- state === "approval" && !calm && "motion-safe:animate-pulse"
100
- )}
101
- />
69
+ {initial(name)}
70
+ {needsReader ? (
71
+ <span
72
+ className={cn(
73
+ "absolute -right-0.5 -bottom-0.5 rounded-full bg-amber-500 ring-2 ring-background",
74
+ size === "sm" ? "size-[7px]" : "size-2.5"
75
+ )}
76
+ />
77
+ ) : null}
102
78
  </span>
103
79
  )
104
80
  }
105
81
 
106
- /** The status line's colour: amber only when the reader is the one to act. */
107
- export function toneClass(state: ChildState, needsReader: boolean): string {
108
- if (needsReader || state === "asking") return "text-amber-700 dark:text-amber-400"
109
- if (state === "done") return "text-emerald-700 dark:text-emerald-400"
110
- if (state === "working") return "text-foreground"
111
- return "text-muted-foreground"
82
+ function initial(name: string): string {
83
+ return Array.from(name.trim())[0]?.toUpperCase() ?? "·"
112
84
  }
113
85
 
86
+ /** The text of what waits on the reader: the amber their attention goes to. */
87
+ export const NEEDS_READER_TEXT = "text-amber-700 dark:text-amber-400"
88
+
114
89
  /** The status line: what it does right now while it works, else where it stands. */
115
90
  export function statusLabel(
116
91
  model: ChildModel,
@@ -137,7 +112,7 @@ export function statusLabel(
137
112
  }
138
113
 
139
114
  /** Where a child stands, in words: also what a screen reader hears when it changes. */
140
- export function stateLabel(
115
+ function stateLabel(
141
116
  state: ChildState,
142
117
  waitingOn: WaitingOn,
143
118
  observed: boolean,
@@ -159,13 +134,16 @@ export function stateLabel(
159
134
  }
160
135
  }
161
136
 
162
- /** How long a child worked, its waits left out, ticking while it works. */
137
+ /**
138
+ * How long a child worked, its waits left out, ticking while it works. Children work side by side,
139
+ * so a group says how long its longest took, not their sum.
140
+ */
163
141
  export function WorkedFor({ views }: { readonly views: readonly (AgentChild | undefined)[] }) {
164
142
  const labels = useAgentMessages().delegation
165
143
  const now = useNow(views.some((view) => activeRun(view) !== undefined))
166
- const worked = views.reduce((total, view) => total + (view ? workedMs(view, now) : 0), 0)
144
+ const worked = Math.max(0, ...views.map((view) => (view ? workedMs(view, now) : 0)))
167
145
  if (worked <= 0) return null
168
- return <>{labels.worked(formatWorked(worked, labels))}</>
146
+ return <>{formatWorked(worked, labels)}</>
169
147
  }
170
148
 
171
149
  /** The model a child runs on: its provider's logo, its name, and the tier it came from. */
@@ -192,42 +170,23 @@ export function ModelChip({
192
170
  return (
193
171
  <span
194
172
  className={cn(
195
- "inline-flex h-6 max-w-full min-w-0 shrink-0 items-center gap-1.5 rounded-full border border-border/70 bg-muted/40 px-2 text-[11px] font-medium text-foreground",
173
+ "inline-flex max-w-full min-w-0 items-center gap-1.5 text-muted-foreground",
196
174
  className
197
175
  )}
198
176
  title={`${ref.provider} · ${ref.modelId}`}
199
177
  >
200
178
  {model ? (
201
- <ProviderLogo model={model} className="size-3" />
179
+ <ProviderLogo model={model} className="size-3 opacity-80" />
202
180
  ) : (
203
- <Bot className="size-3 shrink-0 text-muted-foreground" aria-hidden="true" />
181
+ <Bot className="size-3 shrink-0" aria-hidden="true" />
204
182
  )}
205
- <span className="min-w-0 truncate">{name}</span>
206
- {tier ? <span className="shrink-0 text-muted-foreground">· {labels.tiers[tier]}</span> : null}
183
+ <span className="min-w-0 truncate" title={tier ? labels.tiers[tier] : undefined}>
184
+ {name}
185
+ </span>
207
186
  </span>
208
187
  )
209
188
  }
210
189
 
211
- /** A band of the card below its header, its content aligned with the title. */
212
- export function Section({
213
- label,
214
- children,
215
- }: {
216
- readonly label?: string
217
- readonly children: ReactNode
218
- }) {
219
- return (
220
- <div className="border-t border-border/60 px-4 py-3 sm:pl-14">
221
- {label ? (
222
- <p className="mb-2 text-[11px] font-medium tracking-wide text-muted-foreground uppercase">
223
- {label}
224
- </p>
225
- ) : null}
226
- {children}
227
- </div>
228
- )
229
- }
230
-
231
190
  /**
232
191
  * What the Agent told the child, what the child asked, and what the Agent answered. The question
233
192
  * it waits on reads in full, in amber when the reader is the one to answer.
@@ -257,6 +216,15 @@ export function Exchanges({
257
216
  {shown.map((exchange, index) => {
258
217
  const open = index === lastAsked
259
218
  const amber = open && urgent
219
+ // The question waiting on the reader: its card says so already, so it reads as itself.
220
+ if (amber) {
221
+ return (
222
+ <li key={`${exchange.kind}:${index}`} className="text-sm leading-5 text-foreground">
223
+ <span className="sr-only">{labels.asks} · </span>
224
+ {exchange.text}
225
+ </li>
226
+ )
227
+ }
260
228
  const Icon =
261
229
  exchange.kind === "asked"
262
230
  ? MessageCircleQuestion
@@ -287,10 +255,7 @@ export function Exchanges({
287
255
  />
288
256
  <p className={cn("min-w-0 break-words", !open && "line-clamp-3")} title={exchange.text}>
289
257
  <span
290
- className={cn(
291
- "font-medium",
292
- amber ? "text-amber-700 dark:text-amber-400" : "text-muted-foreground"
293
- )}
258
+ className={cn("font-medium", amber ? NEEDS_READER_TEXT : "text-muted-foreground")}
294
259
  >
295
260
  {label}
296
261
  </span>