Skip to content
20 changes: 10 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
# open: if the diff cannot be resolved, everything runs.
changes:
name: Changes
runs-on: blacksmith-2vcpu-ubuntu-2404
runs-on: ${{ github.repository_owner == 'pingdotgg' && 'blacksmith-2vcpu-ubuntu-2404' || 'ubuntu-24.04' }}
timeout-minutes: 5
outputs:
typecheck: ${{ steps.detect.outputs.typecheck }}
Expand Down Expand Up @@ -63,7 +63,7 @@ jobs:
contents: read
id-token: write
name: Lint
runs-on: blacksmith-8vcpu-ubuntu-2404
runs-on: ${{ github.repository_owner == 'pingdotgg' && 'blacksmith-8vcpu-ubuntu-2404' || 'ubuntu-24.04' }}
timeout-minutes: 10
steps:
- name: Checkout
Expand Down Expand Up @@ -119,7 +119,7 @@ jobs:
name: Build and Typecheck
needs: changes
if: ${{ !cancelled() && (needs.changes.outputs.build != 'false' || needs.changes.outputs.typecheck != 'false') }}
runs-on: blacksmith-8vcpu-ubuntu-2404
runs-on: ${{ github.repository_owner == 'pingdotgg' && 'blacksmith-8vcpu-ubuntu-2404' || 'ubuntu-24.04' }}
timeout-minutes: 10
steps:
- name: Checkout
Expand Down Expand Up @@ -213,7 +213,7 @@ jobs:
name: Test
needs: changes
if: ${{ !cancelled() && needs.changes.outputs.test != 'false' }}
runs-on: blacksmith-8vcpu-ubuntu-2404
runs-on: ${{ github.repository_owner == 'pingdotgg' && 'blacksmith-8vcpu-ubuntu-2404' || 'ubuntu-24.04' }}
timeout-minutes: 10
steps:
- name: Checkout
Expand Down Expand Up @@ -289,7 +289,7 @@ jobs:
name: Test Web
needs: changes
if: ${{ !cancelled() && needs.changes.outputs.test_web != 'false' }}
runs-on: blacksmith-8vcpu-ubuntu-2404
runs-on: ${{ github.repository_owner == 'pingdotgg' && 'blacksmith-8vcpu-ubuntu-2404' || 'ubuntu-24.04' }}
timeout-minutes: 10
steps:
- name: Checkout
Expand Down Expand Up @@ -353,7 +353,7 @@ jobs:
contents: read
id-token: write
name: Test Server ${{ matrix.shard }}
runs-on: blacksmith-4vcpu-ubuntu-2404
runs-on: ${{ github.repository_owner == 'pingdotgg' && 'blacksmith-4vcpu-ubuntu-2404' || 'ubuntu-24.04' }}
# Shards take 2-5 minutes. When the shared task cache throttles reads, each
# failed fetch stalls vp for 15-90s, which pushed shards past 10 minutes.
timeout-minutes: 20
Expand Down Expand Up @@ -469,7 +469,7 @@ jobs:
name: Rust
needs: changes
if: ${{ !cancelled() && needs.changes.outputs.rust != 'false' }}
runs-on: blacksmith-4vcpu-ubuntu-2404
runs-on: ${{ github.repository_owner == 'pingdotgg' && 'blacksmith-4vcpu-ubuntu-2404' || 'ubuntu-24.04' }}
timeout-minutes: 10
steps:
- name: Checkout
Expand Down Expand Up @@ -502,7 +502,7 @@ jobs:
name: Mobile Native Static Analysis
needs: changes
if: ${{ !cancelled() && needs.changes.outputs.mobile_native != 'false' }}
runs-on: blacksmith-6vcpu-macos-26
runs-on: ${{ github.repository_owner == 'pingdotgg' && 'blacksmith-6vcpu-macos-26' || 'macos-latest' }}
timeout-minutes: 10
steps:
- name: Checkout
Expand Down Expand Up @@ -535,7 +535,7 @@ jobs:
name: Release Smoke
needs: changes
if: ${{ !cancelled() && needs.changes.outputs.release_smoke != 'false' }}
runs-on: blacksmith-8vcpu-ubuntu-2404
runs-on: ${{ github.repository_owner == 'pingdotgg' && 'blacksmith-8vcpu-ubuntu-2404' || 'ubuntu-24.04' }}
timeout-minutes: 10
steps:
- name: Checkout
Expand Down Expand Up @@ -575,7 +575,7 @@ jobs:
mobile_native_static_analysis,
release_smoke,
]
runs-on: blacksmith-2vcpu-ubuntu-2404
runs-on: ${{ github.repository_owner == 'pingdotgg' && 'blacksmith-2vcpu-ubuntu-2404' || 'ubuntu-24.04' }}
timeout-minutes: 5
steps:
- name: Require every job to pass
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/mobile-fingerprint-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ concurrency:
jobs:
fingerprint:
name: Native fingerprint diff
runs-on: blacksmith-8vcpu-ubuntu-2404
runs-on: ${{ github.repository_owner == 'pingdotgg' && 'blacksmith-8vcpu-ubuntu-2404' || 'ubuntu-24.04' }}
permissions:
contents: read
env:
Expand Down
32 changes: 32 additions & 0 deletions FORK.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Amartya's T3 Code fork

