@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, 03:37 UTC

main
tsx 55 lines 2.36 KB
Raw
1 import { createContext } from "react";
2
3 import type { InspectorContent } from "../features/layout/inspector-panes";
4 import type { NativeLayoutMetrics } from "../lib/reserved-regions";
5
6 export const NativeWorkspaceModeContext = createContext(false);
7 /**
8 * Each workspace tab slot renders the same routes, so header options a screen sets are kept per
9 * slot (by route key) instead of on the shared route: a slot's header then never shows options
10 * another slot set, and switching tabs has nothing left to update.
11 */
12 export interface WorkspaceSlotOptions {
13 readonly byRoute: ReadonlyMap<string, object>;
14 readonly set: (routeKey: string, options: object) => void;
15 }
16 export const WorkspaceSlotOptionsContext = createContext<WorkspaceSlotOptions | null>(null);
17
18 /** A route's options with whatever its screens set within this slot on top. */
19 export function slotScreenOptions<Options extends object>(
20 slot: WorkspaceSlotOptions | null,
21 routeKey: string | undefined,
22 options: Options,
23 ): Options {
24 const own = routeKey === undefined ? undefined : slot?.byRoute.get(routeKey);
25 return own ? { ...options, ...own } : options;
26 }
27
28 /** Retained tabs must not update another tab's navigation options. */
29 export const NativeWorkspaceTabActivityContext = createContext<{
30 readonly active: boolean;
31 readonly isActive: () => boolean;
32 /**
33 * A tab not shown yet mounts only its header, so UIKit can put it in the window once before
34 * the first visit; it writes header options while inactive and loads nothing.
35 */
36 readonly headerOnly?: boolean;
37 } | null>(null);
38 /**
39 * What the shown workspace tab measured per column. UIKit lays out bars and safe areas only for
40 * the selected tab, so a tab that hasn't been shown yet starts from these instead.
41 */
42 export const WorkspaceColumnMetricsContext = createContext<{
43 readonly byColumn: ReadonlyMap<string, NativeLayoutMetrics>;
44 readonly publish: (column: string, metrics: NativeLayoutMetrics) => void;
45 } | null>(null);
46 export const NativePrimaryColumnContext = createContext<{
47 readonly presented: boolean;
48 readonly selectedThreadKey: string | null;
49 readonly selectedPullRequestKey: string | null;
50 readonly selectedIssueKey: string | null;
51 } | null>(null);
52 export const NativeWorkspaceInspectorContext = createContext<{
53 readonly content: InspectorContent | undefined;
54 readonly visible: boolean;
55 }>({ content: undefined, visible: false });