@agent-native/dispatch 0.6.0 → 0.6.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"app-keys-popover.d.ts","sourceRoot":"","sources":["../../src/components/app-keys-popover.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AA+B1D,UAAU,mBAAmB;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;IACnC,IAAI,CAAC,EAAE,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;CAC5C;AAED,wBAAgB,cAAc,CAAC,EAC7B,KAAK,EACL,OAAO,EACP,OAAO,EACP,KAAa,EACb,IAAe,GAChB,EAAE,mBAAmB,2CAiCrB"}
1
+ {"version":3,"file":"app-keys-popover.d.ts","sourceRoot":"","sources":["../../src/components/app-keys-popover.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAgC1D,UAAU,mBAAmB;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;IACnC,IAAI,CAAC,EAAE,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;CAC5C;AAED,wBAAgB,cAAc,CAAC,EAC7B,KAAK,EACL,OAAO,EACP,OAAO,EACP,KAAa,EACb,IAAe,GAChB,EAAE,mBAAmB,2CAiCrB"}
@@ -5,6 +5,7 @@ import { IconCheck, IconLoader2, IconRefresh, IconSettings, } from "@tabler/icon
5
5
  import { toast } from "sonner";
6
6
  import { Popover, PopoverContent, PopoverTrigger, } from "../components/ui/popover.js";
7
7
  import { Button } from "../components/ui/button.js";
8
+ import { Skeleton } from "../components/ui/skeleton.js";
8
9
  export function AppKeysPopover({ appId, appName, trigger, align = "end", side = "bottom", }) {
9
10
  const [open, setOpen] = useState(false);
10
11
  return (_jsxs(Popover, { open: open, onOpenChange: setOpen, children: [_jsx(PopoverTrigger, { asChild: true, children: trigger ?? (_jsx("button", { type: "button", "aria-label": `Manage keys for ${appName}`, onClick: (event) => {
@@ -71,7 +72,7 @@ function AppKeysPanel({ appId, appName }) {
71
72
  grantMutation.mutate({ secretId: secret.id, appId }, { onSettled });
72
73
  }
73
74
  };
74
- return (_jsxs("div", { className: "flex flex-col gap-3", children: [_jsxs("div", { className: "flex items-center justify-between gap-2 px-1", children: [_jsxs("div", { className: "min-w-0", children: [_jsxs("p", { className: "truncate text-sm font-semibold text-foreground", children: ["Keys for ", appName] }), _jsxs("p", { className: "text-[11px] text-muted-foreground", children: [grantedCount, " of ", typedSecrets.length, " granted"] })] }), _jsxs(Button, { type: "button", variant: "outline", size: "sm", disabled: syncMutation.isPending || grantedCount === 0, onClick: () => syncMutation.mutate({ appId }), className: "h-7 px-2", children: [syncMutation.isPending ? (_jsx(IconLoader2, { className: "h-3 w-3 animate-spin" })) : (_jsx(IconRefresh, { className: "h-3 w-3" })), _jsx("span", { className: "ml-1 text-xs", children: "Sync" })] })] }), _jsx("div", { className: "max-h-[320px] space-y-1.5 overflow-y-auto rounded-md border border-border bg-card p-1.5", children: isLoading ? (_jsx("p", { className: "px-3 py-3 text-xs text-muted-foreground", children: "Loading\u2026" })) : typedSecrets.length === 0 ? (_jsx("p", { className: "rounded-md border border-dashed border-border px-3 py-3 text-xs text-muted-foreground", children: "No vault keys yet. Add one from the Vault page." })) : (typedSecrets.map((secret) => {
75
+ return (_jsxs("div", { className: "flex flex-col gap-3", children: [_jsxs("div", { className: "flex items-center justify-between gap-2 px-1", children: [_jsxs("div", { className: "min-w-0", children: [_jsxs("p", { className: "truncate text-sm font-semibold text-foreground", children: ["Keys for ", appName] }), _jsxs("p", { className: "text-[11px] text-muted-foreground", children: [grantedCount, " of ", typedSecrets.length, " granted"] })] }), _jsxs(Button, { type: "button", variant: "outline", size: "sm", disabled: syncMutation.isPending || grantedCount === 0, onClick: () => syncMutation.mutate({ appId }), className: "h-7 px-2", children: [syncMutation.isPending ? (_jsx(IconLoader2, { className: "h-3 w-3 animate-spin" })) : (_jsx(IconRefresh, { className: "h-3 w-3" })), _jsx("span", { className: "ml-1 text-xs", children: "Sync" })] })] }), _jsx("div", { className: "max-h-[320px] space-y-1.5 overflow-y-auto rounded-md border border-border bg-card p-1.5", children: isLoading ? (_jsx("div", { className: "space-y-1.5 p-1.5", children: Array.from({ length: 3 }).map((_, index) => (_jsxs("div", { className: "flex items-start gap-3 rounded-md px-2.5 py-2", children: [_jsx(Skeleton, { className: "mt-0.5 h-4 w-4 shrink-0 rounded" }), _jsxs("div", { className: "flex-1 space-y-1.5", children: [_jsx(Skeleton, { className: "h-3 w-1/2" }), _jsx(Skeleton, { className: "h-3 w-3/4" })] })] }, index))) })) : typedSecrets.length === 0 ? (_jsx("p", { className: "rounded-md border border-dashed border-border px-3 py-3 text-xs text-muted-foreground", children: "No vault keys yet. Add one from the Vault page." })) : (typedSecrets.map((secret) => {
75
76
  const granted = grantBySecretId.has(secret.id);
76
77
  const pending = pendingSecretIds.has(secret.id);
77
78
  return (_jsxs("button", { type: "button", "aria-pressed": granted, disabled: pending, onClick: () => toggleSecret(secret), className: `flex w-full items-start gap-3 rounded-md px-2.5 py-2 text-left text-sm disabled:cursor-not-allowed disabled:opacity-60 ${pending ? "" : "cursor-pointer"} ${granted
@@ -1 +1 @@
1
- {"version":3,"file":"app-keys-popover.js","sourceRoot":"","sources":["../../src/components/app-keys-popover.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AAC1D,OA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BF,MAAM,CAAC,EAAE,CA8BP,CACV,CAAC;gBACJ,CAAC,CAAC,CACH,GACG,IACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { useMemo, useState, type ReactNode } from \"react\";\nimport { useActionMutation, useActionQuery } from \"@agent-native/core/client\";\nimport {\n IconCheck,\n IconLoader2,\n IconRefresh,\n IconSettings,\n} from \"@tabler/icons-react\";\nimport { toast } from \"sonner\";\nimport {\n Popover,\n PopoverContent,\n PopoverTrigger,\n} from \"@/components/ui/popover\";\nimport { Button } from \"@/components/ui/button\";\n\ninterface VaultSecret {\n id: string;\n name?: string | null;\n credentialKey: string;\n provider?: string | null;\n description?: string | null;\n}\n\ninterface VaultGrant {\n id: string;\n secretId: string;\n appId: string;\n status?: string | null;\n}\n\ninterface AppKeysPopoverProps {\n appId: string;\n appName: string;\n trigger?: ReactNode;\n align?: \"start\" | \"center\" | \"end\";\n side?: \"top\" | \"right\" | \"bottom\" | \"left\";\n}\n\nexport function AppKeysPopover({\n appId,\n appName,\n trigger,\n align = \"end\",\n side = \"bottom\",\n}: AppKeysPopoverProps) {\n const [open, setOpen] = useState(false);\n\n return (\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger asChild>\n {trigger ?? (\n <button\n type=\"button\"\n aria-label={`Manage keys for ${appName}`}\n onClick={(event) => {\n // Keep parent card click handlers from also firing. Do not\n // preventDefault here: Radix uses the same click to open the\n // popover trigger.\n event.stopPropagation();\n }}\n className=\"flex h-7 w-7 cursor-pointer items-center justify-center rounded-md border border-transparent text-muted-foreground/70 hover:border-border hover:bg-accent/40 hover:text-foreground\"\n >\n <IconSettings size={14} />\n </button>\n )}\n </PopoverTrigger>\n <PopoverContent\n align={align}\n side={side}\n sideOffset={6}\n className=\"w-80 p-3\"\n onClick={(event) => event.stopPropagation()}\n >\n {open ? <AppKeysPanel appId={appId} appName={appName} /> : null}\n </PopoverContent>\n </Popover>\n );\n}\n\nfunction AppKeysPanel({ appId, appName }: { appId: string; appName: string }) {\n const { data: secrets = [], isLoading: secretsLoading } = useActionQuery(\n \"list-vault-secret-options\",\n {},\n );\n const {\n data: grants = [],\n isLoading: grantsLoading,\n refetch: refetchGrants,\n } = useActionQuery(\"list-vault-grants\", { appId });\n\n const grantBySecretId = useMemo(() => {\n const map = new Map<string, VaultGrant>();\n for (const grant of grants as VaultGrant[]) {\n if (grant.status && grant.status !== \"active\") continue;\n map.set(grant.secretId, grant);\n }\n return map;\n }, [grants]);\n\n // Track per-secret pending state so a fast double-click on the same row\n // can't queue two `create-vault-grant` requests (which would silently\n // create duplicate active grants — a later revoke only clears one).\n const [pendingSecretIds, setPendingSecretIds] = useState<Set<string>>(\n () => new Set(),\n );\n const markPending = (secretId: string, pending: boolean) =>\n setPendingSecretIds((prev) => {\n const next = new Set(prev);\n if (pending) next.add(secretId);\n else next.delete(secretId);\n return next;\n });\n\n const grantMutation = useActionMutation(\"create-vault-grant\", {\n onSuccess: () => refetchGrants(),\n onError: (err) => toast.error(`Could not grant: ${String(err)}`),\n });\n\n const revokeMutation = useActionMutation(\"revoke-vault-grant\", {\n onSuccess: () => refetchGrants(),\n onError: (err) => toast.error(`Could not revoke: ${String(err)}`),\n });\n\n const syncMutation = useActionMutation(\"sync-vault-to-app\", {\n onSuccess: (result: any) => {\n const synced = result?.synced ?? 0;\n toast.success(\n synced > 0\n ? `Synced ${synced} key${synced === 1 ? \"\" : \"s\"} to ${appName}`\n : `${appName} is up to date`,\n );\n },\n onError: (err) => toast.error(`Sync failed: ${String(err)}`),\n });\n\n const isLoading = secretsLoading || grantsLoading;\n const grantedCount = grantBySecretId.size;\n const typedSecrets = secrets as VaultSecret[];\n\n const toggleSecret = (secret: VaultSecret) => {\n if (pendingSecretIds.has(secret.id)) return;\n const existing = grantBySecretId.get(secret.id);\n markPending(secret.id, true);\n const onSettled = () => markPending(secret.id, false);\n if (existing) {\n revokeMutation.mutate({ grantId: existing.id }, { onSettled });\n } else {\n grantMutation.mutate({ secretId: secret.id, appId }, { onSettled });\n }\n };\n\n return (\n <div className=\"flex flex-col gap-3\">\n <div className=\"flex items-center justify-between gap-2 px-1\">\n <div className=\"min-w-0\">\n <p className=\"truncate text-sm font-semibold text-foreground\">\n Keys for {appName}\n </p>\n <p className=\"text-[11px] text-muted-foreground\">\n {grantedCount} of {typedSecrets.length} granted\n </p>\n </div>\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n disabled={syncMutation.isPending || grantedCount === 0}\n onClick={() => syncMutation.mutate({ appId })}\n className=\"h-7 px-2\"\n >\n {syncMutation.isPending ? (\n <IconLoader2 className=\"h-3 w-3 animate-spin\" />\n ) : (\n <IconRefresh className=\"h-3 w-3\" />\n )}\n <span className=\"ml-1 text-xs\">Sync</span>\n </Button>\n </div>\n\n <div className=\"max-h-[320px] space-y-1.5 overflow-y-auto rounded-md border border-border bg-card p-1.5\">\n {isLoading ? (\n <p className=\"px-3 py-3 text-xs text-muted-foreground\">Loading…</p>\n ) : typedSecrets.length === 0 ? (\n <p className=\"rounded-md border border-dashed border-border px-3 py-3 text-xs text-muted-foreground\">\n No vault keys yet. Add one from the Vault page.\n </p>\n ) : (\n typedSecrets.map((secret) => {\n const granted = grantBySecretId.has(secret.id);\n const pending = pendingSecretIds.has(secret.id);\n return (\n <button\n key={secret.id}\n type=\"button\"\n aria-pressed={granted}\n disabled={pending}\n onClick={() => toggleSecret(secret)}\n className={`flex w-full items-start gap-3 rounded-md px-2.5 py-2 text-left text-sm disabled:cursor-not-allowed disabled:opacity-60 ${\n pending ? \"\" : \"cursor-pointer\"\n } ${\n granted\n ? \"border border-primary/45 bg-primary/5\"\n : \"border border-transparent hover:border-muted-foreground/30 hover:bg-accent/35\"\n }`}\n >\n <span\n className={`mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded border ${\n granted\n ? \"border-primary/60 bg-primary/10 text-primary\"\n : \"border-muted-foreground/35 text-transparent\"\n }`}\n >\n {granted ? <IconCheck className=\"h-3 w-3\" /> : null}\n </span>\n <span className=\"min-w-0 flex-1\">\n <span className=\"block truncate font-medium\">\n {secret.credentialKey}\n </span>\n <span className=\"block truncate text-xs text-muted-foreground/70\">\n {secret.provider || secret.name || \"Vault secret\"}\n </span>\n </span>\n </button>\n );\n })\n )}\n </div>\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"app-keys-popover.js","sourceRoot":"","sources":["../../src/components/app-keys-popover.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC9E,OAAO,EACL,SAAS,EACT,WAAW,EACX,WAAW,EACX,YAAY,GACb,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC/B,OAAO,EACL,OAAO,EACP,cAAc,EACd,cAAc,GACf,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAyBpD,MAAM,UAAU,cAAc,CAAC,EAC7B,KAAK,EACL,OAAO,EACP,OAAO,EACP,KAAK,GAAG,KAAK,EACb,IAAI,GAAG,QAAQ,GACK;IACpB,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAExC,OAAO,CACL,MAAC,OAAO,IAAC,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,aACxC,KAAC,cAAc,IAAC,OAAO,kBACpB,OAAO,IAAI,CACV,iBACE,IAAI,EAAC,QAAQ,gBACD,mBAAmB,OAAO,EAAE,EACxC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;wBACjB,2DAA2D;wBAC3D,6DAA6D;wBAC7D,mBAAmB;wBACnB,KAAK,CAAC,eAAe,EAAE,CAAC;oBAC1B,CAAC,EACD,SAAS,EAAC,oLAAo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AAG,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;oBAChD,OAAO,CACL,kBAEE,IAAI,EAAC,QAAQ,kBACC,OAAO,EACrB,QAAQ,EAAE,OAAO,EACjB,OAAO,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC,EACnC,SAAS,EAAE,0HACT,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,gBACjB,IACE,OAAO;4BACL,CAAC,CAAC,uCAAuC;4BACzC,CAAC,CAAC,+EACN,EAAE,aAEF,eACE,SAAS,EAAE,2EACT,OAAO;oCACL,CAAC,CAAC,8CAA8C;oCAChD,CAAC,CAAC,6CACN,EAAE,YAED,OAAO,CAAC,CAAC,CAAC,KAAC,SAAS,IAAC,SAAS,EAAC,SAAS,GAAG,CAAC,CAAC,CAAC,IAAI,GAC9C,EACP,gBAAM,SAAS,EAAC,gBAAgB,aAC9B,eAAM,SAAS,EAAC,4BAA4B,YACzC,MAAM,CAAC,aAAa,GAChB,EACP,eAAM,SAAS,EAAC,iDAAiD,YAC9D,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,IAAI,IAAI,cAAc,GAC5C,IACF,KA7BF,MAAM,CAAC,EAAE,CA8BP,CACV,CAAC;gBACJ,CAAC,CAAC,CACH,GACG,IACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { useMemo, useState, type ReactNode } from \"react\";\nimport { useActionMutation, useActionQuery } from \"@agent-native/core/client\";\nimport {\n IconCheck,\n IconLoader2,\n IconRefresh,\n IconSettings,\n} from \"@tabler/icons-react\";\nimport { toast } from \"sonner\";\nimport {\n Popover,\n PopoverContent,\n PopoverTrigger,\n} from \"@/components/ui/popover\";\nimport { Button } from \"@/components/ui/button\";\nimport { Skeleton } from \"@/components/ui/skeleton\";\n\ninterface VaultSecret {\n id: string;\n name?: string | null;\n credentialKey: string;\n provider?: string | null;\n description?: string | null;\n}\n\ninterface VaultGrant {\n id: string;\n secretId: string;\n appId: string;\n status?: string | null;\n}\n\ninterface AppKeysPopoverProps {\n appId: string;\n appName: string;\n trigger?: ReactNode;\n align?: \"start\" | \"center\" | \"end\";\n side?: \"top\" | \"right\" | \"bottom\" | \"left\";\n}\n\nexport function AppKeysPopover({\n appId,\n appName,\n trigger,\n align = \"end\",\n side = \"bottom\",\n}: AppKeysPopoverProps) {\n const [open, setOpen] = useState(false);\n\n return (\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger asChild>\n {trigger ?? (\n <button\n type=\"button\"\n aria-label={`Manage keys for ${appName}`}\n onClick={(event) => {\n // Keep parent card click handlers from also firing. Do not\n // preventDefault here: Radix uses the same click to open the\n // popover trigger.\n event.stopPropagation();\n }}\n className=\"flex h-7 w-7 cursor-pointer items-center justify-center rounded-md border border-transparent text-muted-foreground/70 hover:border-border hover:bg-accent/40 hover:text-foreground\"\n >\n <IconSettings size={14} />\n </button>\n )}\n </PopoverTrigger>\n <PopoverContent\n align={align}\n side={side}\n sideOffset={6}\n className=\"w-80 p-3\"\n onClick={(event) => event.stopPropagation()}\n >\n {open ? <AppKeysPanel appId={appId} appName={appName} /> : null}\n </PopoverContent>\n </Popover>\n );\n}\n\nfunction AppKeysPanel({ appId, appName }: { appId: string; appName: string }) {\n const { data: secrets = [], isLoading: secretsLoading } = useActionQuery(\n \"list-vault-secret-options\",\n {},\n );\n const {\n data: grants = [],\n isLoading: grantsLoading,\n refetch: refetchGrants,\n } = useActionQuery(\"list-vault-grants\", { appId });\n\n const grantBySecretId = useMemo(() => {\n const map = new Map<string, VaultGrant>();\n for (const grant of grants as VaultGrant[]) {\n if (grant.status && grant.status !== \"active\") continue;\n map.set(grant.secretId, grant);\n }\n return map;\n }, [grants]);\n\n // Track per-secret pending state so a fast double-click on the same row\n // can't queue two `create-vault-grant` requests (which would silently\n // create duplicate active grants — a later revoke only clears one).\n const [pendingSecretIds, setPendingSecretIds] = useState<Set<string>>(\n () => new Set(),\n );\n const markPending = (secretId: string, pending: boolean) =>\n setPendingSecretIds((prev) => {\n const next = new Set(prev);\n if (pending) next.add(secretId);\n else next.delete(secretId);\n return next;\n });\n\n const grantMutation = useActionMutation(\"create-vault-grant\", {\n onSuccess: () => refetchGrants(),\n onError: (err) => toast.error(`Could not grant: ${String(err)}`),\n });\n\n const revokeMutation = useActionMutation(\"revoke-vault-grant\", {\n onSuccess: () => refetchGrants(),\n onError: (err) => toast.error(`Could not revoke: ${String(err)}`),\n });\n\n const syncMutation = useActionMutation(\"sync-vault-to-app\", {\n onSuccess: (result: any) => {\n const synced = result?.synced ?? 0;\n toast.success(\n synced > 0\n ? `Synced ${synced} key${synced === 1 ? \"\" : \"s\"} to ${appName}`\n : `${appName} is up to date`,\n );\n },\n onError: (err) => toast.error(`Sync failed: ${String(err)}`),\n });\n\n const isLoading = secretsLoading || grantsLoading;\n const grantedCount = grantBySecretId.size;\n const typedSecrets = secrets as VaultSecret[];\n\n const toggleSecret = (secret: VaultSecret) => {\n if (pendingSecretIds.has(secret.id)) return;\n const existing = grantBySecretId.get(secret.id);\n markPending(secret.id, true);\n const onSettled = () => markPending(secret.id, false);\n if (existing) {\n revokeMutation.mutate({ grantId: existing.id }, { onSettled });\n } else {\n grantMutation.mutate({ secretId: secret.id, appId }, { onSettled });\n }\n };\n\n return (\n <div className=\"flex flex-col gap-3\">\n <div className=\"flex items-center justify-between gap-2 px-1\">\n <div className=\"min-w-0\">\n <p className=\"truncate text-sm font-semibold text-foreground\">\n Keys for {appName}\n </p>\n <p className=\"text-[11px] text-muted-foreground\">\n {grantedCount} of {typedSecrets.length} granted\n </p>\n </div>\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n disabled={syncMutation.isPending || grantedCount === 0}\n onClick={() => syncMutation.mutate({ appId })}\n className=\"h-7 px-2\"\n >\n {syncMutation.isPending ? (\n <IconLoader2 className=\"h-3 w-3 animate-spin\" />\n ) : (\n <IconRefresh className=\"h-3 w-3\" />\n )}\n <span className=\"ml-1 text-xs\">Sync</span>\n </Button>\n </div>\n\n <div className=\"max-h-[320px] space-y-1.5 overflow-y-auto rounded-md border border-border bg-card p-1.5\">\n {isLoading ? (\n <div className=\"space-y-1.5 p-1.5\">\n {Array.from({ length: 3 }).map((_, index) => (\n <div\n key={index}\n className=\"flex items-start gap-3 rounded-md px-2.5 py-2\"\n >\n <Skeleton className=\"mt-0.5 h-4 w-4 shrink-0 rounded\" />\n <div className=\"flex-1 space-y-1.5\">\n <Skeleton className=\"h-3 w-1/2\" />\n <Skeleton className=\"h-3 w-3/4\" />\n </div>\n </div>\n ))}\n </div>\n ) : typedSecrets.length === 0 ? (\n <p className=\"rounded-md border border-dashed border-border px-3 py-3 text-xs text-muted-foreground\">\n No vault keys yet. Add one from the Vault page.\n </p>\n ) : (\n typedSecrets.map((secret) => {\n const granted = grantBySecretId.has(secret.id);\n const pending = pendingSecretIds.has(secret.id);\n return (\n <button\n key={secret.id}\n type=\"button\"\n aria-pressed={granted}\n disabled={pending}\n onClick={() => toggleSecret(secret)}\n className={`flex w-full items-start gap-3 rounded-md px-2.5 py-2 text-left text-sm disabled:cursor-not-allowed disabled:opacity-60 ${\n pending ? \"\" : \"cursor-pointer\"\n } ${\n granted\n ? \"border border-primary/45 bg-primary/5\"\n : \"border border-transparent hover:border-muted-foreground/30 hover:bg-accent/35\"\n }`}\n >\n <span\n className={`mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded border ${\n granted\n ? \"border-primary/60 bg-primary/10 text-primary\"\n : \"border-muted-foreground/35 text-transparent\"\n }`}\n >\n {granted ? <IconCheck className=\"h-3 w-3\" /> : null}\n </span>\n <span className=\"min-w-0 flex-1\">\n <span className=\"block truncate font-medium\">\n {secret.credentialKey}\n </span>\n <span className=\"block truncate text-xs text-muted-foreground/70\">\n {secret.provider || secret.name || \"Vault secret\"}\n </span>\n </span>\n </button>\n );\n })\n )}\n </div>\n </div>\n );\n}\n"]}
@@ -2,29 +2,7 @@ import { type LoaderFunctionArgs } from "react-router";
2
2
  export declare function meta(): {
3
3
  title: string;
4
4
  }[];
5
- /**
6
- * Catch-all for `/dispatch/<segment>` paths that don't match an explicit
7
- * Dispatch route. When `<segment>` is the id of a workspace app sibling
8
- * (e.g. `/dispatch/todo` after Builder.io routes a "navigate to /todo"
9
- * call through Dispatch's mount point), bounce to the absolute `/<appId>`
10
- * so the user lands on the actual app instead of a 404 inside Dispatch.
11
- *
12
- * Server-side redirect: we resolve the workspace app manifest via the
13
- * shared `loadWorkspaceAppsManifest()` helper, which checks the
14
- * `AGENT_NATIVE_WORKSPACE_APPS_JSON` env var, then the
15
- * `.agent-native/workspace-apps.json` file written by `workspace-deploy.ts`,
16
- * then a live filesystem scan of `apps/` for local dev. We then throw
17
- * `redirect("/<appId>")`. React Router 7 does not prepend the basename to
18
- * absolute paths returned from a loader, so the redirect escapes Dispatch's
19
- * `/dispatch` mount cleanly.
20
- *
21
- * Why a catch-all instead of fixing the agent prompt: Builder.io currently
22
- * resolves "navigate to /todo" relative to Dispatch's mount, sending the
23
- * user to /dispatch/todo. The same wrong path then gets captured as the
24
- * OAuth callbackURL, so Google sign-in completes back at /dispatch/todo
25
- * and looks broken. This route fixes both the post-creation navigation
26
- * and the OAuth round-trip from a single place.
27
- */
28
5
  export declare function loader({ params }: LoaderFunctionArgs): any;
6
+ export declare function clientLoader({ params }: LoaderFunctionArgs): any;
29
7
  export default function WorkspaceAppCatchAllRoute(): import("react/jsx-runtime").JSX.Element;
30
8
  //# sourceMappingURL=$appId.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"$appId.d.ts","sourceRoot":"","sources":["../../../src/routes/pages/$appId.tsx"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,kBAAkB,EACxB,MAAM,cAAc,CAAC;AAiBtB,wBAAgB,IAAI;;IAEnB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE,kBAAkB,OAUpD;AAED,MAAM,CAAC,OAAO,UAAU,yBAAyB,4CA0FhD"}
1
+ {"version":3,"file":"$appId.d.ts","sourceRoot":"","sources":["../../../src/routes/pages/$appId.tsx"],"names":[],"mappings":"AACA,OAAO,EAKL,KAAK,kBAAkB,EACxB,MAAM,cAAc,CAAC;AAiBtB,wBAAgB,IAAI;;IAEnB;AAmCD,wBAAgB,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE,kBAAkB,OAYpD;AAED,wBAAgB,YAAY,CAAC,EAAE,MAAM,EAAE,EAAE,kBAAkB,OAI1D;AAED,MAAM,CAAC,OAAO,UAAU,yBAAyB,4CAgGhD"}
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useEffect, useMemo } from "react";
3
- import { Link, redirect, useParams, } from "react-router";
3
+ import { Link, Navigate, redirect, useParams, } from "react-router";
4
4
  import { useActionQuery, appPath } from "@agent-native/core/client";
5
5
  import { loadWorkspaceAppsManifest } from "@agent-native/core/server/agent-discovery";
6
6
  import { IconArrowLeft, IconArrowUpRight, IconClockHour4, } from "@tabler/icons-react";
@@ -34,11 +34,24 @@ export function meta() {
34
34
  * OAuth callbackURL, so Google sign-in completes back at /dispatch/todo
35
35
  * and looks broken. This route fixes both the post-creation navigation
36
36
  * and the OAuth round-trip from a single place.
37
+ *
38
+ * `appId === "dispatch"` short-circuit: when the segment matches Dispatch
39
+ * itself (e.g. `/dispatch/dispatch`), we go straight to the overview rather
40
+ * than chaining through `/dispatch` (which polled `useActionQuery` re-fired
41
+ * `window.location.assign` against and looped forever in production).
37
42
  */
43
+ function dispatchSelfRedirect(appId) {
44
+ if (appId === "dispatch")
45
+ return appPath("/overview");
46
+ return null;
47
+ }
38
48
  export function loader({ params }) {
39
49
  const appId = params.appId;
40
50
  if (!appId)
41
51
  return null;
52
+ const selfTarget = dispatchSelfRedirect(appId);
53
+ if (selfTarget)
54
+ throw redirect(selfTarget);
42
55
  const apps = loadWorkspaceAppsManifest();
43
56
  if (!apps)
44
57
  return null;
@@ -48,16 +61,28 @@ export function loader({ params }) {
48
61
  throw redirect(target);
49
62
  return null;
50
63
  }
64
+ export function clientLoader({ params }) {
65
+ const selfTarget = dispatchSelfRedirect(params.appId);
66
+ if (selfTarget)
67
+ throw redirect(selfTarget);
68
+ return null;
69
+ }
51
70
  export default function WorkspaceAppCatchAllRoute() {
52
71
  const { appId } = useParams();
53
72
  const { data: apps = [], isLoading } = useActionQuery("list-workspace-apps", { includeAgentCards: false }, { refetchInterval: 2_000 });
54
73
  const app = useMemo(() => apps.find((item) => item.id === appId) ?? null, [appId, apps]);
55
74
  const href = app ? workspaceAppHref(app) : null;
75
+ const isSelfReference = appId === "dispatch";
56
76
  useEffect(() => {
77
+ if (isSelfReference)
78
+ return;
57
79
  if (!app || app.status === "pending" || !href)
58
80
  return;
59
81
  window.location.assign(href);
60
- }, [app, href]);
82
+ }, [app, href, isSelfReference]);
83
+ if (isSelfReference) {
84
+ return _jsx(Navigate, { to: appPath("/overview"), replace: true });
85
+ }
61
86
  if ((isLoading && !app) || (app && app.status !== "pending" && href)) {
62
87
  return (_jsx("div", { className: "flex h-screen w-full items-center justify-center", children: _jsx(Spinner, { className: "size-8" }) }));
63
88
  }
@@ -1 +1 @@
1
- {"version":3,"file":"$appId.js","sourceRoot":"","sources":["../../../src/routes/pages/$appId.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EACL,IAAI,EACJ,QAAQ,EACR,SAAS,GAEV,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AACtF,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,cAAc,GACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,OAAO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import {\n Link,\n redirect,\n useParams,\n type LoaderFunctionArgs,\n} from \"react-router\";\nimport { useActionQuery, appPath } from \"@agent-native/core/client\";\nimport { loadWorkspaceAppsManifest } from \"@agent-native/core/server/agent-discovery\";\nimport {\n IconArrowLeft,\n IconArrowUpRight,\n IconClockHour4,\n} from \"@tabler/icons-react\";\nimport { DispatchShell } from \"@/components/dispatch-shell\";\nimport { Spinner } from \"@/components/ui/spinner\";\nimport { Badge } from \"@/components/ui/badge\";\nimport { Button } from \"@/components/ui/button\";\nimport {\n workspaceAppHref,\n type WorkspaceAppSummary,\n} from \"@/lib/workspace-apps\";\n\nexport function meta() {\n return [{ title: \"Workspace app - Dispatch\" }];\n}\n\n/**\n * Catch-all for `/dispatch/<segment>` paths that don't match an explicit\n * Dispatch route. When `<segment>` is the id of a workspace app sibling\n * (e.g. `/dispatch/todo` after Builder.io routes a \"navigate to /todo\"\n * call through Dispatch's mount point), bounce to the absolute `/<appId>`\n * so the user lands on the actual app instead of a 404 inside Dispatch.\n *\n * Server-side redirect: we resolve the workspace app manifest via the\n * shared `loadWorkspaceAppsManifest()` helper, which checks the\n * `AGENT_NATIVE_WORKSPACE_APPS_JSON` env var, then the\n * `.agent-native/workspace-apps.json` file written by `workspace-deploy.ts`,\n * then a live filesystem scan of `apps/` for local dev. We then throw\n * `redirect(\"/<appId>\")`. React Router 7 does not prepend the basename to\n * absolute paths returned from a loader, so the redirect escapes Dispatch's\n * `/dispatch` mount cleanly.\n *\n * Why a catch-all instead of fixing the agent prompt: Builder.io currently\n * resolves \"navigate to /todo\" relative to Dispatch's mount, sending the\n * user to /dispatch/todo. The same wrong path then gets captured as the\n * OAuth callbackURL, so Google sign-in completes back at /dispatch/todo\n * and looks broken. This route fixes both the post-creation navigation\n * and the OAuth round-trip from a single place.\n */\nexport function loader({ params }: LoaderFunctionArgs) {\n const appId = params.appId;\n if (!appId) return null;\n const apps = loadWorkspaceAppsManifest();\n if (!apps) return null;\n const app = apps.find((entry) => entry?.id === appId);\n const target =\n app?.path && app.path.startsWith(\"/\") ? app.path : app ? `/${appId}` : null;\n if (target) throw redirect(target);\n return null;\n}\n\nexport default function WorkspaceAppCatchAllRoute() {\n const { appId } = useParams();\n const { data: apps = [], isLoading } = useActionQuery(\n \"list-workspace-apps\",\n { includeAgentCards: false },\n { refetchInterval: 2_000 },\n );\n const app = useMemo(\n () =>\n (apps as WorkspaceAppSummary[]).find((item) => item.id === appId) ?? null,\n [appId, apps],\n );\n const href = app ? workspaceAppHref(app) : null;\n\n useEffect(() => {\n if (!app || app.status === \"pending\" || !href) return;\n window.location.assign(href);\n }, [app, href]);\n\n if ((isLoading && !app) || (app && app.status !== \"pending\" && href)) {\n return (\n <div className=\"flex h-screen w-full items-center justify-center\">\n <Spinner className=\"size-8\" />\n </div>\n );\n }\n\n return (\n <DispatchShell\n title={app?.name || \"Page not found\"}\n description=\"This route is not in the workspace app list yet.\"\n >\n <div className=\"max-w-2xl rounded-lg border bg-card p-5\">\n <Button asChild size=\"sm\" variant=\"ghost\" className=\"-ml-2 mb-4\">\n <Link to={appPath(\"/overview\")}>\n <IconArrowLeft size={15} className=\"mr-1.5\" />\n Overview\n </Link>\n </Button>\n\n {app?.status === \"pending\" ? (\n <div className=\"space-y-4\">\n <div className=\"flex flex-wrap items-center gap-2\">\n <h2 className=\"text-base font-semibold text-foreground\">\n {app.name}\n </h2>\n <Badge\n variant=\"outline\"\n className=\"gap-1 border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300\"\n >\n <IconClockHour4 size={12} />\n Building\n </Badge>\n </div>\n <p className=\"text-sm text-muted-foreground\">\n This app is being created. It will be available at{\" \"}\n <span className=\"font-mono text-foreground\">{app.path}</span>{\" \"}\n after its branch is merged and the workspace deploy finishes.\n </p>\n {app.branchName ? (\n <p className=\"text-xs text-muted-foreground\">\n Branch: {app.branchName}\n </p>\n ) : null}\n {app.builderUrl ? (\n <Button asChild>\n <a href={app.builderUrl} target=\"_blank\" rel=\"noreferrer\">\n Open Builder branch\n <IconArrowUpRight size={15} className=\"ml-1.5\" />\n </a>\n </Button>\n ) : null}\n </div>\n ) : (\n <div className=\"space-y-3\">\n <h2 className=\"text-base font-semibold text-foreground\">\n Page not found\n </h2>\n <p className=\"text-sm text-muted-foreground\">\n <span className=\"font-mono text-foreground\">/{appId}</span> isn't\n a Dispatch tab or a workspace app in this workspace.\n </p>\n <Button asChild>\n <Link to={appPath(\"/apps\")}>Browse apps</Link>\n </Button>\n </div>\n )}\n </div>\n </DispatchShell>\n );\n}\n"]}
1
+ {"version":3,"file":"$appId.js","sourceRoot":"","sources":["../../../src/routes/pages/$appId.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EACL,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,SAAS,GAEV,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AACtF,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,cAAc,GACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EACL,gBAAgB,GAEjB,MAAM,sBAAsB,CAAC;AAE9B,MAAM,UAAU,IAAI;IAClB,OAAO,CAAC,EAAE,KAAK,EAAE,0BAA0B,EAAE,CAAC,CAAC;AACjD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,SAAS,oBAAoB,CAAC,KAAyB;IACrD,IAAI,KAAK,KAAK,UAAU;QAAE,OAAO,OAAO,CAAC,WAAW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,+BAElD,EACL,aAAG,SAAS,EAAC,+BAA+B,aAC1C,gBAAM,SAAS,EAAC,2BAA2B,kBAAG,KAAK,IAAQ,mEAEzD,EACJ,KAAC,MAAM,IAAC,OAAO,kBACb,KAAC,IAAI,IAAC,EAAE,EAAE,OAAO,CAAC,OAAO,CAAC,4BAAoB,GACvC,IACL,CACP,IACG,GACQ,CACjB,CAAC;AACJ,CAAC","sourcesContent":["import { useEffect, useMemo } from \"react\";\nimport {\n Link,\n Navigate,\n redirect,\n useParams,\n type LoaderFunctionArgs,\n} from \"react-router\";\nimport { useActionQuery, appPath } from \"@agent-native/core/client\";\nimport { loadWorkspaceAppsManifest } from \"@agent-native/core/server/agent-discovery\";\nimport {\n IconArrowLeft,\n IconArrowUpRight,\n IconClockHour4,\n} from \"@tabler/icons-react\";\nimport { DispatchShell } from \"@/components/dispatch-shell\";\nimport { Spinner } from \"@/components/ui/spinner\";\nimport { Badge } from \"@/components/ui/badge\";\nimport { Button } from \"@/components/ui/button\";\nimport {\n workspaceAppHref,\n type WorkspaceAppSummary,\n} from \"@/lib/workspace-apps\";\n\nexport function meta() {\n return [{ title: \"Workspace app - Dispatch\" }];\n}\n\n/**\n * Catch-all for `/dispatch/<segment>` paths that don't match an explicit\n * Dispatch route. When `<segment>` is the id of a workspace app sibling\n * (e.g. `/dispatch/todo` after Builder.io routes a \"navigate to /todo\"\n * call through Dispatch's mount point), bounce to the absolute `/<appId>`\n * so the user lands on the actual app instead of a 404 inside Dispatch.\n *\n * Server-side redirect: we resolve the workspace app manifest via the\n * shared `loadWorkspaceAppsManifest()` helper, which checks the\n * `AGENT_NATIVE_WORKSPACE_APPS_JSON` env var, then the\n * `.agent-native/workspace-apps.json` file written by `workspace-deploy.ts`,\n * then a live filesystem scan of `apps/` for local dev. We then throw\n * `redirect(\"/<appId>\")`. React Router 7 does not prepend the basename to\n * absolute paths returned from a loader, so the redirect escapes Dispatch's\n * `/dispatch` mount cleanly.\n *\n * Why a catch-all instead of fixing the agent prompt: Builder.io currently\n * resolves \"navigate to /todo\" relative to Dispatch's mount, sending the\n * user to /dispatch/todo. The same wrong path then gets captured as the\n * OAuth callbackURL, so Google sign-in completes back at /dispatch/todo\n * and looks broken. This route fixes both the post-creation navigation\n * and the OAuth round-trip from a single place.\n *\n * `appId === \"dispatch\"` short-circuit: when the segment matches Dispatch\n * itself (e.g. `/dispatch/dispatch`), we go straight to the overview rather\n * than chaining through `/dispatch` (which polled `useActionQuery` re-fired\n * `window.location.assign` against and looped forever in production).\n */\nfunction dispatchSelfRedirect(appId: string | undefined): string | null {\n if (appId === \"dispatch\") return appPath(\"/overview\");\n return null;\n}\n\nexport function loader({ params }: LoaderFunctionArgs) {\n const appId = params.appId;\n if (!appId) return null;\n const selfTarget = dispatchSelfRedirect(appId);\n if (selfTarget) throw redirect(selfTarget);\n const apps = loadWorkspaceAppsManifest();\n if (!apps) return null;\n const app = apps.find((entry) => entry?.id === appId);\n const target =\n app?.path && app.path.startsWith(\"/\") ? app.path : app ? `/${appId}` : null;\n if (target) throw redirect(target);\n return null;\n}\n\nexport function clientLoader({ params }: LoaderFunctionArgs) {\n const selfTarget = dispatchSelfRedirect(params.appId);\n if (selfTarget) throw redirect(selfTarget);\n return null;\n}\n\nexport default function WorkspaceAppCatchAllRoute() {\n const { appId } = useParams();\n const { data: apps = [], isLoading } = useActionQuery(\n \"list-workspace-apps\",\n { includeAgentCards: false },\n { refetchInterval: 2_000 },\n );\n const app = useMemo(\n () =>\n (apps as WorkspaceAppSummary[]).find((item) => item.id === appId) ?? null,\n [appId, apps],\n );\n const href = app ? workspaceAppHref(app) : null;\n const isSelfReference = appId === \"dispatch\";\n\n useEffect(() => {\n if (isSelfReference) return;\n if (!app || app.status === \"pending\" || !href) return;\n window.location.assign(href);\n }, [app, href, isSelfReference]);\n\n if (isSelfReference) {\n return <Navigate to={appPath(\"/overview\")} replace />;\n }\n\n if ((isLoading && !app) || (app && app.status !== \"pending\" && href)) {\n return (\n <div className=\"flex h-screen w-full items-center justify-center\">\n <Spinner className=\"size-8\" />\n </div>\n );\n }\n\n return (\n <DispatchShell\n title={app?.name || \"Page not found\"}\n description=\"This route is not in the workspace app list yet.\"\n >\n <div className=\"max-w-2xl rounded-lg border bg-card p-5\">\n <Button asChild size=\"sm\" variant=\"ghost\" className=\"-ml-2 mb-4\">\n <Link to={appPath(\"/overview\")}>\n <IconArrowLeft size={15} className=\"mr-1.5\" />\n Overview\n </Link>\n </Button>\n\n {app?.status === \"pending\" ? (\n <div className=\"space-y-4\">\n <div className=\"flex flex-wrap items-center gap-2\">\n <h2 className=\"text-base font-semibold text-foreground\">\n {app.name}\n </h2>\n <Badge\n variant=\"outline\"\n className=\"gap-1 border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300\"\n >\n <IconClockHour4 size={12} />\n Building\n </Badge>\n </div>\n <p className=\"text-sm text-muted-foreground\">\n This app is being created. It will be available at{\" \"}\n <span className=\"font-mono text-foreground\">{app.path}</span>{\" \"}\n after its branch is merged and the workspace deploy finishes.\n </p>\n {app.branchName ? (\n <p className=\"text-xs text-muted-foreground\">\n Branch: {app.branchName}\n </p>\n ) : null}\n {app.builderUrl ? (\n <Button asChild>\n <a href={app.builderUrl} target=\"_blank\" rel=\"noreferrer\">\n Open Builder branch\n <IconArrowUpRight size={15} className=\"ml-1.5\" />\n </a>\n </Button>\n ) : null}\n </div>\n ) : (\n <div className=\"space-y-3\">\n <h2 className=\"text-base font-semibold text-foreground\">\n Page not found\n </h2>\n <p className=\"text-sm text-muted-foreground\">\n <span className=\"font-mono text-foreground\">/{appId}</span> isn't\n a Dispatch tab or a workspace app in this workspace.\n </p>\n <Button asChild>\n <Link to={appPath(\"/apps\")}>Browse apps</Link>\n </Button>\n </div>\n )}\n </div>\n </DispatchShell>\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"approval.d.ts","sourceRoot":"","sources":["../../../src/routes/pages/approval.tsx"],"names":[],"mappings":"AAoBA,wBAAgB,IAAI;;IAEnB;AAoCD,MAAM,CAAC,OAAO,UAAU,oBAAoB,4CAwL3C"}
1
+ {"version":3,"file":"approval.d.ts","sourceRoot":"","sources":["../../../src/routes/pages/approval.tsx"],"names":[],"mappings":"AAqBA,wBAAgB,IAAI;;IAEnB;AAoCD,MAAM,CAAC,OAAO,UAAU,oBAAoB,4CAqN3C"}
@@ -4,6 +4,7 @@ import { useActionMutation, useActionQuery, isInAgentEmbed, postNavigate, appPat
4
4
  import { toast } from "sonner";
5
5
  import { Button } from "../../components/ui/button.js";
6
6
  import { Badge } from "../../components/ui/badge.js";
7
+ import { Skeleton } from "../../components/ui/skeleton.js";
7
8
  import { IconCheck, IconX, IconArrowUpRight, IconShieldCheck, IconClock, IconAlertCircle, } from "@tabler/icons-react";
8
9
  export function meta() {
9
10
  return [{ title: "Approval — Dispatch" }];
@@ -33,7 +34,7 @@ export default function ApprovalPreviewRoute() {
33
34
  return (_jsx("div", { className: "flex min-h-screen items-center justify-center bg-background p-6", children: _jsxs("div", { className: "w-full max-w-md rounded-2xl border bg-card p-6 text-center", children: [_jsx(IconAlertCircle, { size: 32, className: "mx-auto mb-3 text-muted-foreground" }), _jsx("p", { className: "text-sm font-medium text-foreground", children: "No approval id provided" }), _jsxs("p", { className: "mt-1 text-xs text-muted-foreground", children: ["Add ", _jsx("code", { className: "rounded bg-muted px-1", children: "?id=<id>" }), " to the URL."] })] }) }));
34
35
  }
35
36
  if (isLoading) {
36
- return (_jsx("div", { className: "flex min-h-screen items-center justify-center bg-background p-6", children: _jsx("div", { className: "w-full max-w-md rounded-2xl border bg-card p-6 text-center", children: _jsx("p", { className: "text-sm text-muted-foreground", children: "Loading..." }) }) }));
37
+ return (_jsx("div", { className: "flex min-h-screen items-start justify-center bg-background p-6", children: _jsx("div", { className: "w-full max-w-md space-y-4", children: _jsxs("div", { className: "rounded-2xl border bg-card p-5", children: [_jsxs("div", { className: "flex items-start gap-3", children: [_jsx(Skeleton, { className: "h-9 w-9 shrink-0 rounded-xl" }), _jsxs("div", { className: "min-w-0 flex-1 space-y-2", children: [_jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [_jsx(Skeleton, { className: "h-4 w-40" }), _jsx(Skeleton, { className: "h-5 w-20 rounded-full" })] }), _jsx(Skeleton, { className: "h-3 w-32" })] })] }), _jsxs("div", { className: "mt-4 space-y-2 rounded-xl border bg-muted/30 px-4 py-3", children: [_jsxs("div", { className: "flex justify-between gap-4", children: [_jsx(Skeleton, { className: "h-3 w-20" }), _jsx(Skeleton, { className: "h-3 w-24" })] }), _jsxs("div", { className: "flex justify-between gap-4", children: [_jsx(Skeleton, { className: "h-3 w-20" }), _jsx(Skeleton, { className: "h-3 w-28" })] }), _jsxs("div", { className: "flex justify-between gap-4", children: [_jsx(Skeleton, { className: "h-3 w-16" }), _jsx(Skeleton, { className: "h-3 w-32" })] })] }), _jsxs("div", { className: "mt-4 flex gap-2", children: [_jsx(Skeleton, { className: "h-8 flex-1 rounded-md" }), _jsx(Skeleton, { className: "h-8 flex-1 rounded-md" })] })] }) }) }));
37
38
  }
38
39
  if (!approval) {
39
40
  return (_jsx("div", { className: "flex min-h-screen items-center justify-center bg-background p-6", children: _jsxs("div", { className: "w-full max-w-md rounded-2xl border bg-card p-6 text-center", children: [_jsx(IconAlertCircle, { size: 32, className: "mx-auto mb-3 text-muted-foreground" }), _jsx("p", { className: "text-sm font-medium text-foreground", children: "Approval not found" }), _jsxs("p", { className: "mt-1 text-xs text-muted-foreground", children: ["The approval with id", " ", _jsx("code", { className: "rounded bg-muted px-1", children: id }), " does not exist."] }), inEmbed && (_jsxs(Button, { size: "sm", variant: "outline", className: "mt-4 gap-1.5", onClick: () => postNavigate(appPath("/approvals")), children: [_jsx(IconArrowUpRight, { size: 14 }), "View all approvals"] }))] }) }));
@@ -1 +1 @@
1
- {"version":3,"file":"approval.js","sourceRoot":"","sources":["../../../src/routes/pages/approval.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAA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,QAAQ,GAAG,cAE/B,IACL,CACP,IACG,EAEL,OAAO,IAAI,CACV,cAAK,SAAS,EAAC,kBAAkB,YAC/B,MAAC,MAAM,IACL,IAAI,EAAC,IAAI,EACT,OAAO,EAAC,OAAO,EACf,SAAS,EAAC,+BAA+B,EACzC,OAAO,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,aAElD,KAAC,gBAAgB,IAAC,IAAI,EAAE,EAAE,GAAI,mBAEvB,GACL,CACP,IACG,GACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { useSearchParams } from \"react-router\";\nimport {\n useActionMutation,\n useActionQuery,\n isInAgentEmbed,\n postNavigate,\n appPath,\n} from \"@agent-native/core/client\";\nimport { toast } from \"sonner\";\nimport { Button } from \"@/components/ui/button\";\nimport { Badge } from \"@/components/ui/badge\";\nimport {\n IconCheck,\n IconX,\n IconArrowUpRight,\n IconShieldCheck,\n IconClock,\n IconAlertCircle,\n} from \"@tabler/icons-react\";\n\nexport function meta() {\n return [{ title: \"Approval — Dispatch\" }];\n}\n\nfunction StatusBadge({ status }: { status: string }) {\n if (status === \"pending\") {\n return (\n <Badge\n variant=\"outline\"\n className=\"gap-1.5 border-amber-500/40 bg-amber-500/10 text-amber-600 dark:text-amber-400\"\n >\n <IconClock size={11} />\n Pending\n </Badge>\n );\n }\n if (status === \"approved\") {\n return (\n <Badge\n variant=\"outline\"\n className=\"gap-1.5 border-emerald-500/40 bg-emerald-500/10 text-emerald-600 dark:text-emerald-400\"\n >\n <IconCheck size={11} />\n Approved\n </Badge>\n );\n }\n return (\n <Badge\n variant=\"outline\"\n className=\"gap-1.5 border-red-500/40 bg-red-500/10 text-red-600 dark:text-red-400\"\n >\n <IconX size={11} />\n Rejected\n </Badge>\n );\n}\n\nexport default function ApprovalPreviewRoute() {\n const [searchParams] = useSearchParams();\n const id = searchParams.get(\"id\") ?? \"\";\n\n const { data: approvals, isLoading } = useActionQuery(\n \"list-dispatch-approvals\",\n {},\n );\n\n const approve = useActionMutation(\"approve-dispatch-change\", {\n onSuccess: () => toast.success(\"Change approved\"),\n });\n const reject = useActionMutation(\"reject-dispatch-change\", {\n onSuccess: () => toast.success(\"Change rejected\"),\n });\n\n const inEmbed = isInAgentEmbed();\n\n const approval = approvals?.find((item) => item.id === id) ?? null;\n\n if (!id) {\n return (\n <div className=\"flex min-h-screen items-center justify-center bg-background p-6\">\n <div className=\"w-full max-w-md rounded-2xl border bg-card p-6 text-center\">\n <IconAlertCircle\n size={32}\n className=\"mx-auto mb-3 text-muted-foreground\"\n />\n <p className=\"text-sm font-medium text-foreground\">\n No approval id provided\n </p>\n <p className=\"mt-1 text-xs text-muted-foreground\">\n Add <code className=\"rounded bg-muted px-1\">?id=&lt;id&gt;</code> to\n the URL.\n </p>\n </div>\n </div>\n );\n }\n\n if (isLoading) {\n return (\n <div className=\"flex min-h-screen items-center justify-center bg-background p-6\">\n <div className=\"w-full max-w-md rounded-2xl border bg-card p-6 text-center\">\n <p className=\"text-sm text-muted-foreground\">Loading...</p>\n </div>\n </div>\n );\n }\n\n if (!approval) {\n return (\n <div className=\"flex min-h-screen items-center justify-center bg-background p-6\">\n <div className=\"w-full max-w-md rounded-2xl border bg-card p-6 text-center\">\n <IconAlertCircle\n size={32}\n className=\"mx-auto mb-3 text-muted-foreground\"\n />\n <p className=\"text-sm font-medium text-foreground\">\n Approval not found\n </p>\n <p className=\"mt-1 text-xs text-muted-foreground\">\n The approval with id{\" \"}\n <code className=\"rounded bg-muted px-1\">{id}</code> does not exist.\n </p>\n {inEmbed && (\n <Button\n size=\"sm\"\n variant=\"outline\"\n className=\"mt-4 gap-1.5\"\n onClick={() => postNavigate(appPath(\"/approvals\"))}\n >\n <IconArrowUpRight size={14} />\n View all approvals\n </Button>\n )}\n </div>\n </div>\n );\n }\n\n const isPending = approval.status === \"pending\";\n\n return (\n <div className=\"flex min-h-screen items-start justify-center bg-background p-6\">\n <div className=\"w-full max-w-md space-y-4\">\n <div className=\"rounded-2xl border bg-card p-5\">\n <div className=\"flex items-start gap-3\">\n <div className=\"flex h-9 w-9 shrink-0 items-center justify-center rounded-xl border bg-muted text-foreground\">\n <IconShieldCheck size={17} />\n </div>\n <div className=\"min-w-0 flex-1\">\n <div className=\"flex flex-wrap items-center gap-2\">\n <span className=\"text-sm font-semibold text-foreground\">\n {approval.summary}\n </span>\n <StatusBadge status={approval.status} />\n </div>\n <div className=\"mt-1 text-xs text-muted-foreground\">\n Requested by{\" \"}\n <span className=\"font-medium text-foreground\">\n {approval.requestedBy}\n </span>\n </div>\n </div>\n </div>\n\n <div className=\"mt-4 space-y-2 rounded-xl border bg-muted/30 px-4 py-3 text-xs\">\n <div className=\"flex justify-between gap-4\">\n <span className=\"text-muted-foreground\">Change type</span>\n <span className=\"font-mono font-medium text-foreground\">\n {approval.changeType}\n </span>\n </div>\n <div className=\"flex justify-between gap-4\">\n <span className=\"text-muted-foreground\">Target type</span>\n <span className=\"font-mono font-medium text-foreground\">\n {approval.targetType}\n </span>\n </div>\n {approval.targetId && (\n <div className=\"flex justify-between gap-4\">\n <span className=\"text-muted-foreground\">Target id</span>\n <span className=\"truncate font-mono font-medium text-foreground\">\n {approval.targetId}\n </span>\n </div>\n )}\n {approval.reviewedBy && (\n <div className=\"flex justify-between gap-4\">\n <span className=\"text-muted-foreground\">Reviewed by</span>\n <span className=\"font-medium text-foreground\">\n {approval.reviewedBy}\n </span>\n </div>\n )}\n </div>\n\n {isPending && (\n <div className=\"mt-4 flex gap-2\">\n <Button\n size=\"sm\"\n className=\"flex-1\"\n disabled={approve.isPending || reject.isPending}\n onClick={() => approve.mutate({ id: approval.id })}\n >\n <IconCheck size={14} className=\"mr-1.5\" />\n Approve\n </Button>\n <Button\n size=\"sm\"\n variant=\"outline\"\n className=\"flex-1\"\n disabled={approve.isPending || reject.isPending}\n onClick={() =>\n reject.mutate({\n id: approval.id,\n reason: \"Rejected in dispatch UI\",\n })\n }\n >\n <IconX size={14} className=\"mr-1.5\" />\n Reject\n </Button>\n </div>\n )}\n </div>\n\n {inEmbed && (\n <div className=\"flex justify-end\">\n <Button\n size=\"sm\"\n variant=\"ghost\"\n className=\"gap-1.5 text-muted-foreground\"\n onClick={() => postNavigate(appPath(\"/approvals\"))}\n >\n <IconArrowUpRight size={14} />\n Open in app\n </Button>\n </div>\n )}\n </div>\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"approval.js","sourceRoot":"","sources":["../../../src/routes/pages/approval.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,YAAY,EACZ,OAAO,GACR,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EACL,SAAS,EACT,KAAK,EACL,gBAAgB,EAChB,eAAe,EACf,SAAS,EACT,eAAe,GAChB,MAAM,qBAAqB,CAAC;AAE7B,MAAM,UAAU,IAAI;IAClB,OAAO,CAAC,EAAE,KAAK,EAAE,qBAAqB,EAAE,CAAC,CAAC;AAC5C,CAAC;AAED,SAAS,WAAW,CAAC,EAAE,MAAM,EAAsB;IACjD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO,CACL,MAAC,KAAK,IACJ,OAAO,EAAC,SAAS,EACjB,SAAS,EAAC,gFAAgF,aAE1F,KAAC,SAAS,IAAC,IAAI,EAAE,EAAE,GAAI,eAEjB,CACT,CAAC;IACJ,CAAC;IACD,IAAI,MAAM,KAAK,UAAU,EAAE,CAAC;QAC1B,OAAO,CACL,MAAC,KAAK,IACJ,OAAO,EAAC,SAAS,EACjB,SAAS,EAAC,wFAAwF,a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,MAAM,EAAE,yBAAyB;qCAClC,CAAC,aAGJ,KAAC,KAAK,IAAC,IAAI,EAAE,EAAE,EAAE,SAAS,EAAC,QAAQ,GAAG,cAE/B,IACL,CACP,IACG,EAEL,OAAO,IAAI,CACV,cAAK,SAAS,EAAC,kBAAkB,YAC/B,MAAC,MAAM,IACL,IAAI,EAAC,IAAI,EACT,OAAO,EAAC,OAAO,EACf,SAAS,EAAC,+BAA+B,EACzC,OAAO,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,aAElD,KAAC,gBAAgB,IAAC,IAAI,EAAE,EAAE,GAAI,mBAEvB,GACL,CACP,IACG,GACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { useSearchParams } from \"react-router\";\nimport {\n useActionMutation,\n useActionQuery,\n isInAgentEmbed,\n postNavigate,\n appPath,\n} from \"@agent-native/core/client\";\nimport { toast } from \"sonner\";\nimport { Button } from \"@/components/ui/button\";\nimport { Badge } from \"@/components/ui/badge\";\nimport { Skeleton } from \"@/components/ui/skeleton\";\nimport {\n IconCheck,\n IconX,\n IconArrowUpRight,\n IconShieldCheck,\n IconClock,\n IconAlertCircle,\n} from \"@tabler/icons-react\";\n\nexport function meta() {\n return [{ title: \"Approval — Dispatch\" }];\n}\n\nfunction StatusBadge({ status }: { status: string }) {\n if (status === \"pending\") {\n return (\n <Badge\n variant=\"outline\"\n className=\"gap-1.5 border-amber-500/40 bg-amber-500/10 text-amber-600 dark:text-amber-400\"\n >\n <IconClock size={11} />\n Pending\n </Badge>\n );\n }\n if (status === \"approved\") {\n return (\n <Badge\n variant=\"outline\"\n className=\"gap-1.5 border-emerald-500/40 bg-emerald-500/10 text-emerald-600 dark:text-emerald-400\"\n >\n <IconCheck size={11} />\n Approved\n </Badge>\n );\n }\n return (\n <Badge\n variant=\"outline\"\n className=\"gap-1.5 border-red-500/40 bg-red-500/10 text-red-600 dark:text-red-400\"\n >\n <IconX size={11} />\n Rejected\n </Badge>\n );\n}\n\nexport default function ApprovalPreviewRoute() {\n const [searchParams] = useSearchParams();\n const id = searchParams.get(\"id\") ?? \"\";\n\n const { data: approvals, isLoading } = useActionQuery(\n \"list-dispatch-approvals\",\n {},\n );\n\n const approve = useActionMutation(\"approve-dispatch-change\", {\n onSuccess: () => toast.success(\"Change approved\"),\n });\n const reject = useActionMutation(\"reject-dispatch-change\", {\n onSuccess: () => toast.success(\"Change rejected\"),\n });\n\n const inEmbed = isInAgentEmbed();\n\n const approval = approvals?.find((item) => item.id === id) ?? null;\n\n if (!id) {\n return (\n <div className=\"flex min-h-screen items-center justify-center bg-background p-6\">\n <div className=\"w-full max-w-md rounded-2xl border bg-card p-6 text-center\">\n <IconAlertCircle\n size={32}\n className=\"mx-auto mb-3 text-muted-foreground\"\n />\n <p className=\"text-sm font-medium text-foreground\">\n No approval id provided\n </p>\n <p className=\"mt-1 text-xs text-muted-foreground\">\n Add <code className=\"rounded bg-muted px-1\">?id=&lt;id&gt;</code> to\n the URL.\n </p>\n </div>\n </div>\n );\n }\n\n if (isLoading) {\n return (\n <div className=\"flex min-h-screen items-start justify-center bg-background p-6\">\n <div className=\"w-full max-w-md space-y-4\">\n <div className=\"rounded-2xl border bg-card p-5\">\n <div className=\"flex items-start gap-3\">\n <Skeleton className=\"h-9 w-9 shrink-0 rounded-xl\" />\n <div className=\"min-w-0 flex-1 space-y-2\">\n <div className=\"flex flex-wrap items-center gap-2\">\n <Skeleton className=\"h-4 w-40\" />\n <Skeleton className=\"h-5 w-20 rounded-full\" />\n </div>\n <Skeleton className=\"h-3 w-32\" />\n </div>\n </div>\n <div className=\"mt-4 space-y-2 rounded-xl border bg-muted/30 px-4 py-3\">\n <div className=\"flex justify-between gap-4\">\n <Skeleton className=\"h-3 w-20\" />\n <Skeleton className=\"h-3 w-24\" />\n </div>\n <div className=\"flex justify-between gap-4\">\n <Skeleton className=\"h-3 w-20\" />\n <Skeleton className=\"h-3 w-28\" />\n </div>\n <div className=\"flex justify-between gap-4\">\n <Skeleton className=\"h-3 w-16\" />\n <Skeleton className=\"h-3 w-32\" />\n </div>\n </div>\n <div className=\"mt-4 flex gap-2\">\n <Skeleton className=\"h-8 flex-1 rounded-md\" />\n <Skeleton className=\"h-8 flex-1 rounded-md\" />\n </div>\n </div>\n </div>\n </div>\n );\n }\n\n if (!approval) {\n return (\n <div className=\"flex min-h-screen items-center justify-center bg-background p-6\">\n <div className=\"w-full max-w-md rounded-2xl border bg-card p-6 text-center\">\n <IconAlertCircle\n size={32}\n className=\"mx-auto mb-3 text-muted-foreground\"\n />\n <p className=\"text-sm font-medium text-foreground\">\n Approval not found\n </p>\n <p className=\"mt-1 text-xs text-muted-foreground\">\n The approval with id{\" \"}\n <code className=\"rounded bg-muted px-1\">{id}</code> does not exist.\n </p>\n {inEmbed && (\n <Button\n size=\"sm\"\n variant=\"outline\"\n className=\"mt-4 gap-1.5\"\n onClick={() => postNavigate(appPath(\"/approvals\"))}\n >\n <IconArrowUpRight size={14} />\n View all approvals\n </Button>\n )}\n </div>\n </div>\n );\n }\n\n const isPending = approval.status === \"pending\";\n\n return (\n <div className=\"flex min-h-screen items-start justify-center bg-background p-6\">\n <div className=\"w-full max-w-md space-y-4\">\n <div className=\"rounded-2xl border bg-card p-5\">\n <div className=\"flex items-start gap-3\">\n <div className=\"flex h-9 w-9 shrink-0 items-center justify-center rounded-xl border bg-muted text-foreground\">\n <IconShieldCheck size={17} />\n </div>\n <div className=\"min-w-0 flex-1\">\n <div className=\"flex flex-wrap items-center gap-2\">\n <span className=\"text-sm font-semibold text-foreground\">\n {approval.summary}\n </span>\n <StatusBadge status={approval.status} />\n </div>\n <div className=\"mt-1 text-xs text-muted-foreground\">\n Requested by{\" \"}\n <span className=\"font-medium text-foreground\">\n {approval.requestedBy}\n </span>\n </div>\n </div>\n </div>\n\n <div className=\"mt-4 space-y-2 rounded-xl border bg-muted/30 px-4 py-3 text-xs\">\n <div className=\"flex justify-between gap-4\">\n <span className=\"text-muted-foreground\">Change type</span>\n <span className=\"font-mono font-medium text-foreground\">\n {approval.changeType}\n </span>\n </div>\n <div className=\"flex justify-between gap-4\">\n <span className=\"text-muted-foreground\">Target type</span>\n <span className=\"font-mono font-medium text-foreground\">\n {approval.targetType}\n </span>\n </div>\n {approval.targetId && (\n <div className=\"flex justify-between gap-4\">\n <span className=\"text-muted-foreground\">Target id</span>\n <span className=\"truncate font-mono font-medium text-foreground\">\n {approval.targetId}\n </span>\n </div>\n )}\n {approval.reviewedBy && (\n <div className=\"flex justify-between gap-4\">\n <span className=\"text-muted-foreground\">Reviewed by</span>\n <span className=\"font-medium text-foreground\">\n {approval.reviewedBy}\n </span>\n </div>\n )}\n </div>\n\n {isPending && (\n <div className=\"mt-4 flex gap-2\">\n <Button\n size=\"sm\"\n className=\"flex-1\"\n disabled={approve.isPending || reject.isPending}\n onClick={() => approve.mutate({ id: approval.id })}\n >\n <IconCheck size={14} className=\"mr-1.5\" />\n Approve\n </Button>\n <Button\n size=\"sm\"\n variant=\"outline\"\n className=\"flex-1\"\n disabled={approve.isPending || reject.isPending}\n onClick={() =>\n reject.mutate({\n id: approval.id,\n reason: \"Rejected in dispatch UI\",\n })\n }\n >\n <IconX size={14} className=\"mr-1.5\" />\n Reject\n </Button>\n </div>\n )}\n </div>\n\n {inEmbed && (\n <div className=\"flex justify-end\">\n <Button\n size=\"sm\"\n variant=\"ghost\"\n className=\"gap-1.5 text-muted-foreground\"\n onClick={() => postNavigate(appPath(\"/approvals\"))}\n >\n <IconArrowUpRight size={14} />\n Open in app\n </Button>\n </div>\n )}\n </div>\n </div>\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"apps.$appId.d.ts","sourceRoot":"","sources":["../../../src/routes/pages/apps.$appId.tsx"],"names":[],"mappings":"AAgBA,wBAAgB,IAAI;;IAEnB;AAED,MAAM,CAAC,OAAO,UAAU,iBAAiB,4CAoGxC"}
1
+ {"version":3,"file":"apps.$appId.d.ts","sourceRoot":"","sources":["../../../src/routes/pages/apps.$appId.tsx"],"names":[],"mappings":"AAiBA,wBAAgB,IAAI;;IAEnB;AAED,MAAM,CAAC,OAAO,UAAU,iBAAiB,4CAwGxC"}
@@ -6,6 +6,7 @@ import { IconArrowLeft, IconArrowUpRight, IconClockHour4, } from "@tabler/icons-
6
6
  import { DispatchShell } from "../../components/dispatch-shell.js";
7
7
  import { Badge } from "../../components/ui/badge.js";
8
8
  import { Button } from "../../components/ui/button.js";
9
+ import { Skeleton } from "../../components/ui/skeleton.js";
9
10
  import { workspaceAppHref, } from "../../lib/workspace-apps.js";
10
11
  export function meta() {
11
12
  return [{ title: "Workspace app - Dispatch" }];
@@ -22,6 +23,6 @@ export default function WorkspaceAppRoute() {
22
23
  return;
23
24
  window.location.assign(href);
24
25
  }, [app, href]);
25
- return (_jsx(DispatchShell, { title: app?.name || "Workspace App", description: "Open a deployed app or check the status of an app being created.", children: _jsxs("div", { className: "max-w-2xl rounded-lg border bg-card p-5", children: [_jsx(Button, { asChild: true, size: "sm", variant: "ghost", className: "-ml-2 mb-4", children: _jsxs(Link, { to: "/apps", children: [_jsx(IconArrowLeft, { size: 15, className: "mr-1.5" }), "Apps"] }) }), isLoading && !app ? (_jsx("p", { className: "text-sm text-muted-foreground", children: "Loading app status..." })) : !app ? (_jsxs("div", { className: "space-y-3", children: [_jsx("h2", { className: "text-base font-semibold text-foreground", children: "App not found" }), _jsx("p", { className: "text-sm text-muted-foreground", children: "This route is not in the workspace app list yet." })] })) : app.status === "pending" ? (_jsxs("div", { className: "space-y-4", children: [_jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [_jsx("h2", { className: "text-base font-semibold text-foreground", children: app.name }), _jsxs(Badge, { variant: "outline", className: "gap-1 border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300", children: [_jsx(IconClockHour4, { size: 12 }), "Building"] })] }), _jsxs("p", { className: "text-sm text-muted-foreground", children: ["This app is being created. It will be available at", " ", _jsx("span", { className: "font-mono text-foreground", children: app.path }), " ", "after its branch is merged and the workspace deploy finishes."] }), app.branchName ? (_jsxs("p", { className: "text-xs text-muted-foreground", children: ["Branch: ", app.branchName] })) : null, app.builderUrl ? (_jsx(Button, { asChild: true, children: _jsxs("a", { href: app.builderUrl, target: "_blank", rel: "noreferrer", children: ["Open Builder branch", _jsx(IconArrowUpRight, { size: 15, className: "ml-1.5" })] }) })) : null] })) : (_jsxs("div", { className: "space-y-3", children: [_jsxs("h2", { className: "text-base font-semibold text-foreground", children: ["Opening ", app.name] }), _jsxs("p", { className: "text-sm text-muted-foreground", children: ["Redirecting to", " ", _jsx("span", { className: "font-mono text-foreground", children: app.path }), "."] }), href ? (_jsx(Button, { asChild: true, children: _jsxs("a", { href: href, children: ["Open app", _jsx(IconArrowUpRight, { size: 15, className: "ml-1.5" })] }) })) : null] }))] }) }));
26
+ return (_jsx(DispatchShell, { title: app?.name || "Workspace App", description: "Open a deployed app or check the status of an app being created.", children: _jsxs("div", { className: "max-w-2xl rounded-lg border bg-card p-5", children: [_jsx(Button, { asChild: true, size: "sm", variant: "ghost", className: "-ml-2 mb-4", children: _jsxs(Link, { to: "/apps", children: [_jsx(IconArrowLeft, { size: 15, className: "mr-1.5" }), "Apps"] }) }), isLoading && !app ? (_jsxs("div", { className: "space-y-3", children: [_jsx(Skeleton, { className: "h-5 w-48" }), _jsx(Skeleton, { className: "h-4 w-full" }), _jsx(Skeleton, { className: "h-4 w-2/3" })] })) : !app ? (_jsxs("div", { className: "space-y-3", children: [_jsx("h2", { className: "text-base font-semibold text-foreground", children: "App not found" }), _jsx("p", { className: "text-sm text-muted-foreground", children: "This route is not in the workspace app list yet." })] })) : app.status === "pending" ? (_jsxs("div", { className: "space-y-4", children: [_jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [_jsx("h2", { className: "text-base font-semibold text-foreground", children: app.name }), _jsxs(Badge, { variant: "outline", className: "gap-1 border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300", children: [_jsx(IconClockHour4, { size: 12 }), "Building"] })] }), _jsxs("p", { className: "text-sm text-muted-foreground", children: ["This app is being created. It will be available at", " ", _jsx("span", { className: "font-mono text-foreground", children: app.path }), " ", "after its branch is merged and the workspace deploy finishes."] }), app.branchName ? (_jsxs("p", { className: "text-xs text-muted-foreground", children: ["Branch: ", app.branchName] })) : null, app.builderUrl ? (_jsx(Button, { asChild: true, children: _jsxs("a", { href: app.builderUrl, target: "_blank", rel: "noreferrer", children: ["Open Builder branch", _jsx(IconArrowUpRight, { size: 15, className: "ml-1.5" })] }) })) : null] })) : (_jsxs("div", { className: "space-y-3", children: [_jsxs("h2", { className: "text-base font-semibold text-foreground", children: ["Opening ", app.name] }), _jsxs("p", { className: "text-sm text-muted-foreground", children: ["Redirecting to", " ", _jsx("span", { className: "font-mono text-foreground", children: app.path }), "."] }), href ? (_jsx(Button, { asChild: true, children: _jsxs("a", { href: href, children: ["Open app", _jsx(IconArrowUpRight, { size: 15, className: "ml-1.5" })] }) })) : null] }))] }) }));
26
27
  }
27
28
  //# sourceMappingURL=apps.$appId.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"apps.$appId.js","sourceRoot":"","sources":["../../../src/routes/pages/apps.$appId.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,cAAc,GACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EACL,gBAAgB,GAEjB,MAAM,sBAAsB,CAAC;AAE9B,MAAM,UAAU,IAAI;IAClB,OAAO,CAAC,EAAE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AG,CAAC,IAAI,IACd,EACL,aAAG,SAAS,EAAC,+BAA+B,+BAC3B,GAAG,EAClB,eAAM,SAAS,EAAC,2BAA2B,YAAE,GAAG,CAAC,IAAI,GAAQ,SAC3D,EACH,IAAI,CAAC,CAAC,CAAC,CACN,KAAC,MAAM,IAAC,OAAO,kBACb,aAAG,IAAI,EAAE,IAAI,yBAEX,KAAC,gBAAgB,IAAC,IAAI,EAAE,EAAE,EAAE,SAAS,EAAC,QAAQ,GAAG,IAC/C,GACG,CACV,CAAC,CAAC,CAAC,IAAI,IACJ,CACP,IACG,GACQ,CACjB,CAAC;AACJ,CAAC","sourcesContent":["import { useEffect, useMemo } from \"react\";\nimport { Link, useParams } from \"react-router\";\nimport { useActionQuery } from \"@agent-native/core/client\";\nimport {\n IconArrowLeft,\n IconArrowUpRight,\n IconClockHour4,\n} from \"@tabler/icons-react\";\nimport { DispatchShell } from \"@/components/dispatch-shell\";\nimport { Badge } from \"@/components/ui/badge\";\nimport { Button } from \"@/components/ui/button\";\nimport {\n workspaceAppHref,\n type WorkspaceAppSummary,\n} from \"@/lib/workspace-apps\";\n\nexport function meta() {\n return [{ title: \"Workspace app - Dispatch\" }];\n}\n\nexport default function WorkspaceAppRoute() {\n const { appId } = useParams();\n const { data: apps = [], isLoading } = useActionQuery(\n \"list-workspace-apps\",\n { includeAgentCards: false },\n {\n refetchInterval: 2_000,\n },\n );\n const app = useMemo(\n () =>\n (apps as WorkspaceAppSummary[]).find((item) => item.id === appId) ?? null,\n [appId, apps],\n );\n const href = app ? workspaceAppHref(app) : null;\n\n useEffect(() => {\n if (!app || app.status === \"pending\" || !href) return;\n window.location.assign(href);\n }, [app, href]);\n\n return (\n <DispatchShell\n title={app?.name || \"Workspace App\"}\n description=\"Open a deployed app or check the status of an app being created.\"\n >\n <div className=\"max-w-2xl rounded-lg border bg-card p-5\">\n <Button asChild size=\"sm\" variant=\"ghost\" className=\"-ml-2 mb-4\">\n <Link to=\"/apps\">\n <IconArrowLeft size={15} className=\"mr-1.5\" />\n Apps\n </Link>\n </Button>\n\n {isLoading && !app ? (\n <p className=\"text-sm text-muted-foreground\">Loading app status...</p>\n ) : !app ? (\n <div className=\"space-y-3\">\n <h2 className=\"text-base font-semibold text-foreground\">\n App not found\n </h2>\n <p className=\"text-sm text-muted-foreground\">\n This route is not in the workspace app list yet.\n </p>\n </div>\n ) : app.status === \"pending\" ? (\n <div className=\"space-y-4\">\n <div className=\"flex flex-wrap items-center gap-2\">\n <h2 className=\"text-base font-semibold text-foreground\">\n {app.name}\n </h2>\n <Badge\n variant=\"outline\"\n className=\"gap-1 border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300\"\n >\n <IconClockHour4 size={12} />\n Building\n </Badge>\n </div>\n <p className=\"text-sm text-muted-foreground\">\n This app is being created. It will be available at{\" \"}\n <span className=\"font-mono text-foreground\">{app.path}</span>{\" \"}\n after its branch is merged and the workspace deploy finishes.\n </p>\n {app.branchName ? (\n <p className=\"text-xs text-muted-foreground\">\n Branch: {app.branchName}\n </p>\n ) : null}\n {app.builderUrl ? (\n <Button asChild>\n <a href={app.builderUrl} target=\"_blank\" rel=\"noreferrer\">\n Open Builder branch\n <IconArrowUpRight size={15} className=\"ml-1.5\" />\n </a>\n </Button>\n ) : null}\n </div>\n ) : (\n <div className=\"space-y-3\">\n <h2 className=\"text-base font-semibold text-foreground\">\n Opening {app.name}\n </h2>\n <p className=\"text-sm text-muted-foreground\">\n Redirecting to{\" \"}\n <span className=\"font-mono text-foreground\">{app.path}</span>.\n </p>\n {href ? (\n <Button asChild>\n <a href={href}>\n Open app\n <IconArrowUpRight size={15} className=\"ml-1.5\" />\n </a>\n </Button>\n ) : null}\n </div>\n )}\n </div>\n </DispatchShell>\n );\n}\n"]}
1
+ {"version":3,"file":"apps.$appId.js","sourceRoot":"","sources":["../../../src/routes/pages/apps.$appId.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC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G,SAAS,EAAC,+BAA+B,mEACS,GAAG,EACtD,eAAM,SAAS,EAAC,2BAA2B,YAAE,GAAG,CAAC,IAAI,GAAQ,EAAC,GAAG,qEAE/D,EACH,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAChB,aAAG,SAAS,EAAC,+BAA+B,yBACjC,GAAG,CAAC,UAAU,IACrB,CACL,CAAC,CAAC,CAAC,IAAI,EACP,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAChB,KAAC,MAAM,IAAC,OAAO,kBACb,aAAG,IAAI,EAAE,GAAG,CAAC,UAAU,EAAE,MAAM,EAAC,QAAQ,EAAC,GAAG,EAAC,YAAY,oCAEvD,KAAC,gBAAgB,IAAC,IAAI,EAAE,EAAE,EAAE,SAAS,EAAC,QAAQ,GAAG,IAC/C,GACG,CACV,CAAC,CAAC,CAAC,IAAI,IACJ,CACP,CAAC,CAAC,CAAC,CACF,eAAK,SAAS,EAAC,WAAW,aACxB,cAAI,SAAS,EAAC,yCAAyC,yBAC5C,GAAG,CAAC,IAAI,IACd,EACL,aAAG,SAAS,EAAC,+BAA+B,+BAC3B,GAAG,EAClB,eAAM,SAAS,EAAC,2BAA2B,YAAE,GAAG,CAAC,IAAI,GAAQ,SAC3D,EACH,IAAI,CAAC,CAAC,CAAC,CACN,KAAC,MAAM,IAAC,OAAO,kBACb,aAAG,IAAI,EAAE,IAAI,yBAEX,KAAC,gBAAgB,IAAC,IAAI,EAAE,EAAE,EAAE,SAAS,EAAC,QAAQ,GAAG,IAC/C,GACG,CACV,CAAC,CAAC,CAAC,IAAI,IACJ,CACP,IACG,GACQ,CACjB,CAAC;AACJ,CAAC","sourcesContent":["import { useEffect, useMemo } from \"react\";\nimport { Link, useParams } from \"react-router\";\nimport { useActionQuery } from \"@agent-native/core/client\";\nimport {\n IconArrowLeft,\n IconArrowUpRight,\n IconClockHour4,\n} from \"@tabler/icons-react\";\nimport { DispatchShell } from \"@/components/dispatch-shell\";\nimport { Badge } from \"@/components/ui/badge\";\nimport { Button } from \"@/components/ui/button\";\nimport { Skeleton } from \"@/components/ui/skeleton\";\nimport {\n workspaceAppHref,\n type WorkspaceAppSummary,\n} from \"@/lib/workspace-apps\";\n\nexport function meta() {\n return [{ title: \"Workspace app - Dispatch\" }];\n}\n\nexport default function WorkspaceAppRoute() {\n const { appId } = useParams();\n const { data: apps = [], isLoading } = useActionQuery(\n \"list-workspace-apps\",\n { includeAgentCards: false },\n {\n refetchInterval: 2_000,\n },\n );\n const app = useMemo(\n () =>\n (apps as WorkspaceAppSummary[]).find((item) => item.id === appId) ?? null,\n [appId, apps],\n );\n const href = app ? workspaceAppHref(app) : null;\n\n useEffect(() => {\n if (!app || app.status === \"pending\" || !href) return;\n window.location.assign(href);\n }, [app, href]);\n\n return (\n <DispatchShell\n title={app?.name || \"Workspace App\"}\n description=\"Open a deployed app or check the status of an app being created.\"\n >\n <div className=\"max-w-2xl rounded-lg border bg-card p-5\">\n <Button asChild size=\"sm\" variant=\"ghost\" className=\"-ml-2 mb-4\">\n <Link to=\"/apps\">\n <IconArrowLeft size={15} className=\"mr-1.5\" />\n Apps\n </Link>\n </Button>\n\n {isLoading && !app ? (\n <div className=\"space-y-3\">\n <Skeleton className=\"h-5 w-48\" />\n <Skeleton className=\"h-4 w-full\" />\n <Skeleton className=\"h-4 w-2/3\" />\n </div>\n ) : !app ? (\n <div className=\"space-y-3\">\n <h2 className=\"text-base font-semibold text-foreground\">\n App not found\n </h2>\n <p className=\"text-sm text-muted-foreground\">\n This route is not in the workspace app list yet.\n </p>\n </div>\n ) : app.status === \"pending\" ? (\n <div className=\"space-y-4\">\n <div className=\"flex flex-wrap items-center gap-2\">\n <h2 className=\"text-base font-semibold text-foreground\">\n {app.name}\n </h2>\n <Badge\n variant=\"outline\"\n className=\"gap-1 border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300\"\n >\n <IconClockHour4 size={12} />\n Building\n </Badge>\n </div>\n <p className=\"text-sm text-muted-foreground\">\n This app is being created. It will be available at{\" \"}\n <span className=\"font-mono text-foreground\">{app.path}</span>{\" \"}\n after its branch is merged and the workspace deploy finishes.\n </p>\n {app.branchName ? (\n <p className=\"text-xs text-muted-foreground\">\n Branch: {app.branchName}\n </p>\n ) : null}\n {app.builderUrl ? (\n <Button asChild>\n <a href={app.builderUrl} target=\"_blank\" rel=\"noreferrer\">\n Open Builder branch\n <IconArrowUpRight size={15} className=\"ml-1.5\" />\n </a>\n </Button>\n ) : null}\n </div>\n ) : (\n <div className=\"space-y-3\">\n <h2 className=\"text-base font-semibold text-foreground\">\n Opening {app.name}\n </h2>\n <p className=\"text-sm text-muted-foreground\">\n Redirecting to{\" \"}\n <span className=\"font-mono text-foreground\">{app.path}</span>.\n </p>\n {href ? (\n <Button asChild>\n <a href={href}>\n Open app\n <IconArrowUpRight size={15} className=\"ml-1.5\" />\n </a>\n </Button>\n ) : null}\n </div>\n )}\n </div>\n </DispatchShell>\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"overview.d.ts","sourceRoot":"","sources":["../../../src/routes/pages/overview.tsx"],"names":[],"mappings":"AA6YA,wBAAgB,IAAI;;IAEnB;AAED,MAAM,CAAC,OAAO,UAAU,aAAa,4CA0SpC"}
1
+ {"version":3,"file":"overview.d.ts","sourceRoot":"","sources":["../../../src/routes/pages/overview.tsx"],"names":[],"mappings":"AAmcA,wBAAgB,IAAI;;IAEnB;AAED,MAAM,CAAC,OAAO,UAAU,aAAa,4CAoRpC"}
@@ -39,6 +39,15 @@ function HomeChatPanel() {
39
39
  function AppCardSkeleton() {
40
40
  return (_jsx("div", { className: "rounded-lg border bg-card p-4", children: _jsxs("div", { className: "flex items-start justify-between gap-3", children: [_jsxs("div", { className: "min-w-0 flex-1 space-y-3", children: [_jsx(Skeleton, { className: "h-4 w-32" }), _jsx(Skeleton, { className: "h-3 w-24" }), _jsxs("div", { className: "space-y-2 pt-1", children: [_jsx(Skeleton, { className: "h-3 w-full" }), _jsx(Skeleton, { className: "h-3 w-2/3" })] })] }), _jsx(Skeleton, { className: "h-5 w-5 rounded-md" })] }) }));
41
41
  }
42
+ function RecentActivityList({ isLoading, events, }) {
43
+ if (isLoading && events.length === 0) {
44
+ return (_jsx("div", { className: "mt-4 space-y-3", children: Array.from({ length: 3 }).map((_, index) => (_jsxs("div", { className: "rounded-xl border bg-muted/30 px-4 py-3 space-y-2", children: [_jsx(Skeleton, { className: "h-4 w-3/5" }), _jsx(Skeleton, { className: "h-3 w-2/5" })] }, index))) }));
45
+ }
46
+ if (events.length === 0) {
47
+ return (_jsx("div", { className: "mt-4 space-y-3", children: _jsx("div", { className: "rounded-xl border border-dashed px-4 py-6 text-sm text-muted-foreground", children: "No activity yet." }) }));
48
+ }
49
+ return (_jsx("div", { className: "mt-4 space-y-3", children: events.map((event) => (_jsxs("div", { className: "rounded-xl border bg-muted/30 px-4 py-3", children: [_jsx("div", { className: "text-sm font-medium text-foreground", children: event.summary }), _jsxs("div", { className: "mt-1 text-xs text-muted-foreground", children: [event.actor, " \u00B7 ", new Date(event.createdAt).toLocaleString()] })] }, event.id))) }));
50
+ }
42
51
  function WorkspaceAppsSection({ apps, isLoading, }) {
43
52
  const filteredApps = apps.filter((app) => !app.isDispatch);
44
53
  const visibleApps = filteredApps.slice(0, 6);
@@ -188,7 +197,7 @@ export default function OverviewRoute() {
188
197
  },
189
198
  ];
190
199
  const hasIncompleteSteps = steps.some((s) => !s.complete && !s.informational);
191
- return (_jsxs(DispatchShell, { title: "Overview", description: "Create apps, manage shared keys, and route work across your workspace.", children: [_jsx(HomeChatPanel, {}), _jsx(WorkspaceAppsSection, { apps: typedWorkspaceApps, isLoading: appsLoading }), hasIncompleteSteps && (_jsxs("section", { className: "space-y-3", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(IconRocket, { size: 16, className: "text-muted-foreground" }), _jsx("h2", { className: "text-sm font-semibold text-foreground", children: "Getting started" })] }), _jsx("div", { className: "space-y-2", children: steps.map((step) => (_jsx(StepRow, { step: step }, step.number))) })] })), _jsxs("section", { className: "space-y-3", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(IconActivity, { size: 16, className: "text-muted-foreground" }), _jsx("h2", { className: "text-sm font-semibold text-foreground", children: "At a glance" })] }), _jsxs("div", { className: "grid gap-4 md:grid-cols-2 xl:grid-cols-4", children: [_jsx(StatCard, { label: "Vault secrets", help: "Credentials stored in the workspace vault. Grant them to apps from the Vault page.", value: data?.vault?.secretCount || 0, icon: IconKey, cta: (data?.vault?.secretCount || 0) === 0 ? (_jsx(Button, { variant: "outline", size: "sm", asChild: true, children: _jsx(Link, { to: "/vault", children: "Set up vault" }) })) : undefined }), _jsx(StatCard, { label: "Active grants", help: "Secrets currently granted to apps. Sync them to push credentials.", value: data?.vault?.activeGrantCount || 0, icon: IconShieldCheck }), _jsx(StatCard, { label: "Destinations", help: "Saved outbound targets used for proactive sends and scheduled jobs.", value: counts.destinations, icon: IconArrowUpRight, cta: counts.destinations === 0 ? (_jsx(Button, { variant: "outline", size: "sm", asChild: true, children: _jsx(Link, { to: "/destinations", children: "Set up destinations" }) })) : undefined }), _jsx(StatCard, { label: "Agents", help: "Agents available to dispatch for delegation over A2A. This includes the built-in app suite plus any additional agents you add.", value: connectedAgentCount, icon: IconPlugConnected, cta: connectedAgentCount === 0 ? (_jsx(Button, { variant: "outline", size: "sm", asChild: true, children: _jsx(Link, { to: "/agents", children: "Open agents" }) })) : undefined })] })] }), _jsxs("details", { className: "rounded-xl border", children: [_jsxs("summary", { className: "flex cursor-pointer list-none items-center justify-between gap-3 px-5 py-4 text-sm font-semibold text-foreground hover:bg-muted/30 [&::-webkit-details-marker]:hidden", children: [_jsx("span", { children: "Operations detail" }), _jsx("span", { className: "text-xs font-normal text-muted-foreground", children: "Queue, audit, and approvals" })] }), _jsxs("div", { className: "space-y-5 border-t px-5 py-5", children: [_jsx(TaskQueueSection, { stats: taskQueueStats }), _jsxs("div", { className: "grid gap-4 xl:grid-cols-3", children: [_jsxs("section", { className: "rounded-2xl border bg-card p-5 xl:col-span-2", children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("h2", { className: "text-lg font-semibold text-foreground", children: "Recent activity" }), isLoading && (_jsx("span", { className: "text-xs text-muted-foreground", children: "Loading..." }))] }), _jsxs("div", { className: "mt-4 space-y-3", children: [(data?.recentAudit || []).map((event) => (_jsxs("div", { className: "rounded-xl border bg-muted/30 px-4 py-3", children: [_jsx("div", { className: "text-sm font-medium text-foreground", children: event.summary }), _jsxs("div", { className: "mt-1 text-xs text-muted-foreground", children: [event.actor, " \u00B7", " ", new Date(event.createdAt).toLocaleString()] })] }, event.id))), !isLoading && (data?.recentAudit?.length || 0) === 0 && (_jsx("div", { className: "rounded-xl border border-dashed px-4 py-6 text-sm text-muted-foreground", children: "No activity yet." }))] })] }), _jsxs("section", { className: "rounded-2xl border bg-card p-5", children: [_jsx("h2", { className: "text-lg font-semibold text-foreground", children: "Approval mode" }), _jsxs("div", { className: "mt-4 rounded-xl border bg-muted/30 p-4", children: [_jsx("div", { className: "text-sm font-medium text-muted-foreground", children: "Current policy" }), _jsx("div", { className: "mt-2 text-2xl font-semibold text-foreground", children: data?.settings?.enabled ? "Reviewed" : "Immediate" }), _jsx("p", { className: "mt-2 text-sm text-muted-foreground", children: data?.settings?.enabled
200
+ return (_jsxs(DispatchShell, { title: "Overview", description: "Create apps, manage shared keys, and route work across your workspace.", children: [_jsx(HomeChatPanel, {}), _jsx(WorkspaceAppsSection, { apps: typedWorkspaceApps, isLoading: appsLoading }), hasIncompleteSteps && (_jsxs("section", { className: "space-y-3", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(IconRocket, { size: 16, className: "text-muted-foreground" }), _jsx("h2", { className: "text-sm font-semibold text-foreground", children: "Getting started" })] }), _jsx("div", { className: "space-y-2", children: steps.map((step) => (_jsx(StepRow, { step: step }, step.number))) })] })), _jsxs("section", { className: "space-y-3", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(IconActivity, { size: 16, className: "text-muted-foreground" }), _jsx("h2", { className: "text-sm font-semibold text-foreground", children: "At a glance" })] }), _jsxs("div", { className: "grid gap-4 md:grid-cols-2 xl:grid-cols-4", children: [_jsx(StatCard, { label: "Vault secrets", help: "Credentials stored in the workspace vault. Grant them to apps from the Vault page.", value: data?.vault?.secretCount || 0, icon: IconKey, cta: (data?.vault?.secretCount || 0) === 0 ? (_jsx(Button, { variant: "outline", size: "sm", asChild: true, children: _jsx(Link, { to: "/vault", children: "Set up vault" }) })) : undefined }), _jsx(StatCard, { label: "Active grants", help: "Secrets currently granted to apps. Sync them to push credentials.", value: data?.vault?.activeGrantCount || 0, icon: IconShieldCheck }), _jsx(StatCard, { label: "Destinations", help: "Saved outbound targets used for proactive sends and scheduled jobs.", value: counts.destinations, icon: IconArrowUpRight, cta: counts.destinations === 0 ? (_jsx(Button, { variant: "outline", size: "sm", asChild: true, children: _jsx(Link, { to: "/destinations", children: "Set up destinations" }) })) : undefined }), _jsx(StatCard, { label: "Agents", help: "Agents available to dispatch for delegation over A2A. This includes the built-in app suite plus any additional agents you add.", value: connectedAgentCount, icon: IconPlugConnected, cta: connectedAgentCount === 0 ? (_jsx(Button, { variant: "outline", size: "sm", asChild: true, children: _jsx(Link, { to: "/agents", children: "Open agents" }) })) : undefined })] })] }), _jsxs("details", { className: "rounded-xl border", children: [_jsxs("summary", { className: "flex cursor-pointer list-none items-center justify-between gap-3 px-5 py-4 text-sm font-semibold text-foreground hover:bg-muted/30 [&::-webkit-details-marker]:hidden", children: [_jsx("span", { children: "Operations detail" }), _jsx("span", { className: "text-xs font-normal text-muted-foreground", children: "Queue, audit, and approvals" })] }), _jsxs("div", { className: "space-y-5 border-t px-5 py-5", children: [_jsx(TaskQueueSection, { stats: taskQueueStats }), _jsxs("div", { className: "grid gap-4 xl:grid-cols-3", children: [_jsxs("section", { className: "rounded-2xl border bg-card p-5 xl:col-span-2", children: [_jsx("div", { className: "flex items-center justify-between", children: _jsx("h2", { className: "text-lg font-semibold text-foreground", children: "Recent activity" }) }), _jsx(RecentActivityList, { isLoading: isLoading, events: data?.recentAudit ?? [] })] }), _jsxs("section", { className: "rounded-2xl border bg-card p-5", children: [_jsx("h2", { className: "text-lg font-semibold text-foreground", children: "Approval mode" }), _jsxs("div", { className: "mt-4 rounded-xl border bg-muted/30 p-4", children: [_jsx("div", { className: "text-sm font-medium text-muted-foreground", children: "Current policy" }), _jsx("div", { className: "mt-2 text-2xl font-semibold text-foreground", children: data?.settings?.enabled ? "Reviewed" : "Immediate" }), _jsx("p", { className: "mt-2 text-sm text-muted-foreground", children: data?.settings?.enabled
192
201
  ? "Changes wait for approval before they apply."
193
202
  : "Changes apply immediately and are recorded in audit." })] }), _jsxs("div", { className: "mt-4 space-y-2", children: [(data?.recentApprovals || []).map((approval) => (_jsxs("div", { className: "rounded-xl border px-4 py-3", children: [_jsx("div", { className: "text-sm font-medium text-foreground", children: approval.summary }), _jsxs("div", { className: "mt-1 text-xs text-muted-foreground", children: [approval.status, " \u00B7 requested by ", approval.requestedBy] })] }, approval.id))), (data?.recentApprovals?.length || 0) === 0 && (_jsx("div", { className: "rounded-xl border border-dashed px-4 py-6 text-sm text-muted-foreground", children: "No approval requests." }))] })] })] })] })] })] }));
194
203
  }