Skip to content

Commit 0870f7b

Browse files
t3dotggclaude
andcommitted
ci: startup and sidebar changes open the seeded thread before merge
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent b24959d commit 0870f7b

6 files changed

Lines changed: 78 additions & 5 deletions

File tree

‎.github/actions/ci-changes/action.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ outputs:
55
value: ${{ steps.detect.outputs.typecheck }}
66
build:
77
value: ${{ steps.detect.outputs.build }}
8+
desktop_launch:
9+
value: ${{ steps.detect.outputs.desktop_launch }}
810
test:
911
value: ${{ steps.detect.outputs.test }}
1012
test_packages:

‎.github/scripts/ci-changes.cjs‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,20 @@ const BUILD_ONLY_DEPS = { t3: ["@t3tools/web"] };
5151
const MOBILE_NATIVE =
5252
/^apps\/mobile\/.*\.(swift|kt|kts)$|^apps\/mobile\/(\.swiftlint\.yml|detekt\.yml|\.editorconfig|Brewfile)$|^scripts\/mobile-native-static-check\.ts$|^package\.json$|^\.github\/workflows\/ci\.yml$|^\.github\/scripts\/ci-changes\.cjs$|^\.github\/actions\/ci-changes\//;
5353

54+
// Startup, migration, settlement, and sidebar paths that decide whether an upgraded user's
55+
// threads show after launch. Build runs scripts/smoke-desktop-app.ts for them, so they do not
56+
// first fail in the release launch check.
57+
const DESKTOP_LAUNCH = [
58+
/^apps\/desktop\/src\/((main|boot|compileCache|serverCompileCache)\.ts$|(app|backend|window)\/)/,
59+
/^apps\/web\/src\/((main|AppRoot|appInit)\.tsx|(bootstrap|router)\.ts)$/,
60+
/^apps\/web\/src\/.*sidebar/i,
61+
/^apps\/server\/src\/(bin|binMain|server|serverRuntimeStartup)\.ts$/,
62+
/^apps\/server\/src\/persistence\/Migrations/,
63+
/^apps\/server\/src\/orchestration-v2\/((ThreadSettlementService|ProjectionStore)\.ts$|legacy\/)/,
64+
/^packages\/contracts\/src\/settings\.ts$/,
65+
/^scripts\/(smoke-desktop-app\.ts|fixtures\/desktop-launch\/)/,
66+
];
67+
5468
const OWN_TEST_JOB = new Set(["t3", "@t3tools/web", "@t3tools/monorepo"]);
5569

