Skip to content

Commit 9bf1e91

Browse files
chore: sync PR with current upstream main
2 parents b537c91 + 7445aa7 commit 9bf1e91

347 files changed

Lines changed: 7373 additions & 6218 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.

‎.github/VOUCHED.td‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ github:bil0000
1818
github:binbandit
1919
github:Brechard
2020
github:btsouth
21+
github:cestercian
2122
github:chrisdeeming
2223
github:chuks-qua
2324
github:cursoragent
@@ -80,3 +81,4 @@ github:vitalyiegorov
8081
github:Yash-Singh1
8182
github:yashranaway
8283
github:Ymit24
84+
github:yordis
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
const assert = require("node:assert/strict");
2+
const { spawnSync } = require("node:child_process");
3+
const { mkdtempSync, readFileSync, rmSync, existsSync } = require("node:fs");
4+
const { tmpdir } = require("node:os");
5+
const { join } = require("node:path");
6+
const { test } = require("node:test");
7+
8+
const workflow = readFileSync(join(__dirname, "../workflows/release.yml"), "utf8");
9+
const step = workflow.match(
10+
/- name: Read production relay tracing config\n[\s\S]*? run: \|\n((?: .*\n|\n)+)/,
11+
);
12+
assert.ok(step, "Could not find the relay state workflow step");
13+
const script = step[1].replace(/^ /gm, "");
14+
const config = {
15+
clientTracingUrl: "https://example.invalid/traces",
16+
clientTracingDataset: "fixture-dataset",
17+
clientTracingToken: { __redacted__: "fixture-token" },
18+
};
19+
const json = JSON.stringify(config, null, 2);
20+
21+
function runStep(stdout, exitCode = 0) {
22+
const runnerTemp = mkdtempSync(join(tmpdir(), "t3-relay-state-test-"));
23+
try {
24+
const result = spawnSync(
25+
"bash",
26+
["-c", 'npx() { printf "%s\\n" "$FIXTURE_STDOUT"; return "$FIXTURE_EXIT"; }\n' + script],
27+
{
28+
encoding: "utf8",
29+
env: {
30+
PATH: process.env.PATH,
31+
RUNNER_TEMP: runnerTemp,
32+
FIXTURE_STDOUT: stdout,
33+
FIXTURE_EXIT: String(exitCode),
34+
},
35+
},
36+
);
37+
assert.ifError(result.error);
38+
const envPath = join(runnerTemp, "relay-client-tracing.env");
39+
return {
40+
...result,
41+
envFile: existsSync(envPath) ? readFileSync(envPath, "utf8") : undefined,
42+
};
43+
} finally {
44+
rmSync(runnerTemp, { recursive: true, force: true });
45+
}
46+
}
47+
48+
for (const prefix of [
49+
"",
50+
"• Refreshing Cloudflare State Store credentials\n✓ Refreshing Cloudflare State Store credentials\n",
51+
]) {
52+
test(`extracts tracing config ${prefix ? "after progress output" : "from plain JSON"}`, () => {
53+
const result = runStep(prefix + json);
54+
assert.equal(result.status, 0, result.stderr);
55+
assert.equal(result.stdout, "::add-mask::fixture-token\n");
56+
assert.equal(
57+
result.envFile,
58+
"T3CODE_RELAY_CLIENT_OTLP_TRACES_URL=https://example.invalid/traces\n" +
59+
"T3CODE_RELAY_CLIENT_OTLP_TRACES_DATASET=fixture-dataset\n" +
60+
"T3CODE_RELAY_CLIENT_OTLP_TRACES_TOKEN=fixture-token\n",
61+
);
62+
});
63+
}
64+
65+
for (const [name, stdout, exitCode] of [
66+
["failed CLI even with valid JSON", json, 1],
67+
["missing JSON", "Refreshing credentials...", 0],
68+
["malformed JSON", "{not JSON", 0],
69+
["missing token", JSON.stringify({ ...config, clientTracingToken: null }, null, 2), 0],
70+
]) {
71+
test(`rejects ${name} without writing config`, () => {
72+
const result = runStep(stdout, exitCode);
73+
assert.notEqual(result.status, 0);
74+
assert.equal(result.envFile, undefined);
75+
});
76+
}

