@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
@@ -0,0 +1,377 @@
1
+ import {
2
+ getAgentOptions,
3
+ listAgentApprovalsQueryKey,
4
+ listAgentThreadsQueryKey,
5
+ useAgentActivityStream,
6
+ } from "@sixb/client/hooks"
7
+ import { Button } from "@sixb/ui/components"
8
+ import { useLocale } from "@sixb/ui/lib/i18n"
9
+ import { cn } from "@sixb/ui/lib/utils"
10
+ import { useQuery, useQueryClient } from "@tanstack/react-query"
11
+ import { CircleX, Search, SquarePen } from "lucide-react"
12
+ import { type KeyboardEvent, type ReactNode, useMemo, useState } from "react"
13
+ import { PersonAvatar } from "../../artifacts/person-avatar"
14
+ import { useCurrentUser } from "../../session"
15
+ import { formatRelativeTime, groupThreadsByDate } from "../format"
16
+ import { useAgentThreadLists } from "../hooks/use-thread-lists"
17
+ import { useAgentMessages } from "../i18n"
18
+ import { personName, threadOwner } from "../sharing"
19
+ import { agentThreadTitle } from "../thread-navigation"
20
+ import type { AgentThread } from "../types"
21
+
22
+ export interface AgentThreadsProps {
23
+ readonly onSelectThread: (threadId: string) => void
24
+ readonly onNewThread: () => void
25
+ /** Before the title, such as a way back to the app. */
26
+ readonly headerActions?: ReactNode
27
+ readonly className?: string
28
+ }
29
+
30
+ /**
31
+ * Every thread the reader can open, on a page of its own: searched by title, filtered to
32
+ * the ones shared with them or archived, grouped by when they last moved. Those where a call waits
33
+ * for the reader come first.
34
+ */
35
+ export function AgentThreads({
36
+ onSelectThread,
37
+ onNewThread,
38
+ headerActions,
39
+ className,
40
+ }: AgentThreadsProps) {
41
+ const agentMessages = useAgentMessages()
42
+ const messages = agentMessages.threads
43
+ const user = useCurrentUser()
44
+ const agent = useQuery({ ...getAgentOptions(), retry: false, staleTime: 5 * 60_000 })
45
+ const agentName = agent.data?.name ?? "Agent"
46
+ // A run starting or ending anywhere, and a call held or decided, reach the list through the
47
+ // project's activity feed; poll only while it is away.
48
+ const queryClient = useQueryClient()
49
+ const refreshThreads = () =>
50
+ queryClient.invalidateQueries({ queryKey: listAgentThreadsQueryKey() })
51
+ const refreshWaiting = () =>
52
+ queryClient.invalidateQueries({ queryKey: listAgentApprovalsQueryKey() })
53
+ const activity = useAgentActivityStream({
54
+ onActivity: () => void refreshThreads(),
55
+ onApprovalActivity: () => void refreshWaiting(),
56
+ onSubscribed: () => {
57
+ void refreshThreads()
58
+ void refreshWaiting()
59
+ },
60
+ })
61
+ const { threadsQuery, sharedThreadsQuery, threads, sharedThreads, waitingThreadIds } =
62
+ useAgentThreadLists({
63
+ refetchInterval: !activity.connected || activity.error ? 10_000 : false,
64
+ })
65
+ const [searchTerm, setSearchTerm] = useState("")
66
+ const [filter, setFilter] = useState<"all" | "archived" | "shared">("all")
67
+ const canShare = user !== null
68
+ const sharedTotal = Math.max(sharedThreadsQuery.data?.pages[0]?.total ?? 0, sharedThreads.length)
69
+
70
+ const query = searchTerm.trim().toLowerCase()
71
+ const matching = useMemo(() => {
72
+ const listed =
73
+ filter === "archived"
74
+ ? threads.filter((thread) => thread.status === "archived")
75
+ : filter === "shared"
76
+ ? sharedThreads
77
+ : threads
78
+ if (!query) return listed
79
+ return listed.filter((thread) =>
80
+ agentThreadTitle(thread, messages).toLowerCase().includes(query)
81
+ )
82
+ }, [filter, query, threads, sharedThreads, messages])
83
+
84
+ // What waits on the reader comes first, theirs and what others shared alike.
85
+ const waiting =
86
+ filter === "archived"
87
+ ? []
88
+ : unique([...threads, ...sharedThreads]).filter(
89
+ (thread) =>
90
+ waitingThreadIds.has(thread.id) &&
91
+ (!query || agentThreadTitle(thread, messages).toLowerCase().includes(query))
92
+ )
93
+ const waitingIds = new Set(waiting.map((thread) => thread.id))
94
+ const groups = groupThreadsByDate(matching.filter((thread) => !waitingIds.has(thread.id)))
95
+ const archivedCount = threads.filter((thread) => thread.status === "archived").length
96
+ const sharedIds = new Set(sharedThreads.map((thread) => thread.id))
97
+ // The list shown says its own paging; a failed read of either says so wherever it shows.
98
+ const list = filter === "shared" ? sharedThreadsQuery : threadsQuery
99
+ const errors = [
100
+ filter !== "shared" && threadsQuery.isError ? agentMessages.chat.threadsLoadFailed : null,
101
+ filter !== "archived" && sharedThreadsQuery.isError
102
+ ? agentMessages.chat.sharedThreadsLoadFailed
103
+ : null,
104
+ ].filter((error): error is string => error !== null)
105
+ const loading = list.isPending
106
+
107
+ return (
108
+ <div className={cn("min-h-0 overflow-y-auto", className)} onKeyDown={moveRowFocus}>
109
+ <div className="mx-auto w-full max-w-[46rem] px-4 pt-6 pb-[max(2rem,env(safe-area-inset-bottom))] sm:px-6 sm:pt-14">
110
+ <header className="flex min-h-11 items-center gap-2">
111
+ {headerActions}
112
+ <h1 className="min-w-0 flex-1 truncate text-[28px] leading-tight font-semibold tracking-[-0.02em] text-foreground">
113
+ {messages.title}
114
+ </h1>
115
+ {/* On a phone the title keeps the room: the button is its icon. */}
116
+ <Button
117
+ type="button"
118
+ onClick={onNewThread}
119
+ aria-label={messages.new}
120
+ className="size-9 gap-1.5 rounded-full p-0 sm:w-auto sm:px-4"
121
+ >
122
+ <SquarePen className="size-4" aria-hidden="true" />
123
+ <span className="max-sm:sr-only">{messages.new}</span>
124
+ </Button>
125
+ </header>
126
+
127
+ <div className="mt-6 flex h-11 items-center gap-2.5 rounded-xl bg-muted/70 px-3.5 text-muted-foreground transition-colors focus-within:bg-muted">
128
+ <Search className="size-4 shrink-0" aria-hidden="true" />
129
+ <input
130
+ autoFocus
131
+ type="search"
132
+ value={searchTerm}
133
+ onChange={(event) => setSearchTerm(event.target.value)}
134
+ placeholder={messages.search}
135
+ aria-label={messages.searchLabel(agentName)}
136
+ className="h-full min-w-0 flex-1 bg-transparent text-[15px] text-foreground outline-none placeholder:text-muted-foreground [&::-webkit-search-cancel-button]:appearance-none"
137
+ />
138
+ {searchTerm ? (
139
+ <button
140
+ type="button"
141
+ onClick={() => setSearchTerm("")}
142
+ aria-label={messages.clearSearch}
143
+ className="-mr-1.5 flex size-7 items-center justify-center rounded-full outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/30"
144
+ >
145
+ <CircleX className="size-4" aria-hidden="true" />
146
+ </button>
147
+ ) : null}
148
+ </div>
149
+
150
+ {archivedCount > 0 || canShare ? (
151
+ <div className="mt-3 flex flex-wrap gap-1.5" role="group" aria-label={messages.filter}>
152
+ <Filter
153
+ label={messages.all}
154
+ active={filter === "all"}
155
+ onClick={() => setFilter("all")}
156
+ />
157
+ {canShare ? (
158
+ <Filter
159
+ label={messages.sharedFilter(sharedTotal)}
160
+ active={filter === "shared"}
161
+ onClick={() => setFilter("shared")}
162
+ />
163
+ ) : null}
164
+ {archivedCount > 0 ? (
165
+ <Filter
166
+ label={messages.archivedFilter(archivedCount)}
167
+ active={filter === "archived"}
168
+ onClick={() => setFilter("archived")}
169
+ />
170
+ ) : null}
171
+ </div>
172
+ ) : null}
173
+
174
+ <div className="mt-6">
175
+ {waiting.length > 0 ? (
176
+ <Section label={agentMessages.approvals.threadWaiting} waiting>
177
+ {waiting.map((thread) => (
178
+ <Row
179
+ key={thread.id}
180
+ thread={thread}
181
+ shared={sharedIds.has(thread.id)}
182
+ waiting
183
+ onSelect={onSelectThread}
184
+ />
185
+ ))}
186
+ </Section>
187
+ ) : null}
188
+
189
+ {groups.map((group) => (
190
+ <Section key={group.key} label={messages[group.key]}>
191
+ {group.threads.map((thread) => (
192
+ <Row
193
+ key={thread.id}
194
+ thread={thread}
195
+ shared={sharedIds.has(thread.id)}
196
+ waiting={false}
197
+ onSelect={onSelectThread}
198
+ />
199
+ ))}
200
+ </Section>
201
+ ))}
202
+
203
+ {errors.map((error) => (
204
+ <p key={error} role="alert" className="px-3 py-2 text-sm text-destructive">
205
+ {error}
206
+ </p>
207
+ ))}
208
+ {list.isFetchNextPageError ? (
209
+ <p role="alert" className="px-3 py-2 text-sm text-destructive">
210
+ {messages.loadMoreFailed}
211
+ </p>
212
+ ) : null}
213
+ {list.hasNextPage ? (
214
+ <div className="mt-4 flex justify-center">
215
+ <Button
216
+ variant="secondary"
217
+ size="sm"
218
+ className="rounded-full"
219
+ disabled={list.isFetchingNextPage}
220
+ onClick={() => void list.fetchNextPage()}
221
+ >
222
+ {list.isFetchingNextPage ? messages.loading : messages.loadMore}
223
+ </Button>
224
+ </div>
225
+ ) : null}
226
+ {!loading && matching.length === 0 && waiting.length === 0 ? (
227
+ <p className="px-3 py-16 text-center text-sm text-muted-foreground">
228
+ {query ? messages.empty : filter === "shared" ? messages.sharedEmpty : messages.none}
229
+ </p>
230
+ ) : null}
231
+ </div>
232
+ </div>
233
+ </div>
234
+ )
235
+ }
236
+
237
+ function Filter({
238
+ label,
239
+ active,
240
+ onClick,
241
+ }: {
242
+ readonly label: string
243
+ readonly active: boolean
244
+ readonly onClick: () => void
245
+ }) {
246
+ return (
247
+ <button
248
+ type="button"
249
+ onClick={onClick}
250
+ aria-pressed={active}
251
+ className={cn(
252
+ "h-8 rounded-full px-3 text-[13px] outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring/30",
253
+ active
254
+ ? "bg-foreground text-background"
255
+ : "bg-muted/70 text-muted-foreground hover:text-foreground"
256
+ )}
257
+ >
258
+ {label}
259
+ </button>
260
+ )
261
+ }
262
+
263
+ function Section({
264
+ label,
265
+ waiting = false,
266
+ children,
267
+ }: {
268
+ readonly label: string
269
+ /** The threads waiting for the reader: the heading carries the amber mark. */
270
+ readonly waiting?: boolean
271
+ readonly children: ReactNode
272
+ }) {
273
+ return (
274
+ <section className="mt-6 first:mt-0" aria-label={label}>
275
+ <h2
276
+ className={cn(
277
+ "flex items-center gap-1.5 px-3 pb-1.5 text-[13px]",
278
+ waiting ? "text-amber-700 dark:text-amber-400" : "text-muted-foreground"
279
+ )}
280
+ >
281
+ {waiting ? (
282
+ <span className="size-1.5 rounded-full bg-amber-500" aria-hidden="true" />
283
+ ) : null}
284
+ {label}
285
+ </h2>
286
+ <div className="flex flex-col">{children}</div>
287
+ </section>
288
+ )
289
+ }
290
+
291
+ /**
292
+ * One thread: its title, then whether the agent is at work in it, how many messages it holds and
293
+ * whose it is when someone shared it; when it last moved, at the end. Its section says when it
294
+ * waits for the reader.
295
+ */
296
+ function Row({
297
+ thread,
298
+ shared,
299
+ waiting,
300
+ onSelect,
301
+ }: {
302
+ readonly thread: AgentThread
303
+ /** Someone else's: the row names its owner. */
304
+ readonly shared: boolean
305
+ /** A call in it waits for the reader's approval. */
306
+ readonly waiting: boolean
307
+ readonly onSelect: (threadId: string) => void
308
+ }) {
309
+ const agentMessages = useAgentMessages()
310
+ const messages = agentMessages.threads
311
+ const locale = useLocale()
312
+ const title = agentThreadTitle(thread, messages)
313
+ const when =
314
+ thread.status === "archived"
315
+ ? messages.archived
316
+ : formatRelativeTime(thread.lastMessageAt ?? thread.updatedAt, locale, agentMessages.time)
317
+ const owner = shared ? personName(threadOwner(thread)) : null
318
+ const detail = [messages.messageCount(thread.messageCount), owner].filter(Boolean).join(" · ")
319
+ const working = thread.activeRunId !== null
320
+
321
+ return (
322
+ <button
323
+ type="button"
324
+ data-thread-option=""
325
+ onClick={() => onSelect(thread.id)}
326
+ data-thread-working={working ? "" : undefined}
327
+ aria-label={[
328
+ title,
329
+ waiting ? agentMessages.approvals.threadWaiting : working ? messages.working : null,
330
+ detail,
331
+ when,
332
+ ]
333
+ .filter(Boolean)
334
+ .join(", ")}
335
+ className="group flex min-h-16 w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left outline-none transition-colors hover:bg-muted/70 focus-visible:bg-muted/70 focus-visible:ring-2 focus-visible:ring-ring/30"
336
+ >
337
+ {owner ? <PersonAvatar name={owner} /> : null}
338
+ <span className="min-w-0 flex-1">
339
+ <span className="block truncate text-[15px] text-foreground">{title}</span>
340
+ <span className="mt-0.5 block truncate text-[13px] text-muted-foreground">
341
+ {working ? (
342
+ <>
343
+ <span className="inline-flex items-center gap-1.5 align-middle">
344
+ <span
345
+ className="size-1.5 rounded-full bg-sky-500 motion-safe:animate-pulse"
346
+ aria-hidden="true"
347
+ />
348
+ {messages.working}
349
+ </span>
350
+ <span aria-hidden="true"> · </span>
351
+ </>
352
+ ) : null}
353
+ {detail}
354
+ </span>
355
+ </span>
356
+ {when ? (
357
+ <span className="shrink-0 text-[13px] text-muted-foreground tabular-nums">{when}</span>
358
+ ) : null}
359
+ </button>
360
+ )
361
+ }
362
+
363
+ function unique(threads: readonly AgentThread[]): readonly AgentThread[] {
364
+ return [...new Map(threads.map((thread) => [thread.id, thread])).values()]
365
+ }
366
+
367
+ /** Up and down move between the rows, as in a list. */
368
+ function moveRowFocus(event: KeyboardEvent<HTMLDivElement>) {
369
+ if (event.key !== "ArrowDown" && event.key !== "ArrowUp") return
370
+ const options = [...event.currentTarget.querySelectorAll<HTMLElement>("[data-thread-option]")]
371
+ if (options.length === 0) return
372
+ const index = options.indexOf(document.activeElement as HTMLElement)
373
+ const delta = event.key === "ArrowDown" ? 1 : -1
374
+ const next = index < 0 ? (delta > 0 ? 0 : options.length - 1) : index + delta
375
+ options[(next + options.length) % options.length]?.focus()
376
+ event.preventDefault()
377
+ }