Open History to see the last commit
1import { useAuth } from "@clerk/react";
2import { Link } from "@tanstack/react-router";
3
4import { hasCloudPublicConfig } from "~/cloud/publicConfig";
5import { useT3ConnectAuthPrompt } from "../clerk/useT3ConnectAuthPrompt";
6import { Button } from "../ui/button";
7import { Switch } from "../ui/switch";
8import { ScopedSwitch } from "./ScopedSwitch";
9import { SettingsPageContainer, SettingsRow, SettingsSection } from "./settingsLayout";
10import { searchableSetting } from "./settingsSearch";
11import { LegacyFeaturesSection } from "./SettingsPanels";
12import { useScopedSettings, useUpdateScopedSettings } from "./useScopedSettings";
13
14/** Features still settling in, and legacy behavior kept for people who rely on it. */
15export function LabsSettingsPanel() {
16 return (
17 <SettingsPageContainer>
18 <SettingsSection id="beta" title="Beta">
19 <BoringSidebarRow />
20 <BoringSidebarMultilineRow />
21 {/* Clerk is only mounted when this build has T3 Connect. */}
22 {hasCloudPublicConfig() ? <GuestLinksRowWithSignIn /> : <GuestLinksRow />}
23 <LinkedEnvironmentsRow />
24 <SimlockHostsRow />
25 </SettingsSection>
26 <LegacyFeaturesSection />
27 </SettingsPageContainer>
28 );
29}
30
31function BoringSidebarRow() {
32 const settings = useScopedSettings();
33 const updateSettings = useUpdateScopedSettings();
34 return (
35 <SettingsRow
36 {...searchableSetting("boring-sidebar")}
37 description="Group sidebar threads into project folders. Pinned threads stay on top, and Snoozed and Settled stay below the folders."
38 control={
39 <Switch
40 checked={settings.boringSidebarEnabled || settings.legacySidebarEnabled}
41 // Turning it off also clears the opt-in of the removed legacy sidebar.
42 onCheckedChange={(checked) =>
43 updateSettings({ boringSidebarEnabled: Boolean(checked), legacySidebarEnabled: false })
44 }
45 aria-label="Boring sidebar (group by project)"
46 />
47 }
48 />
49 );
50}
51
52function BoringSidebarMultilineRow() {
53 const settings = useScopedSettings();
54 const updateSettings = useUpdateScopedSettings();
55 return (
56 <SettingsRow
57 {...searchableSetting("boring-sidebar-multiline")}
58 description="In the boring sidebar, show folder threads on two lines: the title, then the branch, pull request, and agent."
59 control={
60 <Switch
61 checked={settings.boringSidebarMultilineRows}
62 onCheckedChange={(checked) =>
63 updateSettings({ boringSidebarMultilineRows: Boolean(checked) })
64 }
65 aria-label="Two-line folder rows"
66 />
67 }
68 />
69 );
70}
71
72/** Signed out of T3 Connect, the row offers to sign in instead of its switch. */
73function GuestLinksRowWithSignIn() {
74 const { isSignedIn } = useAuth();
75 const { openAuthPrompt } = useT3ConnectAuthPrompt();
76 // `isSignedIn` is undefined until Clerk loads.
77 if (isSignedIn !== false) return <GuestLinksRow />;
78 return (
79 <SettingsRow
80 {...searchableSetting("guest-links")}
81 description="Share a thread with a guest who watches it live in their browser and sends messages you approve. Sign in to T3 Connect to use guest links."
82 control={
83 <Button size="sm" variant="outline" onClick={openAuthPrompt}>
84 Sign in
85 </Button>
86 }
87 />
88 );
89}
90
91function GuestLinksRow() {
92 const settings = useScopedSettings();
93 const updateSettings = useUpdateScopedSettings();
94 return (
95 <SettingsRow
96 serverScoped
97 {...searchableSetting("guest-links")}
98 settingKeys={["guestSharingEnabled"]}
99 description={
100 <>
101 Share a thread with a guest who watches it live in their browser and sends messages you
102 approve. Needs T3 Connect: sign in and link this machine in{" "}
103 <Link to="/settings/access" className="underline underline-offset-2">
104 Sharing & access
105 </Link>
106 . While it is off, every guest link stops working.
107 </>
108 }
109 control={
110 <ScopedSwitch
111 settingKeys={["guestSharingEnabled"]}
112 checked={settings.guestSharingEnabled}
113 onCheckedChange={(checked) => updateSettings({ guestSharingEnabled: Boolean(checked) })}
114 aria-label="Guest links"
115 />
116 }
117 />
118 );
119}
120
121function LinkedEnvironmentsRow() {
122 const settings = useScopedSettings();
123 const updateSettings = useUpdateScopedSettings();
124 return (
125 <SettingsRow
126 serverScoped
127 {...searchableSetting("linked-environments-beta")}
128 settingKeys={["linkedEnvironmentsEnabled"]}
129 description={
130 <>
131 Let agents here work on your other machines, and theirs here. Turn it on for each machine,
132 then link them in{" "}
133 <Link to="/settings/connections" className="underline underline-offset-2">
134 Connections
135 </Link>
136 . While it is off, nothing new starts over a link; tasks already running finish.
137 </>
138 }
139 control={
140 <ScopedSwitch
141 settingKeys={["linkedEnvironmentsEnabled"]}
142 checked={settings.linkedEnvironmentsEnabled}
143 onCheckedChange={(checked) =>
144 updateSettings({ linkedEnvironmentsEnabled: Boolean(checked) })
145 }
146 aria-label="Linked environments"
147 />
148 }
149 />
150 );
151}
152
153function SimlockHostsRow() {
154 const settings = useScopedSettings();
155 const updateSettings = useUpdateScopedSettings();
156 return (
157 <SettingsRow
158 serverScoped
159 {...searchableSetting("simlock-hosts")}
160 settingKeys={["simlockDeviceHostsEnabled"]}
161 description={
162 <>
163 Let the Device panel lease simulators and emulators from your own{" "}
164 <a
165 href="https://incubator.callstack.com/simlock/"
166 target="_blank"
167 rel="noreferrer"
168 className="underline underline-offset-2"
169 >
170 Simlock
171 </a>{" "}
172 pool, added in{" "}
173 <Link to="/settings/devices" className="underline underline-offset-2">
174 Devices
175 </Link>
176 . An alpha that may change or break. T3 Code never installs Simlock.
177 </>
178 }
179 control={
180 <ScopedSwitch
181 settingKeys={["simlockDeviceHostsEnabled"]}
182 checked={settings.simlockDeviceHostsEnabled}
183 onCheckedChange={(checked) =>
184 updateSettings({ simlockDeviceHostsEnabled: Boolean(checked) })
185 }
186 aria-label="Simlock device hosts"
187 />
188 }
189 />
190 );
191}