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, 08:30 UTC
feat(mobile): source control providers and issue trackers in settings (#37814)
Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
Julius Marminge committed
Nov 16, 2026 at 22:00 UTC
652e2f2ab59266ad6ca0fa4bda57b1dcb97722ff
9 files changed
+1010
-103
apps/mobile/src/Stack.tsx
+12
@@ -99,6 +99,10 @@ import { SettingsDiagnosticsRouteScreen } from "./features/diagnostics/SettingsD
99
import { SettingsProviderAccountsRouteScreen } from "./features/settings/SettingsProviderAccountsRouteScreen";
100
import { SettingsAuthRouteScreen } from "./features/settings/SettingsAuthRouteScreen";
101
import { SettingsEnvironmentDetailRouteScreen } from "./features/settings/SettingsEnvironmentDetailRouteScreen";
102
+import {
103
+ SettingsIssueTrackerRouteScreen,
104
+ SettingsSourceControlProviderRouteScreen,
105
+} from "./features/settings/SettingsSourceControlDetailRouteScreens";
106
import { SettingsEnvironmentsRouteScreen } from "./features/settings/SettingsEnvironmentsRouteScreen";
107
import { SettingsFollowUpRouteScreen } from "./features/settings/SettingsFollowUpRouteScreen";
108
import { SettingsLanguageRouteScreen } from "./features/settings/SettingsLanguageRouteScreen";
@@ -193,6 +197,14 @@ const SETTINGS_SCREENS = {
197
linking: "settings/source-control",
198
options: settingsPage("Source control & issues"),
199
}),
200
+ SettingsSourceControlProvider: createNativeStackScreen({
201
+ screen: SettingsSourceControlProviderRouteScreen,
202
+ options: settingsPage("Provider"),
203
+ }),
204
+ SettingsIssueTracker: createNativeStackScreen({
205
+ screen: SettingsIssueTrackerRouteScreen,
206
+ options: settingsPage("Issue tracker"),
207
+ }),
208
SettingsEnvironmentAgentBehavior: createNativeStackScreen({
209
screen: SettingsThreadsRouteScreen,
210
linking: "settings/agent-behavior",
apps/mobile/src/features/settings/SettingsServerControlsRouteScreen.test.tsx
+3
-2
@@ -45,8 +45,9 @@ vi.mock("../../state/preferences", () => ({
45
updateMobilePreferencesAtom: {},
46
}));
47
vi.mock("./components/AutoSettleDaysField", () => ({ AutoSettleDaysField: () => null }));
48
-vi.mock("./components/SourceControlSignInSection", () => ({
49
- SourceControlSignInSection: () => null,
48
+vi.mock("./components/IssueTrackerSection", () => ({ IssueTrackerSection: () => null }));
49
+vi.mock("./components/SourceControlProvidersSection", () => ({
50
+ SourceControlProvidersSection: () => null,
51
}));
52
vi.mock("react-native-safe-area-context", () => ({ useSafeAreaInsets: () => ({ bottom: 0 }) }));
53
vi.mock("@react-navigation/native", () => ({ useNavigation: () => ({}) }));
apps/mobile/src/features/settings/SettingsServerControlsRouteScreen.tsx
+5
-30
@@ -28,7 +28,8 @@ import { DatabaseStorageNotice } from "./components/DatabaseStorageNotice";
28
import { ListChoiceRow as SettingsChoiceRow } from "../../components/ui/ListChoiceRow";
29
import { SettingsSection } from "./components/SettingsSection";
30
import { SettingsSwitchRow } from "./components/SettingsSwitchRow";
31
-import { SourceControlSignInSection } from "./components/SourceControlSignInSection";
31
+import { IssueTrackerSection } from "./components/IssueTrackerSection";
32
+import { SourceControlProvidersSection } from "./components/SourceControlProvidersSection";
33
import { SettingsProjectOverridesSection } from "./components/SettingsProjectOverridesSection";
34
import { useSettingsEnvironmentFilter } from "./settings-environment-filter";
35
import { useSettingsWriter } from "./useSettingsWriter";
@@ -43,14 +44,12 @@ import {
44
import { PullRequestGlyph } from "../pull-requests/pullRequestGlyphs";
45
import { AutoSettleSettingsRows } from "./ThreadSettingsSections";
46
import { supportsSharedSettingsSync } from "@t3tools/client-runtime/state/shared-settings";
46
-import { isSourceControlProviderOffered } from "@t3tools/client-runtime/operations/projects";
47
-import { sourceControlClients } from "@t3tools/client-runtime/source-control-clients";
47
48
type SettingsPage = "threads" | "source-control" | "worktrees" | "maintenance";
49
50
const PAGE_TITLES: Record<SettingsPage, string> = {
51
threads: "Threads",
53
- "source-control": "Source control",
52
+ "source-control": "Source control & issues",
53
worktrees: "Worktrees",
54
maintenance: "Maintenance",
55
};
@@ -403,36 +402,12 @@ function ServerSettingsDetail(props: { readonly page: SettingsPage }) {
402
{props.page === "source-control" ? (
403
<>
404
{projectSelected ? null : (
406
- <SourceControlSignInSection
405
+ <SourceControlProvidersSection
406
environments={selectedTargets}
407
canWrite={(environmentId) => writableEnvironments.has(environmentId)}
408
/>
409
)}
411
- {projectSelected ? null : (
412
- <SettingsSection title="Project sources">
413
- {sourceControlClients.definitions.map((definition) => {
414
- const offered = displayTargets.map((target) =>
415
- isSourceControlProviderOffered(
416
- target.settings.offeredSourceControlProviders,
417
- definition.kind,
418
- ),
419
- );
420
- return (
421
- <SettingsSwitchRow
422
- key={definition.kind}
423
- label={definition.pickerLabel}
424
- value={
425
- offered.every((value) => value === offered[0]) ? offered[0]! : null
426
- }
427
- disabled={disabledFor("offeredSourceControlProviders")}
428
- onValueChange={(value) =>
429
- write({ offeredSourceControlProviders: { [definition.kind]: value } })
430
- }
431
- />
432
- );
433
- })}
434
- </SettingsSection>
435
- )}
410
+ {projectSelected ? null : <IssueTrackerSection environments={selectedTargets} />}
411
<SettingsSection title="Pull requests">
412
<SettingsSwitchRow
413
icon={PullRequestGlyph.merged}
apps/mobile/src/features/settings/SettingsSourceControlDetailRouteScreens.tsx
new
+196
@@ -0,0 +1,196 @@
1
+import { useAtomValue } from "@effect/atom-react";
2
+import type { StaticScreenProps } from "@react-navigation/native";
3
+import { issueTrackerSummary } from "@t3tools/client-runtime/state/issue-trackers";
4
+import { sourceControlClients } from "@t3tools/client-runtime/source-control-clients";
5
+import {
6
+ AuthSettingsWriteScope,
7
+ type EnvironmentId,
8
+ type SourceControlProviderKind,
9
+} from "@t3tools/contracts";
10
+import * as Option from "effect/Option";
11
+import type { ReactNode } from "react";
12
+import { useSafeAreaInsets } from "react-native-safe-area-context";
13
+
14
+import { AppText as Text } from "../../components/ui/AppText";
15
+import { ScreenScrollView as ScrollView } from "../../components/ui/ScreenScrollView";
16
+import { useEnvironments } from "../../state/environments";
17
+import { issueTrackerEnvironment } from "../../state/issueTrackers";
18
+import { useEnvironmentQuery } from "../../state/query";
19
+import { serverEnvironment } from "../../state/server";
20
+import { useEnvironmentsWithScope } from "../../state/session";
21
+import { sourceControlEnvironment } from "../../state/sourceControl";
22
+import {
23
+ IssueTrackerCredentialForm,
24
+ IssueTrackerProjectRows,
25
+} from "./components/IssueTrackerSection";
26
+import { SettingsScreen } from "./components/SettingsScreen";
27
+import { SettingsSection } from "./components/SettingsSection";
28
+import {
29
+ SourceControlHostFieldsForm,
30
+ SourceControlTokenForm,
31
+ sourceControlProviderSummary,
32
+} from "./components/SourceControlProvidersSection";
33
+import { AppSignInRow } from "./components/SourceControlSignInSection";
34
+import type { SettingsTarget } from "./settings-environment-filter";
35
+
36
+/** The environment a detail page edits, once it is connected, and whether this session may. */
37
+function useDetailEnvironment(environmentId: EnvironmentId) {
38
+ const { environments } = useEnvironments();
39
+ const environment = environments.find(
40
+ (entry): entry is SettingsTarget =>
41
+ entry.environmentId === environmentId &&
42
+ entry.connection.phase === "connected" &&
43
+ entry.serverConfig !== null,
44
+ );
45
+ const writable = useEnvironmentsWithScope(
46
+ environment ? [environment] : [],
47
+ AuthSettingsWriteScope,
48
+ );
49
+ return { environment, canWrite: writable.has(environmentId) };
50
+}
51
+
52
+function DetailPage(props: { readonly title: string; readonly children: ReactNode }) {
53
+ const insets = useSafeAreaInsets();
54
+ return (
55
+ <SettingsScreen title={props.title}>
56
+ <ScrollView
57
+ contentInsetAdjustmentBehavior="automatic"
58
+ showsVerticalScrollIndicator={false}
59
+ keyboardShouldPersistTaps="handled"
60
+ className="flex-1"
61
+ contentContainerClassName="gap-6 px-5 pt-4"
62
+ contentContainerStyle={{ paddingBottom: Math.max(insets.bottom, 18) + 18 }}
63
+ >
64
+ {props.children}
65
+ </ScrollView>
66
+ </SettingsScreen>
67
+ );
68
+}
69
+
70
+const Unavailable = () => (
71
+ <Text className="px-2 text-base text-foreground-muted">
72
+ Connect this environment to change its settings.
73
+ </Text>
74
+);
75
+
76
+export function SettingsSourceControlProviderRouteScreen({
77
+ route,
78
+}: StaticScreenProps<{
79
+ readonly environmentId: EnvironmentId;
80
+ readonly kind: SourceControlProviderKind;
81
+}>) {
82
+ const { environmentId, kind } = route.params;
83
+ const { environment, canWrite } = useDetailEnvironment(environmentId);
84
+ const definition = sourceControlClients.find(kind);
85
+ const discovery = useEnvironmentQuery(
86
+ sourceControlEnvironment.discovery({ environmentId, input: {} }),
87
+ );
88
+ const canUpdate = useAtomValue(serverEnvironment.updateSettings.permissionAtom(environmentId));
89
+ const item = discovery.data?.sourceControlProviders.find((entry) => entry.kind === kind);
90
+ const credentials = definition?.credentials;
91
+ const appSignIn = item?.appSignIn === true ? credentials?.appSignIn : undefined;
92
+ const disabled = !canWrite || !canUpdate;
93
+ return (
94
+ <DetailPage title={definition?.label ?? "Provider"}>
95
+ {!environment || !definition ? (
96
+ <Unavailable />
97
+ ) : (
98
+ <>
99
+ {item ? (
100
+ <Text selectable className="px-2 text-sm text-foreground-muted">
101
+ {[Option.getOrNull(item.version), sourceControlProviderSummary(item)]
102
+ .filter(Boolean)
103
+ .join(" · ")}
104
+ </Text>
105
+ ) : null}
106
+ {appSignIn ? (
107
+ <SettingsSection
108
+ title="Sign in"
109
+ footer="A far higher API rate limit than a personal token or CLI login."
110
+ >
111
+ <AppSignInRow
112
+ environment={environment}
113
+ label={appSignIn.appName}
114
+ definition={definition}
115
+ appSignIn={appSignIn}
116
+ disabled={disabled}
117
+ />
118
+ </SettingsSection>
119
+ ) : null}
120
+ {!credentials && definition.settings ? (
121
+ <SettingsSection title="Credentials">
122
+ <SourceControlHostFieldsForm
123
+ environment={environment}
124
+ definition={definition}
125
+ settings={definition.settings}
126
+ disabled={disabled}
127
+ onSaved={discovery.refresh}
128
+ />
129
+ </SettingsSection>
130
+ ) : null}
131
+ {credentials ? (
132
+ <SettingsSection title={appSignIn ? "Or use your own credentials" : "Token"}>
133
+ <SourceControlTokenForm
134
+ environment={environment}
135
+ definition={definition}
136
+ credentials={credentials}
137
+ disabled={disabled}
138
+ onSaved={discovery.refresh}
139
+ />
140
+ </SettingsSection>
141
+ ) : null}
142
+ </>
143
+ )}
144
+ </DetailPage>
145
+ );
146
+}
147
+
148
+export function SettingsIssueTrackerRouteScreen({
149
+ route,
150
+}: StaticScreenProps<{
151
+ readonly environmentId: EnvironmentId;
152
+ readonly tracker: string;
153
+}>) {
154
+ const { environmentId } = route.params;
155
+ const { environment, canWrite } = useDetailEnvironment(environmentId);
156
+ const query = useEnvironmentQuery(
157
+ issueTrackerEnvironment.connections({ environmentId, input: {} }),
158
+ );
159
+ const canEdit = useAtomValue(issueTrackerEnvironment.connect.permissionAtom(environmentId));
160
+ const tracker = query.data?.trackers.find((entry) => entry.tracker === route.params.tracker);
161
+ const disabled = !canWrite || !canEdit;
162
+ const usable = tracker?.connected === true && tracker.account !== null;
163
+ return (
164
+ <DetailPage title={tracker?.displayName ?? "Issue tracker"}>
165
+ {!environment || !tracker ? (
166
+ <Unavailable />
167
+ ) : (
168
+ <>
169
+ <Text selectable className="px-2 text-sm text-foreground-muted">
170
+ {issueTrackerSummary(tracker, query.data?.bindings ?? {})}
171
+ </Text>
172
+ <SettingsSection title={tracker.credential.label}>
173
+ <IssueTrackerCredentialForm
174
+ environmentId={environmentId}
175
+ tracker={tracker}
176
+ disabled={disabled}
177
+ />
178
+ </SettingsSection>
179
+ {usable && tracker.scopes.length > 0 ? (
180
+ <SettingsSection
181
+ title="Projects"
182
+ footer={`Pick the ${tracker.displayName} ${tracker.scopeNoun} whose issues each project lists beside its repository's own.`}
183
+ >
184
+ <IssueTrackerProjectRows
185
+ environmentId={environmentId}
186
+ tracker={tracker}
187
+ bindings={query.data?.bindings ?? {}}
188
+ disabled={disabled}
189
+ />
190
+ </SettingsSection>
191
+ ) : null}
192
+ </>
193
+ )}
194
+ </DetailPage>
195
+ );
196
+}
apps/mobile/src/features/settings/components/IssueTrackerSection.tsx
new
+260
@@ -0,0 +1,260 @@
1
+import { issueTrackerSummary } from "@t3tools/client-runtime/state/issue-trackers";
2
+import { squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime";
3
+import type {
4
+ EnvironmentId,
5
+ IssueTrackerConnection,
6
+ IssueTrackerConnectionList,
7
+ ProjectId,
8
+} from "@t3tools/contracts";
9
+import { AsyncResult } from "effect/reactivity";
10
+import { useNavigation } from "@react-navigation/native";
11
+import { useState } from "react";
12
+import { Linking, Platform, View } from "react-native";
13
+import Svg, { Path } from "react-native-svg";
14
+import { withUniwind } from "uniwind";
15
+
16
+import { SymbolView } from "../../../components/ui/AppSymbol";
17
+import { AppText as Text } from "../../../components/ui/AppText";
18
+import { Button } from "../../../components/ui/Button";
19
+import { Menu } from "../../../components/ui/Menu";
20
+import { SecretTextInput } from "../../../components/ui/SecretTextInput";
21
+import { useProjects } from "../../../state/entities";
22
+import { issueTrackerEnvironment } from "../../../state/issueTrackers";
23
+import { useEnvironmentQuery } from "../../../state/query";
24
+import { useAtomCommand } from "../../../state/use-atom-command";
25
+import type { SettingsTarget } from "../settings-environment-filter";
26
+import { SettingsProviderRow } from "./SettingsProviderRow";
27
+import { SettingsRow } from "./SettingsRow";
28
+import { SettingsSection } from "./SettingsSection";
29
+
30
+const UNBOUND = "";
31
+const ThemedSvg = withUniwind(Svg);
32
+const ICON_SIZE = Platform.OS === "android" ? 20 : 18;
33
+
34
+/** Art per tracker kind; the server supplies everything else about a tracker. */
35
+const TRACKER_MARKS: Partial<Record<string, string>> = {
36
+ linear:
37
+ "M1.225 61.523c-.222-.949.908-1.546 1.597-.857l36.512 36.512c.69.69.092 1.82-.857 1.597C20.15 94.612 5.388 79.85 1.225 61.523ZM.002 46.889a.99.99 0 0 0 .29.76l52.062 52.061a.99.99 0 0 0 .76.29c2.765-.169 5.47-.559 8.1-1.152.75-.169 1.014-1.084.47-1.63L2.784 38.32c-.545-.545-1.46-.28-1.63.47A50.229 50.229 0 0 0 .002 46.89ZM4.472 29.34a.99.99 0 0 0 .208 1.104l64.878 64.877a.99.99 0 0 0 1.104.208 50.293 50.293 0 0 0 5.807-3.132.99.99 0 0 0 .154-1.53L9.135 23.38a.99.99 0 0 0-1.53.154 50.29 50.29 0 0 0-3.132 5.807ZM12.293 18.229c-.309-.309-.334-.803-.045-1.13C21.376 6.626 34.637 0 49.45 0 76.869 0 99.1 22.231 99.1 49.65c0 14.813-6.626 28.074-17.099 37.202-.327.29-.821.264-1.13-.045L12.293 18.23Z",
38
+};
39
+
40
+/**
41
+ * Standalone issue trackers, such as Linear, for each selected environment: connect one with a
42
+ * credential, then pick which of its scopes each project lists beside its repository's issues.
43
+ */
44
+export function IssueTrackerSection(props: { readonly environments: readonly SettingsTarget[] }) {
45
+ return (
46
+ <>
47
+ {props.environments.map((environment) =>
48
+ environment.serverConfig.environment.capabilities.issues === true ? (
49
+ <EnvironmentTrackers
50
+ key={environment.environmentId}
51
+ environment={environment}
52
+ title={
53
+ props.environments.length > 1
54
+ ? `Issue trackers · ${environment.label}`
55
+ : "Issue trackers"
56
+ }
57
+ />
58
+ ) : null,
59
+ )}
60
+ </>
61
+ );
62
+}
63
+
64
+function EnvironmentTrackers(props: {
65
+ readonly environment: SettingsTarget;
66
+ readonly title: string;
67
+}) {
68
+ const navigation = useNavigation();
69
+ const { environmentId } = props.environment;
70
+ const query = useEnvironmentQuery(
71
+ issueTrackerEnvironment.connections({ environmentId, input: {} }),
72
+ );
73
+ const trackers = query.data?.trackers ?? [];
74
+ if (trackers.length === 0) {
75
+ return query.error ? (
76
+ <SettingsSection title={props.title} footer={query.error}>
77
+ <View className="p-4">
78
+ <Button label="Try again" tone="secondary" onPress={query.refresh} />
79
+ </View>
80
+ </SettingsSection>
81
+ ) : null;
82
+ }
83
+ return (
84
+ <SettingsSection title={props.title}>
85
+ {trackers.map((tracker, index) => (
86
+ <SettingsProviderRow
87
+ key={tracker.tracker}
88
+ icon={<IssueTrackerMark tracker={tracker.tracker} />}
89
+ label={tracker.displayName}
90
+ description={issueTrackerSummary(tracker, query.data?.bindings ?? {})}
91
+ ready={tracker.connected && tracker.account !== null}
92
+ separated={index > 0}
93
+ onPress={() =>
94
+ navigation.navigate("SettingsIssueTracker", {
95
+ environmentId,
96
+ tracker: tracker.tracker,
97
+ })
98
+ }
99
+ />
100
+ ))}
101
+ </SettingsSection>
102
+ );
103
+}
104
+
105
+export function IssueTrackerMark(props: { readonly tracker: string }) {
106
+ const mark = TRACKER_MARKS[props.tracker];
107
+ return mark ? (
108
+ <ThemedSvg
109
+ width={ICON_SIZE}
110
+ height={ICON_SIZE}
111
+ viewBox="0 0 100 100"
112
+ colorClassName="accent-icon"
113
+ >
114
+ <Path fill="currentColor" d={mark} />
115
+ </ThemedSvg>
116
+ ) : (
117
+ <SymbolView name="circle.dashed" size={ICON_SIZE} tintColorClassName="accent-icon" />
118
+ );
119
+}
120
+
121
+/** The credential field for one tracker, with what replaces, removes or creates it. */
122
+export function IssueTrackerCredentialForm(props: {
123
+ readonly environmentId: EnvironmentId;
124
+ readonly tracker: IssueTrackerConnection;
125
+ readonly disabled: boolean;
126
+}) {
127
+ const { environmentId, tracker } = props;
128
+ const connect = useAtomCommand(issueTrackerEnvironment.connect, { reportFailure: false });
129
+ const [draft, setDraft] = useState("");
130
+ const [busy, setBusy] = useState(false);
131
+ const [failure, setFailure] = useState<string | null>(null);
132
+ const submit = async (token: string | null) => {
133
+ setBusy(true);
134
+ setFailure(null);
135
+ const result = await connect({ environmentId, input: { tracker: tracker.tracker, token } });
136
+ setBusy(false);
137
+ if (!AsyncResult.isFailure(result)) {
138
+ setDraft("");
139
+ return;
140
+ }
141
+ const error = squashAtomCommandFailure(result);
142
+ setFailure(error instanceof Error ? error.message : "The request failed.");
143
+ };
144
+ const helpUrl = tracker.credential.helpUrl;
145
+ const locked = props.disabled || busy;
146
+ return (
147
+ <View className="gap-3 p-4">
148
+ <SecretTextInput
149
+ accessibilityLabel={tracker.credential.label}
150
+ placeholder={
151
+ tracker.connected ? "Saved. Enter a new value to replace it" : tracker.credential.label
152
+ }
153
+ value={draft}
154
+ onChangeText={setDraft}
155
+ onSubmitEditing={(value) => {
156
+ if (value.trim()) void submit(value.trim());
157
+ }}
158
+ editable={!locked}
159
+ />
160
+ {failure ? (
161
+ <Text selectable className="text-xs text-danger-foreground">
162
+ {failure}
163
+ </Text>
164
+ ) : null}
165
+ <View className="flex-row flex-wrap justify-end gap-2">
166
+ {helpUrl ? (
167
+ <Button
168
+ label="Create one"
169
+ tone="text"
170
+ size="compact"
171
+ onPress={() => void Linking.openURL(helpUrl).catch(() => undefined)}
172
+ />
173
+ ) : null}
174
+ {tracker.connected ? (
175
+ <Button
176
+ label="Disconnect"
177
+ tone="secondary"
178
+ size="compact"
179
+ disabled={locked}
180
+ onPress={() => void submit(null)}
181
+ />
182
+ ) : null}
183
+ <Button
184
+ label={tracker.connected ? "Replace" : "Connect"}
185
+ tone="primary"
186
+ size="compact"
187
+ loading={busy}
188
+ disabled={locked || !draft.trim()}
189
+ onPress={() => void submit(draft.trim())}
190
+ />
191
+ </View>
192
+ </View>
193
+ );
194
+}
195
+
196
+/** One row per project of the environment: which of the tracker's scopes it reads, if any. */
197
+export function IssueTrackerProjectRows(props: {
198
+ readonly environmentId: EnvironmentId;
199
+ readonly tracker: IssueTrackerConnection;
200
+ readonly bindings: IssueTrackerConnectionList["bindings"];
201
+ readonly disabled: boolean;
202
+}) {
203
+ const { environmentId, tracker } = props;
204
+ const bind = useAtomCommand(issueTrackerEnvironment.bindProject, {
205
+ label: `bind project to ${tracker.displayName}`,
206
+ });
207
+ const projects = useProjects().filter((project) => project.environmentId === environmentId);
208
+ const [binding, setBinding] = useState<ProjectId | null>(null);
209
+ const change = async (projectId: ProjectId, scope: string) => {
210
+ if (props.disabled || binding !== null) return;
211
+ setBinding(projectId);
212
+ await bind({
213
+ environmentId,
214
+ input: {
215
+ projectId,
216
+ binding: scope === UNBOUND ? null : { tracker: tracker.tracker, scope },
217
+ },
218
+ });
219
+ setBinding(null);
220
+ };
221
+ return projects.map((project) => {
222
+ const bound = props.bindings[project.id];
223
+ // A project bound to another tracker keeps that binding; this row shows it unbound.
224
+ const value = bound?.tracker === tracker.tracker ? bound.scope : UNBOUND;
225
+ const locked = props.disabled || binding !== null;
226
+ return (
227
+ <Menu
228
+ key={project.id}
229
+ title={`${tracker.displayName} ${tracker.scopeNoun} for ${project.title}`}
230
+ actions={[
231
+ {
232
+ id: UNBOUND,
233
+ title: "Not bound",
234
+ state: value === UNBOUND ? "on" : "off",
235
+ attributes: { disabled: locked },
236
+ },
237
+ ...tracker.scopes.map((scope) => ({
238
+ id: scope.key,
239
+ title: `${scope.name} (${scope.key})`,
240
+ state: scope.key === value ? ("on" as const) : ("off" as const),
241
+ attributes: { disabled: locked },
242
+ })),
243
+ ]}
244
+ onPressAction={({ nativeEvent }) => void change(project.id, nativeEvent.event)}
245
+ >
246
+ <SettingsRow
247
+ icon="folder"
248
+ label={project.title}
249
+ valuePosition="trailing"
250
+ value={
251
+ value === UNBOUND
252
+ ? "Not bound"
253
+ : (tracker.scopes.find((scope) => scope.key === value)?.name ?? value)
254
+ }
255
+ disabled={locked}
256
+ />
257
+ </Menu>
258
+ );
259
+ });
260
+}
apps/mobile/src/features/settings/components/SettingsProviderRow.tsx
new
+106
@@ -0,0 +1,106 @@
1
+import type { ReactNode } from "react";
2
+import { Pressable, View } from "react-native";
3
+
4
+import { SymbolView } from "../../../components/ui/AppSymbol";
5
+import { AppText as Text } from "../../../components/ui/AppText";
6
+import { ThemedSwitch } from "../../../components/ui/ThemedSwitch";
7
+import { cn } from "../../../lib/cn";
8
+import { ConnectionStatusDot } from "../../connection/ConnectionStatusDot";
9
+
10
+/**
11
+ * One integration in a settings list: its mark with a status dot, what state it is in, an
12
+ * optional switch, and its own page behind the row. The layout of the Environments list's rows.
13
+ */
14
+export function SettingsProviderRow(props: {
15
+ readonly icon: ReactNode;
16
+ readonly label: string;
17
+ readonly detail?: string | null;
18
+ readonly description: string;
19
+ readonly ready: boolean;
20
+ readonly separated: boolean;
21
+ /** Opens the integration's page; a row without one only reports. */
22
+ readonly onPress?: () => void;
23
+ readonly toggle?: {
24
+ readonly accessibilityLabel: string;
25
+ readonly value: boolean;
26
+ readonly disabled: boolean;
27
+ readonly onValueChange: (value: boolean) => void;
28
+ };
29
+}) {
30
+ const summary = (
31
+ <View className="min-w-0 flex-1 gap-0.5">
32
+ <View className="flex-row items-center gap-2 overflow-hidden">
33
+ <View className="size-5 items-center justify-center">
34
+ {props.icon}
35
+ <View className="absolute -top-1 -left-1">
36
+ <ConnectionStatusDot
37
+ state={props.ready ? "connected" : "available"}
38
+ pulse={false}
39
+ size={7}
40
+ />
41
+ </View>
42
+ </View>
43
+ <Text className="shrink-0 text-base font-t3-bold leading-snug text-foreground">
44
+ {props.label}
45
+ </Text>
46
+ {props.detail ? (
47
+ <Text
48
+ className="min-w-0 shrink font-mono text-xs text-foreground-muted"
49
+ numberOfLines={1}
50
+ >
51
+ {props.detail}
52
+ </Text>
53
+ ) : null}
54
+ </View>
55
+ <Text className="text-xs text-foreground-muted" numberOfLines={2}>
56
+ {props.description}
57
+ </Text>
58
+ </View>
59
+ );
60
+ return (
61
+ <View
62
+ className={cn(
63
+ "flex-row items-center gap-3 bg-grouped-card px-4 py-3.5",
64
+ props.separated && "border-t border-border-subtle",
65
+ )}
66
+ >
67
+ {props.onPress ? (
68
+ <Pressable
69
+ className="min-w-0 flex-1 active:opacity-70"
70
+ accessibilityRole="button"
71
+ accessibilityLabel={`Manage ${props.label}`}
72
+ accessibilityHint={props.description}
73
+ onPress={props.onPress}
74
+ >
75
+ {summary}
76
+ </Pressable>
77
+ ) : (
78
+ summary
79
+ )}
80
+ {props.toggle ? (
81
+ <ThemedSwitch
82
+ accessibilityLabel={props.toggle.accessibilityLabel}
83
+ style={{ alignSelf: "center" }}
84
+ disabled={props.toggle.disabled}
85
+ onValueChange={props.toggle.onValueChange}
86
+ value={props.toggle.value}
87
+ />
88
+ ) : null}
89
+ {props.onPress ? (
90
+ <Pressable
91
+ accessibilityElementsHidden
92
+ importantForAccessibility="no-hide-descendants"
93
+ onPress={props.onPress}
94
+ style={{ minWidth: 24, minHeight: 44, alignItems: "center", justifyContent: "center" }}
95
+ >
96
+ <SymbolView
97
+ name="chevron.right"
98
+ size={12}
99
+ tintColorClassName="accent-icon-subtle"
100
+ type="monochrome"
101
+ />
102
+ </Pressable>
103
+ ) : null}
104
+ </View>
105
+ );
106
+}
apps/mobile/src/features/settings/components/SourceControlProvidersSection.tsx
new
+420
@@ -0,0 +1,420 @@
1
+import { useAtomValue } from "@effect/atom-react";
2
+import { isSourceControlProviderOffered } from "@t3tools/client-runtime/operations/projects";
3
+import { squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime";
4
+import {
5
+ readHostCredentialSettings,
6
+ sourceControlClients,
7
+ type SourceControlDefinition,
8
+ type SourceControlHostCredentials,
9
+} from "@t3tools/client-runtime/source-control-clients";
10
+import type {
11
+ EnvironmentId,
12
+ SettingsSecretValue,
13
+ SourceControlProviderDiscoveryItem,
14
+} from "@t3tools/contracts";
15
+import * as Option from "effect/Option";
16
+import * as Schema from "effect/Schema";
17
+import { useNavigation } from "@react-navigation/native";
18
+import { useState } from "react";
19
+import { Linking, Platform, View } from "react-native";
20
+
21
+import { AppText as Text } from "../../../components/ui/AppText";
22
+import { Button } from "../../../components/ui/Button";
23
+import { SecretTextInput } from "../../../components/ui/SecretTextInput";
24
+import { useEnvironmentQuery } from "../../../state/query";
25
+import { serverEnvironment } from "../../../state/server";
26
+import { sourceControlEnvironment } from "../../../state/sourceControl";
27
+import { useAtomCommand } from "../../../state/use-atom-command";
28
+import { ConnectionFormField } from "../../connection/ConnectionFormField";
29
+import { SourceControlIcon } from "../../projects/SourceControlIcon";
30
+import type { SettingsTarget } from "../settings-environment-filter";
31
+import { SettingsProviderRow } from "./SettingsProviderRow";
32
+import { SettingsSection } from "./SettingsSection";
33
+
34
+const saveFailure = (result: Parameters<typeof squashAtomCommandFailure>[0]) => {
35
+ const error = squashAtomCommandFailure(result);
36
+ return error instanceof Error ? error.message : "The settings could not be saved.";
37
+};
38
+
39
+const hasToken = (token: SettingsSecretValue | undefined) =>
40
+ typeof token === "string" ? token.length > 0 : token !== undefined;
41
+
42
+export const sourceControlProviderReady = (item: SourceControlProviderDiscoveryItem) =>
43
+ item.status === "available" && item.auth.status === "authenticated";
44
+
45
+/** The line under a provider's name: whether it works on this server, and what to do if not. */
46
+export function sourceControlProviderSummary(item: SourceControlProviderDiscoveryItem): string {
47
+ if (item.status !== "available") return `Not available on this server: ${item.installHint}`;
48
+ const { auth } = item;
49
+ const detail = Option.getOrNull(auth.detail);
50
+ if (auth.status === "authenticated") {
51
+ const account = Option.getOrNull(auth.account);
52
+ return ["Authenticated", account ? `as ${account}` : null, detail ? `· ${detail}` : null]
53
+ .filter(Boolean)
54
+ .join(" ");
55
+ }
56
+ if (auth.status === "unauthenticated") {
57
+ if (!item.executable) return `Available. ${item.installHint}`;
58
+ if (auth.accounts?.some((entry) => entry.authenticated))
59
+ return detail ?? `Every ${item.label} host is turned off.`;
60
+ return `Not authenticated on this server. Sign in with the ${item.executable} tool on the server host, or save a token here.`;
61
+ }
62
+ return `Could not verify ${item.label}. ${detail ?? item.installHint}`;
63
+}
64
+
65
+/**
66
+ * Every hosting integration each selected environment knows: whether it works there, whether
67
+ * the project pickers offer it, and its credentials where the app can set them.
68
+ */
69
+export function SourceControlProvidersSection(props: {
70
+ readonly environments: readonly SettingsTarget[];
71
+ readonly canWrite: (environmentId: EnvironmentId) => boolean;
72
+}) {
73
+ return (
74
+ <>
75
+ {props.environments.map((environment) => (
76
+ <EnvironmentProviders
77
+ key={environment.environmentId}
78
+ environment={environment}
79
+ title={
80
+ props.environments.length > 1
81
+ ? `Source control providers · ${environment.label}`
82
+ : "Source control providers"
83
+ }
84
+ disabled={!props.canWrite(environment.environmentId)}
85
+ />
86
+ ))}
87
+ </>
88
+ );
89
+}
90
+
91
+function EnvironmentProviders(props: {
92
+ readonly environment: SettingsTarget;
93
+ readonly title: string;
94
+ readonly disabled: boolean;
95
+}) {
96
+ const { environment } = props;
97
+ const { environmentId } = environment;
98
+ const discovery = useEnvironmentQuery(
99
+ sourceControlEnvironment.discovery({ environmentId, input: {} }),
100
+ );
101
+ const canUpdate = useAtomValue(serverEnvironment.updateSettings.permissionAtom(environmentId));
102
+ const updateSettings = useAtomCommand(serverEnvironment.updateSettings, {
103
+ label: "save source control providers",
104
+ });
105
+ const navigation = useNavigation();
106
+ const items = discovery.data?.sourceControlProviders ?? [];
107
+ const offered = environment.serverConfig.settings.offeredSourceControlProviders;
108
+ const disabled = props.disabled || !canUpdate;
109
+ if (items.length === 0) {
110
+ return discovery.error ? (
111
+ <SettingsSection title={props.title} footer={discovery.error}>
112
+ <View className="p-4">
113
+ <Button label="Scan again" tone="secondary" onPress={discovery.refresh} />
114
+ </View>
115
+ </SettingsSection>
116
+ ) : null;
117
+ }
118
+ return (
119
+ <SettingsSection title={props.title}>
120
+ {items.map((item, index) => {
121
+ const definition = sourceControlClients.find(item.kind);
122
+ return (
123
+ <SettingsProviderRow
124
+ key={item.kind}
125
+ icon={
126
+ <SourceControlIcon
127
+ icon={definition?.icon ?? null}
128
+ size={Platform.OS === "android" ? 20 : 18}
129
+ colorClassName="accent-icon"
130
+ />
131
+ }
132
+ label={item.label}
133
+ detail={Option.getOrNull(item.version)}
134
+ description={sourceControlProviderSummary(item)}
135
+ ready={sourceControlProviderReady(item)}
136
+ separated={index > 0}
137
+ {...(definition?.credentials || definition?.settings
138
+ ? {
139
+ onPress: () =>
140
+ navigation.navigate("SettingsSourceControlProvider", {
141
+ environmentId,
142
+ kind: item.kind,
143
+ }),
144
+ }
145
+ : {})}
146
+ toggle={{
147
+ accessibilityLabel: `Offer ${item.label} when adding or publishing a project`,
148
+ value: isSourceControlProviderOffered(offered, item.kind),
149
+ disabled,
150
+ onValueChange: (value) =>
151
+ void updateSettings({
152
+ environmentId,
153
+ input: { patch: { offeredSourceControlProviders: { [item.kind]: value } } },
154
+ }),
155
+ }}
156
+ />
157
+ );
158
+ })}
159
+ </SettingsSection>
160
+ );
161
+}
162
+
163
+export function SourceControlTokenForm(props: {
164
+ readonly environment: SettingsTarget;
165
+ readonly definition: SourceControlDefinition;
166
+ readonly credentials: SourceControlHostCredentials;
167
+ readonly disabled: boolean;
168
+ readonly onSaved: () => void;
169
+}) {
170
+ const { definition, credentials } = props;
171
+ const { environmentId } = props.environment;
172
+ const { tokens } = readHostCredentialSettings(
173
+ props.environment.serverConfig.settings,
174
+ definition.kind,
175
+ );
176
+ const updateSettings = useAtomCommand(serverEnvironment.updateSettings, {
177
+ label: `save ${definition.label} token`,
178
+ });
179
+ const defaultHost = definition.publicHost ?? "";
180
+ const [host, setHost] = useState(defaultHost);
181
+ const [draft, setDraft] = useState("");
182
+ const [saving, setSaving] = useState(false);
183
+ const [failure, setFailure] = useState<string | null>(null);
184
+ const target = host.trim().toLowerCase();
185
+ const saved = hasToken(tokens[target]);
186
+ const savedHosts = Object.entries(tokens)
187
+ .filter(([, value]) => hasToken(value))
188
+ .map(([name]) => name);
189
+
190
+ const save = async (token: string) => {
191
+ if (!target) return;
192
+ setSaving(true);
193
+ setFailure(null);
194
+ const result = await updateSettings({
195
+ environmentId,
196
+ // Send the whole map; other tokens' redaction markers preserve their values.
197
+ input: {
198
+ patch: {
199
+ sourceControlHosts: { [definition.kind]: { tokens: { ...tokens, [target]: token } } },
200
+ },
201
+ },
202
+ });
203
+ setSaving(false);
204
+ if (result._tag !== "Success") {
205
+ setFailure(saveFailure(result));
206
+ return;
207
+ }
208
+ setDraft("");
209
+ props.onSaved();
210
+ };
211
+ const locked = props.disabled || saving;
212
+ return (
213
+ <View className="gap-3 p-4">
214
+ <Text className="text-xs leading-relaxed text-foreground-muted">
215
+ {`A token saved here is used before ${credentials.tokenEnvVar} and the ${credentials.cliName} login, so ${definition.label} works without the ${credentials.cliLabel}. Give it ${credentials.tokenAccess}.`}
216
+ </Text>
217
+ <ConnectionFormField
218
+ label="Host"
219
+ autoCapitalize="none"
220
+ autoCorrect={false}
221
+ keyboardType="url"
222
+ placeholder={defaultHost}
223
+ editable={!locked}
224
+ value={host}
225
+ onChangeText={setHost}
226
+ />
227
+ <SecretTextInput
228
+ accessibilityLabel={`${definition.label} token`}
229
+ placeholder={saved ? "Saved. Enter a new token to replace it" : "Token"}
230
+ value={draft}
231
+ onChangeText={setDraft}
232
+ onSubmitEditing={(value) => {
233
+ if (value.trim()) void save(value.trim());
234
+ }}
235
+ editable={!locked}
236
+ />
237
+ <Text className="text-xs text-foreground-muted">
238
+ {savedHosts.length === 0
239
+ ? `No token saved; the server uses ${credentials.tokenEnvVar} or the ${credentials.cliName} login.`
240
+ : `Saved for ${savedHosts.join(", ")}.`}
241
+ </Text>
242
+ {failure ? (
243
+ <Text selectable className="text-xs text-danger-foreground">
244
+ {failure}
245
+ </Text>
246
+ ) : null}
247
+ <View className="flex-row flex-wrap justify-end gap-2">
248
+ {target || defaultHost ? (
249
+ <Button
250
+ label="Create a token"
251
+ tone="text"
252
+ size="compact"
253
+ onPress={() =>
254
+ void Linking.openURL(credentials.newTokenUrl(target || defaultHost)).catch(
255
+ () => undefined,
256
+ )
257
+ }
258
+ />
259
+ ) : null}
260
+ {saved ? (
261
+ <Button
262
+ label="Remove"
263
+ tone="secondary"
264
+ size="compact"
265
+ disabled={locked}
266
+ onPress={() => void save("")}
267
+ />
268
+ ) : null}
269
+ <Button
270
+ label="Save"
271
+ tone="primary"
272
+ size="compact"
273
+ loading={saving}
274
+ disabled={locked || !target || !draft.trim()}
275
+ onPress={() => void save(draft.trim())}
276
+ />
277
+ </View>
278
+ </View>
279
+ );
280
+}
281
+
282
+type HostSettings = NonNullable<SourceControlDefinition["settings"]>;
283
+
284
+/** The fields a host declares, in its own order, with what its schema says about each. */
285
+function hostSettingsFields(settings: HostSettings) {
286
+ const order = Schema.resolveAnnotations(settings)?.providerSettingsFormSchema?.order ?? [];
287
+ const position = (key: string) => (order.includes(key) ? order.indexOf(key) : order.length);
288
+ return Object.keys(settings.fields)
289
+ .sort((left, right) => position(left) - position(right))
290
+ .flatMap((key) => {
291
+ const field = settings.fields[key]!;
292
+ const annotations = Schema.resolveAnnotationsKey(field) ?? Schema.resolveAnnotations(field);
293
+ const form = annotations?.providerSettingsForm ?? {};
294
+ if (form.hidden) return [];
295
+ return [
296
+ {
297
+ key,
298
+ label: typeof annotations?.title === "string" ? annotations.title : key,
299
+ description:
300
+ typeof annotations?.description === "string" ? annotations.description : undefined,
301
+ placeholder: form.placeholder,
302
+ secret: form.control === "password",
303
+ },
304
+ ];
305
+ });
306
+}
307
+
308
+/** Credentials for a host that names its own fields rather than one token per host. */
309
+export function SourceControlHostFieldsForm(props: {
310
+ readonly environment: SettingsTarget;
311
+ readonly definition: SourceControlDefinition;
312
+ readonly settings: HostSettings;
313
+ readonly disabled: boolean;
314
+ readonly onSaved: () => void;
315
+}) {
316
+ const { definition } = props;
317
+ const { environmentId } = props.environment;
318
+ const saved: Readonly<Record<string, unknown>> =
319
+ props.environment.serverConfig.settings.sourceControlHosts[definition.kind] ?? {};
320
+ const updateSettings = useAtomCommand(serverEnvironment.updateSettings, {
321
+ label: `save ${definition.label} settings`,
322
+ });
323
+ const [drafts, setDrafts] = useState<Readonly<Record<string, string>>>({});
324
+ const [saving, setSaving] = useState(false);
325
+ const [failure, setFailure] = useState<string | null>(null);
326
+ const fields = hostSettingsFields(props.settings);
327
+ const isSet = (key: string) => {
328
+ const value = saved[key];
329
+ return typeof value === "string" ? value.length > 0 : value !== undefined;
330
+ };
331
+ const changed = Object.fromEntries(
332
+ Object.entries(drafts).flatMap(([key, value]) => (value.trim() ? [[key, value.trim()]] : [])),
333
+ );
334
+ const save = async (patch: Record<string, string>) => {
335
+ setSaving(true);
336
+ setFailure(null);
337
+ const result = await updateSettings({
338
+ environmentId,
339
+ input: { patch: { sourceControlHosts: { [definition.kind]: patch } } },
340
+ });
341
+ setSaving(false);
342
+ if (result._tag !== "Success") {
343
+ setFailure(saveFailure(result));
344
+ return;
345
+ }
346
+ setDrafts({});
347
+ props.onSaved();
348
+ };
349
+ const locked = props.disabled || saving;
350
+ const submit = () => {
351
+ if (Object.keys(changed).length > 0) void save(changed);
352
+ };
353
+ return (
354
+ <View className="gap-4 p-4">
355
+ {fields.map((field) => (
356
+ <View key={field.key} className="gap-1.5">
357
+ {field.secret ? (
358
+ <>
359
+ <Text className="text-2xs font-t3-bold tracking-[0.8px] uppercase text-foreground-muted">
360
+ {field.label}
361
+ </Text>
362
+ <SecretTextInput
363
+ accessibilityLabel={field.label}
364
+ placeholder={
365
+ isSet(field.key) ? "Saved. Enter a new value to replace it" : field.label
366
+ }
367
+ value={drafts[field.key] ?? ""}
368
+ onChangeText={(value) => setDrafts({ ...drafts, [field.key]: value })}
369
+ onSubmitEditing={submit}
370
+ editable={!locked}
371
+ />
372
+ </>
373
+ ) : (
374
+ <ConnectionFormField
375
+ label={field.label}
376
+ autoCapitalize="none"
377
+ autoCorrect={false}
378
+ placeholder={
379
+ typeof saved[field.key] === "string" && saved[field.key] !== ""
380
+ ? String(saved[field.key])
381
+ : field.placeholder
382
+ }
383
+ editable={!locked}
384
+ value={drafts[field.key] ?? ""}
385
+ onChangeText={(value) => setDrafts({ ...drafts, [field.key]: value })}
386
+ onSubmitEditing={submit}
387
+ />
388
+ )}
389
+ {field.description ? (
390
+ <Text className="text-xs text-foreground-muted">{field.description}</Text>
391
+ ) : null}
392
+ </View>
393
+ ))}
394
+ {failure ? (
395
+ <Text selectable className="text-xs text-danger-foreground">
396
+ {failure}
397
+ </Text>
398
+ ) : null}
399
+ <View className="flex-row flex-wrap justify-end gap-2">
400
+ {fields.some((field) => isSet(field.key)) ? (
401
+ <Button
402
+ label="Remove"
403
+ tone="secondary"
404
+ size="compact"
405
+ disabled={locked}
406
+ onPress={() => void save(Object.fromEntries(fields.map((field) => [field.key, ""])))}
407
+ />
408
+ ) : null}
409
+ <Button
410
+ label="Save"
411
+ tone="primary"
412
+ size="compact"
413
+ loading={saving}
414
+ disabled={locked || Object.keys(changed).length === 0}
415
+ onPress={submit}
416
+ />
417
+ </View>
418
+ </View>
419
+ );
420
+}
apps/mobile/src/features/settings/components/SourceControlSignInSection.tsx
+3
-71
@@ -1,7 +1,6 @@
1
-import type { EnvironmentId, SourceControlSignInPrompt } from "@t3tools/contracts";
1
+import type { SourceControlSignInPrompt } from "@t3tools/contracts";
2
import {
3
readHostCredentialSettings,
4
- sourceControlClients,
4
type SourceControlAppSignIn,
5
type SourceControlDefinition,
6
} from "@t3tools/client-runtime/source-control-clients";
@@ -11,13 +10,11 @@ import { useRef, useState } from "react";
10
import { Linking } from "react-native";
11
12
import * as Dialog from "../../../components/ui/Dialog";
14
-import { useEnvironmentQuery } from "../../../state/query";
13
import { serverEnvironment } from "../../../state/server";
14
import { sourceControlEnvironment } from "../../../state/sourceControl";
15
import { useAtomCommand } from "../../../state/use-atom-command";
16
import type { SettingsTarget } from "../settings-environment-filter";
17
import { SettingsRow } from "./SettingsRow";
20
-import { SettingsSection } from "./SettingsSection";
18
19
const failureMessage = (cause: Cause.Cause<unknown>) => {
20
const error = Cause.squash(cause);
@@ -26,73 +23,8 @@ const failureMessage = (cause: Cause.Cause<unknown>) => {
23
24
const openUrl = (url: string) => void Linking.openURL(url).catch(() => undefined);
25
29
-const appSignInHosts = sourceControlClients.definitions.flatMap((definition) =>
30
- definition.credentials?.appSignIn === undefined
31
- ? []
32
- : [{ definition, appSignIn: definition.credentials.appSignIn }],
33
-);
34
-
35
-/**
36
- * Signing an environment in through a forge's own app, such as T3 Code for GitHub, on servers
37
- * configured for it.
38
- */
39
-export function SourceControlSignInSection(props: {
40
- readonly environments: readonly SettingsTarget[];
41
- readonly canWrite: (environmentId: EnvironmentId) => boolean;
42
-}) {
43
- return (
44
- <>
45
- {appSignInHosts.flatMap(({ definition, appSignIn }) =>
46
- props.environments.map((environment) => (
47
- <OfferedAppSignIn
48
- key={`${definition.kind}:${environment.environmentId}`}
49
- environment={environment}
50
- title={
51
- props.environments.length > 1
52
- ? `${definition.label} · ${environment.label}`
53
- : definition.label
54
- }
55
- definition={definition}
56
- appSignIn={appSignIn}
57
- disabled={!props.canWrite(environment.environmentId)}
58
- />
59
- )),
60
- )}
61
- </>
62
- );
63
-}
64
-
65
-function OfferedAppSignIn(props: {
66
- readonly environment: SettingsTarget;
67
- readonly title: string;
68
- readonly definition: SourceControlDefinition;
69
- readonly appSignIn: SourceControlAppSignIn;
70
- readonly disabled: boolean;
71
-}) {
72
- const discovery = useEnvironmentQuery(
73
- sourceControlEnvironment.discovery({
74
- environmentId: props.environment.environmentId,
75
- input: {},
76
- }),
77
- );
78
- const offered = discovery.data?.sourceControlProviders.some(
79
- (item) => item.kind === props.definition.kind && item.appSignIn === true,
80
- );
81
- if (offered !== true) return null;
82
- return (
83
- <SettingsSection title={props.title}>
84
- <AppSignInRow
85
- environment={props.environment}
86
- label={props.appSignIn.appName}
87
- definition={props.definition}
88
- appSignIn={props.appSignIn}
89
- disabled={props.disabled}
90
- />
91
- </SettingsSection>
92
- );
93
-}
94
-
95
-function AppSignInRow(props: {
26
+/** Signs an environment in through a forge's own app, such as T3 Code for GitHub. */
27
+export function AppSignInRow(props: {
28
readonly environment: SettingsTarget;
29
readonly label: string;
30
readonly definition: SourceControlDefinition;
apps/mobile/src/state/issueTrackers.ts
new
+5
@@ -0,0 +1,5 @@
1
+import { createIssueTrackerEnvironmentAtoms } from "@t3tools/client-runtime/state/issue-trackers";
2
+
3
+import { connectionAtomRuntime } from "../connection/runtime";
4
+
5
+export const issueTrackerEnvironment = createIssueTrackerEnvironmentAtoms(connectionAtomRuntime);