Skip to content

fix(build): auto-invalidate stale .materialized cache when overlay changes - #1057

Merged
jeonghun-jj-lee merged 1 commit into
mainfrom
fix/stale-materialized-cache
Sep 13, 2026
Merged

fix(build): auto-invalidate stale .materialized cache when overlay changes#1057
jeonghun-jj-lee merged 1 commit into
mainfrom
fix/stale-materialized-cache

Conversation

@jeonghun-jj-lee

Copy link
Copy Markdown
Contributor

Problem

build_app_bundle.mjs reuses .materialized when package.json exists, regardless of whether the overlay has changed since the last materialization. After an overlay sync (e.g. PR #1011 syncing the startsWith fix from opencode PR #337), a local rebuild silently ships the old bundle because the cached tree still contains the pre-fix source.

This is what caused the TypeError: Cannot read properties of undefined (reading 'startsWith') to persist in the installed extension even though the source code fix was merged and the overlay was synced.

Fix

Read manifest.json's fork_sha + promoted_at as the overlay version identity. Compare it against a .overlay-stamp file inside .materialized:

  • Stamp differs or missing → wipe the cached tree and re-materialize
  • Stamp matches → reuse the cache (existing fast path)
  • Backfill — existing trees without a stamp get one written on first build (no unnecessary wipe)

The --direct-worktree and --verified-main modes are excluded from this check (they manage their own trees).

Testing

Verified all three paths locally:

Scenario Result
No stamp (first build / old tree) Detected stale, re-materialized, stamp written
Stamp matches manifest Cache reused, no re-materialize
Stamp differs (simulated with fake stamp) Detected stale, wiped, re-materialized

…anges

The build_app_bundle.mjs script reuses .materialized when package.json
exists, regardless of whether the overlay has changed. This means a
local rebuild after an overlay sync silently ships the old bundle —
which is how the startsWith-undefined-title fix (PR #337 / #1011)
failed to reach the installed VSIX despite the source being correct.

Fix: read manifest.json's fork_sha + promoted_at, compare against a
.overlay-stamp file inside .materialized, and wipe + re-materialize
when they differ. The stamp is written after each materialization and
backfilled for existing trees on the first run.
@coderabbitai

coderabbitai Bot commented Sep 13, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 06d6ca7f-9623-450b-9e3f-2f554bc55b24


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@jeonghun-jj-lee
jeonghun-jj-lee merged commit bcd19f8 into main Sep 13, 2026
10 checks passed
@jeonghun-jj-lee
jeonghun-jj-lee deleted the fix/stale-materialized-cache branch September 13, 2026 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant