Skip to content

Commit 1212fd8

Browse files
refactor(clients): forge settings, routing and icons come from definitions
Clients still held forge knowledge outside the forge packages: the Source Control settings mounted GitHub-only token and account panels by kind, with the PAT URL, GH_TOKEN, gh and "GitHub CLI" hardcoded; settings search listed every forge's name by hand; the per-hostname settings schema lived in contracts as GitHubHost; the forge-neutral pull request routing trust was named GitHub in code, storage and UI; and web and mobile each drew every forge's mark from their own brand components or switch. Definitions now carry it: - `credentials` (cliName, cliLabel, loginCommand, tokenEnvVar, tokenAccess, newTokenUrl), implemented by GitHub. Settings with credentials use core's `hostCredentialSettingsFields` (hosts/tokens keyed by SourceControlHostName, replacing contracts' GitHubHost). Web renders SourceControlTokenSettings and SourceControlAccountSettings for any definition with credentials, through `readHostCredentialSettings(settings, kind)` and patches of `sourceControlHosts[kind]`. - `searchKeywords`; settings search builds each host's entry, the credentials entry and the shared host terms from the definitions. - `icon` is declarative artwork (viewBox, paths with fill/stroke/fill-rule, `currentColor`, user-space linear gradients), or null for the generic glyph. One renderer per client (React DOM svg, react-native-svg) replaces the brand components and the mobile switch. `vp run sync:link-icons` renders each definition's artwork to the mobile link-icon PNGs. GitHub routing is renamed pull request routing throughout. Storage migrates: web reads `t3code:github-routing:<id>` while `t3code:pull-request-routing:<id>` is absent and every write removes the old key; the mobile catalog document reads `githubRoutingPermissions` while `pullRequestRoutingPermissions` is absent and every write replaces it, as does removing a connection. Behaviour changes: routing copy says pull request routing/sharing and source control access; the settings search target for GitHub's accounts is now its host entry; mobile links to gitlab.com, codeberg.org, bitbucket.org and other hosts with artwork show their colour mark (untinted); mobile Bitbucket's gradient is now in user space, as on web; the integrations copy no longer names GitHub. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent f5f485e commit 1212fd8

61 files changed

Lines changed: 1115 additions & 930 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
4.05 KB
Loading
1.88 KB
Loading
1.39 KB
Loading
285 Bytes
Loading
-381 Bytes
Loading
1.68 KB
Loading

‎apps/mobile/package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"config:prod": "APP_VARIANT=production expo config",
4242
"profile:android:hermes": "mkdir -p profiles/review && react-native profile-hermes profiles/review",
4343
"sync:chip-icons": "node scripts/sync-context-chip-icons.mjs",
44+
"sync:link-icons": "node scripts/sync-link-icons.ts",
4445
"sync:pierre-icons": "node scripts/sync-pierre-file-icons.mjs",
4546
"measure-renders": "node scripts/measure-renders.mts",
4647
"generate": "node --disable-warning=MODULE_TYPELESS_PACKAGE_JSON scripts/generate-uniwind-themes.mts",
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
// The native markdown renderer draws a link's icon from a raster image, so each source control
2+
// host's mark is rendered from its definition's artwork into a bundled PNG.
3+
import * as NodeFS from "node:fs";
4+
import * as NodeModule from "node:module";
5+
import * as NodePath from "node:path";
6+
import * as NodeURL from "node:url";
7+
8+
import {
9+
sourceControlClients,
10+
type SourceControlIcon,
11+
} from "@t3tools/client-runtime/source-control-clients";
12+
13+
const appDirectory = NodePath.resolve(
14+
NodePath.dirname(NodeURL.fileURLToPath(import.meta.url)),
15+
"..",
16+
);
17+
const outputDirectory = NodePath.join(appDirectory, "assets/link-icons");
18+
const generatedModulePath = NodePath.join(appDirectory, "src/lib/markdownLinkIcons.generated.ts");
19+
const sharp = NodeModule.createRequire(
20+
NodePath.resolve(appDirectory, "../../scripts/package.json"),
21+
)("sharp");
22+
23+
const SIZE = 64;
24+
25+
function attribute(name: string, value: string | number | undefined): string {
26+
return value === undefined ? "" : ` ${name}="${value}"`;
27+
}
28+
29+
// A monochrome mark is tinted by the renderer, which only reads its alpha.
30+
function svgMarkup(icon: SourceControlIcon): string {
31+
const paint = (value: SourceControlIcon["paths"][number]["fill"]) =>
32+
value === undefined
33+
? "none"
34+
: typeof value === "string"
35+
? value.replace("currentColor", "#ffffff")
36+
: `url(#${value.gradient})`;
37+
const gradients = (icon.gradients ?? [])
38+
.map(
39+
(gradient) =>
40+
`<linearGradient id="${gradient.id}" x1="${gradient.x1}" y1="${gradient.y1}" x2="${gradient.x2}" y2="${gradient.y2}" gradientUnits="userSpaceOnUse"${attribute("gradientTransform", gradient.transform)}>${gradient.stops
41+
.map(
42+
(stop) =>
43+
`<stop offset="${stop.offset}" stop-color="${stop.color}"${attribute("stop-opacity", stop.opacity)}/>`,
44+
)
45+
.join("")}</linearGradient>`,
46+
)
47+
.join("");
48+
const paths = icon.paths
49+
.map(
50+
(path) =>
51+
`<path d="${path.d}" fill="${paint(path.fill)}"${attribute("fill-rule", path.fillRule)}${attribute("fill-opacity", path.fillOpacity)}${attribute("stroke", path.stroke === undefined ? undefined : paint(path.stroke))}${attribute("stroke-width", path.strokeWidth)}/>`,
52+
)
53+
.join("");
54+
return `<svg xmlns="http://www.w3.org/2000/svg" width="${SIZE}" height="${SIZE}" viewBox="${icon.viewBox}" fill="none"><defs>${gradients}</defs>${paths}</svg>`;
55+
}
56+
57+
NodeFS.rmSync(outputDirectory, { recursive: true, force: true });
58+
NodeFS.mkdirSync(outputDirectory, { recursive: true });
59+
60+
const kinds: string[] = [];
61+
for (const definition of sourceControlClients.definitions) {
62+
if (definition.icon === null) continue;
63+
await sharp(Buffer.from(svgMarkup(definition.icon)), { density: 72 * 4 })
64+
.resize(SIZE, SIZE, { fit: "contain", background: { r: 0, g: 0, b: 0, alpha: 0 } })
65+
.png()
66+
.toFile(NodePath.join(outputDirectory, `${definition.kind}.png`));
67+
kinds.push(definition.kind);
68+
}
69+
70+
NodeFS.writeFileSync(
71+
generatedModulePath,
72+
`import type { ImageSourcePropType } from "react-native";\n\nexport const SOURCE_CONTROL_LINK_ICON_SOURCES: Readonly<Record<string, ImageSourcePropType>> = {\n${kinds
73+
.toSorted()
74+
.map(
75+
(kind) =>
76+
` ${/^\w+$/u.test(kind) ? kind : `"${kind}"`}: require("../../assets/link-icons/${kind}.png"),`,
77+
)
78+
.join("\n")}\n};\n`,
79+
);

