Skip to content
TypeScript

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

Julius Marminge326e08b08a96
diff --git a/apps/mobile/assets/link-icons/azure-devops.png b/apps/mobile/assets/link-icons/azure-devops.png
new file mode 100644
index 00000000000..0d0f09b2981
Binary files /dev/null and b/apps/mobile/assets/link-icons/azure-devops.png differ
diff --git a/apps/mobile/assets/link-icons/bitbucket.png b/apps/mobile/assets/link-icons/bitbucket.png
new file mode 100644
index 00000000000..91799fb692e
Binary files /dev/null and b/apps/mobile/assets/link-icons/bitbucket.png differ
diff --git a/apps/mobile/assets/link-icons/forgejo.png b/apps/mobile/assets/link-icons/forgejo.png
new file mode 100644
index 00000000000..a80471d31bd
Binary files /dev/null and b/apps/mobile/assets/link-icons/forgejo.png differ
diff --git a/apps/mobile/assets/link-icons/gitcafe.png b/apps/mobile/assets/link-icons/gitcafe.png
new file mode 100644
index 00000000000..5604d59a9d1
Binary files /dev/null and b/apps/mobile/assets/link-icons/gitcafe.png differ
diff --git a/apps/mobile/assets/link-icons/github.png b/apps/mobile/assets/link-icons/github.png
index 87eab9f5218..502b7ada4e7 100644
Binary files a/apps/mobile/assets/link-icons/github.png and b/apps/mobile/assets/link-icons/github.png differ
diff --git a/apps/mobile/assets/link-icons/gitlab.png b/apps/mobile/assets/link-icons/gitlab.png
new file mode 100644
index 00000000000..28d26431001
Binary files /dev/null and b/apps/mobile/assets/link-icons/gitlab.png differ
diff --git a/apps/mobile/package.json b/apps/mobile/package.json
index 2225adf5273..01b54ef2f13 100644
--- a/apps/mobile/package.json
+++ b/apps/mobile/package.json
@@ -41,6 +41,7 @@
"config:prod": "APP_VARIANT=production expo config",
"profile:android:hermes": "mkdir -p profiles/review && react-native profile-hermes profiles/review",
"sync:chip-icons": "node scripts/sync-context-chip-icons.mjs",
+ "sync:link-icons": "node scripts/sync-link-icons.ts",
"sync:pierre-icons": "node scripts/sync-pierre-file-icons.mjs",
"measure-renders": "node scripts/measure-renders.mts",
"generate": "node --disable-warning=MODULE_TYPELESS_PACKAGE_JSON scripts/generate-uniwind-themes.mts",
diff --git a/apps/mobile/scripts/sync-link-icons.ts b/apps/mobile/scripts/sync-link-icons.ts
new file mode 100644
index 00000000000..981c2485a04
--- /dev/null
+++ b/apps/mobile/scripts/sync-link-icons.ts
@@ -0,0 +1,79 @@
+// The native markdown renderer draws a link's icon from a raster image, so each source control
+// host's mark is rendered from its definition's artwork into a bundled PNG.
+import * as NodeFS from "node:fs";
+import * as NodeModule from "node:module";
+import * as NodePath from "node:path";
+import * as NodeURL from "node:url";
+
+import {
+ sourceControlClients,
+ type SourceControlIcon,
+} from "@t3tools/client-runtime/source-control-clients";
+
+const appDirectory = NodePath.resolve(
+ NodePath.dirname(NodeURL.fileURLToPath(import.meta.url)),
+ "..",
+);
+const outputDirectory = NodePath.join(appDirectory, "assets/link-icons");
+const generatedModulePath = NodePath.join(appDirectory, "src/lib/markdownLinkIcons.generated.ts");
+const sharp = NodeModule.createRequire(
+ NodePath.resolve(appDirectory, "../../scripts/package.json"),
+)("sharp");
+
+const SIZE = 64;
+
+function attribute(name: string, value: string | number | undefined): string {
+ return value === undefined ? "" : ` ${name}="${value}"`;
+}
+
+// A monochrome mark is tinted by the renderer, which only reads its alpha.
+function svgMarkup(icon: SourceControlIcon): string {
+ const paint = (value: SourceControlIcon["paths"][number]["fill"]) =>
+ value === undefined
+ ? "none"
+ : typeof value === "string"
+ ? value.replace("currentColor", "#ffffff")
+ : `url(#${value.gradient})`;
+ const gradients = (icon.gradients ?? [])
+ .map(
+ (gradient) =>
+ `<linearGradient id="${gradient.id}" x1="${gradient.x1}" y1="${gradient.y1}" x2="${gradient.x2}" y2="${gradient.y2}" gradientUnits="userSpaceOnUse"${attribute("gradientTransform", gradient.transform)}>${gradient.stops
+ .map(
+ (stop) =>
+ `<stop offset="${stop.offset}" stop-color="${stop.color}"${attribute("stop-opacity", stop.opacity)}/>`,
+ )
+ .join("")}</linearGradient>`,
+ )
+ .join("");
+ const paths = icon.paths
+ .map(
+ (path) =>
+ `<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)}/>`,
+ )
+ .join("");
+ return `<svg xmlns="http://www.w3.org/2000/svg" width="${SIZE}" height="${SIZE}" viewBox="${icon.viewBox}" fill="none"><defs>${gradients}</defs>${paths}</svg>`;
+}
+
+NodeFS.rmSync(outputDirectory, { recursive: true, force: true });
+NodeFS.mkdirSync(outputDirectory, { recursive: true });
+
+const kinds: string[] = [];
+for (const definition of sourceControlClients.definitions) {
+ if (definition.icon === null) continue;
+ await sharp(Buffer.from(svgMarkup(definition.icon)), { density: 72 * 4 })
+ .resize(SIZE, SIZE, { fit: "contain", background: { r: 0, g: 0, b: 0, alpha: 0 } })
+ .png()
+ .toFile(NodePath.join(outputDirectory, `${definition.kind}.png`));
+ kinds.push(definition.kind);
+}
+
+NodeFS.writeFileSync(
+ generatedModulePath,
+ `import type { ImageSourcePropType } from "react-native";\n\nexport const SOURCE_CONTROL_LINK_ICON_SOURCES: Readonly<Record<string, ImageSourcePropType>> = {\n${kinds
+ .toSorted()
+ .map(
+ (kind) =>
+ ` ${/^\w+$/u.test(kind) ? kind : `"${kind}"`}: require("../../assets/link-icons/${kind}.png"),`,
+ )
+ .join("\n")}\n};\n`,
+);
diff --git a/apps/mobile/src/connection/storage.ts b/apps/mobile/src/connection/storage.ts
index 0bb20a769ed..83805e11942 100644
--- a/apps/mobile/src/connection/storage.ts
+++ b/apps/mobile/src/connection/storage.ts
@@ -13,8 +13,8 @@ import {
ConnectionTransientError,
CredentialStore,
ProfileStore,
- GitHubRoutingPermissions,
- makeGitHubRoutingPermissions,
+ PullRequestRoutingPermissions,
+ makePullRequestRoutingPermissions,
} from "@t3tools/client-runtime/connection";
import * as Context from "effect/Context";
import * as Effect from "effect/Effect";
@@ -42,7 +42,7 @@ function targetPersistenceError(
export const layer = Layer.effectContext(
Effect.gen(function* () {
const catalog = yield* CatalogStore.make();
- const githubRoutingPermissions = yield* makeGitHubRoutingPermissions({
+ const githubRoutingPermissions = yield* makePullRequestRoutingPermissions({
read: catalog.read.pipe(Effect.map((document) => document.githubRoutingPermissions ?? [])),
write: (githubRoutingPermissions) =>
catalog.update((document) => ({ ...document, githubRoutingPermissions })),
@@ -150,7 +150,7 @@ export const layer = Layer.effectContext(
})),
});
return Context.make(Persistence.ConnectionTargetStore, targetStore).pipe(
- Context.add(GitHubRoutingPermissions, githubRoutingPermissions),
+ Context.add(PullRequestRoutingPermissions, githubRoutingPermissions),
Context.add(Persistence.ConnectionRegistrationStore, registrationStore),
Context.add(ProfileStore.ConnectionProfileStore, profileStore),
Context.add(CredentialStore.ConnectionCredentialStore, credentialStore),
diff --git a/apps/mobile/src/features/connection/ConnectionsRouteScreen.tsx b/apps/mobile/src/features/connection/ConnectionsRouteScreen.tsx
index 4696b459ef0..6192b53301c 100644
--- a/apps/mobile/src/features/connection/ConnectionsRouteScreen.tsx
+++ b/apps/mobile/src/features/connection/ConnectionsRouteScreen.tsx
@@ -10,7 +10,7 @@ import { useSafeAreaInsets } from "react-native-safe-area-context";
import { AndroidScreenHeader } from "../../components/ui/AndroidScreenHeader";
import { useRemoteConnections } from "../../state/use-remote-environment-registry";
import { LocalEnvironmentList } from "./LocalEnvironmentList";
-import { GitHubRoutingSettings } from "./GitHubRoutingSettings";
+import { PullRequestRoutingSettings } from "./PullRequestRoutingSettings";
export function ConnectionsRouteScreen() {
const {
@@ -69,7 +69,7 @@ export function ConnectionsRouteScreen() {
onSetEnabled={onSetEnvironmentEnabled}
onUpdate={onUpdateEnvironment}
/>
- <GitHubRoutingSettings />
+ <PullRequestRoutingSettings />
</ScrollView>
</View>
);
diff --git a/apps/mobile/src/features/connection/GitHubRoutingSettings.tsx b/apps/mobile/src/features/connection/PullRequestRoutingSettings.tsx
similarity index 76%
rename from apps/mobile/src/features/connection/GitHubRoutingSettings.tsx
rename to apps/mobile/src/features/connection/PullRequestRoutingSettings.tsx
index 199174208fd..44383db74b2 100644
--- a/apps/mobile/src/features/connection/GitHubRoutingSettings.tsx
+++ b/apps/mobile/src/features/connection/PullRequestRoutingSettings.tsx
@@ -3,9 +3,9 @@ import * as Dialog from "../../components/ui/Dialog";
import { useAtomValue } from "@effect/atom-react";
import {
connectionCatalogDisplayUrl,
- gitHubRoutingConnectionKey,
- gitHubRoutingPermissionFor,
- type GitHubRoutingPermission,
+ pullRequestRoutingConnectionKey,
+ pullRequestRoutingPermissionFor,
+ type PullRequestRoutingPermission,
} from "@t3tools/client-runtime/connection";
import { useState } from "react";
import { Pressable, View } from "react-native";
@@ -17,11 +17,11 @@ import { useAtomCommand } from "../../state/use-atom-command";
import { SettingsSection } from "../settings/components/SettingsSection";
const options: ReadonlyArray<{
- value: GitHubRoutingPermission;
+ value: PullRequestRoutingPermission;
label: string;
description: string;
}> = [
- { value: "off", label: "Off", description: "Keep GitHub requests on this environment." },
+ { value: "off", label: "Off", description: "Keep source control requests on this environment." },
{
value: "read",
label: "Read PRs",
@@ -30,30 +30,32 @@ const options: ReadonlyArray<{
{
value: "read-write",
label: "Read and act",
- description: "Actions may use broader GitHub permissions than the original environment.",
+ description:
+ "Actions may use broader source control permissions than the original environment.",
},
];
-export function GitHubRoutingSettings() {
+export function PullRequestRoutingSettings() {
const catalog = useAtomValue(environmentCatalog.catalogValueAtom);
- const permissions = useAtomValue(environmentCatalog.githubRoutingPermissionsValueAtom);
- const update = useAtomCommand(environmentCatalog.setGitHubRoutingPermission);
+ const permissions = useAtomValue(environmentCatalog.pullRequestRoutingPermissionsValueAtom);
+ const update = useAtomCommand(environmentCatalog.setPullRequestRoutingPermission);
const [expanded, setExpanded] = useState<string | null>(null);
const [saving, setSaving] = useState(false);
if (catalog.entries.size === 0) return null;
return (
<View className="mt-5 gap-3">
- <SettingsSection title="GitHub routing">
+ <SettingsSection title="Pull request routing">
{[...catalog.entries.values()].map((entry) => {
const environmentId = entry.target.environmentId;
- const selected = gitHubRoutingPermissionFor(entry, permissions);
- const disabled = !catalog.isReady || saving || gitHubRoutingConnectionKey(entry) === null;
+ const selected = pullRequestRoutingPermissionFor(entry, permissions);
+ const disabled =
+ !catalog.isReady || saving || pullRequestRoutingConnectionKey(entry) === null;
return (
<View key={environmentId}>
<Pressable
accessibilityRole="button"
- accessibilityLabel={`${entry.target.label} GitHub routing`}
+ accessibilityLabel={`${entry.target.label} pull request routing`}
accessibilityState={{ expanded: expanded === environmentId }}
className="flex-row items-center gap-3 p-4"
onPress={() => setExpanded(expanded === environmentId ? null : environmentId)}
@@ -89,7 +91,7 @@ export function GitHubRoutingSettings() {
setSaving(false);
if (result._tag === "Failure")
Dialog.alert(
- "Could not save GitHub routing permission",
+ "Could not save pull request routing permission",
"Try again before leaving this screen.",
);
});
@@ -102,8 +104,8 @@ export function GitHubRoutingSettings() {
})}
</SettingsSection>
<Text className="px-2 text-sm text-foreground-muted">
- Choose environments you trust to share PR data and use each other's GitHub access. Enable
- both environments. This applies only to this client.
+ Choose environments you trust to share PR data and use each other's source control access.
+ Enable both environments. This applies only to this client.
</Text>
</View>
);
diff --git a/apps/mobile/src/features/projects/AddProjectScreen.tsx b/apps/mobile/src/features/projects/AddProjectScreen.tsx
index 9ac01547d03..903a16140d6 100644
--- a/apps/mobile/src/features/projects/AddProjectScreen.tsx
+++ b/apps/mobile/src/features/projects/AddProjectScreen.tsx
@@ -475,7 +475,7 @@ function SourceControlRow(props: {
/>
) : (
<SourceControlIcon
- kind={sourceControlClients.get(props.source).icon}
+ icon={sourceControlClients.get(props.source).icon}
size={Platform.OS === "android" ? 24 : 18}
colorClassName="accent-icon"
/>
@@ -1113,7 +1113,7 @@ export function AddProjectNewScreen(props: { readonly environmentId?: string | s
}
icon={
<SourceControlIcon
- kind={publishTarget.definition.icon}
+ icon={publishTarget.definition.icon}
size={Platform.OS === "android" ? 24 : 18}
colorClassName="accent-icon"
/>
@@ -1137,7 +1137,7 @@ export function AddProjectNewScreen(props: { readonly environmentId?: string | s
title={target.definition.label}
icon={
<SourceControlIcon
- kind={target.definition.icon}
+ icon={target.definition.icon}
size={Platform.OS === "android" ? 24 : 17}
colorClassName="accent-icon"
/>
diff --git a/apps/mobile/src/features/projects/SourceControlIcon.tsx b/apps/mobile/src/features/projects/SourceControlIcon.tsx
index fe31f90416a..94b72ce3505 100644
--- a/apps/mobile/src/features/projects/SourceControlIcon.tsx
+++ b/apps/mobile/src/features/projects/SourceControlIcon.tsx
@@ -1,261 +1,76 @@
-import Svg, { Circle, Defs, G, LinearGradient, Path, Rect, Stop } from "react-native-svg";
+import type { SourceControlIcon as SourceControlIconArtwork } from "@t3tools/client-runtime/source-control-clients";
+import { useId } from "react";
+import Svg, { Defs, LinearGradient, Path, Stop } from "react-native-svg";
import { withUniwind } from "uniwind";
const ThemedSvg = withUniwind(Svg);
+/** Draws a host's mark from its definition's artwork; `currentColor` follows `color`. */
export function SourceControlIcon(props: {
- readonly kind: string;
+ readonly icon: SourceControlIconArtwork | null;
readonly size?: number;
readonly color?: string;
readonly colorClassName?: string;
}) {
+ // Gradient ids must not collide when one screen shows the same mark more than once.
+ const idPrefix = useId().replace(/[^\w-]/gu, "");
const size = props.size ?? 18;
+ const { icon } = props;
+ if (icon === null) return null;
+ const paint = (value: SourceControlIconArtwork["paths"][number]["fill"]) =>
+ value === undefined
+ ? "none"
+ : typeof value === "string"
+ ? value
+ : `url(#${idPrefix}-${value.gradient})`;
- switch (props.kind) {
- case "forgejo":
- return (
- <Svg width={size} height={size} viewBox="0 0 212 212">
- <G transform="translate(6 6)" fill="none">
- <Path d="M58 168 v-98 a50 50 0 0 1 50-50 h20" stroke="#ff6600" strokeWidth={25} />
- <Path d="M58 168 v-30 a50 50 0 0 1 50-50 h20" stroke="#d40000" strokeWidth={25} />
- <Circle cx={142} cy={20} r={18} stroke="#ff6600" strokeWidth={15} />
- <Circle cx={142} cy={88} r={18} stroke="#d40000" strokeWidth={15} />
- <Circle cx={58} cy={180} r={18} stroke="#d40000" strokeWidth={15} />
- </G>
- </Svg>
- );
- case "github":
- return (
- <ThemedSvg
- width={size}
- height={size}
- viewBox="0 0 16 16"
- color={props.color}
- colorClassName={props.colorClassName}
- fill="none"
- >
- <Path
- fillRule="evenodd"
- clipRule="evenodd"
- 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"
- fill="currentColor"
- />
- </ThemedSvg>
- );
- case "gitlab":
- return (
- <Svg width={size} height={size} viewBox="0 0 32 32" fill="none">
- <Path
- 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"
- fill="#E24329"
- />
- <Path
- 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"
- fill="#FC6D26"
- />
- <Path
- 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"
- fill="#FCA326"
- />
- <Path
- 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"
- fill="#FC6D26"
- />
- </Svg>
- );
- case "azure-devops":
- // Microsoft Azure DevOps mark via selfhst/icons (CC BY 4.0): https://github.com/selfhst/icons/blob/main/svg/azure-devops.svg
- return (
- <Svg width={size} height={size} viewBox="0 0 512 512">
- <Defs>
+ return (
+ <ThemedSvg
+ width={size}
+ height={size}
+ viewBox={icon.viewBox}
+ color={props.color}
+ colorClassName={props.colorClassName}
+ fill="none"
+ >
+ {icon.gradients ? (
+ <Defs>
+ {icon.gradients.map((gradient) => (
<LinearGradient
- id="azure-a"
- x1="58.027"
- x2="58.027"
- y1="356.668"
- y2="100.668"
- gradientTransform="matrix(1 0 0 -1 0 514)"
+ key={gradient.id}
+ id={`${idPrefix}-${gradient.id}`}
+ x1={gradient.x1}
+ y1={gradient.y1}
+ x2={gradient.x2}
+ y2={gradient.y2}
+ gradientTransform={gradient.transform}
gradientUnits="userSpaceOnUse"
>
- <Stop offset="0" stopColor="#163697" />
- <Stop offset=".276" stopColor="#2052cb" />
- <Stop offset=".518" stopColor="#2764e7" />
- <Stop offset=".879" stopColor="#367af2" />
+ {gradient.stops.map((stop) => (
+ <Stop
+ key={stop.offset}
+ offset={stop.offset}
+ stopColor={stop.color}
+ stopOpacity={stop.opacity}
+ />
+ ))}
</LinearGradient>
- <LinearGradient
- id="azure-b"
- x1="58.027"
- x2="58.027"
- y1="351.334"
- y2="292.668"
- gradientTransform="matrix(1 0 0 -1 0 514)"
- gradientUnits="userSpaceOnUse"
- >
- <Stop offset="0" stopColor="#102784" />
- <Stop offset="1" stopColor="#2052cb" stopOpacity="0" />
- </LinearGradient>
- <LinearGradient
- id="azure-c"
- x1="389.98"
- x2="107.314"
- y1="57.935"
- y2="193.935"
- gradientTransform="matrix(1 0 0 -1 0 514)"
- gradientUnits="userSpaceOnUse"
- >
- <Stop offset="0" stopColor="#163697" />
- <Stop offset=".301" stopColor="#2052cb" />
- <Stop offset=".626" stopColor="#2764e7" />
- <Stop offset=".926" stopColor="#367af2" />
- </LinearGradient>
- <LinearGradient
- id="azure-d"
- x1="391.996"
- x2="341.385"
- y1="76.552"
- y2="78.224"
- gradientTransform="matrix(1 0 0 -1 0 514)"
- gradientUnits="userSpaceOnUse"
- >
- <Stop offset="0" stopColor="#102784" />
- <Stop offset="1" stopColor="#2052cb" stopOpacity="0" />
- </LinearGradient>
- <LinearGradient
- id="azure-e"
- x1="442.24"
- x2="442.24"
- y1="54.769"
- y2="419.38"
- gradientTransform="matrix(1 0 0 -1 0 514)"
- gradientUnits="userSpaceOnUse"
- >
- <Stop offset=".043" stopColor="#2052cb" />
- <Stop offset=".489" stopColor="#367af2" />
- <Stop offset=".943" stopColor="#16bbda" />
- </LinearGradient>
- <LinearGradient
- id="azure-f"
- x1="435.596"
- x2="425.732"
- y1="270.413"
- y2="385.266"
- gradientTransform="matrix(1 0 0 -1 0 514)"
- gradientUnits="userSpaceOnUse"
- >
- <Stop offset=".134" stopColor="#16bbda" stopOpacity="0" />
- <Stop offset=".932" stopColor="#6be7a0" stopOpacity=".8629" />
- </LinearGradient>
- <LinearGradient
- id="azure-g"
- x1="437.081"
- x2="507.893"
- y1="204.362"
- y2="119.081"
- gradientTransform="matrix(1 0 0 -1 0 514)"
- gradientUnits="userSpaceOnUse"
- >
- <Stop offset="0" stopColor="#2c68e0" stopOpacity="0" />
- <Stop offset=".898" stopColor="#66c0ff" stopOpacity=".5" />
- </LinearGradient>
- <LinearGradient
- id="azure-h"
- x1="99.399"
- x2="352.75"
- y1="279.26"
- y2="498.676"
- gradientTransform="matrix(1 0 0 -1 0 514)"
- gradientUnits="userSpaceOnUse"
- >
- <Stop offset=".005" stopColor="#367af2" />
- <Stop offset=".507" stopColor="#0fafff" />
- <Stop offset="1" stopColor="#26cfe8" />
- </LinearGradient>
- <LinearGradient
- id="azure-i"
- x1="184.342"
- x2="338.581"
- y1="356.795"
- y2="480.642"
- gradientTransform="matrix(1 0 0 -1 0 514)"
- gradientUnits="userSpaceOnUse"
- >
- <Stop offset=".443" stopColor="#26cfe8" stopOpacity="0" />
- <Stop offset=".897" stopColor="#6be7a0" stopOpacity=".8629" />
- </LinearGradient>
- </Defs>
- <Path
- 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"
- fill="url(#azure-a)"
- />
- <Path
- 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"
- fill="url(#azure-b)"
- />
- <Path
- 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"
- fill="url(#azure-c)"
- />
- <Path
- 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"
- fill="url(#azure-d)"
- />
- <Path
- 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"
- fill="url(#azure-e)"
- />
- <Path
- 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"
- fill="url(#azure-f)"
- fillOpacity=".7"
- />
- <Path
- 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"
- fill="url(#azure-g)"
- />
- <Path
- 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"
- fill="url(#azure-h)"
- />
- <Path
- 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"
- fill="url(#azure-i)"
- fillOpacity=".5"
- />
- </Svg>
- );
- case "bitbucket":
- return (
- <Svg width={size} height={size} viewBox="8.4 14.39 2481.29 2231.21">
- <Defs>
- <LinearGradient
- id="bitbucket-a"
- x1="945.1094"
- y1="1524.8389"
- x2="944.4923"
- y2="1524.1893"
- gradientTransform="matrix(1996.6343 0 0 -1480.3047 -1884485.625 2258195)"
- >
- <Stop offset="0.18" stopColor="#0052CC" />
- <Stop offset="1" stopColor="#2684FF" />
- </LinearGradient>
- </Defs>
- <Path
- fill="#2684FF"
- 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"
- />
- <Path
- fill="url(#bitbucket-a)"
- 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"
- />
- </Svg>
- );
- case "gitcafe":
- return (
- <Svg width={size} height={size} viewBox="0 0 64 64">
- <Rect x={4.8} y={4.8} width={54.4} height={54.4} fill="#a78bfa" />
- </Svg>
- );
- default:
- return null;
- }
+ ))}
+ </Defs>
+ ) : null}
+ {icon.paths.map((path, index) => (
+ <Path
+ // Paths repeat with different paints, so their data is not a key.
+ // oxlint-disable-next-line react/no-array-index-key
+ key={index}
+ d={path.d}
+ fill={paint(path.fill)}
+ fillRule={path.fillRule}
+ fillOpacity={path.fillOpacity}
+ stroke={path.stroke}
+ strokeWidth={path.strokeWidth}
+ />
+ ))}
+ </ThemedSvg>
+ );
}
diff --git a/apps/mobile/src/features/settings/SettingsEnvironmentsRouteScreen.tsx b/apps/mobile/src/features/settings/SettingsEnvironmentsRouteScreen.tsx
index 3710c2f1e91..4a23fdf98a3 100644
--- a/apps/mobile/src/features/settings/SettingsEnvironmentsRouteScreen.tsx
+++ b/apps/mobile/src/features/settings/SettingsEnvironmentsRouteScreen.tsx
@@ -12,7 +12,7 @@ import { AndroidAnchoredMenu } from "../../components/ui/AndroidAnchoredMenu";
import { AndroidHeaderIconButton } from "../../components/ui/AndroidScreenHeader";
import { CloudEnvironmentRows } from "../connection/CloudEnvironmentRows";
import { LocalEnvironmentList } from "../connection/LocalEnvironmentList";
-import { GitHubRoutingSettings } from "../connection/GitHubRoutingSettings";
+import { PullRequestRoutingSettings } from "../connection/PullRequestRoutingSettings";
import { splitEnvironmentSections } from "../connection/environmentSections";
import { useUniwindTheme } from "../../lib/useUniwindTheme";
import { useRemoteConnections } from "../../state/use-remote-environment-registry";
@@ -179,7 +179,7 @@ export function SettingsEnvironmentsRouteScreen() {
}
: {})}
/>
- <GitHubRoutingSettings />
+ <PullRequestRoutingSettings />
</ScrollView>
</SettingsScreen>
);
diff --git a/apps/mobile/src/lib/markdownLinkIcons.generated.ts b/apps/mobile/src/lib/markdownLinkIcons.generated.ts
new file mode 100644
index 00000000000..d6b13c78904
--- /dev/null
+++ b/apps/mobile/src/lib/markdownLinkIcons.generated.ts
@@ -0,0 +1,10 @@
+import type { ImageSourcePropType } from "react-native";
+
+export const SOURCE_CONTROL_LINK_ICON_SOURCES: Readonly<Record<string, ImageSourcePropType>> = {
+ "azure-devops": require("../../assets/link-icons/azure-devops.png"),
+ bitbucket: require("../../assets/link-icons/bitbucket.png"),
+ forgejo: require("../../assets/link-icons/forgejo.png"),
+ gitcafe: require("../../assets/link-icons/gitcafe.png"),
+ github: require("../../assets/link-icons/github.png"),
+ gitlab: require("../../assets/link-icons/gitlab.png"),
+};
diff --git a/apps/mobile/src/lib/markdownLinkIcons.ts b/apps/mobile/src/lib/markdownLinkIcons.ts
index f88ac2f52bc..2aa25166daf 100644
--- a/apps/mobile/src/lib/markdownLinkIcons.ts
+++ b/apps/mobile/src/lib/markdownLinkIcons.ts
@@ -1,13 +1,22 @@
-import { sourceControlClients } from "@t3tools/client-runtime/source-control-clients";
+import {
+ isMonochromeSourceControlIcon,
+ sourceControlClients,
+} from "@t3tools/client-runtime/source-control-clients";
import type { ImageSourcePropType } from "react-native";
-// The native renderer draws a link's icon from an image, so a host's mark is a bundled image keyed
-// by its definition's `icon`. A host without one keeps a plain link.
-const SOURCE_CONTROL_LINK_ICON_SOURCES: Partial<Record<string, ImageSourcePropType>> = {
- github: require("../../assets/link-icons/github.png"),
-};
+import { SOURCE_CONTROL_LINK_ICON_SOURCES } from "./markdownLinkIcons.generated";
-export function markdownLinkIconSource(host: string): ImageSourcePropType | null {
- const icon = sourceControlClients.findByPublicDomain(host)?.icon;
- return (icon === undefined ? undefined : SOURCE_CONTROL_LINK_ICON_SOURCES[icon]) ?? null;
+export interface MarkdownLinkIcon {
+ readonly source: ImageSourcePropType;
+ /** A mark drawn in the text colour takes the link's colour; a coloured mark keeps its own. */
+ readonly tints: boolean;
+}
+
+// `vp run sync:link-icons` renders each host's artwork into the bundled image this reads.
+export function markdownLinkIcon(host: string): MarkdownLinkIcon | null {
+ const definition = sourceControlClients.findByPublicDomain(host);
+ const source = definition && SOURCE_CONTROL_LINK_ICON_SOURCES[definition.kind];
+ return definition?.icon && source
+ ? { source, tints: isMonochromeSourceControlIcon(definition.icon) }
+ : null;
}
diff --git a/apps/mobile/src/native/useEnrichedLinkVariants.ts b/apps/mobile/src/native/useEnrichedLinkVariants.ts
index dda01bd7545..575c6231d0f 100644
--- a/apps/mobile/src/native/useEnrichedLinkVariants.ts
+++ b/apps/mobile/src/native/useEnrichedLinkVariants.ts
@@ -11,7 +11,7 @@ import { CONTEXT_CHIP_ICON_SOURCES } from "../lib/contextChipIcons.generated";
import { FONT_FAMILIES } from "../lib/fontFamilies";
import { contextChipIconSource } from "../lib/contextChipIconSource";
import { markdownFileIconSource } from "../lib/markdownFileIcons";
-import { markdownLinkIconSource } from "../lib/markdownLinkIcons";
+import { markdownLinkIcon } from "../lib/markdownLinkIcons";
import { useUniwindTheme } from "../lib/useUniwindTheme";
import { resolveMarkdownLinkPresentation } from "../lib/markdownLinks";
import type {
@@ -83,12 +83,12 @@ function presentation(
icon: markdownFileIconSource(link.icon),
chip: { accent: contextChipPresentation("mention").accent, tintsIcon: false },
};
- const icon = link.kind === "external" ? markdownLinkIconSource(link.host) : null;
+ const icon = link.kind === "external" ? markdownLinkIcon(link.host) : null;
return icon
? {
color: props.textStyle.linkColor,
- icon,
- iconTintColor: props.textStyle.linkColor,
+ icon: icon.source,
+ ...(icon.tints ? { iconTintColor: props.textStyle.linkColor } : {}),
}
: undefined;
}
diff --git a/apps/web/src/components/Icons.tsx b/apps/web/src/components/Icons.tsx
index 8faedef400f..551312e23f1 100644
--- a/apps/web/src/components/Icons.tsx
+++ b/apps/web/src/components/Icons.tsx
@@ -69,18 +69,6 @@ export const LinuxIcon: Icon = ({ className, ...props }) => (
</svg>
);
-export const GitHubIcon: Icon = (props) => (
- <svg {...props} viewBox="0 0 1024 1024" fill="none">
- <path
- fillRule="evenodd"
- clipRule="evenodd"
- 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"
- transform="scale(64)"
- fill="currentColor"
- />
- </svg>
-);
-
export const GitIcon: Icon = (props) => (
<svg {...props} viewBox="0 0 256 256">
<path
@@ -134,226 +122,6 @@ export const JujutsuIcon: Icon = (props) => {
);
};
-export const GitLabIcon = ({
- monochrome = false,
- ...props
-}: SVGProps<SVGSVGElement> & { readonly monochrome?: boolean }) => (
- <svg {...props} viewBox="0 0 32 32" fill="none">
- <path
- 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"
- fill={monochrome ? "currentColor" : "#E24329"}
- />
- <path
- 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"
- fill={monochrome ? "currentColor" : "#FC6D26"}
- />
- <path
- 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"
- fill={monochrome ? "currentColor" : "#FCA326"}
- />
- <path
- 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"
- fill={monochrome ? "currentColor" : "#FC6D26"}
- />
- </svg>
-);
-
-// Microsoft Azure DevOps mark via selfhst/icons (CC BY 4.0): https://github.com/selfhst/icons/blob/main/svg/azure-devops.svg
-export const AzureDevOpsIcon: Icon = (props) => {
- const id = useId().replaceAll(":", "");
- const gradientId = `${id}-azure`;
-
- return (
- <svg {...props} viewBox="0 0 512 512">
- <defs>
- <linearGradient
- id={`${gradientId}-a`}
- x1="58.027"
- x2="58.027"
- y1="356.668"
- y2="100.668"
- gradientTransform="matrix(1 0 0 -1 0 514)"
- gradientUnits="userSpaceOnUse"
- >
- <stop offset="0" stopColor="#163697" />
- <stop offset=".276" stopColor="#2052cb" />
- <stop offset=".518" stopColor="#2764e7" />
- <stop offset=".879" stopColor="#367af2" />
- </linearGradient>
- <linearGradient
- id={`${gradientId}-b`}
- x1="58.027"
- x2="58.027"
- y1="351.334"
- y2="292.668"
- gradientTransform="matrix(1 0 0 -1 0 514)"
- gradientUnits="userSpaceOnUse"
- >
- <stop offset="0" stopColor="#102784" />
- <stop offset="1" stopColor="#2052cb" stopOpacity="0" />
- </linearGradient>
- <linearGradient
- id={`${gradientId}-c`}
- x1="389.98"
- x2="107.314"
- y1="57.935"
- y2="193.935"
- gradientTransform="matrix(1 0 0 -1 0 514)"
- gradientUnits="userSpaceOnUse"
- >
- <stop offset="0" stopColor="#163697" />
- <stop offset=".301" stopColor="#2052cb" />
- <stop offset=".626" stopColor="#2764e7" />
- <stop offset=".926" stopColor="#367af2" />
- </linearGradient>
- <linearGradient
- id={`${gradientId}-d`}
- x1="391.996"
- x2="341.385"
- y1="76.552"
- y2="78.224"
- gradientTransform="matrix(1 0 0 -1 0 514)"
- gradientUnits="userSpaceOnUse"
- >
- <stop offset="0" stopColor="#102784" />
- <stop offset="1" stopColor="#2052cb" stopOpacity="0" />
- </linearGradient>
- <linearGradient
- id={`${gradientId}-e`}
- x1="442.24"
- x2="442.24"
- y1="54.769"
- y2="419.38"
- gradientTransform="matrix(1 0 0 -1 0 514)"
- gradientUnits="userSpaceOnUse"
- >
- <stop offset=".043" stopColor="#2052cb" />
- <stop offset=".489" stopColor="#367af2" />
- <stop offset=".943" stopColor="#16bbda" />
- </linearGradient>
- <linearGradient
- id={`${gradientId}-f`}
- x1="435.596"
- x2="425.732"
- y1="270.413"
- y2="385.266"
- gradientTransform="matrix(1 0 0 -1 0 514)"
- gradientUnits="userSpaceOnUse"
- >
- <stop offset=".134" stopColor="#16bbda" stopOpacity="0" />
- <stop offset=".932" stopColor="#6be7a0" stopOpacity=".8629" />
- </linearGradient>
- <linearGradient
- id={`${gradientId}-g`}
- x1="437.081"
- x2="507.893"
- y1="204.362"
- y2="119.081"
- gradientTransform="matrix(1 0 0 -1 0 514)"
- gradientUnits="userSpaceOnUse"
- >
- <stop offset="0" stopColor="#2c68e0" stopOpacity="0" />
- <stop offset=".898" stopColor="#66c0ff" stopOpacity=".5" />
- </linearGradient>
- <linearGradient
- id={`${gradientId}-h`}
- x1="99.399"
- x2="352.75"
- y1="279.26"
- y2="498.676"
- gradientTransform="matrix(1 0 0 -1 0 514)"
- gradientUnits="userSpaceOnUse"
- >
- <stop offset=".005" stopColor="#367af2" />
- <stop offset=".507" stopColor="#0fafff" />
- <stop offset="1" stopColor="#26cfe8" />
- </linearGradient>
- <linearGradient
- id={`${gradientId}-i`}
- x1="184.342"
- x2="338.581"
- y1="356.795"
- y2="480.642"
- gradientTransform="matrix(1 0 0 -1 0 514)"
- gradientUnits="userSpaceOnUse"
- >
- <stop offset=".443" stopColor="#26cfe8" stopOpacity="0" />
- <stop offset=".897" stopColor="#6be7a0" stopOpacity=".8629" />
- </linearGradient>
- </defs>
- <path
- 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"
- fill={`url(#${gradientId}-a)`}
- />
- <path
- 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"
- fill={`url(#${gradientId}-b)`}
- />
- <path
- 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"
- fill={`url(#${gradientId}-c)`}
- />
- <path
- 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"
- fill={`url(#${gradientId}-d)`}
- />
- <path
- 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"
- fill={`url(#${gradientId}-e)`}
- />
- <path
- 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"
- fill={`url(#${gradientId}-f)`}
- fillOpacity=".7"
- />
- <path
- 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"
- fill={`url(#${gradientId}-g)`}
- />
- <path
- 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"
- fill={`url(#${gradientId}-h)`}
- />
- <path
- 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"
- fill={`url(#${gradientId}-i)`}
- fillOpacity=".5"
- />
- </svg>
- );
-};
-
-export const BitbucketIcon: Icon = (props) => {
- const id = useId().replaceAll(":", "");
- const gradientId = `${id}-bitbucket-a`;
-
- return (
- <svg {...props} viewBox="8.4 14.39 2481.29 2231.21">
- <path fill="none" d="M989.97,1493.09h518.05l125.04-730.04H852.22L989.97,1493.09z" />
- <path
- fill="#2684FF"
- 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"
- />
- <linearGradient
- id={gradientId}
- gradientUnits="userSpaceOnUse"
- x1="945.1094"
- y1="1524.8389"
- x2="944.4923"
- y2="1524.1893"
- gradientTransform="matrix(1996.6343 0 0 -1480.3047 -1884485.625 2258195)"
- >
- <stop offset="0.18" stopColor="#0052CC" />
- <stop offset="1" stopColor="#2684FF" />
- </linearGradient>
- <path
- fill={`url(#${gradientId})`}
- 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"
- />
- </svg>
- );
-};
-
export const CursorIcon: Icon = ({ className, ...props }) => (
<svg
{...props}
@@ -680,24 +448,6 @@ export const ACPRegistryIcon: Icon = ({ className, ...props }) => (
</svg>
);
-export const ForgejoIcon: Icon = (props) => (
- <svg viewBox="0 0 212 212" aria-hidden="true" {...props}>
- <g transform="translate(6 6)" fill="none">
- <path d="M58 168 v-98 a50 50 0 0 1 50-50 h20" stroke="#ff6600" strokeWidth="25" />
- <path d="M58 168 v-30 a50 50 0 0 1 50-50 h20" stroke="#d40000" strokeWidth="25" />
- <circle cx="142" cy="20" r="18" stroke="#ff6600" strokeWidth="15" />
- <circle cx="142" cy="88" r="18" stroke="#d40000" strokeWidth="15" />
- <circle cx="58" cy="180" r="18" stroke="#d40000" strokeWidth="15" />
- </g>
- </svg>
-);
-
-export const GitCafeIcon: Icon = (props) => (
- <svg viewBox="0 0 64 64" aria-hidden="true" {...props}>
- <rect x="4.8" y="4.8" width="54.4" height="54.4" fill="#a78bfa" />
- </svg>
-);
-
export const MacScreenRecordingIcon: Icon = (props) => {
const gradientId = useId();
return (
diff --git a/apps/web/src/components/SourceControlIconArtwork.tsx b/apps/web/src/components/SourceControlIconArtwork.tsx
new file mode 100644
index 00000000000..7f2ddc3914d
--- /dev/null
+++ b/apps/web/src/components/SourceControlIconArtwork.tsx
@@ -0,0 +1,59 @@
+import type { SourceControlIcon } from "@t3tools/client-runtime/source-control-clients";
+import { useId, type SVGProps } from "react";
+
+/** Draws a host's mark from its definition's artwork. */
+export function SourceControlIconArtwork({
+ icon,
+ ...props
+}: { readonly icon: SourceControlIcon } & SVGProps<SVGSVGElement>) {
+ // Gradient ids are document-wide, and one page can show the same mark many times.
+ const idPrefix = useId().replace(/[^\w-]/gu, "");
+ const paint = (value: SourceControlIcon["paths"][number]["fill"]) =>
+ value === undefined
+ ? "none"
+ : typeof value === "string"
+ ? value
+ : `url(#${idPrefix}-${value.gradient})`;
+ return (
+ <svg aria-hidden {...props} viewBox={icon.viewBox} fill="none">
+ {icon.gradients ? (
+ <defs>
+ {icon.gradients.map((gradient) => (
+ <linearGradient
+ key={gradient.id}
+ id={`${idPrefix}-${gradient.id}`}
+ x1={gradient.x1}
+ y1={gradient.y1}
+ x2={gradient.x2}
+ y2={gradient.y2}
+ gradientTransform={gradient.transform}
+ gradientUnits="userSpaceOnUse"
+ >
+ {gradient.stops.map((stop) => (
+ <stop
+ key={stop.offset}
+ offset={stop.offset}
+ stopColor={stop.color}
+ stopOpacity={stop.opacity}
+ />
+ ))}
+ </linearGradient>
+ ))}
+ </defs>
+ ) : null}
+ {icon.paths.map((path, index) => (
+ <path
+ // Paths repeat with different paints, so their data is not a key.
+ // oxlint-disable-next-line react/no-array-index-key
+ key={index}
+ d={path.d}
+ fill={paint(path.fill)}
+ fillRule={path.fillRule}
+ fillOpacity={path.fillOpacity}
+ stroke={path.stroke}
+ strokeWidth={path.strokeWidth}
+ />
+ ))}
+ </svg>
+ );
+}
diff --git a/apps/web/src/components/settings/ConnectionsSettings.tsx b/apps/web/src/components/settings/ConnectionsSettings.tsx
index 3639c921f35..fea873dc4e5 100644
--- a/apps/web/src/components/settings/ConnectionsSettings.tsx
+++ b/apps/web/src/components/settings/ConnectionsSettings.tsx
@@ -37,7 +37,7 @@ import { searchableSetting } from "./settingsSearch";
import { EnvironmentIconMenu } from "./EnvironmentIconPicker";
import { FoldedSettingsSection } from "./FoldedSettingsSection";
import { LoadBalancingSettings } from "./LoadBalancingSettings";
-import { GitHubRoutingSettings } from "./GitHubRoutingSettings";
+import { PullRequestRoutingSettings } from "./PullRequestRoutingSettings";
import { Input } from "../ui/input";
import {
Dialog,
@@ -1533,7 +1533,7 @@ export function ConnectionsSettings() {
/>
) : null}
<LoadBalancingSettings environments={loadBalancingEnvironments} />
- <GitHubRoutingSettings environments={loadBalancingEnvironments} />
+ <PullRequestRoutingSettings environments={loadBalancingEnvironments} />
</SettingsPageContainer>
);
}
diff --git a/apps/web/src/components/settings/IntegrationsSettings.tsx b/apps/web/src/components/settings/IntegrationsSettings.tsx
index 11e6603391b..3262f44d75d 100644
--- a/apps/web/src/components/settings/IntegrationsSettings.tsx
+++ b/apps/web/src/components/settings/IntegrationsSettings.tsx
@@ -780,7 +780,7 @@ function PullRequestLinksOpenInAppSetting() {
return (
<SettingsRow
{...searchableSetting("pull-request-links-open-in-app")}
- 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."
+ 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."
resetAction={
openInApp ? null : (
<SettingResetButton
diff --git a/apps/web/src/components/settings/GitHubRoutingSettings.tsx b/apps/web/src/components/settings/PullRequestRoutingSettings.tsx
similarity index 71%
rename from apps/web/src/components/settings/GitHubRoutingSettings.tsx
rename to apps/web/src/components/settings/PullRequestRoutingSettings.tsx
index 235a7f810a1..a6e3234ad7e 100644
--- a/apps/web/src/components/settings/GitHubRoutingSettings.tsx
+++ b/apps/web/src/components/settings/PullRequestRoutingSettings.tsx
@@ -1,9 +1,9 @@
import { useAtomValue } from "@effect/atom-react";
import { resolveEnvironmentMachineKind } from "@t3tools/contracts";
import {
- gitHubRoutingConnectionKey,
- gitHubRoutingPermissionFor,
- type GitHubRoutingPermission,
+ pullRequestRoutingConnectionKey,
+ pullRequestRoutingPermissionFor,
+ type PullRequestRoutingPermission,
} from "@t3tools/client-runtime/connection";
import { useState } from "react";
@@ -16,7 +16,7 @@ import { EnvironmentRow, environmentTransportLabel } from "./EnvironmentRow";
import { FoldedSettingsSection } from "./FoldedSettingsSection";
import { searchableSetting } from "./settingsSearch";
-const options: ReadonlyArray<{ value: GitHubRoutingPermission; label: string }> = [
+const options: ReadonlyArray<{ value: PullRequestRoutingPermission; label: string }> = [
{ value: "off", label: "Off" },
{ value: "read", label: "Read PRs" },
{ value: "read-write", label: "Read and act" },
@@ -24,8 +24,11 @@ const options: ReadonlyArray<{ value: GitHubRoutingPermission; label: string }>
const summaryLabels = { "read-write": "read and act", read: "read PRs" } as const;
-function summarizeGitHubRouting(
- entries: ReadonlyArray<{ readonly label: string; readonly permission: GitHubRoutingPermission }>,
+function summarizePullRequestRouting(
+ entries: ReadonlyArray<{
+ readonly label: string;
+ readonly permission: PullRequestRoutingPermission;
+ }>,
): string | null {
const groups = (["read-write", "read"] as const).flatMap((permission) => {
const labels = entries.filter((entry) => entry.permission === permission);
@@ -36,36 +39,36 @@ function summarizeGitHubRouting(
return groups.length === 0 ? null : groups.join(" · ");
}
-export function GitHubRoutingSettings({
+export function PullRequestRoutingSettings({
environments,
}: {
readonly environments: ReadonlyArray<EnvironmentPresentation>;
}) {
- const permissions = useAtomValue(environmentCatalog.githubRoutingPermissionsValueAtom);
+ const permissions = useAtomValue(environmentCatalog.pullRequestRoutingPermissionsValueAtom);
const catalog = useAtomValue(environmentCatalog.catalogValueAtom);
- const update = useAtomCommand(environmentCatalog.setGitHubRoutingPermission);
+ const update = useAtomCommand(environmentCatalog.setPullRequestRoutingPermission);
const [saving, setSaving] = useState(false);
if (environments.length < 2) return null;
- const { id, title } = searchableSetting("github-routing");
+ const { id, title } = searchableSetting("pull-request-routing");
return (
<FoldedSettingsSection
id={id}
title={title}
summary={
- summarizeGitHubRouting(
+ summarizePullRequestRouting(
environments.map((environment) => ({
label: environment.label,
- permission: gitHubRoutingPermissionFor(environment.entry, permissions),
+ permission: pullRequestRoutingPermissionFor(environment.entry, permissions),
})),
) ?? "Off"
}
>
<p className="px-3 py-2.5 text-xs text-muted-foreground sm:px-4">
- Machines you trust here can read PR data through each other's GitHub access. Enable both
- machines. Read and act may use broader permissions than the machine that owns them. This
- applies only to this device.
+ Machines you trust here can read PR data through each other's source control access. Enable
+ both machines. Read and act may use broader permissions than the machine that owns them.
+ This applies only to this device.
</p>
{environments.map((environment) => (
<EnvironmentRow
@@ -76,9 +79,11 @@ export function GitHubRoutingSettings({
>
<Select
items={options}
- value={gitHubRoutingPermissionFor(environment.entry, permissions)}
+ value={pullRequestRoutingPermissionFor(environment.entry, permissions)}
disabled={
- !catalog.isReady || saving || gitHubRoutingConnectionKey(environment.entry) === null
+ !catalog.isReady ||
+ saving ||
+ pullRequestRoutingConnectionKey(environment.entry) === null
}
onValueChange={(permission) => {
if (permission === null) return;
@@ -89,7 +94,7 @@ export function GitHubRoutingSettings({
if (result._tag === "Failure")
toastManager.add({
type: "error",
- title: "Could not save GitHub routing permission",
+ title: "Could not save pull request routing permission",
});
},
);
@@ -98,7 +103,7 @@ export function GitHubRoutingSettings({
<SelectTrigger
size="xs"
className="w-32"
- aria-label={`${environment.label} GitHub routing`}
+ aria-label={`${environment.label} pull request routing`}
>
<SelectValue />
</SelectTrigger>
diff --git a/apps/web/src/components/settings/GitHubAccountSettings.logic.test.ts b/apps/web/src/components/settings/SourceControlAccountSettings.logic.test.ts
similarity index 73%
rename from apps/web/src/components/settings/GitHubAccountSettings.logic.test.ts
rename to apps/web/src/components/settings/SourceControlAccountSettings.logic.test.ts
index a1a895297da..add97c27cfa 100644
--- a/apps/web/src/components/settings/GitHubAccountSettings.logic.test.ts
+++ b/apps/web/src/components/settings/SourceControlAccountSettings.logic.test.ts
@@ -1,11 +1,11 @@
import { describe, expect, it } from "vite-plus/test";
-import { groupGitHubAccounts, nextGitHubHosts } from "./GitHubAccountSettings.logic";
+import { groupHostAccounts, nextHostAccountChoices } from "./SourceControlAccountSettings.logic";
-describe("groupGitHubAccounts", () => {
+describe("groupHostAccounts", () => {
it("groups logins by host, keeping broken and environment logins out of the picker", () => {
expect(
- groupGitHubAccounts([
+ groupHostAccounts([
{ host: "github.com", account: "personal", active: true, authenticated: true },
{ host: "github.com", account: "work", active: false, authenticated: true },
{ host: "github.com", account: "old", active: false, authenticated: false, error: "bad" },
@@ -39,17 +39,17 @@ describe("groupGitHubAccounts", () => {
});
});
-describe("nextGitHubHosts", () => {
- it("pins an account, keeps other hosts, and drops a host back on gh's defaults", () => {
+describe("nextHostAccountChoices", () => {
+ it("pins an account, keeps other hosts, and drops a host back on the CLI defaults", () => {
const other = { "ghe.acme.test": { enabled: false } };
- const pinned = nextGitHubHosts(other, "github.com", { account: "work" });
+ const pinned = nextHostAccountChoices(other, "github.com", { account: "work" });
expect(pinned).toEqual({ ...other, "github.com": { enabled: true, account: "work" } });
- const disabled = nextGitHubHosts(pinned, "github.com", { enabled: false });
+ const disabled = nextHostAccountChoices(pinned, "github.com", { enabled: false });
expect(disabled["github.com"]).toEqual({ enabled: false, account: "work" });
- expect(nextGitHubHosts(disabled, "github.com", { enabled: true, account: null })).toEqual(
- other,
- );
+ expect(
+ nextHostAccountChoices(disabled, "github.com", { enabled: true, account: null }),
+ ).toEqual(other);
});
});
diff --git a/apps/web/src/components/settings/GitHubAccountSettings.logic.ts b/apps/web/src/components/settings/SourceControlAccountSettings.logic.ts
similarity index 73%
rename from apps/web/src/components/settings/GitHubAccountSettings.logic.ts
rename to apps/web/src/components/settings/SourceControlAccountSettings.logic.ts
index 2e81d50ecad..4cf8a5d83f0 100644
--- a/apps/web/src/components/settings/GitHubAccountSettings.logic.ts
+++ b/apps/web/src/components/settings/SourceControlAccountSettings.logic.ts
@@ -1,19 +1,19 @@
import type { SourceControlProviderAuth } from "@t3tools/contracts";
-import type { GitHubSettings } from "@t3tools/client-runtime/source-control-clients";
+import type { HostCredentialSettings } from "@t3tools/client-runtime/source-control-clients";
-export type GitHubDiscoveredAccount = NonNullable<SourceControlProviderAuth["accounts"]>[number];
+export type DiscoveredAccount = NonNullable<SourceControlProviderAuth["accounts"]>[number];
-export interface GitHubHostGroup {
+export interface HostAccountGroup {
readonly host: string;
readonly activeAccount: string | null;
readonly selectable: ReadonlyArray<string>;
- readonly broken: ReadonlyArray<GitHubDiscoveredAccount>;
+ readonly broken: ReadonlyArray<DiscoveredAccount>;
readonly environmentVariable: string | null;
}
-export function groupGitHubAccounts(
- accounts: ReadonlyArray<GitHubDiscoveredAccount>,
-): ReadonlyArray<GitHubHostGroup> {
+export function groupHostAccounts(
+ accounts: ReadonlyArray<DiscoveredAccount>,
+): ReadonlyArray<HostAccountGroup> {
const hosts = [...new Set(accounts.map((entry) => entry.host))];
return hosts.map((host) => {
const entries = accounts.filter((entry) => entry.host === host);
@@ -30,11 +30,11 @@ export function groupGitHubAccounts(
});
}
-export function nextGitHubHosts(
- current: GitHubSettings["hosts"],
+export function nextHostAccountChoices(
+ current: HostCredentialSettings["hosts"],
host: string,
change: { readonly enabled?: boolean; readonly account?: string | null },
-): GitHubSettings["hosts"] {
+): HostCredentialSettings["hosts"] {
const previous = current[host];
const enabled = change.enabled ?? previous?.enabled ?? true;
const account = change.account === undefined ? previous?.account : (change.account ?? undefined);
diff --git a/apps/web/src/components/settings/GitHubAccountSettings.tsx b/apps/web/src/components/settings/SourceControlAccountSettings.tsx
similarity index 81%
rename from apps/web/src/components/settings/GitHubAccountSettings.tsx
rename to apps/web/src/components/settings/SourceControlAccountSettings.tsx
index cc628b85242..258436f1df2 100644
--- a/apps/web/src/components/settings/GitHubAccountSettings.tsx
+++ b/apps/web/src/components/settings/SourceControlAccountSettings.tsx
@@ -8,12 +8,16 @@ import { useAtomCommand } from "../../state/use-atom-command";
import { Button } from "../ui/button";
import { Select, SelectItem, SelectPopup, SelectTrigger, SelectValue } from "../ui/select";
import { Switch } from "../ui/switch";
-import { groupGitHubAccounts, nextGitHubHosts } from "./GitHubAccountSettings.logic";
-import { readGitHubSettings } from "@t3tools/client-runtime/source-control-clients";
+import { groupHostAccounts, nextHostAccountChoices } from "./SourceControlAccountSettings.logic";
+import {
+ readHostCredentialSettings,
+ type SourceControlClientDefinition,
+ type SourceControlHostCredentials,
+} from "@t3tools/client-runtime/source-control-clients";
import { redactedPlaceholder } from "./RedactedSensitiveText";
-/** Sentinel select value for "follow gh's active login"; logins never contain spaces. */
-const ACTIVE_ACCOUNT = "active gh account";
+/** Sentinel select value for "follow the CLI's active login"; logins never contain spaces. */
+const ACTIVE_ACCOUNT = "active cli account";
function RedactedLogin(props: {
readonly account: string;
@@ -32,23 +36,30 @@ function RedactedLogin(props: {
);
}
-export function GitHubAccountSettings({
+export function SourceControlAccountSettings({
environmentId,
+ definition,
+ credentials,
auth,
onSaved,
}: {
readonly environmentId: EnvironmentId;
+ readonly definition: SourceControlClientDefinition;
+ readonly credentials: SourceControlHostCredentials;
readonly auth: SourceControlProviderAuth;
readonly onSaved: () => void;
}) {
- const github = useEnvironmentSettings(environmentId, readGitHubSettings);
- const hosts = github.hosts;
+ const { hosts } = useEnvironmentSettings(environmentId, (settings) =>
+ readHostCredentialSettings(settings, definition.kind),
+ );
+ const { label } = definition;
+ const { cliName } = credentials;
const updateSettings = useAtomCommand(serverEnvironment.updateSettings, {
- label: "save GitHub account settings",
+ label: `save ${label} account settings`,
});
const [saving, setSaving] = useState(false);
const [revealed, setRevealed] = useState(false);
- const groups = groupGitHubAccounts(auth.accounts ?? []);
+ const groups = groupHostAccounts(auth.accounts ?? []);
const save = async (
host: string,
@@ -59,7 +70,9 @@ export function GitHubAccountSettings({
environmentId,
input: {
patch: {
- sourceControlHosts: { github: { hosts: nextGitHubHosts(hosts, host, change) } },
+ sourceControlHosts: {
+ [definition.kind]: { hosts: nextHostAccountChoices(hosts, host, change) },
+ },
},
},
});
@@ -70,7 +83,8 @@ export function GitHubAccountSettings({
if (groups.length === 0) {
return (
<p className="text-xs text-muted-foreground">
- Sign in with <code className="rounded bg-muted px-1 py-px text-2xs">gh auth login</code> on
+ Sign in with{" "}
+ <code className="rounded bg-muted px-1 py-px text-2xs">{credentials.loginCommand}</code> on
the server host, then rescan to choose accounts here.
</p>
);
@@ -80,14 +94,14 @@ export function GitHubAccountSettings({
<div className="grid gap-4">
<div className="flex items-center justify-between gap-3">
<p className="max-w-2xl text-xs leading-relaxed text-muted-foreground">
- Choose which <code className="rounded bg-muted px-1 py-px text-2xs">gh</code> login each
- GitHub host uses, or turn a host off.
+ Choose which <code className="rounded bg-muted px-1 py-px text-2xs">{cliName}</code> login
+ each {label} host uses, or turn a host off.
</p>
<Button
size="icon-xs"
variant="ghost-muted"
onClick={() => setRevealed((current) => !current)}
- aria-label={revealed ? "Hide GitHub accounts" : "Reveal GitHub accounts"}
+ aria-label={revealed ? `Hide ${label} accounts` : `Reveal ${label} accounts`}
aria-pressed={revealed}
>
{revealed ? <EyeOffIcon /> : <EyeIcon />}
@@ -114,7 +128,7 @@ export function GitHubAccountSettings({
<Switch
checked={enabled}
disabled={saving}
- aria-label={`Use GitHub on ${group.host}`}
+ aria-label={`Use ${label} on ${group.host}`}
onCheckedChange={(checked) => void save(group.host, { enabled: checked })}
/>
</div>
@@ -132,12 +146,12 @@ export function GitHubAccountSettings({
});
}}
>
- <SelectTrigger size="sm" aria-label={`GitHub account for ${group.host}`}>
+ <SelectTrigger size="sm" aria-label={`${label} account for ${group.host}`}>
<SelectValue>
{(value: string) =>
value === ACTIVE_ACCOUNT ? (
<span className="flex min-w-0 items-center gap-1">
- Active gh account
+ Active {cliName} account
{group.activeAccount ? (
<>
(
@@ -158,7 +172,7 @@ export function GitHubAccountSettings({
<SelectPopup align="end" alignItemWithTrigger={false}>
<SelectItem value={ACTIVE_ACCOUNT}>
<span className="flex min-w-0 items-center gap-1">
- Active gh account
+ Active {cliName} account
{group.activeAccount ? (
<>
(<RedactedLogin revealed={revealed} account={group.activeAccount} />)
@@ -183,7 +197,7 @@ export function GitHubAccountSettings({
{stalePin ? (
<div className="flex items-center justify-between gap-3">
<p className="text-xs text-warning">
- The chosen login is no longer signed in, so the active gh login is used.
+ The chosen login is no longer signed in, so the active {cliName} login is used.
</p>
<Button
size="xs"
@@ -201,7 +215,9 @@ export function GitHubAccountSettings({
className="flex min-w-0 flex-wrap items-center gap-1 text-xs text-muted-foreground/70"
>
<RedactedLogin revealed={revealed} account={entry.account} />
- <span>can't be used: {entry.error ?? "gh reports this login as invalid."}</span>
+ <span>
+ can't be used: {entry.error ?? `${cliName} reports this login as invalid.`}
+ </span>
</p>
))}
{group.environmentVariable ? (
diff --git a/apps/web/src/components/settings/SourceControlSettings.tsx b/apps/web/src/components/settings/SourceControlSettings.tsx
index 16d4d042693..e694d9dc8cf 100644
--- a/apps/web/src/components/settings/SourceControlSettings.tsx
+++ b/apps/web/src/components/settings/SourceControlSettings.tsx
@@ -47,8 +47,8 @@ import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
import { GitIcon, JujutsuIcon, type Icon } from "../Icons";
import { SourceControlHostSettings } from "./SourceControlHostSettings";
-import { GitHubAccountSettings } from "./GitHubAccountSettings";
-import { GitHubTokenSettings } from "./GitHubTokenSettings";
+import { SourceControlAccountSettings } from "./SourceControlAccountSettings";
+import { SourceControlTokenSettings } from "./SourceControlTokenSettings";
import { RedactedSensitiveText } from "./RedactedSensitiveText";
import { SourceControlWritingSettingsSection } from "./SourceControlWritingSettings";
import {
@@ -280,8 +280,7 @@ function DiscoveryItemRow({
const [seenSearchTargetId, setSeenSearchTargetId] = useState<string | null>(null);
const targetsThisRow =
(item.kind === "git" && searchTargetId === searchableSetting("git-fetch-interval").id) ||
- searchTargetId === sourceControlHostSettingsSearchId(item.kind) ||
- (item.kind === "github" && searchTargetId === searchableSetting("github-accounts").id);
+ searchTargetId === sourceControlHostSettingsSearchId(item.kind);
if (targetsThisRow && !isExpanded && seenSearchTargetId !== searchTargetId) {
setIsExpanded(true);
}
@@ -526,11 +525,37 @@ export function SourceControlSettingsPanel() {
const handleScan = () => {
discovery.refresh();
};
- const hostSettingsPanel = (kind: string) => {
- const definition = sourceControlClients.find(kind);
+ const hostSettingsPanel = (item: SourceControlProviderDiscoveryItem) => {
+ const definition = sourceControlClients.find(item.kind);
if (!definition?.settings || environmentId === null) return undefined;
+ const { credentials } = definition;
+ if (credentials) {
+ return (
+ <SettingsSearchTarget id={sourceControlHostSettingsSearchId(item.kind)}>
+ <div className="grid gap-6">
+ <SourceControlTokenSettings
+ key={`token-${environmentId}`}
+ environmentId={environmentId}
+ definition={definition}
+ credentials={credentials}
+ onSaved={handleScan}
+ />
+ {item.status === "available" ? (
+ <SourceControlAccountSettings
+ key={environmentId}
+ environmentId={environmentId}
+ definition={definition}
+ credentials={credentials}
+ auth={item.auth}
+ onSaved={handleScan}
+ />
+ ) : null}
+ </div>
+ </SettingsSearchTarget>
+ );
+ }
return (
- <SettingsSearchTarget id={sourceControlHostSettingsSearchId(kind)}>
+ <SettingsSearchTarget id={sourceControlHostSettingsSearchId(item.kind)}>
<SourceControlHostSettings
// Drafts belong to one environment; switching must not carry them over.
key={environmentId}
@@ -605,28 +630,7 @@ export function SourceControlSettingsPanel() {
>
{result.sourceControlProviders.map((item) => (
<DiscoveryItemRow key={`provider:${item.kind}`} item={item}>
- {item.kind === "github" ? (
- <SettingsSearchTarget id={searchableSetting("github-accounts").id}>
- <div className="grid gap-6">
- {}
- <GitHubTokenSettings
- key={`token-${environmentId}`}
- environmentId={environmentId}
- onSaved={handleScan}
- />
- {item.status === "available" ? (
- <GitHubAccountSettings
- key={environmentId}
- environmentId={environmentId}
- auth={item.auth}
- onSaved={handleScan}
- />
- ) : null}
- </div>
- </SettingsSearchTarget>
- ) : (
- hostSettingsPanel(item.kind)
- )}
+ {hostSettingsPanel(item)}
</DiscoveryItemRow>
))}
</SettingsSection>
diff --git a/apps/web/src/components/settings/GitHubTokenSettings.tsx b/apps/web/src/components/settings/SourceControlTokenSettings.tsx
similarity index 63%
rename from apps/web/src/components/settings/GitHubTokenSettings.tsx
rename to apps/web/src/components/settings/SourceControlTokenSettings.tsx
index a71001f0079..d0d44c8b006 100644
--- a/apps/web/src/components/settings/GitHubTokenSettings.tsx
+++ b/apps/web/src/components/settings/SourceControlTokenSettings.tsx
@@ -3,7 +3,11 @@ import { ExternalLinkIcon } from "lucide-react";
import { useState } from "react";
import { useEnvironmentSettings } from "../../hooks/useSettings";
-import { readGitHubSettings } from "@t3tools/client-runtime/source-control-clients";
+import {
+ readHostCredentialSettings,
+ type SourceControlClientDefinition,
+ type SourceControlHostCredentials,
+} from "@t3tools/client-runtime/source-control-clients";
import { serverEnvironment } from "../../state/server";
import { useAtomCommand } from "../../state/use-atom-command";
import { Button, InlineButton } from "../ui/button";
@@ -11,24 +15,25 @@ import { Input } from "../ui/input";
import { SecretInput } from "./SecretInput";
import { Label } from "../ui/label";
-const DEFAULT_HOST = "github.com";
-
-function newTokenUrl(host: string): string {
- return `https://${host}/settings/personal-access-tokens/new`;
-}
-
-export function GitHubTokenSettings({
+export function SourceControlTokenSettings({
environmentId,
+ definition,
+ credentials,
onSaved,
}: {
readonly environmentId: EnvironmentId;
+ readonly definition: SourceControlClientDefinition;
+ readonly credentials: SourceControlHostCredentials;
readonly onSaved: () => void;
}) {
- const { tokens } = useEnvironmentSettings(environmentId, readGitHubSettings);
+ const { tokens } = useEnvironmentSettings(environmentId, (settings) =>
+ readHostCredentialSettings(settings, definition.kind),
+ );
const updateSettings = useAtomCommand(serverEnvironment.updateSettings, {
- label: "save GitHub token",
+ label: `save ${definition.label} token`,
});
- const [host, setHost] = useState(DEFAULT_HOST);
+ const defaultHost = definition.publicHost ?? "";
+ const [host, setHost] = useState(defaultHost);
const [draft, setDraft] = useState("");
const [saving, setSaving] = useState(false);
const normalizedHost = host.trim().toLowerCase();
@@ -43,7 +48,9 @@ export function GitHubTokenSettings({
environmentId,
// The map travels whole: every other saved token as its redaction marker, which keeps it.
input: {
- patch: { sourceControlHosts: { github: { tokens: { ...tokens, [target]: token } } } },
+ patch: {
+ sourceControlHosts: { [definition.kind]: { tokens: { ...tokens, [target]: token } } },
+ },
},
});
setSaving(false);
@@ -65,38 +72,42 @@ export function GitHubTokenSettings({
<fieldset disabled={saving} className="contents">
<p className="max-w-2xl text-xs leading-relaxed text-muted-foreground">
A token saved here is used before{" "}
- <code className="rounded bg-muted px-1 py-px text-2xs">GH_TOKEN</code> and the{" "}
- <code className="rounded bg-muted px-1 py-px text-2xs">gh</code> login, so GitHub works
- without the GitHub CLI. Give it read and write access to pull requests and contents.{" "}
- <InlineButton
- render={
- <a
- href={newTokenUrl(normalizedHost || DEFAULT_HOST)}
- target="_blank"
- rel="noreferrer noopener"
- />
- }
- >
- Create a token
- <ExternalLinkIcon aria-hidden className="size-3" />
- </InlineButton>
+ <code className="rounded bg-muted px-1 py-px text-2xs">{credentials.tokenEnvVar}</code>{" "}
+ and the{" "}
+ <code className="rounded bg-muted px-1 py-px text-2xs">{credentials.cliName}</code> login,
+ so {definition.label} works without the {credentials.cliLabel}. Give it{" "}
+ {credentials.tokenAccess}.{" "}
+ {normalizedHost || defaultHost ? (
+ <InlineButton
+ render={
+ <a
+ href={credentials.newTokenUrl(normalizedHost || defaultHost)}
+ target="_blank"
+ rel="noreferrer noopener"
+ />
+ }
+ >
+ Create a token
+ <ExternalLinkIcon aria-hidden className="size-3" />
+ </InlineButton>
+ ) : null}
</p>
<div className="grid gap-3 sm:grid-cols-[12rem_1fr]">
<div className="grid gap-1.5">
- <Label htmlFor={`github-token-host-${environmentId}`}>Host</Label>
+ <Label htmlFor={`${definition.kind}-token-host-${environmentId}`}>Host</Label>
<Input
- id={`github-token-host-${environmentId}`}
+ id={`${definition.kind}-token-host-${environmentId}`}
autoComplete="off"
size="sm"
- placeholder={DEFAULT_HOST}
+ placeholder={defaultHost}
value={host}
onChange={(event) => setHost(event.target.value)}
/>
</div>
<div className="grid gap-1.5">
- <Label htmlFor={`github-token-${environmentId}`}>Token</Label>
+ <Label htmlFor={`${definition.kind}-token-${environmentId}`}>Token</Label>
<SecretInput
- id={`github-token-${environmentId}`}
+ id={`${definition.kind}-token-${environmentId}`}
size="sm"
configured={isSaved}
value={draft}
@@ -107,7 +118,7 @@ export function GitHubTokenSettings({
<div className="flex items-center justify-between gap-3">
<p className="text-xs text-muted-foreground">
{savedHosts.length === 0
- ? "No token saved; the server uses GH_TOKEN or the gh login."
+ ? `No token saved; the server uses ${credentials.tokenEnvVar} or the ${credentials.cliName} login.`
: `Saved for ${savedHosts.join(", ")}.`}
</p>
<div className="flex shrink-0 gap-2">
diff --git a/apps/web/src/components/settings/settingsSearch.test.ts b/apps/web/src/components/settings/settingsSearch.test.ts
index 82995946155..1584bbe719a 100644
--- a/apps/web/src/components/settings/settingsSearch.test.ts
+++ b/apps/web/src/components/settings/settingsSearch.test.ts
@@ -1,5 +1,11 @@
import { describe, expect, it, vi } from "vite-plus/test";
-import { EnvironmentId } from "@t3tools/contracts";
+import {
+ EnvironmentId,
+ makeProviderSettingsSchema,
+ SourceControlProviderKind,
+} from "@t3tools/contracts";
+import { UNKNOWN_SOURCE_CONTROL_CLIENT } from "@t3tools/client-runtime/source-control-clients";
+import * as Schema from "effect/Schema";
import {
filterAvailableSettingsSearchItems,
@@ -8,6 +14,8 @@ import {
isSettingsSearchScopeAvailable,
searchSettings,
SETTINGS_SEARCH_ITEMS,
+ sourceControlHostSearchItems,
+ sourceControlHostSettingsSearchId,
type SettingsSearchItem,
} from "./settingsSearch";
@@ -234,3 +242,46 @@ describe("auto-settlement search availability", () => {
).toBe(true);
});
});
+
+describe("source control host search items", () => {
+ const definition = {
+ ...UNKNOWN_SOURCE_CONTROL_CLIENT,
+ kind: SourceControlProviderKind.make("example"),
+ label: "Example",
+ searchKeywords: ["sample"],
+ settings: makeProviderSettingsSchema({ apiToken: Schema.String }),
+ };
+
+ it("lists a host by its label, its keywords, and its settings fields", () => {
+ const items = sourceControlHostSearchItems([UNKNOWN_SOURCE_CONTROL_CLIENT, definition]);
+ expect(items.map((item) => item.title)).toEqual(["Example credentials"]);
+ expect(searchSettings("sample apitoken", items).map((item) => item.id)).toEqual([
+ sourceControlHostSettingsSearchId("example"),
+ ]);
+ });
+
+ it("lists a host with credentials by its accounts, token and CLI", () => {
+ const items = sourceControlHostSearchItems([
+ {
+ ...definition,
+ credentials: {
+ cliName: "ex",
+ cliLabel: "Example CLI",
+ loginCommand: "ex login",
+ tokenEnvVar: "EX_TOKEN",
+ tokenAccess: "access",
+ newTokenUrl: (host) => `https://${host}/tokens`,
+ },
+ },
+ ]);
+ expect(items.map((item) => item.title)).toEqual(["Example accounts and token"]);
+ expect(searchSettings("ex switch accounts", items)).toHaveLength(1);
+ });
+
+ it("finds the built-in hosts by their own words", () => {
+ expect(searchSettings("codeberg").map((item) => item.id)).toContain("source-control");
+ expect(searchSettings("ghes").map((item) => item.id)).toContain(
+ sourceControlHostSettingsSearchId("github"),
+ );
+ });
+});
diff --git a/apps/web/src/components/settings/settingsSearch.ts b/apps/web/src/components/settings/settingsSearch.ts
index eac65e29742..8d177d78859 100644
--- a/apps/web/src/components/settings/settingsSearch.ts
+++ b/apps/web/src/components/settings/settingsSearch.ts
@@ -4,7 +4,10 @@ import { isMacPlatform, isWindowsPlatform, normalizeSearchText } from "~/lib/uti
import { STATIC_KEYBINDING_COMMANDS, type KeybindingCommand } from "@t3tools/contracts";
import type { EnvironmentId } from "@t3tools/contracts";
import type { EnvironmentConnectionPhase } from "@t3tools/client-runtime/connection";
-import { sourceControlClients } from "@t3tools/client-runtime/source-control-clients";
+import {
+ sourceControlClients,
+ type SourceControlClientDefinition,
+} from "@t3tools/client-runtime/source-control-clients";
import { DEFAULT_KEYBINDINGS } from "@t3tools/shared/keybindings";
import { commandLabel } from "./KeybindingsSettings.logic";
import {
@@ -111,22 +114,42 @@ export function sourceControlHostSettingsSearchId(kind: string) {
return `source-control-host-${kind}` as const;
}
-const SOURCE_CONTROL_HOST_SEARCH_ITEMS = sourceControlClients.definitions.flatMap((definition) =>
- definition.settings && definition.kind !== "github"
- ? [
- {
- id: sourceControlHostSettingsSearchId(definition.kind),
- title: `${definition.label} credentials`,
- to: "/settings/source-control" as const,
- searchTerms: [
- `${definition.label} ${Object.keys(definition.settings.fields).join(" ")} token credentials sign in`,
- ],
- environmentOnly: true,
- scope: "environment-defaults" as const,
- },
- ]
- : [],
-);
+/** Each host's own settings: its accounts and token, or the fields of its settings form. */
+export function sourceControlHostSearchItems(
+ definitions: ReadonlyArray<SourceControlClientDefinition>,
+): ReadonlyArray<
+ SettingsSearchItem & { readonly id: ReturnType<typeof sourceControlHostSettingsSearchId> }
+> {
+ return definitions.flatMap((definition) => {
+ if (!definition.settings) return [];
+ const names = [definition.label, ...(definition.searchKeywords ?? [])].join(" ");
+ const { credentials } = definition;
+ return [
+ {
+ id: sourceControlHostSettingsSearchId(definition.kind),
+ title: credentials
+ ? `${definition.label} accounts and token`
+ : `${definition.label} credentials`,
+ to: "/settings/source-control" as const,
+ searchTerms: [
+ credentials
+ ? `${names} ${credentials.cliName} account login user host switch multiple accounts disable sign in token personal access token pat api key credential`
+ : `${names} ${Object.keys(definition.settings.fields).join(" ")} token credentials sign in`,
+ ],
+ environmentOnly: true,
+ scope: "environment-defaults" as const,
+ },
+ ];
+ });
+}
+
+/** For settings that apply to every host. */
+const SOURCE_CONTROL_HOST_LABELS = sourceControlClients.definitions
+ .map((definition) => definition.label)
+ .join(" ");
+const SOURCE_CONTROL_HOST_TERMS = sourceControlClients.definitions
+ .flatMap((definition) => [definition.label, ...(definition.searchKeywords ?? [])])
+ .join(" ");
export const SETTINGS_SEARCH_ITEMS = [
{
@@ -775,7 +798,9 @@ export const SETTINGS_SEARCH_ITEMS = [
id: "pull-request-links-open-in-app",
title: "Open pull requests in T3 Code",
to: "/settings/integrations",
- searchTerms: ["pr links github browser external click default pull request view panel"],
+ searchTerms: [
+ `pr links ${SOURCE_CONTROL_HOST_LABELS} browser external click default pull request view panel`,
+ ],
},
{
id: "browser-auto-show-floating-preview",
@@ -795,7 +820,9 @@ export const SETTINGS_SEARCH_ITEMS = [
title: "Remove agent credits when merging",
to: "/settings/source-control",
scope: "project-defaults",
- searchTerms: ["pull request github squash co-authored-by attribution claude codex generated"],
+ searchTerms: [
+ `pull request ${SOURCE_CONTROL_HOST_LABELS} squash co-authored-by attribution claude codex generated`,
+ ],
},
{
id: "pull-request-merge-method",
@@ -810,7 +837,7 @@ export const SETTINGS_SEARCH_ITEMS = [
to: "/settings/source-control",
scope: "environment-defaults",
searchTerms: [
- "version control git github gitlab forgejo gitea tea codeberg bitbucket azure devops hosting integrations credentials scan server environment",
+ `version control git ${SOURCE_CONTROL_HOST_TERMS} hosting integrations credentials scan server environment`,
],
},
{
@@ -831,17 +858,7 @@ export const SETTINGS_SEARCH_ITEMS = [
environmentOnly: true,
scope: "project-defaults",
},
- {
- id: "github-accounts",
- title: "GitHub accounts and token",
- to: "/settings/source-control",
- searchTerms: [
- "github gh account login user host enterprise ghes switch multiple accounts disable sign in token personal access token pat api key credential",
- ],
- environmentOnly: true,
- scope: "environment-defaults",
- },
- ...SOURCE_CONTROL_HOST_SEARCH_ITEMS,
+ ...sourceControlHostSearchItems(sourceControlClients.definitions),
{
id: "source-control-writing-style",
title: "Source control writing style",
@@ -996,10 +1013,12 @@ export const SETTINGS_SEARCH_ITEMS = [
],
},
{
- id: "github-routing",
- title: "GitHub sharing",
+ id: "pull-request-routing",
+ title: "Pull request sharing",
to: "/settings/connections",
- searchTerms: ["pull request trusted environments shared credentials permissions read actions"],
+ searchTerms: [
+ `pull request routing trusted environments shared credentials permissions read actions source control ${SOURCE_CONTROL_HOST_LABELS}`,
+ ],
},
{
id: "archive",
diff --git a/apps/web/src/connection/storage.test.ts b/apps/web/src/connection/storage.test.ts
index edec7330983..7afe2b1e857 100644
--- a/apps/web/src/connection/storage.test.ts
+++ b/apps/web/src/connection/storage.test.ts
@@ -219,8 +219,8 @@ describe("browser GitHub routing permissions", () => {
};
const firstBrowser = Object.assign(new EventTarget(), { localStorage });
const secondBrowser = Object.assign(new EventTarget(), { localStorage });
- const first = ConnectionStorage.makeBrowserGitHubRoutingPermissions(firstBrowser);
- const second = ConnectionStorage.makeBrowserGitHubRoutingPermissions(secondBrowser);
+ const first = ConnectionStorage.makeBrowserPullRequestRoutingPermissions(firstBrowser);
+ const second = ConnectionStorage.makeBrowserPullRequestRoutingPermissions(secondBrowser);
const entry = {
target: new PrimaryConnectionTarget({
environmentId: EnvironmentId.make("first"),
@@ -268,7 +268,7 @@ describe("browser GitHub routing permissions", () => {
expect(yield* second.get(entry)).toBe("off");
expect(yield* first.get(other)).toBe("read");
expect(
- yield* ConnectionStorage.makeBrowserGitHubRoutingPermissions(firstBrowser).get(entry),
+ yield* ConnectionStorage.makeBrowserPullRequestRoutingPermissions(firstBrowser).get(entry),
).toBe("off");
yield* first.set(entry, "read-write");
diff --git a/apps/web/src/connection/storage.ts b/apps/web/src/connection/storage.ts
index 4e7bcf3e58e..bee5b0bc06c 100644
--- a/apps/web/src/connection/storage.ts
+++ b/apps/web/src/connection/storage.ts
@@ -23,10 +23,10 @@ import {
ConnectionBlockedError,
CredentialStore,
ProfileStore,
- GitHubRoutingPermissions,
- StoredGitHubRoutingPermission,
- gitHubRoutingConnectionKey,
- gitHubRoutingPermissionFor,
+ PullRequestRoutingPermissions,
+ StoredPullRequestRoutingPermission,
+ pullRequestRoutingConnectionKey,
+ pullRequestRoutingPermissionFor,
} from "@t3tools/client-runtime/connection";
import { EnvironmentId, ServerConfig, ThreadId, VcsListRefsResult } from "@t3tools/contracts";
import * as Context from "effect/Context";
@@ -496,36 +496,38 @@ export const makeCatalogStore = Effect.fn("web.connectionStorage.makeCatalogStor
return { read, update } satisfies CatalogStore;
});
-const GITHUB_ROUTING_KEY_PREFIX = "t3code:github-routing:";
-const GITHUB_ROUTING_CHANGED = "t3code:github-routing-changed";
-const isStoredGitHubRoutingPermission = Schema.is(StoredGitHubRoutingPermission);
-const encodeStoredGitHubRoutingPermission = Schema.encodeSync(
- Schema.fromJsonString(StoredGitHubRoutingPermission),
+// The stored names predate the rename and stay, so a tab still on an older version and an
+// updated one read and revoke the same grants.
+const PULL_REQUEST_ROUTING_KEY_PREFIX = "t3code:github-routing:";
+const PULL_REQUEST_ROUTING_CHANGED = "t3code:github-routing-changed";
+const isStoredPullRequestRoutingPermission = Schema.is(StoredPullRequestRoutingPermission);
+const encodeStoredPullRequestRoutingPermission = Schema.encodeSync(
+ Schema.fromJsonString(StoredPullRequestRoutingPermission),
);
/** Each grant has its own key so stale tabs and unrelated catalog saves cannot restore trust. */
-export function makeBrowserGitHubRoutingPermissions(
+export function makeBrowserPullRequestRoutingPermissions(
browser: Pick<Window, "localStorage"> & EventTarget = window,
) {
- const read = (key: string): StoredGitHubRoutingPermission | null => {
+ const read = (key: string): StoredPullRequestRoutingPermission | null => {
try {
const raw = browser.localStorage.getItem(key);
const value: unknown = raw === null ? null : JSON.parse(raw);
- return isStoredGitHubRoutingPermission(value) &&
- key === `${GITHUB_ROUTING_KEY_PREFIX}${value.environmentId}`
+ return isStoredPullRequestRoutingPermission(value) &&
+ key === `${PULL_REQUEST_ROUTING_KEY_PREFIX}${value.environmentId}`
? value
: null;
} catch {
return null;
}
};
- const readAll = (): ReadonlyArray<StoredGitHubRoutingPermission> => {
+ const readAll = (): ReadonlyArray<StoredPullRequestRoutingPermission> => {
try {
- const values: StoredGitHubRoutingPermission[] = [];
+ const values: StoredPullRequestRoutingPermission[] = [];
const storage = browser.localStorage;
for (let index = 0; index < storage.length; index++) {
const key = storage.key(index);
- if (key?.startsWith(GITHUB_ROUTING_KEY_PREFIX)) {
+ if (key?.startsWith(PULL_REQUEST_ROUTING_KEY_PREFIX)) {
const value = read(key);
if (value !== null) values.push(value);
}
@@ -535,46 +537,46 @@ export function makeBrowserGitHubRoutingPermissions(
return [];
}
};
- const write = (environmentId: EnvironmentId, value: StoredGitHubRoutingPermission | null) =>
+ const write = (environmentId: EnvironmentId, value: StoredPullRequestRoutingPermission | null) =>
Effect.try({
try: () => {
- const key = `${GITHUB_ROUTING_KEY_PREFIX}${environmentId}`;
+ const key = `${PULL_REQUEST_ROUTING_KEY_PREFIX}${environmentId}`;
if (value === null) browser.localStorage.removeItem(key);
- else browser.localStorage.setItem(key, encodeStoredGitHubRoutingPermission(value));
- browser.dispatchEvent(new Event(GITHUB_ROUTING_CHANGED));
+ else browser.localStorage.setItem(key, encodeStoredPullRequestRoutingPermission(value));
+ browser.dispatchEvent(new Event(PULL_REQUEST_ROUTING_CHANGED));
},
- catch: (cause) => catalogError("save GitHub routing permissions in", cause),
+ catch: (cause) => catalogError("save pull request routing permissions in", cause),
});
- return GitHubRoutingPermissions.of({
+ return PullRequestRoutingPermissions.of({
get: (entry) =>
Effect.sync(() => {
- const value = read(`${GITHUB_ROUTING_KEY_PREFIX}${entry.target.environmentId}`);
- return gitHubRoutingPermissionFor(entry, value === null ? [] : [value]);
+ const value = read(`${PULL_REQUEST_ROUTING_KEY_PREFIX}${entry.target.environmentId}`);
+ return pullRequestRoutingPermissionFor(entry, value === null ? [] : [value]);
}),
- changes: Stream.callback<ReadonlyArray<StoredGitHubRoutingPermission>>((queue) =>
+ changes: Stream.callback<ReadonlyArray<StoredPullRequestRoutingPermission>>((queue) =>
Effect.acquireRelease(
Effect.sync(() => {
const listener = (event: Event) => {
if (event.type === "storage") {
const key = (event as StorageEvent).key;
- if (key !== null && !key?.startsWith(GITHUB_ROUTING_KEY_PREFIX)) return;
+ if (key !== null && !key?.startsWith(PULL_REQUEST_ROUTING_KEY_PREFIX)) return;
}
Queue.offerUnsafe(queue, readAll());
};
browser.addEventListener("storage", listener);
- browser.addEventListener(GITHUB_ROUTING_CHANGED, listener);
+ browser.addEventListener(PULL_REQUEST_ROUTING_CHANGED, listener);
Queue.offerUnsafe(queue, readAll());
return listener;
}),
(listener) =>
Effect.sync(() => {
browser.removeEventListener("storage", listener);
- browser.removeEventListener(GITHUB_ROUTING_CHANGED, listener);
+ browser.removeEventListener(PULL_REQUEST_ROUTING_CHANGED, listener);
}),
).pipe(Effect.asVoid),
),
set: (entry, permission) => {
- const connectionKey = gitHubRoutingConnectionKey(entry);
+ const connectionKey = pullRequestRoutingConnectionKey(entry);
if (connectionKey === null)
return Effect.fail(
new ConnectionBlockedError({
@@ -623,7 +625,7 @@ export const layer = Layer.effectContext(
(owned) => owned.close,
);
const catalog = yield* makeCatalogStore(makeCatalogBackend(database));
- const githubRoutingPermissions = makeBrowserGitHubRoutingPermissions();
+ const pullRequestRoutingPermissions = makeBrowserPullRequestRoutingPermissions();
// Remembers each thread row's encoding, so a save only encodes rows that changed.
const encodeStoredShellSnapshot = makeStoredShellSnapshotEncoder({
yieldToHost: yieldToBrowserTask,
@@ -930,7 +932,7 @@ export const layer = Layer.effectContext(
});
return Context.make(Persistence.ConnectionTargetStore, targetStore).pipe(
- Context.add(GitHubRoutingPermissions, githubRoutingPermissions),
+ Context.add(PullRequestRoutingPermissions, pullRequestRoutingPermissions),
Context.add(Persistence.ConnectionRegistrationStore, registrationStore),
Context.add(ProfileStore.ConnectionProfileStore, profileStore),
Context.add(CredentialStore.ConnectionCredentialStore, credentialStore),
diff --git a/apps/web/src/sourceControlPresentation.ts b/apps/web/src/sourceControlPresentation.tsx
similarity index 72%
rename from apps/web/src/sourceControlPresentation.ts
rename to apps/web/src/sourceControlPresentation.tsx
index ec8b4c7242d..8fbc1470870 100644
--- a/apps/web/src/sourceControlPresentation.ts
+++ b/apps/web/src/sourceControlPresentation.tsx
@@ -5,31 +5,27 @@ import type {
ChangeRequestTerminology,
SourceControlClientDefinition,
} from "@t3tools/client-runtime/source-control-clients";
-import {
- AzureDevOpsIcon,
- BitbucketIcon,
- ForgejoIcon,
- GitCafeIcon,
- GitHubIcon,
- GitLabIcon,
-} from "./components/Icons";
import { PullRequestGlyph } from "~/components/pullRequest/pullRequestIcons";
+import { SourceControlIconArtwork } from "./components/SourceControlIconArtwork";
export type { ChangeRequestTerminology } from "@t3tools/client-runtime/source-control-clients";
type SourceControlIcon = ElementType<{ className?: string }>;
-const SOURCE_CONTROL_ICONS: Partial<Record<string, SourceControlIcon>> = {
- github: GitHubIcon,
- gitlab: GitLabIcon,
- forgejo: ForgejoIcon,
- bitbucket: BitbucketIcon,
- "azure-devops": AzureDevOpsIcon,
- gitcafe: GitCafeIcon,
-};
+const SOURCE_CONTROL_ICONS = new WeakMap<SourceControlClientDefinition, SourceControlIcon>();
+/** One component per definition, so a host's icon keeps its identity across renders. */
export function sourceControlIcon(definition: SourceControlClientDefinition): SourceControlIcon {
- return SOURCE_CONTROL_ICONS[definition.icon] ?? PullRequestGlyph.pullRequest;
+ const artwork = definition.icon;
+ if (artwork === null) return PullRequestGlyph.pullRequest;
+ let Icon = SOURCE_CONTROL_ICONS.get(definition);
+ if (Icon === undefined) {
+ Icon = (props: { className?: string }) => (
+ <SourceControlIconArtwork {...props} icon={artwork} />
+ );
+ SOURCE_CONTROL_ICONS.set(definition, Icon);
+ }
+ return Icon;
}
export interface SourceControlPresentation {
diff --git a/docs/internals/remote.md b/docs/internals/remote.md
index 5fcec03bbaf..b581e1be1d5 100644
--- a/docs/internals/remote.md
+++ b/docs/internals/remote.md
@@ -54,7 +54,7 @@ dropped, which is how a changed LAN address replaces the old one; routes the
user saved are never touched. The reported addresses are hints like any advertised endpoint, so a
learned route still has to answer as this environment before it is used.
-GitHub routing trust covers the whole route list. Adding or changing a route
+Pull request routing trust covers the whole route list. Adding or changing a route
revokes it; reordering does not, because the same addresses remain trusted.
## Hosted web is a client
diff --git a/docs/user/source-control.md b/docs/user/source-control.md
index cb323ea4c3b..de63202c51e 100644
--- a/docs/user/source-control.md
+++ b/docs/user/source-control.md
@@ -183,15 +183,16 @@ Press **Escape** before releasing to cancel. Failed closes stay in the list so y
GitHub, GitLab, and Azure DevOps support auto-merge while checks are outstanding. GitHub also
supports approving waiting fork workflows and opening a revert pull request for a merged change.
-GitHub sharing is off by default. In Settings → Connections → GitHub sharing (Environments on mobile), choose
-**Read PRs** or **Read and act** for each environment you trust to share GitHub access.
+Pull request sharing is off by default. In Settings → Connections → Pull request sharing (Pull
+request routing under Environments on mobile), choose **Read PRs** or **Read and act** for each
+environment you trust to share its source control access.
Enable both the original environment and the environment answering its requests on this client.
-**Read and act** can use broader GitHub permissions than the original environment's credential;
+**Read and act** can use broader permissions than the original environment's credential;
only enable it for environments you control and trust. Changing a saved endpoint or removing an
environment clears its permission.
-GitHub review details, linked PR status, and permitted review actions can then use another
-connected environment signed in to the same GitHub account. Each needs a project on that host.
+Review details, linked PR status, and permitted review actions can then use another connected
+environment signed in to the same account on the same host. Each needs a project on that host.
A connected local environment is preferred for actions and can answer slow or failed reads.
Browsers and mobile clients need a paired environment to use its GitHub credentials.
Credentials stay on their machines. Previously verified credentials remain usable for routing
diff --git a/packages/client-runtime/src/connection/index.ts b/packages/client-runtime/src/connection/index.ts
index 5686b3c3df7..02a30adb57f 100644
--- a/packages/client-runtime/src/connection/index.ts
+++ b/packages/client-runtime/src/connection/index.ts
@@ -4,7 +4,7 @@ export * as Connectivity from "./connectivity.ts";
export * as CredentialStore from "./credentialStore.ts";
export { type ConnectionDriverProgress, type EnvironmentConnectionLease } from "./driver.ts";
export * from "./errors.ts";
-export * from "./githubRoutingPermissions.ts";
+export * from "./pullRequestRoutingPermissions.ts";
export * from "./hostFreeze.ts";
export * as Connection from "./layer.ts";
export * from "./model.ts";
diff --git a/packages/client-runtime/src/connection/githubRoutingPermissions.ts b/packages/client-runtime/src/connection/pullRequestRoutingPermissions.ts
similarity index 75%
rename from packages/client-runtime/src/connection/githubRoutingPermissions.ts
rename to packages/client-runtime/src/connection/pullRequestRoutingPermissions.ts
index 3da40fb6515..23f7eb59844 100644
--- a/packages/client-runtime/src/connection/githubRoutingPermissions.ts
+++ b/packages/client-runtime/src/connection/pullRequestRoutingPermissions.ts
@@ -10,21 +10,21 @@ import * as SubscriptionRef from "effect/SubscriptionRef";
import type { ConnectionCatalogEntry } from "./catalog.ts";
import { ConnectionBlockedError, type ConnectionAttemptError } from "./model.ts";
-export const GitHubRoutingPermission = Schema.Literals(["off", "read", "read-write"]);
-export type GitHubRoutingPermission = typeof GitHubRoutingPermission.Type;
-export const StoredGitHubRoutingPermission = Schema.Struct({
+export const PullRequestRoutingPermission = Schema.Literals(["off", "read", "read-write"]);
+export type PullRequestRoutingPermission = typeof PullRequestRoutingPermission.Type;
+export const StoredPullRequestRoutingPermission = Schema.Struct({
environmentId: EnvironmentId,
connectionKey: Schema.String,
- permission: GitHubRoutingPermission,
+ permission: PullRequestRoutingPermission,
});
-export type StoredGitHubRoutingPermission = typeof StoredGitHubRoutingPermission.Type;
+export type StoredPullRequestRoutingPermission = typeof StoredPullRequestRoutingPermission.Type;
/**
* Trust belongs to the saved endpoints, never to an environment id advertised
* by a server alone. With several routes the key covers all of them, sorted so
* reordering keeps trust but adding or changing an address revokes it.
*/
-export function gitHubRoutingConnectionKey(entry: ConnectionCatalogEntry): string | null {
+export function pullRequestRoutingConnectionKey(entry: ConnectionCatalogEntry): string | null {
const routes = [
{ target: entry.target, profile: entry.profile },
...(entry.alternateRoutes ?? []),
@@ -75,25 +75,25 @@ function routeConnectionKey(
}
}
-export function gitHubRoutingPermissionFor(
+export function pullRequestRoutingPermissionFor(
entry: ConnectionCatalogEntry,
- permissions: ReadonlyArray<StoredGitHubRoutingPermission>,
-): GitHubRoutingPermission {
- const key = gitHubRoutingConnectionKey(entry);
+ permissions: ReadonlyArray<StoredPullRequestRoutingPermission>,
+): PullRequestRoutingPermission {
+ const key = pullRequestRoutingConnectionKey(entry);
return key === null
? "off"
: (permissions.find((permission) => permission.connectionKey === key)?.permission ?? "off");
}
-export class GitHubRoutingPermissions extends Context.Reference<{
- readonly get: (entry: ConnectionCatalogEntry) => Effect.Effect<GitHubRoutingPermission>;
- readonly changes: Stream.Stream<ReadonlyArray<StoredGitHubRoutingPermission>>;
+export class PullRequestRoutingPermissions extends Context.Reference<{
+ readonly get: (entry: ConnectionCatalogEntry) => Effect.Effect<PullRequestRoutingPermission>;
+ readonly changes: Stream.Stream<ReadonlyArray<StoredPullRequestRoutingPermission>>;
readonly set: (
entry: ConnectionCatalogEntry,
- permission: GitHubRoutingPermission,
+ permission: PullRequestRoutingPermission,
) => Effect.Effect<void, ConnectionAttemptError>;
readonly forget: (environmentId: EnvironmentId) => Effect.Effect<void, ConnectionAttemptError>;
-}>("@t3tools/client-runtime/connection/GitHubRoutingPermissions", {
+}>("@t3tools/client-runtime/connection/PullRequestRoutingPermissions", {
defaultValue: () => ({
get: () => Effect.succeed("off"),
changes: Stream.succeed([]),
@@ -101,29 +101,29 @@ export class GitHubRoutingPermissions extends Context.Reference<{
Effect.fail(
new ConnectionBlockedError({
reason: "unsupported",
- detail: "GitHub routing preferences are unavailable on this client.",
+ detail: "Pull request routing preferences are unavailable on this client.",
}),
),
forget: () => Effect.void,
}),
}) {}
-export const makeGitHubRoutingPermissions = Effect.fn("makeGitHubRoutingPermissions")(
+export const makePullRequestRoutingPermissions = Effect.fn("makePullRequestRoutingPermissions")(
function* (storage: {
readonly read: Effect.Effect<
- ReadonlyArray<StoredGitHubRoutingPermission>,
+ ReadonlyArray<StoredPullRequestRoutingPermission>,
ConnectionAttemptError
>;
readonly write: (
- permissions: ReadonlyArray<StoredGitHubRoutingPermission>,
+ permissions: ReadonlyArray<StoredPullRequestRoutingPermission>,
) => Effect.Effect<void, ConnectionAttemptError>;
}) {
const state = yield* SubscriptionRef.make(yield* storage.read);
const lock = yield* Semaphore.make(1);
const update = (
transform: (
- current: ReadonlyArray<StoredGitHubRoutingPermission>,
- ) => ReadonlyArray<StoredGitHubRoutingPermission>,
+ current: ReadonlyArray<StoredPullRequestRoutingPermission>,
+ ) => ReadonlyArray<StoredPullRequestRoutingPermission>,
) =>
lock.withPermits(1)(
Effect.gen(function* () {
@@ -134,14 +134,14 @@ export const makeGitHubRoutingPermissions = Effect.fn("makeGitHubRoutingPermissi
yield* SubscriptionRef.set(state, next);
}),
);
- return GitHubRoutingPermissions.of({
+ return PullRequestRoutingPermissions.of({
get: (entry) =>
SubscriptionRef.get(state).pipe(
- Effect.map((permissions) => gitHubRoutingPermissionFor(entry, permissions)),
+ Effect.map((permissions) => pullRequestRoutingPermissionFor(entry, permissions)),
),
changes: SubscriptionRef.changes(state),
set: (entry, permission) => {
- const connectionKey = gitHubRoutingConnectionKey(entry);
+ const connectionKey = pullRequestRoutingConnectionKey(entry);
if (connectionKey === null)
return Effect.fail(
new ConnectionBlockedError({
diff --git a/packages/client-runtime/src/connection/registry.test.ts b/packages/client-runtime/src/connection/registry.test.ts
index b9f58c63346..0d0327c53af 100644
--- a/packages/client-runtime/src/connection/registry.test.ts
+++ b/packages/client-runtime/src/connection/registry.test.ts
@@ -57,10 +57,10 @@ import * as Persistence from "../platform/persistence.ts";
import * as ConnectionProfileStore from "./profileStore.ts";
import * as EnvironmentRegistry from "./registry.ts";
import {
- GitHubRoutingPermissions,
- type StoredGitHubRoutingPermission,
- makeGitHubRoutingPermissions,
-} from "./githubRoutingPermissions.ts";
+ PullRequestRoutingPermissions,
+ type StoredPullRequestRoutingPermission,
+ makePullRequestRoutingPermissions,
+} from "./pullRequestRoutingPermissions.ts";
import * as RpcSession from "../rpc/session.ts";
import * as EnvironmentSupervisor from "./supervisor.ts";
import * as ConnectionWakeups from "./wakeups.ts";
@@ -1553,7 +1553,7 @@ describe("EnvironmentRegistry", () => {
label: "Shadowed relay environment",
});
const harness = yield* makeHarness([shadowedTarget]);
- const permissions = yield* makeGitHubRoutingPermissions({
+ const permissions = yield* makePullRequestRoutingPermissions({
read: Effect.succeed([]),
write: () => Effect.void,
});
@@ -1578,7 +1578,7 @@ describe("EnvironmentRegistry", () => {
expect(hasRoutes(yield* Ref.get(harness.storedTargets), TARGET.environmentId)).toBe(false);
}).pipe(
Effect.provide(harness.layer),
- Effect.provideService(GitHubRoutingPermissions, permissions),
+ Effect.provideService(PullRequestRoutingPermissions, permissions),
Effect.scoped,
);
}),
@@ -1765,7 +1765,7 @@ describe("EnvironmentRegistry", () => {
Effect.gen(function* () {
const harness = yield* makeHarness([]);
let failWrites = false;
- const permissions = yield* makeGitHubRoutingPermissions({
+ const permissions = yield* makePullRequestRoutingPermissions({
read: Effect.succeed([]),
write: () =>
failWrites
@@ -1822,7 +1822,7 @@ describe("EnvironmentRegistry", () => {
expect(yield* permissions.get(entry)).toBe("off");
}).pipe(
Effect.provide(harness.layer),
- Effect.provideService(GitHubRoutingPermissions, permissions),
+ Effect.provideService(PullRequestRoutingPermissions, permissions),
Effect.scoped,
);
}),
@@ -2021,33 +2021,38 @@ describe("EnvironmentRegistry routes", () => {
}),
);
- it.effect("revokes GitHub routing trust when a route is added but keeps it on reorder", () =>
- Effect.gen(function* () {
- const harness = yield* makeHarness([RELAY_TARGET]);
- let stored: ReadonlyArray<StoredGitHubRoutingPermission> = [];
- const permissions = yield* makeGitHubRoutingPermissions({
- read: Effect.sync(() => stored),
- write: (next) => Effect.sync(() => void (stored = next)),
- });
- yield* Effect.gen(function* () {
- const registry = yield* EnvironmentRegistry.EnvironmentRegistry;
- const current = () =>
- SubscriptionRef.get(registry.entries).pipe(
- Effect.map((entries) => entries.get(RELAY_TARGET.environmentId)!),
- );
- yield* permissions.set(yield* current(), "read");
- yield* registry.register(lanRegistration());
- expect(yield* permissions.get(yield* current())).toBe("off");
-
- yield* permissions.set(yield* current(), "read");
- yield* registry.reorderRoutes(LAN_TARGET.environmentId, ["relay", LAN_TARGET.connectionId]);
- expect(yield* permissions.get(yield* current())).toBe("read");
- }).pipe(
- Effect.provide(harness.layer),
- Effect.provideService(GitHubRoutingPermissions, permissions),
- Effect.scoped,
- );
- }),
+ it.effect(
+ "revokes pull request routing trust when a route is added but keeps it on reorder",
+ () =>
+ Effect.gen(function* () {
+ const harness = yield* makeHarness([RELAY_TARGET]);
+ let stored: ReadonlyArray<StoredPullRequestRoutingPermission> = [];
+ const permissions = yield* makePullRequestRoutingPermissions({
+ read: Effect.sync(() => stored),
+ write: (next) => Effect.sync(() => void (stored = next)),
+ });
+ yield* Effect.gen(function* () {
+ const registry = yield* EnvironmentRegistry.EnvironmentRegistry;
+ const current = () =>
+ SubscriptionRef.get(registry.entries).pipe(
+ Effect.map((entries) => entries.get(RELAY_TARGET.environmentId)!),
+ );
+ yield* permissions.set(yield* current(), "read");
+ yield* registry.register(lanRegistration());
+ expect(yield* permissions.get(yield* current())).toBe("off");
+
+ yield* permissions.set(yield* current(), "read");
+ yield* registry.reorderRoutes(LAN_TARGET.environmentId, [
+ "relay",
+ LAN_TARGET.connectionId,
+ ]);
+ expect(yield* permissions.get(yield* current())).toBe("read");
+ }).pipe(
+ Effect.provide(harness.layer),
+ Effect.provideService(PullRequestRoutingPermissions, permissions),
+ Effect.scoped,
+ );
+ }),
);
it.effect("loads saved routes grouped by environment, in saved order", () =>
diff --git a/packages/client-runtime/src/connection/registry.ts b/packages/client-runtime/src/connection/registry.ts
index 76c49bc86ea..debd9d65e92 100644
--- a/packages/client-runtime/src/connection/registry.ts
+++ b/packages/client-runtime/src/connection/registry.ts
@@ -40,9 +40,9 @@ import * as EnvironmentSupervisor from "./supervisor.ts";
import * as ConnectionDriver from "./driver.ts";
import * as ConnectionWakeups from "./wakeups.ts";
import {
- GitHubRoutingPermissions,
- gitHubRoutingConnectionKey,
-} from "./githubRoutingPermissions.ts";
+ PullRequestRoutingPermissions,
+ pullRequestRoutingConnectionKey,
+} from "./pullRequestRoutingPermissions.ts";
import {
RELAY_ROUTE_ID,
connectionRouteId,
@@ -208,7 +208,7 @@ export const make = Effect.gen(function* () {
const ownedDataCleanup = yield* Persistence.EnvironmentOwnedDataCleanup;
const profiles = yield* ConnectionProfileStore.ConnectionProfileStore;
const credentials = yield* ConnectionCredentialStore.ConnectionCredentialStore;
- const githubRoutingPermissions = yield* GitHubRoutingPermissions;
+ const pullRequestRoutingPermissions = yield* PullRequestRoutingPermissions;
const connectivity = yield* Connectivity.Connectivity;
const driver = yield* ConnectionDriver.ConnectionDriver;
const wakeups = yield* ConnectionWakeups.ConnectionWakeups;
@@ -508,7 +508,7 @@ export const make = Effect.gen(function* () {
environmentId: EnvironmentId,
operation: "register-connection" | "set-connection-routes",
) =>
- githubRoutingPermissions.forget(environmentId).pipe(
+ pullRequestRoutingPermissions.forget(environmentId).pipe(
Effect.mapError(
(error) =>
new Persistence.ConnectionPersistenceError({
@@ -522,12 +522,12 @@ export const make = Effect.gen(function* () {
connectionRoutes(entry).map((route) => route.target as PersistedConnectionTarget);
/**
- * GitHub trust and an unsupported verdict both belong to the saved addresses: a changed set may
+ * Pull request routing trust and an unsupported verdict both belong to the saved addresses: a changed set may
* reach a different server, so both are dropped and the next connection decides.
*/
const withRoutes = (previous: ConnectionCatalogEntry, routes: ReadonlyArray<ConnectionRoute>) => {
const next = entryWithRoutes(previous, routes);
- if (gitHubRoutingConnectionKey(previous) === gitHubRoutingConnectionKey(next)) {
+ if (pullRequestRoutingConnectionKey(previous) === pullRequestRoutingConnectionKey(next)) {
return { entry: next, addressesChanged: false };
}
const { unsupportedReason: _reason, serverUpdateRequired: _update, ...rest } = next;
@@ -604,19 +604,20 @@ export const make = Effect.gen(function* () {
const previous = (yield* SubscriptionRef.get(entries)).get(target.environmentId);
const entry: ConnectionCatalogEntry =
previous?.unsupportedReason !== undefined &&
- gitHubRoutingConnectionKey(previous) === gitHubRoutingConnectionKey(registered)
+ pullRequestRoutingConnectionKey(previous) ===
+ pullRequestRoutingConnectionKey(registered)
? { ...registered, ...unsupportedState(previous) }
: registered;
const persisted = (yield* Ref.get(persistedEnvironmentIds)).has(target.environmentId);
if (
persisted ||
(previous !== undefined &&
- gitHubRoutingConnectionKey(previous) !== gitHubRoutingConnectionKey(entry))
+ pullRequestRoutingConnectionKey(previous) !== pullRequestRoutingConnectionKey(entry))
) {
- const revoked = yield* githubRoutingPermissions.forget(target.environmentId).pipe(
+ const revoked = yield* pullRequestRoutingPermissions.forget(target.environmentId).pipe(
Effect.tapError((error) =>
Effect.logWarning(
- "Could not clear GitHub routing permission for a platform environment.",
+ "Could not clear pull request routing permission for a platform environment.",
{
environmentId: target.environmentId,
error,
@@ -725,10 +726,10 @@ export const make = Effect.gen(function* () {
environmentId,
Effect.gen(function* () {
const entry = (yield* SubscriptionRef.get(entries)).get(environmentId);
- const revoked = yield* githubRoutingPermissions.forget(environmentId).pipe(
+ const revoked = yield* pullRequestRoutingPermissions.forget(environmentId).pipe(
Effect.tapError((error) =>
Effect.logWarning(
- "Could not clear GitHub routing permission after platform removal.",
+ "Could not clear pull request routing permission after platform removal.",
{
environmentId,
error,
@@ -811,7 +812,7 @@ export const make = Effect.gen(function* () {
}
const entry = yield* getEntry(environmentId);
- yield* githubRoutingPermissions.forget(environmentId);
+ yield* pullRequestRoutingPermissions.forget(environmentId);
yield* registrations.remove(environmentId);
yield* Ref.update(persistedEnvironmentIds, (current) => {
const next = new Set(current);
@@ -867,7 +868,7 @@ export const make = Effect.gen(function* () {
typeof globalThis.location === "undefined" || globalThis.location.protocol !== "https:";
/**
- * Learned routes reuse the active route's credential, so they do not revoke GitHub routing
+ * Learned routes reuse the active route's credential, so they do not revoke pull request routing
* trust the way a newly paired address does.
*/
const learnRoutes = Effect.fn("EnvironmentRegistry.learnRoutes")(function* (input: {
diff --git a/packages/client-runtime/src/connection/resolver.test.ts b/packages/client-runtime/src/connection/resolver.test.ts
index 849cacbab3a..1a5fbffddb5 100644
--- a/packages/client-runtime/src/connection/resolver.test.ts
+++ b/packages/client-runtime/src/connection/resolver.test.ts
@@ -29,10 +29,10 @@ import {
import * as ConnectionProfileStore from "./profileStore.ts";
import * as RpcHttp from "../rpc/http.ts";
import {
- GitHubRoutingPermissions,
- gitHubRoutingConnectionKey,
- makeGitHubRoutingPermissions,
-} from "./githubRoutingPermissions.ts";
+ PullRequestRoutingPermissions,
+ pullRequestRoutingConnectionKey,
+ makePullRequestRoutingPermissions,
+} from "./pullRequestRoutingPermissions.ts";
const ENVIRONMENT_ID = EnvironmentId.make("environment-1");
const ENDPOINT = {
@@ -275,11 +275,11 @@ describe("ConnectionResolver", () => {
reason: "remote-unavailable",
detail: "Could not persist routing consent.",
});
- const permissions = yield* makeGitHubRoutingPermissions({
+ const permissions = yield* makePullRequestRoutingPermissions({
read: Effect.succeed([
{
environmentId: ENVIRONMENT_ID,
- connectionKey: gitHubRoutingConnectionKey(entry)!,
+ connectionKey: pullRequestRoutingConnectionKey(entry)!,
permission: "read-write",
},
]),
@@ -328,7 +328,7 @@ describe("ConnectionResolver", () => {
);
const prepare = broker
.prepare(entry)
- .pipe(Effect.provideService(GitHubRoutingPermissions, permissions));
+ .pipe(Effect.provideService(PullRequestRoutingPermissions, permissions));
if (scenario === "revocation-failed") {
expect(yield* Effect.flip(prepare)).toBe(failure);
expect(savedProfile).toBe(profile);
diff --git a/packages/client-runtime/src/connection/resolver.ts b/packages/client-runtime/src/connection/resolver.ts
index cfcf719d9bf..647fbab1dba 100644
--- a/packages/client-runtime/src/connection/resolver.ts
+++ b/packages/client-runtime/src/connection/resolver.ts
@@ -31,9 +31,9 @@ import {
profileMissingError,
} from "./errors.ts";
import {
- GitHubRoutingPermissions,
- gitHubRoutingConnectionKey,
-} from "./githubRoutingPermissions.ts";
+ PullRequestRoutingPermissions,
+ pullRequestRoutingConnectionKey,
+} from "./pullRequestRoutingPermissions.ts";
import type {
BearerConnectionTarget,
ConnectionTarget,
@@ -250,10 +250,10 @@ const makeSshBroker = Effect.fn("clientRuntime.connection.broker.makeSsh")(funct
target: prepared.bootstrap.target,
});
if (
- gitHubRoutingConnectionKey(entry) !==
- gitHubRoutingConnectionKey({ ...entry, profile: Option.some(preparedProfile) })
+ pullRequestRoutingConnectionKey(entry) !==
+ pullRequestRoutingConnectionKey({ ...entry, profile: Option.some(preparedProfile) })
) {
- const permissions = yield* GitHubRoutingPermissions;
+ const permissions = yield* PullRequestRoutingPermissions;
yield* permissions.forget(target.environmentId);
}
yield* profiles.put(preparedProfile);
diff --git a/packages/client-runtime/src/connection/routes.test.ts b/packages/client-runtime/src/connection/routes.test.ts
index 7e93017334c..44bca8a7a9a 100644
--- a/packages/client-runtime/src/connection/routes.test.ts
+++ b/packages/client-runtime/src/connection/routes.test.ts
@@ -7,7 +7,7 @@ import {
type ConnectionCatalogEntry,
type ConnectionRoute,
} from "./catalog.ts";
-import { gitHubRoutingConnectionKey } from "./githubRoutingPermissions.ts";
+import { pullRequestRoutingConnectionKey } from "./pullRequestRoutingPermissions.ts";
import { BearerConnectionTarget, RelayConnectionTarget } from "./model.ts";
import {
connectionRouteId,
@@ -347,7 +347,7 @@ describe("learned routes", () => {
expect(removedWithRelay(entryWithRoutes(relayOnly, [LAN, RELAY]))).toBe(false);
});
- it("keeps GitHub routing trust when a route is learned", () => {
+ it("keeps pull request routing trust when a route is learned", () => {
const learned = mergeLearnedRoutes({
entry: relayOnly,
activeRoute: RELAY,
@@ -360,7 +360,9 @@ describe("learned routes", () => {
profile: learned[0]!.profile,
alternateRoutes: learned.slice(1),
};
- expect(gitHubRoutingConnectionKey(withLearned)).toBe(gitHubRoutingConnectionKey(relayOnly));
+ expect(pullRequestRoutingConnectionKey(withLearned)).toBe(
+ pullRequestRoutingConnectionKey(relayOnly),
+ );
});
it("keeps the T3 Connect credential when learning over a learned T3 Connect route", () => {
diff --git a/packages/client-runtime/src/platform/storageDocument.test.ts b/packages/client-runtime/src/platform/storageDocument.test.ts
index 1ea0c9d7f1b..60f561e3dae 100644
--- a/packages/client-runtime/src/platform/storageDocument.test.ts
+++ b/packages/client-runtime/src/platform/storageDocument.test.ts
@@ -21,9 +21,9 @@ import {
SshConnectionTarget,
} from "../connection/model.ts";
import {
- GitHubRoutingPermissions,
- makeGitHubRoutingPermissions,
-} from "../connection/githubRoutingPermissions.ts";
+ PullRequestRoutingPermissions,
+ makePullRequestRoutingPermissions,
+} from "../connection/pullRequestRoutingPermissions.ts";
import {
ConnectionCatalogDocument,
EMPTY_CONNECTION_CATALOG_DOCUMENT,
@@ -87,10 +87,10 @@ describe("ConnectionCatalogDocument", () => {
}).pipe(Effect.orDie);
}),
};
- const permissions = yield* makeGitHubRoutingPermissions(storage);
+ const permissions = yield* makePullRequestRoutingPermissions(storage);
expect(yield* permissions.get(entry)).toBe("off");
yield* permissions.set(entry, "read");
- const restarted = yield* makeGitHubRoutingPermissions(storage);
+ const restarted = yield* makePullRequestRoutingPermissions(storage);
expect(yield* restarted.get(entry)).toBe("read");
const changedEndpoint = {
@@ -121,19 +121,19 @@ describe("ConnectionCatalogDocument", () => {
expect(yield* restarted.get(entry)).toBe("read-write");
yield* restarted.forget(ENVIRONMENT_ID);
expect(yield* restarted.get(entry)).toBe("off");
- const afterRemoval = yield* makeGitHubRoutingPermissions(storage);
+ const afterRemoval = yield* makePullRequestRoutingPermissions(storage);
expect(yield* afterRemoval.get(entry)).toBe("off");
yield* permissions.set(entry, "read");
document = removeConnectionFromCatalog(document, ENVIRONMENT_ID);
- const afterCatalogRemoval = yield* makeGitHubRoutingPermissions(storage);
+ const afterCatalogRemoval = yield* makePullRequestRoutingPermissions(storage);
expect(yield* afterCatalogRemoval.get(entry)).toBe("off");
}),
);
it.effect("requires explicit trust for primary, relay, and SSH connections independently", () =>
Effect.gen(function* () {
- const permissions = yield* makeGitHubRoutingPermissions({
+ const permissions = yield* makePullRequestRoutingPermissions({
read: Effect.succeed([]),
write: () => Effect.void,
});
@@ -179,8 +179,8 @@ describe("ConnectionCatalogDocument", () => {
it.effect("does not enable GitHub routing when permission persistence fails", () =>
Effect.gen(function* () {
const entry = { target: BEARER_TARGET, profile: Option.some(BEARER_PROFILE), enabled: true };
- expect(yield* (yield* GitHubRoutingPermissions).get(entry)).toBe("off");
- const permissions = yield* makeGitHubRoutingPermissions({
+ expect(yield* (yield* PullRequestRoutingPermissions).get(entry)).toBe("off");
+ const permissions = yield* makePullRequestRoutingPermissions({
read: Effect.succeed([]),
write: () =>
Effect.fail(
diff --git a/packages/client-runtime/src/platform/storageDocument.ts b/packages/client-runtime/src/platform/storageDocument.ts
index 8fe8533b3c5..1af8e0e3d67 100644
--- a/packages/client-runtime/src/platform/storageDocument.ts
+++ b/packages/client-runtime/src/platform/storageDocument.ts
@@ -9,7 +9,7 @@ import {
} from "../connection/catalog.ts";
import { type ConnectionTarget, PersistedConnectionTarget } from "../connection/model.ts";
import * as TokenStore from "../authorization/tokenStore.ts";
-import { StoredGitHubRoutingPermission } from "../connection/githubRoutingPermissions.ts";
+import { StoredPullRequestRoutingPermission } from "../connection/pullRequestRoutingPermissions.ts";
export const StoredConnectionCredential = Schema.Struct({
connectionId: Schema.String,
@@ -23,7 +23,9 @@ export const ConnectionCatalogDocument = Schema.Struct({
profiles: Schema.Array(ConnectionProfile),
credentials: Schema.Array(StoredConnectionCredential),
remoteDpopTokens: Schema.Array(TokenStore.RemoteDpopAccessToken),
- githubRoutingPermissions: Schema.optionalKey(Schema.Array(StoredGitHubRoutingPermission)),
+ // Pull request routing grants. The field name predates the rename and stays, so older and
+ // newer clients sharing this document keep reading and revoking the same grants.
+ githubRoutingPermissions: Schema.optionalKey(Schema.Array(StoredPullRequestRoutingPermission)),
disabledEnvironmentIds: Schema.Array(EnvironmentId).pipe(
Schema.withDecodingDefaultKey(Effect.succeed([])),
),
diff --git a/packages/client-runtime/src/sourceControlClients.ts b/packages/client-runtime/src/sourceControlClients.ts
index 87da337cdee..ade5732df68 100644
--- a/packages/client-runtime/src/sourceControlClients.ts
+++ b/packages/client-runtime/src/sourceControlClients.ts
@@ -1,18 +1,24 @@
import * as AzureDevOps from "@t3tools/source-control-azure-devops/client/definition";
import * as Bitbucket from "@t3tools/source-control-bitbucket/client/definition";
import {
+ HostCredentialSettings,
makeSourceControlClientRegistry,
readSourceControlHostSettings,
} from "@t3tools/source-control-core/client/definition";
import type { ServerSettings } from "@t3tools/contracts";
export {
+ isMonochromeSourceControlIcon,
UNKNOWN_SOURCE_CONTROL_CLIENT,
type ChangeRequestLink,
type ChangeRequestTerminology,
+ type HostAccountChoice,
+ type HostCredentialSettings,
type ParsedChangeRequestUrl,
type ReferenceAutolink,
type SourceControlClientDefinition,
+ type SourceControlHostCredentials,
+ type SourceControlIcon,
} from "@t3tools/source-control-core/client/definition";
import * as Forgejo from "@t3tools/source-control-forgejo/client/definition";
import * as GitCafe from "@t3tools/source-control-gitcafe/client/definition";
@@ -51,8 +57,10 @@ export const sourceControlClients = makeSourceControlClientRegistry(
},
);
-export type { GitHubSettings } from "@t3tools/source-control-github/client/definition";
-
-export function readGitHubSettings(settings: Pick<ServerSettings, "sourceControlHosts">) {
- return readSourceControlHostSettings(GitHub.settings, settings.sourceControlHosts.github);
+/** The saved per-hostname accounts and tokens of a host whose definition has `credentials`. */
+export function readHostCredentialSettings(
+ settings: Pick<ServerSettings, "sourceControlHosts">,
+ kind: string,
+): HostCredentialSettings {
+ return readSourceControlHostSettings(HostCredentialSettings, settings.sourceControlHosts[kind]);
}
diff --git a/packages/client-runtime/src/state/connections.ts b/packages/client-runtime/src/state/connections.ts
index 686bcfd8315..779bbd054ad 100644
--- a/packages/client-runtime/src/state/connections.ts
+++ b/packages/client-runtime/src/state/connections.ts
@@ -10,10 +10,10 @@ import type { ConnectionCatalogEntry } from "../connection/catalog.ts";
import { AVAILABLE_CONNECTION_STATE } from "../connection/model.ts";
import * as EnvironmentSupervisor from "../connection/supervisor.ts";
import {
- GitHubRoutingPermissions,
- type GitHubRoutingPermission,
- type StoredGitHubRoutingPermission,
-} from "../connection/githubRoutingPermissions.ts";
+ PullRequestRoutingPermissions,
+ type PullRequestRoutingPermission,
+ type StoredPullRequestRoutingPermission,
+} from "../connection/pullRequestRoutingPermissions.ts";
import {
createAtomCommandScheduler,
createRuntimeCommand,
@@ -65,20 +65,22 @@ export function createEnvironmentCatalogAtoms<R, E>(
Option.getOrElse(AsyncResult.value(get(catalogAtom)), () => EMPTY_ENVIRONMENT_CATALOG_STATE),
).pipe(Atom.withLabel("environment-catalog-value"));
- const githubRoutingPermissionsAtom = runtime.atom(
- Stream.unwrap(GitHubRoutingPermissions.pipe(Effect.map((permissions) => permissions.changes))),
- { initialValue: [] as ReadonlyArray<StoredGitHubRoutingPermission> },
+ const pullRequestRoutingPermissionsAtom = runtime.atom(
+ Stream.unwrap(
+ PullRequestRoutingPermissions.pipe(Effect.map((permissions) => permissions.changes)),
+ ),
+ { initialValue: [] as ReadonlyArray<StoredPullRequestRoutingPermission> },
);
- const githubRoutingPermissionsValueAtom = Atom.make((get) =>
- Option.getOrElse(AsyncResult.value(get(githubRoutingPermissionsAtom)), () => []),
- ).pipe(Atom.withLabel("environment-github-routing-permissions"));
- const setGitHubRoutingPermission = createRuntimeCommand(runtime, {
- label: "environment-catalog:github-routing-permission",
+ const pullRequestRoutingPermissionsValueAtom = Atom.make((get) =>
+ Option.getOrElse(AsyncResult.value(get(pullRequestRoutingPermissionsAtom)), () => []),
+ ).pipe(Atom.withLabel("environment-pull-request-routing-permissions"));
+ const setPullRequestRoutingPermission = createRuntimeCommand(runtime, {
+ label: "environment-catalog:pull-request-routing-permission",
scheduler: commandScheduler,
concurrency: serial,
execute: Effect.fn(function* (input: {
readonly environmentId: EnvironmentIdType;
- readonly permission: GitHubRoutingPermission;
+ readonly permission: PullRequestRoutingPermission;
}) {
const registry = yield* EnvironmentRegistry.EnvironmentRegistry;
const entry = (yield* SubscriptionRef.get(registry.entries)).get(input.environmentId);
@@ -86,7 +88,7 @@ export function createEnvironmentCatalogAtoms<R, E>(
return yield* new EnvironmentRegistry.EnvironmentNotRegisteredError({
environmentId: input.environmentId,
});
- const permissions = yield* GitHubRoutingPermissions;
+ const permissions = yield* PullRequestRoutingPermissions;
yield* permissions.set(entry, input.permission);
}),
});
@@ -190,8 +192,8 @@ export function createEnvironmentCatalogAtoms<R, E>(
return {
catalogAtom,
catalogValueAtom,
- githubRoutingPermissionsValueAtom,
- setGitHubRoutingPermission,
+ pullRequestRoutingPermissionsValueAtom,
+ setPullRequestRoutingPermission,
networkStatusAtom,
networkStatusValueAtom,
stateAtom,
diff --git a/packages/client-runtime/src/state/pullRequestRouting.ts b/packages/client-runtime/src/state/pullRequestRouting.ts
index a6cd89ee864..ef146fb1f30 100644
--- a/packages/client-runtime/src/state/pullRequestRouting.ts
+++ b/packages/client-runtime/src/state/pullRequestRouting.ts
@@ -18,9 +18,9 @@ import * as SubscriptionRef from "effect/SubscriptionRef";
import * as EnvironmentRegistry from "../connection/registry.ts";
import * as EnvironmentSupervisor from "../connection/supervisor.ts";
import {
- GitHubRoutingPermissions,
- gitHubRoutingConnectionKey,
-} from "../connection/githubRoutingPermissions.ts";
+ PullRequestRoutingPermissions,
+ pullRequestRoutingConnectionKey,
+} from "../connection/pullRequestRoutingPermissions.ts";
import type { ConnectionCatalogEntry } from "../connection/catalog.ts";
import * as ConnectionProfileStore from "../connection/profileStore.ts";
import type { RpcSession } from "../rpc/session.ts";
@@ -171,7 +171,7 @@ const routingAllowed = Effect.fn("PullRequestRouting.allowed")(function* (
destination.unsupportedReason !== undefined
)
return false;
- const permissions = yield* GitHubRoutingPermissions;
+ const permissions = yield* PullRequestRoutingPermissions;
const source = yield* permissions.get(origin);
const target = yield* permissions.get(destination);
const allowed = write
@@ -185,8 +185,9 @@ const routingAllowed = Effect.fn("PullRequestRouting.allowed")(function* (
const profile = yield* profiles.value
.get(entry.target.connectionId)
.pipe(Effect.orElseSucceed(() => Option.none()));
- const key = gitHubRoutingConnectionKey(entry);
- if (key === null || key !== gitHubRoutingConnectionKey({ ...entry, profile })) return false;
+ const key = pullRequestRoutingConnectionKey(entry);
+ if (key === null || key !== pullRequestRoutingConnectionKey({ ...entry, profile }))
+ return false;
}
return true;
});
diff --git a/packages/client-runtime/src/state/pullRequests.test.ts b/packages/client-runtime/src/state/pullRequests.test.ts
index 74493ff95fb..474ef49de53 100644
--- a/packages/client-runtime/src/state/pullRequests.test.ts
+++ b/packages/client-runtime/src/state/pullRequests.test.ts
@@ -44,7 +44,7 @@ import {
import * as PullRequestDiffLoader from "./pullRequestDiffHttp.ts";
import { executeAtomQuery } from "./runtime.ts";
import { createPullRequestRouter } from "./pullRequestRouting.ts";
-import { GitHubRoutingPermissions } from "../connection/githubRoutingPermissions.ts";
+import { PullRequestRoutingPermissions } from "../connection/pullRequestRoutingPermissions.ts";
const trustedRouting = {
get: () => Effect.succeed("read-write" as const),
@@ -198,7 +198,7 @@ for (const scenario of [
).pipe(
Effect.provideService(EnvironmentRegistry.EnvironmentRegistry, environmentRegistry),
Effect.provideService(RpcPermissionGuard, { authorize: () => Effect.void }),
- Effect.provideService(GitHubRoutingPermissions, {
+ Effect.provideService(PullRequestRoutingPermissions, {
...trustedRouting,
get: () => Effect.succeed(trusted ? "read-write" : "off"),
}),
@@ -283,7 +283,7 @@ it.effect.each([
}).pipe(
Effect.provideService(EnvironmentRegistry.EnvironmentRegistry, environmentRegistry),
Effect.provideService(EnvironmentSupervisor.EnvironmentSupervisor, supervisor),
- Effect.provideService(GitHubRoutingPermissions, trustedRouting),
+ Effect.provideService(PullRequestRoutingPermissions, trustedRouting),
);
const first = yield* read().pipe(Effect.forkChild);
yield* Deferred.await(started);
@@ -347,7 +347,7 @@ it.effect.each(["revoked", "disabled"] as const)(
).pipe(
Effect.provideService(EnvironmentRegistry.EnvironmentRegistry, environmentRegistry),
Effect.provideService(EnvironmentSupervisor.EnvironmentSupervisor, supervisor),
- Effect.provideService(GitHubRoutingPermissions, {
+ Effect.provideService(PullRequestRoutingPermissions, {
...trustedRouting,
get: () => Effect.sync(() => (trusted ? "read-write" : "off")),
}),
@@ -415,7 +415,7 @@ it.effect.each(["origin", "alternate"] as const)(
}).pipe(
Effect.provideService(EnvironmentRegistry.EnvironmentRegistry, environmentRegistry),
Effect.provideService(EnvironmentSupervisor.EnvironmentSupervisor, supervisor),
- Effect.provideService(GitHubRoutingPermissions, trustedRouting),
+ Effect.provideService(PullRequestRoutingPermissions, trustedRouting),
);
const first = yield* read().pipe(Effect.forkChild);
yield* Deferred.await(started);
@@ -479,7 +479,7 @@ it.effect("forgets routed viewed marks when a viewed-files batch fails", () =>
);
}).pipe(
Effect.provideService(EnvironmentRegistry.EnvironmentRegistry, environmentRegistry),
- Effect.provideService(GitHubRoutingPermissions, trustedRouting),
+ Effect.provideService(PullRequestRoutingPermissions, trustedRouting),
Effect.provideService(RpcPermissionGuard, { authorize: () => Effect.void }),
Effect.provideService(EnvironmentSupervisor.EnvironmentSupervisor, supervisor),
);
@@ -678,7 +678,7 @@ it.effect.each([
? request
: request.pipe(
Effect.provideService(RpcPermissionGuard, { authorize: () => Effect.void }),
- Effect.provideService(GitHubRoutingPermissions, {
+ Effect.provideService(PullRequestRoutingPermissions, {
...trustedRouting,
get: (entry) =>
Effect.succeed(
@@ -797,7 +797,7 @@ it.effect.each(
}).pipe(
Effect.provideService(EnvironmentRegistry.EnvironmentRegistry, environmentRegistry),
Effect.provideService(EnvironmentSupervisor.EnvironmentSupervisor, supervisor),
- Effect.provideService(GitHubRoutingPermissions, trustedRouting),
+ Effect.provideService(PullRequestRoutingPermissions, trustedRouting),
Effect.provideService(RpcPermissionGuard, { authorize: () => Effect.void }),
);
yield* stored === "unavailable"
@@ -860,7 +860,7 @@ it.live.each([undefined, true, false])(
number: 7,
}).pipe(
Effect.provideService(EnvironmentRegistry.EnvironmentRegistry, environmentRegistry),
- Effect.provideService(GitHubRoutingPermissions, trustedRouting),
+ Effect.provideService(PullRequestRoutingPermissions, trustedRouting),
Effect.provideService(RpcPermissionGuard, { authorize: () => Effect.void }),
Effect.provideService(EnvironmentSupervisor.EnvironmentSupervisor, supervisor),
);
@@ -956,7 +956,7 @@ it.live(
expect(invalidations).toContainEqual({ environment: "local", input: {} });
}).pipe(
Effect.provideService(EnvironmentRegistry.EnvironmentRegistry, environmentRegistry),
- Effect.provideService(GitHubRoutingPermissions, trustedRouting),
+ Effect.provideService(PullRequestRoutingPermissions, trustedRouting),
Effect.provideService(RpcPermissionGuard, { authorize: () => Effect.void }),
Effect.provideService(EnvironmentSupervisor.EnvironmentSupervisor, supervisor),
);
@@ -1504,7 +1504,7 @@ it.effect("denies a routed write when only the origin has source-control permiss
}).pipe(
Effect.provideService(EnvironmentRegistry.EnvironmentRegistry, fixture.environmentRegistry),
Effect.provideService(EnvironmentSupervisor.EnvironmentSupervisor, fixture.supervisor),
- Effect.provideService(GitHubRoutingPermissions, trustedRouting),
+ Effect.provideService(PullRequestRoutingPermissions, trustedRouting),
Effect.provideService(RpcPermissionGuard, {
authorize: (id, method, input) =>
createCommandPermissions(fixture.runtime, method).authorize(
diff --git a/packages/contracts/src/settings.ts b/packages/contracts/src/settings.ts
index 7923879541a..9f84636d12b 100644
--- a/packages/contracts/src/settings.ts
+++ b/packages/contracts/src/settings.ts
@@ -827,10 +827,6 @@ export const UsageLimitSourceConfig = Schema.Struct({
});
export type UsageLimitSourceConfig = typeof UsageLimitSourceConfig.Type;
-export const GitHubHost = TrimmedNonEmptyString.pipe(
- Schema.decodeTo(Schema.String, SchemaTransformation.toLowerCase()),
-);
-
export const SourceControlHostSettings = Schema.Record(Schema.String, Schema.Unknown);
export type SourceControlHostSettings = typeof SourceControlHostSettings.Type;
diff --git a/packages/source-control-azure-devops/src/client/definition.ts b/packages/source-control-azure-devops/src/client/definition.ts
index bc203ef1dcf..e209192a45a 100644
--- a/packages/source-control-azure-devops/src/client/definition.ts
+++ b/packages/source-control-azure-devops/src/client/definition.ts
@@ -6,6 +6,7 @@ import {
parseChangeRequestPath,
remoteWebOrigin,
} from "@t3tools/source-control-core/client/definition";
+import { icon } from "./icon.ts";
// Azure DevOps Server runs on any hostname; its `_git` route identifies it.
const CHANGE_REQUEST_PATH = /^\/((?:[^/]+\/)*_git\/[^/]+)\/pullrequest\/(\d+)(?:\/|$)/u;
@@ -66,7 +67,7 @@ export const definition = defineSourceControlClient({
kind: KIND,
label: "Azure DevOps",
pickerLabel: "Azure DevOps",
- icon: "azure-devops",
+ icon,
changeRequest: { shortLabel: "PR", singular: "pull request" },
repositoryPathHint: "project/repository",
// `az repos` reads need the checkout's organization and project, so a bare hostname names no
diff --git a/packages/source-control-azure-devops/src/client/icon.ts b/packages/source-control-azure-devops/src/client/icon.ts
new file mode 100644
index 00000000000..58cfef61e4d
--- /dev/null
+++ b/packages/source-control-azure-devops/src/client/icon.ts
@@ -0,0 +1,162 @@
+import type { SourceControlIcon } from "@t3tools/source-control-core/client/definition";
+
+// Microsoft Azure DevOps mark via selfhst/icons (CC BY 4.0): https://github.com/selfhst/icons/blob/main/svg/azure-devops.svg
+export const icon: SourceControlIcon = {
+ viewBox: "0 0 512 512",
+ gradients: [
+ {
+ id: "a",
+ x1: 58.027,
+ y1: 356.668,
+ x2: 58.027,
+ y2: 100.668,
+ transform: "matrix(1 0 0 -1 0 514)",
+ stops: [
+ { offset: 0, color: "#163697" },
+ { offset: 0.276, color: "#2052cb" },
+ { offset: 0.518, color: "#2764e7" },
+ { offset: 0.879, color: "#367af2" },
+ ],
+ },
+ {
+ id: "b",
+ x1: 58.027,
+ y1: 351.334,
+ x2: 58.027,
+ y2: 292.668,
+ transform: "matrix(1 0 0 -1 0 514)",
+ stops: [
+ { offset: 0, color: "#102784" },
+ { offset: 1, color: "#2052cb", opacity: 0 },
+ ],
+ },
+ {
+ id: "c",
+ x1: 389.98,
+ y1: 57.935,
+ x2: 107.314,
+ y2: 193.935,
+ transform: "matrix(1 0 0 -1 0 514)",
+ stops: [
+ { offset: 0, color: "#163697" },
+ { offset: 0.301, color: "#2052cb" },
+ { offset: 0.626, color: "#2764e7" },
+ { offset: 0.926, color: "#367af2" },
+ ],
+ },
+ {
+ id: "d",
+ x1: 391.996,
+ y1: 76.552,
+ x2: 341.385,
+ y2: 78.224,
+ transform: "matrix(1 0 0 -1 0 514)",
+ stops: [
+ { offset: 0, color: "#102784" },
+ { offset: 1, color: "#2052cb", opacity: 0 },
+ ],
+ },
+ {
+ id: "e",
+ x1: 442.24,
+ y1: 54.769,
+ x2: 442.24,
+ y2: 419.38,
+ transform: "matrix(1 0 0 -1 0 514)",
+ stops: [
+ { offset: 0.043, color: "#2052cb" },
+ { offset: 0.489, color: "#367af2" },
+ { offset: 0.943, color: "#16bbda" },
+ ],
+ },
+ {
+ id: "f",
+ x1: 435.596,
+ y1: 270.413,
+ x2: 425.732,
+ y2: 385.266,
+ transform: "matrix(1 0 0 -1 0 514)",
+ stops: [
+ { offset: 0.134, color: "#16bbda", opacity: 0 },
+ { offset: 0.932, color: "#6be7a0", opacity: 0.8629 },
+ ],
+ },
+ {
+ id: "g",
+ x1: 437.081,
+ y1: 204.362,
+ x2: 507.893,
+ y2: 119.081,
+ transform: "matrix(1 0 0 -1 0 514)",
+ stops: [
+ { offset: 0, color: "#2c68e0", opacity: 0 },
+ { offset: 0.898, color: "#66c0ff", opacity: 0.5 },
+ ],
+ },
+ {
+ id: "h",
+ x1: 99.399,
+ y1: 279.26,
+ x2: 352.75,
+ y2: 498.676,
+ transform: "matrix(1 0 0 -1 0 514)",
+ stops: [
+ { offset: 0.005, color: "#367af2" },
+ { offset: 0.507, color: "#0fafff" },
+ { offset: 1, color: "#26cfe8" },
+ ],
+ },
+ {
+ id: "i",
+ x1: 184.342,
+ y1: 356.795,
+ x2: 338.581,
+ y2: 480.642,
+ transform: "matrix(1 0 0 -1 0 514)",
+ stops: [
+ { offset: 0.443, color: "#26cfe8", opacity: 0 },
+ { offset: 0.897, color: "#6be7a0", opacity: 0.8629 },
+ ],
+ },
+ ],
+ paths: [
+ {
+ 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",
+ fill: { gradient: "a" },
+ },
+ {
+ 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",
+ fill: { gradient: "b" },
+ },
+ {
+ 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",
+ fill: { gradient: "c" },
+ },
+ {
+ 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",
+ fill: { gradient: "d" },
+ },
+ {
+ 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",
+ fill: { gradient: "e" },
+ },
+ {
+ 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",
+ fill: { gradient: "f" },
+ fillOpacity: 0.7,
+ },
+ {
+ 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",
+ fill: { gradient: "g" },
+ },
+ {
+ 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",
+ fill: { gradient: "h" },
+ },
+ {
+ 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",
+ fill: { gradient: "i" },
+ fillOpacity: 0.5,
+ },
+ ],
+};
diff --git a/packages/source-control-bitbucket/src/client/definition.ts b/packages/source-control-bitbucket/src/client/definition.ts
index 3ed6ddeaad8..b4540f4f3bd 100644
--- a/packages/source-control-bitbucket/src/client/definition.ts
+++ b/packages/source-control-bitbucket/src/client/definition.ts
@@ -13,6 +13,7 @@ import {
parseChangeRequestPath,
projectChangeRequestHost,
} from "@t3tools/source-control-core/client/definition";
+import { icon } from "./icon.ts";
const safeShellArgument = /^[A-Za-z0-9._/@+=,-]+$/;
const repositoryName = /^[A-Za-z0-9._-]+\/[A-Za-z0-9._-]+$/;
@@ -66,7 +67,7 @@ export const definition = defineSourceControlClient({
kind: KIND,
label: "Bitbucket",
pickerLabel: "Bitbucket",
- icon: "bitbucket",
+ icon,
changeRequest: { shortLabel: "PR", singular: "pull request" },
repositoryPathHint: "workspace/repository",
publicHost: "bitbucket.org",
diff --git a/packages/source-control-bitbucket/src/client/icon.ts b/packages/source-control-bitbucket/src/client/icon.ts
new file mode 100644
index 00000000000..56902ec6148
--- /dev/null
+++ b/packages/source-control-bitbucket/src/client/icon.ts
@@ -0,0 +1,29 @@
+import type { SourceControlIcon } from "@t3tools/source-control-core/client/definition";
+
+export const icon: SourceControlIcon = {
+ viewBox: "8.4 14.39 2481.29 2231.21",
+ gradients: [
+ {
+ id: "a",
+ x1: 945.1094,
+ y1: 1524.8389,
+ x2: 944.4923,
+ y2: 1524.1893,
+ transform: "matrix(1996.6343 0 0 -1480.3047 -1884485.625 2258195)",
+ stops: [
+ { offset: 0.18, color: "#0052CC" },
+ { offset: 1, color: "#2684FF" },
+ ],
+ },
+ ],
+ paths: [
+ {
+ 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",
+ fill: "#2684FF",
+ },
+ {
+ 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",
+ fill: { gradient: "a" },
+ },
+ ],
+};
diff --git a/packages/source-control-core/src/client/definition.ts b/packages/source-control-core/src/client/definition.ts
index 53101b59955..45dda11fedc 100644
--- a/packages/source-control-core/src/client/definition.ts
+++ b/packages/source-control-core/src/client/definition.ts
@@ -2,11 +2,16 @@ import {
type PullRequestAction,
type PullRequestReviewVerdict,
type RepositoryIdentity,
+ secretSetting,
SourceControlProviderKind,
type SourceControlProviderInfo,
+ TrimmedNonEmptyString,
+ TrimmedString,
} from "@t3tools/contracts";
import { normalizeGitRemoteUrl, parseGitRemoteRepository } from "@t3tools/shared/git";
+import * as Effect from "effect/Effect";
import * as Schema from "effect/Schema";
+import * as SchemaTransformation from "effect/SchemaTransformation";
/**
* The two strings are what `changeRequestHost` and the project's `repositoryIdentity` produce
@@ -94,11 +99,107 @@ export interface ReferenceAutolink {
readonly kind: "reference" | "commit" | "mention";
}
+/**
+ * A host's mark as data, so web and mobile draw the same artwork without React in the host's
+ * package. Paths only: a circle or rectangle is written as a path.
+ */
+export interface SourceControlIcon {
+ readonly viewBox: string;
+ /** Always in user space, as `gradientUnits="userSpaceOnUse"`. */
+ readonly gradients?: ReadonlyArray<SourceControlIconGradient>;
+ readonly paths: ReadonlyArray<SourceControlIconPath>;
+}
+
+export interface SourceControlIconGradient {
+ /** Unique within the icon; renderers make it unique on the page. */
+ readonly id: string;
+ readonly x1: number;
+ readonly y1: number;
+ readonly x2: number;
+ readonly y2: number;
+ readonly transform?: string;
+ readonly stops: ReadonlyArray<{
+ readonly offset: number;
+ readonly color: string;
+ readonly opacity?: number;
+ }>;
+}
+
+/** A colour, `currentColor` for a mark drawn in the text colour, or one of the icon's gradients. */
+export type SourceControlIconPaint = string | { readonly gradient: string };
+
+export interface SourceControlIconPath {
+ readonly d: string;
+ /** Absent means unfilled. */
+ readonly fill?: SourceControlIconPaint;
+ readonly fillRule?: "evenodd" | "nonzero";
+ readonly fillOpacity?: number;
+ readonly stroke?: string;
+ readonly strokeWidth?: number;
+}
+
+/** Whether the mark is drawn in the text colour alone, so a client may tint it. */
+export function isMonochromeSourceControlIcon(icon: SourceControlIcon): boolean {
+ return icon.paths.every(
+ (path) =>
+ (path.fill === undefined || path.fill === "currentColor") &&
+ (path.stroke === undefined || path.stroke === "currentColor"),
+ );
+}
+
+/**
+ * For a host whose server signs in per hostname, with a saved token or one of a CLI's logins.
+ * Its `settings` include `hostCredentialSettingsFields`, and clients show controls for those
+ * instead of the generic settings form.
+ */
+export interface SourceControlHostCredentials {
+ /** The command name, as `gh`. */
+ readonly cliName: string;
+ /** The CLI's product name, as `GitHub CLI`. */
+ readonly cliLabel: string;
+ readonly loginCommand: string;
+ /** The variable the server reads a token from, which a saved token takes precedence over. */
+ readonly tokenEnvVar: string;
+ /** What a token must be granted, completing "Give it …". */
+ readonly tokenAccess: string;
+ readonly newTokenUrl: (host: string) => string;
+}
+
+export const SourceControlHostName = TrimmedNonEmptyString.pipe(
+ Schema.decodeTo(Schema.String, SchemaTransformation.toLowerCase()),
+);
+
+export const HostAccountChoice = Schema.Struct({
+ account: Schema.optionalKey(TrimmedNonEmptyString),
+ enabled: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))),
+});
+export type HostAccountChoice = typeof HostAccountChoice.Type;
+
+/** Per-hostname settings of a host with `credentials`, keyed by lower-case hostname. */
+export const hostCredentialSettingsFields = {
+ hosts: Schema.Record(SourceControlHostName, HostAccountChoice).pipe(
+ Schema.withDecodingDefault(Effect.succeed({})),
+ Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
+ ),
+ tokens: Schema.Record(SourceControlHostName, TrimmedString).pipe(
+ Schema.withDecodingDefault(Effect.succeed({})),
+ secretSetting,
+ Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
+ ),
+};
+
+export const HostCredentialSettings = Schema.Struct(hostCredentialSettingsFields);
+export type HostCredentialSettings = typeof HostCredentialSettings.Type;
+
export interface SourceControlClientDefinition {
readonly kind: SourceControlProviderKind;
readonly label: string;
readonly pickerLabel: string;
- readonly icon: string;
+ /** Null for a host without a mark of its own; clients draw a generic change request glyph. */
+ readonly icon: SourceControlIcon | null;
+ /** Further words settings search finds this host by, besides its label. */
+ readonly searchKeywords?: ReadonlyArray<string>;
+ readonly credentials?: SourceControlHostCredentials;
readonly changeRequest: ChangeRequestTerminology;
readonly repositoryPathHint: string;
readonly publicHost: string | null;
@@ -363,7 +464,7 @@ export const UNKNOWN_SOURCE_CONTROL_CLIENT: SourceControlClientDefinition = {
kind: SourceControlProviderKind.make("unknown"),
label: "source control",
pickerLabel: "source control",
- icon: "change-request",
+ icon: null,
changeRequest: { shortLabel: "change request", singular: "change request" },
repositoryPathHint: "URL",
publicHost: null,
diff --git a/packages/source-control-forgejo/src/client/definition.ts b/packages/source-control-forgejo/src/client/definition.ts
index ea2759a61b7..949cc9d0443 100644
--- a/packages/source-control-forgejo/src/client/definition.ts
+++ b/packages/source-control-forgejo/src/client/definition.ts
@@ -11,6 +11,7 @@ import {
projectChangeRequestHost,
remoteWebOrigin,
} from "@t3tools/source-control-core/client/definition";
+import { icon } from "./icon.ts";
const CHECKOUT_COMMAND = /^tea\s+(?:pr|pulls)\s+checkout\s+(.+)$/i;
const CHANGE_REQUEST_REFERENCE =
@@ -54,7 +55,8 @@ export const definition = defineSourceControlClient({
kind: KIND,
label: "Forgejo",
pickerLabel: "Forgejo / Gitea",
- icon: "forgejo",
+ icon,
+ searchKeywords: ["gitea", "tea", "codeberg"],
changeRequest: { shortLabel: "PR", singular: "pull request" },
repositoryPathHint: "owner/repo",
// Codeberg is the public Forgejo; any other server is self-hosted.
diff --git a/packages/source-control-forgejo/src/client/icon.ts b/packages/source-control-forgejo/src/client/icon.ts
new file mode 100644
index 00000000000..61c5ee88ba7
--- /dev/null
+++ b/packages/source-control-forgejo/src/client/icon.ts
@@ -0,0 +1,13 @@
+import type { SourceControlIcon } from "@t3tools/source-control-core/client/definition";
+
+// The view box starts at -6 to move the mark 6 units in, as the published artwork's group does.
+export const icon: SourceControlIcon = {
+ viewBox: "-6 -6 212 212",
+ paths: [
+ { d: "M58 168 v-98 a50 50 0 0 1 50-50 h20", stroke: "#ff6600", strokeWidth: 25 },
+ { d: "M58 168 v-30 a50 50 0 0 1 50-50 h20", stroke: "#d40000", strokeWidth: 25 },
+ { d: "M124 20 a18 18 0 1 0 36 0 a18 18 0 1 0 -36 0z", stroke: "#ff6600", strokeWidth: 15 },
+ { d: "M124 88 a18 18 0 1 0 36 0 a18 18 0 1 0 -36 0z", stroke: "#d40000", strokeWidth: 15 },
+ { d: "M40 180 a18 18 0 1 0 36 0 a18 18 0 1 0 -36 0z", stroke: "#d40000", strokeWidth: 15 },
+ ],
+};
diff --git a/packages/source-control-gitcafe/src/client/definition.ts b/packages/source-control-gitcafe/src/client/definition.ts
index 22c96ce70c8..a2617c2db91 100644
--- a/packages/source-control-gitcafe/src/client/definition.ts
+++ b/packages/source-control-gitcafe/src/client/definition.ts
@@ -14,6 +14,7 @@ import {
parseChangeRequestPath,
projectChangeRequestHost,
} from "@t3tools/source-control-core/client/definition";
+import { icon } from "./icon.ts";
/** GitCafe has no self-hosted installs: production and staging are its only hosts. */
const GITCAFE_HOSTS = new Set(["git.cafe", "staging.git.cafe"]);
@@ -41,7 +42,7 @@ export const definition = defineSourceControlClient({
kind: KIND,
label: "GitCafe",
pickerLabel: "GitCafe",
- icon: "gitcafe",
+ icon,
changeRequest: { shortLabel: "PR", singular: "pull request" },
repositoryPathHint: "owner/repo",
publicHost: null,
diff --git a/packages/source-control-gitcafe/src/client/icon.ts b/packages/source-control-gitcafe/src/client/icon.ts
new file mode 100644
index 00000000000..97f38fbf41e
--- /dev/null
+++ b/packages/source-control-gitcafe/src/client/icon.ts
@@ -0,0 +1,6 @@
+import type { SourceControlIcon } from "@t3tools/source-control-core/client/definition";
+
+export const icon: SourceControlIcon = {
+ viewBox: "0 0 64 64",
+ paths: [{ d: "M4.8 4.8h54.4v54.4H4.8z", fill: "#a78bfa" }],
+};
diff --git a/packages/source-control-github/src/client/definition.ts b/packages/source-control-github/src/client/definition.ts
index 1a45ab704cd..e583b900be4 100644
--- a/packages/source-control-github/src/client/definition.ts
+++ b/packages/source-control-github/src/client/definition.ts
@@ -1,16 +1,8 @@
-import {
- GitHubHost,
- makeProviderSettingsSchema,
- secretSetting,
- SourceControlProviderKind,
- TrimmedNonEmptyString,
- TrimmedString,
-} from "@t3tools/contracts";
-import * as Effect from "effect/Effect";
-import * as Schema from "effect/Schema";
+import { makeProviderSettingsSchema, SourceControlProviderKind } from "@t3tools/contracts";
import {
changeRequestUrlBelow,
defineSourceControlClient,
+ hostCredentialSettingsFields,
isChangeRequestInProjectRepository,
isChangeRequestOnProjectHost,
parseChangeRequestPath,
@@ -19,6 +11,7 @@ import {
} from "@t3tools/source-control-core/client/definition";
import { gitHubMediaUrl } from "./gitHubMedia.ts";
+import { icon } from "./icon.ts";
import { gitHubReferenceAutolinks } from "./referenceAutolinks.ts";
const CHECKOUT_COMMAND = /^gh\s+pr\s+checkout\s+(.+)$/i;
@@ -49,30 +42,23 @@ function isRepositoryPath(repository: string): boolean {
);
}
-export const GitHubHostChoice = Schema.Struct({
- account: Schema.optionalKey(TrimmedNonEmptyString),
- enabled: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))),
-});
-export type GitHubHostChoice = typeof GitHubHostChoice.Type;
-
-export const settings = makeProviderSettingsSchema({
- hosts: Schema.Record(GitHubHost, GitHubHostChoice).pipe(
- Schema.withDecodingDefault(Effect.succeed({})),
- Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
- ),
- tokens: Schema.Record(GitHubHost, TrimmedString).pipe(
- Schema.withDecodingDefault(Effect.succeed({})),
- secretSetting,
- Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
- ),
-});
+export const settings = makeProviderSettingsSchema(hostCredentialSettingsFields);
export type GitHubSettings = typeof settings.Type;
export const definition = defineSourceControlClient({
kind: KIND,
label: "GitHub",
pickerLabel: "GitHub",
- icon: "github",
+ icon,
+ searchKeywords: ["ghes", "enterprise"],
+ credentials: {
+ cliName: "gh",
+ cliLabel: "GitHub CLI",
+ loginCommand: "gh auth login",
+ tokenEnvVar: "GH_TOKEN",
+ tokenAccess: "read and write access to pull requests and contents",
+ newTokenUrl: (host) => `https://${host}/settings/personal-access-tokens/new`,
+ },
changeRequest: { shortLabel: "PR", singular: "pull request" },
repositoryPathHint: "owner/repo",
publicHost: "github.com",
diff --git a/packages/source-control-github/src/client/icon.ts b/packages/source-control-github/src/client/icon.ts
new file mode 100644
index 00000000000..45ee6149f12
--- /dev/null
+++ b/packages/source-control-github/src/client/icon.ts
@@ -0,0 +1,12 @@
+import type { SourceControlIcon } from "@t3tools/source-control-core/client/definition";
+
+export const icon: SourceControlIcon = {
+ viewBox: "0 0 16 16",
+ paths: [
+ {
+ 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",
+ fill: "currentColor",
+ fillRule: "evenodd",
+ },
+ ],
+};
diff --git a/packages/source-control-gitlab/src/client/definition.ts b/packages/source-control-gitlab/src/client/definition.ts
index ce1262f42fb..c99b47559e9 100644
--- a/packages/source-control-gitlab/src/client/definition.ts
+++ b/packages/source-control-gitlab/src/client/definition.ts
@@ -7,6 +7,7 @@ import {
parseChangeRequestPath,
projectChangeRequestHost,
} from "@t3tools/source-control-core/client/definition";
+import { icon } from "./icon.ts";
const CHECKOUT_COMMAND = /^glab\s+mr\s+checkout\s+(.+)$/i;
const CHANGE_REQUEST_REFERENCE =
@@ -21,7 +22,7 @@ export const definition = defineSourceControlClient({
kind: KIND,
label: "GitLab",
pickerLabel: "GitLab",
- icon: "gitlab",
+ icon,
changeRequest: { shortLabel: "MR", singular: "merge request" },
repositoryPathHint: "group/project",
publicHost: "gitlab.com",
diff --git a/packages/source-control-gitlab/src/client/icon.ts b/packages/source-control-gitlab/src/client/icon.ts
new file mode 100644
index 00000000000..b825fac2198
--- /dev/null
+++ b/packages/source-control-gitlab/src/client/icon.ts
@@ -0,0 +1,23 @@
+import type { SourceControlIcon } from "@t3tools/source-control-core/client/definition";
+
+export const icon: SourceControlIcon = {
+ viewBox: "0 0 32 32",
+ paths: [
+ {
+ 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",
+ fill: "#E24329",
+ },
+ {
+ 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",
+ fill: "#FC6D26",
+ },
+ {
+ 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",
+ fill: "#FCA326",
+ },
+ {
+ 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",
+ fill: "#FC6D26",
+ },
+ ],
+};