‎.github/workflows/mobile-fingerprint-check.yml‎

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,9 @@ name: Mobile Fingerprint Check
1313
# pnpm), so the comparison is self-consistent; no EXPO_TOKEN needed.
1414
on:
1515
pull_request:
16-
paths:
17-
- apps/mobile/**
18-
- packages/client-runtime/**
19-
- packages/contracts/**
20-
- packages/shared/**
21-
- assets/**
22-
- scripts/**
23-
- patches/**
24-
- pnpm-lock.yaml
25-
- pnpm-workspace.yaml
26-
- .github/workflows/mobile-fingerprint-check.yml
16+
# Run even when a rebase or base change removes every native input from the
17+
# diff, so the label can be cleared without installing Expo dependencies.
18+
types: [opened, synchronize, reopened, edited]
2719

2820
concurrency:
2921
group: mobile-fingerprint-check-${{ github.event.pull_request.number }}
@@ -44,12 +36,29 @@ jobs:
4436
- name: Checkout
4537
uses: actions/checkout@v6
4638
with:
47-
# Default pull_request checkout is the merge commit (PR applied on
48-
# top of base), so the "head" fingerprint is the state main would
49-
# actually be in after merging — stale branches compare cleanly.
50-
fetch-depth: 0
39+
# The merge ref can advance after the event is queued. Pin its commit
40+
# and compare against its first parent, rather than the event's base.
41+
ref: ${{ github.sha }}
42+
fetch-depth: 2
43+
44+
- id: changes
45+
name: Detect native fingerprint inputs
46+
run: |
47+
base_sha=$(git rev-parse HEAD^1)
48+
echo "base_sha=$base_sha" >> "$GITHUB_OUTPUT"
49+
paths=$(git diff --no-renames --name-only "$base_sha" HEAD -- \
50+
apps/mobile/ packages/client-runtime/ packages/contracts/ packages/shared/ \
51+
assets/ scripts/ patches/ package.json pnpm-lock.yaml pnpm-workspace.yaml \
52+
.github/workflows/mobile-fingerprint-check.yml)
53+
if [[ -n "$paths" ]]; then
54+
echo "relevant=true" >> "$GITHUB_OUTPUT"
55+
else
56+
echo "relevant=false" >> "$GITHUB_OUTPUT"
57+
echo "No native fingerprint inputs changed; clearing any stale native change label." >> "$GITHUB_STEP_SUMMARY"
58+
fi
5159
5260
- name: Setup Vite+
61+
if: steps.changes.outputs.relevant == 'true'
5362
uses: voidzero-dev/setup-vp@v1
5463
with:
5564
node-version-file: package.json
@@ -59,13 +68,15 @@ jobs:
5968
- --filter=@t3tools/mobile...
6069
6170
- name: Expose pnpm
71+
if: steps.changes.outputs.relevant == 'true'
6272
run: |
6373
pnpm_version="$(node --print "require('./package.json').packageManager.split('@').pop()")"
6474
vp_pnpm_bin="$HOME/.vite-plus/package_manager/pnpm/$pnpm_version/pnpm/bin"
6575
echo "$vp_pnpm_bin" >> "$GITHUB_PATH"
6676
"$vp_pnpm_bin/pnpm" --version
6777
6878
- name: Fingerprint merge result
79+
if: steps.changes.outputs.relevant == 'true'
6980
working-directory: apps/mobile
7081
run: |
7182
mkdir -p "$RUNNER_TEMP/fp/head" "$RUNNER_TEMP/fp/base"
@@ -74,8 +85,11 @@ jobs:
7485
done
7586
7687
- name: Fingerprint base
88+
if: steps.changes.outputs.relevant == 'true'
89+
env:
90+
BASE_SHA: ${{ steps.changes.outputs.base_sha }}
7791
run: |
78-
git checkout --quiet "${{ github.event.pull_request.base.sha }}"
92+
git checkout --quiet "$BASE_SHA"
7993
# Re-sync node_modules to the base commit's lockfile before
8094
# fingerprinting — a dep-changing PR must not fingerprint the base
8195
# against head's installed packages.
@@ -87,6 +101,7 @@ jobs:
87101
88102
- id: compare
89103
name: Compare fingerprints
104+
if: steps.changes.outputs.relevant == 'true'
90105
run: |
91106
changed=""
92107
{

‎.github/workflows/release.yml‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,14 +312,17 @@ jobs:
312312
- --filter=t3code-relay...
313313
314314
# The deployed stack's outputs, read from Alchemy's state store without
315-
# planning or applying. Redacted values are persisted as
315+
# planning or applying. Select the backend explicitly to avoid loading
316+
# the stack's unrelated provider credentials; suppress informational logs
317+
# and strip the credential-refresh progress prefix before parsing JSON.
318+
# Redacted values are persisted as
316319
# {"__redacted__": "<value>"}; the token is masked before it is written.
317320
- name: Read production relay tracing config
318321
shell: bash
319322
working-directory: infra/relay
320323
run: |
321324
set -euo pipefail
322-
output="$(npx alchemy state read T3CodeRelay/prod/output --no-input)"
325+
output="$(npx alchemy state read T3CodeRelay/prod/output --backend cloudflare --log-level error --no-input | sed -n '/^{/,$p')"
323326
field() {
324327
jq -er --arg key "$1" '.[$key] | if type == "object" then .__redacted__ else . end | select(. != null and . != "")' <<<"$output" \
325328
|| { echo "Relay stack output is missing $1" >&2; exit 1; }

‎apps/desktop/src/app/DesktopAppIdentity.test.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ const makeElectronAppLayer = (calls: ElectronAppCalls) =>
5757
}),
5858
setAppUserModelId: () => Effect.void,
5959
getAppMetrics: Effect.succeed([]),
60-
isDefaultProtocolClient: () => Effect.succeed(false),
6160
setAsDefaultProtocolClient: () => Effect.succeed(true),
6261
setDesktopName: () => Effect.void,
6362
setDockIcon: (iconPath) =>

‎apps/desktop/src/app/DesktopConfig.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ export const DesktopConfig = Config.all({
4646
desktopLanHostOverride: trimmedString("T3CODE_DESKTOP_LAN_HOST"),
4747
desktopHttpsEndpointUrls: commaSeparatedStrings("T3CODE_DESKTOP_HTTPS_ENDPOINTS"),
4848
otlpTracesUrl: trimmedString("T3CODE_OTLP_TRACES_URL"),
49+
otlpMetricsUrl: trimmedString("T3CODE_OTLP_METRICS_URL"),
50+
otlpLogsUrl: trimmedString("T3CODE_OTLP_LOGS_URL"),
4951
otlpExportIntervalMs: Config.Int("T3CODE_OTLP_EXPORT_INTERVAL_MS").pipe(
5052
Config.withDefault(10_000),
5153
),

‎apps/desktop/src/app/DesktopConnectionCatalogStore.test.ts‎

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { assert, describe, it } from "@effect/vitest";
33
import { ConnectionCatalogDocument } from "@t3tools/client-runtime/platform";
44
import { EnvironmentId, type PersistedSavedEnvironmentRecord } from "@t3tools/contracts";
55
import * as Effect from "effect/Effect";
6+
import * as Encoding from "effect/Encoding";
67
import * as FileSystem from "effect/FileSystem";
78
import * as Path from "effect/Path";
89
import * as Layer from "effect/Layer";
@@ -22,6 +23,11 @@ const textEncoder = new TextEncoder();
2223
const decodeConnectionCatalog = Schema.decodeEffect(
2324
Schema.fromJsonString(ConnectionCatalogDocument),
2425
);
26+
const encodeLegacySavedEnvironments = Schema.encodeEffect(
27+
Schema.fromJsonString(
28+
Schema.Struct({ version: Schema.Literal(1), records: Schema.Array(Schema.Unknown) }),
29+
),
30+
);
2531
function makeSafeStorageLayer(available: boolean, failDecrypt: Ref.Ref<boolean> | null = null) {
2632
return Layer.succeed(ElectronSafeStorage.ElectronSafeStorage, {
2733
isEncryptionAvailable: Effect.succeed(available),
@@ -125,7 +131,8 @@ describe("DesktopConnectionCatalogStore", () => {
125131
withStore(
126132
Effect.gen(function* () {
127133
const store = yield* DesktopConnectionCatalogStore.DesktopConnectionCatalogStore;
128-
const savedEnvironments = yield* DesktopSavedEnvironments.DesktopSavedEnvironments;
134+
const environment = yield* DesktopEnvironment.DesktopEnvironment;
135+
const fileSystem = yield* FileSystem.FileSystem;
129136
const records: readonly PersistedSavedEnvironmentRecord[] = [
130137
{
131138
environmentId: EnvironmentId.make("relay-environment"),
@@ -159,11 +166,21 @@ describe("DesktopConnectionCatalogStore", () => {
159166
lastConnectedAt: null,
160167
},
161168
];
162-
yield* savedEnvironments.setRegistry(records);
163-
assert.isTrue(
164-
yield* savedEnvironments.setSecret({
165-
environmentId: EnvironmentId.make("bearer-environment"),
166-
secret: "legacy-token",
169+
yield* fileSystem.makeDirectory(environment.stateDir, { recursive: true });
170+
yield* fileSystem.writeFileString(
171+
environment.savedEnvironmentRegistryPath,
172+
yield* encodeLegacySavedEnvironments({
173+
version: 1,
174+
records: records.map((record) =>
175+
record.environmentId === "bearer-environment"
176+
? {
177+
...record,
178+
encryptedBearerToken: Encoding.encodeBase64(
179+
textEncoder.encode("encrypted:legacy-token"),
180+
),
181+
}
182+
: record,
183+
),
167184
}),
168185
);
169186

@@ -218,7 +235,10 @@ describe("DesktopConnectionCatalogStore", () => {
218235
assert.equal(catalog.credentials[0].credential.token, "legacy-token");
219236
}
220237

221-
yield* savedEnvironments.setRegistry([]);
238+
yield* fileSystem.writeFileString(
239+
environment.savedEnvironmentRegistryPath,
240+
'{"version":1,"records":[]}',
241+
);
222242
assert.deepEqual(yield* store.get, migrated);
223243
}),
224244
),

‎apps/desktop/src/app/DesktopEnvironment.test.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ describe("DesktopEnvironment", () => {
5151
VITE_DEV_SERVER_URL: "http://localhost:5173",
5252
T3CODE_DEV_REMOTE_T3_SERVER_ENTRY_PATH: " /remote/server.mjs ",
5353
T3CODE_OTLP_TRACES_URL: " http://127.0.0.1:4318/v1/traces ",
54+
T3CODE_OTLP_METRICS_URL: " http://127.0.0.1:4318/v1/metrics ",
55+
T3CODE_OTLP_LOGS_URL: " http://127.0.0.1:4318/v1/logs ",
5456
T3CODE_OTLP_EXPORT_INTERVAL_MS: "2500",
5557
T3CODE_OTLP_HEADERS: "authorization=Basic%20abc%3D%3D,x-tenant=t3",
5658
T3CODE_OTLP_PROTOCOL: "http/protobuf",
@@ -86,6 +88,8 @@ describe("DesktopEnvironment", () => {
8688
assert.deepEqual(environment.configuredBackendPort, Option.some(4949));
8789
assert.deepEqual(environment.commitHashOverride, Option.some("0123456789abcdef"));
8890
assert.deepEqual(environment.otlpTracesUrl, Option.some("http://127.0.0.1:4318/v1/traces"));
91+
assert.deepEqual(environment.otlpMetricsUrl, Option.some("http://127.0.0.1:4318/v1/metrics"));
92+
assert.deepEqual(environment.otlpLogsUrl, Option.some("http://127.0.0.1:4318/v1/logs"));
8993
assert.equal(environment.otlpExportIntervalMs, 2500);
9094
assert.deepEqual(
9195
environment.otlpHeaders,

‎apps/desktop/src/app/DesktopEnvironment.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ export class DesktopEnvironment extends Context.Service<
7272
readonly configuredBackendPort: Option.Option<number>;
7373
readonly commitHashOverride: Option.Option<string>;
7474
readonly otlpTracesUrl: Option.Option<string>;
75+
readonly otlpMetricsUrl: Option.Option<string>;
76+
readonly otlpLogsUrl: Option.Option<string>;
7577
readonly otlpExportIntervalMs: number;
7678
readonly otlpHeaders: Option.Option<Record<string, string>>;
7779
readonly otlpProtocol: OtlpProtocol;
@@ -227,6 +229,8 @@ const make = Effect.fn("desktop.environment.make")(function* (
227229
configuredBackendPort: config.configuredBackendPort,
228230
commitHashOverride: config.commitHashOverride,
229231
otlpTracesUrl: config.otlpTracesUrl,
232+
otlpMetricsUrl: config.otlpMetricsUrl,
233+
otlpLogsUrl: config.otlpLogsUrl,
230234
otlpExportIntervalMs: config.otlpExportIntervalMs,
231235
otlpHeaders: config.otlpHeaders,
232236
otlpProtocol: config.otlpProtocol,

‎apps/desktop/src/app/DesktopLifecycle.test.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ function makeElectronAppLayer(
4343
setAboutPanelOptions: () => Effect.void,
4444
setAppUserModelId: () => Effect.void,
4545
getAppMetrics: Effect.succeed([]),
46-
isDefaultProtocolClient: () => Effect.succeed(false),
4746
setAsDefaultProtocolClient: () => Effect.succeed(true),
4847
setDesktopName: () => Effect.void,
4948
setDockIcon: () => Effect.void,

0 commit comments

Comments
 (0)