Skip to content

Commit 862b291

Browse files
Sean-R-Wilsonclaude
andcommitted
Merge origin/main into fix/server-browser-site-copy
Resolves the conflict with #34204, which gave each copy key its own time window and moved its read after the key so a busy frame no longer holds input. Clicks now follow the same pattern, as #34204 asked. A clean left press records when it was sent and no longer reads every frame before it is dispatched. Each read after the release takes only a click copy made from that press up to the moment the read started. A copy from before the press is dropped as stale, and a slow read can never take the next press's copy. Copy keys keep #34204's windows in the merged recorder. The busy-frame test now also sends a left click while a frame's read is stalled, and fails with the old pre-press read. A real-Chromium test pins the recorder's clock to check both windows. Co-Authored-By: Claude Opus 5.5 <[email protected]>
2 parents 91bdf45 + 6a8f82c commit 862b291

754 files changed

Lines changed: 39525 additions & 7054 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/workflows/ci.yml‎

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -355,16 +355,22 @@ jobs:
355355
356356
# The web suite is the largest outside the server. In the shared Test job it
357357
# started last and ran alone for about 40s after everything else finished.
358-
# release.yml mirrors this test, test_web, and test_server split.
358+
# Browser tests are bound by the Vite server transforming modules for each
359+
# file, not by Chromium, so a second runner (and Vite server) halves the job
360+
# that gated every run. release.yml mirrors this test, test_web, and test_server split.
359361
test_web:
360362
permissions:
361363
contents: read
362364
id-token: write
363-
name: Test Web
365+
name: Test Web ${{ matrix.shard }}
364366
needs: changes
365367
if: ${{ !cancelled() && needs.changes.outputs.test_web != 'false' }}
366368
runs-on: blacksmith-8vcpu-ubuntu-2404
367369
timeout-minutes: 10
370+
strategy:
371+
fail-fast: false
372+
matrix:
373+
shard: [1, 2]
368374
steps:
369375
- name: Checkout
370376
uses: actions/checkout@v6
@@ -406,7 +412,7 @@ jobs:
406412
fi
407413
408414
- name: Test
409-
run: vp run --filter @t3tools/web test
415+
run: vp run --filter @t3tools/web test --shard ${{ matrix.shard }}/${{ strategy.job-total }}
410416

411417
# apps/server sets `fileParallelism: false`, so its test files run strictly
412418
# one at a time. Sharding spreads them over separate runners instead of
@@ -481,6 +487,17 @@ jobs:
481487
node apps/server/node_modules/playwright-core/cli.js install-deps chromium
482488
fi
483489
490+
# Each server test file runs in its own Vitest process, and a fresh install starts
491+
# Vitest's content-keyed module cache empty, so every file re-transformed its imports.
492+
# Only pushes to main save it, so pull requests never evict each other's entries.
493+
- name: Restore Vitest module cache
494+
if: steps.changes.outputs.test_server != 'false'
495+
uses: actions/cache/restore@v6
496+
with:
497+
path: node_modules/.vitest-cache
498+
key: vitest-modules-server-${{ matrix.shard }}-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}-${{ github.sha }}
499+
restore-keys: vitest-modules-server-${{ matrix.shard }}-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}-
500+
484501
- name: Test
485502
if: steps.changes.outputs.test_server != 'false'
486503
env:
@@ -489,15 +506,14 @@ jobs:
489506
run: >-
490507
vp run test:cached -- --shard ${{ matrix.shard }}/${{ strategy.job-total }}
491508
--uncached apps/server/integration/transferBudgetV2.integration.test.ts
492-
--verify-hits 1 --report "${{ runner.temp }}/test-cache-${{ matrix.shard }}.json" apps/server
509+
--verify-hits 1 apps/server
493510
494-
- name: Upload test cache measurements
495-
if: always() && steps.changes.outputs.test_server != 'false'
496-
uses: actions/upload-artifact@v7
511+
- name: Save Vitest module cache
512+
if: github.event_name == 'push' && steps.changes.outputs.test_server != 'false'
513+
uses: actions/cache/save@v6
497514
with:
498-
name: test-cache-${{ matrix.shard }}
499-
path: ${{ runner.temp }}/test-cache-${{ matrix.shard }}.json
500-
if-no-files-found: error
515+
path: node_modules/.vitest-cache
516+
key: vitest-modules-server-${{ matrix.shard }}-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}-${{ github.sha }}
501517

502518
# integration/transferBudgetV2.integration.test.ts writes the report; exactly one shard
503519
# produces these files. Gating the upload on their presence keeps a

