@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.
- package/dist/agent/agent-chat.d.ts +8 -1
- package/dist/agent/agent-chat.d.ts.map +1 -1
- package/dist/agent/agent-panel.d.ts +8 -1
- package/dist/agent/agent-panel.d.ts.map +1 -1
- package/dist/agent/agent-surface.d.ts +8 -1
- package/dist/agent/agent-surface.d.ts.map +1 -1
- package/dist/agent/approvals.d.ts +1 -4
- package/dist/agent/approvals.d.ts.map +1 -1
- package/dist/agent/artifact-panel.d.ts +21 -2
- package/dist/agent/artifact-panel.d.ts.map +1 -1
- package/dist/agent/components/activity-status.d.ts +1 -1
- package/dist/agent/components/activity-status.d.ts.map +1 -1
- package/dist/agent/components/agent-threads.d.ts +15 -0
- package/dist/agent/components/agent-threads.d.ts.map +1 -0
- package/dist/agent/components/approval-card.d.ts +4 -4
- package/dist/agent/components/approval-card.d.ts.map +1 -1
- package/dist/agent/components/approval-mode-chip.d.ts +4 -6
- package/dist/agent/components/approval-mode-chip.d.ts.map +1 -1
- package/dist/agent/components/auto-model-chip.d.ts +2 -3
- package/dist/agent/components/auto-model-chip.d.ts.map +1 -1
- package/dist/agent/components/composer-menu.d.ts +42 -0
- package/dist/agent/components/composer-menu.d.ts.map +1 -0
- package/dist/agent/components/composer.d.ts +8 -5
- package/dist/agent/components/composer.d.ts.map +1 -1
- package/dist/agent/components/conversation-panel.d.ts +3 -12
- package/dist/agent/components/conversation-panel.d.ts.map +1 -1
- package/dist/agent/components/dictation-bar.d.ts +13 -0
- package/dist/agent/components/dictation-bar.d.ts.map +1 -0
- package/dist/agent/components/message-parts.d.ts.map +1 -1
- package/dist/agent/components/message-view.d.ts +3 -1
- package/dist/agent/components/message-view.d.ts.map +1 -1
- package/dist/agent/components/model-controls.d.ts +15 -0
- package/dist/agent/components/model-controls.d.ts.map +1 -1
- package/dist/agent/components/model-picker-row.d.ts +9 -2
- package/dist/agent/components/model-picker-row.d.ts.map +1 -1
- package/dist/agent/components/participant-input.d.ts +7 -6
- package/dist/agent/components/participant-input.d.ts.map +1 -1
- package/dist/agent/components/thread-people.d.ts +4 -4
- package/dist/agent/components/thread-people.d.ts.map +1 -1
- package/dist/agent/components/threads-button.d.ts +14 -0
- package/dist/agent/components/threads-button.d.ts.map +1 -0
- package/dist/agent/conversation.d.ts +3 -1
- package/dist/agent/conversation.d.ts.map +1 -1
- package/dist/agent/delegation/child-card.d.ts +24 -11
- package/dist/agent/delegation/child-card.d.ts.map +1 -1
- package/dist/agent/delegation/child-cards.d.ts +2 -2
- package/dist/agent/delegation/child-cards.d.ts.map +1 -1
- package/dist/agent/delegation/child-group.d.ts +5 -4
- package/dist/agent/delegation/child-group.d.ts.map +1 -1
- package/dist/agent/delegation/child-parts.d.ts +17 -18
- package/dist/agent/delegation/child-parts.d.ts.map +1 -1
- package/dist/agent/delegation/child-work.d.ts +0 -13
- package/dist/agent/delegation/child-work.d.ts.map +1 -1
- package/dist/agent/delegation/interpret.d.ts +0 -5
- package/dist/agent/delegation/interpret.d.ts.map +1 -1
- package/dist/agent/delegation/model.d.ts +12 -6
- package/dist/agent/delegation/model.d.ts.map +1 -1
- package/dist/agent/dictation.d.ts +16 -0
- package/dist/agent/dictation.d.ts.map +1 -0
- package/dist/agent/hooks/use-agent-conversation.d.ts +3 -270
- package/dist/agent/hooks/use-agent-conversation.d.ts.map +1 -1
- package/dist/agent/hooks/use-people-suggestions.d.ts +21 -0
- package/dist/agent/hooks/use-people-suggestions.d.ts.map +1 -0
- package/dist/agent/hooks/use-thread-lists.d.ts +220 -0
- package/dist/agent/hooks/use-thread-lists.d.ts.map +1 -0
- package/dist/agent/i18n/en.d.ts +47 -36
- package/dist/agent/i18n/en.d.ts.map +1 -1
- package/dist/agent/i18n/fr.d.ts.map +1 -1
- package/dist/agent/i18n/index.d.ts +84 -72
- package/dist/agent/i18n/index.d.ts.map +1 -1
- package/dist/agent/react-router.d.ts +9 -0
- package/dist/agent/react-router.d.ts.map +1 -1
- package/dist/agent/run-presentation.d.ts +4 -1
- package/dist/agent/run-presentation.d.ts.map +1 -1
- package/dist/agent/thread-navigation.d.ts +8 -0
- package/dist/agent/thread-navigation.d.ts.map +1 -1
- package/dist/agent/thread-pages.d.ts +11 -0
- package/dist/agent/thread-pages.d.ts.map +1 -0
- package/dist/artifacts/person-avatar.d.ts +2 -2
- package/dist/{chunk-aes17xmx.js → chunk-12v6y89k.js} +4180 -3793
- package/dist/{chunk-aes17xmx.js.map → chunk-12v6y89k.js.map} +48 -42
- package/dist/{chunk-0yb22w6m.js → chunk-2a69ge8h.js} +1 -1
- package/dist/{chunk-vtp6nk44.js → chunk-bpj9mg5c.js} +1 -1
- package/dist/{chunk-1rhht9y0.js → chunk-hzy2g13h.js} +1 -1
- package/dist/createCustomApp.d.ts.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -6
- package/dist/index.js.map +6 -6
- package/dist/pages/home.d.ts.map +1 -1
- package/dist/pages/observability/ai-usage/calls.d.ts.map +1 -1
- package/dist/pages/settings/memory-history.d.ts.map +1 -1
- package/dist/pages/settings/messages.d.ts.map +1 -1
- package/dist/pages/values.d.ts +5 -0
- package/dist/pages/values.d.ts.map +1 -1
- package/dist/pages.d.ts +1 -1
- package/dist/pages.d.ts.map +1 -1
- package/dist/pages.js +60 -44
- package/dist/pages.js.map +8 -8
- package/dist/server.js +12 -6
- package/dist/server.js.map +3 -3
- package/dist/shell/agent-dock.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/agent/agent-chat.tsx +15 -23
- package/src/agent/agent-panel.tsx +11 -0
- package/src/agent/agent-surface.tsx +11 -0
- package/src/agent/agent.css +33 -3
- package/src/agent/approvals.ts +4 -5
- package/src/agent/artifact-panel.tsx +113 -37
- package/src/agent/components/activity-status.tsx +1 -1
- package/src/agent/components/agent-threads.tsx +377 -0
- package/src/agent/components/approval-card.tsx +336 -327
- package/src/agent/components/approval-mode-chip.tsx +38 -145
- package/src/agent/components/auto-model-chip.tsx +103 -167
- package/src/agent/components/composer-menu.tsx +185 -0
- package/src/agent/components/composer.tsx +168 -103
- package/src/agent/components/context-chips.tsx +1 -1
- package/src/agent/components/conversation-panel.tsx +16 -36
- package/src/agent/components/dictation-bar.tsx +110 -0
- package/src/agent/components/file-attachment-card.tsx +5 -2
- package/src/agent/components/message-parts.tsx +27 -11
- package/src/agent/components/message-view.tsx +182 -68
- package/src/agent/components/model-controls.tsx +133 -125
- package/src/agent/components/model-picker-row.tsx +38 -17
- package/src/agent/components/participant-input.tsx +159 -31
- package/src/agent/components/reasoning-effort-slider.tsx +27 -27
- package/src/agent/components/shared-thread-notice.tsx +1 -1
- package/src/agent/components/thread-people.tsx +45 -15
- package/src/agent/components/threads-button.tsx +70 -0
- package/src/agent/components/transcript.tsx +30 -1
- package/src/agent/conversation.ts +25 -1
- package/src/agent/delegation/child-card.tsx +187 -247
- package/src/agent/delegation/child-cards.tsx +4 -7
- package/src/agent/delegation/child-group.tsx +179 -98
- package/src/agent/delegation/child-parts.tsx +71 -106
- package/src/agent/delegation/child-work.tsx +6 -52
- package/src/agent/delegation/interpret.ts +0 -28
- package/src/agent/delegation/model.ts +115 -39
- package/src/agent/dictation.ts +48 -0
- package/src/agent/hooks/use-agent-conversation.ts +10 -92
- package/src/agent/hooks/use-people-suggestions.ts +90 -0
- package/src/agent/hooks/use-thread-lists.ts +77 -0
- package/src/agent/i18n/en.ts +100 -83
- package/src/agent/i18n/fr.ts +109 -100
- package/src/agent/react-router.tsx +48 -5
- package/src/agent/run-presentation.ts +6 -2
- package/src/agent/thread-navigation.ts +16 -0
- package/src/agent/thread-pages.ts +24 -0
- package/src/artifacts/person-avatar.tsx +1 -1
- package/src/createCustomApp.ts +13 -6
- package/src/index.ts +7 -3
- package/src/pages/home.tsx +3 -1
- package/src/pages/observability/ai-usage/calls.tsx +2 -1
- package/src/pages/settings/memory-history.tsx +2 -1
- package/src/pages/settings/messages.ts +2 -3
- package/src/pages/values.tsx +23 -1
- package/src/pages.ts +5 -1
- package/src/shell/agent-dock.tsx +4 -2
- package/dist/agent/agents-page.d.ts +0 -4
- package/dist/agent/agents-page.d.ts.map +0 -1
- package/dist/agent/components/agent-thread-switcher.d.ts +0 -37
- package/dist/agent/components/agent-thread-switcher.d.ts.map +0 -1
- package/src/agent/agents-page.ts +0 -7
- package/src/agent/components/agent-thread-switcher.tsx +0 -519
- /package/dist/{chunk-0yb22w6m.js.map → chunk-2a69ge8h.js.map} +0 -0
- /package/dist/{chunk-vtp6nk44.js.map → chunk-bpj9mg5c.js.map} +0 -0
- /package/dist/{chunk-1rhht9y0.js.map → chunk-hzy2g13h.js.map} +0 -0
|
@@ -1,519 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Button,
|
|
3
|
-
Dialog,
|
|
4
|
-
DialogClose,
|
|
5
|
-
DialogContent,
|
|
6
|
-
DialogDescription,
|
|
7
|
-
DialogTitle,
|
|
8
|
-
DialogTrigger,
|
|
9
|
-
} from "@sixb/ui/components"
|
|
10
|
-
import { useLocale } from "@sixb/ui/lib/i18n"
|
|
11
|
-
import { cn } from "@sixb/ui/lib/utils"
|
|
12
|
-
import { CirclePause, History, LoaderCircle, Plus, Search, X } from "lucide-react"
|
|
13
|
-
import { type KeyboardEvent, type ReactNode, useMemo, useState } from "react"
|
|
14
|
-
import { PersonAvatar } from "../../artifacts/person-avatar"
|
|
15
|
-
import { formatRelativeTime, groupThreadsByDate } from "../format"
|
|
16
|
-
import { useAgentMessages } from "../i18n"
|
|
17
|
-
import { personName, threadOwner } from "../sharing"
|
|
18
|
-
import { agentThreadTitle } from "../thread-navigation"
|
|
19
|
-
import type { AgentThread } from "../types"
|
|
20
|
-
|
|
21
|
-
/** The conversations other people shared with the reader, paged like their own. */
|
|
22
|
-
export interface SharedThreadList {
|
|
23
|
-
readonly threads: readonly AgentThread[]
|
|
24
|
-
/** All of them, beyond the pages read so far. */
|
|
25
|
-
readonly total: number
|
|
26
|
-
readonly error?: string | null
|
|
27
|
-
readonly hasMore?: boolean
|
|
28
|
-
readonly loadingMore?: boolean
|
|
29
|
-
readonly loadMoreError?: boolean
|
|
30
|
-
readonly onLoadMore?: () => void
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const NO_SHARED_THREADS: SharedThreadList = { threads: [], total: 0 }
|
|
34
|
-
const NO_WAITING_THREADS: ReadonlySet<string> = new Set()
|
|
35
|
-
|
|
36
|
-
export interface AgentThreadSwitcherProps {
|
|
37
|
-
readonly agentName: string
|
|
38
|
-
readonly currentThread: AgentThread | null
|
|
39
|
-
readonly threads: readonly AgentThread[]
|
|
40
|
-
/**
|
|
41
|
-
* Conversations other people shared with the reader, listed apart from their own. Omitted
|
|
42
|
-
* where nothing can be shared, without a signed-in user.
|
|
43
|
-
*/
|
|
44
|
-
readonly sharedThreads?: SharedThreadList
|
|
45
|
-
readonly runningThreadCount?: number
|
|
46
|
-
/**
|
|
47
|
-
* The threads where a call waits for the reader's approval: they open the list, each row says so,
|
|
48
|
-
* and the button counts them.
|
|
49
|
-
*/
|
|
50
|
-
readonly waitingThreadIds?: ReadonlySet<string>
|
|
51
|
-
readonly threadsError?: string | null
|
|
52
|
-
readonly hasMoreThreads?: boolean
|
|
53
|
-
readonly loadingMoreThreads?: boolean
|
|
54
|
-
readonly loadMoreThreadsError?: boolean
|
|
55
|
-
readonly onLoadMoreThreads?: () => void
|
|
56
|
-
readonly onSelectThread: (threadId: string) => void
|
|
57
|
-
readonly onNewThread?: () => void
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export function AgentThreadSwitcher({
|
|
61
|
-
agentName,
|
|
62
|
-
currentThread,
|
|
63
|
-
threads,
|
|
64
|
-
sharedThreads,
|
|
65
|
-
runningThreadCount = 0,
|
|
66
|
-
waitingThreadIds = NO_WAITING_THREADS,
|
|
67
|
-
threadsError,
|
|
68
|
-
hasMoreThreads,
|
|
69
|
-
loadingMoreThreads,
|
|
70
|
-
loadMoreThreadsError,
|
|
71
|
-
onLoadMoreThreads,
|
|
72
|
-
onSelectThread,
|
|
73
|
-
onNewThread,
|
|
74
|
-
}: AgentThreadSwitcherProps) {
|
|
75
|
-
const agentMessages = useAgentMessages()
|
|
76
|
-
const messages = agentMessages.threads
|
|
77
|
-
const approvalMessages = agentMessages.approvals
|
|
78
|
-
const shared = sharedThreads ?? NO_SHARED_THREADS
|
|
79
|
-
const canShare = sharedThreads !== undefined
|
|
80
|
-
const [open, setOpen] = useState(false)
|
|
81
|
-
const [searchTerm, setSearchTerm] = useState("")
|
|
82
|
-
const [filter, setFilter] = useState<"all" | "archived" | "shared">("all")
|
|
83
|
-
const [snapshot, setSnapshot] = useState<{
|
|
84
|
-
readonly own: readonly string[]
|
|
85
|
-
readonly shared: readonly string[]
|
|
86
|
-
}>({ own: [], shared: [] })
|
|
87
|
-
const allThreads = useMemo(() => uniqueThreads(currentThread, threads), [currentThread, threads])
|
|
88
|
-
|
|
89
|
-
// While open, rows keep the order they had when it opened, whatever activity moves meanwhile.
|
|
90
|
-
const shownThreads = open ? inSnapshotOrder(allThreads, snapshot.own) : allThreads
|
|
91
|
-
const shownShared = open ? inSnapshotOrder(shared.threads, snapshot.shared) : shared.threads
|
|
92
|
-
const normalizedSearchTerm = searchTerm.trim().toLowerCase()
|
|
93
|
-
const matchingThreads = useMemo(() => {
|
|
94
|
-
const byState =
|
|
95
|
-
filter === "archived"
|
|
96
|
-
? shownThreads.filter((thread) => thread.status === "archived")
|
|
97
|
-
: filter === "shared"
|
|
98
|
-
? shownShared
|
|
99
|
-
: shownThreads
|
|
100
|
-
if (!normalizedSearchTerm) return byState
|
|
101
|
-
return byState.filter((thread) =>
|
|
102
|
-
agentThreadTitle(thread, messages).toLowerCase().includes(normalizedSearchTerm)
|
|
103
|
-
)
|
|
104
|
-
}, [filter, normalizedSearchTerm, shownThreads, shownShared, messages])
|
|
105
|
-
const matchingIds = new Set(matchingThreads.map((thread) => thread.id))
|
|
106
|
-
const currentVisible = currentThread && matchingIds.has(currentThread.id) ? currentThread : null
|
|
107
|
-
// Waiting threads open the list, the reader's own and those shared with them alike.
|
|
108
|
-
const waitingRows =
|
|
109
|
-
filter === "archived"
|
|
110
|
-
? []
|
|
111
|
-
: uniqueThreads(null, [...shownThreads, ...shownShared]).filter(
|
|
112
|
-
(thread) =>
|
|
113
|
-
waitingThreadIds.has(thread.id) &&
|
|
114
|
-
thread.id !== currentVisible?.id &&
|
|
115
|
-
(!normalizedSearchTerm ||
|
|
116
|
-
agentThreadTitle(thread, messages).toLowerCase().includes(normalizedSearchTerm))
|
|
117
|
-
)
|
|
118
|
-
const waitingRowIds = new Set(waitingRows.map((thread) => thread.id))
|
|
119
|
-
const groups = groupThreadsByDate(
|
|
120
|
-
matchingThreads.filter(
|
|
121
|
-
(thread) => thread.id !== currentVisible?.id && !waitingRowIds.has(thread.id)
|
|
122
|
-
)
|
|
123
|
-
)
|
|
124
|
-
const archivedCount = shownThreads.filter((thread) => thread.status === "archived").length
|
|
125
|
-
const currentTitle = agentThreadTitle(currentThread, messages)
|
|
126
|
-
// The open conversation shows its own cards: the button counts the others that wait.
|
|
127
|
-
const waitingElsewhere = [...waitingThreadIds].filter(
|
|
128
|
-
(threadId) => threadId !== currentThread?.id
|
|
129
|
-
).length
|
|
130
|
-
const waitingLabel =
|
|
131
|
-
waitingElsewhere > 0 ? approvalMessages.waitingThreads(waitingElsewhere) : null
|
|
132
|
-
const historyLabel = [
|
|
133
|
-
runningThreadCount > 0
|
|
134
|
-
? messages.runningHistory(runningThreadCount, currentTitle)
|
|
135
|
-
: messages.historyCurrent(currentTitle),
|
|
136
|
-
waitingLabel,
|
|
137
|
-
]
|
|
138
|
-
.filter(Boolean)
|
|
139
|
-
.join(". ")
|
|
140
|
-
|
|
141
|
-
// The list shown says its own errors and pages.
|
|
142
|
-
const list =
|
|
143
|
-
filter === "shared"
|
|
144
|
-
? {
|
|
145
|
-
error: null,
|
|
146
|
-
loadMoreError: shared.loadMoreError,
|
|
147
|
-
hasMore: shared.hasMore,
|
|
148
|
-
loadingMore: shared.loadingMore,
|
|
149
|
-
onLoadMore: shared.onLoadMore,
|
|
150
|
-
}
|
|
151
|
-
: {
|
|
152
|
-
error: threadsError,
|
|
153
|
-
loadMoreError: loadMoreThreadsError,
|
|
154
|
-
hasMore: hasMoreThreads,
|
|
155
|
-
loadingMore: loadingMoreThreads,
|
|
156
|
-
onLoadMore: onLoadMoreThreads,
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
function updateOpen(nextOpen: boolean) {
|
|
160
|
-
setOpen(nextOpen)
|
|
161
|
-
if (nextOpen) {
|
|
162
|
-
setSnapshot({
|
|
163
|
-
own: allThreads.map((thread) => thread.id),
|
|
164
|
-
shared: shared.threads.map((thread) => thread.id),
|
|
165
|
-
})
|
|
166
|
-
} else {
|
|
167
|
-
setSearchTerm("")
|
|
168
|
-
setFilter("all")
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
function selectThread(threadId: string) {
|
|
173
|
-
updateOpen(false)
|
|
174
|
-
onSelectThread(threadId)
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
function startThread() {
|
|
178
|
-
updateOpen(false)
|
|
179
|
-
onNewThread?.()
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
return (
|
|
183
|
-
<Dialog open={open} onOpenChange={updateOpen}>
|
|
184
|
-
<DialogTrigger asChild>
|
|
185
|
-
<Button
|
|
186
|
-
type="button"
|
|
187
|
-
variant="ghost"
|
|
188
|
-
size="icon-lg"
|
|
189
|
-
aria-label={historyLabel}
|
|
190
|
-
title={
|
|
191
|
-
waitingLabel ??
|
|
192
|
-
(runningThreadCount > 0 ? messages.running(runningThreadCount) : messages.history)
|
|
193
|
-
}
|
|
194
|
-
className="relative [&_svg]:size-5"
|
|
195
|
-
>
|
|
196
|
-
{waitingElsewhere > 0 ? (
|
|
197
|
-
// Beside a running count, a dot: the spinner keeps its own number readable.
|
|
198
|
-
<span
|
|
199
|
-
data-waiting-approval-count={waitingElsewhere}
|
|
200
|
-
aria-hidden="true"
|
|
201
|
-
className={cn(
|
|
202
|
-
"absolute rounded-full bg-amber-500 ring-2 ring-background",
|
|
203
|
-
runningThreadCount > 0
|
|
204
|
-
? "top-1.5 right-1.5 size-2.5"
|
|
205
|
-
: "top-1 right-1 flex h-4 min-w-4 items-center justify-center px-1 text-[9px] font-semibold leading-none text-white tabular-nums"
|
|
206
|
-
)}
|
|
207
|
-
>
|
|
208
|
-
{runningThreadCount > 0 ? null : waitingElsewhere > 9 ? "9+" : waitingElsewhere}
|
|
209
|
-
</span>
|
|
210
|
-
) : null}
|
|
211
|
-
{runningThreadCount > 0 ? (
|
|
212
|
-
<span
|
|
213
|
-
data-active-thread-count={runningThreadCount}
|
|
214
|
-
aria-hidden="true"
|
|
215
|
-
className="relative grid size-5 shrink-0 place-items-center"
|
|
216
|
-
>
|
|
217
|
-
<LoaderCircle className="absolute inset-0 size-5 animate-spin [animation-duration:1.4s] motion-reduce:animate-none" />
|
|
218
|
-
<span className="text-[8px] font-semibold leading-none tabular-nums">
|
|
219
|
-
{runningThreadCount > 99 ? "99+" : runningThreadCount}
|
|
220
|
-
</span>
|
|
221
|
-
</span>
|
|
222
|
-
) : (
|
|
223
|
-
<History />
|
|
224
|
-
)}
|
|
225
|
-
</Button>
|
|
226
|
-
</DialogTrigger>
|
|
227
|
-
<DialogContent
|
|
228
|
-
showCloseButton={false}
|
|
229
|
-
onKeyDown={moveThreadFocus}
|
|
230
|
-
className="top-0 left-0 flex h-dvh w-screen max-w-none translate-x-0 translate-y-0 flex-col gap-0 overflow-hidden rounded-none border-0 p-0 sm:top-[50%] sm:left-[50%] sm:h-auto sm:max-h-[calc(100dvh-2rem)] sm:w-[min(calc(100vw-2rem),40rem)] sm:max-w-[40rem] sm:translate-x-[-50%] sm:translate-y-[-50%] sm:rounded-2xl sm:border"
|
|
231
|
-
>
|
|
232
|
-
<DialogDescription className="sr-only">{messages.description(agentName)}</DialogDescription>
|
|
233
|
-
|
|
234
|
-
<div className="flex h-16 shrink-0 items-center gap-3 px-4 sm:px-5">
|
|
235
|
-
<DialogTitle className="text-lg">{messages.title}</DialogTitle>
|
|
236
|
-
{onNewThread ? (
|
|
237
|
-
<Button type="button" size="sm" className="ml-auto gap-1.5" onClick={startThread}>
|
|
238
|
-
<Plus />
|
|
239
|
-
{messages.new}
|
|
240
|
-
</Button>
|
|
241
|
-
) : null}
|
|
242
|
-
<DialogClose asChild>
|
|
243
|
-
<Button
|
|
244
|
-
type="button"
|
|
245
|
-
variant="ghost"
|
|
246
|
-
size="icon-sm"
|
|
247
|
-
aria-label={messages.close}
|
|
248
|
-
className={cn(
|
|
249
|
-
!onNewThread && "ml-auto",
|
|
250
|
-
"text-muted-foreground hover:text-foreground"
|
|
251
|
-
)}
|
|
252
|
-
>
|
|
253
|
-
<X />
|
|
254
|
-
</Button>
|
|
255
|
-
</DialogClose>
|
|
256
|
-
</div>
|
|
257
|
-
|
|
258
|
-
<div className="shrink-0 border-border/60 border-b px-4 pb-3 sm:px-5">
|
|
259
|
-
<div className="flex h-10 items-center gap-2.5 rounded-lg border border-input bg-muted/20 px-3 text-muted-foreground transition-colors focus-within:border-foreground/25 focus-within:bg-background">
|
|
260
|
-
<Search className="size-4 shrink-0" aria-hidden="true" />
|
|
261
|
-
<input
|
|
262
|
-
autoFocus
|
|
263
|
-
value={searchTerm}
|
|
264
|
-
onChange={(event) => setSearchTerm(event.target.value)}
|
|
265
|
-
placeholder={messages.search}
|
|
266
|
-
aria-label={messages.searchLabel(agentName)}
|
|
267
|
-
className="h-full min-w-0 flex-1 bg-transparent text-sm text-foreground outline-none placeholder:text-muted-foreground"
|
|
268
|
-
/>
|
|
269
|
-
</div>
|
|
270
|
-
{archivedCount > 0 || canShare ? (
|
|
271
|
-
<div className="mt-2.5 flex flex-wrap gap-1.5" aria-label={messages.filter}>
|
|
272
|
-
<FilterButton
|
|
273
|
-
label={messages.all}
|
|
274
|
-
active={filter === "all"}
|
|
275
|
-
onClick={() => setFilter("all")}
|
|
276
|
-
/>
|
|
277
|
-
{canShare ? (
|
|
278
|
-
<FilterButton
|
|
279
|
-
label={messages.sharedFilter(Math.max(shared.total, shared.threads.length))}
|
|
280
|
-
active={filter === "shared"}
|
|
281
|
-
onClick={() => setFilter("shared")}
|
|
282
|
-
/>
|
|
283
|
-
) : null}
|
|
284
|
-
{archivedCount > 0 ? (
|
|
285
|
-
<FilterButton
|
|
286
|
-
label={messages.archivedFilter(archivedCount)}
|
|
287
|
-
active={filter === "archived"}
|
|
288
|
-
onClick={() => setFilter("archived")}
|
|
289
|
-
/>
|
|
290
|
-
) : null}
|
|
291
|
-
</div>
|
|
292
|
-
) : null}
|
|
293
|
-
</div>
|
|
294
|
-
|
|
295
|
-
<div className="min-h-0 flex-1 overflow-y-auto px-3 pt-3 pb-[max(1rem,env(safe-area-inset-bottom))] sm:max-h-[min(68dvh,36rem)] sm:flex-none sm:px-4 sm:pb-4">
|
|
296
|
-
{currentVisible ? (
|
|
297
|
-
<ThreadSwitcherSection label={messages.current}>
|
|
298
|
-
<ThreadSwitcherRow
|
|
299
|
-
thread={currentVisible}
|
|
300
|
-
selected
|
|
301
|
-
shared={filter === "shared"}
|
|
302
|
-
waiting={waitingThreadIds.has(currentVisible.id)}
|
|
303
|
-
onSelect={selectThread}
|
|
304
|
-
/>
|
|
305
|
-
</ThreadSwitcherSection>
|
|
306
|
-
) : null}
|
|
307
|
-
|
|
308
|
-
{waitingRows.length > 0 ? (
|
|
309
|
-
<ThreadSwitcherSection label={approvalMessages.threadWaiting}>
|
|
310
|
-
{waitingRows.map((thread) => (
|
|
311
|
-
<ThreadSwitcherRow
|
|
312
|
-
key={thread.id}
|
|
313
|
-
thread={thread}
|
|
314
|
-
selected={false}
|
|
315
|
-
shared={!threads.some((own) => own.id === thread.id)}
|
|
316
|
-
waiting
|
|
317
|
-
onSelect={selectThread}
|
|
318
|
-
/>
|
|
319
|
-
))}
|
|
320
|
-
</ThreadSwitcherSection>
|
|
321
|
-
) : null}
|
|
322
|
-
|
|
323
|
-
{groups.map((group) => (
|
|
324
|
-
<ThreadSwitcherSection key={group.key} label={messages[group.key]}>
|
|
325
|
-
{group.threads.map((thread) => (
|
|
326
|
-
<ThreadSwitcherRow
|
|
327
|
-
key={thread.id}
|
|
328
|
-
thread={thread}
|
|
329
|
-
selected={thread.id === currentThread?.id}
|
|
330
|
-
shared={filter === "shared"}
|
|
331
|
-
waiting={waitingThreadIds.has(thread.id)}
|
|
332
|
-
onSelect={selectThread}
|
|
333
|
-
/>
|
|
334
|
-
))}
|
|
335
|
-
</ThreadSwitcherSection>
|
|
336
|
-
))}
|
|
337
|
-
|
|
338
|
-
{list.error ? (
|
|
339
|
-
<p role="alert" className="px-3 py-2 text-sm text-destructive">
|
|
340
|
-
{list.error}
|
|
341
|
-
</p>
|
|
342
|
-
) : null}
|
|
343
|
-
{shared.error && filter !== "archived" ? (
|
|
344
|
-
<p role="alert" className="px-3 py-2 text-sm text-destructive">
|
|
345
|
-
{shared.error}
|
|
346
|
-
</p>
|
|
347
|
-
) : null}
|
|
348
|
-
{list.loadMoreError ? (
|
|
349
|
-
<p role="alert" className="px-3 py-2 text-sm text-destructive">
|
|
350
|
-
{messages.loadMoreFailed}
|
|
351
|
-
</p>
|
|
352
|
-
) : null}
|
|
353
|
-
{list.hasMore && list.onLoadMore ? (
|
|
354
|
-
<Button
|
|
355
|
-
variant="outline"
|
|
356
|
-
size="sm"
|
|
357
|
-
disabled={list.loadingMore}
|
|
358
|
-
onClick={list.onLoadMore}
|
|
359
|
-
>
|
|
360
|
-
{list.loadingMore ? messages.loading : messages.loadMore}
|
|
361
|
-
</Button>
|
|
362
|
-
) : null}
|
|
363
|
-
{matchingThreads.length === 0 ? (
|
|
364
|
-
<p className="px-3 py-10 text-center text-sm text-muted-foreground">
|
|
365
|
-
{filter === "shared" && !normalizedSearchTerm ? messages.sharedEmpty : messages.empty}
|
|
366
|
-
</p>
|
|
367
|
-
) : null}
|
|
368
|
-
</div>
|
|
369
|
-
</DialogContent>
|
|
370
|
-
</Dialog>
|
|
371
|
-
)
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
function FilterButton({
|
|
375
|
-
label,
|
|
376
|
-
active,
|
|
377
|
-
onClick,
|
|
378
|
-
}: {
|
|
379
|
-
label: string
|
|
380
|
-
active: boolean
|
|
381
|
-
onClick: () => void
|
|
382
|
-
}) {
|
|
383
|
-
return (
|
|
384
|
-
<button
|
|
385
|
-
type="button"
|
|
386
|
-
onClick={onClick}
|
|
387
|
-
aria-pressed={active}
|
|
388
|
-
className={cn(
|
|
389
|
-
"h-7 rounded-full px-2.5 text-xs font-medium outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring/30",
|
|
390
|
-
active
|
|
391
|
-
? "bg-foreground text-background"
|
|
392
|
-
: "bg-muted/70 text-muted-foreground hover:text-foreground"
|
|
393
|
-
)}
|
|
394
|
-
>
|
|
395
|
-
{label}
|
|
396
|
-
</button>
|
|
397
|
-
)
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
function ThreadSwitcherSection({ label, children }: { label: string; children: ReactNode }) {
|
|
401
|
-
return (
|
|
402
|
-
<section className="mt-4 first:mt-0" aria-label={label}>
|
|
403
|
-
<p className="px-2 pb-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/80">
|
|
404
|
-
{label}
|
|
405
|
-
</p>
|
|
406
|
-
<div className="space-y-0.5">{children}</div>
|
|
407
|
-
</section>
|
|
408
|
-
)
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
function ThreadSwitcherRow({
|
|
412
|
-
thread,
|
|
413
|
-
selected,
|
|
414
|
-
shared = false,
|
|
415
|
-
waiting = false,
|
|
416
|
-
onSelect,
|
|
417
|
-
}: {
|
|
418
|
-
thread: AgentThread
|
|
419
|
-
selected: boolean
|
|
420
|
-
/** Someone else's conversation: the row names its owner. */
|
|
421
|
-
shared?: boolean
|
|
422
|
-
/** A call in it waits for the reader's approval. */
|
|
423
|
-
waiting?: boolean
|
|
424
|
-
onSelect: (threadId: string) => void
|
|
425
|
-
}) {
|
|
426
|
-
const agentMessages = useAgentMessages()
|
|
427
|
-
const messages = agentMessages.threads
|
|
428
|
-
const locale = useLocale()
|
|
429
|
-
const title = agentThreadTitle(thread, messages)
|
|
430
|
-
const relativeTime = formatRelativeTime(
|
|
431
|
-
thread.lastMessageAt ?? thread.updatedAt,
|
|
432
|
-
locale,
|
|
433
|
-
agentMessages.time
|
|
434
|
-
)
|
|
435
|
-
const meta = thread.status === "archived" ? messages.archived : relativeTime
|
|
436
|
-
const owner = personName(threadOwner(thread))
|
|
437
|
-
|
|
438
|
-
return (
|
|
439
|
-
<button
|
|
440
|
-
type="button"
|
|
441
|
-
data-thread-option=""
|
|
442
|
-
onClick={() => onSelect(thread.id)}
|
|
443
|
-
aria-current={selected ? "page" : undefined}
|
|
444
|
-
aria-label={[
|
|
445
|
-
title,
|
|
446
|
-
selected ? messages.currentState : null,
|
|
447
|
-
waiting ? agentMessages.approvals.threadWaiting : null,
|
|
448
|
-
meta || null,
|
|
449
|
-
]
|
|
450
|
-
.filter(Boolean)
|
|
451
|
-
.join(", ")}
|
|
452
|
-
className={cn(
|
|
453
|
-
"group flex min-h-14 w-full items-center rounded-xl px-4 py-2.5 text-left outline-none transition-colors hover:bg-muted focus-visible:bg-muted focus-visible:ring-2 focus-visible:ring-ring/30",
|
|
454
|
-
selected && "bg-muted/70"
|
|
455
|
-
)}
|
|
456
|
-
>
|
|
457
|
-
{shared ? <PersonAvatar name={owner} className="mr-3" /> : null}
|
|
458
|
-
<span className="min-w-0 flex-1">
|
|
459
|
-
<span className="block truncate text-sm font-medium text-foreground">{title}</span>
|
|
460
|
-
<span className="mt-0.5 block truncate text-[11px] text-muted-foreground">
|
|
461
|
-
{waiting ? (
|
|
462
|
-
<span className="mr-1 inline-flex items-center gap-1 font-medium text-amber-700 dark:text-amber-400">
|
|
463
|
-
<CirclePause className="size-3" aria-hidden="true" />
|
|
464
|
-
{agentMessages.approvals.threadWaiting}
|
|
465
|
-
<span className="font-normal text-muted-foreground">·</span>
|
|
466
|
-
</span>
|
|
467
|
-
) : null}
|
|
468
|
-
{shared
|
|
469
|
-
? messages.sharedBy(owner, thread.messageCount)
|
|
470
|
-
: messages.messages(thread.messageCount)}
|
|
471
|
-
</span>
|
|
472
|
-
</span>
|
|
473
|
-
{meta ? (
|
|
474
|
-
<span className="flex shrink-0 items-center gap-1.5 text-[11px] tabular-nums text-muted-foreground">
|
|
475
|
-
{meta}
|
|
476
|
-
</span>
|
|
477
|
-
) : null}
|
|
478
|
-
</button>
|
|
479
|
-
)
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
/** Threads in the order of a snapshot of their ids, with any new ones after it. */
|
|
483
|
-
function inSnapshotOrder(
|
|
484
|
-
threads: readonly AgentThread[],
|
|
485
|
-
snapshot: readonly string[]
|
|
486
|
-
): readonly AgentThread[] {
|
|
487
|
-
const byId = new Map(threads.map((thread) => [thread.id, thread]))
|
|
488
|
-
const known = new Set(snapshot)
|
|
489
|
-
|
|
490
|
-
return [
|
|
491
|
-
...snapshot.flatMap((threadId) => {
|
|
492
|
-
const thread = byId.get(threadId)
|
|
493
|
-
return thread ? [thread] : []
|
|
494
|
-
}),
|
|
495
|
-
...threads.filter((thread) => !known.has(thread.id)),
|
|
496
|
-
]
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
function uniqueThreads(
|
|
500
|
-
currentThread: AgentThread | null,
|
|
501
|
-
threads: readonly AgentThread[]
|
|
502
|
-
): readonly AgentThread[] {
|
|
503
|
-
const byId = new Map<string, AgentThread>()
|
|
504
|
-
for (const thread of threads) byId.set(thread.id, thread)
|
|
505
|
-
if (currentThread) byId.set(currentThread.id, currentThread)
|
|
506
|
-
return [...byId.values()]
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
function moveThreadFocus(event: KeyboardEvent<HTMLDivElement>) {
|
|
510
|
-
if (event.key !== "ArrowDown" && event.key !== "ArrowUp") return
|
|
511
|
-
if (event.target instanceof HTMLInputElement) return
|
|
512
|
-
const options = [...event.currentTarget.querySelectorAll<HTMLElement>("[data-thread-option]")]
|
|
513
|
-
if (options.length === 0) return
|
|
514
|
-
const currentIndex = options.indexOf(document.activeElement as HTMLElement)
|
|
515
|
-
const delta = event.key === "ArrowDown" ? 1 : -1
|
|
516
|
-
const nextIndex = currentIndex < 0 ? (delta > 0 ? 0 : options.length - 1) : currentIndex + delta
|
|
517
|
-
options[(nextIndex + options.length) % options.length]?.focus()
|
|
518
|
-
event.preventDefault()
|
|
519
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|