5670
function readWorkspace() {
@@ -151,12 +165,18 @@ function decide(files, packages, full) {
151165
(pkg) => pkg.hasTest && !OWN_TEST_JOB.has(pkg.name) && affected.has(pkg.name),
152166
);
153167
const has = (name) => affected.has(name);
168+
const desktopLaunch =
169+
everything ||
170+
files.some(
171+
(file) => !/\.test\.tsx?$/.test(file) && DESKTOP_LAUNCH.some((pattern) => pattern.test(file)),
172+
);
154173

155174
return {
156175
affected: [...affected].sort(),
157176
outputs: {
158177
typecheck: affected.size > 0,
159-
build: has("@t3tools/desktop") || has("t3") || has("@t3tools/web"),
178+
build: has("@t3tools/desktop") || has("t3") || has("@t3tools/web") || desktopLaunch,
179+
desktop_launch: desktopLaunch,
160180
test: tested.length > 0,
161181
// Empty means every package the Test job covers.
162182
test_packages: everything ? "" : tested.map((pkg) => pkg.name).join(" "),

‎.github/scripts/ci-changes.d.cts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export function decide(
1616
outputs: {
1717
typecheck: boolean;
1818
build: boolean;
19+
desktop_launch: boolean;
1920
test: boolean;
2021
test_packages: string;
2122
test_web: boolean;

‎.github/workflows/ci.yml‎

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ jobs:
2727
outputs:
2828
typecheck: ${{ steps.detect.outputs.typecheck }}
2929
build: ${{ steps.detect.outputs.build }}
30+
desktop_launch: ${{ steps.detect.outputs.desktop_launch }}
3031
test: ${{ steps.detect.outputs.test }}
3132
test_packages: ${{ steps.detect.outputs.test_packages }}
3233
test_web: ${{ steps.detect.outputs.test_web }}
@@ -135,13 +136,14 @@ jobs:
135136
if: needs.changes.outputs.build != 'false'
136137

137138
# Runs in the background while Vite+ installs; the step before the build waits for it.
139+
# Xvfb is for the desktop launch check below.
138140
- name: Start installing browser secret helper build libraries
139141
if: needs.changes.outputs.build != 'false'
140142
run: |
141143
sudo sed -i 's|http://|https://|g' /etc/apt/blacksmith-ubuntu-mirrors.txt /etc/apt/sources.list.d/ubuntu.sources
142144
(
143145
set +e
144-
sudo apt-get update && sudo apt-get install -y libsecret-1-dev pkg-config
146+
sudo apt-get update && sudo apt-get install -y libsecret-1-dev pkg-config xvfb
145147
echo "$?" > "$RUNNER_TEMP/apt-status"
146148
) > "$RUNNER_TEMP/apt.log" 2>&1 < /dev/null &
147149
@@ -192,6 +194,25 @@ jobs:
192194
if: ${{ !cancelled() && steps.build.outcome == 'success' }}
193195
run: node apps/desktop/scripts/verify-preload-bundle.mjs
194196

197+
# The release launch check, run unpackaged against the same old-state fixture, for
198+
# startup and sidebar changes. Packaging and signing stay release-only.
199+
- name: Open the seeded thread in the built desktop app
200+
id: desktop_launch
201+
if: ${{ !cancelled() && steps.build.outcome == 'success' && needs.changes.outputs.desktop_launch != 'false' }}
202+
timeout-minutes: 4
203+
run: |
204+
electron=$(node -p "require('./apps/desktop/node_modules/electron')")
205+
xvfb-run -a node scripts/smoke-desktop-app.ts --executable "$electron" --app apps/desktop \
206+
--artifacts-dir "$RUNNER_TEMP/desktop-launch-check"
207+
208+
- name: Upload desktop launch check
209+
if: ${{ failure() && steps.desktop_launch.outcome == 'failure' }}
210+
uses: actions/upload-artifact@v7
211+
with:
212+
name: desktop-launch-check
213+
path: ${{ runner.temp }}/desktop-launch-check
214+
if-no-files-found: ignore
215+
195216
# Browser tests run source modules; this boots the production chunk graph. The
196217
# desktop build above already produced apps/web/dist, and the client waits about
197218
# 15s for a session that never comes, so this runs here instead of in Test Web,
@@ -622,7 +643,7 @@ jobs:
622643
# not needed. Gates are keyed by job name, except merged Build and the
623644
# macOS lint.
624645
echo "$RESULTS" | jq -e '.changes.outputs as $gates
625-
| {build: ["build", "typecheck"], mobile_native_static_analysis: ["mobile_native"]} as $renamed
646+
| {build: ["build", "typecheck", "desktop_launch"], mobile_native_static_analysis: ["mobile_native"]} as $renamed
626647
| all(to_entries[];
627648
.value.result == "success"
628649
or (.value.result == "skipped"

‎scripts/check-changed.test.ts‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,31 @@ describe("check:changed", () => {
198198
});
199199
});
200200

201+
it("opens the built desktop app only for startup, settlement, and sidebar changes", () => {
202+
const packages = readWorkspace();
203+
const launches = (file: string) => decide([file], packages, false).outputs.desktop_launch;
204+
for (const file of [
205+
"apps/server/src/orchestration-v2/ThreadSettlementService.ts",
206+
"apps/server/src/persistence/Migrations/054_ProjectionThreadsAutoSettleDisabledAt.ts",
207+
"apps/web/src/components/sidebar/SidebarThreadRow.tsx",
208+
"apps/desktop/src/backend/DesktopBackendManager.ts",
209+
"packages/contracts/src/settings.ts",
210+
"scripts/fixtures/desktop-launch/statev2.sqlite",
211+
]) {
212+
assert.isTrue(launches(file), file);
213+
}
214+
for (const file of [
215+
"apps/server/src/orchestration-v2/ThreadSettlementService.test.ts",
216+
"apps/web/src/components/chat/ChatView.tsx",
217+
"apps/desktop/src/updates/DesktopRemoteUpdates.ts",
218+
"packages/contracts/src/orchestration.ts",
219+
]) {
220+
assert.isFalse(launches(file), file);
221+
}
222+
// A script-only change still builds the app it opens.
223+
assert.isTrue(decide(["scripts/smoke-desktop-app.ts"], packages, false).outputs.build);
224+
});
225+
201226
it.each([
202227
"packages/shared/src/testing/longTempDir.ts",
203228
"packages/shared/src/testing/providerEnv.ts",

‎scripts/smoke-desktop-app.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,16 @@ const STEP_TIMEOUT_MS = 60_000;
1919
const { values } = NodeUtil.parseArgs({
2020
options: {
2121
executable: { type: "string" },
22+
// An unpackaged app directory for a plain Electron executable, as PR CI runs it.
23+
app: { type: "string" },
2224
"artifacts-dir": { type: "string" },
2325
},
2426
});
2527
const executable = values.executable;
2628
if (!executable)
27-
throw new Error("Usage: smoke-desktop-app.ts --executable <app> [--artifacts-dir <dir>]");
29+
throw new Error(
30+
"Usage: smoke-desktop-app.ts --executable <app> [--app <dir>] [--artifacts-dir <dir>]",
31+
);
2832
const artifactsDir = NodePath.resolve(values["artifacts-dir"] ?? "desktop-launch-check");
2933

3034
const home = NodeFS.mkdtempSync(NodePath.join(NodeOS.tmpdir(), "t3-desktop-launch-"));
@@ -38,7 +42,7 @@ try {
3842
app = await _electron.launch({
3943
executablePath: executable,
4044
// Linux CI runners do not allow the Chromium sandbox's user namespaces.
41-
args: ["--no-sandbox"],
45+
args: [...(values.app ? [NodePath.resolve(values.app)] : []), "--no-sandbox"],
4246
// HOME stays real: on macOS a fake HOME has no login keychain, and safeStorage blocks the
4347
// main process on a keychain dialog. macOS keeps its Electron profile in the runner's HOME.
4448
env: {

0 commit comments

Comments
 (0)