Skip to content

Commit 189972f

Browse files
radroidclaude
andcommitted
perf(coil): halve the desktop release bundle (#53)
app.asar 189.66 MiB / 14,765 files -> 99.02 MiB / 3,429 files (-47.8%, -76.8% files). The updater's .zip drops 20.1 MB; the electron-builder phase drops 62%. Three cuts, each measured from the packed asar rather than the install tree: - Web renderer source maps (37.4 MiB) via T3CODE_WEB_SOURCEMAP=0, an existing upstream variable. All 385 renderer chunks are byte-identical afterwards apart from the trailing sourceMappingURL comment. - Third-party source maps (18.2 MiB). First-party maps are kept, so NODE_OPTIONS=--enable-source-maps still gives readable frames for our code. - Two renderer-only dependency trees: Clerk's browser SDK (23.2 MiB, 16 packages) and @pierre/diffs' shiki tree (21.0 MiB, 50 packages). Both are bundled by a client build before staging, and the renderer runs sandboxed with nodeIntegration off, so neither is resolvable at runtime. Sync cost is one upstream file, +21/-0. The seam is an env hook on scripts/build-desktop-artifact.ts rather than an edited literal: upstream's test asserts DESKTOP_FILE_EXCLUSIONS deep-equals exactly its one entry, and the fork's list is 67 globs and grows, so an inline list would make every future size fix an edit to an upstream test assertion. An unset environment packages exactly what upstream packages. No new seam rows, no new deletions. Two new fork-owned tools: - desktop-bundle-reachability.mjs analyses a staged build. It follows literal import edges AND string-mention edges, because PlaywrightInjectedRuntime.ts resolves playwright-core through a const and an import-only scan calls 10.2 MiB of live code dead. - verify-desktop-bundle.mjs gates every release on both platforms, failing any packaged import that is not loadable. Found two bugs in itself under test: it would have failed every Windows release by ignoring app.asar.unpacked, and an earlier severity split passed a deliberately-broken build. Re-measured on 136b351, after the #71 Coil rename, #58's dependency re-resolution and #92 retiring the local autobuild. The packed asar is the same size on both sides of the rename, and all 66 non-wildcard globs still match a shipped package. Corrects issue #53 on five points, recorded in docs/coil/desktop-bundle-size.md — its size table measured `du` block allocation (core-js "15 MB" is 1.25 MiB of content), it misses source maps entirely, DESKTOP_FILE_EXCLUSIONS is not fork-owned, the mac leg is not the release critical path, and the pnpm store is already cached. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
1 parent eea4d1f commit 189972f

11 files changed

Lines changed: 2313 additions & 2 deletions

‎.github/workflows/coil-release.yml‎

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,19 @@ jobs:
389389
# process that resets the limit to its default of 4, so the serialisation would be a no-op.
390390
- name: Build desktop bundle (serialised)
391391
shell: bash
392+
env:
393+
# Issue #53. The web renderer's source maps were 37.4 MiB of a 189.66 MiB app.asar — the
394+
# single largest line item in the bundle, and 20% of what every user downloads on every
395+
# update. Nothing reads them: a `.map` is only parsed with --enable-source-maps, which the
396+
# desktop backend passes through rather than sets (DesktopBackendConfiguration.ts), and
397+
# renderer maps are DevTools-only.
398+
#
399+
# This is an EXISTING upstream variable (apps/web/vite.config.ts), which is why the biggest
400+
# single win in the issue costs zero seam rows. First-party maps outside the renderer —
401+
# bin.mjs.map and main.cjs.map, ~12 MiB — are deliberately still built and still shipped, so
402+
# an operator who exports NODE_OPTIONS=--enable-source-maps keeps readable stack traces for
403+
# our own code.
404+
T3CODE_WEB_SOURCEMAP: "0"
392405
run: |
393406
set -uo pipefail
394407
@@ -438,6 +451,29 @@ jobs:
438451
echo "::error::build:desktop failed three times with transient process-startup errors." >&2
439452
exit 1
440453
454+
# Issue #53. Kept in its own step so the exact glob list appears in the release log: the list is
455+
# the risky part of the packaging change, and reading it back out of a failed build matters more
456+
# than saving a step. scripts/coil/desktop-file-exclusions.mjs is the single source — it also
457+
# feeds its own unit tests.
458+
#
459+
# A STEP OUTPUT, NOT $GITHUB_ENV, and that is deliberate. Upstream's own test asserts
460+
# DESKTOP_FILE_EXCLUSIONS deep-equals exactly its one entry, so any job-wide export of this
461+
# variable makes `vp test` fail in that job with a confusing 68-vs-1 array diff. An output is
462+
# consumed by exactly the one step that names it below.
463+
- name: Resolve desktop bundle exclusions
464+
id: exclusions
465+
shell: bash
466+
run: |
467+
set -euo pipefail
468+
exclusions="$(node scripts/coil/desktop-file-exclusions.mjs)"
469+
if [[ -z "$exclusions" ]]; then
470+
echo "::error::scripts/coil/desktop-file-exclusions.mjs produced an empty list." >&2
471+
exit 1
472+
fi
473+
echo "value=$exclusions" >> "$GITHUB_OUTPUT"
474+
echo "Excluding from the asar:"
475+
tr ',' '\n' <<< "$exclusions" | sed 's/^/ /'
476+
441477
- name: Build desktop artifact
442478
shell: bash
443479
env:
@@ -468,6 +504,9 @@ jobs:
468504
# Keep this in step with DESKTOP_BUNDLE_IDENTIFIER in scripts/coil/mac-signature.ts; a test
469505
# asserts the two agree, and the verify step below fails an artifact carrying the wrong id.
470506
T3X_DESKTOP_APP_ID: dev.curlycloud.t3coil
507+
# Issue #53. Takes the packaged asar from 189.66 MiB / 14,765 files to 99.02 MiB / 3,429.
508+
# Scoped to this step on purpose — see the note on the step that produces it.
509+
T3X_DESKTOP_FILE_EXCLUSIONS: ${{ steps.exclusions.outputs.value }}
471510
run: |
472511
set -euo pipefail
473512
node scripts/build-desktop-artifact.ts \
@@ -492,6 +531,30 @@ jobs:
492531
fi
493532
echo "No app-update.yml packaged."
494533
534+
# Issue #53's compensating control, and the reason the exclusion list above is safe to grow.
535+
#
536+
# The fork now excludes roughly half the asar. The failure mode of one bad glob is a
537+
# MODULE_NOT_FOUND thrown by a shipped app, on a path that may not run until a user signs in,
538+
# days after a green release. So this reads the artifact that is about to be published, resolves
539+
# every bare import in the packaged first-party bundles against what actually survived, and fails
540+
# if any of them is not loadable — whether or not a fork glob can be blamed for it. Severity does
541+
# not depend on attribution: a bundle that imports what it does not contain is broken either way,
542+
# and an earlier draft that warned on unattributed gaps passed a build that could not start.
543+
#
544+
# Runs on BOTH platforms: the Windows bundle unpacks node_modules outside the asar (the checker
545+
# merges app.asar.unpacked back in) and its graph differs (WSL backend, Linux fff binaries), so a
546+
# mac-only check would not cover it.
547+
- name: Verify the packaged bundle still resolves
548+
shell: bash
549+
run: |
550+
set -euo pipefail
551+
asar="$(find release -name "app.asar" -print -quit)"
552+
if [[ -z "$asar" ]]; then
553+
echo "::error::No app.asar found under release/. Nothing was verified." >&2
554+
exit 1
555+
fi
556+
node scripts/coil/verify-desktop-bundle.mjs --asar "$asar"
557+
495558
# The machine-checkable form of "this update will not re-ask for permissions" (issue #70),
496559
# made against the .app inside the shipped .dmg rather than a staging copy.
497560
#

‎docs/coil/SEAMS.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
**The authoritative list of every upstream-owned file this fork edits.**
44

5-
Measured, not asserted: **48 upstream-owned files, +2281 / -1068 lines**, against merge-base
5+
Measured, not asserted: **48 upstream-owned files, +2302 / -1068 lines**, against merge-base
66
`78f462c4e` (upstream v0.0.33, the 2026-08-10 sync). Everything else the fork adds lives in new
77
files upstream has never seen and cannot conflict.
88

@@ -284,7 +284,7 @@ Sorted by risk, worst first.
284284
| `apps/desktop/src/preload.ts` | +29/-0 | 14 | **406** | `showNotification` + `onNotificationActivated` on the exposed bridge, plus the `t3xUpdate` bridge object (get / subscribe / restart / dismiss) |
285285
| `packages/contracts/src/settings.ts` | +7/-2 | 23 | **207** | `notifyOnNeedsInput` (**persisted schema**) + Claude `homePath` placeholder/description |
286286
| `apps/mobile/modules/t3-composer-editor/ios/T3ComposerEditorView.swift` | +33/-0 | 6 | **198** | Shift+Return newline vs. bare Return submit |
287-
| `scripts/build-desktop-artifact.ts` | +11/-1 | 15 | **180** | Issue #70: `DESKTOP_APP_ID` reads `process.env.T3X_DESKTOP_APP_ID` before falling back to upstream's `com.t3tools.t3code`, so the fork's app owns its own TCC permission rows instead of sharing them with upstream's nightly. Ten of the eleven added lines are the comment explaining that. An env hook rather than a changed literal on purpose: the literal would also have broken three upstream assertions in `build-desktop-artifact.test.ts` and cost a second row. Guarded from the fork side by `scripts/coil/mac-signature.test.ts` (the hook exists and the release workflow sets it) and by `scripts/coil/verify-mac-signature.ts` (the shipped artifact carries the expected identifier) |
287+
| `scripts/build-desktop-artifact.ts` | +32/-1 | 15 | **180** | **Two env hooks, one displaced line, no new deletions.** Issue #70: `DESKTOP_APP_ID` reads `process.env.T3X_DESKTOP_APP_ID` before falling back to upstream's `com.t3tools.t3code`, so the fork's app owns its own TCC permission rows instead of sharing them with upstream's nightly. Issue #53: `DESKTOP_FILE_EXCLUSIONS` appends `process.env.T3X_DESKTOP_FILE_EXCLUSIONS` (comma-separated globs), taking the packaged asar from 189.66 MiB / 14,765 files to 99.02 MiB / 3,429 and the `.zip` users download by 20.1 MB. Most of the added lines are the comments explaining both. Env hooks rather than changed literals on purpose. For #53 the reason is not row count — `build-desktop-artifact.test.ts` is already a row (see #71 above) — but that the fork's list is **67 globs and grows**: an inline list would make every future size fix an edit to an upstream TEST assertion, resolved by hand at every sync. Through the environment, an unset environment packages precisely what upstream packages and upstream's `deepStrictEqual` keeps passing untouched. Guarded from the fork side by `scripts/coil/mac-signature.test.ts` and `scripts/coil/desktop-bundle-size.test.ts` (both hooks exist, the release workflow sets them, the exclusions never name a package the main process loads) and by two artifact checks: `verify-mac-signature.ts` and `verify-desktop-bundle.mjs` (the shipped app still resolves every import its own bundles make) |
288288
| `apps/desktop/src/backend/DesktopBackendConfiguration.ts` | +29/-0 | 6 | **174** | Backend heap headroom (`NODE_OPTIONS`) |
289289
| `apps/desktop/src/backend/DesktopBackendConfiguration.test.ts` | +42/-0 | 4 | **168** | Heap-headroom assertions |
290290
| `apps/desktop/src/main.ts` | +9/-0 | 18 | **162** | `ElectronNotification` layer + the `T3xUpdateDelivery` layer |

0 commit comments

Comments
 (0)