‎apps/mobile/src/connection/storage.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import {
1313
ConnectionTransientError,
1414
CredentialStore,
1515
ProfileStore,
16-
GitHubRoutingPermissions,
17-
makeGitHubRoutingPermissions,
16+
PullRequestRoutingPermissions,
17+
makePullRequestRoutingPermissions,
1818
} from "@t3tools/client-runtime/connection";
1919
import * as Context from "effect/Context";
2020
import * as Effect from "effect/Effect";
@@ -42,7 +42,7 @@ function targetPersistenceError(
4242
export const layer = Layer.effectContext(
4343
Effect.gen(function* () {
4444
const catalog = yield* CatalogStore.make();
45-
const githubRoutingPermissions = yield* makeGitHubRoutingPermissions({
45+
const githubRoutingPermissions = yield* makePullRequestRoutingPermissions({
4646
read: catalog.read.pipe(Effect.map((document) => document.githubRoutingPermissions ?? [])),
4747
write: (githubRoutingPermissions) =>
4848
catalog.update((document) => ({ ...document, githubRoutingPermissions })),
@@ -150,7 +150,7 @@ export const layer = Layer.effectContext(
150150
})),
151151
});
152152
return Context.make(Persistence.ConnectionTargetStore, targetStore).pipe(
153-
Context.add(GitHubRoutingPermissions, githubRoutingPermissions),
153+
Context.add(PullRequestRoutingPermissions, githubRoutingPermissions),
154154
Context.add(Persistence.ConnectionRegistrationStore, registrationStore),
155155
Context.add(ProfileStore.ConnectionProfileStore, profileStore),
156156
Context.add(CredentialStore.ConnectionCredentialStore, credentialStore),

‎apps/mobile/src/features/connection/ConnectionsRouteScreen.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { useSafeAreaInsets } from "react-native-safe-area-context";
1010
import { AndroidScreenHeader } from "../../components/ui/AndroidScreenHeader";
1111
import { useRemoteConnections } from "../../state/use-remote-environment-registry";
1212
import { LocalEnvironmentList } from "./LocalEnvironmentList";
13-
import { GitHubRoutingSettings } from "./GitHubRoutingSettings";
13+
import { PullRequestRoutingSettings } from "./PullRequestRoutingSettings";
1414

1515
export function ConnectionsRouteScreen() {
1616
const {
@@ -69,7 +69,7 @@ export function ConnectionsRouteScreen() {
6969
onSetEnabled={onSetEnvironmentEnabled}
7070
onUpdate={onUpdateEnvironment}
7171
/>
72-
<GitHubRoutingSettings />
72+
<PullRequestRoutingSettings />
7373
</ScrollView>
7474
</View>
7575
);

0 commit comments

Comments
 (0)