Skip to content

Commit ee69e93

Browse files
Merge branch 'main' into codex/relay-managed-tunnels-auth-infra
2 parents f438a94 + 300f7fd commit ee69e93

39 files changed

Lines changed: 873 additions & 98 deletions

‎.github/workflows/release.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,7 @@ jobs:
773773
run-install: |
774774
args:
775775
- --filter=@t3tools/scripts...
776+
- --filter=@t3tools/oxlint-plugin-t3code...
776777
777778
- id: update_versions
778779
name: Update version strings

‎apps/desktop/src/shell/DesktopShellEnvironment.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,6 @@ const readWindowsEnvironment = Effect.fn("desktop.shellEnvironment.readWindowsEn
241241
const output = yield* runCommandOutput({
242242
command,
243243
args,
244-
shell: true,
245244
timeout: LOGIN_SHELL_TIMEOUT,
246245
});
247246
const environment = extractEnvironment(output, names);

‎apps/mobile/src/features/threads/ThreadComposer.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import type {
1010
import {
1111
detectComposerTrigger,
1212
replaceTextRange,
13+
serializeComposerMentionPath,
1314
type ComposerTrigger,
1415
} from "@t3tools/shared/composerTrigger";
1516
import { TextInputWrapper } from "expo-paste-input";
@@ -418,7 +419,7 @@ export const ThreadComposer = memo(function ThreadComposer(props: ThreadComposer
418419

419420
let replacement = "";
420421
if (item.type === "path") {
421-
replacement = `@${item.path} `;
422+
replacement = `@${serializeComposerMentionPath(item.path)} `;
422423
} else if (item.type === "skill") {
423424
replacement = `$${item.skill.name} `;
424425
} else if (item.type === "slash-command") {

‎apps/server/scripts/cli.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,6 @@ const buildCmd = Command.make(
175175
cwd: serverDir,
176176
stdout: config.verbose ? "inherit" : "ignore",
177177
stderr: "inherit",
178-
// Windows needs shell mode to resolve `.cmd` shims on PATH.
179-
shell: process.platform === "win32",
180178
}),
181179
);
182180

‎apps/server/src/diagnostics/ProcessDiagnostics.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,6 @@ const runProcess = Effect.fn("runProcess")(
280280
const child = yield* spawner.spawn(
281281
ChildProcess.make(input.command, input.args, {
282282
cwd: process.cwd(),
283-
shell: process.platform === "win32",
284283
}),
285284
);
286285
const [stdout, stderr, exitCode] = yield* Effect.all(

‎apps/server/src/environment/Layers/ServerEnvironmentLabel.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ const runFriendlyLabelCommand = Effect.fn("runFriendlyLabelCommand")(function* (
5959
command,
6060
args,
6161
timeoutBehavior: "timedOutResult",
62-
shell: process.platform === "win32",
6362
})
6463
.pipe(Effect.option);
6564

‎apps/server/src/project/Layers/RepositoryIdentityResolver.test.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ const git = (cwd: string, args: ReadonlyArray<string>) =>
2323
return yield* processRunner.run({
2424
command: "git",
2525
args: ["-C", cwd, ...args],
26-
shell: process.platform === "win32",
2726
});
2827
}).pipe(Effect.provide(ProcessRunner.layer));
2928

‎apps/server/src/project/Layers/RepositoryIdentityResolver.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ const resolveRepositoryIdentityCacheKey = Effect.fn("resolveRepositoryIdentityCa
9494
command: "git",
9595
args: ["-C", cwd, "rev-parse", "--show-toplevel"],
9696
timeoutBehavior: "timedOutResult",
97-
shell: process.platform === "win32",
9897
})
9998
.pipe(Effect.option);
10099
if (topLevelResult._tag === "None" || topLevelResult.value.code !== 0) {
@@ -119,7 +118,6 @@ const resolveRepositoryIdentityFromCacheKey = Effect.fn("resolveRepositoryIdenti
119118
command: "git",
120119
args: ["-C", cacheKey, "remote", "-v"],
121120
timeoutBehavior: "timedOutResult",
122-
shell: process.platform === "win32",
123121
})
124122
.pipe(Effect.option);
125123
if (remoteResult._tag === "None" || remoteResult.value.code !== 0) {

‎apps/server/src/sourceControl/AzureDevOpsCli.test.ts‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ describe("AzureDevOpsCli.layer", () => {
6464

6565
assert.strictEqual(result.number, 42);
6666
assert.strictEqual(result.title, "Add Azure provider");
67+
assert.strictEqual(result.url, "https://dev.azure.com/acme/project/_git/repo/pullrequest/42");
6768
assert.strictEqual(result.baseRefName, "main");
6869
assert.strictEqual(result.headRefName, "feature/source-control");
6970
assert.strictEqual(result.state, "open");
@@ -89,6 +90,43 @@ describe("AzureDevOpsCli.layer", () => {
8990
}).pipe(Effect.provide(layer)),
9091
);
9192

93+
it.effect("builds a web URL when Azure returns only the pull request REST URL", () =>
94+
Effect.gen(function* () {
95+
mockRun.mockReturnValueOnce(
96+
Effect.succeed(
97+
processOutput(
98+
// @effect-diagnostics-next-line preferSchemaOverJson:off
99+
JSON.stringify({
100+
pullRequestId: 863,
101+
title: "Fix Azure link",
102+
url: "https://dev.azure.com/saplyai/a8fe4088-ad76-4eda-aaaa-e3329713a097/_apis/git/repositories/16108a25-93a3-4eff-b77d-85e894ee0fe4/pullRequests/863",
103+
repository: {
104+
name: "CV-engine",
105+
project: {
106+
name: "CV-engine",
107+
},
108+
},
109+
sourceRefName: "refs/heads/feature/azure-pr-link",
110+
targetRefName: "refs/heads/main",
111+
status: "active",
112+
}),
113+
),
114+
),
115+
);
116+
117+
const az = yield* AzureDevOpsCli.AzureDevOpsCli;
118+
const result = yield* az.getPullRequest({
119+
cwd: "/repo",
120+
reference: "863",
121+
});
122+
123+
assert.strictEqual(
124+
result.url,
125+
"https://dev.azure.com/saplyai/CV-engine/_git/CV-engine/pullrequest/863",
126+
);
127+
}).pipe(Effect.provide(layer)),
128+
);
129+
92130
it.effect("lists pull requests with Azure status and source branch arguments", () =>
93131
Effect.gen(function* () {
94132
mockRun.mockReturnValueOnce(

‎apps/server/src/sourceControl/GitHubSourceControlProvider.test.ts‎

Lines changed: 185 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,19 @@ import { ChildProcessSpawner } from "effect/unstable/process";
77

88
import * as VcsProcess from "../vcs/VcsProcess.ts";
99
import * as GitHubCli from "./GitHubCli.ts";
10+
import { parseGitHubAuthStatus } from "./gitHubAuthStatus.ts";
1011
import * as GitHubSourceControlProvider from "./GitHubSourceControlProvider.ts";
1112

12-
const processResult = (stdout: string): VcsProcess.VcsProcessOutput => ({
13-
exitCode: ChildProcessSpawner.ExitCode(0),
13+
const processResult = (
14+
stdout: string,
15+
options?: {
16+
readonly stderr?: string;
17+
readonly exitCode?: ChildProcessSpawner.ExitCode;
18+
},
19+
): VcsProcess.VcsProcessOutput => ({
20+
exitCode: options?.exitCode ?? ChildProcessSpawner.ExitCode(0),
1421
stdout,
15-
stderr: "",
22+
stderr: options?.stderr ?? "",
1623
stdoutTruncated: false,
1724
stderrTruncated: false,
1825
});
@@ -157,3 +164,178 @@ it.effect("creates GitHub PRs through provider-neutral input names", () =>
157164
});
158165
}),
159166
);
167+
168+
it("accepts active authenticated GitHub accounts when another account fails", () => {
169+
const auth = GitHubSourceControlProvider.discovery.parseAuth(
170+
processResult(
171+
JSON.stringify({
172+
hosts: {
173+
"github.com": [
174+
{
175+
state: "success",
176+
active: true,
177+
host: "github.com",
178+
login: "active-user",
179+
tokenSource: "keyring",
180+
gitProtocol: "ssh",
181+
},
182+
{
183+
state: "error",
184+
active: false,
185+
host: "github.com",
186+
login: "stale-user",
187+
tokenSource: "keyring",
188+
gitProtocol: "ssh",
189+
error: "The token in keyring is invalid.",
190+
},
191+
],
192+
},
193+
}),
194+
),
195+
);
196+
197+
assert.deepStrictEqual(
198+
{
199+
status: auth.status,
200+
account: auth.account,
201+
host: auth.host,
202+
},
203+
{
204+
status: "authenticated",
205+
account: Option.some("active-user"),
206+
host: Option.some("github.com"),
207+
},
208+
);
209+
});
210+
211+
it("parses GitHub auth JSON from stdout when stderr has warnings", () => {
212+
const auth = GitHubSourceControlProvider.discovery.parseAuth(
213+
processResult(
214+
JSON.stringify({
215+
hosts: {
216+
"github.com": [
217+
{
218+
state: "success",
219+
active: true,
220+
host: "github.com",
221+
login: "active-user",
222+
tokenSource: "keyring",
223+
gitProtocol: "ssh",
224+
},
225+
],
226+
},
227+
}),
228+
{ stderr: "warning: ignored diagnostic from gh\n" },
229+
),
230+
);
231+
232+
assert.deepStrictEqual(
233+
{
234+
status: auth.status,
235+
account: auth.account,
236+
host: auth.host,
237+
},
238+
{
239+
status: "authenticated",
240+
account: Option.some("active-user"),
241+
host: Option.some("github.com"),
242+
},
243+
);
244+
});
245+
246+
it("parses GitHub auth status accounts by host and active state", () => {
247+
assert.deepStrictEqual(
248+
parseGitHubAuthStatus(
249+
JSON.stringify({
250+
hosts: {
251+
"github.com": [
252+
{
253+
state: "success",
254+
active: true,
255+
host: "github.com",
256+
login: "active-user",
257+
tokenSource: "keyring",
258+
gitProtocol: "ssh",
259+
},
260+
{
261+
state: "error",
262+
active: false,
263+
host: "github.com",
264+
login: "stale-user",
265+
tokenSource: "keyring",
266+
gitProtocol: "ssh",
267+
},
268+
],
269+
"github.example.test": [
270+
{
271+
state: "success",
272+
active: false,
273+
host: "github.example.test",
274+
login: "enterprise-user",
275+
tokenSource: "keyring",
276+
gitProtocol: "ssh",
277+
},
278+
],
279+
},
280+
}),
281+
).accounts,
282+
[
283+
{
284+
host: "github.com",
285+
account: "active-user",
286+
authenticated: true,
287+
active: true,
288+
error: null,
289+
},
290+
{
291+
host: "github.com",
292+
account: "stale-user",
293+
authenticated: false,
294+
active: false,
295+
error: null,
296+
},
297+
{
298+
host: "github.example.test",
299+
account: "enterprise-user",
300+
authenticated: true,
301+
active: false,
302+
error: null,
303+
},
304+
],
305+
);
306+
});
307+
308+
it("reports unauthenticated when GitHub JSON has accounts but none are valid", () => {
309+
const auth = GitHubSourceControlProvider.discovery.parseAuth(
310+
processResult(
311+
JSON.stringify({
312+
hosts: {
313+
"github.com": [
314+
{
315+
state: "error",
316+
active: true,
317+
host: "github.com",
318+
login: "stale-user",
319+
tokenSource: "keyring",
320+
gitProtocol: "ssh",
321+
error: "The token in keyring is invalid.",
322+
},
323+
],
324+
},
325+
}),
326+
),
327+
);
328+
329+
assert.deepStrictEqual(
330+
{
331+
status: auth.status,
332+
host: auth.host,
333+
detail: auth.detail,
334+
},
335+
{
336+
status: "unauthenticated",
337+
host: Option.some("github.com"),
338+
detail: Option.some("The token in keyring is invalid."),
339+
},
340+
);
341+
});

0 commit comments

Comments
 (0)