Skip to content

Preserve notification images from localhost file URLs - #13730

Open
Inference1 wants to merge 1 commit into
omacom:quattrofrom
Inference1:fix/notification-localhost-image-persistence
Open

Inference1 wants to merge 1 commit into
omacom:quattrofrom
Inference1:fix/notification-localhost-image-persistence

Conversation

@Inference1

@Inference1 Inference1 commented Sep 29, 2026 •

Copy link
Copy Markdown

Notifications using file://localhost/tmp/avatar.png keep referencing the sender's original file instead of copying it into the notification state directory. If the sender deletes that file, the persisted notification loses its image. localImageFile() removes file:// but then rejects the remaining localhost/... because it does not start with /.

Recognize an exact, case-insensitive localhost authority before decoding the path. This lets the existing persistence flow copy both appIcon and image values and restore them from the cache. Other host authorities remain rejected; themed icons and image:// handling are unchanged. This follows the local-file semantics in RFC 8089.

Regression coverage checks lowercase/uppercase localhost, percent-encoded spaces, single decoding, remote/lookalike hosts, both image roles, serialization/restoration, repeat persistence, and preservation of the live snapshot.

Validation:

  • bash test/shell.d/notifications-test.sh: 152 assertions pass with Node 20.20.2 and Git Bash 5.2.26 on Windows, using a test-launcher-only conversion of ROOT to a Windows path. The new regression fails on the base revision.
  • A separate filesystem probe executed the actual Service.qml persistence function and copy script with Node/Git Bash, replacing only queue scheduling with synchronous execution. Before the fix no cache file was produced; afterwards the persisted PNG remained byte-for-byte intact after deleting the sender's source.
  • git diff --check passes.

@Inference1

Copy link
Copy Markdown
Author

Would you please review this pr

@sanjyay

sanjyay commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

Independent community review

This is an independent community review and unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Tested: localImageFile resolution of file://localhost/... URLs and notification image persistence in an isolated Omarchy test VM environment.

Result: The change behaved as expected. The base branch reproduces the issue: passing file://localhost/tmp/... strips file:// leaving localhost/tmp/..., which fails the leading-slash check and returns an empty string, preventing persistablePopup from staging copies of sender-owned images into the notification state cache before the sender deletes or modifies them. With s.replace(/^localhost\//i, "/"), localhost authorities are recognized per RFC 8089 Section 2, paths resolve to /tmp/..., and both appIcon and image copies are properly scheduled, persisted, and restored.

Testing details
  • Tested PR commit: 9452128ad37c58cc9763c3ef7f4bf4e2ba5a21cb
  • Base comparison:
    • Base (origin/quattro): Running test/shell.d/notifications-test.sh with the new assertions reproduces the failure:
      expected: /tmp/logo a.png
      actual:   
      not ok - notifications resolve localhost file URLs to copyable paths: file://localhost/tmp/logo%20a.png
      
    • PR branch (pr-13730): All 152 assertions in test/shell.d/notifications-test.sh pass cleanly, including:
      • Case-insensitive localhost resolution (file://localhost/... and file://LOCALHOST/...)
      • Single URI decode safety (file://localhost/tmp/logo%2520a.png -> /tmp/logo%20a.png)
      • Rejection of remote and lookalike authorities (file://remote/..., file://localhost.example/...)
      • Dual image role persistence (appIcon and image) and cache restoration
  • Test suites & validation:
    • bash test/shell.d/notifications-test.sh: 152 assertions passed.
    • bash test/shell.d/notification-send-test.sh: 17 assertions passed.
    • bin/omarchy commands --check: passed across 467 commands.
    • git diff --check origin/quattro: clean.

If you'd prefer not to receive these independent reviews on your PRs, reply to this comment, and I won't review your future PRs.

@omarchybot omarchybot added bug Something isn't working verified Omarchy Triage has verified that this issue is ready for final review labels Oct 3, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at 9452128 against quattro, and the fix holds.

Reproduced on an Omarchy worker VM. With base, notify-send -h string:image-path:file://localhost/tmp/....png was persisted still pointing at the sender's file, and no copy was made in the notification images directory. With this branch the PNG is copied there, the persisted entry points at the copy, and the copy is intact after the sender's file is deleted.

Tests on the worker: test/shell.d/notifications-test.sh passes on this branch (152) and fails with the NotificationLogic.js change reverted, at the new localhost assertion. notification-send-test.sh passes (17). ./test/cli has one failure, vscode generated theme references current theme file, and it fails the same way on the merge base, so it has nothing to do with this change.

Second opinion: Codex Medium reviewed the diff and found no defect. It checked lookalike hosts, localhost%2F, a missing path, and decoding order, and confirmed from Quickshell's source that file://localhost values reach Omarchy unchanged. Since it agrees with this review, take that as agreement rather than an independent check. Its one note: the test labelled "copy both localhost image roles before the sender can remove them" checks the planned copies, not an actual copy or deletion. That doesn't change behaviour.

No other open pull request fixes this. #12111 rewrites the same localImageFile function with a path allowlist, so whichever lands second will need a small conflict resolved.

Labelled verified. Nothing is needed from you. It is waiting on the maintainer, plus a green full suite once the unrelated vscode test failure on quattro is fixed, and CI, which hasn't reported on this branch.

@omarchybot omarchybot removed the verified Omarchy Triage has verified that this issue is ready for final review label Oct 20, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Re-reviewed against quattro at 087f73d, since this branch no longer merges: quattro has since removed the code this fixes, so there is nothing left here to port.

NotificationLogic.js, including localImageFile(), went in 4671ae2 ("Replace the notification engine with Omapager's stacks, snoozes and panel"). The new engine does not copy sender images into its state at all. Store.sanitiseForPersistence() clears image before anything is written (shell/plugins/notifications/Store.js:350), image is not among the stored fields (Store.js:163), and appIcon is kept only as a theme icon name, never a path (Store.js:107). So a restored notification can no longer point at a file the sender has since deleted, whether its URL names localhost or not, and the copy this PR fixed for file://localhost/ has no counterpart left to fix.

One related point is now the maintainer's call rather than a port of this change. The new Security.localImagePath() accepts only file:/// URLs (shell/plugins/notifications/Security.js:97), so a live notification whose image is file://localhost/... shows no picture. Its tests list file://localhost/tmp/a.png among the inputs it must reject (test/shell.d/notifications/logic.cjs:187), so that refusal is deliberate. Accepting a localhost authority there would be a separate change.

This was checked by reading quattro's source. Nothing ran on a worker, because there was no fix left to run. Codex Medium reviewed the same question as a second opinion and reached the same conclusion, citing the same lines; its independence from this review is not guaranteed. This now waits on the maintainer, and the recommendation is to close it as superseded by 4671ae2. Thank you for the careful fix and tests: the bug was real on the engine it was written for.

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants