Skip to content

fix(assets): non-media assets, assets:// paths on Linux, theme before first paint, published pages icons - #13898

Open
yuxi-liu-wired wants to merge 4 commits into
logseq:masterfrom
yuxi-liu-wired:fix/dbtest-assets
Open

yuxi-liu-wired wants to merge 4 commits into
logseq:masterfrom
yuxi-liu-wired:fix/dbtest-assets

Conversation

@yuxi-liu-wired

@yuxi-liu-wired yuxi-liu-wired commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Fixes logseq/db-test#1437, Fixes logseq/db-test#1231, Fixes logseq/db-test#962, Fixes logseq/db-test#1412.

One commit per issue, each with its test.

#1437: non-media asset files render as plain text

What the user sees: dropping or uploading a .txt, .xlsx or .docx file copies it to the graph's assets folder, but the block shows only the file name as plain text, in editing mode and after leaving it.

Cause: block-title sent only pdf asset blocks to asset-cp, and the block content path only images, audio and video (img-audio-video?). Every other type fell through to text-block-title. asset-link already has the open (Electron) and download (web) branch for these types, but nothing reached it. The "second upload inserts nothing" part is by design: new-asset-block warns that the asset already exists and inserts no block.

Change: block-title sends every asset block that is not an image, audio or video to asset-cp (pdf as before). Media blocks are unchanged, their content path renders the media and keeps the editable title below it.

Test: non-media-asset-title-renders-as-asset-link-test (pdf, txt, xlsx, docx expect the asset component; png, mp3, mp4 still get the title only). On master it fails for txt, xlsx and docx.

Not checked at runtime: I did not drop a file into a running app.

#1231: Electron assets:// handler gets the host eating the leading slash

What the user sees: adding an asset on Linux logs resolve-assets-url Unknown assets url assets://home/... in the console, and the handler passes a relative path to Electron.

Cause: the renderer builds assets:///home/me/graph/assets/a.png, but the assets scheme is registered standard, so Chromium reads home as the host and the handler receives assets://home/me/.... After removing the prefix the path has no leading slash and fell to the :else branch. Only Windows had a branch for this form (UNC paths).

Change: the path resolution moves to electron.assets-protocol/url->file-path (no Electron requires, so it can be unit tested). A path without a leading slash is an absolute path on macOS and Linux and stays a UNC path on Windows. The handler in electron.core calls it.

Test: url->file-path-test (host-eaten form, three-slash form, percent escapes with query and fragment, Windows UNC and drive forms). On master the host-eaten form returns the relative path and the test fails.

Not checked at runtime: I did not run Electron and did not log request.url; the two-slash form comes from the reporter's log. Chromium also lowercases a host, so a first path segment with capital letters (for example /Media/... on Linux) would reach the handler lowercased; that cannot be recovered in the handler and is not changed here.

#962: Electron window is white before the theme is applied

What the user sees: with the dark theme the window opens white and switches to dark after the app has loaded, which takes seconds with plugins.

Cause: the window is shown on ready-to-show, after index.html has painted, but data-theme is set by the app only after it mounts (theme.cljs), so until then the page uses the light defaults.

