Skip to content

Commit 3c34fcc

Browse files
chore: merge main into workflow Lineage
2 parents 9b984e3 + 61eb4af commit 3c34fcc

142 files changed

Lines changed: 3198 additions & 1527 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.

‎apps/mobile/src/components/SourceControlIcon.tsx‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
import Svg, { Circle, Defs, G, LinearGradient, Path, Stop } from "react-native-svg";
1+
import Svg, { Circle, Defs, G, LinearGradient, Path, Rect, Stop } from "react-native-svg";
22
import { withUniwind } from "uniwind";
33

44
const ThemedSvg = withUniwind(Svg);
55

6-
export type SourceControlIconKind = "github" | "gitlab" | "forgejo" | "bitbucket" | "azure-devops";
7-
6+
/** Draws a host's glyph by its client definition's `icon` key; null for a key it has no art for. */
87
export function SourceControlIcon(props: {
9-
readonly kind: SourceControlIconKind;
8+
readonly kind: string;
109
readonly size?: number;
1110
readonly color?: string;
1211
readonly colorClassName?: string;
@@ -252,5 +251,14 @@ export function SourceControlIcon(props: {
252251
/>
253252
</Svg>
254253
);
254+
case "gitcafe":
255+
// GitCafe's own mark from https://git.cafe/favicon.svg, inset like the web icon.
256+
return (
257+
<Svg width={size} height={size} viewBox="0 0 64 64">
258+
<Rect x={4.8} y={4.8} width={54.4} height={54.4} fill="#a78bfa" />
259+
</Svg>
260+
);
261+
default:
262+
return null;
255263
}
256264
}

‎apps/mobile/src/connection/environment-cache-store.test.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
ORCHESTRATION_CACHE_SCHEMA_VERSION,
3+
ORCHESTRATION_THREAD_CACHE_SCHEMA_VERSION,
34
StoredOrchestrationShellSnapshot,
45
} from "@t3tools/client-runtime/platform";
56
import {
@@ -251,7 +252,7 @@ describe("mobile SQLite environment cache store", () => {
251252
ORCHESTRATION_CACHE_SCHEMA_VERSION,
252253
);
253254
expect(memory.schemaVersions.get(cacheId(ENVIRONMENT_ID, "thread", THREAD_ID))).toBe(
254-
ORCHESTRATION_CACHE_SCHEMA_VERSION,
255+
ORCHESTRATION_THREAD_CACHE_SCHEMA_VERSION,
255256
);
256257
}),
257258
);

