@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
ts 62 lines 1.79 KB
Raw
1 /**
2 * Root routes listed as presented over the workspace, including ones that are plain cards on
3 * Android but still sit above the workspace there.
4 */
5 const LISTED_OVERLAY_ROUTES: ReadonlySet<string> = new Set([
6 "PullRequestReview",
7 "PullRequestInlineComment",
8 "ConnectOnboarding",
9 "Connections",
10 "ConnectionsNew",
11 "GitBranches",
12 "GitCommit",
13 "GitConfirm",
14 "GitOverview",
15 "NewTaskProject",
16 "NewTaskFiles",
17 "NewTaskFile",
18 "NewTaskAttachment",
19 "NewTaskThreadSettings",
20 "AddProject",
21 "AddProjectRepository",
22 "AddProjectDestination",
23 "AddProjectLocal",
24 "AddProjectNew",
25 "NewTaskEnvironment",
26 "NewTaskBranch",
27 "SettingsLegal",
28 "SettingsAuth",
29 "SettingsWaitlist",
30 "ThreadAgents",
31 "ThreadBackgroundWork",
32 "ThreadGuestShare",
33 "ThreadPullRequests",
34 "ThreadQueue",
35 "ThreadReviewComment",
36 "ThreadDevicePreview",
37 "ThreadBrowserPreview",
38 "ThreadSettingsSheet",
39 ]);
40
41 // Every route whose `presentation` is a sheet or modal, read from the root stack's config once.
42 let presentedRoutes: ReadonlySet<string> = new Set();
43
44 export function registerPresentedRoutes(names: Iterable<string>) {
45 presentedRoutes = new Set(names);
46 }
47
48 /** Whether a root route is presented over the workspace (a sheet or modal). */
49 export function isWorkspaceOverlayRoute(name: string) {
50 return LISTED_OVERLAY_ROUTES.has(name) || presentedRoutes.has(name);
51 }
52
53 /** The routes that make up the workspace, up to the first sheet or modal above it. */
54 export function workspaceRoutesOf<Route extends { readonly name: string }>(
55 routes: readonly Route[],
56 ) {
57 const firstOverlay = routes.findIndex((route) => isWorkspaceOverlayRoute(route.name));
58 return {
59 workspace: firstOverlay < 0 ? routes : routes.slice(0, firstOverlay),
60 overlays: firstOverlay < 0 ? [] : routes.slice(firstOverlay),
61 };
62 }