Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@
"@tanstack/react-start": "1.168.26",
"@tanstack/react-start-client": "1.168.14",
"@tanstack/react-table": "^8.21.3",
"@tanstack/workflow-core": "0.0.3",
"@tanstack/workflow-runtime": "0.0.2",
"@tanstack/workflow-store-drizzle-postgres": "0.0.4",
"@types/d3": "^7.4.3",
"@uploadthing/react": "^7.3.3",
"@visx/hierarchy": "^3.12.0",
Expand Down
65 changes: 65 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 2 additions & 5 deletions src/db/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1140,14 +1140,11 @@ export type NewIntentPackage = InferInsertModel<typeof intentPackages>

// Per-version snapshot of a package's skills (latest + last 5 versions)
//
// syncStatus acts as a durable work queue:
// syncStatus tracks domain progress for each discovered package version:
// 'pending' -- version discovered, tarball not yet downloaded/extracted
// 'synced' -- skills extracted and indexed successfully
// 'failed' -- tarball processing failed (will be retried next cycle)
//
// This means the scheduled function can be interrupted at any point and
// resume from where it left off. Only the currently in-flight version is
// at risk of being re-processed on restart (upserts make that safe).
// Workflow run/step replay lives in the Workflow Postgres store, not here.
export const intentPackageVersions = pgTable(
'intent_package_versions',
{
Expand Down
108 changes: 108 additions & 0 deletions src/routes/admin/intent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
getIntentAdminStats,
listIntentPackages,
listFailedVersions,
listIntentWorkflowRuns,
triggerIntentDiscover,
triggerIntentProcess,
retryIntentVersion,
Expand All @@ -40,6 +41,7 @@ const QK = {
stats: ['admin', 'intent', 'stats'] as const,
packages: ['admin', 'intent', 'packages'] as const,
failed: ['admin', 'intent', 'failed'] as const,
workflows: ['admin', 'intent', 'workflows'] as const,
}

// ---------------------------------------------------------------------------
Expand Down Expand Up @@ -69,6 +71,12 @@ function IntentAdminPage() {
queryFn: () => listFailedVersions(),
})

const workflowsQuery = useQuery({
queryKey: QK.workflows,
queryFn: () => listIntentWorkflowRuns(),
refetchInterval: 10_000,
})

const discoverMutation = useMutation({
mutationFn: () => triggerIntentDiscover(),
onSuccess: invalidateAll,
Expand Down Expand Up @@ -324,6 +332,11 @@ function IntentAdminPage() {
/>
</div>

<WorkflowRunsSection
runs={workflowsQuery.data ?? []}
loading={workflowsQuery.isLoading}
/>

{/* Failed versions (shown prominently when non-zero) */}
{(failedQuery.data?.length ?? 0) > 0 && (
<FailedVersionsSection
Expand Down Expand Up @@ -380,6 +393,101 @@ function StatCard({
)
}

function WorkflowRunsSection({
runs,
loading,
}: {
readonly runs: Array<{
runId: string
workflowId: string
workflowVersion?: string
status: string
waitingFor?: string
wakeAt: Date | null
createdAt: Date
updatedAt: Date
}>
readonly loading: boolean
}) {
return (
<div className="mb-6">
<h2 className="text-sm font-semibold text-gray-700 dark:text-gray-300 flex items-center gap-1.5 mb-2">
<Clock className="w-4 h-4" />
Workflow Runs
</h2>
{loading ? (
<div className="h-24 rounded-xl bg-gray-100 dark:bg-gray-800 animate-pulse" />
) : runs.length === 0 ? (
<Card className="p-4 text-sm text-gray-500 dark:text-gray-400">
No workflow runs recorded yet.
</Card>
) : (
<div className="rounded-xl border border-gray-200 dark:border-gray-800 overflow-hidden">
<table className="w-full text-sm">
<thead className="bg-gray-50 dark:bg-gray-900/50">
<tr>
<th className="text-left px-3 py-2 text-xs font-medium text-gray-500">
Workflow
</th>
<th className="text-left px-3 py-2 text-xs font-medium text-gray-500">
Status
</th>
<th className="text-left px-3 py-2 text-xs font-medium text-gray-500 hidden md:table-cell">
Run
</th>
<th className="text-left px-3 py-2 text-xs font-medium text-gray-500">
Updated
</th>
</tr>
</thead>
<tbody className="divide-y divide-gray-100 dark:divide-gray-800">
{runs.map((run) => (
<tr key={run.runId} className="bg-white dark:bg-gray-900">
<td className="px-3 py-2 font-mono text-xs text-gray-900 dark:text-gray-100">
{run.workflowId}
</td>
<td className="px-3 py-2">
<span
className={`inline-flex items-center rounded px-1.5 py-0.5 text-xs font-medium ${getWorkflowStatusClass(run.status)}`}
>
{run.waitingFor
? `${run.status}:${run.waitingFor}`
: run.status}
</span>
</td>
<td className="px-3 py-2 font-mono text-xs text-gray-500 dark:text-gray-400 hidden md:table-cell">
{run.runId}
</td>
<td className="px-3 py-2 text-xs text-gray-500 dark:text-gray-400">
{formatDistanceToNow(run.updatedAt, { addSuffix: true })}
</td>
</tr>
))}
</tbody>
</table>
</div>
)}
</div>
)
}

function getWorkflowStatusClass(status: string): string {
switch (status) {
case 'finished':
return 'bg-emerald-100 text-emerald-700 dark:bg-emerald-900/40 dark:text-emerald-300'
case 'errored':
case 'aborted':
return 'bg-red-100 text-red-700 dark:bg-red-900/40 dark:text-red-300'
case 'paused':
return 'bg-amber-100 text-amber-700 dark:bg-amber-900/40 dark:text-amber-300'
case 'running':
case 'queued':
return 'bg-sky-100 text-sky-700 dark:bg-sky-900/40 dark:text-sky-300'
default:
return 'bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300'
}
}

// ---------------------------------------------------------------------------
// Result banner
// ---------------------------------------------------------------------------
Expand Down
Loading
Loading