This repository tracks [pingdotgg/t3code](https://github.com/pingdotgg/t3code). `main` is a 1:1 mirror. Fork behavior lives on `patches` and is cherry-picked onto each upstream **stable** tag by `.github/workflows/fork-stable-release.yml`.

The contract for those patches is [PATCH.md](PATCH.md).

## First install

1. Wait for a GitHub Release on [amartya18/t3code](https://github.com/amartya18/t3code/releases) with a macOS zip or dmg and `latest-mac.yml`.
2. Download the arm64 zip or dmg. This is a self-signed build, not a Developer ID build.
3. Open it. Gatekeeper will warn. Open anyway from System Settings → Privacy & Security, or right-click Open.
4. Keychain may ask to trust the signing identity. Allow it. Later updates from this fork use the same identity, so Squirrel.Mac accepts them.
5. Do not replace an official T3 Code install in place and expect the official updater to switch feeds. Official builds look at pingdotgg/t3code. This fork's `app-update.yml` looks at amartya18/t3code. Install this build as your daily app if you want fork updates. Bundle id and user-data dir match upstream (`com.t3tools.t3code`, `~/Library/Application Support/t3code` with legacy `T3 Code (Alpha)`), so existing threads stay.

## Add or change a patch

1. Branch from `patches`.
2. Make one concern. Keep it rebase-friendly.
3. Update [PATCH.md](PATCH.md) in the same change.
4. Open a PR that targets `patches`, not `main`. Do not merge into `main`.

## Conflicts

The daily workflow cherry-picks `patches` onto the newest upstream stable tag. If git cannot apply a patch, it opens a GitHub issue and publishes nothing. Rebase `patches` onto the new tag, restore the PATCH.md invariants, and re-run the workflow.

Prefer upstream on conflicted hunks, then re-apply only the contract in PATCH.md. If the invariant cannot be re-expressed without changing behavior, leave the conflict and say which invariant is at risk.

## Rollback

- App: download an older fork release zip and replace the `.app`. Same signing identity, so this is a downgrade the updater will try to replace on the next check.
- Patches: reset `patches` to the last known-good commit. `main` stays a mirror; do not rewind it with fork commits.
- Stop taking updates: quit the app, or switch back to an official pingdotgg build (that is a different signing identity; it will not consume this feed).
35 changes: 35 additions & 0 deletions PATCH.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Fork patches

This branch (`patches`) is the personal [amartya18/t3code](https://github.com/amartya18/t3code) stack. Cherry-pick it onto any upstream **stable** tag. `main` is a 1:1 mirror of [pingdotgg/t3code](https://github.com/pingdotgg/t3code) and must not receive these commits.

See [FORK.md](FORK.md) for install, adding patches, conflicts, and rollback.

## Behavioral contract

### Signed macOS builds without Apple Developer ID

1. `--signed` on macOS still codesigns via `scripts/sign-macos.ts` and `CSC_LINK`.
2. If `T3CODE_APPLE_TEAM_ID` and `T3CODE_MACOS_PROVISIONING_PROFILE` are both unset or empty, the build does **not** resolve passkey signing, does **not** embed a provisioning profile, sets `mac.notarize: false` and `mac.forceCodeSigning: true`, and signs with hardened-runtime entitlements (JIT, disable-library-validation, camera, microphone) that do **not** include associated-domains or a team identifier.
3. If either Apple variable is set, the upstream passkey path still runs and still fails closed on a missing profile, bad team id, or bad RP domain.
4. Bundle id stays `com.t3tools.t3code`. User-data directory stays `t3code` (legacy `T3 Code (Alpha)`).

### GitHub-hosted CI on this fork

5. `ci.yml` and `mobile-fingerprint-check.yml` use GitHub-hosted `ubuntu-24.04` / `macos-latest` when `github.repository_owner != pingdotgg`. pingdotgg keeps Blacksmith. `ubuntu-latest` is Ubuntu 26, which Playwright 1.60 cannot install Chromium on.
6. Two v0.1.6 tests are adjusted so GitHub-hosted CI can go green: storage cleanup accepts Git 2.56's gitfile fatal instead of treating a missing gitdir as a branch change, and the usage "windows it reaches" fixture stays inside the 92-day cache retention window via `Clock.currentTimeMillis` (not `Date.now()`, which lint forbids in tests).
7. The workspace PDF scroll/zoom browser test waits up to 30s for `1 / 3 pages` and has a 60s test budget. GitHub-hosted `ubuntu-24.04` (4 vCPU) is slower than Blacksmith 8vcpu; the 15s default cuts off first paint.

## Maintained files

- `scripts/build-desktop-artifact.ts` (+ `.test.ts`)
- `.github/workflows/ci.yml`
- `.github/workflows/mobile-fingerprint-check.yml`
- `apps/server/src/storageCleanup.test.ts`
- `apps/server/src/usage/UsageService.test.ts`
- `apps/web/src/components/files/AttachmentFilePreview.browser.test.tsx`

## Dropped from upstream signing

- Notarization (no Apple notary credentials)
- Associated-domain / passkey entitlements (no Apple team provisioning profile)
- Clerk desktop passkeys on this fork
11 changes: 10 additions & 1 deletion apps/server/src/storageCleanup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2050,7 +2050,16 @@ describe("storage cleanup reports and local file policies", () => {
yield* fs.remove(`${index.trim()}.lock`);
const gitFile = yield* fs.readFileString(`${worktree}/.git`);
yield* fs.writeFileString(`${worktree}/.git`, "gitdir: /missing-git-directory\n");
expect((yield* service.runNow).entries[0]).toMatchObject(changed);
// Git 2.43 treats a missing gitdir as a branch change (kept). Git 2.56
// on GitHub-hosted runners fatals ("gitfile does not point to a valid
// repository"). Either way the worktree must not be removed.
const missingGit = (yield* service.runNow).entries[0];
expect(missingGit?.outcome).not.toBe("removed");
if (missingGit?.outcome === "failed") {
expect(missingGit.reason).toContain("gitfile");
} else {
expect(missingGit).toMatchObject(changed);
}
yield* fs.writeFileString(`${worktree}/.git`, gitFile);
expect((yield* service.runNow).entries[0]).toMatchObject({ outcome: "removed" });
expect(fullStatusCalls()).toBe(0);
Expand Down
32 changes: 25 additions & 7 deletions apps/server/src/usage/UsageService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
type UsageSummaryInput,
} from "@t3tools/contracts";
import * as Duration from "effect/Duration";
import * as DateTime from "effect/DateTime";
import * as Clock from "effect/Clock";
import * as Deferred from "effect/Deferred";
import * as Effect from "effect/Effect";
Expand Down Expand Up @@ -2609,27 +2610,44 @@ describe("UsageService", () => {
it.live("reports saved usage of a removed directory only for windows it reaches", () =>
Effect.gen(function* () {
const { transcript, settings, home } = yield* setup;
// Cache retention is 92 days. Hard-coded 2026-08-01 dates fall out of
// that window once "now" is early November 2026, so the file mtime and
// the windows under test stay 10 days behind the live clock.
const fileMs = (yield* Clock.currentTimeMillis) - 10 * 24 * 60 * 60 * 1000;
const utcDay = (ms: number) => DateTime.formatIso(DateTime.makeUnsafe(ms)).slice(0, 10);
const fileDay = utcDay(fileMs);
const window = {
timeZone: "UTC" as const,
sinceDay: UsageDay.make(utcDay(fileMs - 24 * 60 * 60 * 1000)),
untilDay: UsageDay.make(utcDay(fileMs + 24 * 60 * 60 * 1000)),
};
yield* Effect.promise(async () => {
await NodeFSP.writeFile(transcript, claudeLine(1, 5));
const lastWrite = Date.parse("2026-08-01T10:00:00Z") / 1000;
await NodeFSP.utimes(transcript, lastWrite, lastWrite);
await NodeFSP.writeFile(
transcript,
claudeLine(1, 5).replace(
"2026-08-01T10:00:00Z",
DateTime.formatIso(DateTime.makeUnsafe(fileMs)),
),
);
await NodeFSP.utimes(transcript, fileMs / 1000, fileMs / 1000);
});
const service = yield* UsageService.make.pipe(
Effect.provide(layerService({ prefix: "usage-service-saved-window-test", home, settings })),
);
const first = yield* service.readSummary(WINDOW);
const first = yield* service.readSummary(window);
assert.strictEqual(first.buckets[0]?.day, fileDay);
yield* Effect.promise(() =>
NodeFSP.rm(NodePath.join(home, "claude", "projects"), { recursive: true }),
);

const reached = yield* service.readSummary(WINDOW);
const reached = yield* service.readSummary(window);
assert.deepStrictEqual(reached.buckets, first.buckets);
assert.strictEqual(reached.sources[0]?.status, "ok");

const later = yield* service.readSummary({
timeZone: "UTC",
sinceDay: UsageDay.make("2026-08-10"),
untilDay: UsageDay.make("2026-08-12"),
sinceDay: UsageDay.make(utcDay(fileMs + 9 * 24 * 60 * 60 * 1000)),
untilDay: UsageDay.make(utcDay(fileMs + 11 * 24 * 60 * 60 * 1000)),
});
assert.deepStrictEqual(later.buckets, []);
assert.strictEqual(later.sources[0]?.status, "missing");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2516,11 +2516,15 @@ function pdfScroll(screen: Screen) {
return { region, canvas, offset, scrollTo };
}

// oxlint-disable-next-line t3code/no-test-timeout-or-unreasoned-skip -- PDF first paint on GitHub-hosted 4vcpu, not a hidden wait.
it("keeps workspace PDF scroll and zoom after reloads", async () => {
using fixture = await workspacePdfPreview();
const { preview, urls } = fixture;
await using screen = await render(preview(urls.original, "one"));
await expect.element(screen.getByText("1 / 3 pages", { exact: true })).toBeVisible();
await expect
.element(screen.getByText("1 / 3 pages", { exact: true }), { timeout: 30_000 })
.toBeVisible();

await screen.getByRole("button", { name: "Next page", exact: true }).click();
await vi.waitFor(() => expect(screen.container.textContent).toContain("2 / 3 pages"));
await screen.getByRole("button", { name: "Next page", exact: true }).click();
Expand Down Expand Up @@ -2575,7 +2579,7 @@ it("keeps workspace PDF scroll and zoom after reloads", async () => {
expect(region().scrollTop).toBe(0);
expect(region().scrollLeft).toBe(0);
});
});
}, 60_000);

it("clamps workspace PDF scroll when pages shrink or disappear", async () => {
using fixture = await workspacePdfPreview();
Expand Down
105 changes: 105 additions & 0 deletions scripts/build-desktop-artifact.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ import {
packWindowsServerAsar,
preflightWindowsDesktopBuild,
renderMacPasskeyEntitlements,
renderMacSelfSignedEntitlements,
resolveMacWebAuthnEntitlements,
resolveMacPasskeySigningConfiguration,
shouldResolveMacPasskeySigning,
resolveMergedStageDependencies,
resolveBuildOptions,
stageWslRuntimeArchive,
Expand Down Expand Up @@ -546,6 +548,76 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
),
);

it.effect(
"signed macOS builds without a passkey profile skip notarization and provisioning",
() =>
Effect.gen(function* () {
const signedSelf = yield* createBuildConfig("mac", "dmg", "0.1.6", true, false, undefined, {
entitlementsPath: "/tmp/entitlements.mac.plist",
});
const mac = signedSelf.mac as Record<string, unknown>;
assert.equal(mac.notarize, false);
assert.equal(mac.forceCodeSigning, true);
assert.match(String(mac.sign), /scripts[\\/]sign-macos\.ts$/);
assert.notProperty(mac, "provisioningProfile");
assert.equal(mac.entitlements, "/tmp/entitlements.mac.plist");

const signedPasskeys = yield* createBuildConfig(
"mac",
"dmg",
"0.1.6",
true,
false,
undefined,
{
entitlementsPath: "/tmp/entitlements.mac.plist",
provisioningProfilePath: "/tmp/t3code.provisionprofile",
},
);
const passkeyMac = signedPasskeys.mac as Record<string, unknown>;
assert.notProperty(passkeyMac, "notarize");
assert.equal(passkeyMac.forceCodeSigning, true);
assert.equal(passkeyMac.provisioningProfile, "/tmp/t3code.provisionprofile");
assert.equal(passkeyMac.entitlements, "/tmp/entitlements.mac.plist");
}).pipe(
Effect.provide(
ConfigProvider.layer(
ConfigProvider.fromEnv({ env: { GITHUB_REPOSITORY: "amartya18/t3code" } }),
),
),
),
);

it.effect("resolves the GitHub update feed from T3CODE_DESKTOP_UPDATE_REPOSITORY", () =>
Effect.gen(function* () {
const config = yield* createBuildConfig(
"mac",
"dmg",
"0.1.6",
false,
false,
undefined,
undefined,
);
assert.deepStrictEqual(config.publish, [
{
provider: "github",
owner: "amartya18",
repo: "t3code",
releaseType: "release",
},
]);
}).pipe(
Effect.provide(
ConfigProvider.layer(
ConfigProvider.fromEnv({
env: { T3CODE_DESKTOP_UPDATE_REPOSITORY: "amartya18/t3code" },
}),
),
),
),
);

// pnpm writes "set this to true or false" placeholders into allowBuilds when a
// tarball changes. pnpm ignores them, but the release build decode rejects them.
it.effect("decodes the repo allowBuilds and every file: tarball it names exists", () =>
Expand Down Expand Up @@ -1490,6 +1562,39 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
);
});

it("self-signed mac entitlements keep camera, mic, and JIT without Apple team claims", () => {
const entitlements = renderMacSelfSignedEntitlements();
assert.match(entitlements, /<key>com\.apple\.security\.cs\.allow-jit<\/key>\s*<true\/>/u);
assert.match(
entitlements,
/<key>com\.apple\.security\.cs\.disable-library-validation<\/key>\s*<true\/>/u,
);
assert.match(entitlements, /<key>com\.apple\.security\.device\.camera<\/key>\s*<true\/>/u);
assert.match(entitlements, /<key>com\.apple\.security\.device\.audio-input<\/key>\s*<true\/>/u);
assert.notInclude(entitlements, "com.apple.application-identifier");
assert.notInclude(entitlements, "com.apple.developer.team-identifier");
assert.notInclude(entitlements, "com.apple.developer.associated-domains");
assert.notInclude(entitlements, "webcredentials:");
});

it("skips passkey resolution when Apple team id and provisioning profile are both absent", () => {
assert.equal(shouldResolveMacPasskeySigning({}), false);
assert.equal(
shouldResolveMacPasskeySigning({
T3CODE_APPLE_TEAM_ID: " ",
T3CODE_MACOS_PROVISIONING_PROFILE: "",
}),
false,
);
assert.equal(shouldResolveMacPasskeySigning({ T3CODE_APPLE_TEAM_ID: "ABC1234567" }), true);
assert.equal(
shouldResolveMacPasskeySigning({
T3CODE_MACOS_PROVISIONING_PROFILE: "/tmp/t3code.provisionprofile",
}),
true,
);
});

it("rejects incomplete macOS passkey signing configuration", () => {
const captureError = (env: Readonly<Record<string, string | undefined>>) => {
try {
Expand Down
Loading
Loading