‎.github/workflows/release.yml‎

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,11 +300,15 @@ jobs:
300300
# Web browser tests time out when they share a runner with the other package
301301
# suites: Chromium gets too little CPU and diff workers miss their 10s start budget.
302302
test_web:
303-
name: Release web tests
303+
name: Release web tests ${{ matrix.shard }}
304304
needs: [preflight]
305305
if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' }}
306306
runs-on: blacksmith-8vcpu-ubuntu-2404
307307
timeout-minutes: 10
308+
strategy:
309+
fail-fast: false
310+
matrix:
311+
shard: [1, 2]
308312
steps:
309313
- name: Checkout
310314
uses: actions/checkout@v6
@@ -344,10 +348,11 @@ jobs:
344348
fi
345349
346350
- name: Test
347-
run: vp run --filter @t3tools/web test
351+
run: vp run --filter @t3tools/web test --shard ${{ matrix.shard }}/${{ strategy.job-total }}
348352

349353
# Browser tests run source modules; this boots the production chunk graph.
350354
- name: Boot the built web client
355+
if: matrix.shard == 1
351356
run: |
352357
vp run --filter @t3tools/web build
353358
node apps/web/scripts/verify-built-boot.ts
@@ -1482,7 +1487,18 @@ jobs:
14821487
14831488
git add apps/server/package.json apps/desktop/package.json apps/web/package.json packages/contracts/package.json pnpm-lock.yaml
14841489
git commit --no-verify -m "chore(release): prepare $RELEASE_TAG"
1485-
git push origin HEAD:main
1490+
1491+
# main moves while this job runs, so a rejected push rebases and retries.
1492+
for attempt in 1 2 3 4 5; do
1493+
if git push origin HEAD:main; then
1494+
exit 0
1495+
fi
1496+
echo "Push rejected (attempt $attempt). Rebasing onto latest main."
1497+
git pull --rebase origin main
1498+
done
1499+
1500+
echo "Could not push the version bump after 5 attempts." >&2
1501+
exit 1
14861502
14871503
announce_discord:
14881504
name: Announce release on Discord

‎.macroscope/check-run-agents/ui-consistency.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ The reference for how this codebase wants UI built is the composer banner system
4444

4545
- `ComposerBanner.tsx` exports one object of small slot components (`Root`, `Row`, `Icon`, `Content`, `Actions`, `Dismiss`, `Children`, and so on). Each slot owns its own Tailwind classes, exposes a `data-slot` attribute, takes `className` and spreads the rest of its props, and uses `cn` so callers can adjust without overriding. Variants and density are props on `Root`, not ad hoc class strings at call sites. Where a slot needs a real control it renders `Button` from `ui/` rather than a styled `<button>`.
4646
- `ComposerBannerStack.tsx` composes those slots into the ordered stack and owns only stack behavior (priority, expand and collapse, dismiss transitions).
47-
- Consumers such as `ComposerPlanFollowUpBanner.tsx` are a few lines of `<ComposerBanner.Row><ComposerBanner.Icon/><ComposerBanner.Content>…` and style only their own content.
47+
- Consumers compose the slots and style only their own content.
4848

4949
Hold new and changed UI to that shape:
5050

‎apps/desktop/package.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@t3tools/desktop",
3-
"version": "0.1.8",
3+
"version": "0.1.9",
44
"private": true,
55
"type": "module",
66
"main": "dist-electron/boot.cjs",
@@ -37,6 +37,7 @@
3737
"acorn": "8.16.0",
3838
"cross-env": "^10.1.0",
3939
"electron-builder": "26.16.1",
40+
"jsdom": "^30.0.1",
4041
"tailwindcss": "^4.0.0",
4142
"vite-plus": "catalog:"
4243
},

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

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ import * as NodeFS from "node:fs";
33
import * as NodeOS from "node:os";
44
import * as NodePath from "node:path";
55
import { assert, describe, it } from "@effect/vitest";
6-
import { vi } from "vite-plus/test";
7-
8-
vi.mock("node:fs", { spy: true });
96

107
import { openClerkTokenStorage, type ClerkTokenStorage } from "./ClerkTokenStore.ts";
118

@@ -91,24 +88,6 @@ describePosix("ClerkTokenStore", () => {
9188
});
9289
});
9390

