perf(overlay): only ship editor assets to pages that mount an editor

Addresses Important #2 from the final code review.

The asset partial was previously included unconditionally for any
overlay detail page. Workshop overlays and read-only files-type
overlays (when the viewer isn't the owner or admin) have no
data-editor-language textarea, so the ~30 KB of Prism + CodeJar + JS
+ CSS shipped pointlessly. Gate the include on the two cases that
actually mount an editor: script-type overlays (bash editor) and
files-type overlays where the current user has edit rights (the
files-editor modal).

I-1 from the review (race window during "Loading…") was confirmed
moot — editorDialog.showModal() only fires after the fetch resolves
(files-overlay.js:409), so the dialog is invisible during the
fetch-and-placeholder window and the user can't type into it.

I-3 (Playwright coverage of the language dropdown override) is real
follow-up work that needs a new files-type overlay seed in the
live_server fixture. Deferred as a v2 ticket.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
mwiegand 2026-05-16 22:25:44 +02:00
parent 7b54d1348b
commit 5bec91ab17
No known key found for this signature in database

View file

@ -282,5 +282,11 @@
<script src="{{ url_for('static', filename='js/files-overlay.js') }}" defer></script>
{% endif %}
{% include '_editor_assets.html' %}
{# Only include the ~30 KB of editor assets on pages that actually mount
an editor: script-type overlays (bash editor) and files-type overlays
that the current user can edit (the files-editor modal). Workshop
overlays and read-only pages skip the include entirely. #}
{% if overlay.type == 'script' or files_can_edit %}
{% include '_editor_assets.html' %}
{% endif %}
{% endblock %}