Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

_chat.workflows.tsx

24 lines1.1 KB

1import { splitsSurrogatePair } from "@t3tools/shared/assistantCitations";
2import { createFileRoute } from "@tanstack/react-router";
3​
4import { readWorkflowPane } from "../components/workflows/workflowPane.logic";
5import { WorkflowsPage, type WorkflowsSearch } from "../components/workflows/WorkflowsPage";
6​
7const sliceParam = (value: unknown) => {
8 if (typeof value !== "string") return undefined;
9 const sliced = value.slice(0, splitsSurrogatePair(value, 200) ? 199 : 200);
10 return sliced.trim() ? sliced : undefined;
11};
12​
13export const Route = createFileRoute("/_chat/workflows")({
14 validateSearch: (raw: Record<string, unknown>): WorkflowsSearch => ({
15 // Always set so a number or blank in the URL cannot fall through from the unvalidated search.
16 env: sliceParam(raw.env),
17 run: sliceParam(raw.run),
18 ...readWorkflowPane(raw.pane, raw.tab),
19 ...(raw.definitions === true || raw.definitions === "true" ? { definitions: true } : {}),
20 // Kept whole: a cut name would open, and save over, a different file.
21 file: typeof raw.file === "string" && raw.file.trim() ? raw.file : undefined,
22 }),
23 component: WorkflowsPage,
24});