@devries-cameron20 / t3code Mirror · read-only / commits / 326e08b08a
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 22, 18:15 UTC

refactor(clients): forge settings, routing and icons come from definitions (#23998)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Julius Marminge committed Oct 24, 2026 at 04:24 UTC 326e08b08a96c81a286fdff13ddb38ff46dc1902
61 files changed +1115 -930
apps/mobile/assets/link-icons/azure-devops.png
Binary files /dev/null and b/apps/mobile/assets/link-icons/azure-devops.png differ
apps/mobile/assets/link-icons/bitbucket.png
Binary files /dev/null and b/apps/mobile/assets/link-icons/bitbucket.png differ
apps/mobile/assets/link-icons/forgejo.png
Binary files /dev/null and b/apps/mobile/assets/link-icons/forgejo.png differ
apps/mobile/assets/link-icons/gitcafe.png
Binary files /dev/null and b/apps/mobile/assets/link-icons/gitcafe.png differ
apps/mobile/assets/link-icons/github.png
Binary files a/apps/mobile/assets/link-icons/github.png and b/apps/mobile/assets/link-icons/github.png differ
apps/mobile/assets/link-icons/gitlab.png
Binary files /dev/null and b/apps/mobile/assets/link-icons/gitlab.png differ
apps/mobile/package.json
+1
@@ -41,6 +41,7 @@
41 "config:prod": "APP_VARIANT=production expo config",
42 "profile:android:hermes": "mkdir -p profiles/review && react-native profile-hermes profiles/review",
43 "sync:chip-icons": "node scripts/sync-context-chip-icons.mjs",
44 + "sync:link-icons": "node scripts/sync-link-icons.ts",
45 "sync:pierre-icons": "node scripts/sync-pierre-file-icons.mjs",
46 "measure-renders": "node scripts/measure-renders.mts",
47 "generate": "node --disable-warning=MODULE_TYPELESS_PACKAGE_JSON scripts/generate-uniwind-themes.mts",
apps/mobile/scripts/sync-link-icons.ts new
+79
@@ -0,0 +1,79 @@
1 +// The native markdown renderer draws a link's icon from a raster image, so each source control
2 +// host's mark is rendered from its definition's artwork into a bundled PNG.
3 +import * as NodeFS from "node:fs";
4 +import * as NodeModule from "node:module";
5 +import * as NodePath from "node:path";
6 +import * as NodeURL from "node:url";
7 +
8 +import {
9 + sourceControlClients,
10 + type SourceControlIcon,
11 +} from "@t3tools/client-runtime/source-control-clients";
12 +
13 +const appDirectory = NodePath.resolve(
14 + NodePath.dirname(NodeURL.fileURLToPath(import.meta.url)),
15 + "..",
16 +);
17 +const outputDirectory = NodePath.join(appDirectory, "assets/link-icons");
18 +const generatedModulePath = NodePath.join(appDirectory, "src/lib/markdownLinkIcons.generated.ts");
19 +const sharp = NodeModule.createRequire(
20 + NodePath.resolve(appDirectory, "../../scripts/package.json"),
21 +)("sharp");
22 +
23 +const SIZE = 64;
24 +
25 +function attribute(name: string, value: string | number | undefined): string {
26 + return value === undefined ? "" : ` ${name}="${value}"`;
27 +}
28 +
29 +// A monochrome mark is tinted by the renderer, which only reads its alpha.
30 +function svgMarkup(icon: SourceControlIcon): string {
31 + const paint = (value: SourceControlIcon["paths"][number]["fill"]) =>
32 + value === undefined
33 + ? "none"
34 + : typeof value === "string"
35 + ? value.replace("currentColor", "#ffffff")
36 + : `url(#${value.gradient})`;
37 + const gradients = (icon.gradients ?? [])
38 + .map(
39 + (gradient) =>
40 + `<linearGradient id="${gradient.id}" x1="${gradient.x1}" y1="${gradient.y1}" x2="${gradient.x2}" y2="${gradient.y2}" gradientUnits="userSpaceOnUse"${attribute("gradientTransform", gradient.transform)}>${gradient.stops
41 + .map(
42 + (stop) =>
43 + `<stop offset="${stop.offset}" stop-color="${stop.color}"${attribute("stop-opacity", stop.opacity)}/>`,
44 + )
45 + .join("")}</linearGradient>`,
46 + )
47 + .join("");
48 + const paths = icon.paths
49 + .map(
50 + (path) =>
51 + `<path d="${path.d}" fill="${paint(path.fill)}"${attribute("fill-rule", path.fillRule)}${attribute("fill-opacity", path.fillOpacity)}${attribute("stroke", path.stroke === undefined ? undefined : paint(path.stroke))}${attribute("stroke-width", path.strokeWidth)}/>`,
52 + )
53 + .join("");
54 + return `<svg xmlns="http://www.w3.org/2000/svg" width="${SIZE}" height="${SIZE}" viewBox="${icon.viewBox}" fill="none"><defs>${gradients}</defs>${paths}</svg>`;
55 +}
56 +
57 +NodeFS.rmSync(outputDirectory, { recursive: true, force: true });
58 +NodeFS.mkdirSync(outputDirectory, { recursive: true });
59 +
60 +const kinds: string[] = [];
61 +for (const definition of sourceControlClients.definitions) {
62 + if (definition.icon === null) continue;
63 + await sharp(Buffer.from(svgMarkup(definition.icon)), { density: 72 * 4 })
64 + .resize(SIZE, SIZE, { fit: "contain", background: { r: 0, g: 0, b: 0, alpha: 0 } })
65 + .png()
66 + .toFile(NodePath.join(outputDirectory, `${definition.kind}.png`));
67 + kinds.push(definition.kind);
68 +}
69 +
70 +NodeFS.writeFileSync(
71 + generatedModulePath,
72 + `import type { ImageSourcePropType } from "react-native";\n\nexport const SOURCE_CONTROL_LINK_ICON_SOURCES: Readonly<Record<string, ImageSourcePropType>> = {\n${kinds
73 + .toSorted()
74 + .map(
75 + (kind) =>
76 + ` ${/^\w+$/u.test(kind) ? kind : `"${kind}"`}: require("../../assets/link-icons/${kind}.png"),`,
77 + )
78 + .join("\n")}\n};\n`,
79 +);
apps/mobile/src/connection/storage.ts
+4 -4
@@ -13,8 +13,8 @@ import {
13 ConnectionTransientError,
14 CredentialStore,
15 ProfileStore,
16 - GitHubRoutingPermissions,
17 - makeGitHubRoutingPermissions,
16 + PullRequestRoutingPermissions,
17 + makePullRequestRoutingPermissions,
18 } from "@t3tools/client-runtime/connection";
19 import * as Context from "effect/Context";
20 import * as Effect from "effect/Effect";
@@ -42,7 +42,7 @@ function targetPersistenceError(
42 export const layer = Layer.effectContext(
43 Effect.gen(function* () {
44 const catalog = yield* CatalogStore.make();
45 - const githubRoutingPermissions = yield* makeGitHubRoutingPermissions({
45 + const githubRoutingPermissions = yield* makePullRequestRoutingPermissions({
46 read: catalog.read.pipe(Effect.map((document) => document.githubRoutingPermissions ?? [])),
47 write: (githubRoutingPermissions) =>
48 catalog.update((document) => ({ ...document, githubRoutingPermissions })),
@@ -150,7 +150,7 @@ export const layer = Layer.effectContext(
150 })),
151 });
152 return Context.make(Persistence.ConnectionTargetStore, targetStore).pipe(
153 - Context.add(GitHubRoutingPermissions, githubRoutingPermissions),
153 + Context.add(PullRequestRoutingPermissions, githubRoutingPermissions),
154 Context.add(Persistence.ConnectionRegistrationStore, registrationStore),
155 Context.add(ProfileStore.ConnectionProfileStore, profileStore),
156 Context.add(CredentialStore.ConnectionCredentialStore, credentialStore),
apps/mobile/src/features/connection/ConnectionsRouteScreen.tsx
+2 -2
@@ -10,7 +10,7 @@ import { useSafeAreaInsets } from "react-native-safe-area-context";
10 import { AndroidScreenHeader } from "../../components/ui/AndroidScreenHeader";
11 import { useRemoteConnections } from "../../state/use-remote-environment-registry";
12 import { LocalEnvironmentList } from "./LocalEnvironmentList";
13 -import { GitHubRoutingSettings } from "./GitHubRoutingSettings";
13 +import { PullRequestRoutingSettings } from "./PullRequestRoutingSettings";
14
15 export function ConnectionsRouteScreen() {
16 const {
@@ -69,7 +69,7 @@ export function ConnectionsRouteScreen() {
69 onSetEnabled={onSetEnvironmentEnabled}
70 onUpdate={onUpdateEnvironment}
71 />
72 - <GitHubRoutingSettings />
72 + <PullRequestRoutingSettings />
73 </ScrollView>
74 </View>
75 );
apps/mobile/src/features/connection/PullRequestRoutingSettings.tsx renamed
+18 -16
@@ -3,9 +3,9 @@ import * as Dialog from "../../components/ui/Dialog";
3 import { useAtomValue } from "@effect/atom-react";
4 import {
5 connectionCatalogDisplayUrl,
6 - gitHubRoutingConnectionKey,
7 - gitHubRoutingPermissionFor,
8 - type GitHubRoutingPermission,
6 + pullRequestRoutingConnectionKey,
7 + pullRequestRoutingPermissionFor,
8 + type PullRequestRoutingPermission,
9 } from "@t3tools/client-runtime/connection";
10 import { useState } from "react";
11 import { Pressable, View } from "react-native";
@@ -17,11 +17,11 @@ import { useAtomCommand } from "../../state/use-atom-command";
17 import { SettingsSection } from "../settings/components/SettingsSection";
18
19 const options: ReadonlyArray<{
20 - value: GitHubRoutingPermission;
20 + value: PullRequestRoutingPermission;
21 label: string;
22 description: string;
23 }> = [
24 - { value: "off", label: "Off", description: "Keep GitHub requests on this environment." },
24 + { value: "off", label: "Off", description: "Keep source control requests on this environment." },
25 {
26 value: "read",
27 label: "Read PRs",
@@ -30,30 +30,32 @@ const options: ReadonlyArray<{
30 {
31 value: "read-write",
32 label: "Read and act",
33 - description: "Actions may use broader GitHub permissions than the original environment.",
33 + description:
34 + "Actions may use broader source control permissions than the original environment.",
35 },
36 ];
37
37 -export function GitHubRoutingSettings() {
38 +export function PullRequestRoutingSettings() {
39 const catalog = useAtomValue(environmentCatalog.catalogValueAtom);
39 - const permissions = useAtomValue(environmentCatalog.githubRoutingPermissionsValueAtom);
40 - const update = useAtomCommand(environmentCatalog.setGitHubRoutingPermission);
40 + const permissions = useAtomValue(environmentCatalog.pullRequestRoutingPermissionsValueAtom);
41 + const update = useAtomCommand(environmentCatalog.setPullRequestRoutingPermission);
42 const [expanded, setExpanded] = useState<string | null>(null);
43 const [saving, setSaving] = useState(false);
44 if (catalog.entries.size === 0) return null;
45
46 return (
47 <View className="mt-5 gap-3">
47 - <SettingsSection title="GitHub routing">
48 + <SettingsSection title="Pull request routing">
49 {[...catalog.entries.values()].map((entry) => {
50 const environmentId = entry.target.environmentId;
50 - const selected = gitHubRoutingPermissionFor(entry, permissions);
51 - const disabled = !catalog.isReady || saving || gitHubRoutingConnectionKey(entry) === null;
51 + const selected = pullRequestRoutingPermissionFor(entry, permissions);
52 + const disabled =
53 + !catalog.isReady || saving || pullRequestRoutingConnectionKey(entry) === null;
54 return (
55 <View key={environmentId}>
56 <Pressable
57 accessibilityRole="button"
56 - accessibilityLabel={`${entry.target.label} GitHub routing`}
58 + accessibilityLabel={`${entry.target.label} pull request routing`}
59 accessibilityState={{ expanded: expanded === environmentId }}
60 className="flex-row items-center gap-3 p-4"
61 onPress={() => setExpanded(expanded === environmentId ? null : environmentId)}
@@ -89,7 +91,7 @@ export function GitHubRoutingSettings() {
91 setSaving(false);
92 if (result._tag === "Failure")
93 Dialog.alert(
92 - "Could not save GitHub routing permission",
94 + "Could not save pull request routing permission",
95 "Try again before leaving this screen.",
96 );
97 });
@@ -102,8 +104,8 @@ export function GitHubRoutingSettings() {
104 })}
105 </SettingsSection>
106 <Text className="px-2 text-sm text-foreground-muted">
105 - Choose environments you trust to share PR data and use each other's GitHub access. Enable
106 - both environments. This applies only to this client.
107 + Choose environments you trust to share PR data and use each other's source control access.
108 + Enable both environments. This applies only to this client.
109 </Text>
110 </View>
111 );
apps/mobile/src/features/projects/AddProjectScreen.tsx
+3 -3
@@ -475,7 +475,7 @@ function SourceControlRow(props: {
475 />
476 ) : (
477 <SourceControlIcon
478 - kind={sourceControlClients.get(props.source).icon}
478 + icon={sourceControlClients.get(props.source).icon}
479 size={Platform.OS === "android" ? 24 : 18}
480 colorClassName="accent-icon"
481 />
@@ -1113,7 +1113,7 @@ export function AddProjectNewScreen(props: { readonly environmentId?: string | s
1113 }
1114 icon={
1115 <SourceControlIcon
1116 - kind={publishTarget.definition.icon}
1116 + icon={publishTarget.definition.icon}
1117 size={Platform.OS === "android" ? 24 : 18}
1118 colorClassName="accent-icon"
1119 />
@@ -1137,7 +1137,7 @@ export function AddProjectNewScreen(props: { readonly environmentId?: string | s
1137 title={target.definition.label}
1138 icon={
1139 <SourceControlIcon
1140 - kind={target.definition.icon}
1140 + icon={target.definition.icon}
1141 size={Platform.OS === "android" ? 24 : 17}
1142 colorClassName="accent-icon"
1143 />
apps/mobile/src/features/projects/SourceControlIcon.tsx
+60 -245
@@ -1,261 +1,76 @@
1 -import Svg, { Circle, Defs, G, LinearGradient, Path, Rect, Stop } from "react-native-svg";
1 +import type { SourceControlIcon as SourceControlIconArtwork } from "@t3tools/client-runtime/source-control-clients";
2 +import { useId } from "react";
3 +import Svg, { Defs, LinearGradient, Path, Stop } from "react-native-svg";
4 import { withUniwind } from "uniwind";
5
6 const ThemedSvg = withUniwind(Svg);
7
8 +/** Draws a host's mark from its definition's artwork; `currentColor` follows `color`. */
9 export function SourceControlIcon(props: {
7 - readonly kind: string;
10 + readonly icon: SourceControlIconArtwork | null;
11 readonly size?: number;
12 readonly color?: string;
13 readonly colorClassName?: string;
14 }) {
15 + // Gradient ids must not collide when one screen shows the same mark more than once.
16 + const idPrefix = useId().replace(/[^\w-]/gu, "");
17 const size = props.size ?? 18;
18 + const { icon } = props;
19 + if (icon === null) return null;
20 + const paint = (value: SourceControlIconArtwork["paths"][number]["fill"]) =>
21 + value === undefined
22 + ? "none"
23 + : typeof value === "string"
24 + ? value
25 + : `url(#${idPrefix}-${value.gradient})`;
26
14 - switch (props.kind) {
15 - case "forgejo":
16 - return (
17 - <Svg width={size} height={size} viewBox="0 0 212 212">
18 - <G transform="translate(6 6)" fill="none">
19 - <Path d="M58 168 v-98 a50 50 0 0 1 50-50 h20" stroke="#ff6600" strokeWidth={25} />
20 - <Path d="M58 168 v-30 a50 50 0 0 1 50-50 h20" stroke="#d40000" strokeWidth={25} />
21 - <Circle cx={142} cy={20} r={18} stroke="#ff6600" strokeWidth={15} />
22 - <Circle cx={142} cy={88} r={18} stroke="#d40000" strokeWidth={15} />
23 - <Circle cx={58} cy={180} r={18} stroke="#d40000" strokeWidth={15} />
24 - </G>
25 - </Svg>
26 - );
27 - case "github":
28 - return (
29 - <ThemedSvg
30 - width={size}
31 - height={size}
32 - viewBox="0 0 16 16"
33 - color={props.color}
34 - colorClassName={props.colorClassName}
35 - fill="none"
36 - >
37 - <Path
38 - fillRule="evenodd"
39 - clipRule="evenodd"
40 - d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82A7.68 7.68 0 0 1 8.02 3.86c.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8Z"
41 - fill="currentColor"
42 - />
43 - </ThemedSvg>
44 - );
45 - case "gitlab":
46 - return (
47 - <Svg width={size} height={size} viewBox="0 0 32 32" fill="none">
48 - <Path
49 - d="m31.46 12.78-.04-.12-4.35-11.35A1.14 1.14 0 0 0 25.94.6c-.24 0-.47.1-.66.24-.19.15-.33.36-.39.6l-2.94 9h-11.9l-2.94-9A1.14 1.14 0 0 0 6.07.58a1.15 1.15 0 0 0-1.14.72L.58 12.68l-.05.11a8.1 8.1 0 0 0 2.68 9.34l.02.01.04.03 6.63 4.97 3.28 2.48 2 1.52a1.35 1.35 0 0 0 1.62 0l2-1.52 3.28-2.48 6.67-5h.02a8.09 8.09 0 0 0 2.7-9.36Z"
50 - fill="#E24329"
51 - />
52 - <Path
53 - d="m31.46 12.78-.04-.12a14.75 14.75 0 0 0-5.86 2.64l-9.55 7.24 6.09 4.6 6.67-5h.02a8.09 8.09 0 0 0 2.67-9.36Z"
54 - fill="#FC6D26"
55 - />
56 - <Path
57 - d="m9.9 27.14 3.28 2.48 2 1.52a1.35 1.35 0 0 0 1.62 0l2-1.52 3.28-2.48-6.1-4.6-6.07 4.6Z"
58 - fill="#FCA326"
59 - />
60 - <Path
61 - d="M6.44 15.3a14.71 14.71 0 0 0-5.86-2.63l-.05.12a8.1 8.1 0 0 0 2.68 9.34l.02.01.04.03 6.63 4.97 6.1-4.6-9.56-7.24Z"
62 - fill="#FC6D26"
63 - />
64 - </Svg>
65 - );
66 - case "azure-devops":
67 - // Microsoft Azure DevOps mark via selfhst/icons (CC BY 4.0): https://github.com/selfhst/icons/blob/main/svg/azure-devops.svg
68 - return (
69 - <Svg width={size} height={size} viewBox="0 0 512 512">
70 - <Defs>
27 + return (
28 + <ThemedSvg
29 + width={size}
30 + height={size}
31 + viewBox={icon.viewBox}
32 + color={props.color}
33 + colorClassName={props.colorClassName}
34 + fill="none"
35 + >
36 + {icon.gradients ? (
37 + <Defs>
38 + {icon.gradients.map((gradient) => (
39 <LinearGradient
72 - id="azure-a"
73 - x1="58.027"
74 - x2="58.027"
75 - y1="356.668"
76 - y2="100.668"
77 - gradientTransform="matrix(1 0 0 -1 0 514)"
40 + key={gradient.id}
41 + id={`${idPrefix}-${gradient.id}`}
42 + x1={gradient.x1}
43 + y1={gradient.y1}
44 + x2={gradient.x2}
45 + y2={gradient.y2}
46 + gradientTransform={gradient.transform}
47 gradientUnits="userSpaceOnUse"
48 >
80 - <Stop offset="0" stopColor="#163697" />
81 - <Stop offset=".276" stopColor="#2052cb" />
82 - <Stop offset=".518" stopColor="#2764e7" />
83 - <Stop offset=".879" stopColor="#367af2" />
49 + {gradient.stops.map((stop) => (
50 + <Stop
51 + key={stop.offset}
52 + offset={stop.offset}
53 + stopColor={stop.color}
54 + stopOpacity={stop.opacity}
55 + />
56 + ))}
57 </LinearGradient>
85 - <LinearGradient
86 - id="azure-b"
87 - x1="58.027"
88 - x2="58.027"
89 - y1="351.334"
90 - y2="292.668"
91 - gradientTransform="matrix(1 0 0 -1 0 514)"
92 - gradientUnits="userSpaceOnUse"
93 - >
94 - <Stop offset="0" stopColor="#102784" />
95 - <Stop offset="1" stopColor="#2052cb" stopOpacity="0" />
96 - </LinearGradient>
97 - <LinearGradient
98 - id="azure-c"
99 - x1="389.98"
100 - x2="107.314"
101 - y1="57.935"
102 - y2="193.935"
103 - gradientTransform="matrix(1 0 0 -1 0 514)"
104 - gradientUnits="userSpaceOnUse"
105 - >
106 - <Stop offset="0" stopColor="#163697" />
107 - <Stop offset=".301" stopColor="#2052cb" />
108 - <Stop offset=".626" stopColor="#2764e7" />
109 - <Stop offset=".926" stopColor="#367af2" />
110 - </LinearGradient>
111 - <LinearGradient
112 - id="azure-d"
113 - x1="391.996"
114 - x2="341.385"
115 - y1="76.552"
116 - y2="78.224"
117 - gradientTransform="matrix(1 0 0 -1 0 514)"
118 - gradientUnits="userSpaceOnUse"
119 - >
120 - <Stop offset="0" stopColor="#102784" />
121 - <Stop offset="1" stopColor="#2052cb" stopOpacity="0" />
122 - </LinearGradient>
123 - <LinearGradient
124 - id="azure-e"
125 - x1="442.24"
126 - x2="442.24"
127 - y1="54.769"
128 - y2="419.38"
129 - gradientTransform="matrix(1 0 0 -1 0 514)"
130 - gradientUnits="userSpaceOnUse"
131 - >
132 - <Stop offset=".043" stopColor="#2052cb" />
133 - <Stop offset=".489" stopColor="#367af2" />
134 - <Stop offset=".943" stopColor="#16bbda" />
135 - </LinearGradient>
136 - <LinearGradient
137 - id="azure-f"
138 - x1="435.596"
139 - x2="425.732"
140 - y1="270.413"
141 - y2="385.266"
142 - gradientTransform="matrix(1 0 0 -1 0 514)"
143 - gradientUnits="userSpaceOnUse"
144 - >
145 - <Stop offset=".134" stopColor="#16bbda" stopOpacity="0" />
146 - <Stop offset=".932" stopColor="#6be7a0" stopOpacity=".8629" />
147 - </LinearGradient>
148 - <LinearGradient
149 - id="azure-g"
150 - x1="437.081"
151 - x2="507.893"
152 - y1="204.362"
153 - y2="119.081"
154 - gradientTransform="matrix(1 0 0 -1 0 514)"
155 - gradientUnits="userSpaceOnUse"
156 - >
157 - <Stop offset="0" stopColor="#2c68e0" stopOpacity="0" />
158 - <Stop offset=".898" stopColor="#66c0ff" stopOpacity=".5" />
159 - </LinearGradient>
160 - <LinearGradient
161 - id="azure-h"
162 - x1="99.399"
163 - x2="352.75"
164 - y1="279.26"
165 - y2="498.676"
166 - gradientTransform="matrix(1 0 0 -1 0 514)"
167 - gradientUnits="userSpaceOnUse"
168 - >
169 - <Stop offset=".005" stopColor="#367af2" />
170 - <Stop offset=".507" stopColor="#0fafff" />
171 - <Stop offset="1" stopColor="#26cfe8" />
172 - </LinearGradient>
173 - <LinearGradient
174 - id="azure-i"
175 - x1="184.342"
176 - x2="338.581"
177 - y1="356.795"
178 - y2="480.642"
179 - gradientTransform="matrix(1 0 0 -1 0 514)"
180 - gradientUnits="userSpaceOnUse"
181 - >
182 - <Stop offset=".443" stopColor="#26cfe8" stopOpacity="0" />
183 - <Stop offset=".897" stopColor="#6be7a0" stopOpacity=".8629" />
184 - </LinearGradient>
185 - </Defs>
186 - <Path
187 - d="M116.1 73.4c-5.8 5.8-13.7 13.8-13.7 22.6v216.4c0 8.9-3.3 17.3-9 23.4s-13.3 9.2-21.1 8.5l-42.7-3.1c-7.9-.5-15-3.9-20.3-9.3-5.7-5.7-9.3-13.7-9.3-22.6V202.7c0-8.9 3.6-16.9 9.4-22.6l2-1.9z"
188 - fill="url(#azure-a)"
189 - />
190 - <Path
191 - d="M116.1 73.4c-5.8 5.8-13.7 13.8-13.7 22.6v216.4c0 8.9-3.3 17.3-9 23.4s-13.3 9.2-21.1 8.5l-42.7-3.1c-7.9-.5-15-3.9-20.3-9.3-5.7-5.7-9.3-13.7-9.3-22.6V202.7c0-8.9 3.6-16.9 9.4-22.6l2-1.9z"
192 - fill="url(#azure-b)"
193 - />
194 - <Path
195 - d="m500.5 366-128 106.7c-5.5 4.6-12.7 7.4-20.5 7.4q-2.4 0-4.8-.3l-112.5-16.9v27.8c0 11.7-9.6 21.3-21.3 21.3-7.3 0-13.5-3.6-17.5-9.1l-36.2-51.4-5.4-7.6-36.6-51.9-7-10c-2.6-3.5-3.9-7.8-3.9-12.3 0-6 2.5-11.6 6.8-15.7 3.8-3.7 9.1-5.8 14.5-5.8.4 0 1 .1 1.5.1l105.2 7.5L384 366.5l93.7 6.7c.7.1 1.6.1 2.3.1 7.8 0 14.9-2.7 20.5-7.3"
196 - fill="url(#azure-c)"
197 - />
198 - <Path
199 - d="m500.5 366-128 106.7c-5.5 4.6-12.7 7.4-20.5 7.4q-2.4 0-4.8-.3l-112.5-16.9v27.8c0 11.7-9.6 21.3-21.3 21.3-7.3 0-13.5-3.6-17.5-9.1l-36.2-51.4-5.4-7.6-36.6-51.9-7-10c-2.6-3.5-3.9-7.8-3.9-12.3 0-6 2.5-11.6 6.8-15.7 3.8-3.7 9.1-5.8 14.5-5.8.4 0 1 .1 1.5.1l105.2 7.5L384 366.5l93.7 6.7c.7.1 1.6.1 2.3.1 7.8 0 14.9-2.7 20.5-7.3"
200 - fill="url(#azure-d)"
201 - />
202 - <Path
203 - d="M512 170.7v170.7c0 9.9-4.5 18.8-11.5 24.6l-128 106.7c7-5.9 11.5-14.7 11.5-24.6V175.3c0-16.7 13-30.7 29.8-31.9l63.9-4.6c.7-.1 1.6-.1 2.3-.1 7.8 0 14.9 2.8 20.5 7.4 7 5.8 11.5 14.6 11.5 24.6"
204 - fill="url(#azure-e)"
205 - />
206 - <Path
207 - d="M512 170.7v170.7c0 9.9-4.5 18.8-11.5 24.6l-128 106.7c7-5.9 11.5-14.7 11.5-24.6V175.3c0-16.7 13-30.7 29.8-31.9l63.9-4.6c.7-.1 1.6-.1 2.3-.1 7.8 0 14.9 2.8 20.5 7.4 7 5.8 11.5 14.6 11.5 24.6"
208 - fill="url(#azure-f)"
209 - fillOpacity=".7"
210 - />
211 - <Path
212 - d="M512 170.7v170.7c0 9.9-4.5 18.8-11.5 24.6l-128 106.7c7-5.9 11.5-14.7 11.5-24.6V175.3c0-16.7 13-30.7 29.8-31.9l63.9-4.6c.7-.1 1.6-.1 2.3-.1 7.8 0 14.9 2.8 20.5 7.4 7 5.8 11.5 14.6 11.5 24.6"
213 - fill="url(#azure-g)"
214 - />
215 - <Path
216 - d="M384 125.5c0 11.2-8.6 20.5-19.8 21.3-.5 0-1.1.1-1.6.1l-127.9 9.2-132.3 9.1-72.7 5.5c-6.9.4-13.2 3.1-18.2 7.4L116.1 73.4c4.7-4.7 10.9-8 17.8-9.1l100.8-15.1V21.3C234.7 9.6 244.3 0 256 0c5.8 0 11.1 2.3 14.9 6.1l33.4 32.6 16.9 16.5 40.3 39.3 16.1 15.8c4.1 3.9 6.4 9.4 6.4 15.2"
217 - fill="url(#azure-h)"
218 - />
219 - <Path
220 - d="M384 125.5c0 11.2-8.6 20.5-19.8 21.3-.5 0-1.1.1-1.6.1l-127.9 9.2-132.3 9.1-72.7 5.5c-6.9.4-13.2 3.1-18.2 7.4L116.1 73.4c4.7-4.7 10.9-8 17.8-9.1l100.8-15.1V21.3C234.7 9.6 244.3 0 256 0c5.8 0 11.1 2.3 14.9 6.1l33.4 32.6 16.9 16.5 40.3 39.3 16.1 15.8c4.1 3.9 6.4 9.4 6.4 15.2"
221 - fill="url(#azure-i)"
222 - fillOpacity=".5"
223 - />
224 - </Svg>
225 - );
226 - case "bitbucket":
227 - return (
228 - <Svg width={size} height={size} viewBox="8.4 14.39 2481.29 2231.21">
229 - <Defs>
230 - <LinearGradient
231 - id="bitbucket-a"
232 - x1="945.1094"
233 - y1="1524.8389"
234 - x2="944.4923"
235 - y2="1524.1893"
236 - gradientTransform="matrix(1996.6343 0 0 -1480.3047 -1884485.625 2258195)"
237 - >
238 - <Stop offset="0.18" stopColor="#0052CC" />
239 - <Stop offset="1" stopColor="#2684FF" />
240 - </LinearGradient>
241 - </Defs>
242 - <Path
243 - fill="#2684FF"
244 - d="M88.92,14.4C45.02,13.83,8.97,48.96,8.41,92.86c-0.06,4.61,0.28,9.22,1.02,13.77l337.48,2048.72 c8.68,51.75,53.26,89.8,105.74,90.24h1619.03c39.38,0.5,73.19-27.9,79.49-66.78l337.49-2071.78c7.03-43.34-22.41-84.17-65.75-91.2 c-4.55-0.74-9.15-1.08-13.76-1.02L88.92,14.4z M1509.99,1495.09H993.24l-139.92-731h781.89L1509.99,1495.09z"
245 - />
246 - <Path
247 - fill="url(#bitbucket-a)"
248 - d="M2379.27,763.06h-745.5l-125.12,730.42H992.31l-609.67,723.67c19.32,16.71,43.96,26,69.5,26.21h1618.13 c39.35,0.51,73.14-27.88,79.44-66.72L2379.27,763.06z"
249 - />
250 - </Svg>
251 - );
252 - case "gitcafe":
253 - return (
254 - <Svg width={size} height={size} viewBox="0 0 64 64">
255 - <Rect x={4.8} y={4.8} width={54.4} height={54.4} fill="#a78bfa" />
256 - </Svg>
257 - );
258 - default:
259 - return null;
260 - }
58 + ))}
59 + </Defs>
60 + ) : null}
61 + {icon.paths.map((path, index) => (
62 + <Path
63 + // Paths repeat with different paints, so their data is not a key.
64 + // oxlint-disable-next-line react/no-array-index-key
65 + key={index}
66 + d={path.d}
67 + fill={paint(path.fill)}
68 + fillRule={path.fillRule}
69 + fillOpacity={path.fillOpacity}
70 + stroke={path.stroke}
71 + strokeWidth={path.strokeWidth}
72 + />
73 + ))}
74 + </ThemedSvg>
75 + );
76 }
apps/mobile/src/features/settings/SettingsEnvironmentsRouteScreen.tsx
+2 -2
@@ -12,7 +12,7 @@ import { AndroidAnchoredMenu } from "../../components/ui/AndroidAnchoredMenu";
12 import { AndroidHeaderIconButton } from "../../components/ui/AndroidScreenHeader";
13 import { CloudEnvironmentRows } from "../connection/CloudEnvironmentRows";
14 import { LocalEnvironmentList } from "../connection/LocalEnvironmentList";
15 -import { GitHubRoutingSettings } from "../connection/GitHubRoutingSettings";
15 +import { PullRequestRoutingSettings } from "../connection/PullRequestRoutingSettings";
16 import { splitEnvironmentSections } from "../connection/environmentSections";
17 import { useUniwindTheme } from "../../lib/useUniwindTheme";
18 import { useRemoteConnections } from "../../state/use-remote-environment-registry";
@@ -179,7 +179,7 @@ export function SettingsEnvironmentsRouteScreen() {
179 }
180 : {})}
181 />
182 - <GitHubRoutingSettings />
182 + <PullRequestRoutingSettings />
183 </ScrollView>
184 </SettingsScreen>
185 );
apps/mobile/src/lib/markdownLinkIcons.generated.ts new
+10
@@ -0,0 +1,10 @@
1 +import type { ImageSourcePropType } from "react-native";
2 +
3 +export const SOURCE_CONTROL_LINK_ICON_SOURCES: Readonly<Record<string, ImageSourcePropType>> = {
4 + "azure-devops": require("../../assets/link-icons/azure-devops.png"),
5 + bitbucket: require("../../assets/link-icons/bitbucket.png"),
6 + forgejo: require("../../assets/link-icons/forgejo.png"),
7 + gitcafe: require("../../assets/link-icons/gitcafe.png"),
8 + github: require("../../assets/link-icons/github.png"),
9 + gitlab: require("../../assets/link-icons/gitlab.png"),
10 +};
apps/mobile/src/lib/markdownLinkIcons.ts
+18 -9
@@ -1,13 +1,22 @@
1 -import { sourceControlClients } from "@t3tools/client-runtime/source-control-clients";
1 +import {
2 + isMonochromeSourceControlIcon,
3 + sourceControlClients,
4 +} from "@t3tools/client-runtime/source-control-clients";
5 import type { ImageSourcePropType } from "react-native";
6
4 -// The native renderer draws a link's icon from an image, so a host's mark is a bundled image keyed
5 -// by its definition's `icon`. A host without one keeps a plain link.
6 -const SOURCE_CONTROL_LINK_ICON_SOURCES: Partial<Record<string, ImageSourcePropType>> = {
7 - github: require("../../assets/link-icons/github.png"),
8 -};
7 +import { SOURCE_CONTROL_LINK_ICON_SOURCES } from "./markdownLinkIcons.generated";
8
10 -export function markdownLinkIconSource(host: string): ImageSourcePropType | null {
11 - const icon = sourceControlClients.findByPublicDomain(host)?.icon;
12 - return (icon === undefined ? undefined : SOURCE_CONTROL_LINK_ICON_SOURCES[icon]) ?? null;
9 +export interface MarkdownLinkIcon {
10 + readonly source: ImageSourcePropType;
11 + /** A mark drawn in the text colour takes the link's colour; a coloured mark keeps its own. */
12 + readonly tints: boolean;
13 +}
14 +
15 +// `vp run sync:link-icons` renders each host's artwork into the bundled image this reads.
16 +export function markdownLinkIcon(host: string): MarkdownLinkIcon | null {
17 + const definition = sourceControlClients.findByPublicDomain(host);
18 + const source = definition && SOURCE_CONTROL_LINK_ICON_SOURCES[definition.kind];
19 + return definition?.icon && source
20 + ? { source, tints: isMonochromeSourceControlIcon(definition.icon) }
21 + : null;
22 }
apps/mobile/src/native/useEnrichedLinkVariants.ts
+4 -4
@@ -11,7 +11,7 @@ import { CONTEXT_CHIP_ICON_SOURCES } from "../lib/contextChipIcons.generated";
11 import { FONT_FAMILIES } from "../lib/fontFamilies";
12 import { contextChipIconSource } from "../lib/contextChipIconSource";
13 import { markdownFileIconSource } from "../lib/markdownFileIcons";
14 -import { markdownLinkIconSource } from "../lib/markdownLinkIcons";
14 +import { markdownLinkIcon } from "../lib/markdownLinkIcons";
15 import { useUniwindTheme } from "../lib/useUniwindTheme";
16 import { resolveMarkdownLinkPresentation } from "../lib/markdownLinks";
17 import type {
@@ -83,12 +83,12 @@ function presentation(
83 icon: markdownFileIconSource(link.icon),
84 chip: { accent: contextChipPresentation("mention").accent, tintsIcon: false },
85 };
86 - const icon = link.kind === "external" ? markdownLinkIconSource(link.host) : null;
86 + const icon = link.kind === "external" ? markdownLinkIcon(link.host) : null;
87 return icon
88 ? {
89 color: props.textStyle.linkColor,
90 - icon,
91 - iconTintColor: props.textStyle.linkColor,
90 + icon: icon.source,
91 + ...(icon.tints ? { iconTintColor: props.textStyle.linkColor } : {}),
92 }
93 : undefined;
94 }
apps/web/src/components/Icons.tsx
-250
@@ -69,18 +69,6 @@ export const LinuxIcon: Icon = ({ className, ...props }) => (
69 </svg>
70 );
71
72 -export const GitHubIcon: Icon = (props) => (
73 - <svg {...props} viewBox="0 0 1024 1024" fill="none">
74 - <path
75 - fillRule="evenodd"
76 - clipRule="evenodd"
77 - d="M8 0C3.58 0 0 3.58 0 8C0 11.54 2.29 14.53 5.47 15.59C5.87 15.66 6.02 15.42 6.02 15.21C6.02 15.02 6.01 14.39 6.01 13.72C4 14.09 3.48 13.23 3.32 12.78C3.23 12.55 2.84 11.84 2.5 11.65C2.22 11.5 1.82 11.13 2.49 11.12C3.12 11.11 3.57 11.7 3.72 11.94C4.44 13.15 5.59 12.81 6.05 12.6C6.12 12.08 6.33 11.73 6.56 11.53C4.78 11.33 2.92 10.64 2.92 7.58C2.92 6.71 3.23 5.99 3.74 5.43C3.66 5.23 3.38 4.41 3.82 3.31C3.82 3.31 4.49 3.1 6.02 4.13C6.66 3.95 7.34 3.86 8.02 3.86C8.7 3.86 9.38 3.95 10.02 4.13C11.55 3.09 12.22 3.31 12.22 3.31C12.66 4.41 12.38 5.23 12.3 5.43C12.81 5.99 13.12 6.7 13.12 7.58C13.12 10.65 11.25 11.33 9.47 11.53C9.76 11.78 10.01 12.26 10.01 13.01C10.01 14.08 10 14.94 10 15.21C10 15.42 10.15 15.67 10.55 15.59C13.71 14.53 16 11.53 16 8C16 3.58 12.42 0 8 0Z"
78 - transform="scale(64)"
79 - fill="currentColor"
80 - />
81 - </svg>
82 -);
83 -
72 export const GitIcon: Icon = (props) => (
73 <svg {...props} viewBox="0 0 256 256">
74 <path
@@ -134,226 +122,6 @@ export const JujutsuIcon: Icon = (props) => {
122 );
123 };
124
137 -export const GitLabIcon = ({
138 - monochrome = false,
139 - ...props
140 -}: SVGProps<SVGSVGElement> & { readonly monochrome?: boolean }) => (
141 - <svg {...props} viewBox="0 0 32 32" fill="none">
142 - <path
143 - d="m31.46 12.78-.04-.12-4.35-11.35A1.14 1.14 0 0 0 25.94.6c-.24 0-.47.1-.66.24-.19.15-.33.36-.39.6l-2.94 9h-11.9l-2.94-9A1.14 1.14 0 0 0 6.07.58a1.15 1.15 0 0 0-1.14.72L.58 12.68l-.05.11a8.1 8.1 0 0 0 2.68 9.34l.02.01.04.03 6.63 4.97 3.28 2.48 2 1.52a1.35 1.35 0 0 0 1.62 0l2-1.52 3.28-2.48 6.67-5h.02a8.09 8.09 0 0 0 2.7-9.36Z"
144 - fill={monochrome ? "currentColor" : "#E24329"}
145 - />
146 - <path
147 - d="m31.46 12.78-.04-.12a14.75 14.75 0 0 0-5.86 2.64l-9.55 7.24 6.09 4.6 6.67-5h.02a8.09 8.09 0 0 0 2.67-9.36Z"
148 - fill={monochrome ? "currentColor" : "#FC6D26"}
149 - />
150 - <path
151 - d="m9.9 27.14 3.28 2.48 2 1.52a1.35 1.35 0 0 0 1.62 0l2-1.52 3.28-2.48-6.1-4.6-6.07 4.6Z"
152 - fill={monochrome ? "currentColor" : "#FCA326"}
153 - />
154 - <path
155 - d="M6.44 15.3a14.71 14.71 0 0 0-5.86-2.63l-.05.12a8.1 8.1 0 0 0 2.68 9.34l.02.01.04.03 6.63 4.97 6.1-4.6-9.56-7.24Z"
156 - fill={monochrome ? "currentColor" : "#FC6D26"}
157 - />
158 - </svg>
159 -);
160 -
161 -// Microsoft Azure DevOps mark via selfhst/icons (CC BY 4.0): https://github.com/selfhst/icons/blob/main/svg/azure-devops.svg
162 -export const AzureDevOpsIcon: Icon = (props) => {
163 - const id = useId().replaceAll(":", "");
164 - const gradientId = `${id}-azure`;
165 -
166 - return (
167 - <svg {...props} viewBox="0 0 512 512">
168 - <defs>
169 - <linearGradient
170 - id={`${gradientId}-a`}
171 - x1="58.027"
172 - x2="58.027"
173 - y1="356.668"
174 - y2="100.668"
175 - gradientTransform="matrix(1 0 0 -1 0 514)"
176 - gradientUnits="userSpaceOnUse"
177 - >
178 - <stop offset="0" stopColor="#163697" />
179 - <stop offset=".276" stopColor="#2052cb" />
180 - <stop offset=".518" stopColor="#2764e7" />
181 - <stop offset=".879" stopColor="#367af2" />
182 - </linearGradient>
183 - <linearGradient
184 - id={`${gradientId}-b`}
185 - x1="58.027"
186 - x2="58.027"
187 - y1="351.334"
188 - y2="292.668"
189 - gradientTransform="matrix(1 0 0 -1 0 514)"
190 - gradientUnits="userSpaceOnUse"
191 - >
192 - <stop offset="0" stopColor="#102784" />
193 - <stop offset="1" stopColor="#2052cb" stopOpacity="0" />
194 - </linearGradient>
195 - <linearGradient
196 - id={`${gradientId}-c`}
197 - x1="389.98"
198 - x2="107.314"
199 - y1="57.935"
200 - y2="193.935"
201 - gradientTransform="matrix(1 0 0 -1 0 514)"
202 - gradientUnits="userSpaceOnUse"
203 - >
204 - <stop offset="0" stopColor="#163697" />
205 - <stop offset=".301" stopColor="#2052cb" />
206 - <stop offset=".626" stopColor="#2764e7" />
207 - <stop offset=".926" stopColor="#367af2" />
208 - </linearGradient>
209 - <linearGradient
210 - id={`${gradientId}-d`}
211 - x1="391.996"
212 - x2="341.385"
213 - y1="76.552"
214 - y2="78.224"
215 - gradientTransform="matrix(1 0 0 -1 0 514)"
216 - gradientUnits="userSpaceOnUse"
217 - >
218 - <stop offset="0" stopColor="#102784" />
219 - <stop offset="1" stopColor="#2052cb" stopOpacity="0" />
220 - </linearGradient>
221 - <linearGradient
222 - id={`${gradientId}-e`}
223 - x1="442.24"
224 - x2="442.24"
225 - y1="54.769"
226 - y2="419.38"
227 - gradientTransform="matrix(1 0 0 -1 0 514)"
228 - gradientUnits="userSpaceOnUse"
229 - >
230 - <stop offset=".043" stopColor="#2052cb" />
231 - <stop offset=".489" stopColor="#367af2" />
232 - <stop offset=".943" stopColor="#16bbda" />
233 - </linearGradient>
234 - <linearGradient
235 - id={`${gradientId}-f`}
236 - x1="435.596"
237 - x2="425.732"
238 - y1="270.413"
239 - y2="385.266"
240 - gradientTransform="matrix(1 0 0 -1 0 514)"
241 - gradientUnits="userSpaceOnUse"
242 - >
243 - <stop offset=".134" stopColor="#16bbda" stopOpacity="0" />
244 - <stop offset=".932" stopColor="#6be7a0" stopOpacity=".8629" />
245 - </linearGradient>
246 - <linearGradient
247 - id={`${gradientId}-g`}
248 - x1="437.081"
249 - x2="507.893"
250 - y1="204.362"
251 - y2="119.081"
252 - gradientTransform="matrix(1 0 0 -1 0 514)"
253 - gradientUnits="userSpaceOnUse"
254 - >
255 - <stop offset="0" stopColor="#2c68e0" stopOpacity="0" />
256 - <stop offset=".898" stopColor="#66c0ff" stopOpacity=".5" />
257 - </linearGradient>
258 - <linearGradient
259 - id={`${gradientId}-h`}
260 - x1="99.399"
261 - x2="352.75"
262 - y1="279.26"
263 - y2="498.676"
264 - gradientTransform="matrix(1 0 0 -1 0 514)"
265 - gradientUnits="userSpaceOnUse"
266 - >
267 - <stop offset=".005" stopColor="#367af2" />
268 - <stop offset=".507" stopColor="#0fafff" />
269 - <stop offset="1" stopColor="#26cfe8" />
270 - </linearGradient>
271 - <linearGradient
272 - id={`${gradientId}-i`}
273 - x1="184.342"
274 - x2="338.581"
275 - y1="356.795"
276 - y2="480.642"
277 - gradientTransform="matrix(1 0 0 -1 0 514)"
278 - gradientUnits="userSpaceOnUse"
279 - >
280 - <stop offset=".443" stopColor="#26cfe8" stopOpacity="0" />
281 - <stop offset=".897" stopColor="#6be7a0" stopOpacity=".8629" />
282 - </linearGradient>
283 - </defs>
284 - <path
285 - d="M116.1 73.4c-5.8 5.8-13.7 13.8-13.7 22.6v216.4c0 8.9-3.3 17.3-9 23.4s-13.3 9.2-21.1 8.5l-42.7-3.1c-7.9-.5-15-3.9-20.3-9.3-5.7-5.7-9.3-13.7-9.3-22.6V202.7c0-8.9 3.6-16.9 9.4-22.6l2-1.9z"
286 - fill={`url(#${gradientId}-a)`}
287 - />
288 - <path
289 - d="M116.1 73.4c-5.8 5.8-13.7 13.8-13.7 22.6v216.4c0 8.9-3.3 17.3-9 23.4s-13.3 9.2-21.1 8.5l-42.7-3.1c-7.9-.5-15-3.9-20.3-9.3-5.7-5.7-9.3-13.7-9.3-22.6V202.7c0-8.9 3.6-16.9 9.4-22.6l2-1.9z"
290 - fill={`url(#${gradientId}-b)`}
291 - />
292 - <path
293 - d="m500.5 366-128 106.7c-5.5 4.6-12.7 7.4-20.5 7.4q-2.4 0-4.8-.3l-112.5-16.9v27.8c0 11.7-9.6 21.3-21.3 21.3-7.3 0-13.5-3.6-17.5-9.1l-36.2-51.4-5.4-7.6-36.6-51.9-7-10c-2.6-3.5-3.9-7.8-3.9-12.3 0-6 2.5-11.6 6.8-15.7 3.8-3.7 9.1-5.8 14.5-5.8.4 0 1 .1 1.5.1l105.2 7.5L384 366.5l93.7 6.7c.7.1 1.6.1 2.3.1 7.8 0 14.9-2.7 20.5-7.3"
294 - fill={`url(#${gradientId}-c)`}
295 - />
296 - <path
297 - d="m500.5 366-128 106.7c-5.5 4.6-12.7 7.4-20.5 7.4q-2.4 0-4.8-.3l-112.5-16.9v27.8c0 11.7-9.6 21.3-21.3 21.3-7.3 0-13.5-3.6-17.5-9.1l-36.2-51.4-5.4-7.6-36.6-51.9-7-10c-2.6-3.5-3.9-7.8-3.9-12.3 0-6 2.5-11.6 6.8-15.7 3.8-3.7 9.1-5.8 14.5-5.8.4 0 1 .1 1.5.1l105.2 7.5L384 366.5l93.7 6.7c.7.1 1.6.1 2.3.1 7.8 0 14.9-2.7 20.5-7.3"
298 - fill={`url(#${gradientId}-d)`}
299 - />
300 - <path
301 - d="M512 170.7v170.7c0 9.9-4.5 18.8-11.5 24.6l-128 106.7c7-5.9 11.5-14.7 11.5-24.6V175.3c0-16.7 13-30.7 29.8-31.9l63.9-4.6c.7-.1 1.6-.1 2.3-.1 7.8 0 14.9 2.8 20.5 7.4 7 5.8 11.5 14.6 11.5 24.6"
302 - fill={`url(#${gradientId}-e)`}
303 - />
304 - <path
305 - d="M512 170.7v170.7c0 9.9-4.5 18.8-11.5 24.6l-128 106.7c7-5.9 11.5-14.7 11.5-24.6V175.3c0-16.7 13-30.7 29.8-31.9l63.9-4.6c.7-.1 1.6-.1 2.3-.1 7.8 0 14.9 2.8 20.5 7.4 7 5.8 11.5 14.6 11.5 24.6"
306 - fill={`url(#${gradientId}-f)`}
307 - fillOpacity=".7"
308 - />
309 - <path
310 - d="M512 170.7v170.7c0 9.9-4.5 18.8-11.5 24.6l-128 106.7c7-5.9 11.5-14.7 11.5-24.6V175.3c0-16.7 13-30.7 29.8-31.9l63.9-4.6c.7-.1 1.6-.1 2.3-.1 7.8 0 14.9 2.8 20.5 7.4 7 5.8 11.5 14.6 11.5 24.6"
311 - fill={`url(#${gradientId}-g)`}
312 - />
313 - <path
314 - d="M384 125.5c0 11.2-8.6 20.5-19.8 21.3-.5 0-1.1.1-1.6.1l-127.9 9.2-132.3 9.1-72.7 5.5c-6.9.4-13.2 3.1-18.2 7.4L116.1 73.4c4.7-4.7 10.9-8 17.8-9.1l100.8-15.1V21.3C234.7 9.6 244.3 0 256 0c5.8 0 11.1 2.3 14.9 6.1l33.4 32.6 16.9 16.5 40.3 39.3 16.1 15.8c4.1 3.9 6.4 9.4 6.4 15.2"
315 - fill={`url(#${gradientId}-h)`}
316 - />
317 - <path
318 - d="M384 125.5c0 11.2-8.6 20.5-19.8 21.3-.5 0-1.1.1-1.6.1l-127.9 9.2-132.3 9.1-72.7 5.5c-6.9.4-13.2 3.1-18.2 7.4L116.1 73.4c4.7-4.7 10.9-8 17.8-9.1l100.8-15.1V21.3C234.7 9.6 244.3 0 256 0c5.8 0 11.1 2.3 14.9 6.1l33.4 32.6 16.9 16.5 40.3 39.3 16.1 15.8c4.1 3.9 6.4 9.4 6.4 15.2"
319 - fill={`url(#${gradientId}-i)`}
320 - fillOpacity=".5"
321 - />
322 - </svg>
323 - );
324 -};
325 -
326 -export const BitbucketIcon: Icon = (props) => {
327 - const id = useId().replaceAll(":", "");
328 - const gradientId = `${id}-bitbucket-a`;
329 -
330 - return (
331 - <svg {...props} viewBox="8.4 14.39 2481.29 2231.21">
332 - <path fill="none" d="M989.97,1493.09h518.05l125.04-730.04H852.22L989.97,1493.09z" />
333 - <path
334 - fill="#2684FF"
335 - d="M88.92,14.4C45.02,13.83,8.97,48.96,8.41,92.86c-0.06,4.61,0.28,9.22,1.02,13.77l337.48,2048.72 c8.68,51.75,53.26,89.8,105.74,90.24h1619.03c39.38,0.5,73.19-27.9,79.49-66.78l337.49-2071.78c7.03-43.34-22.41-84.17-65.75-91.2 c-4.55-0.74-9.15-1.08-13.76-1.02L88.92,14.4z M1509.99,1495.09H993.24l-139.92-731h781.89L1509.99,1495.09z"
336 - />
337 - <linearGradient
338 - id={gradientId}
339 - gradientUnits="userSpaceOnUse"
340 - x1="945.1094"
341 - y1="1524.8389"
342 - x2="944.4923"
343 - y2="1524.1893"
344 - gradientTransform="matrix(1996.6343 0 0 -1480.3047 -1884485.625 2258195)"
345 - >
346 - <stop offset="0.18" stopColor="#0052CC" />
347 - <stop offset="1" stopColor="#2684FF" />
348 - </linearGradient>
349 - <path
350 - fill={`url(#${gradientId})`}
351 - d="M2379.27,763.06h-745.5l-125.12,730.42H992.31l-609.67,723.67c19.32,16.71,43.96,26,69.5,26.21h1618.13 c39.35,0.51,73.14-27.88,79.44-66.72L2379.27,763.06z"
352 - />
353 - </svg>
354 - );
355 -};
356 -
125 export const CursorIcon: Icon = ({ className, ...props }) => (
126 <svg
127 {...props}
@@ -680,24 +448,6 @@ export const ACPRegistryIcon: Icon = ({ className, ...props }) => (
448 </svg>
449 );
450
683 -export const ForgejoIcon: Icon = (props) => (
684 - <svg viewBox="0 0 212 212" aria-hidden="true" {...props}>
685 - <g transform="translate(6 6)" fill="none">
686 - <path d="M58 168 v-98 a50 50 0 0 1 50-50 h20" stroke="#ff6600" strokeWidth="25" />
687 - <path d="M58 168 v-30 a50 50 0 0 1 50-50 h20" stroke="#d40000" strokeWidth="25" />
688 - <circle cx="142" cy="20" r="18" stroke="#ff6600" strokeWidth="15" />
689 - <circle cx="142" cy="88" r="18" stroke="#d40000" strokeWidth="15" />
690 - <circle cx="58" cy="180" r="18" stroke="#d40000" strokeWidth="15" />
691 - </g>
692 - </svg>
693 -);
694 -
695 -export const GitCafeIcon: Icon = (props) => (
696 - <svg viewBox="0 0 64 64" aria-hidden="true" {...props}>
697 - <rect x="4.8" y="4.8" width="54.4" height="54.4" fill="#a78bfa" />
698 - </svg>
699 -);
700 -
451 export const MacScreenRecordingIcon: Icon = (props) => {
452 const gradientId = useId();
453 return (
apps/web/src/components/SourceControlIconArtwork.tsx new
+59
@@ -0,0 +1,59 @@
1 +import type { SourceControlIcon } from "@t3tools/client-runtime/source-control-clients";
2 +import { useId, type SVGProps } from "react";
3 +
4 +/** Draws a host's mark from its definition's artwork. */
5 +export function SourceControlIconArtwork({
6 + icon,
7 + ...props
8 +}: { readonly icon: SourceControlIcon } & SVGProps<SVGSVGElement>) {
9 + // Gradient ids are document-wide, and one page can show the same mark many times.
10 + const idPrefix = useId().replace(/[^\w-]/gu, "");
11 + const paint = (value: SourceControlIcon["paths"][number]["fill"]) =>
12 + value === undefined
13 + ? "none"
14 + : typeof value === "string"
15 + ? value
16 + : `url(#${idPrefix}-${value.gradient})`;
17 + return (
18 + <svg aria-hidden {...props} viewBox={icon.viewBox} fill="none">
19 + {icon.gradients ? (
20 + <defs>
21 + {icon.gradients.map((gradient) => (
22 + <linearGradient
23 + key={gradient.id}
24 + id={`${idPrefix}-${gradient.id}`}
25 + x1={gradient.x1}
26 + y1={gradient.y1}
27 + x2={gradient.x2}
28 + y2={gradient.y2}
29 + gradientTransform={gradient.transform}
30 + gradientUnits="userSpaceOnUse"
31 + >
32 + {gradient.stops.map((stop) => (
33 + <stop
34 + key={stop.offset}
35 + offset={stop.offset}
36 + stopColor={stop.color}
37 + stopOpacity={stop.opacity}
38 + />
39 + ))}
40 + </linearGradient>
41 + ))}
42 + </defs>
43 + ) : null}
44 + {icon.paths.map((path, index) => (
45 + <path
46 + // Paths repeat with different paints, so their data is not a key.
47 + // oxlint-disable-next-line react/no-array-index-key
48 + key={index}
49 + d={path.d}
50 + fill={paint(path.fill)}
51 + fillRule={path.fillRule}
52 + fillOpacity={path.fillOpacity}
53 + stroke={path.stroke}
54 + strokeWidth={path.strokeWidth}
55 + />
56 + ))}
57 + </svg>
58 + );
59 +}
apps/web/src/components/settings/ConnectionsSettings.tsx
+2 -2
@@ -37,7 +37,7 @@ import { searchableSetting } from "./settingsSearch";
37 import { EnvironmentIconMenu } from "./EnvironmentIconPicker";
38 import { FoldedSettingsSection } from "./FoldedSettingsSection";
39 import { LoadBalancingSettings } from "./LoadBalancingSettings";
40 -import { GitHubRoutingSettings } from "./GitHubRoutingSettings";
40 +import { PullRequestRoutingSettings } from "./PullRequestRoutingSettings";
41 import { Input } from "../ui/input";
42 import {
43 Dialog,
@@ -1533,7 +1533,7 @@ export function ConnectionsSettings() {
1533 />
1534 ) : null}
1535 <LoadBalancingSettings environments={loadBalancingEnvironments} />
1536 - <GitHubRoutingSettings environments={loadBalancingEnvironments} />
1536 + <PullRequestRoutingSettings environments={loadBalancingEnvironments} />
1537 </SettingsPageContainer>
1538 );
1539 }
apps/web/src/components/settings/IntegrationsSettings.tsx
+1 -1
@@ -780,7 +780,7 @@ function PullRequestLinksOpenInAppSetting() {
780 return (
781 <SettingsRow
782 {...searchableSetting("pull-request-links-open-in-app")}
783 - description="Clicking a pull request link opens it in T3 Code. Turn off to open pull request links like any other link, on GitHub or your git host."
783 + description="Clicking a pull request link opens it in T3 Code. Turn off to open pull request links like any other link, on your git host."
784 resetAction={
785 openInApp ? null : (
786 <SettingResetButton
apps/web/src/components/settings/PullRequestRoutingSettings.tsx renamed
+24 -19
@@ -1,9 +1,9 @@
1 import { useAtomValue } from "@effect/atom-react";
2 import { resolveEnvironmentMachineKind } from "@t3tools/contracts";
3 import {
4 - gitHubRoutingConnectionKey,
5 - gitHubRoutingPermissionFor,
6 - type GitHubRoutingPermission,
4 + pullRequestRoutingConnectionKey,
5 + pullRequestRoutingPermissionFor,
6 + type PullRequestRoutingPermission,
7 } from "@t3tools/client-runtime/connection";
8 import { useState } from "react";
9
@@ -16,7 +16,7 @@ import { EnvironmentRow, environmentTransportLabel } from "./EnvironmentRow";
16 import { FoldedSettingsSection } from "./FoldedSettingsSection";
17 import { searchableSetting } from "./settingsSearch";
18
19 -const options: ReadonlyArray<{ value: GitHubRoutingPermission; label: string }> = [
19 +const options: ReadonlyArray<{ value: PullRequestRoutingPermission; label: string }> = [
20 { value: "off", label: "Off" },
21 { value: "read", label: "Read PRs" },
22 { value: "read-write", label: "Read and act" },
@@ -24,8 +24,11 @@ const options: ReadonlyArray<{ value: GitHubRoutingPermission; label: string }>
24
25 const summaryLabels = { "read-write": "read and act", read: "read PRs" } as const;
26
27 -function summarizeGitHubRouting(
28 - entries: ReadonlyArray<{ readonly label: string; readonly permission: GitHubRoutingPermission }>,
27 +function summarizePullRequestRouting(
28 + entries: ReadonlyArray<{
29 + readonly label: string;
30 + readonly permission: PullRequestRoutingPermission;
31 + }>,
32 ): string | null {
33 const groups = (["read-write", "read"] as const).flatMap((permission) => {
34 const labels = entries.filter((entry) => entry.permission === permission);
@@ -36,36 +39,36 @@ function summarizeGitHubRouting(
39 return groups.length === 0 ? null : groups.join(" · ");
40 }
41
39 -export function GitHubRoutingSettings({
42 +export function PullRequestRoutingSettings({
43 environments,
44 }: {
45 readonly environments: ReadonlyArray<EnvironmentPresentation>;
46 }) {
44 - const permissions = useAtomValue(environmentCatalog.githubRoutingPermissionsValueAtom);
47 + const permissions = useAtomValue(environmentCatalog.pullRequestRoutingPermissionsValueAtom);
48 const catalog = useAtomValue(environmentCatalog.catalogValueAtom);
46 - const update = useAtomCommand(environmentCatalog.setGitHubRoutingPermission);
49 + const update = useAtomCommand(environmentCatalog.setPullRequestRoutingPermission);
50 const [saving, setSaving] = useState(false);
51
52 if (environments.length < 2) return null;
53
51 - const { id, title } = searchableSetting("github-routing");
54 + const { id, title } = searchableSetting("pull-request-routing");
55 return (
56 <FoldedSettingsSection
57 id={id}
58 title={title}
59 summary={
57 - summarizeGitHubRouting(
60 + summarizePullRequestRouting(
61 environments.map((environment) => ({
62 label: environment.label,
60 - permission: gitHubRoutingPermissionFor(environment.entry, permissions),
63 + permission: pullRequestRoutingPermissionFor(environment.entry, permissions),
64 })),
65 ) ?? "Off"
66 }
67 >
68 <p className="px-3 py-2.5 text-xs text-muted-foreground sm:px-4">
66 - Machines you trust here can read PR data through each other's GitHub access. Enable both
67 - machines. Read and act may use broader permissions than the machine that owns them. This
68 - applies only to this device.
69 + Machines you trust here can read PR data through each other's source control access. Enable
70 + both machines. Read and act may use broader permissions than the machine that owns them.
71 + This applies only to this device.
72 </p>
73 {environments.map((environment) => (
74 <EnvironmentRow
@@ -76,9 +79,11 @@ export function GitHubRoutingSettings({
79 >
80 <Select
81 items={options}
79 - value={gitHubRoutingPermissionFor(environment.entry, permissions)}
82 + value={pullRequestRoutingPermissionFor(environment.entry, permissions)}
83 disabled={
81 - !catalog.isReady || saving || gitHubRoutingConnectionKey(environment.entry) === null
84 + !catalog.isReady ||
85 + saving ||
86 + pullRequestRoutingConnectionKey(environment.entry) === null
87 }
88 onValueChange={(permission) => {
89 if (permission === null) return;
@@ -89,7 +94,7 @@ export function GitHubRoutingSettings({
94 if (result._tag === "Failure")
95 toastManager.add({
96 type: "error",
92 - title: "Could not save GitHub routing permission",
97 + title: "Could not save pull request routing permission",
98 });
99 },
100 );
@@ -98,7 +103,7 @@ export function GitHubRoutingSettings({
103 <SelectTrigger
104 size="xs"
105 className="w-32"
101 - aria-label={`${environment.label} GitHub routing`}
106 + aria-label={`${environment.label} pull request routing`}
107 >
108 <SelectValue />
109 </SelectTrigger>
apps/web/src/components/settings/SourceControlAccountSettings.logic.test.ts renamed
+10 -10
@@ -1,11 +1,11 @@
1 import { describe, expect, it } from "vite-plus/test";
2
3 -import { groupGitHubAccounts, nextGitHubHosts } from "./GitHubAccountSettings.logic";
3 +import { groupHostAccounts, nextHostAccountChoices } from "./SourceControlAccountSettings.logic";
4
5 -describe("groupGitHubAccounts", () => {
5 +describe("groupHostAccounts", () => {
6 it("groups logins by host, keeping broken and environment logins out of the picker", () => {
7 expect(
8 - groupGitHubAccounts([
8 + groupHostAccounts([
9 { host: "github.com", account: "personal", active: true, authenticated: true },
10 { host: "github.com", account: "work", active: false, authenticated: true },
11 { host: "github.com", account: "old", active: false, authenticated: false, error: "bad" },
@@ -39,17 +39,17 @@ describe("groupGitHubAccounts", () => {
39 });
40 });
41
42 -describe("nextGitHubHosts", () => {
43 - it("pins an account, keeps other hosts, and drops a host back on gh's defaults", () => {
42 +describe("nextHostAccountChoices", () => {
43 + it("pins an account, keeps other hosts, and drops a host back on the CLI defaults", () => {
44 const other = { "ghe.acme.test": { enabled: false } };
45 - const pinned = nextGitHubHosts(other, "github.com", { account: "work" });
45 + const pinned = nextHostAccountChoices(other, "github.com", { account: "work" });
46 expect(pinned).toEqual({ ...other, "github.com": { enabled: true, account: "work" } });
47
48 - const disabled = nextGitHubHosts(pinned, "github.com", { enabled: false });
48 + const disabled = nextHostAccountChoices(pinned, "github.com", { enabled: false });
49 expect(disabled["github.com"]).toEqual({ enabled: false, account: "work" });
50
51 - expect(nextGitHubHosts(disabled, "github.com", { enabled: true, account: null })).toEqual(
52 - other,
53 - );
51 + expect(
52 + nextHostAccountChoices(disabled, "github.com", { enabled: true, account: null }),
53 + ).toEqual(other);
54 });
55 });
apps/web/src/components/settings/SourceControlAccountSettings.logic.ts renamed
+10 -10
@@ -1,19 +1,19 @@
1 import type { SourceControlProviderAuth } from "@t3tools/contracts";
2 -import type { GitHubSettings } from "@t3tools/client-runtime/source-control-clients";
2 +import type { HostCredentialSettings } from "@t3tools/client-runtime/source-control-clients";
3
4 -export type GitHubDiscoveredAccount = NonNullable<SourceControlProviderAuth["accounts"]>[number];
4 +export type DiscoveredAccount = NonNullable<SourceControlProviderAuth["accounts"]>[number];
5
6 -export interface GitHubHostGroup {
6 +export interface HostAccountGroup {
7 readonly host: string;
8 readonly activeAccount: string | null;
9 readonly selectable: ReadonlyArray<string>;
10 - readonly broken: ReadonlyArray<GitHubDiscoveredAccount>;
10 + readonly broken: ReadonlyArray<DiscoveredAccount>;
11 readonly environmentVariable: string | null;
12 }
13
14 -export function groupGitHubAccounts(
15 - accounts: ReadonlyArray<GitHubDiscoveredAccount>,
16 -): ReadonlyArray<GitHubHostGroup> {
14 +export function groupHostAccounts(
15 + accounts: ReadonlyArray<DiscoveredAccount>,
16 +): ReadonlyArray<HostAccountGroup> {
17 const hosts = [...new Set(accounts.map((entry) => entry.host))];
18 return hosts.map((host) => {
19 const entries = accounts.filter((entry) => entry.host === host);
@@ -30,11 +30,11 @@ export function groupGitHubAccounts(
30 });
31 }
32
33 -export function nextGitHubHosts(
34 - current: GitHubSettings["hosts"],
33 +export function nextHostAccountChoices(
34 + current: HostCredentialSettings["hosts"],
35 host: string,
36 change: { readonly enabled?: boolean; readonly account?: string | null },
37 -): GitHubSettings["hosts"] {
37 +): HostCredentialSettings["hosts"] {
38 const previous = current[host];
39 const enabled = change.enabled ?? previous?.enabled ?? true;
40 const account = change.account === undefined ? previous?.account : (change.account ?? undefined);
apps/web/src/components/settings/SourceControlAccountSettings.tsx renamed
+36 -20
@@ -8,12 +8,16 @@ import { useAtomCommand } from "../../state/use-atom-command";
8 import { Button } from "../ui/button";
9 import { Select, SelectItem, SelectPopup, SelectTrigger, SelectValue } from "../ui/select";
10 import { Switch } from "../ui/switch";
11 -import { groupGitHubAccounts, nextGitHubHosts } from "./GitHubAccountSettings.logic";
12 -import { readGitHubSettings } from "@t3tools/client-runtime/source-control-clients";
11 +import { groupHostAccounts, nextHostAccountChoices } from "./SourceControlAccountSettings.logic";
12 +import {
13 + readHostCredentialSettings,
14 + type SourceControlClientDefinition,
15 + type SourceControlHostCredentials,
16 +} from "@t3tools/client-runtime/source-control-clients";
17 import { redactedPlaceholder } from "./RedactedSensitiveText";
18
15 -/** Sentinel select value for "follow gh's active login"; logins never contain spaces. */
16 -const ACTIVE_ACCOUNT = "active gh account";
19 +/** Sentinel select value for "follow the CLI's active login"; logins never contain spaces. */
20 +const ACTIVE_ACCOUNT = "active cli account";
21
22 function RedactedLogin(props: {
23 readonly account: string;
@@ -32,23 +36,30 @@ function RedactedLogin(props: {
36 );
37 }
38
35 -export function GitHubAccountSettings({
39 +export function SourceControlAccountSettings({
40 environmentId,
41 + definition,
42 + credentials,
43 auth,
44 onSaved,
45 }: {
46 readonly environmentId: EnvironmentId;
47 + readonly definition: SourceControlClientDefinition;
48 + readonly credentials: SourceControlHostCredentials;
49 readonly auth: SourceControlProviderAuth;
50 readonly onSaved: () => void;
51 }) {
44 - const github = useEnvironmentSettings(environmentId, readGitHubSettings);
45 - const hosts = github.hosts;
52 + const { hosts } = useEnvironmentSettings(environmentId, (settings) =>
53 + readHostCredentialSettings(settings, definition.kind),
54 + );
55 + const { label } = definition;
56 + const { cliName } = credentials;
57 const updateSettings = useAtomCommand(serverEnvironment.updateSettings, {
47 - label: "save GitHub account settings",
58 + label: `save ${label} account settings`,
59 });
60 const [saving, setSaving] = useState(false);
61 const [revealed, setRevealed] = useState(false);
51 - const groups = groupGitHubAccounts(auth.accounts ?? []);
62 + const groups = groupHostAccounts(auth.accounts ?? []);
63
64 const save = async (
65 host: string,
@@ -59,7 +70,9 @@ export function GitHubAccountSettings({
70 environmentId,
71 input: {
72 patch: {
62 - sourceControlHosts: { github: { hosts: nextGitHubHosts(hosts, host, change) } },
73 + sourceControlHosts: {
74 + [definition.kind]: { hosts: nextHostAccountChoices(hosts, host, change) },
75 + },
76 },
77 },
78 });
@@ -70,7 +83,8 @@ export function GitHubAccountSettings({
83 if (groups.length === 0) {
84 return (
85 <p className="text-xs text-muted-foreground">
73 - Sign in with <code className="rounded bg-muted px-1 py-px text-2xs">gh auth login</code> on
86 + Sign in with{" "}
87 + <code className="rounded bg-muted px-1 py-px text-2xs">{credentials.loginCommand}</code> on
88 the server host, then rescan to choose accounts here.
89 </p>
90 );
@@ -80,14 +94,14 @@ export function GitHubAccountSettings({
94 <div className="grid gap-4">
95 <div className="flex items-center justify-between gap-3">
96 <p className="max-w-2xl text-xs leading-relaxed text-muted-foreground">
83 - Choose which <code className="rounded bg-muted px-1 py-px text-2xs">gh</code> login each
84 - GitHub host uses, or turn a host off.
97 + Choose which <code className="rounded bg-muted px-1 py-px text-2xs">{cliName}</code> login
98 + each {label} host uses, or turn a host off.
99 </p>
100 <Button
101 size="icon-xs"
102 variant="ghost-muted"
103 onClick={() => setRevealed((current) => !current)}
90 - aria-label={revealed ? "Hide GitHub accounts" : "Reveal GitHub accounts"}
104 + aria-label={revealed ? `Hide ${label} accounts` : `Reveal ${label} accounts`}
105 aria-pressed={revealed}
106 >
107 {revealed ? <EyeOffIcon /> : <EyeIcon />}
@@ -114,7 +128,7 @@ export function GitHubAccountSettings({
128 <Switch
129 checked={enabled}
130 disabled={saving}
117 - aria-label={`Use GitHub on ${group.host}`}
131 + aria-label={`Use ${label} on ${group.host}`}
132 onCheckedChange={(checked) => void save(group.host, { enabled: checked })}
133 />
134 </div>
@@ -132,12 +146,12 @@ export function GitHubAccountSettings({
146 });
147 }}
148 >
135 - <SelectTrigger size="sm" aria-label={`GitHub account for ${group.host}`}>
149 + <SelectTrigger size="sm" aria-label={`${label} account for ${group.host}`}>
150 <SelectValue>
151 {(value: string) =>
152 value === ACTIVE_ACCOUNT ? (
153 <span className="flex min-w-0 items-center gap-1">
140 - Active gh account
154 + Active {cliName} account
155 {group.activeAccount ? (
156 <>
157 (
@@ -158,7 +172,7 @@ export function GitHubAccountSettings({
172 <SelectPopup align="end" alignItemWithTrigger={false}>
173 <SelectItem value={ACTIVE_ACCOUNT}>
174 <span className="flex min-w-0 items-center gap-1">
161 - Active gh account
175 + Active {cliName} account
176 {group.activeAccount ? (
177 <>
178 (<RedactedLogin revealed={revealed} account={group.activeAccount} />)
@@ -183,7 +197,7 @@ export function GitHubAccountSettings({
197 {stalePin ? (
198 <div className="flex items-center justify-between gap-3">
199 <p className="text-xs text-warning">
186 - The chosen login is no longer signed in, so the active gh login is used.
200 + The chosen login is no longer signed in, so the active {cliName} login is used.
201 </p>
202 <Button
203 size="xs"
@@ -201,7 +215,9 @@ export function GitHubAccountSettings({
215 className="flex min-w-0 flex-wrap items-center gap-1 text-xs text-muted-foreground/70"
216 >
217 <RedactedLogin revealed={revealed} account={entry.account} />
204 - <span>can't be used: {entry.error ?? "gh reports this login as invalid."}</span>
218 + <span>
219 + can't be used: {entry.error ?? `${cliName} reports this login as invalid.`}
220 + </span>
221 </p>
222 ))}
223 {group.environmentVariable ? (
apps/web/src/components/settings/SourceControlSettings.tsx
+33 -29
@@ -47,8 +47,8 @@ import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
47
48 import { GitIcon, JujutsuIcon, type Icon } from "../Icons";
49 import { SourceControlHostSettings } from "./SourceControlHostSettings";
50 -import { GitHubAccountSettings } from "./GitHubAccountSettings";
51 -import { GitHubTokenSettings } from "./GitHubTokenSettings";
50 +import { SourceControlAccountSettings } from "./SourceControlAccountSettings";
51 +import { SourceControlTokenSettings } from "./SourceControlTokenSettings";
52 import { RedactedSensitiveText } from "./RedactedSensitiveText";
53 import { SourceControlWritingSettingsSection } from "./SourceControlWritingSettings";
54 import {
@@ -280,8 +280,7 @@ function DiscoveryItemRow({
280 const [seenSearchTargetId, setSeenSearchTargetId] = useState<string | null>(null);
281 const targetsThisRow =
282 (item.kind === "git" && searchTargetId === searchableSetting("git-fetch-interval").id) ||
283 - searchTargetId === sourceControlHostSettingsSearchId(item.kind) ||
284 - (item.kind === "github" && searchTargetId === searchableSetting("github-accounts").id);
283 + searchTargetId === sourceControlHostSettingsSearchId(item.kind);
284 if (targetsThisRow && !isExpanded && seenSearchTargetId !== searchTargetId) {
285 setIsExpanded(true);
286 }
@@ -526,11 +525,37 @@ export function SourceControlSettingsPanel() {
525 const handleScan = () => {
526 discovery.refresh();
527 };
529 - const hostSettingsPanel = (kind: string) => {
530 - const definition = sourceControlClients.find(kind);
528 + const hostSettingsPanel = (item: SourceControlProviderDiscoveryItem) => {
529 + const definition = sourceControlClients.find(item.kind);
530 if (!definition?.settings || environmentId === null) return undefined;
531 + const { credentials } = definition;
532 + if (credentials) {
533 + return (
534 + <SettingsSearchTarget id={sourceControlHostSettingsSearchId(item.kind)}>
535 + <div className="grid gap-6">
536 + <SourceControlTokenSettings
537 + key={`token-${environmentId}`}
538 + environmentId={environmentId}
539 + definition={definition}
540 + credentials={credentials}
541 + onSaved={handleScan}
542 + />
543 + {item.status === "available" ? (
544 + <SourceControlAccountSettings
545 + key={environmentId}
546 + environmentId={environmentId}
547 + definition={definition}
548 + credentials={credentials}
549 + auth={item.auth}
550 + onSaved={handleScan}
551 + />
552 + ) : null}
553 + </div>
554 + </SettingsSearchTarget>
555 + );
556 + }
557 return (
533 - <SettingsSearchTarget id={sourceControlHostSettingsSearchId(kind)}>
558 + <SettingsSearchTarget id={sourceControlHostSettingsSearchId(item.kind)}>
559 <SourceControlHostSettings
560 // Drafts belong to one environment; switching must not carry them over.
561 key={environmentId}
@@ -605,28 +630,7 @@ export function SourceControlSettingsPanel() {
630 >
631 {result.sourceControlProviders.map((item) => (
632 <DiscoveryItemRow key={`provider:${item.kind}`} item={item}>
608 - {item.kind === "github" ? (
609 - <SettingsSearchTarget id={searchableSetting("github-accounts").id}>
610 - <div className="grid gap-6">
611 - {}
612 - <GitHubTokenSettings
613 - key={`token-${environmentId}`}
614 - environmentId={environmentId}
615 - onSaved={handleScan}
616 - />
617 - {item.status === "available" ? (
618 - <GitHubAccountSettings
619 - key={environmentId}
620 - environmentId={environmentId}
621 - auth={item.auth}
622 - onSaved={handleScan}
623 - />
624 - ) : null}
625 - </div>
626 - </SettingsSearchTarget>
627 - ) : (
628 - hostSettingsPanel(item.kind)
629 - )}
633 + {hostSettingsPanel(item)}
634 </DiscoveryItemRow>
635 ))}
636 </SettingsSection>
apps/web/src/components/settings/SourceControlTokenSettings.tsx renamed
+44 -33
@@ -3,7 +3,11 @@ import { ExternalLinkIcon } from "lucide-react";
3 import { useState } from "react";
4
5 import { useEnvironmentSettings } from "../../hooks/useSettings";
6 -import { readGitHubSettings } from "@t3tools/client-runtime/source-control-clients";
6 +import {
7 + readHostCredentialSettings,
8 + type SourceControlClientDefinition,
9 + type SourceControlHostCredentials,
10 +} from "@t3tools/client-runtime/source-control-clients";
11 import { serverEnvironment } from "../../state/server";
12 import { useAtomCommand } from "../../state/use-atom-command";
13 import { Button, InlineButton } from "../ui/button";
@@ -11,24 +15,25 @@ import { Input } from "../ui/input";
15 import { SecretInput } from "./SecretInput";
16 import { Label } from "../ui/label";
17
14 -const DEFAULT_HOST = "github.com";
15 -
16 -function newTokenUrl(host: string): string {
17 - return `https://${host}/settings/personal-access-tokens/new`;
18 -}
19 -
20 -export function GitHubTokenSettings({
18 +export function SourceControlTokenSettings({
19 environmentId,
20 + definition,
21 + credentials,
22 onSaved,
23 }: {
24 readonly environmentId: EnvironmentId;
25 + readonly definition: SourceControlClientDefinition;
26 + readonly credentials: SourceControlHostCredentials;
27 readonly onSaved: () => void;
28 }) {
27 - const { tokens } = useEnvironmentSettings(environmentId, readGitHubSettings);
29 + const { tokens } = useEnvironmentSettings(environmentId, (settings) =>
30 + readHostCredentialSettings(settings, definition.kind),
31 + );
32 const updateSettings = useAtomCommand(serverEnvironment.updateSettings, {
29 - label: "save GitHub token",
33 + label: `save ${definition.label} token`,
34 });
31 - const [host, setHost] = useState(DEFAULT_HOST);
35 + const defaultHost = definition.publicHost ?? "";
36 + const [host, setHost] = useState(defaultHost);
37 const [draft, setDraft] = useState("");
38 const [saving, setSaving] = useState(false);
39 const normalizedHost = host.trim().toLowerCase();
@@ -43,7 +48,9 @@ export function GitHubTokenSettings({
48 environmentId,
49 // The map travels whole: every other saved token as its redaction marker, which keeps it.
50 input: {
46 - patch: { sourceControlHosts: { github: { tokens: { ...tokens, [target]: token } } } },
51 + patch: {
52 + sourceControlHosts: { [definition.kind]: { tokens: { ...tokens, [target]: token } } },
53 + },
54 },
55 });
56 setSaving(false);
@@ -65,38 +72,42 @@ export function GitHubTokenSettings({
72 <fieldset disabled={saving} className="contents">
73 <p className="max-w-2xl text-xs leading-relaxed text-muted-foreground">
74 A token saved here is used before{" "}
68 - <code className="rounded bg-muted px-1 py-px text-2xs">GH_TOKEN</code> and the{" "}
69 - <code className="rounded bg-muted px-1 py-px text-2xs">gh</code> login, so GitHub works
70 - without the GitHub CLI. Give it read and write access to pull requests and contents.{" "}
71 - <InlineButton
72 - render={
73 - <a
74 - href={newTokenUrl(normalizedHost || DEFAULT_HOST)}
75 - target="_blank"
76 - rel="noreferrer noopener"
77 - />
78 - }
79 - >
80 - Create a token
81 - <ExternalLinkIcon aria-hidden className="size-3" />
82 - </InlineButton>
75 + <code className="rounded bg-muted px-1 py-px text-2xs">{credentials.tokenEnvVar}</code>{" "}
76 + and the{" "}
77 + <code className="rounded bg-muted px-1 py-px text-2xs">{credentials.cliName}</code> login,
78 + so {definition.label} works without the {credentials.cliLabel}. Give it{" "}
79 + {credentials.tokenAccess}.{" "}
80 + {normalizedHost || defaultHost ? (
81 + <InlineButton
82 + render={
83 + <a
84 + href={credentials.newTokenUrl(normalizedHost || defaultHost)}
85 + target="_blank"
86 + rel="noreferrer noopener"
87 + />
88 + }
89 + >
90 + Create a token
91 + <ExternalLinkIcon aria-hidden className="size-3" />
92 + </InlineButton>
93 + ) : null}
94 </p>
95 <div className="grid gap-3 sm:grid-cols-[12rem_1fr]">
96 <div className="grid gap-1.5">
86 - <Label htmlFor={`github-token-host-${environmentId}`}>Host</Label>
97 + <Label htmlFor={`${definition.kind}-token-host-${environmentId}`}>Host</Label>
98 <Input
88 - id={`github-token-host-${environmentId}`}
99 + id={`${definition.kind}-token-host-${environmentId}`}
100 autoComplete="off"
101 size="sm"
91 - placeholder={DEFAULT_HOST}
102 + placeholder={defaultHost}
103 value={host}
104 onChange={(event) => setHost(event.target.value)}
105 />
106 </div>
107 <div className="grid gap-1.5">
97 - <Label htmlFor={`github-token-${environmentId}`}>Token</Label>
108 + <Label htmlFor={`${definition.kind}-token-${environmentId}`}>Token</Label>
109 <SecretInput
99 - id={`github-token-${environmentId}`}
110 + id={`${definition.kind}-token-${environmentId}`}
111 size="sm"
112 configured={isSaved}
113 value={draft}
@@ -107,7 +118,7 @@ export function GitHubTokenSettings({
118 <div className="flex items-center justify-between gap-3">
119 <p className="text-xs text-muted-foreground">
120 {savedHosts.length === 0
110 - ? "No token saved; the server uses GH_TOKEN or the gh login."
121 + ? `No token saved; the server uses ${credentials.tokenEnvVar} or the ${credentials.cliName} login.`
122 : `Saved for ${savedHosts.join(", ")}.`}
123 </p>
124 <div className="flex shrink-0 gap-2">
apps/web/src/components/settings/settingsSearch.test.ts
+52 -1
@@ -1,5 +1,11 @@
1 import { describe, expect, it, vi } from "vite-plus/test";
2 -import { EnvironmentId } from "@t3tools/contracts";
2 +import {
3 + EnvironmentId,
4 + makeProviderSettingsSchema,
5 + SourceControlProviderKind,
6 +} from "@t3tools/contracts";
7 +import { UNKNOWN_SOURCE_CONTROL_CLIENT } from "@t3tools/client-runtime/source-control-clients";
8 +import * as Schema from "effect/Schema";
9
10 import {
11 filterAvailableSettingsSearchItems,
@@ -8,6 +14,8 @@ import {
14 isSettingsSearchScopeAvailable,
15 searchSettings,
16 SETTINGS_SEARCH_ITEMS,
17 + sourceControlHostSearchItems,
18 + sourceControlHostSettingsSearchId,
19 type SettingsSearchItem,
20 } from "./settingsSearch";
21
@@ -234,3 +242,46 @@ describe("auto-settlement search availability", () => {
242 ).toBe(true);
243 });
244 });
245 +
246 +describe("source control host search items", () => {
247 + const definition = {
248 + ...UNKNOWN_SOURCE_CONTROL_CLIENT,
249 + kind: SourceControlProviderKind.make("example"),
250 + label: "Example",
251 + searchKeywords: ["sample"],
252 + settings: makeProviderSettingsSchema({ apiToken: Schema.String }),
253 + };
254 +
255 + it("lists a host by its label, its keywords, and its settings fields", () => {
256 + const items = sourceControlHostSearchItems([UNKNOWN_SOURCE_CONTROL_CLIENT, definition]);
257 + expect(items.map((item) => item.title)).toEqual(["Example credentials"]);
258 + expect(searchSettings("sample apitoken", items).map((item) => item.id)).toEqual([
259 + sourceControlHostSettingsSearchId("example"),
260 + ]);
261 + });
262 +
263 + it("lists a host with credentials by its accounts, token and CLI", () => {
264 + const items = sourceControlHostSearchItems([
265 + {
266 + ...definition,
267 + credentials: {
268 + cliName: "ex",
269 + cliLabel: "Example CLI",
270 + loginCommand: "ex login",
271 + tokenEnvVar: "EX_TOKEN",
272 + tokenAccess: "access",
273 + newTokenUrl: (host) => `https://${host}/tokens`,
274 + },
275 + },
276 + ]);
277 + expect(items.map((item) => item.title)).toEqual(["Example accounts and token"]);
278 + expect(searchSettings("ex switch accounts", items)).toHaveLength(1);
279 + });
280 +
281 + it("finds the built-in hosts by their own words", () => {
282 + expect(searchSettings("codeberg").map((item) => item.id)).toContain("source-control");
283 + expect(searchSettings("ghes").map((item) => item.id)).toContain(
284 + sourceControlHostSettingsSearchId("github"),
285 + );
286 + });
287 +});
apps/web/src/components/settings/settingsSearch.ts
+53 -34
@@ -4,7 +4,10 @@ import { isMacPlatform, isWindowsPlatform, normalizeSearchText } from "~/lib/uti
4 import { STATIC_KEYBINDING_COMMANDS, type KeybindingCommand } from "@t3tools/contracts";
5 import type { EnvironmentId } from "@t3tools/contracts";
6 import type { EnvironmentConnectionPhase } from "@t3tools/client-runtime/connection";
7 -import { sourceControlClients } from "@t3tools/client-runtime/source-control-clients";
7 +import {
8 + sourceControlClients,
9 + type SourceControlClientDefinition,
10 +} from "@t3tools/client-runtime/source-control-clients";
11 import { DEFAULT_KEYBINDINGS } from "@t3tools/shared/keybindings";
12 import { commandLabel } from "./KeybindingsSettings.logic";
13 import {
@@ -111,22 +114,42 @@ export function sourceControlHostSettingsSearchId(kind: string) {
114 return `source-control-host-${kind}` as const;
115 }
116
114 -const SOURCE_CONTROL_HOST_SEARCH_ITEMS = sourceControlClients.definitions.flatMap((definition) =>
115 - definition.settings && definition.kind !== "github"
116 - ? [
117 - {
118 - id: sourceControlHostSettingsSearchId(definition.kind),
119 - title: `${definition.label} credentials`,
120 - to: "/settings/source-control" as const,
121 - searchTerms: [
122 - `${definition.label} ${Object.keys(definition.settings.fields).join(" ")} token credentials sign in`,
123 - ],
124 - environmentOnly: true,
125 - scope: "environment-defaults" as const,
126 - },
127 - ]
128 - : [],
129 -);
117 +/** Each host's own settings: its accounts and token, or the fields of its settings form. */
118 +export function sourceControlHostSearchItems(
119 + definitions: ReadonlyArray<SourceControlClientDefinition>,
120 +): ReadonlyArray<
121 + SettingsSearchItem & { readonly id: ReturnType<typeof sourceControlHostSettingsSearchId> }
122 +> {
123 + return definitions.flatMap((definition) => {
124 + if (!definition.settings) return [];
125 + const names = [definition.label, ...(definition.searchKeywords ?? [])].join(" ");
126 + const { credentials } = definition;
127 + return [
128 + {
129 + id: sourceControlHostSettingsSearchId(definition.kind),
130 + title: credentials
131 + ? `${definition.label} accounts and token`
132 + : `${definition.label} credentials`,
133 + to: "/settings/source-control" as const,
134 + searchTerms: [
135 + credentials
136 + ? `${names} ${credentials.cliName} account login user host switch multiple accounts disable sign in token personal access token pat api key credential`
137 + : `${names} ${Object.keys(definition.settings.fields).join(" ")} token credentials sign in`,
138 + ],
139 + environmentOnly: true,
140 + scope: "environment-defaults" as const,
141 + },
142 + ];
143 + });
144 +}
145 +
146 +/** For settings that apply to every host. */
147 +const SOURCE_CONTROL_HOST_LABELS = sourceControlClients.definitions
148 + .map((definition) => definition.label)
149 + .join(" ");
150 +const SOURCE_CONTROL_HOST_TERMS = sourceControlClients.definitions
151 + .flatMap((definition) => [definition.label, ...(definition.searchKeywords ?? [])])
152 + .join(" ");
153
154 export const SETTINGS_SEARCH_ITEMS = [
155 {
@@ -775,7 +798,9 @@ export const SETTINGS_SEARCH_ITEMS = [
798 id: "pull-request-links-open-in-app",
799 title: "Open pull requests in T3 Code",
800 to: "/settings/integrations",
778 - searchTerms: ["pr links github browser external click default pull request view panel"],
801 + searchTerms: [
802 + `pr links ${SOURCE_CONTROL_HOST_LABELS} browser external click default pull request view panel`,
803 + ],
804 },
805 {
806 id: "browser-auto-show-floating-preview",
@@ -795,7 +820,9 @@ export const SETTINGS_SEARCH_ITEMS = [
820 title: "Remove agent credits when merging",
821 to: "/settings/source-control",
822 scope: "project-defaults",
798 - searchTerms: ["pull request github squash co-authored-by attribution claude codex generated"],
823 + searchTerms: [
824 + `pull request ${SOURCE_CONTROL_HOST_LABELS} squash co-authored-by attribution claude codex generated`,
825 + ],
826 },
827 {
828 id: "pull-request-merge-method",
@@ -810,7 +837,7 @@ export const SETTINGS_SEARCH_ITEMS = [
837 to: "/settings/source-control",
838 scope: "environment-defaults",
839 searchTerms: [
813 - "version control git github gitlab forgejo gitea tea codeberg bitbucket azure devops hosting integrations credentials scan server environment",
840 + `version control git ${SOURCE_CONTROL_HOST_TERMS} hosting integrations credentials scan server environment`,
841 ],
842 },
843 {
@@ -831,17 +858,7 @@ export const SETTINGS_SEARCH_ITEMS = [
858 environmentOnly: true,
859 scope: "project-defaults",
860 },
834 - {
835 - id: "github-accounts",
836 - title: "GitHub accounts and token",
837 - to: "/settings/source-control",
838 - searchTerms: [
839 - "github gh account login user host enterprise ghes switch multiple accounts disable sign in token personal access token pat api key credential",
840 - ],
841 - environmentOnly: true,
842 - scope: "environment-defaults",
843 - },
844 - ...SOURCE_CONTROL_HOST_SEARCH_ITEMS,
861 + ...sourceControlHostSearchItems(sourceControlClients.definitions),
862 {
863 id: "source-control-writing-style",
864 title: "Source control writing style",
@@ -996,10 +1013,12 @@ export const SETTINGS_SEARCH_ITEMS = [
1013 ],
1014 },
1015 {
999 - id: "github-routing",
1000 - title: "GitHub sharing",
1016 + id: "pull-request-routing",
1017 + title: "Pull request sharing",
1018 to: "/settings/connections",
1002 - searchTerms: ["pull request trusted environments shared credentials permissions read actions"],
1019 + searchTerms: [
1020 + `pull request routing trusted environments shared credentials permissions read actions source control ${SOURCE_CONTROL_HOST_LABELS}`,
1021 + ],
1022 },
1023 {
1024 id: "archive",
apps/web/src/connection/storage.test.ts
+3 -3
@@ -219,8 +219,8 @@ describe("browser GitHub routing permissions", () => {
219 };
220 const firstBrowser = Object.assign(new EventTarget(), { localStorage });
221 const secondBrowser = Object.assign(new EventTarget(), { localStorage });
222 - const first = ConnectionStorage.makeBrowserGitHubRoutingPermissions(firstBrowser);
223 - const second = ConnectionStorage.makeBrowserGitHubRoutingPermissions(secondBrowser);
222 + const first = ConnectionStorage.makeBrowserPullRequestRoutingPermissions(firstBrowser);
223 + const second = ConnectionStorage.makeBrowserPullRequestRoutingPermissions(secondBrowser);
224 const entry = {
225 target: new PrimaryConnectionTarget({
226 environmentId: EnvironmentId.make("first"),
@@ -268,7 +268,7 @@ describe("browser GitHub routing permissions", () => {
268 expect(yield* second.get(entry)).toBe("off");
269 expect(yield* first.get(other)).toBe("read");
270 expect(
271 - yield* ConnectionStorage.makeBrowserGitHubRoutingPermissions(firstBrowser).get(entry),
271 + yield* ConnectionStorage.makeBrowserPullRequestRoutingPermissions(firstBrowser).get(entry),
272 ).toBe("off");
273
274 yield* first.set(entry, "read-write");
apps/web/src/connection/storage.ts
+33 -31
@@ -23,10 +23,10 @@ import {
23 ConnectionBlockedError,
24 CredentialStore,
25 ProfileStore,
26 - GitHubRoutingPermissions,
27 - StoredGitHubRoutingPermission,
28 - gitHubRoutingConnectionKey,
29 - gitHubRoutingPermissionFor,
26 + PullRequestRoutingPermissions,
27 + StoredPullRequestRoutingPermission,
28 + pullRequestRoutingConnectionKey,
29 + pullRequestRoutingPermissionFor,
30 } from "@t3tools/client-runtime/connection";
31 import { EnvironmentId, ServerConfig, ThreadId, VcsListRefsResult } from "@t3tools/contracts";
32 import * as Context from "effect/Context";
@@ -496,36 +496,38 @@ export const makeCatalogStore = Effect.fn("web.connectionStorage.makeCatalogStor
496 return { read, update } satisfies CatalogStore;
497 });
498
499 -const GITHUB_ROUTING_KEY_PREFIX = "t3code:github-routing:";
500 -const GITHUB_ROUTING_CHANGED = "t3code:github-routing-changed";
501 -const isStoredGitHubRoutingPermission = Schema.is(StoredGitHubRoutingPermission);
502 -const encodeStoredGitHubRoutingPermission = Schema.encodeSync(
503 - Schema.fromJsonString(StoredGitHubRoutingPermission),
499 +// The stored names predate the rename and stay, so a tab still on an older version and an
500 +// updated one read and revoke the same grants.
501 +const PULL_REQUEST_ROUTING_KEY_PREFIX = "t3code:github-routing:";
502 +const PULL_REQUEST_ROUTING_CHANGED = "t3code:github-routing-changed";
503 +const isStoredPullRequestRoutingPermission = Schema.is(StoredPullRequestRoutingPermission);
504 +const encodeStoredPullRequestRoutingPermission = Schema.encodeSync(
505 + Schema.fromJsonString(StoredPullRequestRoutingPermission),
506 );
507
508 /** Each grant has its own key so stale tabs and unrelated catalog saves cannot restore trust. */
507 -export function makeBrowserGitHubRoutingPermissions(
509 +export function makeBrowserPullRequestRoutingPermissions(
510 browser: Pick<Window, "localStorage"> & EventTarget = window,
511 ) {
510 - const read = (key: string): StoredGitHubRoutingPermission | null => {
512 + const read = (key: string): StoredPullRequestRoutingPermission | null => {
513 try {
514 const raw = browser.localStorage.getItem(key);
515 const value: unknown = raw === null ? null : JSON.parse(raw);
514 - return isStoredGitHubRoutingPermission(value) &&
515 - key === `${GITHUB_ROUTING_KEY_PREFIX}${value.environmentId}`
516 + return isStoredPullRequestRoutingPermission(value) &&
517 + key === `${PULL_REQUEST_ROUTING_KEY_PREFIX}${value.environmentId}`
518 ? value
519 : null;
520 } catch {
521 return null;
522 }
523 };
522 - const readAll = (): ReadonlyArray<StoredGitHubRoutingPermission> => {
524 + const readAll = (): ReadonlyArray<StoredPullRequestRoutingPermission> => {
525 try {
524 - const values: StoredGitHubRoutingPermission[] = [];
526 + const values: StoredPullRequestRoutingPermission[] = [];
527 const storage = browser.localStorage;
528 for (let index = 0; index < storage.length; index++) {
529 const key = storage.key(index);
528 - if (key?.startsWith(GITHUB_ROUTING_KEY_PREFIX)) {
530 + if (key?.startsWith(PULL_REQUEST_ROUTING_KEY_PREFIX)) {
531 const value = read(key);
532 if (value !== null) values.push(value);
533 }
@@ -535,46 +537,46 @@ export function makeBrowserGitHubRoutingPermissions(
537 return [];
538 }
539 };
538 - const write = (environmentId: EnvironmentId, value: StoredGitHubRoutingPermission | null) =>
540 + const write = (environmentId: EnvironmentId, value: StoredPullRequestRoutingPermission | null) =>
541 Effect.try({
542 try: () => {
541 - const key = `${GITHUB_ROUTING_KEY_PREFIX}${environmentId}`;
543 + const key = `${PULL_REQUEST_ROUTING_KEY_PREFIX}${environmentId}`;
544 if (value === null) browser.localStorage.removeItem(key);
543 - else browser.localStorage.setItem(key, encodeStoredGitHubRoutingPermission(value));
544 - browser.dispatchEvent(new Event(GITHUB_ROUTING_CHANGED));
545 + else browser.localStorage.setItem(key, encodeStoredPullRequestRoutingPermission(value));
546 + browser.dispatchEvent(new Event(PULL_REQUEST_ROUTING_CHANGED));
547 },
546 - catch: (cause) => catalogError("save GitHub routing permissions in", cause),
548 + catch: (cause) => catalogError("save pull request routing permissions in", cause),
549 });
548 - return GitHubRoutingPermissions.of({
550 + return PullRequestRoutingPermissions.of({
551 get: (entry) =>
552 Effect.sync(() => {
551 - const value = read(`${GITHUB_ROUTING_KEY_PREFIX}${entry.target.environmentId}`);
552 - return gitHubRoutingPermissionFor(entry, value === null ? [] : [value]);
553 + const value = read(`${PULL_REQUEST_ROUTING_KEY_PREFIX}${entry.target.environmentId}`);
554 + return pullRequestRoutingPermissionFor(entry, value === null ? [] : [value]);
555 }),
554 - changes: Stream.callback<ReadonlyArray<StoredGitHubRoutingPermission>>((queue) =>
556 + changes: Stream.callback<ReadonlyArray<StoredPullRequestRoutingPermission>>((queue) =>
557 Effect.acquireRelease(
558 Effect.sync(() => {
559 const listener = (event: Event) => {
560 if (event.type === "storage") {
561 const key = (event as StorageEvent).key;
560 - if (key !== null && !key?.startsWith(GITHUB_ROUTING_KEY_PREFIX)) return;
562 + if (key !== null && !key?.startsWith(PULL_REQUEST_ROUTING_KEY_PREFIX)) return;
563 }
564 Queue.offerUnsafe(queue, readAll());
565 };
566 browser.addEventListener("storage", listener);
565 - browser.addEventListener(GITHUB_ROUTING_CHANGED, listener);
567 + browser.addEventListener(PULL_REQUEST_ROUTING_CHANGED, listener);
568 Queue.offerUnsafe(queue, readAll());
569 return listener;
570 }),
571 (listener) =>
572 Effect.sync(() => {
573 browser.removeEventListener("storage", listener);
572 - browser.removeEventListener(GITHUB_ROUTING_CHANGED, listener);
574 + browser.removeEventListener(PULL_REQUEST_ROUTING_CHANGED, listener);
575 }),
576 ).pipe(Effect.asVoid),
577 ),
578 set: (entry, permission) => {
577 - const connectionKey = gitHubRoutingConnectionKey(entry);
579 + const connectionKey = pullRequestRoutingConnectionKey(entry);
580 if (connectionKey === null)
581 return Effect.fail(
582 new ConnectionBlockedError({
@@ -623,7 +625,7 @@ export const layer = Layer.effectContext(
625 (owned) => owned.close,
626 );
627 const catalog = yield* makeCatalogStore(makeCatalogBackend(database));
626 - const githubRoutingPermissions = makeBrowserGitHubRoutingPermissions();
628 + const pullRequestRoutingPermissions = makeBrowserPullRequestRoutingPermissions();
629 // Remembers each thread row's encoding, so a save only encodes rows that changed.
630 const encodeStoredShellSnapshot = makeStoredShellSnapshotEncoder({
631 yieldToHost: yieldToBrowserTask,
@@ -930,7 +932,7 @@ export const layer = Layer.effectContext(
932 });
933
934 return Context.make(Persistence.ConnectionTargetStore, targetStore).pipe(
933 - Context.add(GitHubRoutingPermissions, githubRoutingPermissions),
935 + Context.add(PullRequestRoutingPermissions, pullRequestRoutingPermissions),
936 Context.add(Persistence.ConnectionRegistrationStore, registrationStore),
937 Context.add(ProfileStore.ConnectionProfileStore, profileStore),
938 Context.add(CredentialStore.ConnectionCredentialStore, credentialStore),
apps/web/src/sourceControlPresentation.tsx renamed
+13 -17
@@ -5,31 +5,27 @@ import type {
5 ChangeRequestTerminology,
6 SourceControlClientDefinition,
7 } from "@t3tools/client-runtime/source-control-clients";
8 -import {
9 - AzureDevOpsIcon,
10 - BitbucketIcon,
11 - ForgejoIcon,
12 - GitCafeIcon,
13 - GitHubIcon,
14 - GitLabIcon,
15 -} from "./components/Icons";
8 import { PullRequestGlyph } from "~/components/pullRequest/pullRequestIcons";
9 +import { SourceControlIconArtwork } from "./components/SourceControlIconArtwork";
10
11 export type { ChangeRequestTerminology } from "@t3tools/client-runtime/source-control-clients";
12
13 type SourceControlIcon = ElementType<{ className?: string }>;
14
22 -const SOURCE_CONTROL_ICONS: Partial<Record<string, SourceControlIcon>> = {
23 - github: GitHubIcon,
24 - gitlab: GitLabIcon,
25 - forgejo: ForgejoIcon,
26 - bitbucket: BitbucketIcon,
27 - "azure-devops": AzureDevOpsIcon,
28 - gitcafe: GitCafeIcon,
29 -};
15 +const SOURCE_CONTROL_ICONS = new WeakMap<SourceControlClientDefinition, SourceControlIcon>();
16
17 +/** One component per definition, so a host's icon keeps its identity across renders. */
18 export function sourceControlIcon(definition: SourceControlClientDefinition): SourceControlIcon {
32 - return SOURCE_CONTROL_ICONS[definition.icon] ?? PullRequestGlyph.pullRequest;
19 + const artwork = definition.icon;
20 + if (artwork === null) return PullRequestGlyph.pullRequest;
21 + let Icon = SOURCE_CONTROL_ICONS.get(definition);
22 + if (Icon === undefined) {
23 + Icon = (props: { className?: string }) => (
24 + <SourceControlIconArtwork {...props} icon={artwork} />
25 + );
26 + SOURCE_CONTROL_ICONS.set(definition, Icon);
27 + }
28 + return Icon;
29 }
30
31 export interface SourceControlPresentation {
docs/internals/remote.md
+1 -1
@@ -54,7 +54,7 @@ dropped, which is how a changed LAN address replaces the old one; routes the
54 user saved are never touched. The reported addresses are hints like any advertised endpoint, so a
55 learned route still has to answer as this environment before it is used.
56
57 -GitHub routing trust covers the whole route list. Adding or changing a route
57 +Pull request routing trust covers the whole route list. Adding or changing a route
58 revokes it; reordering does not, because the same addresses remain trusted.
59
60 ## Hosted web is a client
docs/user/source-control.md
+6 -5
@@ -183,15 +183,16 @@ Press **Escape** before releasing to cancel. Failed closes stay in the list so y
183 GitHub, GitLab, and Azure DevOps support auto-merge while checks are outstanding. GitHub also
184 supports approving waiting fork workflows and opening a revert pull request for a merged change.
185
186 -GitHub sharing is off by default. In Settings → Connections → GitHub sharing (Environments on mobile), choose
187 -**Read PRs** or **Read and act** for each environment you trust to share GitHub access.
186 +Pull request sharing is off by default. In Settings → Connections → Pull request sharing (Pull
187 +request routing under Environments on mobile), choose **Read PRs** or **Read and act** for each
188 +environment you trust to share its source control access.
189 Enable both the original environment and the environment answering its requests on this client.
189 -**Read and act** can use broader GitHub permissions than the original environment's credential;
190 +**Read and act** can use broader permissions than the original environment's credential;
191 only enable it for environments you control and trust. Changing a saved endpoint or removing an
192 environment clears its permission.
193
193 -GitHub review details, linked PR status, and permitted review actions can then use another
194 -connected environment signed in to the same GitHub account. Each needs a project on that host.
194 +Review details, linked PR status, and permitted review actions can then use another connected
195 +environment signed in to the same account on the same host. Each needs a project on that host.
196 A connected local environment is preferred for actions and can answer slow or failed reads.
197 Browsers and mobile clients need a paired environment to use its GitHub credentials.
198 Credentials stay on their machines. Previously verified credentials remain usable for routing
packages/client-runtime/src/connection/index.ts
+1 -1
@@ -4,7 +4,7 @@ export * as Connectivity from "./connectivity.ts";
4 export * as CredentialStore from "./credentialStore.ts";
5 export { type ConnectionDriverProgress, type EnvironmentConnectionLease } from "./driver.ts";
6 export * from "./errors.ts";
7 -export * from "./githubRoutingPermissions.ts";
7 +export * from "./pullRequestRoutingPermissions.ts";
8 export * from "./hostFreeze.ts";
9 export * as Connection from "./layer.ts";
10 export * from "./model.ts";
packages/client-runtime/src/connection/pullRequestRoutingPermissions.ts renamed
+24 -24
@@ -10,21 +10,21 @@ import * as SubscriptionRef from "effect/SubscriptionRef";
10 import type { ConnectionCatalogEntry } from "./catalog.ts";
11 import { ConnectionBlockedError, type ConnectionAttemptError } from "./model.ts";
12
13 -export const GitHubRoutingPermission = Schema.Literals(["off", "read", "read-write"]);
14 -export type GitHubRoutingPermission = typeof GitHubRoutingPermission.Type;
15 -export const StoredGitHubRoutingPermission = Schema.Struct({
13 +export const PullRequestRoutingPermission = Schema.Literals(["off", "read", "read-write"]);
14 +export type PullRequestRoutingPermission = typeof PullRequestRoutingPermission.Type;
15 +export const StoredPullRequestRoutingPermission = Schema.Struct({
16 environmentId: EnvironmentId,
17 connectionKey: Schema.String,
18 - permission: GitHubRoutingPermission,
18 + permission: PullRequestRoutingPermission,
19 });
20 -export type StoredGitHubRoutingPermission = typeof StoredGitHubRoutingPermission.Type;
20 +export type StoredPullRequestRoutingPermission = typeof StoredPullRequestRoutingPermission.Type;
21
22 /**
23 * Trust belongs to the saved endpoints, never to an environment id advertised
24 * by a server alone. With several routes the key covers all of them, sorted so
25 * reordering keeps trust but adding or changing an address revokes it.
26 */
27 -export function gitHubRoutingConnectionKey(entry: ConnectionCatalogEntry): string | null {
27 +export function pullRequestRoutingConnectionKey(entry: ConnectionCatalogEntry): string | null {
28 const routes = [
29 { target: entry.target, profile: entry.profile },
30 ...(entry.alternateRoutes ?? []),
@@ -75,25 +75,25 @@ function routeConnectionKey(
75 }
76 }
77
78 -export function gitHubRoutingPermissionFor(
78 +export function pullRequestRoutingPermissionFor(
79 entry: ConnectionCatalogEntry,
80 - permissions: ReadonlyArray<StoredGitHubRoutingPermission>,
81 -): GitHubRoutingPermission {
82 - const key = gitHubRoutingConnectionKey(entry);
80 + permissions: ReadonlyArray<StoredPullRequestRoutingPermission>,
81 +): PullRequestRoutingPermission {
82 + const key = pullRequestRoutingConnectionKey(entry);
83 return key === null
84 ? "off"
85 : (permissions.find((permission) => permission.connectionKey === key)?.permission ?? "off");
86 }
87
88 -export class GitHubRoutingPermissions extends Context.Reference<{
89 - readonly get: (entry: ConnectionCatalogEntry) => Effect.Effect<GitHubRoutingPermission>;
90 - readonly changes: Stream.Stream<ReadonlyArray<StoredGitHubRoutingPermission>>;
88 +export class PullRequestRoutingPermissions extends Context.Reference<{
89 + readonly get: (entry: ConnectionCatalogEntry) => Effect.Effect<PullRequestRoutingPermission>;
90 + readonly changes: Stream.Stream<ReadonlyArray<StoredPullRequestRoutingPermission>>;
91 readonly set: (
92 entry: ConnectionCatalogEntry,
93 - permission: GitHubRoutingPermission,
93 + permission: PullRequestRoutingPermission,
94 ) => Effect.Effect<void, ConnectionAttemptError>;
95 readonly forget: (environmentId: EnvironmentId) => Effect.Effect<void, ConnectionAttemptError>;
96 -}>("@t3tools/client-runtime/connection/GitHubRoutingPermissions", {
96 +}>("@t3tools/client-runtime/connection/PullRequestRoutingPermissions", {
97 defaultValue: () => ({
98 get: () => Effect.succeed("off"),
99 changes: Stream.succeed([]),
@@ -101,29 +101,29 @@ export class GitHubRoutingPermissions extends Context.Reference<{
101 Effect.fail(
102 new ConnectionBlockedError({
103 reason: "unsupported",
104 - detail: "GitHub routing preferences are unavailable on this client.",
104 + detail: "Pull request routing preferences are unavailable on this client.",
105 }),
106 ),
107 forget: () => Effect.void,
108 }),
109 }) {}
110
111 -export const makeGitHubRoutingPermissions = Effect.fn("makeGitHubRoutingPermissions")(
111 +export const makePullRequestRoutingPermissions = Effect.fn("makePullRequestRoutingPermissions")(
112 function* (storage: {
113 readonly read: Effect.Effect<
114 - ReadonlyArray<StoredGitHubRoutingPermission>,
114 + ReadonlyArray<StoredPullRequestRoutingPermission>,
115 ConnectionAttemptError
116 >;
117 readonly write: (
118 - permissions: ReadonlyArray<StoredGitHubRoutingPermission>,
118 + permissions: ReadonlyArray<StoredPullRequestRoutingPermission>,
119 ) => Effect.Effect<void, ConnectionAttemptError>;
120 }) {
121 const state = yield* SubscriptionRef.make(yield* storage.read);
122 const lock = yield* Semaphore.make(1);
123 const update = (
124 transform: (
125 - current: ReadonlyArray<StoredGitHubRoutingPermission>,
126 - ) => ReadonlyArray<StoredGitHubRoutingPermission>,
125 + current: ReadonlyArray<StoredPullRequestRoutingPermission>,
126 + ) => ReadonlyArray<StoredPullRequestRoutingPermission>,
127 ) =>
128 lock.withPermits(1)(
129 Effect.gen(function* () {
@@ -134,14 +134,14 @@ export const makeGitHubRoutingPermissions = Effect.fn("makeGitHubRoutingPermissi
134 yield* SubscriptionRef.set(state, next);
135 }),
136 );
137 - return GitHubRoutingPermissions.of({
137 + return PullRequestRoutingPermissions.of({
138 get: (entry) =>
139 SubscriptionRef.get(state).pipe(
140 - Effect.map((permissions) => gitHubRoutingPermissionFor(entry, permissions)),
140 + Effect.map((permissions) => pullRequestRoutingPermissionFor(entry, permissions)),
141 ),
142 changes: SubscriptionRef.changes(state),
143 set: (entry, permission) => {
144 - const connectionKey = gitHubRoutingConnectionKey(entry);
144 + const connectionKey = pullRequestRoutingConnectionKey(entry);
145 if (connectionKey === null)
146 return Effect.fail(
147 new ConnectionBlockedError({
packages/client-runtime/src/connection/registry.test.ts
+40 -35
@@ -57,10 +57,10 @@ import * as Persistence from "../platform/persistence.ts";
57 import * as ConnectionProfileStore from "./profileStore.ts";
58 import * as EnvironmentRegistry from "./registry.ts";
59 import {
60 - GitHubRoutingPermissions,
61 - type StoredGitHubRoutingPermission,
62 - makeGitHubRoutingPermissions,
63 -} from "./githubRoutingPermissions.ts";
60 + PullRequestRoutingPermissions,
61 + type StoredPullRequestRoutingPermission,
62 + makePullRequestRoutingPermissions,
63 +} from "./pullRequestRoutingPermissions.ts";
64 import * as RpcSession from "../rpc/session.ts";
65 import * as EnvironmentSupervisor from "./supervisor.ts";
66 import * as ConnectionWakeups from "./wakeups.ts";
@@ -1553,7 +1553,7 @@ describe("EnvironmentRegistry", () => {
1553 label: "Shadowed relay environment",
1554 });
1555 const harness = yield* makeHarness([shadowedTarget]);
1556 - const permissions = yield* makeGitHubRoutingPermissions({
1556 + const permissions = yield* makePullRequestRoutingPermissions({
1557 read: Effect.succeed([]),
1558 write: () => Effect.void,
1559 });
@@ -1578,7 +1578,7 @@ describe("EnvironmentRegistry", () => {
1578 expect(hasRoutes(yield* Ref.get(harness.storedTargets), TARGET.environmentId)).toBe(false);
1579 }).pipe(
1580 Effect.provide(harness.layer),
1581 - Effect.provideService(GitHubRoutingPermissions, permissions),
1581 + Effect.provideService(PullRequestRoutingPermissions, permissions),
1582 Effect.scoped,
1583 );
1584 }),
@@ -1765,7 +1765,7 @@ describe("EnvironmentRegistry", () => {
1765 Effect.gen(function* () {
1766 const harness = yield* makeHarness([]);
1767 let failWrites = false;
1768 - const permissions = yield* makeGitHubRoutingPermissions({
1768 + const permissions = yield* makePullRequestRoutingPermissions({
1769 read: Effect.succeed([]),
1770 write: () =>
1771 failWrites
@@ -1822,7 +1822,7 @@ describe("EnvironmentRegistry", () => {
1822 expect(yield* permissions.get(entry)).toBe("off");
1823 }).pipe(
1824 Effect.provide(harness.layer),
1825 - Effect.provideService(GitHubRoutingPermissions, permissions),
1825 + Effect.provideService(PullRequestRoutingPermissions, permissions),
1826 Effect.scoped,
1827 );
1828 }),
@@ -2021,33 +2021,38 @@ describe("EnvironmentRegistry routes", () => {
2021 }),
2022 );
2023
2024 - it.effect("revokes GitHub routing trust when a route is added but keeps it on reorder", () =>
2025 - Effect.gen(function* () {
2026 - const harness = yield* makeHarness([RELAY_TARGET]);
2027 - let stored: ReadonlyArray<StoredGitHubRoutingPermission> = [];
2028 - const permissions = yield* makeGitHubRoutingPermissions({
2029 - read: Effect.sync(() => stored),
2030 - write: (next) => Effect.sync(() => void (stored = next)),
2031 - });
2032 - yield* Effect.gen(function* () {
2033 - const registry = yield* EnvironmentRegistry.EnvironmentRegistry;
2034 - const current = () =>
2035 - SubscriptionRef.get(registry.entries).pipe(
2036 - Effect.map((entries) => entries.get(RELAY_TARGET.environmentId)!),
2037 - );
2038 - yield* permissions.set(yield* current(), "read");
2039 - yield* registry.register(lanRegistration());
2040 - expect(yield* permissions.get(yield* current())).toBe("off");
2041 -
2042 - yield* permissions.set(yield* current(), "read");
2043 - yield* registry.reorderRoutes(LAN_TARGET.environmentId, ["relay", LAN_TARGET.connectionId]);
2044 - expect(yield* permissions.get(yield* current())).toBe("read");
2045 - }).pipe(
2046 - Effect.provide(harness.layer),
2047 - Effect.provideService(GitHubRoutingPermissions, permissions),
2048 - Effect.scoped,
2049 - );
2050 - }),
2024 + it.effect(
2025 + "revokes pull request routing trust when a route is added but keeps it on reorder",
2026 + () =>
2027 + Effect.gen(function* () {
2028 + const harness = yield* makeHarness([RELAY_TARGET]);
2029 + let stored: ReadonlyArray<StoredPullRequestRoutingPermission> = [];
2030 + const permissions = yield* makePullRequestRoutingPermissions({
2031 + read: Effect.sync(() => stored),
2032 + write: (next) => Effect.sync(() => void (stored = next)),
2033 + });
2034 + yield* Effect.gen(function* () {
2035 + const registry = yield* EnvironmentRegistry.EnvironmentRegistry;
2036 + const current = () =>
2037 + SubscriptionRef.get(registry.entries).pipe(
2038 + Effect.map((entries) => entries.get(RELAY_TARGET.environmentId)!),
2039 + );
2040 + yield* permissions.set(yield* current(), "read");
2041 + yield* registry.register(lanRegistration());
2042 + expect(yield* permissions.get(yield* current())).toBe("off");
2043 +
2044 + yield* permissions.set(yield* current(), "read");
2045 + yield* registry.reorderRoutes(LAN_TARGET.environmentId, [
2046 + "relay",
2047 + LAN_TARGET.connectionId,
2048 + ]);
2049 + expect(yield* permissions.get(yield* current())).toBe("read");
2050 + }).pipe(
2051 + Effect.provide(harness.layer),
2052 + Effect.provideService(PullRequestRoutingPermissions, permissions),
2053 + Effect.scoped,
2054 + );
2055 + }),
2056 );
2057
2058 it.effect("loads saved routes grouped by environment, in saved order", () =>
packages/client-runtime/src/connection/registry.ts
+16 -15
@@ -40,9 +40,9 @@ import * as EnvironmentSupervisor from "./supervisor.ts";
40 import * as ConnectionDriver from "./driver.ts";
41 import * as ConnectionWakeups from "./wakeups.ts";
42 import {
43 - GitHubRoutingPermissions,
44 - gitHubRoutingConnectionKey,
45 -} from "./githubRoutingPermissions.ts";
43 + PullRequestRoutingPermissions,
44 + pullRequestRoutingConnectionKey,
45 +} from "./pullRequestRoutingPermissions.ts";
46 import {
47 RELAY_ROUTE_ID,
48 connectionRouteId,
@@ -208,7 +208,7 @@ export const make = Effect.gen(function* () {
208 const ownedDataCleanup = yield* Persistence.EnvironmentOwnedDataCleanup;
209 const profiles = yield* ConnectionProfileStore.ConnectionProfileStore;
210 const credentials = yield* ConnectionCredentialStore.ConnectionCredentialStore;
211 - const githubRoutingPermissions = yield* GitHubRoutingPermissions;
211 + const pullRequestRoutingPermissions = yield* PullRequestRoutingPermissions;
212 const connectivity = yield* Connectivity.Connectivity;
213 const driver = yield* ConnectionDriver.ConnectionDriver;
214 const wakeups = yield* ConnectionWakeups.ConnectionWakeups;
@@ -508,7 +508,7 @@ export const make = Effect.gen(function* () {
508 environmentId: EnvironmentId,
509 operation: "register-connection" | "set-connection-routes",
510 ) =>
511 - githubRoutingPermissions.forget(environmentId).pipe(
511 + pullRequestRoutingPermissions.forget(environmentId).pipe(
512 Effect.mapError(
513 (error) =>
514 new Persistence.ConnectionPersistenceError({
@@ -522,12 +522,12 @@ export const make = Effect.gen(function* () {
522 connectionRoutes(entry).map((route) => route.target as PersistedConnectionTarget);
523
524 /**
525 - * GitHub trust and an unsupported verdict both belong to the saved addresses: a changed set may
525 + * Pull request routing trust and an unsupported verdict both belong to the saved addresses: a changed set may
526 * reach a different server, so both are dropped and the next connection decides.
527 */
528 const withRoutes = (previous: ConnectionCatalogEntry, routes: ReadonlyArray<ConnectionRoute>) => {
529 const next = entryWithRoutes(previous, routes);
530 - if (gitHubRoutingConnectionKey(previous) === gitHubRoutingConnectionKey(next)) {
530 + if (pullRequestRoutingConnectionKey(previous) === pullRequestRoutingConnectionKey(next)) {
531 return { entry: next, addressesChanged: false };
532 }
533 const { unsupportedReason: _reason, serverUpdateRequired: _update, ...rest } = next;
@@ -604,19 +604,20 @@ export const make = Effect.gen(function* () {
604 const previous = (yield* SubscriptionRef.get(entries)).get(target.environmentId);
605 const entry: ConnectionCatalogEntry =
606 previous?.unsupportedReason !== undefined &&
607 - gitHubRoutingConnectionKey(previous) === gitHubRoutingConnectionKey(registered)
607 + pullRequestRoutingConnectionKey(previous) ===
608 + pullRequestRoutingConnectionKey(registered)
609 ? { ...registered, ...unsupportedState(previous) }
610 : registered;
611 const persisted = (yield* Ref.get(persistedEnvironmentIds)).has(target.environmentId);
612 if (
613 persisted ||
614 (previous !== undefined &&
614 - gitHubRoutingConnectionKey(previous) !== gitHubRoutingConnectionKey(entry))
615 + pullRequestRoutingConnectionKey(previous) !== pullRequestRoutingConnectionKey(entry))
616 ) {
616 - const revoked = yield* githubRoutingPermissions.forget(target.environmentId).pipe(
617 + const revoked = yield* pullRequestRoutingPermissions.forget(target.environmentId).pipe(
618 Effect.tapError((error) =>
619 Effect.logWarning(
619 - "Could not clear GitHub routing permission for a platform environment.",
620 + "Could not clear pull request routing permission for a platform environment.",
621 {
622 environmentId: target.environmentId,
623 error,
@@ -725,10 +726,10 @@ export const make = Effect.gen(function* () {
726 environmentId,
727 Effect.gen(function* () {
728 const entry = (yield* SubscriptionRef.get(entries)).get(environmentId);
728 - const revoked = yield* githubRoutingPermissions.forget(environmentId).pipe(
729 + const revoked = yield* pullRequestRoutingPermissions.forget(environmentId).pipe(
730 Effect.tapError((error) =>
731 Effect.logWarning(
731 - "Could not clear GitHub routing permission after platform removal.",
732 + "Could not clear pull request routing permission after platform removal.",
733 {
734 environmentId,
735 error,
@@ -811,7 +812,7 @@ export const make = Effect.gen(function* () {
812 }
813 const entry = yield* getEntry(environmentId);
814
814 - yield* githubRoutingPermissions.forget(environmentId);
815 + yield* pullRequestRoutingPermissions.forget(environmentId);
816 yield* registrations.remove(environmentId);
817 yield* Ref.update(persistedEnvironmentIds, (current) => {
818 const next = new Set(current);
@@ -867,7 +868,7 @@ export const make = Effect.gen(function* () {
868 typeof globalThis.location === "undefined" || globalThis.location.protocol !== "https:";
869
870 /**
870 - * Learned routes reuse the active route's credential, so they do not revoke GitHub routing
871 + * Learned routes reuse the active route's credential, so they do not revoke pull request routing
872 * trust the way a newly paired address does.
873 */
874 const learnRoutes = Effect.fn("EnvironmentRegistry.learnRoutes")(function* (input: {
packages/client-runtime/src/connection/resolver.test.ts
+7 -7
@@ -29,10 +29,10 @@ import {
29 import * as ConnectionProfileStore from "./profileStore.ts";
30 import * as RpcHttp from "../rpc/http.ts";
31 import {
32 - GitHubRoutingPermissions,
33 - gitHubRoutingConnectionKey,
34 - makeGitHubRoutingPermissions,
35 -} from "./githubRoutingPermissions.ts";
32 + PullRequestRoutingPermissions,
33 + pullRequestRoutingConnectionKey,
34 + makePullRequestRoutingPermissions,
35 +} from "./pullRequestRoutingPermissions.ts";
36
37 const ENVIRONMENT_ID = EnvironmentId.make("environment-1");
38 const ENDPOINT = {
@@ -275,11 +275,11 @@ describe("ConnectionResolver", () => {
275 reason: "remote-unavailable",
276 detail: "Could not persist routing consent.",
277 });
278 - const permissions = yield* makeGitHubRoutingPermissions({
278 + const permissions = yield* makePullRequestRoutingPermissions({
279 read: Effect.succeed([
280 {
281 environmentId: ENVIRONMENT_ID,
282 - connectionKey: gitHubRoutingConnectionKey(entry)!,
282 + connectionKey: pullRequestRoutingConnectionKey(entry)!,
283 permission: "read-write",
284 },
285 ]),
@@ -328,7 +328,7 @@ describe("ConnectionResolver", () => {
328 );
329 const prepare = broker
330 .prepare(entry)
331 - .pipe(Effect.provideService(GitHubRoutingPermissions, permissions));
331 + .pipe(Effect.provideService(PullRequestRoutingPermissions, permissions));
332 if (scenario === "revocation-failed") {
333 expect(yield* Effect.flip(prepare)).toBe(failure);
334 expect(savedProfile).toBe(profile);
packages/client-runtime/src/connection/resolver.ts
+6 -6
@@ -31,9 +31,9 @@ import {
31 profileMissingError,
32 } from "./errors.ts";
33 import {
34 - GitHubRoutingPermissions,
35 - gitHubRoutingConnectionKey,
36 -} from "./githubRoutingPermissions.ts";
34 + PullRequestRoutingPermissions,
35 + pullRequestRoutingConnectionKey,
36 +} from "./pullRequestRoutingPermissions.ts";
37 import type {
38 BearerConnectionTarget,
39 ConnectionTarget,
@@ -250,10 +250,10 @@ const makeSshBroker = Effect.fn("clientRuntime.connection.broker.makeSsh")(funct
250 target: prepared.bootstrap.target,
251 });
252 if (
253 - gitHubRoutingConnectionKey(entry) !==
254 - gitHubRoutingConnectionKey({ ...entry, profile: Option.some(preparedProfile) })
253 + pullRequestRoutingConnectionKey(entry) !==
254 + pullRequestRoutingConnectionKey({ ...entry, profile: Option.some(preparedProfile) })
255 ) {
256 - const permissions = yield* GitHubRoutingPermissions;
256 + const permissions = yield* PullRequestRoutingPermissions;
257 yield* permissions.forget(target.environmentId);
258 }
259 yield* profiles.put(preparedProfile);
packages/client-runtime/src/connection/routes.test.ts
+5 -3
@@ -7,7 +7,7 @@ import {
7 type ConnectionCatalogEntry,
8 type ConnectionRoute,
9 } from "./catalog.ts";
10 -import { gitHubRoutingConnectionKey } from "./githubRoutingPermissions.ts";
10 +import { pullRequestRoutingConnectionKey } from "./pullRequestRoutingPermissions.ts";
11 import { BearerConnectionTarget, RelayConnectionTarget } from "./model.ts";
12 import {
13 connectionRouteId,
@@ -347,7 +347,7 @@ describe("learned routes", () => {
347 expect(removedWithRelay(entryWithRoutes(relayOnly, [LAN, RELAY]))).toBe(false);
348 });
349
350 - it("keeps GitHub routing trust when a route is learned", () => {
350 + it("keeps pull request routing trust when a route is learned", () => {
351 const learned = mergeLearnedRoutes({
352 entry: relayOnly,
353 activeRoute: RELAY,
@@ -360,7 +360,9 @@ describe("learned routes", () => {
360 profile: learned[0]!.profile,
361 alternateRoutes: learned.slice(1),
362 };
363 - expect(gitHubRoutingConnectionKey(withLearned)).toBe(gitHubRoutingConnectionKey(relayOnly));
363 + expect(pullRequestRoutingConnectionKey(withLearned)).toBe(
364 + pullRequestRoutingConnectionKey(relayOnly),
365 + );
366 });
367
368 it("keeps the T3 Connect credential when learning over a learned T3 Connect route", () => {
packages/client-runtime/src/platform/storageDocument.test.ts
+10 -10
@@ -21,9 +21,9 @@ import {
21 SshConnectionTarget,
22 } from "../connection/model.ts";
23 import {
24 - GitHubRoutingPermissions,
25 - makeGitHubRoutingPermissions,
26 -} from "../connection/githubRoutingPermissions.ts";
24 + PullRequestRoutingPermissions,
25 + makePullRequestRoutingPermissions,
26 +} from "../connection/pullRequestRoutingPermissions.ts";
27 import {
28 ConnectionCatalogDocument,
29 EMPTY_CONNECTION_CATALOG_DOCUMENT,
@@ -87,10 +87,10 @@ describe("ConnectionCatalogDocument", () => {
87 }).pipe(Effect.orDie);
88 }),
89 };
90 - const permissions = yield* makeGitHubRoutingPermissions(storage);
90 + const permissions = yield* makePullRequestRoutingPermissions(storage);
91 expect(yield* permissions.get(entry)).toBe("off");
92 yield* permissions.set(entry, "read");
93 - const restarted = yield* makeGitHubRoutingPermissions(storage);
93 + const restarted = yield* makePullRequestRoutingPermissions(storage);
94 expect(yield* restarted.get(entry)).toBe("read");
95
96 const changedEndpoint = {
@@ -121,19 +121,19 @@ describe("ConnectionCatalogDocument", () => {
121 expect(yield* restarted.get(entry)).toBe("read-write");
122 yield* restarted.forget(ENVIRONMENT_ID);
123 expect(yield* restarted.get(entry)).toBe("off");
124 - const afterRemoval = yield* makeGitHubRoutingPermissions(storage);
124 + const afterRemoval = yield* makePullRequestRoutingPermissions(storage);
125 expect(yield* afterRemoval.get(entry)).toBe("off");
126
127 yield* permissions.set(entry, "read");
128 document = removeConnectionFromCatalog(document, ENVIRONMENT_ID);
129 - const afterCatalogRemoval = yield* makeGitHubRoutingPermissions(storage);
129 + const afterCatalogRemoval = yield* makePullRequestRoutingPermissions(storage);
130 expect(yield* afterCatalogRemoval.get(entry)).toBe("off");
131 }),
132 );
133
134 it.effect("requires explicit trust for primary, relay, and SSH connections independently", () =>
135 Effect.gen(function* () {
136 - const permissions = yield* makeGitHubRoutingPermissions({
136 + const permissions = yield* makePullRequestRoutingPermissions({
137 read: Effect.succeed([]),
138 write: () => Effect.void,
139 });
@@ -179,8 +179,8 @@ describe("ConnectionCatalogDocument", () => {
179 it.effect("does not enable GitHub routing when permission persistence fails", () =>
180 Effect.gen(function* () {
181 const entry = { target: BEARER_TARGET, profile: Option.some(BEARER_PROFILE), enabled: true };
182 - expect(yield* (yield* GitHubRoutingPermissions).get(entry)).toBe("off");
183 - const permissions = yield* makeGitHubRoutingPermissions({
182 + expect(yield* (yield* PullRequestRoutingPermissions).get(entry)).toBe("off");
183 + const permissions = yield* makePullRequestRoutingPermissions({
184 read: Effect.succeed([]),
185 write: () =>
186 Effect.fail(
packages/client-runtime/src/platform/storageDocument.ts
+4 -2
@@ -9,7 +9,7 @@ import {
9 } from "../connection/catalog.ts";
10 import { type ConnectionTarget, PersistedConnectionTarget } from "../connection/model.ts";
11 import * as TokenStore from "../authorization/tokenStore.ts";
12 -import { StoredGitHubRoutingPermission } from "../connection/githubRoutingPermissions.ts";
12 +import { StoredPullRequestRoutingPermission } from "../connection/pullRequestRoutingPermissions.ts";
13
14 export const StoredConnectionCredential = Schema.Struct({
15 connectionId: Schema.String,
@@ -23,7 +23,9 @@ export const ConnectionCatalogDocument = Schema.Struct({
23 profiles: Schema.Array(ConnectionProfile),
24 credentials: Schema.Array(StoredConnectionCredential),
25 remoteDpopTokens: Schema.Array(TokenStore.RemoteDpopAccessToken),
26 - githubRoutingPermissions: Schema.optionalKey(Schema.Array(StoredGitHubRoutingPermission)),
26 + // Pull request routing grants. The field name predates the rename and stays, so older and
27 + // newer clients sharing this document keep reading and revoking the same grants.
28 + githubRoutingPermissions: Schema.optionalKey(Schema.Array(StoredPullRequestRoutingPermission)),
29 disabledEnvironmentIds: Schema.Array(EnvironmentId).pipe(
30 Schema.withDecodingDefaultKey(Effect.succeed([])),
31 ),
packages/client-runtime/src/sourceControlClients.ts
+12 -4
@@ -1,18 +1,24 @@
1 import * as AzureDevOps from "@t3tools/source-control-azure-devops/client/definition";
2 import * as Bitbucket from "@t3tools/source-control-bitbucket/client/definition";
3 import {
4 + HostCredentialSettings,
5 makeSourceControlClientRegistry,
6 readSourceControlHostSettings,
7 } from "@t3tools/source-control-core/client/definition";
8 import type { ServerSettings } from "@t3tools/contracts";
9
10 export {
11 + isMonochromeSourceControlIcon,
12 UNKNOWN_SOURCE_CONTROL_CLIENT,
13 type ChangeRequestLink,
14 type ChangeRequestTerminology,
15 + type HostAccountChoice,
16 + type HostCredentialSettings,
17 type ParsedChangeRequestUrl,
18 type ReferenceAutolink,
19 type SourceControlClientDefinition,
20 + type SourceControlHostCredentials,
21 + type SourceControlIcon,
22 } from "@t3tools/source-control-core/client/definition";
23 import * as Forgejo from "@t3tools/source-control-forgejo/client/definition";
24 import * as GitCafe from "@t3tools/source-control-gitcafe/client/definition";
@@ -51,8 +57,10 @@ export const sourceControlClients = makeSourceControlClientRegistry(
57 },
58 );
59
54 -export type { GitHubSettings } from "@t3tools/source-control-github/client/definition";
55 -
56 -export function readGitHubSettings(settings: Pick<ServerSettings, "sourceControlHosts">) {
57 - return readSourceControlHostSettings(GitHub.settings, settings.sourceControlHosts.github);
60 +/** The saved per-hostname accounts and tokens of a host whose definition has `credentials`. */
61 +export function readHostCredentialSettings(
62 + settings: Pick<ServerSettings, "sourceControlHosts">,
63 + kind: string,
64 +): HostCredentialSettings {
65 + return readSourceControlHostSettings(HostCredentialSettings, settings.sourceControlHosts[kind]);
66 }
packages/client-runtime/src/state/connections.ts
+18 -16
@@ -10,10 +10,10 @@ import type { ConnectionCatalogEntry } from "../connection/catalog.ts";
10 import { AVAILABLE_CONNECTION_STATE } from "../connection/model.ts";
11 import * as EnvironmentSupervisor from "../connection/supervisor.ts";
12 import {
13 - GitHubRoutingPermissions,
14 - type GitHubRoutingPermission,
15 - type StoredGitHubRoutingPermission,
16 -} from "../connection/githubRoutingPermissions.ts";
13 + PullRequestRoutingPermissions,
14 + type PullRequestRoutingPermission,
15 + type StoredPullRequestRoutingPermission,
16 +} from "../connection/pullRequestRoutingPermissions.ts";
17 import {
18 createAtomCommandScheduler,
19 createRuntimeCommand,
@@ -65,20 +65,22 @@ export function createEnvironmentCatalogAtoms<R, E>(
65 Option.getOrElse(AsyncResult.value(get(catalogAtom)), () => EMPTY_ENVIRONMENT_CATALOG_STATE),
66 ).pipe(Atom.withLabel("environment-catalog-value"));
67
68 - const githubRoutingPermissionsAtom = runtime.atom(
69 - Stream.unwrap(GitHubRoutingPermissions.pipe(Effect.map((permissions) => permissions.changes))),
70 - { initialValue: [] as ReadonlyArray<StoredGitHubRoutingPermission> },
68 + const pullRequestRoutingPermissionsAtom = runtime.atom(
69 + Stream.unwrap(
70 + PullRequestRoutingPermissions.pipe(Effect.map((permissions) => permissions.changes)),
71 + ),
72 + { initialValue: [] as ReadonlyArray<StoredPullRequestRoutingPermission> },
73 );
72 - const githubRoutingPermissionsValueAtom = Atom.make((get) =>
73 - Option.getOrElse(AsyncResult.value(get(githubRoutingPermissionsAtom)), () => []),
74 - ).pipe(Atom.withLabel("environment-github-routing-permissions"));
75 - const setGitHubRoutingPermission = createRuntimeCommand(runtime, {
76 - label: "environment-catalog:github-routing-permission",
74 + const pullRequestRoutingPermissionsValueAtom = Atom.make((get) =>
75 + Option.getOrElse(AsyncResult.value(get(pullRequestRoutingPermissionsAtom)), () => []),
76 + ).pipe(Atom.withLabel("environment-pull-request-routing-permissions"));
77 + const setPullRequestRoutingPermission = createRuntimeCommand(runtime, {
78 + label: "environment-catalog:pull-request-routing-permission",
79 scheduler: commandScheduler,
80 concurrency: serial,
81 execute: Effect.fn(function* (input: {
82 readonly environmentId: EnvironmentIdType;
81 - readonly permission: GitHubRoutingPermission;
83 + readonly permission: PullRequestRoutingPermission;
84 }) {
85 const registry = yield* EnvironmentRegistry.EnvironmentRegistry;
86 const entry = (yield* SubscriptionRef.get(registry.entries)).get(input.environmentId);
@@ -86,7 +88,7 @@ export function createEnvironmentCatalogAtoms<R, E>(
88 return yield* new EnvironmentRegistry.EnvironmentNotRegisteredError({
89 environmentId: input.environmentId,
90 });
89 - const permissions = yield* GitHubRoutingPermissions;
91 + const permissions = yield* PullRequestRoutingPermissions;
92 yield* permissions.set(entry, input.permission);
93 }),
94 });
@@ -190,8 +192,8 @@ export function createEnvironmentCatalogAtoms<R, E>(
192 return {
193 catalogAtom,
194 catalogValueAtom,
193 - githubRoutingPermissionsValueAtom,
194 - setGitHubRoutingPermission,
195 + pullRequestRoutingPermissionsValueAtom,
196 + setPullRequestRoutingPermission,
197 networkStatusAtom,
198 networkStatusValueAtom,
199 stateAtom,
packages/client-runtime/src/state/pullRequestRouting.ts
+7 -6
@@ -18,9 +18,9 @@ import * as SubscriptionRef from "effect/SubscriptionRef";
18 import * as EnvironmentRegistry from "../connection/registry.ts";
19 import * as EnvironmentSupervisor from "../connection/supervisor.ts";
20 import {
21 - GitHubRoutingPermissions,
22 - gitHubRoutingConnectionKey,
23 -} from "../connection/githubRoutingPermissions.ts";
21 + PullRequestRoutingPermissions,
22 + pullRequestRoutingConnectionKey,
23 +} from "../connection/pullRequestRoutingPermissions.ts";
24 import type { ConnectionCatalogEntry } from "../connection/catalog.ts";
25 import * as ConnectionProfileStore from "../connection/profileStore.ts";
26 import type { RpcSession } from "../rpc/session.ts";
@@ -171,7 +171,7 @@ const routingAllowed = Effect.fn("PullRequestRouting.allowed")(function* (
171 destination.unsupportedReason !== undefined
172 )
173 return false;
174 - const permissions = yield* GitHubRoutingPermissions;
174 + const permissions = yield* PullRequestRoutingPermissions;
175 const source = yield* permissions.get(origin);
176 const target = yield* permissions.get(destination);
177 const allowed = write
@@ -185,8 +185,9 @@ const routingAllowed = Effect.fn("PullRequestRouting.allowed")(function* (
185 const profile = yield* profiles.value
186 .get(entry.target.connectionId)
187 .pipe(Effect.orElseSucceed(() => Option.none()));
188 - const key = gitHubRoutingConnectionKey(entry);
189 - if (key === null || key !== gitHubRoutingConnectionKey({ ...entry, profile })) return false;
188 + const key = pullRequestRoutingConnectionKey(entry);
189 + if (key === null || key !== pullRequestRoutingConnectionKey({ ...entry, profile }))
190 + return false;
191 }
192 return true;
193 });
packages/client-runtime/src/state/pullRequests.test.ts
+11 -11
@@ -44,7 +44,7 @@ import {
44 import * as PullRequestDiffLoader from "./pullRequestDiffHttp.ts";
45 import { executeAtomQuery } from "./runtime.ts";
46 import { createPullRequestRouter } from "./pullRequestRouting.ts";
47 -import { GitHubRoutingPermissions } from "../connection/githubRoutingPermissions.ts";
47 +import { PullRequestRoutingPermissions } from "../connection/pullRequestRoutingPermissions.ts";
48
49 const trustedRouting = {
50 get: () => Effect.succeed("read-write" as const),
@@ -198,7 +198,7 @@ for (const scenario of [
198 ).pipe(
199 Effect.provideService(EnvironmentRegistry.EnvironmentRegistry, environmentRegistry),
200 Effect.provideService(RpcPermissionGuard, { authorize: () => Effect.void }),
201 - Effect.provideService(GitHubRoutingPermissions, {
201 + Effect.provideService(PullRequestRoutingPermissions, {
202 ...trustedRouting,
203 get: () => Effect.succeed(trusted ? "read-write" : "off"),
204 }),
@@ -283,7 +283,7 @@ it.effect.each([
283 }).pipe(
284 Effect.provideService(EnvironmentRegistry.EnvironmentRegistry, environmentRegistry),
285 Effect.provideService(EnvironmentSupervisor.EnvironmentSupervisor, supervisor),
286 - Effect.provideService(GitHubRoutingPermissions, trustedRouting),
286 + Effect.provideService(PullRequestRoutingPermissions, trustedRouting),
287 );
288 const first = yield* read().pipe(Effect.forkChild);
289 yield* Deferred.await(started);
@@ -347,7 +347,7 @@ it.effect.each(["revoked", "disabled"] as const)(
347 ).pipe(
348 Effect.provideService(EnvironmentRegistry.EnvironmentRegistry, environmentRegistry),
349 Effect.provideService(EnvironmentSupervisor.EnvironmentSupervisor, supervisor),
350 - Effect.provideService(GitHubRoutingPermissions, {
350 + Effect.provideService(PullRequestRoutingPermissions, {
351 ...trustedRouting,
352 get: () => Effect.sync(() => (trusted ? "read-write" : "off")),
353 }),
@@ -415,7 +415,7 @@ it.effect.each(["origin", "alternate"] as const)(
415 }).pipe(
416 Effect.provideService(EnvironmentRegistry.EnvironmentRegistry, environmentRegistry),
417 Effect.provideService(EnvironmentSupervisor.EnvironmentSupervisor, supervisor),
418 - Effect.provideService(GitHubRoutingPermissions, trustedRouting),
418 + Effect.provideService(PullRequestRoutingPermissions, trustedRouting),
419 );
420 const first = yield* read().pipe(Effect.forkChild);
421 yield* Deferred.await(started);
@@ -479,7 +479,7 @@ it.effect("forgets routed viewed marks when a viewed-files batch fails", () =>
479 );
480 }).pipe(
481 Effect.provideService(EnvironmentRegistry.EnvironmentRegistry, environmentRegistry),
482 - Effect.provideService(GitHubRoutingPermissions, trustedRouting),
482 + Effect.provideService(PullRequestRoutingPermissions, trustedRouting),
483 Effect.provideService(RpcPermissionGuard, { authorize: () => Effect.void }),
484 Effect.provideService(EnvironmentSupervisor.EnvironmentSupervisor, supervisor),
485 );
@@ -678,7 +678,7 @@ it.effect.each([
678 ? request
679 : request.pipe(
680 Effect.provideService(RpcPermissionGuard, { authorize: () => Effect.void }),
681 - Effect.provideService(GitHubRoutingPermissions, {
681 + Effect.provideService(PullRequestRoutingPermissions, {
682 ...trustedRouting,
683 get: (entry) =>
684 Effect.succeed(
@@ -797,7 +797,7 @@ it.effect.each(
797 }).pipe(
798 Effect.provideService(EnvironmentRegistry.EnvironmentRegistry, environmentRegistry),
799 Effect.provideService(EnvironmentSupervisor.EnvironmentSupervisor, supervisor),
800 - Effect.provideService(GitHubRoutingPermissions, trustedRouting),
800 + Effect.provideService(PullRequestRoutingPermissions, trustedRouting),
801 Effect.provideService(RpcPermissionGuard, { authorize: () => Effect.void }),
802 );
803 yield* stored === "unavailable"
@@ -860,7 +860,7 @@ it.live.each([undefined, true, false])(
860 number: 7,
861 }).pipe(
862 Effect.provideService(EnvironmentRegistry.EnvironmentRegistry, environmentRegistry),
863 - Effect.provideService(GitHubRoutingPermissions, trustedRouting),
863 + Effect.provideService(PullRequestRoutingPermissions, trustedRouting),
864 Effect.provideService(RpcPermissionGuard, { authorize: () => Effect.void }),
865 Effect.provideService(EnvironmentSupervisor.EnvironmentSupervisor, supervisor),
866 );
@@ -956,7 +956,7 @@ it.live(
956 expect(invalidations).toContainEqual({ environment: "local", input: {} });
957 }).pipe(
958 Effect.provideService(EnvironmentRegistry.EnvironmentRegistry, environmentRegistry),
959 - Effect.provideService(GitHubRoutingPermissions, trustedRouting),
959 + Effect.provideService(PullRequestRoutingPermissions, trustedRouting),
960 Effect.provideService(RpcPermissionGuard, { authorize: () => Effect.void }),
961 Effect.provideService(EnvironmentSupervisor.EnvironmentSupervisor, supervisor),
962 );
@@ -1504,7 +1504,7 @@ it.effect("denies a routed write when only the origin has source-control permiss
1504 }).pipe(
1505 Effect.provideService(EnvironmentRegistry.EnvironmentRegistry, fixture.environmentRegistry),
1506 Effect.provideService(EnvironmentSupervisor.EnvironmentSupervisor, fixture.supervisor),
1507 - Effect.provideService(GitHubRoutingPermissions, trustedRouting),
1507 + Effect.provideService(PullRequestRoutingPermissions, trustedRouting),
1508 Effect.provideService(RpcPermissionGuard, {
1509 authorize: (id, method, input) =>
1510 createCommandPermissions(fixture.runtime, method).authorize(
packages/contracts/src/settings.ts
-4
@@ -827,10 +827,6 @@ export const UsageLimitSourceConfig = Schema.Struct({
827 });
828 export type UsageLimitSourceConfig = typeof UsageLimitSourceConfig.Type;
829
830 -export const GitHubHost = TrimmedNonEmptyString.pipe(
831 - Schema.decodeTo(Schema.String, SchemaTransformation.toLowerCase()),
832 -);
833 -
830 export const SourceControlHostSettings = Schema.Record(Schema.String, Schema.Unknown);
831 export type SourceControlHostSettings = typeof SourceControlHostSettings.Type;
832
packages/source-control-azure-devops/src/client/definition.ts
+2 -1
@@ -6,6 +6,7 @@ import {
6 parseChangeRequestPath,
7 remoteWebOrigin,
8 } from "@t3tools/source-control-core/client/definition";
9 +import { icon } from "./icon.ts";
10
11 // Azure DevOps Server runs on any hostname; its `_git` route identifies it.
12 const CHANGE_REQUEST_PATH = /^\/((?:[^/]+\/)*_git\/[^/]+)\/pullrequest\/(\d+)(?:\/|$)/u;
@@ -66,7 +67,7 @@ export const definition = defineSourceControlClient({
67 kind: KIND,
68 label: "Azure DevOps",
69 pickerLabel: "Azure DevOps",
69 - icon: "azure-devops",
70 + icon,
71 changeRequest: { shortLabel: "PR", singular: "pull request" },
72 repositoryPathHint: "project/repository",
73 // `az repos` reads need the checkout's organization and project, so a bare hostname names no
packages/source-control-azure-devops/src/client/icon.ts new
+162
@@ -0,0 +1,162 @@
1 +import type { SourceControlIcon } from "@t3tools/source-control-core/client/definition";
2 +
3 +// Microsoft Azure DevOps mark via selfhst/icons (CC BY 4.0): https://github.com/selfhst/icons/blob/main/svg/azure-devops.svg
4 +export const icon: SourceControlIcon = {
5 + viewBox: "0 0 512 512",
6 + gradients: [
7 + {
8 + id: "a",
9 + x1: 58.027,
10 + y1: 356.668,
11 + x2: 58.027,
12 + y2: 100.668,
13 + transform: "matrix(1 0 0 -1 0 514)",
14 + stops: [
15 + { offset: 0, color: "#163697" },
16 + { offset: 0.276, color: "#2052cb" },
17 + { offset: 0.518, color: "#2764e7" },
18 + { offset: 0.879, color: "#367af2" },
19 + ],
20 + },
21 + {
22 + id: "b",
23 + x1: 58.027,
24 + y1: 351.334,
25 + x2: 58.027,
26 + y2: 292.668,
27 + transform: "matrix(1 0 0 -1 0 514)",
28 + stops: [
29 + { offset: 0, color: "#102784" },
30 + { offset: 1, color: "#2052cb", opacity: 0 },
31 + ],
32 + },
33 + {
34 + id: "c",
35 + x1: 389.98,
36 + y1: 57.935,
37 + x2: 107.314,
38 + y2: 193.935,
39 + transform: "matrix(1 0 0 -1 0 514)",
40 + stops: [
41 + { offset: 0, color: "#163697" },
42 + { offset: 0.301, color: "#2052cb" },
43 + { offset: 0.626, color: "#2764e7" },
44 + { offset: 0.926, color: "#367af2" },
45 + ],
46 + },
47 + {
48 + id: "d",
49 + x1: 391.996,
50 + y1: 76.552,
51 + x2: 341.385,
52 + y2: 78.224,
53 + transform: "matrix(1 0 0 -1 0 514)",
54 + stops: [
55 + { offset: 0, color: "#102784" },
56 + { offset: 1, color: "#2052cb", opacity: 0 },
57 + ],
58 + },
59 + {
60 + id: "e",
61 + x1: 442.24,
62 + y1: 54.769,
63 + x2: 442.24,
64 + y2: 419.38,
65 + transform: "matrix(1 0 0 -1 0 514)",
66 + stops: [
67 + { offset: 0.043, color: "#2052cb" },
68 + { offset: 0.489, color: "#367af2" },
69 + { offset: 0.943, color: "#16bbda" },
70 + ],
71 + },
72 + {
73 + id: "f",
74 + x1: 435.596,
75 + y1: 270.413,
76 + x2: 425.732,
77 + y2: 385.266,
78 + transform: "matrix(1 0 0 -1 0 514)",
79 + stops: [
80 + { offset: 0.134, color: "#16bbda", opacity: 0 },
81 + { offset: 0.932, color: "#6be7a0", opacity: 0.8629 },
82 + ],
83 + },
84 + {
85 + id: "g",
86 + x1: 437.081,
87 + y1: 204.362,
88 + x2: 507.893,
89 + y2: 119.081,
90 + transform: "matrix(1 0 0 -1 0 514)",
91 + stops: [
92 + { offset: 0, color: "#2c68e0", opacity: 0 },
93 + { offset: 0.898, color: "#66c0ff", opacity: 0.5 },
94 + ],
95 + },
96 + {
97 + id: "h",
98 + x1: 99.399,
99 + y1: 279.26,
100 + x2: 352.75,
101 + y2: 498.676,
102 + transform: "matrix(1 0 0 -1 0 514)",
103 + stops: [
104 + { offset: 0.005, color: "#367af2" },
105 + { offset: 0.507, color: "#0fafff" },
106 + { offset: 1, color: "#26cfe8" },
107 + ],
108 + },
109 + {
110 + id: "i",
111 + x1: 184.342,
112 + y1: 356.795,
113 + x2: 338.581,
114 + y2: 480.642,
115 + transform: "matrix(1 0 0 -1 0 514)",
116 + stops: [
117 + { offset: 0.443, color: "#26cfe8", opacity: 0 },
118 + { offset: 0.897, color: "#6be7a0", opacity: 0.8629 },
119 + ],
120 + },
121 + ],
122 + paths: [
123 + {
124 + d: "M116.1 73.4c-5.8 5.8-13.7 13.8-13.7 22.6v216.4c0 8.9-3.3 17.3-9 23.4s-13.3 9.2-21.1 8.5l-42.7-3.1c-7.9-.5-15-3.9-20.3-9.3-5.7-5.7-9.3-13.7-9.3-22.6V202.7c0-8.9 3.6-16.9 9.4-22.6l2-1.9z",
125 + fill: { gradient: "a" },
126 + },
127 + {
128 + d: "M116.1 73.4c-5.8 5.8-13.7 13.8-13.7 22.6v216.4c0 8.9-3.3 17.3-9 23.4s-13.3 9.2-21.1 8.5l-42.7-3.1c-7.9-.5-15-3.9-20.3-9.3-5.7-5.7-9.3-13.7-9.3-22.6V202.7c0-8.9 3.6-16.9 9.4-22.6l2-1.9z",
129 + fill: { gradient: "b" },
130 + },
131 + {
132 + d: "m500.5 366-128 106.7c-5.5 4.6-12.7 7.4-20.5 7.4q-2.4 0-4.8-.3l-112.5-16.9v27.8c0 11.7-9.6 21.3-21.3 21.3-7.3 0-13.5-3.6-17.5-9.1l-36.2-51.4-5.4-7.6-36.6-51.9-7-10c-2.6-3.5-3.9-7.8-3.9-12.3 0-6 2.5-11.6 6.8-15.7 3.8-3.7 9.1-5.8 14.5-5.8.4 0 1 .1 1.5.1l105.2 7.5L384 366.5l93.7 6.7c.7.1 1.6.1 2.3.1 7.8 0 14.9-2.7 20.5-7.3",
133 + fill: { gradient: "c" },
134 + },
135 + {
136 + d: "m500.5 366-128 106.7c-5.5 4.6-12.7 7.4-20.5 7.4q-2.4 0-4.8-.3l-112.5-16.9v27.8c0 11.7-9.6 21.3-21.3 21.3-7.3 0-13.5-3.6-17.5-9.1l-36.2-51.4-5.4-7.6-36.6-51.9-7-10c-2.6-3.5-3.9-7.8-3.9-12.3 0-6 2.5-11.6 6.8-15.7 3.8-3.7 9.1-5.8 14.5-5.8.4 0 1 .1 1.5.1l105.2 7.5L384 366.5l93.7 6.7c.7.1 1.6.1 2.3.1 7.8 0 14.9-2.7 20.5-7.3",
137 + fill: { gradient: "d" },
138 + },
139 + {
140 + d: "M512 170.7v170.7c0 9.9-4.5 18.8-11.5 24.6l-128 106.7c7-5.9 11.5-14.7 11.5-24.6V175.3c0-16.7 13-30.7 29.8-31.9l63.9-4.6c.7-.1 1.6-.1 2.3-.1 7.8 0 14.9 2.8 20.5 7.4 7 5.8 11.5 14.6 11.5 24.6",
141 + fill: { gradient: "e" },
142 + },
143 + {
144 + d: "M512 170.7v170.7c0 9.9-4.5 18.8-11.5 24.6l-128 106.7c7-5.9 11.5-14.7 11.5-24.6V175.3c0-16.7 13-30.7 29.8-31.9l63.9-4.6c.7-.1 1.6-.1 2.3-.1 7.8 0 14.9 2.8 20.5 7.4 7 5.8 11.5 14.6 11.5 24.6",
145 + fill: { gradient: "f" },
146 + fillOpacity: 0.7,
147 + },
148 + {
149 + d: "M512 170.7v170.7c0 9.9-4.5 18.8-11.5 24.6l-128 106.7c7-5.9 11.5-14.7 11.5-24.6V175.3c0-16.7 13-30.7 29.8-31.9l63.9-4.6c.7-.1 1.6-.1 2.3-.1 7.8 0 14.9 2.8 20.5 7.4 7 5.8 11.5 14.6 11.5 24.6",
150 + fill: { gradient: "g" },
151 + },
152 + {
153 + d: "M384 125.5c0 11.2-8.6 20.5-19.8 21.3-.5 0-1.1.1-1.6.1l-127.9 9.2-132.3 9.1-72.7 5.5c-6.9.4-13.2 3.1-18.2 7.4L116.1 73.4c4.7-4.7 10.9-8 17.8-9.1l100.8-15.1V21.3C234.7 9.6 244.3 0 256 0c5.8 0 11.1 2.3 14.9 6.1l33.4 32.6 16.9 16.5 40.3 39.3 16.1 15.8c4.1 3.9 6.4 9.4 6.4 15.2",
154 + fill: { gradient: "h" },
155 + },
156 + {
157 + d: "M384 125.5c0 11.2-8.6 20.5-19.8 21.3-.5 0-1.1.1-1.6.1l-127.9 9.2-132.3 9.1-72.7 5.5c-6.9.4-13.2 3.1-18.2 7.4L116.1 73.4c4.7-4.7 10.9-8 17.8-9.1l100.8-15.1V21.3C234.7 9.6 244.3 0 256 0c5.8 0 11.1 2.3 14.9 6.1l33.4 32.6 16.9 16.5 40.3 39.3 16.1 15.8c4.1 3.9 6.4 9.4 6.4 15.2",
158 + fill: { gradient: "i" },
159 + fillOpacity: 0.5,
160 + },
161 + ],
162 +};
packages/source-control-bitbucket/src/client/definition.ts
+2 -1
@@ -13,6 +13,7 @@ import {
13 parseChangeRequestPath,
14 projectChangeRequestHost,
15 } from "@t3tools/source-control-core/client/definition";
16 +import { icon } from "./icon.ts";
17
18 const safeShellArgument = /^[A-Za-z0-9._/@+=,-]+$/;
19 const repositoryName = /^[A-Za-z0-9._-]+\/[A-Za-z0-9._-]+$/;
@@ -66,7 +67,7 @@ export const definition = defineSourceControlClient({
67 kind: KIND,
68 label: "Bitbucket",
69 pickerLabel: "Bitbucket",
69 - icon: "bitbucket",
70 + icon,
71 changeRequest: { shortLabel: "PR", singular: "pull request" },
72 repositoryPathHint: "workspace/repository",
73 publicHost: "bitbucket.org",
packages/source-control-bitbucket/src/client/icon.ts new
+29
@@ -0,0 +1,29 @@
1 +import type { SourceControlIcon } from "@t3tools/source-control-core/client/definition";
2 +
3 +export const icon: SourceControlIcon = {
4 + viewBox: "8.4 14.39 2481.29 2231.21",
5 + gradients: [
6 + {
7 + id: "a",
8 + x1: 945.1094,
9 + y1: 1524.8389,
10 + x2: 944.4923,
11 + y2: 1524.1893,
12 + transform: "matrix(1996.6343 0 0 -1480.3047 -1884485.625 2258195)",
13 + stops: [
14 + { offset: 0.18, color: "#0052CC" },
15 + { offset: 1, color: "#2684FF" },
16 + ],
17 + },
18 + ],
19 + paths: [
20 + {
21 + d: "M88.92,14.4C45.02,13.83,8.97,48.96,8.41,92.86c-0.06,4.61,0.28,9.22,1.02,13.77l337.48,2048.72 c8.68,51.75,53.26,89.8,105.74,90.24h1619.03c39.38,0.5,73.19-27.9,79.49-66.78l337.49-2071.78c7.03-43.34-22.41-84.17-65.75-91.2 c-4.55-0.74-9.15-1.08-13.76-1.02L88.92,14.4z M1509.99,1495.09H993.24l-139.92-731h781.89L1509.99,1495.09z",
22 + fill: "#2684FF",
23 + },
24 + {
25 + d: "M2379.27,763.06h-745.5l-125.12,730.42H992.31l-609.67,723.67c19.32,16.71,43.96,26,69.5,26.21h1618.13 c39.35,0.51,73.14-27.88,79.44-66.72L2379.27,763.06z",
26 + fill: { gradient: "a" },
27 + },
28 + ],
29 +};
packages/source-control-core/src/client/definition.ts
+103 -2
@@ -2,11 +2,16 @@ import {
2 type PullRequestAction,
3 type PullRequestReviewVerdict,
4 type RepositoryIdentity,
5 + secretSetting,
6 SourceControlProviderKind,
7 type SourceControlProviderInfo,
8 + TrimmedNonEmptyString,
9 + TrimmedString,
10 } from "@t3tools/contracts";
11 import { normalizeGitRemoteUrl, parseGitRemoteRepository } from "@t3tools/shared/git";
12 +import * as Effect from "effect/Effect";
13 import * as Schema from "effect/Schema";
14 +import * as SchemaTransformation from "effect/SchemaTransformation";
15
16 /**
17 * The two strings are what `changeRequestHost` and the project's `repositoryIdentity` produce
@@ -94,11 +99,107 @@ export interface ReferenceAutolink {
99 readonly kind: "reference" | "commit" | "mention";
100 }
101
102 +/**
103 + * A host's mark as data, so web and mobile draw the same artwork without React in the host's
104 + * package. Paths only: a circle or rectangle is written as a path.
105 + */
106 +export interface SourceControlIcon {
107 + readonly viewBox: string;
108 + /** Always in user space, as `gradientUnits="userSpaceOnUse"`. */
109 + readonly gradients?: ReadonlyArray<SourceControlIconGradient>;
110 + readonly paths: ReadonlyArray<SourceControlIconPath>;
111 +}
112 +
113 +export interface SourceControlIconGradient {
114 + /** Unique within the icon; renderers make it unique on the page. */
115 + readonly id: string;
116 + readonly x1: number;
117 + readonly y1: number;
118 + readonly x2: number;
119 + readonly y2: number;
120 + readonly transform?: string;
121 + readonly stops: ReadonlyArray<{
122 + readonly offset: number;
123 + readonly color: string;
124 + readonly opacity?: number;
125 + }>;
126 +}
127 +
128 +/** A colour, `currentColor` for a mark drawn in the text colour, or one of the icon's gradients. */
129 +export type SourceControlIconPaint = string | { readonly gradient: string };
130 +
131 +export interface SourceControlIconPath {
132 + readonly d: string;
133 + /** Absent means unfilled. */
134 + readonly fill?: SourceControlIconPaint;
135 + readonly fillRule?: "evenodd" | "nonzero";
136 + readonly fillOpacity?: number;
137 + readonly stroke?: string;
138 + readonly strokeWidth?: number;
139 +}
140 +
141 +/** Whether the mark is drawn in the text colour alone, so a client may tint it. */
142 +export function isMonochromeSourceControlIcon(icon: SourceControlIcon): boolean {
143 + return icon.paths.every(
144 + (path) =>
145 + (path.fill === undefined || path.fill === "currentColor") &&
146 + (path.stroke === undefined || path.stroke === "currentColor"),
147 + );
148 +}
149 +
150 +/**
151 + * For a host whose server signs in per hostname, with a saved token or one of a CLI's logins.
152 + * Its `settings` include `hostCredentialSettingsFields`, and clients show controls for those
153 + * instead of the generic settings form.
154 + */
155 +export interface SourceControlHostCredentials {
156 + /** The command name, as `gh`. */
157 + readonly cliName: string;
158 + /** The CLI's product name, as `GitHub CLI`. */
159 + readonly cliLabel: string;
160 + readonly loginCommand: string;
161 + /** The variable the server reads a token from, which a saved token takes precedence over. */
162 + readonly tokenEnvVar: string;
163 + /** What a token must be granted, completing "Give it …". */
164 + readonly tokenAccess: string;
165 + readonly newTokenUrl: (host: string) => string;
166 +}
167 +
168 +export const SourceControlHostName = TrimmedNonEmptyString.pipe(
169 + Schema.decodeTo(Schema.String, SchemaTransformation.toLowerCase()),
170 +);
171 +
172 +export const HostAccountChoice = Schema.Struct({
173 + account: Schema.optionalKey(TrimmedNonEmptyString),
174 + enabled: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))),
175 +});
176 +export type HostAccountChoice = typeof HostAccountChoice.Type;
177 +
178 +/** Per-hostname settings of a host with `credentials`, keyed by lower-case hostname. */
179 +export const hostCredentialSettingsFields = {
180 + hosts: Schema.Record(SourceControlHostName, HostAccountChoice).pipe(
181 + Schema.withDecodingDefault(Effect.succeed({})),
182 + Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
183 + ),
184 + tokens: Schema.Record(SourceControlHostName, TrimmedString).pipe(
185 + Schema.withDecodingDefault(Effect.succeed({})),
186 + secretSetting,
187 + Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
188 + ),
189 +};
190 +
191 +export const HostCredentialSettings = Schema.Struct(hostCredentialSettingsFields);
192 +export type HostCredentialSettings = typeof HostCredentialSettings.Type;
193 +
194 export interface SourceControlClientDefinition {
195 readonly kind: SourceControlProviderKind;
196 readonly label: string;
197 readonly pickerLabel: string;
101 - readonly icon: string;
198 + /** Null for a host without a mark of its own; clients draw a generic change request glyph. */
199 + readonly icon: SourceControlIcon | null;
200 + /** Further words settings search finds this host by, besides its label. */
201 + readonly searchKeywords?: ReadonlyArray<string>;
202 + readonly credentials?: SourceControlHostCredentials;
203 readonly changeRequest: ChangeRequestTerminology;
204 readonly repositoryPathHint: string;
205 readonly publicHost: string | null;
@@ -363,7 +464,7 @@ export const UNKNOWN_SOURCE_CONTROL_CLIENT: SourceControlClientDefinition = {
464 kind: SourceControlProviderKind.make("unknown"),
465 label: "source control",
466 pickerLabel: "source control",
366 - icon: "change-request",
467 + icon: null,
468 changeRequest: { shortLabel: "change request", singular: "change request" },
469 repositoryPathHint: "URL",
470 publicHost: null,
packages/source-control-forgejo/src/client/definition.ts
+3 -1
@@ -11,6 +11,7 @@ import {
11 projectChangeRequestHost,
12 remoteWebOrigin,
13 } from "@t3tools/source-control-core/client/definition";
14 +import { icon } from "./icon.ts";
15
16 const CHECKOUT_COMMAND = /^tea\s+(?:pr|pulls)\s+checkout\s+(.+)$/i;
17 const CHANGE_REQUEST_REFERENCE =
@@ -54,7 +55,8 @@ export const definition = defineSourceControlClient({
55 kind: KIND,
56 label: "Forgejo",
57 pickerLabel: "Forgejo / Gitea",
57 - icon: "forgejo",
58 + icon,
59 + searchKeywords: ["gitea", "tea", "codeberg"],
60 changeRequest: { shortLabel: "PR", singular: "pull request" },
61 repositoryPathHint: "owner/repo",
62 // Codeberg is the public Forgejo; any other server is self-hosted.
packages/source-control-forgejo/src/client/icon.ts new
+13
@@ -0,0 +1,13 @@
1 +import type { SourceControlIcon } from "@t3tools/source-control-core/client/definition";
2 +
3 +// The view box starts at -6 to move the mark 6 units in, as the published artwork's group does.
4 +export const icon: SourceControlIcon = {
5 + viewBox: "-6 -6 212 212",
6 + paths: [
7 + { d: "M58 168 v-98 a50 50 0 0 1 50-50 h20", stroke: "#ff6600", strokeWidth: 25 },
8 + { d: "M58 168 v-30 a50 50 0 0 1 50-50 h20", stroke: "#d40000", strokeWidth: 25 },
9 + { d: "M124 20 a18 18 0 1 0 36 0 a18 18 0 1 0 -36 0z", stroke: "#ff6600", strokeWidth: 15 },
10 + { d: "M124 88 a18 18 0 1 0 36 0 a18 18 0 1 0 -36 0z", stroke: "#d40000", strokeWidth: 15 },
11 + { d: "M40 180 a18 18 0 1 0 36 0 a18 18 0 1 0 -36 0z", stroke: "#d40000", strokeWidth: 15 },
12 + ],
13 +};
packages/source-control-gitcafe/src/client/definition.ts
+2 -1
@@ -14,6 +14,7 @@ import {
14 parseChangeRequestPath,
15 projectChangeRequestHost,
16 } from "@t3tools/source-control-core/client/definition";
17 +import { icon } from "./icon.ts";
18
19 /** GitCafe has no self-hosted installs: production and staging are its only hosts. */
20 const GITCAFE_HOSTS = new Set(["git.cafe", "staging.git.cafe"]);
@@ -41,7 +42,7 @@ export const definition = defineSourceControlClient({
42 kind: KIND,
43 label: "GitCafe",
44 pickerLabel: "GitCafe",
44 - icon: "gitcafe",
45 + icon,
46 changeRequest: { shortLabel: "PR", singular: "pull request" },
47 repositoryPathHint: "owner/repo",
48 publicHost: null,
packages/source-control-gitcafe/src/client/icon.ts new
+6
@@ -0,0 +1,6 @@
1 +import type { SourceControlIcon } from "@t3tools/source-control-core/client/definition";
2 +
3 +export const icon: SourceControlIcon = {
4 + viewBox: "0 0 64 64",
5 + paths: [{ d: "M4.8 4.8h54.4v54.4H4.8z", fill: "#a78bfa" }],
6 +};
packages/source-control-github/src/client/definition.ts
+14 -28
@@ -1,16 +1,8 @@
1 -import {
2 - GitHubHost,
3 - makeProviderSettingsSchema,
4 - secretSetting,
5 - SourceControlProviderKind,
6 - TrimmedNonEmptyString,
7 - TrimmedString,
8 -} from "@t3tools/contracts";
9 -import * as Effect from "effect/Effect";
10 -import * as Schema from "effect/Schema";
1 +import { makeProviderSettingsSchema, SourceControlProviderKind } from "@t3tools/contracts";
2 import {
3 changeRequestUrlBelow,
4 defineSourceControlClient,
5 + hostCredentialSettingsFields,
6 isChangeRequestInProjectRepository,
7 isChangeRequestOnProjectHost,
8 parseChangeRequestPath,
@@ -19,6 +11,7 @@ import {
11 } from "@t3tools/source-control-core/client/definition";
12
13 import { gitHubMediaUrl } from "./gitHubMedia.ts";
14 +import { icon } from "./icon.ts";
15 import { gitHubReferenceAutolinks } from "./referenceAutolinks.ts";
16
17 const CHECKOUT_COMMAND = /^gh\s+pr\s+checkout\s+(.+)$/i;
@@ -49,30 +42,23 @@ function isRepositoryPath(repository: string): boolean {
42 );
43 }
44
52 -export const GitHubHostChoice = Schema.Struct({
53 - account: Schema.optionalKey(TrimmedNonEmptyString),
54 - enabled: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))),
55 -});
56 -export type GitHubHostChoice = typeof GitHubHostChoice.Type;
57 -
58 -export const settings = makeProviderSettingsSchema({
59 - hosts: Schema.Record(GitHubHost, GitHubHostChoice).pipe(
60 - Schema.withDecodingDefault(Effect.succeed({})),
61 - Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
62 - ),
63 - tokens: Schema.Record(GitHubHost, TrimmedString).pipe(
64 - Schema.withDecodingDefault(Effect.succeed({})),
65 - secretSetting,
66 - Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
67 - ),
68 -});
45 +export const settings = makeProviderSettingsSchema(hostCredentialSettingsFields);
46 export type GitHubSettings = typeof settings.Type;
47
48 export const definition = defineSourceControlClient({
49 kind: KIND,
50 label: "GitHub",
51 pickerLabel: "GitHub",
75 - icon: "github",
52 + icon,
53 + searchKeywords: ["ghes", "enterprise"],
54 + credentials: {
55 + cliName: "gh",
56 + cliLabel: "GitHub CLI",
57 + loginCommand: "gh auth login",
58 + tokenEnvVar: "GH_TOKEN",
59 + tokenAccess: "read and write access to pull requests and contents",
60 + newTokenUrl: (host) => `https://${host}/settings/personal-access-tokens/new`,
61 + },
62 changeRequest: { shortLabel: "PR", singular: "pull request" },
63 repositoryPathHint: "owner/repo",
64 publicHost: "github.com",
packages/source-control-github/src/client/icon.ts new
+12
@@ -0,0 +1,12 @@
1 +import type { SourceControlIcon } from "@t3tools/source-control-core/client/definition";
2 +
3 +export const icon: SourceControlIcon = {
4 + viewBox: "0 0 16 16",
5 + paths: [
6 + {
7 + d: "M8 0C3.58 0 0 3.58 0 8C0 11.54 2.29 14.53 5.47 15.59C5.87 15.66 6.02 15.42 6.02 15.21C6.02 15.02 6.01 14.39 6.01 13.72C4 14.09 3.48 13.23 3.32 12.78C3.23 12.55 2.84 11.84 2.5 11.65C2.22 11.5 1.82 11.13 2.49 11.12C3.12 11.11 3.57 11.7 3.72 11.94C4.44 13.15 5.59 12.81 6.05 12.6C6.12 12.08 6.33 11.73 6.56 11.53C4.78 11.33 2.92 10.64 2.92 7.58C2.92 6.71 3.23 5.99 3.74 5.43C3.66 5.23 3.38 4.41 3.82 3.31C3.82 3.31 4.49 3.1 6.02 4.13C6.66 3.95 7.34 3.86 8.02 3.86C8.7 3.86 9.38 3.95 10.02 4.13C11.55 3.09 12.22 3.31 12.22 3.31C12.66 4.41 12.38 5.23 12.3 5.43C12.81 5.99 13.12 6.7 13.12 7.58C13.12 10.65 11.25 11.33 9.47 11.53C9.76 11.78 10.01 12.26 10.01 13.01C10.01 14.08 10 14.94 10 15.21C10 15.42 10.15 15.67 10.55 15.59C13.71 14.53 16 11.53 16 8C16 3.58 12.42 0 8 0Z",
8 + fill: "currentColor",
9 + fillRule: "evenodd",
10 + },
11 + ],
12 +};
packages/source-control-gitlab/src/client/definition.ts
+2 -1
@@ -7,6 +7,7 @@ import {
7 parseChangeRequestPath,
8 projectChangeRequestHost,
9 } from "@t3tools/source-control-core/client/definition";
10 +import { icon } from "./icon.ts";
11
12 const CHECKOUT_COMMAND = /^glab\s+mr\s+checkout\s+(.+)$/i;
13 const CHANGE_REQUEST_REFERENCE =
@@ -21,7 +22,7 @@ export const definition = defineSourceControlClient({
22 kind: KIND,
23 label: "GitLab",
24 pickerLabel: "GitLab",
24 - icon: "gitlab",
25 + icon,
26 changeRequest: { shortLabel: "MR", singular: "merge request" },
27 repositoryPathHint: "group/project",
28 publicHost: "gitlab.com",
packages/source-control-gitlab/src/client/icon.ts new
+23
@@ -0,0 +1,23 @@
1 +import type { SourceControlIcon } from "@t3tools/source-control-core/client/definition";
2 +
3 +export const icon: SourceControlIcon = {
4 + viewBox: "0 0 32 32",
5 + paths: [
6 + {
7 + d: "m31.46 12.78-.04-.12-4.35-11.35A1.14 1.14 0 0 0 25.94.6c-.24 0-.47.1-.66.24-.19.15-.33.36-.39.6l-2.94 9h-11.9l-2.94-9A1.14 1.14 0 0 0 6.07.58a1.15 1.15 0 0 0-1.14.72L.58 12.68l-.05.11a8.1 8.1 0 0 0 2.68 9.34l.02.01.04.03 6.63 4.97 3.28 2.48 2 1.52a1.35 1.35 0 0 0 1.62 0l2-1.52 3.28-2.48 6.67-5h.02a8.09 8.09 0 0 0 2.7-9.36Z",
8 + fill: "#E24329",
9 + },
10 + {
11 + d: "m31.46 12.78-.04-.12a14.75 14.75 0 0 0-5.86 2.64l-9.55 7.24 6.09 4.6 6.67-5h.02a8.09 8.09 0 0 0 2.67-9.36Z",
12 + fill: "#FC6D26",
13 + },
14 + {
15 + d: "m9.9 27.14 3.28 2.48 2 1.52a1.35 1.35 0 0 0 1.62 0l2-1.52 3.28-2.48-6.1-4.6-6.07 4.6Z",
16 + fill: "#FCA326",
17 + },
18 + {
19 + d: "M6.44 15.3a14.71 14.71 0 0 0-5.86-2.63l-.05.12a8.1 8.1 0 0 0 2.68 9.34l.02.01.04.03 6.63 4.97 6.1-4.6-9.56-7.24Z",
20 + fill: "#FC6D26",
21 + },
22 + ],
23 +};