Repository navigation
Conversation
ac3f9a3 to
0c6a0f4
Compare
0c6a0f4 to
3fb67d5
Compare
3fb67d5 to
1820bb2
Compare
1820bb2 to
1e076fc
Compare
1e076fc to
9d5acdd
Compare
9d5acdd to
4afd75c
Compare
…m build The xterm patch is 7.3 MB of diff over minified bundles with no recorded provenance, so no one could regenerate it or tell whether the source hunks and the bundle hunks still agree. Any IME fix that touches CompositionHelper had to be hand-applied to four generated files. Adds config/patches/xterm-src/ as the source of truth (832 lines over four files), a pinned upstream manifest, and a generator that rebuilds the bundles from that commit with the toolchain its lockfile pins, then derives the full patch. `--check` runs it in CI as the new xterm_patch_sync job. The committed patch is regenerated to match pnpm's own diff output (-U3 rather than the hand-made -U6). This changes the patch bytes but no installed byte: both patches applied to pristine tarballs produce recursively identical trees, and all 8 patched files hash-identical to the installed package. pnpm's patchedDependencies hash is sha256 of the patch file — verified for all five of Orca's patches — so pnpm-lock.yaml carries the matching one-line update.
4afd75c to
8692b6f
Compare
The patch carried 5.8MB of sourcemaps for bundles it rewrites, so the maps it shipped described the wrong offsets anyway. The manifest's sourcemaps.policy was documentation the generator never read; it is now the switch that drives this. Deleting the maps rather than omitting their hunks is what keeps the patch honest: omission saves the same bytes but leaves a map pointing into code that moved. Nothing here consumes them - sourcemaps are off in every build config and the package is a devDependency, so it never reaches a packaged app. Also moves the .gitattributes -text rule down to the commit that introduces the patch. It was added at the top of the stack, which left every commit in between shipping a byte-hashed artifact that a CRLF checkout would corrupt. Co-authored-by: Orca <[email protected]>
15203ea to
eef1b32
Compare
pnpm records the hash in patchedDependencies and again in every resolution key that depends on the patched package. The generator only maintained the first, so a regenerated patch left the rest stale: installs succeeded on a warm store and the lockfile drifted on a cold one, which is CI. Co-authored-by: Orca <[email protected]>
|
Leaving this open — not superseded. Build reproducibility for the xterm patch is independent of who owns composition, and main still carries a hand-maintained patch ( That patch grew during this work and is load-bearing: it reworks the One file here ( |
|
Closing as superseded after checking current Superseded by merged #15223, which restored the pinned-upstream xterm patch regeneration harness and added its CI gate. Main now has the upstream pin, source patches, regeneration tooling, and later terminal dependency upgrades. The earlier comment that this was not superseded predates that merge. Closing this PR only; its branch is being retained. |
Summary
Makes the vendored xterm patch reproducible instead of hand-maintained.
Orca patches
@xterm/xtermto add composition-session events that the terminal IME path depends on. The patch was previously edited by hand against built output, so nobody could tell which upstream commit it applied to, whether it still applied cleanly, or what it actually changed semantically. That is a bad foundation for the IME fixes in this stack, which all reason about the patchedCompositionHelper.Changes:
config/patches/xterm-upstream.jsonpins the exact upstream revision the patch is generated from.config/scripts/regenerate-xterm-patches.mjsrebuilds both thesrcpatch and the dist patch from that pinned build, so the diff is derived, not authored.@[email protected]so the TypeScript source changes are reviewable — this is what makes theCompositionHelperbehavior in fix(ime): stop dropping and splitting composition commits in the terminal #11896/fix(ime): let Escape reach the shell when the composition flag has drifted #11897 auditable at all.docs/reference/xterm-patch-regeneration.mddocuments the workflow.Why delete the sourcemaps
The patch rewrites
lib/xterm.jsandlib/xterm.mjs, so a retained.mapwould have to move with them. Simply omitting the map hunks — what the two addon patches in this repo do today — ships maps whose offsets point at the wrong code, which is worse than having none. Deleting them is the honest form of the same size saving:config/patches/@[email protected]…/xterm-src/@[email protected]sourcemaps.policyin the manifest controls this, andassertSourcemapPolicyrejects any value the generator does not implement — without it a typo would silently fall back to including the maps and re-inflate the patch by 5.8 MB.Verified against a real install, not a scratch project:
pnpm install --frozen-lockfilesucceeds cold, the maps are absent fromnode_modules/@xterm/xterm/lib/, zerosourceMappingURLreferences remain, and the two bundles are byte-identical to a clean build after stripping the trailing comment (−34 B / −36 B).--checkreportsin sync (1529822 bytes)from an empty work directory, so the reduction is reproducible from nothing..gitattributes/config/patches/@xterm__xterm@*.patchis marked-diff -text.-textis load-bearing, not cosmetic: pnpm hashes the patch byte-for-byte, so a CRLF checkout on Windows changes the hash and breakspnpm install. The rule lands in the same commit that introduces the patch — parking it higher in the stack would leave every intermediate PR broken for Windows contributors.pnpm writes the patch hash in two places
--checkand--writepreviously managed one of them, and the gap cost this stack a full CI failure. Worth writing down, because the failure mode is specifically designed to look like success.pnpm keys a patched package by the sha256 of the patch file. It records that hash under
patchedDependencies:, and again inside every resolution key that depends on the patched package — 23 of them for@xterm/xterm, in two different spellings:Regenerating the patch therefore produced a lockfile with a correct
patchedDependencieshash and 23 stale resolution keys. On a warm storepnpm installresolves from cache, reports success, and leaves the stale keys in place;pnpm install --frozen-lockfilethen passes locally. On a cold store — which is CI — the same lockfile drifts and the install step fails.pnpm install --forcemakes it worse: it rewrites the resolution keys back to the cached value, so the obvious remedy silently reintroduces the bug.That is what took out ~40 checks on the two PRs above this one. The install job's diff read
-d396b2ad / +ec0d5d6e, andshasum -a 256of the patch file agreed with CI, not with the lockfile.The fix is in
regenerate-xterm-patches.mjs:readLockfileResolutionHashesfinds both spellings (name@version(patch_hash=…)and the bare: version(patch_hash=…)).lockfilePatchHashIsStaleis now the staleness predicate for both--writeand--check, so a lockfile stale in its resolution keys alone is a--checkfailure rather than a clean bill of health.--check's failure message prints all three values —patchedDependencies, the distinct stale resolution hashes, and the patch's own sha256 — because the useful diagnostic is which of the two sites disagrees.patchedDependenciesis already correct and asserts--checkstill fails, which is exactly the case the old predicate passed.docs/reference/xterm-patch-regeneration.mdstates the operational consequence:--checkis the authority on the lockfile, notpnpm install. Always finish on step 4.Both fix PRs' lockfiles were repaired per-commit, so each commit's
patchedDependencies, its 23 resolution keys, and the sha256 of the patch file it carries all agree at that commit — verified individually rather than only at the tip.Screenshots
No visual change.
Testing
pnpm lintpnpm typecheckpnpm test—regenerate-xterm-patches.test.mjs(new, 27 tests) andpr-workflow-parallelism.test.mjspassnode config/scripts/regenerate-xterm-patches.mjs --checkagainst an empty work dir — full clone,npm ci, two builds, byte-identicalpnpm install --frozen-lockfilecold, then the terminal-pane suite (219 files / 2,902 tests) against the resulting installpnpm build— not run locally; the CI job exercises the regeneration pathOn test assurance, stated plainly: the unit tests cover the pure pieces — diff normalization, hunk splitting, round-trip stability, the commit and build-order assertions, the sourcemap-policy guard, and lockfile coupling. They cannot prove the rebuild reproduces upstream; only the CI job that actually clones and builds does that. The runtime test in this PR asserts the version banner the patched bundle emits, which reads the bundle itself; provenance against the pinned commit stays the generator's job, since
src/common/Version.tsis the one source file the generator deliberately exempts from comparison (upstream's publish step rewrites it).AI Review Report
Reviewed for cross-platform correctness of the regeneration script, which is the main risk here since it shells out and manipulates paths.
/.pnpm/Node, not a shell-specific pipeline, so it runs on Windows as well as macOS/Linux.-textattribute above is the Windows-specific correctness fix, not a formatting preference.metaKey-style assumptions (no UI surface in this PR).Risk checked and accepted: pinning an upstream beta means a future upstream bump is a deliberate, reviewable step rather than an implicit one. That is the intent.
Risk checked and accepted: nothing in this repo consumes the xterm bundle sourcemaps at build or run time, so deleting them costs no debuggability that was actually available — the maps that shipped before were already only as good as their offsets.
Security Audit
@xterm/xtermrevision and verifies the generated patch byte-for-byte in CI, which narrows the supply-chain surface compared to a hand-edited patch.pnpm-lock.yamlchanges are the patch-hash update and its peer-suffix propagation only.Notes
Base: #11893. This PR exists to make the two fix PRs above it verifiable — reviewers of #11896/#11897 can read the actual patched
CompositionHelper.tssource.