@agent-native/dispatch 0.30.1 → 0.30.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/routes/pages/$appId.d.ts.map +1 -1
- package/dist/routes/pages/$appId.js +4 -3
- package/dist/routes/pages/$appId.js.map +1 -1
- package/dist/routes/pages/_index.d.ts.map +1 -1
- package/dist/routes/pages/_index.js +7 -2
- package/dist/routes/pages/_index.js.map +1 -1
- package/dist/routes/pages/_index.test.d.ts +2 -0
- package/dist/routes/pages/_index.test.d.ts.map +1 -0
- package/dist/routes/pages/_index.test.js +29 -0
- package/dist/routes/pages/_index.test.js.map +1 -0
- package/package.json +3 -3
- package/src/routes/pages/$appId.tsx +4 -3
- package/src/routes/pages/_index.test.ts +34 -0
- package/src/routes/pages/_index.tsx +7 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"$appId.d.ts","sourceRoot":"","sources":["../../../src/routes/pages/$appId.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"$appId.d.ts","sourceRoot":"","sources":["../../../src/routes/pages/$appId.tsx"],"names":[],"mappings":"AAWA,OAAO,EAKL,KAAK,wBAAwB,EAC7B,KAAK,kBAAkB,EACxB,MAAM,cAAc,CAAC;AActB,wBAAgB,IAAI;;IAEnB;AA2CD,wBAAsB,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE,kBAAkB,iBAQ1D;AAED,wBAAsB,YAAY,CAAC,EACjC,MAAM,EACN,YAAY,GACb,EAAE,wBAAwB,oBAS1B;AAED,MAAM,CAAC,OAAO,UAAU,yBAAyB,oDA0IhD"}
|
|
@@ -2,6 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { appPath } from "@agent-native/core/client/api-path";
|
|
3
3
|
import { useActionQuery } from "@agent-native/core/client/hooks";
|
|
4
4
|
import { useT } from "@agent-native/core/client/i18n";
|
|
5
|
+
import { withSsrHtmlContentType } from "@agent-native/core/shared";
|
|
5
6
|
import { withBuilderUtmTrackingParams } from "@agent-native/core/shared/builder-link-tracking";
|
|
6
7
|
import { IconArrowLeft, IconArrowUpRight, IconClockHour4, } from "@tabler/icons-react";
|
|
7
8
|
import { useEffect, useMemo, useState } from "react";
|
|
@@ -63,16 +64,16 @@ export async function loader({ params }) {
|
|
|
63
64
|
return null;
|
|
64
65
|
const selfTarget = dispatchSelfRedirect(appId);
|
|
65
66
|
if (selfTarget)
|
|
66
|
-
throw redirect(selfTarget);
|
|
67
|
+
throw withSsrHtmlContentType(redirect(selfTarget));
|
|
67
68
|
const target = await resolveServerCatchAllTarget(appId);
|
|
68
69
|
if (target)
|
|
69
|
-
throw redirect(target);
|
|
70
|
+
throw withSsrHtmlContentType(redirect(target));
|
|
70
71
|
return null;
|
|
71
72
|
}
|
|
72
73
|
export async function clientLoader({ params, serverLoader, }) {
|
|
73
74
|
const selfTarget = dispatchSelfRedirect(params.appId);
|
|
74
75
|
if (selfTarget)
|
|
75
|
-
throw redirect(selfTarget);
|
|
76
|
+
throw withSsrHtmlContentType(redirect(selfTarget));
|
|
76
77
|
// Defer to the server loader so the built-in template fallback runs on
|
|
77
78
|
// SPA navigations too (e.g. clicking a `/<template-id>` link inside
|
|
78
79
|
// dispatch). Without this the client side would only check the workspace
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"$appId.js","sourceRoot":"","sources":["../../../src/routes/pages/$appId.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,IAAI,EAAE,MAAM,gCAAgC,CAAC;AACtD,OAAO,EAAE,4BAA4B,EAAE,MAAM,iDAAiD,CAAC;AAC/F,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,cAAc,GACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,O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B,OAAO,EAAE,iBAAiB;iCAC3B,CAAC,EACF,MAAM,EAAC,QAAQ,EACf,GAAG,EAAC,YAAY,aAEf,CAAC,CAAC,kCAAkC,EAAE;wCACrC,YAAY,EAAE,iBAAiB;qCAChC,CAAC,EACF,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,aAAI,SAAS,EAAC,yCAAyC,YACpD,CAAC,CAAC,6BAA6B,CAAC,GAC9B,EACL,aAAG,SAAS,EAAC,+BAA+B,aAC1C,gBAAM,SAAS,EAAC,2BAA2B,kBAAG,KAAK,IAAQ,YAC1D,CAAC,CAAC,0CAA0C,CAAC,IAC5C,EACJ,KAAC,MAAM,IAAC,OAAO,kBACb,KAAC,IAAI,IAAC,EAAE,EAAE,OAAO,CAAC,OAAO,CAAC,YACvB,CAAC,CAAC,2BAA2B,CAAC,GAC1B,GACA,IACL,CACP,IACG,GACQ,CACjB,CAAC;AACJ,CAAC","sourcesContent":["import { appPath } from \"@agent-native/core/client/api-path\";\nimport { useActionQuery } from \"@agent-native/core/client/hooks\";\nimport { useT } from \"@agent-native/core/client/i18n\";\nimport { withBuilderUtmTrackingParams } from \"@agent-native/core/shared/builder-link-tracking\";\nimport {\n IconArrowLeft,\n IconArrowUpRight,\n IconClockHour4,\n} from \"@tabler/icons-react\";\nimport { useEffect, useMemo, useState } from \"react\";\nimport {\n Link,\n Navigate,\n redirect,\n useParams,\n type ClientLoaderFunctionArgs,\n type LoaderFunctionArgs,\n} from \"react-router\";\n\nimport { ActionQueryError } from \"../../components/action-query-error\";\nimport { DispatchShell } from \"../../components/dispatch-shell\";\nimport { Badge } from \"../../components/ui/badge\";\nimport { Button } from \"../../components/ui/button\";\nimport { Spinner } from \"../../components/ui/spinner\";\nimport { resolveServerCatchAllTarget } from \"../../lib/catch-all-target\";\nimport {\n navigateToWorkspaceApp,\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 * Built-in template fallback: when no workspace manifest is available\n * (framework dev with each template on its own port, hosted dispatch with\n * no sibling apps), redirect to the matching first-party template's deploy\n * URL — `http://localhost:<devPort>` in dev, `https://<id>.agent-native.com`\n * in production. Without this, a user visiting `/forms` on dispatch is\n * forced to sign in (auth guard) and then lands on this route's \"Page not\n * found\" pane after the post-login reload.\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 async 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 target = await resolveServerCatchAllTarget(appId);\n if (target) throw redirect(target);\n return null;\n}\n\nexport async function clientLoader({\n params,\n serverLoader,\n}: ClientLoaderFunctionArgs) {\n const selfTarget = dispatchSelfRedirect(params.appId);\n if (selfTarget) throw redirect(selfTarget);\n // Defer to the server loader so the built-in template fallback runs on\n // SPA navigations too (e.g. clicking a `/<template-id>` link inside\n // dispatch). Without this the client side would only check the workspace\n // apps query, which never lists the static first-party templates and so\n // the user would land on the \"Page not found\" pane.\n return serverLoader();\n}\n\nexport default function WorkspaceAppCatchAllRoute() {\n const t = useT();\n const { appId } = useParams();\n const appsQuery = useActionQuery(\"list-workspace-apps\", {\n includeAgentCards: false,\n });\n const { data: apps = [], isLoading } = appsQuery;\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 const hasApp = app !== null;\n const appIsPending = app?.status === \"pending\";\n const [navigationFailed, setNavigationFailed] = useState(false);\n\n useEffect(() => {\n if (isSelfReference) return;\n if (!hasApp || appIsPending || !href) {\n setNavigationFailed(false);\n return;\n }\n setNavigationFailed(!navigateToWorkspaceApp(href));\n }, [appIsPending, hasApp, href, isSelfReference]);\n\n if (isSelfReference) {\n return <Navigate to={appPath(\"/overview\")} replace />;\n }\n\n if (appsQuery.isError) {\n return (\n <DispatchShell\n title={t(\"dispatch.pages.dataLoadFailed\")}\n description={t(\"dispatch.pages.pageNotFoundDescription\")}\n >\n <ActionQueryError\n error={appsQuery.error}\n onRetry={() => void appsQuery.refetch()}\n />\n </DispatchShell>\n );\n }\n\n if (navigationFailed && href) {\n return (\n <DispatchShell\n title={t(\"dispatch.pages.dataLoadFailed\")}\n description={t(\"dispatch.pages.pageNotFoundDescription\")}\n >\n <ActionQueryError\n onRetry={() => setNavigationFailed(!navigateToWorkspaceApp(href))}\n />\n </DispatchShell>\n );\n }\n\n if (\n (isLoading && !app) ||\n (app && app.status !== \"pending\" && href && !navigationFailed)\n ) {\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 || t(\"dispatch.pages.pageNotFound\")}\n description={t(\"dispatch.pages.pageNotFoundDescription\")}\n >\n <div className=\"max-w-2xl rounded-lg 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 {t(\"dispatch.nav.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 {t(\"dispatch.pages.building\")}\n </Badge>\n </div>\n <p className=\"text-sm text-muted-foreground\">\n {t(\"dispatch.pages.appBuildingPrefix\")}{\" \"}\n <span className=\"font-mono text-foreground\">{app.path}</span>{\" \"}\n {t(\"dispatch.pages.appBuildingSuffix\")}\n </p>\n {app.builderUrl ? (\n <Button asChild>\n <a\n href={withBuilderUtmTrackingParams(app.builderUrl, {\n campaign: \"product\",\n content: \"dispatch_branch\",\n })}\n target=\"_blank\"\n rel=\"noreferrer\"\n >\n {t(\"dispatch.pages.openBuilderBranch\", {\n defaultValue: \"Open in Builder\",\n })}\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 {t(\"dispatch.pages.pageNotFound\")}\n </h2>\n <p className=\"text-sm text-muted-foreground\">\n <span className=\"font-mono text-foreground\">/{appId}</span> isn't\n {t(\"dispatch.pages.notDispatchOrWorkspaceApp\")}\n </p>\n <Button asChild>\n <Link to={appPath(\"/apps\")}>\n {t(\"dispatch.pages.browseApps\")}\n </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,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,IAAI,EAAE,MAAM,gCAAgC,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,4BAA4B,EAAE,MAAM,iDAAiD,CAAC;AAC/F,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,cAAc,GACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EACL,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,SAAS,GAGV,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AACtD,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EACL,sBAAsB,EACtB,gBAAgB,GAEjB,MAAM,0BAA0B,CAAC;AAElC,MAAM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S,EAAC,2BAA2B,kBAAG,KAAK,IAAQ,YAC1D,CAAC,CAAC,0CAA0C,CAAC,IAC5C,EACJ,KAAC,MAAM,IAAC,OAAO,kBACb,KAAC,IAAI,IAAC,EAAE,EAAE,OAAO,CAAC,OAAO,CAAC,YACvB,CAAC,CAAC,2BAA2B,CAAC,GAC1B,GACA,IACL,CACP,IACG,GACQ,CACjB,CAAC;AACJ,CAAC","sourcesContent":["import { appPath } from \"@agent-native/core/client/api-path\";\nimport { useActionQuery } from \"@agent-native/core/client/hooks\";\nimport { useT } from \"@agent-native/core/client/i18n\";\nimport { withSsrHtmlContentType } from \"@agent-native/core/shared\";\nimport { withBuilderUtmTrackingParams } from \"@agent-native/core/shared/builder-link-tracking\";\nimport {\n IconArrowLeft,\n IconArrowUpRight,\n IconClockHour4,\n} from \"@tabler/icons-react\";\nimport { useEffect, useMemo, useState } from \"react\";\nimport {\n Link,\n Navigate,\n redirect,\n useParams,\n type ClientLoaderFunctionArgs,\n type LoaderFunctionArgs,\n} from \"react-router\";\n\nimport { ActionQueryError } from \"../../components/action-query-error\";\nimport { DispatchShell } from \"../../components/dispatch-shell\";\nimport { Badge } from \"../../components/ui/badge\";\nimport { Button } from \"../../components/ui/button\";\nimport { Spinner } from \"../../components/ui/spinner\";\nimport { resolveServerCatchAllTarget } from \"../../lib/catch-all-target\";\nimport {\n navigateToWorkspaceApp,\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 * Built-in template fallback: when no workspace manifest is available\n * (framework dev with each template on its own port, hosted dispatch with\n * no sibling apps), redirect to the matching first-party template's deploy\n * URL — `http://localhost:<devPort>` in dev, `https://<id>.agent-native.com`\n * in production. Without this, a user visiting `/forms` on dispatch is\n * forced to sign in (auth guard) and then lands on this route's \"Page not\n * found\" pane after the post-login reload.\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 async function loader({ params }: LoaderFunctionArgs) {\n const appId = params.appId;\n if (!appId) return null;\n const selfTarget = dispatchSelfRedirect(appId);\n if (selfTarget) throw withSsrHtmlContentType(redirect(selfTarget));\n const target = await resolveServerCatchAllTarget(appId);\n if (target) throw withSsrHtmlContentType(redirect(target));\n return null;\n}\n\nexport async function clientLoader({\n params,\n serverLoader,\n}: ClientLoaderFunctionArgs) {\n const selfTarget = dispatchSelfRedirect(params.appId);\n if (selfTarget) throw withSsrHtmlContentType(redirect(selfTarget));\n // Defer to the server loader so the built-in template fallback runs on\n // SPA navigations too (e.g. clicking a `/<template-id>` link inside\n // dispatch). Without this the client side would only check the workspace\n // apps query, which never lists the static first-party templates and so\n // the user would land on the \"Page not found\" pane.\n return serverLoader();\n}\n\nexport default function WorkspaceAppCatchAllRoute() {\n const t = useT();\n const { appId } = useParams();\n const appsQuery = useActionQuery(\"list-workspace-apps\", {\n includeAgentCards: false,\n });\n const { data: apps = [], isLoading } = appsQuery;\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 const hasApp = app !== null;\n const appIsPending = app?.status === \"pending\";\n const [navigationFailed, setNavigationFailed] = useState(false);\n\n useEffect(() => {\n if (isSelfReference) return;\n if (!hasApp || appIsPending || !href) {\n setNavigationFailed(false);\n return;\n }\n setNavigationFailed(!navigateToWorkspaceApp(href));\n }, [appIsPending, hasApp, href, isSelfReference]);\n\n if (isSelfReference) {\n return <Navigate to={appPath(\"/overview\")} replace />;\n }\n\n if (appsQuery.isError) {\n return (\n <DispatchShell\n title={t(\"dispatch.pages.dataLoadFailed\")}\n description={t(\"dispatch.pages.pageNotFoundDescription\")}\n >\n <ActionQueryError\n error={appsQuery.error}\n onRetry={() => void appsQuery.refetch()}\n />\n </DispatchShell>\n );\n }\n\n if (navigationFailed && href) {\n return (\n <DispatchShell\n title={t(\"dispatch.pages.dataLoadFailed\")}\n description={t(\"dispatch.pages.pageNotFoundDescription\")}\n >\n <ActionQueryError\n onRetry={() => setNavigationFailed(!navigateToWorkspaceApp(href))}\n />\n </DispatchShell>\n );\n }\n\n if (\n (isLoading && !app) ||\n (app && app.status !== \"pending\" && href && !navigationFailed)\n ) {\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 || t(\"dispatch.pages.pageNotFound\")}\n description={t(\"dispatch.pages.pageNotFoundDescription\")}\n >\n <div className=\"max-w-2xl rounded-lg 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 {t(\"dispatch.nav.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 {t(\"dispatch.pages.building\")}\n </Badge>\n </div>\n <p className=\"text-sm text-muted-foreground\">\n {t(\"dispatch.pages.appBuildingPrefix\")}{\" \"}\n <span className=\"font-mono text-foreground\">{app.path}</span>{\" \"}\n {t(\"dispatch.pages.appBuildingSuffix\")}\n </p>\n {app.builderUrl ? (\n <Button asChild>\n <a\n href={withBuilderUtmTrackingParams(app.builderUrl, {\n campaign: \"product\",\n content: \"dispatch_branch\",\n })}\n target=\"_blank\"\n rel=\"noreferrer\"\n >\n {t(\"dispatch.pages.openBuilderBranch\", {\n defaultValue: \"Open in Builder\",\n })}\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 {t(\"dispatch.pages.pageNotFound\")}\n </h2>\n <p className=\"text-sm text-muted-foreground\">\n <span className=\"font-mono text-foreground\">/{appId}</span> isn't\n {t(\"dispatch.pages.notDispatchOrWorkspaceApp\")}\n </p>\n <Button asChild>\n <Link to={appPath(\"/apps\")}>\n {t(\"dispatch.pages.browseApps\")}\n </Link>\n </Button>\n </div>\n )}\n </div>\n </DispatchShell>\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_index.d.ts","sourceRoot":"","sources":["../../../src/routes/pages/_index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"_index.d.ts","sourceRoot":"","sources":["../../../src/routes/pages/_index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAY,KAAK,kBAAkB,EAAE,MAAM,cAAc,CAAC;AASjE,wBAAgB,IAAI;;;;;;;;;;;;;;;KAanB;AAkBD,wBAAgB,MAAM,CAAC,EAAE,GAAG,EAAE,EAAE,kBAAkB,QAIjD;AAED,wBAAgB,YAAY,CAAC,EAAE,GAAG,EAAE,EAAE,kBAAkB,QAIvD;AAED,wBAAgB,eAAe,oDAM9B;AAED,MAAM,CAAC,OAAO,UAAU,SAAS,SAEhC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { appPath } from "@agent-native/core/client/api-path";
|
|
3
|
+
import { withSsrHtmlContentType } from "@agent-native/core/shared";
|
|
3
4
|
import { redirect } from "react-router";
|
|
4
5
|
import { Spinner } from "../../components/ui/spinner.js";
|
|
5
6
|
const SEO_TITLE = "Dispatch - Open Source workspace control plane for AI agents";
|
|
@@ -34,10 +35,14 @@ function buildTarget(url) {
|
|
|
34
35
|
return appPath(`/overview${url.search}${url.hash}`);
|
|
35
36
|
}
|
|
36
37
|
export function loader({ url }) {
|
|
37
|
-
throw redirect(buildTarget(url))
|
|
38
|
+
throw withSsrHtmlContentType(redirect(buildTarget(url)), {
|
|
39
|
+
varyByQuery: true,
|
|
40
|
+
});
|
|
38
41
|
}
|
|
39
42
|
export function clientLoader({ url }) {
|
|
40
|
-
throw redirect(buildTarget(url))
|
|
43
|
+
throw withSsrHtmlContentType(redirect(buildTarget(url)), {
|
|
44
|
+
varyByQuery: true,
|
|
45
|
+
});
|
|
41
46
|
}
|
|
42
47
|
export function HydrateFallback() {
|
|
43
48
|
return (_jsx("div", { className: "flex items-center justify-center h-screen w-full", children: _jsx(Spinner, { className: "size-8" }) }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_index.js","sourceRoot":"","sources":["../../../src/routes/pages/_index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAA2B,MAAM,cAAc,CAAC;AAEjE,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAEtD,MAAM,SAAS,GACb,8DAA8D,CAAC;AACjE,MAAM,eAAe,GACnB,iIAAiI,CAAC;AAEpI,MAAM,UAAU,IAAI;IAClB,OAAO;QACL,EAAE,KAAK,EAAE,SAAS,EAAE;QACpB;YACE,IAAI,EAAE,aAAa;YACnB,OAAO,EAAE,eAAe;SACzB;QACD,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE;QAC5C,EAAE,QAAQ,EAAE,gBAAgB,EAAE,OAAO,EAAE,eAAe,EAAE;QACxD,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,SAAS,EAAE;QAC5C,EAAE,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,SAAS,EAAE;QAC7C,EAAE,IAAI,EAAE,qBAAqB,EAAE,OAAO,EAAE,eAAe,EAAE;KAC1D,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAS,WAAW,CAAC,GAAQ;IAC3B,OAAO,OAAO,CAAC,YAAY,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,EAAE,GAAG,EAAsB;IAChD,MAAM,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"_index.js","sourceRoot":"","sources":["../../../src/routes/pages/_index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,QAAQ,E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C,QAAQ,GAAG,GAC1B,CACP,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,OAAO,UAAU,SAAS;IAC/B,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import { appPath } from \"@agent-native/core/client/api-path\";\nimport { withSsrHtmlContentType } from \"@agent-native/core/shared\";\nimport { redirect, type LoaderFunctionArgs } from \"react-router\";\n\nimport { Spinner } from \"../../components/ui/spinner\";\n\nconst SEO_TITLE =\n \"Dispatch - Open Source workspace control plane for AI agents\";\nconst SEO_DESCRIPTION =\n \"Open Source workspace control plane for AI agents to manage apps, secrets, approvals, messages, jobs, and cross-app delegation.\";\n\nexport function meta() {\n return [\n { title: SEO_TITLE },\n {\n name: \"description\",\n content: SEO_DESCRIPTION,\n },\n { property: \"og:title\", content: SEO_TITLE },\n { property: \"og:description\", content: SEO_DESCRIPTION },\n { name: \"twitter:card\", content: \"summary\" },\n { name: \"twitter:title\", content: SEO_TITLE },\n { name: \"twitter:description\", content: SEO_DESCRIPTION },\n ];\n}\n\n/**\n * Run the redirect on both the server and the client. A client-only\n * `<Navigate>` can drop during hydration (before the route tree is fully\n * attached), leaving the user stranded on `/` with a blank main area while\n * the layout chrome around it still renders. A `loader` redirect runs as\n * part of the server response and the navigation completes before the app\n * hydrates; `clientLoader` covers SPA-style navigations to `/`.\n *\n * We preserve `?` and `#` so deep-links like `?thread=<id>` from a Slack\n * \"Open thread\" button survive the bounce — `useThreadDeepLink` in\n * `root.tsx` reads them after the redirect lands and opens `/chat`.\n */\nfunction buildTarget(url: URL): string {\n return appPath(`/overview${url.search}${url.hash}`);\n}\n\nexport function loader({ url }: LoaderFunctionArgs) {\n throw withSsrHtmlContentType(redirect(buildTarget(url)), {\n varyByQuery: true,\n });\n}\n\nexport function clientLoader({ url }: LoaderFunctionArgs) {\n throw withSsrHtmlContentType(redirect(buildTarget(url)), {\n varyByQuery: true,\n });\n}\n\nexport function HydrateFallback() {\n return (\n <div className=\"flex items-center justify-center h-screen w-full\">\n <Spinner className=\"size-8\" />\n </div>\n );\n}\n\nexport default function IndexPage() {\n return null;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_index.test.d.ts","sourceRoot":"","sources":["../../../src/routes/pages/_index.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { SSR_QUERY_CACHE_KEY_HEADER } from "@agent-native/core/shared";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
import { clientLoader, loader } from "./_index.js";
|
|
4
|
+
function expectOverviewRedirect(routeLoader) {
|
|
5
|
+
let thrown;
|
|
6
|
+
try {
|
|
7
|
+
routeLoader({
|
|
8
|
+
url: new URL("https://dispatch.example/?thread=thread-1"),
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
catch (error) {
|
|
12
|
+
thrown = error;
|
|
13
|
+
}
|
|
14
|
+
expect(thrown).toBeInstanceOf(Response);
|
|
15
|
+
const response = thrown;
|
|
16
|
+
expect(response.status).toBe(302);
|
|
17
|
+
expect(response.headers.get("location")).toBe("/overview?thread=thread-1");
|
|
18
|
+
expect(response.headers.get("content-type")).toBe("text/html; charset=utf-8");
|
|
19
|
+
expect(response.headers.get(SSR_QUERY_CACHE_KEY_HEADER)).toBe("query");
|
|
20
|
+
}
|
|
21
|
+
describe("Dispatch root route", () => {
|
|
22
|
+
it("marks the server redirect as cacheable HTML", () => {
|
|
23
|
+
expectOverviewRedirect(loader);
|
|
24
|
+
});
|
|
25
|
+
it("marks the client redirect as cacheable HTML", () => {
|
|
26
|
+
expectOverviewRedirect(clientLoader);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
//# sourceMappingURL=_index.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_index.test.js","sourceRoot":"","sources":["../../../src/routes/pages/_index.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AACvE,O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"@agent-native/core/shared\";\nimport { describe, expect, it } from \"vitest\";\n\nimport { clientLoader, loader } from \"./_index\";\n\nfunction expectOverviewRedirect(\n routeLoader: typeof loader | typeof clientLoader,\n) {\n let thrown: unknown;\n try {\n routeLoader({\n url: new URL(\"https://dispatch.example/?thread=thread-1\"),\n } as never);\n } catch (error) {\n thrown = error;\n }\n\n expect(thrown).toBeInstanceOf(Response);\n const response = thrown as Response;\n expect(response.status).toBe(302);\n expect(response.headers.get(\"location\")).toBe(\"/overview?thread=thread-1\");\n expect(response.headers.get(\"content-type\")).toBe(\"text/html; charset=utf-8\");\n expect(response.headers.get(SSR_QUERY_CACHE_KEY_HEADER)).toBe(\"query\");\n}\n\ndescribe(\"Dispatch root route\", () => {\n it(\"marks the server redirect as cacheable HTML\", () => {\n expectOverviewRedirect(loader);\n });\n\n it(\"marks the client redirect as cacheable HTML\", () => {\n expectOverviewRedirect(clientLoader);\n });\n});\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-native/dispatch",
|
|
3
|
-
"version": "0.30.
|
|
3
|
+
"version": "0.30.2",
|
|
4
4
|
"description": "Dispatch — workspace control plane for agent-native apps. Vault, integrations, destinations, scheduled jobs, and cross-app delegation, shipped as a single drop-in package.",
|
|
5
5
|
"homepage": "https://github.com/BuilderIO/agent-native#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -101,10 +101,10 @@
|
|
|
101
101
|
"typescript-7": "npm:typescript@^7.0.2",
|
|
102
102
|
"vite": "8.1.0",
|
|
103
103
|
"vitest": "^4.1.5",
|
|
104
|
-
"@agent-native/core": "0.
|
|
104
|
+
"@agent-native/core": "0.0.0-beta-20260819161541"
|
|
105
105
|
},
|
|
106
106
|
"peerDependencies": {
|
|
107
|
-
"@agent-native/core": "
|
|
107
|
+
"@agent-native/core": "0.0.0-beta-20260819161541",
|
|
108
108
|
"react": ">=19.2.7",
|
|
109
109
|
"react-dom": ">=19.2.7",
|
|
110
110
|
"react-router": ">=8"
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { appPath } from "@agent-native/core/client/api-path";
|
|
2
2
|
import { useActionQuery } from "@agent-native/core/client/hooks";
|
|
3
3
|
import { useT } from "@agent-native/core/client/i18n";
|
|
4
|
+
import { withSsrHtmlContentType } from "@agent-native/core/shared";
|
|
4
5
|
import { withBuilderUtmTrackingParams } from "@agent-native/core/shared/builder-link-tracking";
|
|
5
6
|
import {
|
|
6
7
|
IconArrowLeft,
|
|
@@ -78,9 +79,9 @@ export async function loader({ params }: LoaderFunctionArgs) {
|
|
|
78
79
|
const appId = params.appId;
|
|
79
80
|
if (!appId) return null;
|
|
80
81
|
const selfTarget = dispatchSelfRedirect(appId);
|
|
81
|
-
if (selfTarget) throw redirect(selfTarget);
|
|
82
|
+
if (selfTarget) throw withSsrHtmlContentType(redirect(selfTarget));
|
|
82
83
|
const target = await resolveServerCatchAllTarget(appId);
|
|
83
|
-
if (target) throw redirect(target);
|
|
84
|
+
if (target) throw withSsrHtmlContentType(redirect(target));
|
|
84
85
|
return null;
|
|
85
86
|
}
|
|
86
87
|
|
|
@@ -89,7 +90,7 @@ export async function clientLoader({
|
|
|
89
90
|
serverLoader,
|
|
90
91
|
}: ClientLoaderFunctionArgs) {
|
|
91
92
|
const selfTarget = dispatchSelfRedirect(params.appId);
|
|
92
|
-
if (selfTarget) throw redirect(selfTarget);
|
|
93
|
+
if (selfTarget) throw withSsrHtmlContentType(redirect(selfTarget));
|
|
93
94
|
// Defer to the server loader so the built-in template fallback runs on
|
|
94
95
|
// SPA navigations too (e.g. clicking a `/<template-id>` link inside
|
|
95
96
|
// dispatch). Without this the client side would only check the workspace
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { SSR_QUERY_CACHE_KEY_HEADER } from "@agent-native/core/shared";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
|
|
4
|
+
import { clientLoader, loader } from "./_index";
|
|
5
|
+
|
|
6
|
+
function expectOverviewRedirect(
|
|
7
|
+
routeLoader: typeof loader | typeof clientLoader,
|
|
8
|
+
) {
|
|
9
|
+
let thrown: unknown;
|
|
10
|
+
try {
|
|
11
|
+
routeLoader({
|
|
12
|
+
url: new URL("https://dispatch.example/?thread=thread-1"),
|
|
13
|
+
} as never);
|
|
14
|
+
} catch (error) {
|
|
15
|
+
thrown = error;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
expect(thrown).toBeInstanceOf(Response);
|
|
19
|
+
const response = thrown as Response;
|
|
20
|
+
expect(response.status).toBe(302);
|
|
21
|
+
expect(response.headers.get("location")).toBe("/overview?thread=thread-1");
|
|
22
|
+
expect(response.headers.get("content-type")).toBe("text/html; charset=utf-8");
|
|
23
|
+
expect(response.headers.get(SSR_QUERY_CACHE_KEY_HEADER)).toBe("query");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
describe("Dispatch root route", () => {
|
|
27
|
+
it("marks the server redirect as cacheable HTML", () => {
|
|
28
|
+
expectOverviewRedirect(loader);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("marks the client redirect as cacheable HTML", () => {
|
|
32
|
+
expectOverviewRedirect(clientLoader);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { appPath } from "@agent-native/core/client/api-path";
|
|
2
|
+
import { withSsrHtmlContentType } from "@agent-native/core/shared";
|
|
2
3
|
import { redirect, type LoaderFunctionArgs } from "react-router";
|
|
3
4
|
|
|
4
5
|
import { Spinner } from "../../components/ui/spinner";
|
|
@@ -40,11 +41,15 @@ function buildTarget(url: URL): string {
|
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
export function loader({ url }: LoaderFunctionArgs) {
|
|
43
|
-
throw redirect(buildTarget(url))
|
|
44
|
+
throw withSsrHtmlContentType(redirect(buildTarget(url)), {
|
|
45
|
+
varyByQuery: true,
|
|
46
|
+
});
|
|
44
47
|
}
|
|
45
48
|
|
|
46
49
|
export function clientLoader({ url }: LoaderFunctionArgs) {
|
|
47
|
-
throw redirect(buildTarget(url))
|
|
50
|
+
throw withSsrHtmlContentType(redirect(buildTarget(url)), {
|
|
51
|
+
varyByQuery: true,
|
|
52
|
+
});
|
|
48
53
|
}
|
|
49
54
|
|
|
50
55
|
export function HydrateFallback() {
|