Repository navigation
Templates: Fixed the preview changing the built theme files and double query strings on asset links - #145
Closed
whereareiam wants to merge 1 commit into
Closed
Templates: Fixed the preview changing the built theme files and double query strings on asset links#145whereareiam wants to merge 1 commit into
whereareiam wants to merge 1 commit into
Conversation
5 of 8 tasks
The preview added ?preview=<revision> to the auto themes' imports in dist/forgejo itself, so src/build-output.test.ts failed after any dev:forgejo session until the next bun bundle. The stamp also went after the path, before the content version the bundle had already appended, which made links with two question marks such as theme-github-dark.css?preview=<id>?v=<hash>. ThemeSynchronizer now copies the built css and js into dev/.generated/public/assets, and the reloader stamps that copy and writes preview-revision.json there. The Compose file mounts it instead of dist, and a sync recreates the container rather than restarting it, so a preview started before this change picks up the new mounts. The revision joins any existing query with &, keeping one query per link. The fixture README explains how to sign in as sam, whose password is preview-fixture like every fixture user other than alex. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
whereareiam
force-pushed
the
chore/build-cleanup
branch
from
October 28, 2026 18:28
370a98b to
2c8a558
Compare
whereareiam
force-pushed
the
fix/preview-dist-stamp
branch
from
October 28, 2026 18:28
e19839e to
1fed0d9
Compare
5 of 8 tasks
Owner
Author
|
Landing as part of #147, which carries this commit rebased onto |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The local preview edited the build in
dist/forgejodirectly to make open pages reload. That caused two problems:?preview=<revision>to the auto themes'@imports indist/forgejo/public/assets/css. Until the nextbun bundle,src/build-output.test.tsthen failed, because it compares those files withdist/<auto>.css.bun bundlehad already added. Links ended up liketheme-github-dark.css?preview=<id>?v=<hash>, so the content version became part of the preview parameter.What changed:
ThemeSynchronizer.stage()copies the builtcssandjsintodev/.generated/public/assets. It empties the mounted folders and refills them, rather than replacing them. The reloader stamps that copy and writespreview-revision.jsonthere, sodiststays exactly asbun bundlewrote it.dev/docker-compose.ymlmountsdev/.generated/public/assets/{css,js}instead ofdist.bun dev:forgejo:syncand the watcher now recreate the Forgejo container instead of restarting it (up -d --force-recreate --no-deps). This way a preview started before this change picks up the new mounts. The data volume stays.&, e.g.?v=<hash>&preview=<rev>. This applies to auto-theme imports and template links. The browser-side reload script already usedURLSearchParamsand needed no change.dev/fixtures/README.mdexplains how to sign in assam: turn off the automatic sign-in withFORGEJO_PREVIEW_AUTO_LOGIN=false bun dev:forgejo:sync, sign out, then sign in withpreview-fixture(FIXTURES.userPassword). README and ARCHITECTURE describe the preview's own copy of the build.bun dev:forgejo,bun dev:forgejo:syncandbun dev:forgejo:watchrun the same steps as before. They now copy the build intodev/.generatedbefore stamping it.Checks
src/preview-reloader.test.tswas rewritten against adist/forgejolaid out likebun bundleoutput, including the?v=versions. The tests check that:diststays as built;dev/.generated.bun bundleand all 458 tests pass. I also ran the prepare steps against a real build and found no link with two?;src/build-output.test.tsstill passed afterwards.bun lintdoes not run in this environment: typescript-eslint does not support the installed TypeScript 7. It fails the same way ondev.Stacked on #144: review only the last commit; GitHub retargets this pull request to
devonce the one below is merged.Release notes
Area: Descriptionwith a listed areaBranches: Fixed ...feature,change,bug,dependencies, orskip-changelogbugonly for a bug that shipped in a release; a fix for a bug that only existed ondevisskip-changelogmajoradded when admins must act on upgrade, for example a new minimum Forgejo version.github/release-notes.md, if admins need themChecks
🤖 Generated with Claude Code