‎apps/mobile/src/connection/environment-cache-store.ts‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
ORCHESTRATION_CACHE_SCHEMA_VERSION,
3+
ORCHESTRATION_THREAD_CACHE_SCHEMA_VERSION,
34
StoredOrchestrationThreadSnapshot,
45
Persistence,
56
} from "@t3tools/client-runtime/platform";
@@ -148,13 +149,19 @@ export const make = Effect.fn("MobileEnvironmentCacheStore.make")(function* () {
148149
saveThread: Effect.fn("MobileEnvironmentCache.saveThread")(function* (environmentId, snapshot) {
149150
const threadId = snapshot.projection.thread.id;
150151
const payload = yield* encodeStoredThreadSnapshot({
151-
schemaVersion: ORCHESTRATION_CACHE_SCHEMA_VERSION,
152+
schemaVersion: ORCHESTRATION_THREAD_CACHE_SCHEMA_VERSION,
152153
environmentId,
153154
threadId,
154155
snapshot,
155156
}).pipe(Effect.mapError((cause) => persistenceError("save-thread", cause)));
156157
yield* database
157-
.saveCache(environmentId, "thread", threadId, ORCHESTRATION_CACHE_SCHEMA_VERSION, payload)
158+
.saveCache(
159+
environmentId,
160+
"thread",
161+
threadId,
162+
ORCHESTRATION_THREAD_CACHE_SCHEMA_VERSION,
163+
payload,
164+
)
158165
.pipe(Effect.mapError(mapDatabaseError("save-thread")));
159166
}),
160167
removeThread: Effect.fn("MobileEnvironmentCache.removeThread")((environmentId, threadId) =>

‎apps/mobile/src/features/projects/AddProjectRepositoryRoute.tsx‎

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import type { StaticScreenProps } from "@react-navigation/native";
22
import { NativeStackScreenOptions } from "../../native/StackHeader";
3-
import { addProjectRemoteSourceLabel } from "@t3tools/client-runtime/operations/projects";
3+
import {
4+
addProjectRemoteSourceLabel,
5+
parseAddProjectRemoteSource,
6+
} from "@t3tools/client-runtime/operations/projects";
47

58
import { AddProjectRepositoryScreen } from "./AddProjectScreen";
69

@@ -14,14 +17,7 @@ export function AddProjectRepositoryRoute({
1417
}: StaticScreenProps<AddProjectRepositoryRouteParams>) {
1518
const params = route.params ?? {};
1619
const source = Array.isArray(params.source) ? params.source[0] : params.source;
17-
const title =
18-
source === "github" ||
19-
source === "gitlab" ||
20-
source === "forgejo" ||
21-
source === "bitbucket" ||
22-
source === "azure-devops"
23-
? addProjectRemoteSourceLabel(source)
24-
: "Git URL";
20+
const title = addProjectRemoteSourceLabel(parseAddProjectRemoteSource(source));
2521

2622
return (
2723
<>

‎apps/mobile/src/features/projects/AddProjectScreen.tsx‎

Lines changed: 60 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ import {
1515
getCloneDestinationPath,
1616
getCloneDirectoryName,
1717
getDefaultCloneUrl,
18-
getNewProjectGitHubRepository,
19-
getNewProjectGitHubTarget,
2018
getNewProjectPathPreview,
19+
getNewProjectPublishTarget,
20+
getNewProjectPublishTargets,
21+
getNewProjectRepository,
2122
normalizePastedCloneUrl,
23+
parseAddProjectRemoteSource,
2224
resolveAddProjectPath,
2325
sortAddProjectProviderSources,
2426
type AddProjectRemoteSource,
@@ -48,6 +50,7 @@ import {
4850
type EnvironmentMachineKind,
4951
ProjectId,
5052
resolveEnvironmentMachineKind,
53+
SourceControlProviderKind,
5154
} from "@t3tools/contracts";
5255
import { CommonActions, StackActions, useNavigation } from "@react-navigation/native";
5356
import { SymbolView } from "../../components/AppSymbol";
@@ -70,6 +73,7 @@ import { AppText as Text, AppTextInput as TextInput } from "../../components/App
7073
import { EnvironmentMachineSymbol } from "../../components/EnvironmentMachineSymbol";
7174
import { ErrorBanner } from "../../components/ErrorBanner";
7275
import { SourceControlIcon } from "../../components/SourceControlIcon";
76+
import { sourceControlClients } from "@t3tools/client-runtime/source-control-clients";
7377
import { ThemedSwitch } from "../../components/ThemedSwitch";
7478
import { uuidv4 } from "../../lib/uuid";
7579
import { useAtomCommand } from "../../state/use-atom-command";
@@ -122,18 +126,7 @@ function stringParam(value: string | string[] | undefined): string | null {
122126
}
123127

124128
function sourceFromParam(value: string | string[] | undefined): AddProjectRemoteSource {
125-
const source = stringParam(value);
126-
if (
127-
source === "url" ||
128-
source === "github" ||
129-
source === "gitlab" ||
130-
source === "forgejo" ||
131-
source === "bitbucket" ||
132-
source === "azure-devops"
133-
) {
134-
return source;
135-
}
136-
return "url";
129+
return parseAddProjectRemoteSource(stringParam(value));
137130
}
138131

139132
function SectionTitle(props: { readonly children: string }) {
@@ -498,7 +491,7 @@ function SourceControlRow(props: {
498491
/>
499492
) : (
500493
<SourceControlIcon
501-
kind={props.source}
494+
kind={sourceControlClients.get(props.source).icon}
502495
size={Platform.OS === "android" ? 24 : 18}
503496
colorClassName="accent-icon"
504497
/>
@@ -658,13 +651,13 @@ export function AddProjectSourceScreen() {
658651
key={candidate}
659652
source={candidate}
660653
selectedEnvironmentId={selectedEnvironment.environmentId}
661-
ready={canCloneProject && readiness[candidate].ready}
654+
ready={canCloneProject && readiness(candidate).ready}
662655
hint={
663656
!canCloneProject
664657
? "This connection cannot clone projects."
665-
: readiness[candidate].ready
658+
: readiness(candidate).ready
666659
? addProjectRemoteSourcePathHint(candidate)
667-
: (readiness[candidate].hint ?? "")
660+
: (readiness(candidate).hint ?? "")
668661
}
669662
isFirst={false}
670663
/>
@@ -1003,9 +996,12 @@ export function AddProjectNewScreen(props: { readonly environmentId?: string | s
1003996
input: {},
1004997
}),
1005998
);
1006-
const githubTarget = getNewProjectGitHubTarget(discoveryState.data);
999+
const publishTargets = getNewProjectPublishTargets(discoveryState.data);
10071000
const [name, setName] = useState("");
1008-
const [publishesToGitHub, setPublishesToGitHub] = useState(false);
1001+
const [publishes, setPublishes] = useState(false);
1002+
// Null takes the first ready host, GitHub when it is ready.
1003+
const [publishKind, setPublishKind] = useState<SourceControlProviderKind | null>(null);
1004+
const publishTarget = getNewProjectPublishTarget(publishTargets, publishKind);
10091005
const [isSubmitting, setIsSubmitting] = useState(false);
10101006
const [error, setError] = useState<string | null>(null);
10111007
const trimmedName = name.trim();
@@ -1074,19 +1070,19 @@ export function AddProjectNewScreen(props: { readonly environmentId?: string | s
10741070
if (commitError !== undefined) {
10751071
Alert.alert("Created without a first commit", commitError);
10761072
}
1077-
if (publishesToGitHub && githubTarget !== null) {
1073+
if (publishes && publishTarget !== null) {
10781074
void publishRepository({
10791075
environmentId: environment.environmentId,
10801076
input: {
10811077
cwd: workspaceRoot,
1082-
provider: "github",
1083-
repository: getNewProjectGitHubRepository(githubTarget, workspaceRoot),
1078+
provider: publishTarget.definition.kind,
1079+
repository: getNewProjectRepository(publishTarget, workspaceRoot),
10841080
visibility: "private",
10851081
},
10861082
}).then((publishResult) => {
10871083
if (AsyncResult.isFailure(publishResult)) {
10881084
Alert.alert(
1089-
"Could not create the GitHub repository",
1085+
`Could not create the ${publishTarget.definition.label} repository`,
10901086
errorMessage(Cause.squash(publishResult.cause)),
10911087
);
10921088
}
@@ -1141,32 +1137,63 @@ export function AddProjectNewScreen(props: { readonly environmentId?: string | s
11411137
</Text>
11421138
) : null}
11431139
{machineRows}
1144-
{githubTarget !== null ? (
1140+
{publishTarget !== null ? (
11451141
<ListSection>
11461142
<ListRow
1147-
title="Create private repository on GitHub"
1143+
title={`Create private repository on ${publishTarget.definition.label}`}
11481144
subtitle={
11491145
trimmedName.length > 0 && pathPreview !== null
1150-
? getNewProjectGitHubRepository(githubTarget, pathPreview)
1151-
: githubTarget.account
1146+
? getNewProjectRepository(publishTarget, pathPreview)
1147+
: publishTarget.owner
11521148
}
11531149
icon={
11541150
<SourceControlIcon
1155-
kind="github"
1151+
kind={publishTarget.definition.icon}
11561152
size={Platform.OS === "android" ? 24 : 18}
11571153
colorClassName="accent-icon"
11581154
/>
11591155
}
11601156
isFirst
11611157
right={
11621158
<ThemedSwitch
1163-
accessibilityLabel="Create private repository on GitHub"
1164-
value={publishesToGitHub}
1165-
onValueChange={setPublishesToGitHub}
1159+
accessibilityLabel={`Create private repository on ${publishTarget.definition.label}`}
1160+
value={publishes}
1161+
onValueChange={setPublishes}
11661162
/>
11671163
}
1168-
onPress={() => setPublishesToGitHub((publishes) => !publishes)}
1164+
onPress={() => setPublishes((current) => !current)}
11691165
/>
1166+
{publishes && publishTargets.length > 1
1167+
? publishTargets.map((target) => {
1168+
const selected = target.definition.kind === publishTarget.definition.kind;
1169+
return (
1170+
<ListRow
1171+
key={target.definition.kind}
1172+
title={target.definition.label}
1173+
icon={
1174+
<SourceControlIcon
1175+
kind={target.definition.icon}
1176+
size={Platform.OS === "android" ? 24 : 17}
1177+
colorClassName="accent-icon"
1178+
/>
1179+
}
1180+
selected={selected}
1181+
disabled={isSubmitting}
1182+
right={
1183+
selected ? (
1184+
<SymbolView
1185+
name="checkmark"
1186+
size={Platform.OS === "android" ? 20 : 14}
1187+
tintColorClassName="accent-icon"
1188+
type="monochrome"
1189+
/>
1190+
) : null
1191+
}
1192+
onPress={() => setPublishKind(target.definition.kind)}
1193+
/>
1194+
);
1195+
})
1196+
: null}
11701197
</ListSection>
11711198
) : null}
11721199
<PrimaryActionButton

‎apps/mobile/src/state/thread-pr-presentation.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type {
44
ThreadPullRequestLink,
55
VcsStatusResult,
66
} from "@t3tools/contracts";
7-
import { resolveChangeRequestPresentation } from "@t3tools/shared/sourceControl";
7+
import { sourceControlClients } from "@t3tools/client-runtime/source-control-clients";
88

99
import {
1010
resolveThreadCurrentPullRequestLink,
@@ -39,7 +39,7 @@ export function presentThreadPr(
3939
pr: ThreadPr,
4040
provider: VcsStatusResult["sourceControlProvider"] | null | undefined,
4141
): ThreadPrPresentation {
42-
const presentation = resolveChangeRequestPresentation(provider);
42+
const { changeRequest } = sourceControlClients.get(provider?.kind);
4343
const isDraft = pr.state === "open" && pr.isDraft === true;
4444
return {
4545
kind: "pull-request",
@@ -50,7 +50,7 @@ export function presentThreadPr(
5050
updatedAt: pr.updatedAt ?? null,
5151
url: pr.url,
5252
label: String(pr.number),
53-
accessibilityLabel: `#${pr.number} ${presentation.longName} ${isDraft ? "draft" : pr.state}`,
53+
accessibilityLabel: `#${pr.number} ${changeRequest.singular} ${isDraft ? "draft" : pr.state}`,
5454
textClassName: isDraft ? "text-foreground-muted" : PR_STATE_TEXT_CLASS[pr.state],
5555
};
5656
}

‎apps/mobile/src/state/use-thread-pr.test.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { SourceControlProviderKind } from "@t3tools/contracts";
12
import { ProjectId, type ThreadPullRequestLink, type VcsStatusResult } from "@t3tools/contracts";
23
import { describe, expect, it } from "vite-plus/test";
34

@@ -28,7 +29,7 @@ describe("presentThreadPr", () => {
2829
it("uses merge-request terminology for GitLab", () => {
2930
expect(
3031
presentThreadPr(pullRequest, {
31-
kind: "gitlab",
32+
kind: SourceControlProviderKind.make("gitlab"),
3233
name: "GitLab",
3334
baseUrl: "https://gitlab.com",
3435
}),

‎apps/server/src/auth/EnvironmentAuth.ts‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import {
44
AuthAdministrativeScopes,
55
AuthOrchestrationOperateScope,
66
AuthOrchestrationReadScope,
7+
AuthSettingsWriteScope,
8+
AuthSourceControlWriteScope,
79
AuthStandardClientScopes,
810
type AuthAccessTokenResult,
911
type AuthBrowserSessionResult,
@@ -74,7 +76,10 @@ export interface IssuedBearerSession {
7476
* token cannot reach the full RPC surface around that cap.
7577
*
7678
* A read-only grant holds `orchestration:read` alone. Any other grant also
77-
* holds `orchestration:operate` and carries its runtime-mode ceiling.
79+
* holds `orchestration:operate` and carries its runtime-mode ceiling. A
80+
* full-access client may also change environment preferences and clone
81+
* repositories, so it holds the scopes those need over RPC. Approving a grant
82+
* requires every scope it holds.
7883
*/
7984
const MCP_CLIENT_SUBJECT = "mcp-client";
8085
const MCP_CLIENT_SESSION_TTL = Duration.days(30);
@@ -84,7 +89,14 @@ export const mcpClientScopes = (
8489
): ReadonlyArray<AuthEnvironmentScope> =>
8590
access === "read-only"
8691
? [AuthOrchestrationReadScope]
87-
: [AuthOrchestrationReadScope, AuthOrchestrationOperateScope];
92+
: access === "full-access"
93+
? [
94+
AuthOrchestrationReadScope,
95+
AuthOrchestrationOperateScope,
96+
AuthSettingsWriteScope,
97+
AuthSourceControlWriteScope,
98+
]
99+
: [AuthOrchestrationReadScope, AuthOrchestrationOperateScope];
88100

89101
export interface McpClientSession {
90102
readonly sessionId: AuthSessionId;

‎apps/server/src/auth/McpOAuth.test.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,15 @@ it.live(
451451
const readOnlyResponse = yield* approveWith(readOnly.credential);
452452
expect(readOnlyResponse.status).toBe(400);
453453
expect(readOnlyResponse.message).toContain("cannot grant this access");
454+
const operator = yield* auth.issuePairingCredential({
455+
scopes: ["orchestration:read", "orchestration:operate"],
456+
});
457+
const operatorFull = yield* decide(handler, params, {
458+
_tag: "pairing-code",
459+
access: "full-access",
460+
code: operator.credential,
461+
});
462+
expect(operatorFull.status).toBe(400);
454463

455464
// A read-only code can approve read-only access.
456465
const readOnlyCode = yield* auth.issuePairingCredential({ scopes: ["orchestration:read"] });

0 commit comments

Comments
 (0)