Repository navigation
Conversation
|
Important Review skippedWe couldn't safely recover the incremental review. No full review was started, and the last reviewed checkpoint was preserved. Retry later, or explicitly request a full review by commenting You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review. 📝 WalkthroughWalkthroughThe change limits desktop and mobile xterm contrast caches to 4096 entries and adds tests for eviction and reset behavior. It adds mobile patch profile and regeneration support, parameterizes patch generation inputs, and verifies both patch sets in CI. New DOM and WebGL audits measure cache retention and rendering behavior before and after the change. Documentation records the mobile patch process and audit results. Priority: ⬇️ Low Merge Risk: 🔵 Low · up to The payload expectation change is narrow, but the supporting WebGL audit still lacks verified evidence that contrast is recalculated after cache clearing. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Warning Git: CodeRabbit could not clone the repository, so clone-backed analysis was skipped and this review may be incomplete. Verify repository clone access, such as SSH credentials, before requesting another full review. If clone access is intentionally unavailable, use Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 89ea4405-5896-46ac-9cac-cafeb9858ba8
⛔ Files ignored due to path filters (2)
mobile/pnpm-lock.yamlis excluded by!**/pnpm-lock.yamlpnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (20)
.github/workflows/mobile.yml.github/workflows/pr.ymlconfig/patches/@[email protected]config/patches/xterm-src/@[email protected]config/scripts/pr-code-change-scope.test.mjsconfig/scripts/regenerate-xterm-patches-mobile.mjsconfig/scripts/regenerate-xterm-patches-mobile.test.mjsconfig/scripts/regenerate-xterm-patches.mjsconfig/scripts/xterm-contrast-cache.test.mjsdocs/audits/terminal-contrast-cache-retention/README.mddocs/audits/terminal-contrast-cache-retention/reproduce-dom.mjsdocs/audits/terminal-contrast-cache-retention/reproduce.mjsdocs/audits/terminal-contrast-cache-retention/results-dom.jsondocs/audits/terminal-contrast-cache-retention/results-mobile-dom.jsondocs/audits/terminal-contrast-cache-retention/results.jsondocs/reference/xterm-patch-regeneration.mdmobile/patches/@[email protected]mobile/patches/xterm-src/@[email protected]mobile/pnpm-workspace.yamlmobile/src/terminal/terminal-webview-contrast-cache.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This run reviewed the full 22-file diff: the vendored xterm ColorContrastCache bound, the regenerated desktop and mobile patches, the mobile patch-variant generator, the CI wiring, and the new tests and audit artifacts.
- Contrast-cache bound —
ColorContrastCacheadmits at most 4096 combined color/CSS entries per instance, flushes on overflow, and resets its counter onclear(); the desktop and mobile source and bundle patches are regenerated together with lockfile hashes. - Mobile patch variant —
regenerate-xterm-patches-mobile.mjsderives a contrast-only profile from the desktop manifest and source, andregenerate-xterm-patches.mjsgains injectablemanifest/lockfileRelativePathparameters; mobile excludes the desktop IME/SortedList hunks. - CI wiring —
pr.ymlruns desktop and mobile--checkin onexterm_patch_syncstep;mobile.ymladds a standalone mobile check. - Tests and audit — unit coverage for the bound and the generator, a generated-engine mobile test, and reproduction scripts/results under
docs/audits/terminal-contrast-cache-retention/.
I verified the fix is real rather than asserted: the patched package installs and lib/xterm.js carries the bound, xterm-contrast-cache.test.mjs fails with the admit logic removed (2 of 3 tests) and passes with it, the generator and change-scope suites pass, the _entryCount invariant is exact (never more than 4096 entries, no stale values returned), and the mobile patch contains exactly the expected four bundle/map hunks plus the source stanza with no desktop-only changes.
ℹ️ Edits to the shared patch-text layer bypass the patch-sync checks
config/scripts/xterm-patch-text.mjs drives both generators' patch formatting and stanza selection, and this PR newly makes the mobile generator depend on it, but it matches neither XTERM_PREFIXES nor mobile.yml paths. This predates the PR, so it is not a blocker, but it is worth knowing: a change to that file alone schedules no pinned-build --check.
Technical details
# xterm-patch-text.mjs is not a patch-sync trigger
## Affected sites
- `config/scripts/pr-code-change-scope.mjs:69-74` — `XTERM_PREFIXES` lists `config/patches/xterm-upstream.json`, `config/patches/@xterm`, `config/patches/xterm-src/`, `config/scripts/regenerate-xterm-patches`; `xterm-patch-text.mjs` matches none.
- `.github/workflows/mobile.yml:10-19` — `paths` is `mobile/**` plus named shared files; nothing under `config/scripts/`.
## Why it matters
`splitPatchEntries`/`selectPatchEntries` choose the mobile contrast stanza, and
`normalizePnpmDiff`/`PNPM_DIFF_FLAGS`/`CHECKOUT_DIFF_FLAGS` define the emitted patch
bytes. Editing any of those with no accompanying `config/patches` change schedules
neither `pr.yml` `xterm_patch_sync` nor the new `mobile.yml` step, so the committed
`.patch` files and their lockfile hashes can drift from what the generator now emits
with no failing gate.
## Note on the added classification test
`config/scripts/pr-code-change-scope.test.mjs:183-185` asserts
`config/scripts/regenerate-xterm-patches-mobile.mjs` is `xterm_patch_sync: true`, but
`matchesPrefix` uses `startsWith` and the pre-existing prefix
`config/scripts/regenerate-xterm-patches` already matches that file, so the assertion
passes before and after this PR.
## Suggested approach (optional)
If coverage here is desired: add `config/scripts/xterm-patch-text` to `XTERM_PREFIXES`
and to the `mobile.yml` `paths` list. Not required for this PR.DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This run reviewed the single commit added since the prior pullfrog review (05caeb6df1): a test-only update to the mobile WebView payload guard that tracks the contrast-patched engine shipped by the earlier commits.
- Payload hash guard re-pinned —
mobile/src/terminal/terminal-webview-payload-hash.test.ts:9-10updates the expectedXTERM_HTMLSHA256 (25b800f…→bdd9b21…) and length (730472→730693) for the contrast-only mobile engine. The exacttoBeassertions mean the guard still fails on any unintended document change.
Verified against the real toolchain: pnpm install --frozen-lockfile in mobile/ applies the contrast-only patch (mobile ColorContrastCache.ts carries CONTRAST_CACHE_MAX_ENTRIES = 4096), rebuilds the engine, and the updated test passes with the new constants.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
47bb299 to
94105d9
Compare
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This run reviewed the single commit added since the prior pullfrog review (c455f5c669): a test-only change that decouples the mobile contrast-cache test from the generated WebView engine bundle.
- Mobile cache test imports the package directly —
mobile/src/terminal/terminal-webview-contrast-cache.test.tsnow importsTerminalfrom@xterm/xterminstead of evaluating the gitignoredterminal-webview-engine.generated.tsbundle throughnode:vm, matching the two sibling terminal tests that already import the package this way. All assertions are unchanged and exact, and the shipped WebView document stays pinned byterminal-webview-payload-hash.test.ts.
Verified in this environment: a mobile install applies the contrast-only patch (_admitNewEntry / _entryCount / 4096 present in node_modules/@xterm/xterm/lib/xterm.js), the test passes 3/3, and the file is clean under oxlint and typecheck:tests (the 508 other errors there are pre-existing).
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This run reviewed the single commit added since the prior pullfrog review (00ed3625f8): trigger coverage for the shared xterm patch-text generator, plus an audit-script recompute check.
- Patch-text generator now a patch-sync trigger —
config/scripts/xterm-patch-text.mjsis added toXTERM_PREFIXES(config/scripts/pr-code-change-scope.mjs:77) and to theMobile Checkspathsfilters (.github/workflows/mobile.yml:12,:50), so editing the shared patch formatter schedules both thexterm_patch_syncjob (desktop and mobile--check) and the mobile workflow. This closes the informational finding from the earlier pullfrog review. - Classification test added —
config/scripts/pr-code-change-scope.test.mjs:184-186pinsxterm-patch-text.mjstoxterm_patch_sync: true. The assertion is real (it fails without the new prefix), and the suite passes 38/38 here. - Audit recompute check —
docs/audits/terminal-contrast-cache-retention/reproduce.mjs:174-188clears the glyph atlas before re-rendering aftercache.clear()and asserts the contrast cache repopulates (afterRecompute > 0), matching the CodeRabbit proposal;review-validation.jsonrecords the fresh results. - Docs —
README.mdandxterm-patch-regeneration.mddescribe the new trigger and the mobile contrast-only variant.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Important
The mobile WebView payload guard is stale, so Mobile Checks / verify is red on this head. The regenerated mobile contrast patch changed the generated engine, but terminal-webview-payload-hash.test.ts still pins the previous document (AssertionError: expected 730692 to be 730693). Re-pin it before merge.
Reviewed changes
This run reviewed the three commits added since the prior pullfrog review (00ed3625f8): the contrast-cache admission refactor, its regression test, and the widened Mobile Checks trigger.
- Admission counts a pair once —
_admitPairreplaces the per-map_admitNewEntry, so one(bg, fg)pair consumes one of the 4096 slots rather than two. The intermediate_seenmap was dropped in favor of reading the two maps, which are only written through the admitting setters and only ever clear together. - Regression test added —
config/scripts/xterm-contrast-cache.test.mjspins single-count admission across both setters; it fails under the previous per-map logic. - Patches and lockfiles regenerated — the desktop and mobile source/bundle patches and both lockfile
patch_hashes track the new admission code (hashes verified against the committed patch files). - Mobile Checks trigger widened —
mobile.ymlnow runs onconfig/patches/xterm-src/**andconfig/patches/xterm-upstream.json, which the mobile patch generator reads.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
`_admitNewEntry` fired from both `setCss` and `setColor`, so one (bg, fg) pair consumed two of the 4096 slots and the cache actually wiped at ~2048 pairs. Track admission in a `_seen` TwoKeyMap keyed by the pair, cleared with the other maps, so the bound matches the documented constant. Regenerated the desktop and mobile bundle patches and both lockfile hashes.
regenerate-xterm-patches-mobile.mjs derives the mobile patch from the desktop `ColorContrastCache.ts` stanza and `xterm-upstream.json`, so an edit to either changes what the mobile patch check expects while mobile.yml never triggers.
The admission set was a third bounded map inside a patch whose purpose is capping memory. The color and CSS maps only ever clear together, so either one already holding the pair proves it was counted.
The rebase took main's side for the generated bundle patch and lockfile, so this rebuilds both from the merged source stanzas (contrast cap plus main's CJK preedit WidthCache hunk). Also re-pins the mobile WebView payload hash: the _seen-map removal changed the minified engine by one character and the pin was never updated, so the branch head was already failing that test before the rebase.
009e86a to
4f990f2
Compare
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This run reviewed the delta since the prior pullfrog review (009e86addc): a rebase onto current main, regeneration of the desktop xterm bundle patch, and the mobile WebView payload re-pin that fixes the prior review's blocking finding.
- Rebased onto
main— the branch adopts main'squery-string: 9.5.1mobile override and main's CJK preeditWidthCachehunk in the desktop source patch; the mobile source patch stays contrast-only, so the mobile engine payload is unchanged apart from the already-pinned_seenremoval. - Desktop bundle patch and root lockfile regenerated —
config/patches/@[email protected]is rebuilt from the merged source stanzas and the rootpnpm-lock.yamlpatch hash moves toee817998…, matching the committed file. - Mobile payload guard re-pinned —
mobile/src/terminal/terminal-webview-payload-hash.test.ts:9-10now pinsd04f3370…/730692 for the_seen-removal engine, resolving the prior[!IMPORTANT]finding. Verified locally: the payload test passes 1/1 and the mobile contrast-cache test passes 3/3. - Mobile patch registration —
mobile/pnpm-workspace.yamlandmobile/pnpm-lock.yamlregister'@xterm/[email protected]': 45b11f5c…in pnpm 12's single-linepatchedDependenciesform, with every importer/snapshot reference carrying the same hash.
Verified against the pinned toolchain at head 4f990f2b30: the committed desktop and mobile patch sha256 values match their lockfile patchedDependencies; a fresh root pnpm install --frozen-lockfile applies the combined patch, and xterm-contrast-cache.test.mjs (4), regenerate-xterm-patches-mobile.test.mjs (5, including the committed-patch/lockfile-hash consistency assertion) and pr-code-change-scope.test.mjs (38) pass 47/47. CI xterm patch sync is green on this head.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
Closing: this conflicts with main and targets xterm beta.303, while main is on beta.304. The real fix is ~20 lines, but it ships with ~4k lines of audit artifacts, mobile patch tooling, CI edits and lockfile churn. Its own synthetic test needed 100k redraws to grow the heap ~5 MB per terminal. If wanted, this should come back as a ~20-line patch to the beta.304 desktop patch only. |

ELI5
The terminal adjusts text colors when needed to make them readable against the background. It remembers each answer so it can reuse it. Output with endlessly changing colors could make that collection grow forever.
What Changed
Each normal and dim contrast cache now holds at most 4,096 saved answers. When the limit is reached, the cache is cleared; the same color is recomputed if it returns later. Text, themes, colors, and scrollback capacity remain unchanged across desktop and mobile terminals.
Why
Existing glyph cleanup does not clear these color calculations. Bounding them prevents memory growth with every new foreground/background combination.
Synthetic 100,000-redraw tests reduced heap growth from roughly 4–5.5 MB to 0.3–0.4 MB. This demonstrates retention, not the cause of a particular production OOM.
User impact
There is no intended visible difference. Desktop WebGL/DOM and generated mobile WebView controls produced the same colors and pixels after eviction. Workloads cycling through more than 4,096 pairs do more recomputation, so zero CPU cost is not claimed.
Linked Issue
Related to #19831 as memory hardening; incident causality is not established.
Visual Proof
N/A — no intended visual change; before/after colors and pixels match.
Testing
Recorded desktop/mobile rendering, DOM color, patch-sync, typecheck, lint, and cache-overflow controls passed. Audit evidence is in terminal-contrast-cache-retention.
Review
Rebased onto current main at
c455f5c669; the follow-up audit now forces contrast-cache repopulation. #20992 and #21112 are stacked on this PR.