Change: resources/index.html gets an inline script (#theme-boot) that reads the stored theme and system-theme? from localStorage and sets data-theme and the dark class on the root element before the first paint. It mirrors the initial state in frontend.state: the system theme follows prefers-color-scheme, a first start uses it on macOS and Windows and light on Linux. The window's :backgroundColor is not changed: the window is hidden until ready-to-show, and the main process cannot read the renderer's stored theme.

Test: stored-theme-is-applied-before-the-app-mounts-test runs the boot script from resources/index.html against fake browser globals (stored dark, stored light with a dark system, system theme both ways, first start on macOS and Linux). On master the file has no boot script and every assertion fails.

Not checked at runtime: I did not start Electron with a dark theme and look at the first paint.

#1412: exported public pages never load tabler.ext.js

What the user sees: in a page exported with "Export public pages" (SPA HTML) the Status property shows no icon.

Cause: the status icons (Backlog, InProgress50, ...) are custom icons defined only in static/js/tabler.ext.js, which resources/index.html loads. The generated index.html never included it, so the icon lookup falls back to an empty font icon. It was dropped by the "SPA HTML export renders blank page" rework (b517311).

Change: publishing-html lists static/js/tabler.ext.js (deferred, like the other scripts that are not needed before main.js). The file is already copied with the static js directory.

Test: published-html-loads-tabler-ext-js (deps/publishing, nbb) builds the HTML for a small graph and checks the script list. On master it fails.

Proof

Not in this PR

  • feat: prevent wheel event when sidebar on boundary #971 (image placeholder (or width 250 asset-width)): not changed, because it needs a maintainer's choice and does not reproduce as a code defect. 250 is the default display width on purpose: the same img-metadata is also applied to the real <img>, so with stored asset/width and asset/height the placeholder and the image have the same size, and asset-width being unreachable in the or changes nothing. Images that were never rendered (for example after an import) have no stored size, so neither the placeholder nor the unloaded <img> can reserve a height until asset-container measures it on first render; fixing the jump means either guessing an aspect ratio for the placeholder or storing the size at import, which is a design decision, and a scroll jump cannot be reproduced in a unit test.

Devin Review

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@yuxi-liu-wired
yuxi-liu-wired force-pushed the fix/dbtest-assets branch 3 times, most recently from 458e0cf to 7b03117 Compare November 3, 2026 12:02
@yuxi-liu-wired
yuxi-liu-wired force-pushed the fix/dbtest-assets branch 8 times, most recently from 637d4cd to 9a66e4f Compare November 18, 2026 14:01
…render

In a page exported with "Export public pages" (SPA HTML), the Status property showed no icon: Todo, Doing, Done and the other status values rendered as empty.

The status icons (Backlog, InProgress50, ...) are custom icons that exist only in static/js/tabler.ext.js, which the app's own index.html loads. The generated index.html never included that script, so the icon lookup fell back to an empty font icon. The script was dropped when the exported script list was reworked.

Add tabler.ext.js to the script list in publishing-html. The file is already copied with the static js directory.

Test: published-html-loads-tabler-ext-js builds the HTML for a small graph and checks that the script list contains static/js/tabler.ext.js.

Fixes logseq/db-test#1412
Uploading a .txt, .xlsx or .docx file to a block copied the file into the graph's assets folder but the block only showed the file name as plain text, in editing mode and after leaving it.

block-title routed only pdf asset blocks to asset-cp, and the block content path only images, audio and video. Every other asset type fell through to text-block-title, which prints the title. asset-link already has a branch that opens the file (Electron) or downloads it (web), but nothing reached it for these types.

block-title now sends every asset block that is not an image, audio or video to asset-cp, which includes pdf as before. Media blocks are unchanged: their content path renders the media and keeps the editable title below it.

Test: non-media-asset-title-renders-as-asset-link-test renders block-title for pdf, txt, xlsx and docx asset blocks and expects the asset component, and for png, mp3 and mp4 expects the title only.

Fixes logseq/db-test#1437
…g slash

Adding an asset on Linux logged "resolve-assets-url Unknown assets url assets://home/..." in the console, and the handler passed a relative path to Electron.

The renderer builds assets:///home/me/graph/assets/a.png, but the assets scheme is registered as standard, so Chromium reads the first path segment as the host and the handler receives assets://home/me/graph/assets/a.png. After the prefix is removed the path has no leading slash, which the handler treated as an unknown URL. Only Windows had a branch for this form (UNC paths).

Move the path resolution to electron.assets-protocol/url->file-path. A path without a leading slash is an absolute path on macOS and Linux, and stays a UNC path on Windows.

Test: url->file-path-test covers the host-eaten form, the three-slash form, percent escapes with a query and fragment, and the Windows UNC and drive forms.

Fixes logseq/db-test#1231
With the dark theme selected, Logseq opened as a white window and switched to dark only after the app had loaded, which can take seconds with plugins.

The window is shown as soon as index.html has painted, but data-theme is set by the app only after it mounts, so until then the page uses the light default variables.

index.html now has an inline script that reads the stored theme and the system-theme flag from localStorage and sets data-theme and the dark class on the root element before the first paint. It follows the same rules as the initial theme state: the system theme follows prefers-color-scheme, and a first start uses it on macOS and Windows and light on Linux.

Test: stored-theme-is-applied-before-the-app-mounts-test runs the boot script from resources/index.html against fake browser globals for a stored dark theme, a stored light theme with a dark system, the system theme in both directions, and a first start on macOS and Linux.

Fixes logseq/db-test#962

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

1 participant