@sixb/app 0.2.5 → 0.2.7
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/components/agent-threads.d.ts.map +1 -1
- package/dist/agent/components/composer-place.d.ts.map +1 -1
- package/dist/agent/components/computer-place.d.ts +24 -6
- package/dist/agent/components/computer-place.d.ts.map +1 -1
- package/dist/agent/components/conversation-panel.d.ts.map +1 -1
- package/dist/agent/components/message-view.d.ts +13 -3
- package/dist/agent/components/message-view.d.ts.map +1 -1
- package/dist/agent/components/pending-messages.d.ts.map +1 -1
- package/dist/agent/components/sandbox-recovery.d.ts +8 -2
- package/dist/agent/components/sandbox-recovery.d.ts.map +1 -1
- package/dist/agent/components/transcript.d.ts +13 -0
- package/dist/agent/components/transcript.d.ts.map +1 -1
- package/dist/agent/conversation.d.ts +4 -0
- package/dist/agent/conversation.d.ts.map +1 -1
- package/dist/agent/delegation/use-children.d.ts +5 -5
- package/dist/agent/delegation/use-children.d.ts.map +1 -1
- package/dist/agent/format.d.ts +7 -0
- package/dist/agent/format.d.ts.map +1 -1
- package/dist/agent/hooks/thread-queries.d.ts +1548 -0
- package/dist/agent/hooks/thread-queries.d.ts.map +1 -0
- package/dist/agent/hooks/use-agent-conversation.d.ts +41 -2
- package/dist/agent/hooks/use-agent-conversation.d.ts.map +1 -1
- package/dist/agent/hooks/use-thread-lists.d.ts +80 -3
- package/dist/agent/hooks/use-thread-lists.d.ts.map +1 -1
- package/dist/agent/hooks/use-thread-place.d.ts +49 -0
- package/dist/agent/hooks/use-thread-place.d.ts.map +1 -0
- package/dist/agent/i18n/en.d.ts +44 -6
- 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 +76 -12
- package/dist/agent/i18n/index.d.ts.map +1 -1
- package/dist/agent/live-run.d.ts.map +1 -1
- package/dist/agent/model-selection.d.ts +3 -2
- package/dist/agent/model-selection.d.ts.map +1 -1
- package/dist/agent/moves.d.ts +40 -0
- package/dist/agent/moves.d.ts.map +1 -0
- package/dist/agent/thread-reader-state.d.ts +30 -0
- package/dist/agent/thread-reader-state.d.ts.map +1 -0
- package/dist/agent/types.d.ts +4 -0
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/artifacts/live/session.d.ts.map +1 -1
- package/dist/artifacts/queries.d.ts.map +1 -1
- package/dist/artifacts/renderers/live-frame.d.ts.map +1 -1
- package/dist/{chunk-69qgh20f.js → chunk-1f4h75n3.js} +1 -1
- package/dist/{chunk-4fex83k2.js → chunk-7v9622qb.js} +2254 -739
- package/dist/{chunk-4fex83k2.js.map → chunk-7v9622qb.js.map} +29 -26
- package/dist/{chunk-5sgac68y.js → chunk-dntecmwb.js} +1 -1
- package/dist/{chunk-4wm09prf.js → chunk-qmka6aea.js} +1 -1
- package/dist/createCustomApp.d.ts +8 -1
- package/dist/createCustomApp.d.ts.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +3 -3
- package/dist/pages/console/data/accounts.d.ts +94 -0
- package/dist/pages/console/data/accounts.d.ts.map +1 -0
- package/dist/pages/console/data/connectors.d.ts.map +1 -1
- package/dist/pages/console/data/datasets.d.ts.map +1 -1
- package/dist/pages/console/data/live-updates.d.ts.map +1 -1
- package/dist/pages/console/data/messages.d.ts +46 -0
- package/dist/pages/console/data/messages.d.ts.map +1 -1
- package/dist/pages/console/data/pipelines.d.ts.map +1 -1
- package/dist/pages/console/data/projections.d.ts.map +1 -1
- package/dist/pages/console/data/sync-button.d.ts.map +1 -1
- package/dist/pages/console/data/syncs.d.ts.map +1 -1
- package/dist/pages/console/ontology/actions.d.ts.map +1 -1
- package/dist/pages/console/ontology/object-type.d.ts.map +1 -1
- package/dist/pages/console/ontology/object-types.d.ts.map +1 -1
- package/dist/pages/console/ontology/rules.d.ts.map +1 -1
- package/dist/pages/console/ontology/workflow.d.ts.map +1 -1
- package/dist/pages/console/ontology/workflows.d.ts.map +1 -1
- package/dist/pages/folders.d.ts +106 -0
- package/dist/pages/folders.d.ts.map +1 -0
- package/dist/pages/settings/usage/breakdown.d.ts.map +1 -1
- package/dist/pages/settings/usage/page.d.ts +4 -1
- package/dist/pages/settings/usage/page.d.ts.map +1 -1
- package/dist/pages/settings/usage/spend-model.d.ts +43 -19
- package/dist/pages/settings/usage/spend-model.d.ts.map +1 -1
- package/dist/pages.js +23453 -22656
- package/dist/pages.js.map +23 -21
- package/dist/server.d.ts +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +40 -3
- package/dist/server.js.map +3 -3
- package/package.json +3 -3
- package/src/agent/agent-chat.tsx +2 -2
- package/src/agent/components/agent-threads.tsx +42 -2
- package/src/agent/components/composer-place.tsx +2 -7
- package/src/agent/components/computer-place.tsx +415 -70
- package/src/agent/components/conversation-panel.tsx +31 -26
- package/src/agent/components/message-view.tsx +418 -9
- package/src/agent/components/pending-messages.tsx +5 -1
- package/src/agent/components/sandbox-recovery.tsx +24 -6
- package/src/agent/components/transcript.tsx +136 -5
- package/src/agent/conversation.ts +16 -1
- package/src/agent/format.ts +52 -0
- package/src/agent/hooks/thread-queries.ts +75 -0
- package/src/agent/hooks/use-agent-conversation.ts +461 -112
- package/src/agent/hooks/use-thread-lists.ts +72 -7
- package/src/agent/hooks/use-thread-place.ts +239 -0
- package/src/agent/i18n/en.ts +69 -16
- package/src/agent/i18n/fr.ts +71 -19
- package/src/agent/live-run.ts +38 -0
- package/src/agent/model-selection.ts +3 -2
- package/src/agent/moves.ts +174 -0
- package/src/agent/thread-reader-state.ts +75 -0
- package/src/agent/types.ts +6 -0
- package/src/artifacts/live/session.ts +5 -0
- package/src/createCustomApp.ts +57 -3
- package/src/index.ts +4 -0
- package/src/pages/console/data/accounts.tsx +509 -0
- package/src/pages/console/data/connectors.tsx +67 -64
- package/src/pages/console/data/datasets.tsx +79 -68
- package/src/pages/console/data/live-updates.ts +2 -0
- package/src/pages/console/data/messages.ts +73 -0
- package/src/pages/console/data/pipelines.tsx +80 -69
- package/src/pages/console/data/projections.tsx +111 -82
- package/src/pages/console/data/sync-button.tsx +56 -16
- package/src/pages/console/data/syncs.tsx +121 -86
- package/src/pages/console/ontology/actions.tsx +51 -24
- package/src/pages/console/ontology/object-type.tsx +5 -1
- package/src/pages/console/ontology/object-types.tsx +41 -32
- package/src/pages/console/ontology/rules.tsx +48 -38
- package/src/pages/console/ontology/workflow.tsx +9 -3
- package/src/pages/console/ontology/workflows.tsx +55 -67
- package/src/pages/folders.tsx +335 -0
- package/src/pages/section-ui.tsx +1 -1
- package/src/pages/settings/usage/breakdown.tsx +5 -2
- package/src/pages/settings/usage/filter-menu.tsx +1 -1
- package/src/pages/settings/usage/page.tsx +32 -13
- package/src/pages/settings/usage/spend-chart.tsx +2 -2
- package/src/pages/settings/usage/spend-model.ts +118 -50
- package/src/server.ts +1 -0
- /package/dist/{chunk-69qgh20f.js.map → chunk-1f4h75n3.js.map} +0 -0
- /package/dist/{chunk-5sgac68y.js.map → chunk-dntecmwb.js.map} +0 -0
- /package/dist/{chunk-4wm09prf.js.map → chunk-qmka6aea.js.map} +0 -0
|
@@ -8,8 +8,9 @@ import {
|
|
|
8
8
|
} from "@sixb/client/hooks"
|
|
9
9
|
import { useQuery } from "@tanstack/react-query"
|
|
10
10
|
import { Activity, ArrowRight, Box, ChevronRight, Layers, Link2 } from "lucide-react"
|
|
11
|
-
import { type ComponentType, type ReactNode, useState } from "react"
|
|
11
|
+
import { type ComponentType, type ReactNode, useMemo, useState } from "react"
|
|
12
12
|
import { Link, useParams } from "react-router-dom"
|
|
13
|
+
import { FolderContents, folderBack, noItems, useFolderBrowser } from "../../folders"
|
|
13
14
|
import { DetailFallback, SectionPage } from "../../section-page"
|
|
14
15
|
import {
|
|
15
16
|
apiErrorMessage,
|
|
@@ -82,102 +83,127 @@ export function projectionRunsPollInterval(
|
|
|
82
83
|
/** Console › Projections: how datasets become objects, links and telemetry. */
|
|
83
84
|
export function ConsoleProjectionsPage() {
|
|
84
85
|
const messages = useDataMessages()
|
|
85
|
-
const format = useFormat()
|
|
86
86
|
const [tab, setTab] = useState<Tab>("all")
|
|
87
87
|
const projectionsQuery = useQuery({ ...listProjectionsOptions(), retry: false })
|
|
88
88
|
const data = projectionsQuery.data
|
|
89
|
-
const all
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
89
|
+
const all = useMemo<readonly Projection[]>(
|
|
90
|
+
() =>
|
|
91
|
+
data
|
|
92
|
+
? [...data.objectProjections, ...data.linkProjections, ...data.telemetryProjections]
|
|
93
|
+
: noItems,
|
|
94
|
+
[data]
|
|
95
|
+
)
|
|
96
|
+
const browser = useFolderBrowser({
|
|
97
|
+
items: all,
|
|
98
|
+
title: messages.projections.title,
|
|
99
|
+
description: messages.projections.description,
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
return (
|
|
103
|
+
<SectionPage section="console" page="projections" {...browser.frame}>
|
|
104
|
+
{all.length > 0 ? (
|
|
105
|
+
<FolderContents browser={browser} rootLabel={messages.projections.title}>
|
|
106
|
+
{(projections) => (
|
|
107
|
+
<ProjectionsPanel projections={projections} tab={tab} onTabChange={setTab} />
|
|
108
|
+
)}
|
|
109
|
+
</FolderContents>
|
|
110
|
+
) : (
|
|
111
|
+
<Panel
|
|
112
|
+
toolbar={projectionsQuery.isPending ? <SkeletonBlock className="h-7 w-56" /> : undefined}
|
|
113
|
+
>
|
|
114
|
+
{projectionsQuery.isPending ? (
|
|
115
|
+
<PanelSkeleton rows={3} interactive trailing={<TrailingSkeleton chevron />} />
|
|
116
|
+
) : projectionsQuery.isError ? (
|
|
117
|
+
<PanelEmpty
|
|
118
|
+
tone="error"
|
|
119
|
+
icon={Layers}
|
|
120
|
+
title={messages.projections.title}
|
|
121
|
+
description={apiErrorMessage(projectionsQuery.error, messages.common.loadFailed)}
|
|
122
|
+
/>
|
|
123
|
+
) : (
|
|
124
|
+
<PanelEmpty
|
|
125
|
+
icon={Layers}
|
|
126
|
+
title={messages.projections.emptyTitle}
|
|
127
|
+
description={messages.projections.emptyDescription}
|
|
128
|
+
/>
|
|
129
|
+
)}
|
|
130
|
+
</Panel>
|
|
131
|
+
)}
|
|
132
|
+
</SectionPage>
|
|
133
|
+
)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** Projections with a tab for each kind among them, so no tab is ever empty. */
|
|
137
|
+
function ProjectionsPanel({
|
|
138
|
+
projections,
|
|
139
|
+
tab: chosen,
|
|
140
|
+
onTabChange,
|
|
141
|
+
}: {
|
|
142
|
+
readonly projections: readonly Projection[]
|
|
143
|
+
readonly tab: Tab
|
|
144
|
+
readonly onTabChange: (tab: Tab) => void
|
|
145
|
+
}) {
|
|
146
|
+
const messages = useDataMessages()
|
|
147
|
+
const format = useFormat()
|
|
148
|
+
const count = (kind: ProjectionKind) => projections.filter((p) => kindOf(p) === kind).length
|
|
95
149
|
const tabs = (
|
|
96
150
|
[
|
|
97
|
-
{ id: "all", label: messages.projections.tabs.all, count:
|
|
151
|
+
{ id: "all", label: messages.projections.tabs.all, count: projections.length },
|
|
98
152
|
{ id: "object", label: messages.projections.tabs.object, count: count("object") },
|
|
99
153
|
{ id: "link", label: messages.projections.tabs.link, count: count("link") },
|
|
100
154
|
{ id: "telemetry", label: messages.projections.tabs.telemetry, count: count("telemetry") },
|
|
101
155
|
] satisfies { id: Tab; label: string; count: number }[]
|
|
102
156
|
).filter((entry) => entry.id === "all" || entry.count > 0)
|
|
157
|
+
// A folder without the chosen kind shows all of its own.
|
|
158
|
+
const tab = tabs.some((entry) => entry.id === chosen) ? chosen : "all"
|
|
159
|
+
const shown =
|
|
160
|
+
tab === "all" ? projections : projections.filter((projection) => kindOf(projection) === tab)
|
|
103
161
|
|
|
104
162
|
return (
|
|
105
|
-
<
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
tone="error"
|
|
125
|
-
icon={Layers}
|
|
126
|
-
title={messages.projections.title}
|
|
127
|
-
description={apiErrorMessage(projectionsQuery.error, messages.common.loadFailed)}
|
|
128
|
-
/>
|
|
129
|
-
) : shown.length === 0 ? (
|
|
130
|
-
<PanelEmpty
|
|
131
|
-
icon={Layers}
|
|
132
|
-
title={messages.projections.emptyTitle}
|
|
133
|
-
description={messages.projections.emptyDescription}
|
|
134
|
-
/>
|
|
135
|
-
) : (
|
|
136
|
-
shown.map((projection) => {
|
|
137
|
-
const kind = kindOf(projection)
|
|
138
|
-
return (
|
|
139
|
-
<PanelRow
|
|
140
|
-
key={projection.id}
|
|
141
|
-
href={`/console/projections/${encodeURIComponent(projection.id)}`}
|
|
142
|
-
leading={<IconTile icon={kindIcons[kind]} />}
|
|
143
|
-
title={<span className="truncate">{humanize(projection.id)}</span>}
|
|
144
|
-
meta={
|
|
163
|
+
<Panel toolbar={<ToolbarTabs value={tab} onChange={onTabChange} tabs={tabs} />}>
|
|
164
|
+
{shown.map((projection) => {
|
|
165
|
+
const kind = kindOf(projection)
|
|
166
|
+
return (
|
|
167
|
+
<PanelRow
|
|
168
|
+
key={projection.id}
|
|
169
|
+
href={`/console/projections/${encodeURIComponent(projection.id)}`}
|
|
170
|
+
leading={<IconTile icon={kindIcons[kind]} />}
|
|
171
|
+
title={<span className="truncate">{humanize(projection.id)}</span>}
|
|
172
|
+
meta={
|
|
173
|
+
<>
|
|
174
|
+
<span>{messages.projections.kinds[kind]}</span>
|
|
175
|
+
<MetaDot />
|
|
176
|
+
<span className="inline-flex min-w-0 items-center gap-1">
|
|
177
|
+
<span className="truncate font-mono text-xs">{projection.datasetId}</span>
|
|
178
|
+
<ArrowRight className="size-3 shrink-0" />
|
|
179
|
+
<span className="truncate">{targetOf(projection)}</span>
|
|
180
|
+
</span>
|
|
181
|
+
{projection.latestRun ? (
|
|
145
182
|
<>
|
|
146
|
-
<span>{messages.projections.kinds[kind]}</span>
|
|
147
183
|
<MetaDot />
|
|
148
|
-
<span
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
184
|
+
<span>
|
|
185
|
+
{format.relative(
|
|
186
|
+
projection.latestRun.startedAt ?? projection.latestRun.queuedAt
|
|
187
|
+
)}
|
|
152
188
|
</span>
|
|
153
|
-
{projection.latestRun ? (
|
|
154
|
-
<>
|
|
155
|
-
<MetaDot />
|
|
156
|
-
<span>
|
|
157
|
-
{format.relative(
|
|
158
|
-
projection.latestRun.startedAt ?? projection.latestRun.queuedAt
|
|
159
|
-
)}
|
|
160
|
-
</span>
|
|
161
|
-
</>
|
|
162
|
-
) : null}
|
|
163
|
-
</>
|
|
164
|
-
}
|
|
165
|
-
trailing={
|
|
166
|
-
<>
|
|
167
|
-
{projection.latestRun ? (
|
|
168
|
-
<RunStatusPill status={projection.latestRun.status} />
|
|
169
|
-
) : (
|
|
170
|
-
<Pill tone="muted">{messages.common.neverRun}</Pill>
|
|
171
|
-
)}
|
|
172
|
-
<ChevronRight className="size-4 text-muted-foreground/60" />
|
|
173
189
|
</>
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
190
|
+
) : null}
|
|
191
|
+
</>
|
|
192
|
+
}
|
|
193
|
+
trailing={
|
|
194
|
+
<>
|
|
195
|
+
{projection.latestRun ? (
|
|
196
|
+
<RunStatusPill status={projection.latestRun.status} />
|
|
197
|
+
) : (
|
|
198
|
+
<Pill tone="muted">{messages.common.neverRun}</Pill>
|
|
199
|
+
)}
|
|
200
|
+
<ChevronRight className="size-4 text-muted-foreground/60" />
|
|
201
|
+
</>
|
|
202
|
+
}
|
|
203
|
+
/>
|
|
204
|
+
)
|
|
205
|
+
})}
|
|
206
|
+
</Panel>
|
|
181
207
|
)
|
|
182
208
|
}
|
|
183
209
|
|
|
@@ -209,7 +235,10 @@ export function ConsoleProjectionPage() {
|
|
|
209
235
|
})
|
|
210
236
|
|
|
211
237
|
const projection = projectionQuery.data
|
|
212
|
-
const back =
|
|
238
|
+
const back = folderBack(
|
|
239
|
+
{ href: "/console/projections", label: messages.projections.title },
|
|
240
|
+
projection?.folder
|
|
241
|
+
)
|
|
213
242
|
|
|
214
243
|
if (!projection) {
|
|
215
244
|
return (
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { GetSyncResponse } from "@sixb/client"
|
|
1
2
|
import {
|
|
2
3
|
getSyncOptions,
|
|
3
4
|
getSyncQueryKey,
|
|
@@ -13,6 +14,9 @@ import { apiErrorMessage, useFormat } from "../../section-ui"
|
|
|
13
14
|
import { useSyncLiveUpdates } from "./live-updates"
|
|
14
15
|
import { useDataMessages } from "./messages"
|
|
15
16
|
|
|
17
|
+
type Sync = GetSyncResponse
|
|
18
|
+
type SyncStatus = { readonly text: string; readonly failed: boolean }
|
|
19
|
+
|
|
16
20
|
export interface SyncButtonProps {
|
|
17
21
|
/** The sync's id, as named in `syncs/`. */
|
|
18
22
|
readonly sync: string
|
|
@@ -44,10 +48,7 @@ export function SyncButton({
|
|
|
44
48
|
...getSyncOptions({ path }),
|
|
45
49
|
retry: false,
|
|
46
50
|
// Live updates refresh it as the run moves; polling covers a dropped event stream.
|
|
47
|
-
refetchInterval: (query) =>
|
|
48
|
-
const status = query.state.data?.latestRun?.status
|
|
49
|
-
return status === "queued" || status === "running" ? 5000 : false
|
|
50
|
-
},
|
|
51
|
+
refetchInterval: (query) => (query.state.data && isSyncing(query.state.data) ? 5000 : false),
|
|
51
52
|
})
|
|
52
53
|
const request = useMutation({
|
|
53
54
|
...requestSyncRunMutation(),
|
|
@@ -56,24 +57,17 @@ export function SyncButton({
|
|
|
56
57
|
queryClient.invalidateQueries({ queryKey: getSyncQueryKey({ path }) }),
|
|
57
58
|
queryClient.invalidateQueries({ queryKey: listSyncsQueryKey() }),
|
|
58
59
|
queryClient.invalidateQueries({ queryKey: listSyncRunsQueryKey() }),
|
|
60
|
+
queryClient.invalidateQueries({ queryKey: [{ _id: "listConnectorAccounts" }] }),
|
|
59
61
|
]),
|
|
60
62
|
})
|
|
61
63
|
|
|
62
|
-
const
|
|
63
|
-
const working =
|
|
64
|
-
request.isPending || latestRun?.status === "queued" || latestRun?.status === "running"
|
|
64
|
+
const working = request.isPending || (syncQuery.data ? isSyncing(syncQuery.data) : false)
|
|
65
65
|
|
|
66
|
-
let status:
|
|
66
|
+
let status: SyncStatus | null = null
|
|
67
67
|
if (request.isError) {
|
|
68
68
|
status = { text: apiErrorMessage(request.error, messages.requestFailed), failed: true }
|
|
69
|
-
} else if (!working && syncQuery.
|
|
70
|
-
|
|
71
|
-
else if (latestRun.status === "failed") status = { text: messages.failed, failed: true }
|
|
72
|
-
else if (latestRun.status === "succeeded")
|
|
73
|
-
status = {
|
|
74
|
-
text: messages.synced(format.relative(latestRun.finishedAt ?? latestRun.queuedAt)),
|
|
75
|
-
failed: false,
|
|
76
|
-
}
|
|
69
|
+
} else if (!working && syncQuery.data) {
|
|
70
|
+
status = syncStatus(syncQuery.data, messages, format)
|
|
77
71
|
}
|
|
78
72
|
|
|
79
73
|
return (
|
|
@@ -101,3 +95,49 @@ export function SyncButton({
|
|
|
101
95
|
</div>
|
|
102
96
|
)
|
|
103
97
|
}
|
|
98
|
+
|
|
99
|
+
/** Whether a run is under way: the latest one, or on a sync of an OAuth connector, any account's. */
|
|
100
|
+
function isSyncing(sync: Sync): boolean {
|
|
101
|
+
if (sync.accounts) return sync.accounts.running > 0
|
|
102
|
+
|
|
103
|
+
const status = sync.latestRun?.status
|
|
104
|
+
return status === "queued" || status === "running"
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* When it last synced, or that it failed. On a sync of an OAuth connector, the accounts you see
|
|
109
|
+
* tell: the latest run is only the account that ran last.
|
|
110
|
+
*/
|
|
111
|
+
function syncStatus(
|
|
112
|
+
sync: Sync,
|
|
113
|
+
messages: ReturnType<typeof useDataMessages>["syncButton"],
|
|
114
|
+
format: ReturnType<typeof useFormat>
|
|
115
|
+
): SyncStatus | null {
|
|
116
|
+
const accounts = sync.accounts
|
|
117
|
+
|
|
118
|
+
if (accounts) {
|
|
119
|
+
if (accounts.needsReconnecting > 0) {
|
|
120
|
+
return { text: messages.accountsNeedReconnecting(accounts.needsReconnecting), failed: true }
|
|
121
|
+
}
|
|
122
|
+
if (accounts.failing > 0) {
|
|
123
|
+
return { text: messages.accountsFailed(accounts.failing), failed: true }
|
|
124
|
+
}
|
|
125
|
+
if (accounts.lastSyncedAt) {
|
|
126
|
+
return { text: messages.synced(format.relative(accounts.lastSyncedAt)), failed: false }
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return { text: accounts.total === 0 ? messages.noAccounts : messages.never, failed: false }
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const latestRun = sync.latestRun
|
|
133
|
+
if (!latestRun) return { text: messages.never, failed: false }
|
|
134
|
+
if (latestRun.status === "failed") return { text: messages.failed, failed: true }
|
|
135
|
+
if (latestRun.status === "succeeded") {
|
|
136
|
+
return {
|
|
137
|
+
text: messages.synced(format.relative(latestRun.finishedAt ?? latestRun.queuedAt)),
|
|
138
|
+
failed: false,
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return null
|
|
143
|
+
}
|
|
@@ -2,6 +2,7 @@ import { getSyncOptions, listSyncRunsOptions, listSyncsOptions } from "@sixb/cli
|
|
|
2
2
|
import { useQuery } from "@tanstack/react-query"
|
|
3
3
|
import { CalendarClock, ChevronRight, RefreshCw } from "lucide-react"
|
|
4
4
|
import { Link, useParams } from "react-router-dom"
|
|
5
|
+
import { FolderContents, folderBack, noItems, useFolderBrowser } from "../../folders"
|
|
5
6
|
import { DetailFallback, SectionPage } from "../../section-page"
|
|
6
7
|
import {
|
|
7
8
|
apiErrorMessage,
|
|
@@ -25,6 +26,14 @@ import {
|
|
|
25
26
|
useRunStatusLabels,
|
|
26
27
|
} from "../../section-ui"
|
|
27
28
|
import { MetaSkeleton, SkeletonBlock, StatsSkeleton, TrailingSkeleton } from "../skeletons"
|
|
29
|
+
import {
|
|
30
|
+
AccountsMeta,
|
|
31
|
+
needsReconnecting,
|
|
32
|
+
SyncStatusPill,
|
|
33
|
+
SyncTimeMeta,
|
|
34
|
+
useAccountsStats,
|
|
35
|
+
useConnectorAccounts,
|
|
36
|
+
} from "./accounts"
|
|
28
37
|
import { useSyncLiveUpdates } from "./live-updates"
|
|
29
38
|
import { useDataMessages } from "./messages"
|
|
30
39
|
import { SchemaPanel } from "./schema"
|
|
@@ -34,73 +43,71 @@ import { SyncButton } from "./sync-button"
|
|
|
34
43
|
/** Console › Syncs: what copies each connector's data into the project, and how it last went. */
|
|
35
44
|
export function ConsoleSyncsPage() {
|
|
36
45
|
const messages = useDataMessages()
|
|
37
|
-
const format = useFormat()
|
|
38
46
|
useSyncLiveUpdates()
|
|
39
47
|
const syncsQuery = useQuery({ ...listSyncsOptions(), retry: false })
|
|
40
|
-
const
|
|
48
|
+
const browser = useFolderBrowser({
|
|
49
|
+
items: syncsQuery.data ?? noItems,
|
|
50
|
+
title: messages.syncs.title,
|
|
51
|
+
description: messages.syncs.description,
|
|
52
|
+
})
|
|
41
53
|
|
|
42
54
|
return (
|
|
43
|
-
<SectionPage
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
icon={RefreshCw}
|
|
56
|
-
title={messages.syncs.title}
|
|
57
|
-
description={apiErrorMessage(syncsQuery.error, messages.common.loadFailed)}
|
|
58
|
-
/>
|
|
59
|
-
) : syncs.length === 0 ? (
|
|
60
|
-
<PanelEmpty
|
|
61
|
-
icon={RefreshCw}
|
|
62
|
-
title={messages.syncs.emptyTitle}
|
|
63
|
-
description={messages.syncs.emptyDescription}
|
|
64
|
-
/>
|
|
65
|
-
) : (
|
|
66
|
-
syncs.map((sync) => (
|
|
67
|
-
<PanelRow
|
|
68
|
-
key={sync.id}
|
|
69
|
-
href={`/console/syncs/${encodeURIComponent(sync.id)}`}
|
|
70
|
-
leading={<ConnectorIcon type={sync.connector.type} />}
|
|
71
|
-
title={<span className="truncate">{humanize(sync.id)}</span>}
|
|
72
|
-
meta={
|
|
73
|
-
<>
|
|
74
|
-
<span>{messages.common.modes[sync.mode]}</span>
|
|
75
|
-
<MetaDot />
|
|
76
|
-
<span className="truncate">{messages.common.writes(sync.target.dataset.id)}</span>
|
|
77
|
-
{sync.triggers.map((trigger) => (
|
|
78
|
-
<ScheduleMeta key={trigger.scheduleId} id={trigger.scheduleId} />
|
|
79
|
-
))}
|
|
80
|
-
{sync.latestRun ? (
|
|
55
|
+
<SectionPage section="console" page="syncs" {...browser.frame}>
|
|
56
|
+
{syncsQuery.isSuccess && syncsQuery.data.length > 0 ? (
|
|
57
|
+
<FolderContents browser={browser} rootLabel={messages.syncs.title}>
|
|
58
|
+
{(syncs) => (
|
|
59
|
+
<Panel>
|
|
60
|
+
{syncs.map((sync) => (
|
|
61
|
+
<PanelRow
|
|
62
|
+
key={sync.id}
|
|
63
|
+
href={`/console/syncs/${encodeURIComponent(sync.id)}`}
|
|
64
|
+
leading={<ConnectorIcon type={sync.connector.type} />}
|
|
65
|
+
title={<span className="truncate">{humanize(sync.id)}</span>}
|
|
66
|
+
meta={
|
|
81
67
|
<>
|
|
68
|
+
<span>{messages.common.modes[sync.mode]}</span>
|
|
82
69
|
<MetaDot />
|
|
83
|
-
<span>
|
|
84
|
-
{
|
|
70
|
+
<span className="truncate">
|
|
71
|
+
{messages.common.writes(sync.target.dataset.id)}
|
|
85
72
|
</span>
|
|
73
|
+
{sync.triggers.map((trigger) => (
|
|
74
|
+
<ScheduleMeta key={trigger.scheduleId} id={trigger.scheduleId} />
|
|
75
|
+
))}
|
|
76
|
+
<SyncTimeMeta sync={sync} />
|
|
77
|
+
{sync.accounts ? <AccountsMeta summary={sync.accounts} /> : null}
|
|
86
78
|
</>
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
79
|
+
}
|
|
80
|
+
trailing={
|
|
81
|
+
<>
|
|
82
|
+
<SyncStatusPill sync={sync} />
|
|
83
|
+
<ChevronRight className="size-4 text-muted-foreground/60" />
|
|
84
|
+
</>
|
|
85
|
+
}
|
|
86
|
+
/>
|
|
87
|
+
))}
|
|
88
|
+
</Panel>
|
|
89
|
+
)}
|
|
90
|
+
</FolderContents>
|
|
91
|
+
) : (
|
|
92
|
+
<Panel>
|
|
93
|
+
{syncsQuery.isPending ? (
|
|
94
|
+
<PanelSkeleton rows={3} interactive trailing={<TrailingSkeleton chevron />} />
|
|
95
|
+
) : syncsQuery.isError ? (
|
|
96
|
+
<PanelEmpty
|
|
97
|
+
tone="error"
|
|
98
|
+
icon={RefreshCw}
|
|
99
|
+
title={messages.syncs.title}
|
|
100
|
+
description={apiErrorMessage(syncsQuery.error, messages.common.loadFailed)}
|
|
101
|
+
/>
|
|
102
|
+
) : (
|
|
103
|
+
<PanelEmpty
|
|
104
|
+
icon={RefreshCw}
|
|
105
|
+
title={messages.syncs.emptyTitle}
|
|
106
|
+
description={messages.syncs.emptyDescription}
|
|
100
107
|
/>
|
|
101
|
-
)
|
|
102
|
-
|
|
103
|
-
|
|
108
|
+
)}
|
|
109
|
+
</Panel>
|
|
110
|
+
)}
|
|
104
111
|
</SectionPage>
|
|
105
112
|
)
|
|
106
113
|
}
|
|
@@ -124,7 +131,16 @@ export function ConsoleSyncPage() {
|
|
|
124
131
|
: false,
|
|
125
132
|
})
|
|
126
133
|
const sync = syncQuery.data
|
|
127
|
-
const
|
|
134
|
+
const accountsStats = useAccountsStats(sync?.accounts)
|
|
135
|
+
// Runs name their account: the connector's accounts give their labels.
|
|
136
|
+
const accountsQuery = useConnectorAccounts(sync?.connector.id ?? "", sync?.accounts !== undefined)
|
|
137
|
+
const accountLabels = new Map(
|
|
138
|
+
accountsQuery.data?.accounts.map(({ connection }) => [
|
|
139
|
+
connection.id,
|
|
140
|
+
connection.account.label,
|
|
141
|
+
]) ?? []
|
|
142
|
+
)
|
|
143
|
+
const back = folderBack({ href: "/console/syncs", label: messages.syncs.title }, sync?.folder)
|
|
128
144
|
|
|
129
145
|
if (!sync) {
|
|
130
146
|
return (
|
|
@@ -165,7 +181,8 @@ export function ConsoleSyncPage() {
|
|
|
165
181
|
)
|
|
166
182
|
}
|
|
167
183
|
|
|
168
|
-
|
|
184
|
+
// On a sync of an OAuth connector, the latest run is one account's: the accounts describe it.
|
|
185
|
+
const latestRun = sync.accounts ? null : sync.latestRun
|
|
169
186
|
// A failed latest run gets its own panel; its row leaves the failure out rather than repeat it.
|
|
170
187
|
const failedLatest = latestRun?.status === "failed" && latestRun.error ? latestRun : null
|
|
171
188
|
const dataset = sync.target.dataset
|
|
@@ -180,40 +197,44 @@ export function ConsoleSyncPage() {
|
|
|
180
197
|
title={humanize(sync.id)}
|
|
181
198
|
meta={
|
|
182
199
|
<>
|
|
183
|
-
{
|
|
184
|
-
<RunStatusPill status={latestRun.status} />
|
|
185
|
-
) : (
|
|
186
|
-
<Pill tone="muted">{messages.common.neverRun}</Pill>
|
|
187
|
-
)}
|
|
200
|
+
<SyncStatusPill sync={sync} />
|
|
188
201
|
<span>{messages.common.modes[sync.mode]}</span>
|
|
189
202
|
<MetaDot />
|
|
190
203
|
<Link to={datasetHref} className="hover:text-foreground hover:underline">
|
|
191
204
|
{messages.common.writes(dataset.id)}
|
|
192
205
|
</Link>
|
|
206
|
+
{sync.accounts ? (
|
|
207
|
+
<AccountsMeta
|
|
208
|
+
summary={sync.accounts}
|
|
209
|
+
href={`/console/connectors/${encodeURIComponent(sync.connector.id)}`}
|
|
210
|
+
/>
|
|
211
|
+
) : null}
|
|
193
212
|
</>
|
|
194
213
|
}
|
|
195
214
|
actions={<SyncButton sync={sync.id} variant="default" />}
|
|
196
215
|
>
|
|
197
216
|
<Stats
|
|
198
|
-
items={
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
+
items={
|
|
218
|
+
accountsStats ?? [
|
|
219
|
+
{
|
|
220
|
+
label: messages.common.lastRun,
|
|
221
|
+
value: latestRun ? (
|
|
222
|
+
statusLabels[latestRun.status]
|
|
223
|
+
) : (
|
|
224
|
+
<span className="text-muted-foreground">{messages.common.neverRun}</span>
|
|
225
|
+
),
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
label: messages.common.started,
|
|
229
|
+
value: latestRun ? format.relative(latestRun.startedAt ?? latestRun.queuedAt) : "—",
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
label: messages.common.took,
|
|
233
|
+
value: formatDuration(latestRun?.startedAt, latestRun?.finishedAt),
|
|
234
|
+
},
|
|
235
|
+
{ label: messages.syncs.rowsRead, value: numbers.count(latestRun?.rowsRead) },
|
|
236
|
+
]
|
|
237
|
+
}
|
|
217
238
|
/>
|
|
218
239
|
|
|
219
240
|
{failedLatest?.error ? (
|
|
@@ -250,6 +271,14 @@ export function ConsoleSyncPage() {
|
|
|
250
271
|
title={format.dateTime(run.startedAt ?? run.queuedAt)}
|
|
251
272
|
meta={
|
|
252
273
|
<>
|
|
274
|
+
{run.connectionId ? (
|
|
275
|
+
<>
|
|
276
|
+
<span className="truncate">
|
|
277
|
+
{accountLabels.get(run.connectionId) ?? run.connectionId}
|
|
278
|
+
</span>
|
|
279
|
+
<MetaDot />
|
|
280
|
+
</>
|
|
281
|
+
) : null}
|
|
253
282
|
<span>{messages.common.modes[run.mode]}</span>
|
|
254
283
|
{run.finishedAt ? (
|
|
255
284
|
<>
|
|
@@ -292,9 +321,15 @@ export function ConsoleSyncPage() {
|
|
|
292
321
|
) : null}
|
|
293
322
|
</>
|
|
294
323
|
}
|
|
295
|
-
trailing={
|
|
324
|
+
trailing={
|
|
325
|
+
needsReconnecting(run) ? (
|
|
326
|
+
<Pill tone="warn">{messages.syncs.needsReconnecting}</Pill>
|
|
327
|
+
) : (
|
|
328
|
+
<RunStatusPill status={run.status} />
|
|
329
|
+
)
|
|
330
|
+
}
|
|
296
331
|
>
|
|
297
|
-
{run.error && run.id !== failedLatest?.id ? (
|
|
332
|
+
{run.error && run.id !== failedLatest?.id && !needsReconnecting(run) ? (
|
|
298
333
|
<FailureSummary failure={run.error} compact />
|
|
299
334
|
) : null}
|
|
300
335
|
</PanelRow>
|