94-
it("removes the legacy token file when the private copy already exists", async () => {
95-
await withStateDir((stateDir) => {
96-
const directory = NodePath.join(stateDir, "clerk");
97-
const legacyPath = NodePath.join(stateDir, "clerk-tokens.json");
98-
const tokenPath = NodePath.join(directory, "clerk-tokens.json");
99-
NodeFS.mkdirSync(directory, { mode: 0o755 });
100-
writeLoose(legacyPath, "stale-credential");
101-
writeLoose(tokenPath, "kept-credential");
102-
103-
openClerkTokenStorage(stateDir, () => idleStorage());
104-
105-
assert.equal(NodeFS.existsSync(legacyPath), false);
106-
assert.equal(modeOf(directory), 0o700);
107-
assert.equal(modeOf(tokenPath), 0o600);
108-
assert.equal(NodeFS.readFileSync(tokenPath, "utf8"), "kept-credential");
109-
});
110-
});
111-
11291
it("resolves a relative state directory before opening storage", async () => {
11392
await withStateDir(async (stateDir) => {
11493
const relativeStateDir = NodePath.relative(process.cwd(), stateDir);
@@ -150,23 +129,6 @@ describePosix("ClerkTokenStore", () => {
150129
});
151130
});
152131

153-
it("migrates tokens when the legacy directory is on another filesystem", async () => {
154-
await withStateDir((stateDir) => {
155-
const legacyPath = NodePath.join(stateDir, "clerk-tokens.json");
156-
writeLoose(legacyPath, "existing-session");
157-
using _rename = vi.spyOn(NodeFS, "renameSync").mockImplementation(() => {
158-
throw Object.assign(new Error("cross-device link"), { code: "EXDEV" });
159-
});
160-
161-
openClerkTokenStorage(stateDir, idleStorage);
162-
163-
const tokenPath = NodePath.join(stateDir, "clerk", "clerk-tokens.json");
164-
assert.equal(NodeFS.readFileSync(tokenPath, "utf8"), "existing-session");
165-
assert.equal(modeOf(tokenPath), 0o600);
166-
assert.equal(NodeFS.existsSync(legacyPath), false);
167-
});
168-
});
169-
170132
it("does not follow a symlinked clerk directory or token file", async () => {
171133
await withStateDir(async (stateDir) => {
172134
const outsideDirectory = NodePath.join(stateDir, "outside-dir");

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import * as Layer from "effect/Layer";
77
import * as FileSystem from "effect/FileSystem";
88
import * as Path from "effect/Path";
99
import * as HttpClient from "effect/http/HttpClient";
10+
import { ChildProcessSpawner } from "effect/process";
1011
import * as NetService from "@t3tools/shared/Net";
1112
import * as Fiber from "effect/Fiber";
1213
import * as Option from "effect/Option";
@@ -213,6 +214,7 @@ it.effect.each([false, true])(
213214
Effect.provide(
214215
Layer.mergeAll(
215216
Layer.mock(BrowserImport.BrowserImport, {}),
217+
Layer.mock(ChildProcessSpawner.ChildProcessSpawner, {}),
216218
Layer.mock(DesktopBackendConfiguration.DesktopBackendConfiguration, {}),
217219
Layer.mock(DesktopCliCommand.DesktopCliCommand, {}),
218220
Layer.mock(DesktopClientSettings.DesktopClientSettings, {}),

‎apps/desktop/src/backend/DesktopBackendManager.test.ts‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ describe("DesktopBackendManager", () => {
421421
),
422422
);
423423

424-
it.effect("starts the configured backend and closes the scoped process on stop", () =>
424+
it.effect("stops the scoped process with output still pending", () =>
425425
Effect.scoped(
426426
Effect.gen(function* () {
427427
let startCount = 0;
@@ -458,6 +458,7 @@ describe("DesktopBackendManager", () => {
458458
yield* Scope.addFinalizer(scope, close);
459459

460460
return makeProcess({
461+
stdout: Stream.never,
461462
exitCode: Deferred.await(closed).pipe(Effect.as(ChildProcessSpawner.ExitCode(0))),
462463
kill: () => close,
463464
});
@@ -721,14 +722,12 @@ describe("DesktopBackendManager", () => {
721722
),
722723
);
723724

724-
it.effect("the quit stop deadline waits for a backend that only exits at the force kill", () =>
725+
it.effect("the quit stop keeps waiting for a backend that outlasts its deadline", () =>
725726
Effect.scoped(
726727
Effect.gen(function* () {
727728
const spawned = yield* Deferred.make<void>();
728729
const teardownStarted = yield* Deferred.make<void>();
729730
const teardownFinished = yield* Deferred.make<void>();
730-
// The real spawner sends SIGTERM, waits the grace, then SIGKILLs. A backend that
731-
// ignores SIGTERM therefore finishes tearing down just after the grace.
732731
const instance = yield* makeTestInstance({
733732
spawnerLayer: Layer.succeed(
734733
ChildProcessSpawner.ChildProcessSpawner,
@@ -739,7 +738,7 @@ describe("DesktopBackendManager", () => {
739738
yield* Scope.addFinalizer(
740739
scope,
741740
Deferred.succeed(teardownStarted, undefined).pipe(
742-
Effect.andThen(Effect.sleep(Duration.seconds(6))),
741+
Effect.andThen(Effect.sleep(Duration.seconds(10))),
743742
Effect.andThen(Deferred.succeed(teardownFinished, undefined)),
744743
Effect.asVoid,
745744
),
@@ -764,11 +763,11 @@ describe("DesktopBackendManager", () => {
764763
.pipe(Effect.andThen(Deferred.succeed(quitDone, undefined)), Effect.forkChild);
765764

766765
yield* Deferred.await(teardownStarted);
767-
// Past the SIGTERM grace but before the force kill lands: quit must still be waiting.
768-
yield* TestClock.adjust(Duration.millis(5_500));
766+
// Past the quit deadline, quit must still wait for the backend to exit.
767+
yield* TestClock.adjust(Duration.seconds(9));
769768
assert.isFalse(yield* Deferred.isDone(quitDone));
770769

771-
yield* TestClock.adjust(Duration.millis(500));
770+
yield* TestClock.adjust(Duration.seconds(1));
772771
yield* Fiber.join(quitFiber);
773772
assert.isTrue(yield* Deferred.isDone(teardownFinished));
774773
}).pipe(Effect.provide(TestClock.layer())),

‎apps/desktop/src/backend/DesktopBackendManager.ts‎

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ export interface DesktopBackendInstance {
240240
readonly id: BackendInstanceId;
241241
readonly label: Effect.Effect<string>;
242242
readonly start: Effect.Effect<void>;
243+
/** Timeout controls the warning; stop still waits for process teardown and exit. */
243244
readonly stop: (options?: { readonly timeout?: Duration.Duration }) => Effect.Effect<void>;
244245
readonly currentConfig: Effect.Effect<Option.Option<DesktopBackendStartConfig>>;
245246
readonly snapshot: Effect.Effect<DesktopBackendSnapshot>;
@@ -307,7 +308,7 @@ const closeRun = (
307308
run: ActiveBackendRun,
308309
parentScope: Scope.Scope,
309310
options?: { readonly timeout?: Duration.Duration },
310-
): Effect.Effect<boolean> => {
311+
) => {
311312
const waitForFiber = Option.match(run.fiber, {
312313
onNone: () => Effect.void,
313314
onSome: (fiber) => Fiber.await(fiber).pipe(Effect.asVoid),
@@ -319,12 +320,24 @@ const closeRun = (
319320
const timeout = options?.timeout;
320321

321322
if (!timeout) {
322-
return close.pipe(Effect.as(true));
323+
return close;
323324
}
324325

325-
return Effect.forkIn(close, parentScope).pipe(
326+
return Effect.forkIn(close, parentScope, { startImmediately: true }).pipe(
326327
Effect.flatMap((closeFiber) =>
327-
Fiber.await(closeFiber).pipe(Effect.timeoutOption(timeout), Effect.map(Option.isSome)),
328+
Fiber.await(closeFiber).pipe(
329+
Effect.timeoutOption(timeout),
330+
Effect.tap((completed) =>
331+
Option.isNone(completed)
332+
? logBackendProcessWarning("backend shutdown exceeded timeout; waiting for exit", {
333+
timeoutMs: Duration.toMillis(timeout),
334+
})
335+
: Effect.void,
336+
),
337+
// Parent-scope interruption still finishes release; do not cancel sibling stops.
338+
Effect.andThen(Fiber.await(closeFiber)),
339+
Effect.asVoid,
340+
),
328341
),
329342
);
330343
};
@@ -1099,10 +1112,7 @@ export const makeBackendInstance = Effect.fn("makeBackendInstance")(function* (
10991112
onNone: () => Effect.void,
11001113
// The enclosing operation owns the span for this inline handler.
11011114
onSome: Effect.fnUntraced(function* (run) {
1102-
const closed = yield* closeRun(run, parentScope, options);
1103-
if (!closed) {
1104-
return;
1105-
}
1115+
yield* closeRun(run, parentScope, options);
11061116
const cleanup = yield* mutex.withPermits(1)(
11071117
SubscriptionRef.modify(
11081118
state,

0 commit comments

Comments
 (0)