Skip to content

refactor(core): refine artwork handling, notifications, and security#48

Merged
flexiondotorg merged 6 commits intomainfrom
refine
Mar 25, 2026
Merged

refactor(core): refine artwork handling, notifications, and security#48
flexiondotorg merged 6 commits intomainfrom
refine

Conversation

@flexiondotorg
Copy link
Copy Markdown
Member

Summary

This branch refines the Sidra codebase across five areas identified in code review:

  • Artwork module rewrite: replaced https.get with net.fetch, atomic .tmp file writes with rename-on-success, UUID-based persistent cache keys extracted from Apple CDN URLs, unique tmp suffixes to prevent concurrent download race conditions, cache hit and download success logging
  • Notifications robustness: added missing .catch() handler, will-quit cleanup, non-blocking artwork download via Promise.race with 500ms fallback
  • MPRIS log clarity: "artwork cached" message renamed to "mpris:artUrl updated to local file"
  • CSP hardening: Content-Security-Policy meta tags added to splash and about windows; about window image reference aligned to use relative path (removing file:// construction and file: CSP directive)
  • Documentation: explanatory comment in i18n.ts, JSDoc microsecond annotation on PlayerEvents.playbackTimeDidChange
  • CI fix: latest*.yml electron-updater manifests now included in release asset uploads
  • autoUpdate: "No published versions on GitHub" handled gracefully at info level; unhandled promise rejection fixed

Changes

  • Rewrote artwork download with atomic file writes and persistent cache keys
  • Simplified MPRIS artwork URL logging
  • Added CSP headers to security-sensitive windows
  • Strengthened notifications error handling and cleanup
  • Improved log messages for clarity
  • Fixed CI manifest uploads and autoUpdate error handling

Testing

  • Artwork downloads with concurrent requests verify unique tmp file handling
  • Notifications cleanup verified on app quit
  • CSP headers validated in splash and about windows
  • autoUpdate graceful degradation with missing releases confirmed

…ersistent cache

- Replace https.get() with net.fetch() for consistent error handling
- Implement atomic writes using .tmp files with rename-on-success
  pattern
- Replace in-memory lastArtworkUrl/lastArtworkPath with URL-derived
  filesystem cache
- Extract UUID from Apple CDN artwork URLs for human-readable,
  deterministic cache keys
- Use unique .tmp suffixes per invocation to prevent concurrent download
  race conditions
- Add cache hit and download success logging
- Fix robustness issues in notifications integration: add missing
  .catch() handlers, implement will-quit cleanup, ensure non-blocking
  artwork downloads

Signed-off-by: Martin Wimpress <code@wimpress.io>
- Add Content-Security-Policy meta tags to splash.html and about.html
  with policy: default-src 'none'; style-src 'unsafe-inline';
  script-src 'unsafe-inline'; img-src 'self'
- Align about.html image reference to use relative path (sidra-logo.png)
  instead of file:// absolute path, matching splash.html
- Remove icon query parameter and file:// handling from about.html
  and src/tray.ts

CSP prevents inline script and style injection while restricting image
loads to local files, reducing attack surface for window content. Image
alignment ensures both auxiliary windows follow consistent asset
patterns.

Signed-off-by: Martin Wimpress <code@wimpress.io>
- Explain module-level readFileSync usage in i18n.ts
- Document playbackTimeDidChange unit (microseconds) in PlayerEvents

Signed-off-by: Martin Wimpress <code@wimpress.io>
Add release/latest*.yml to artefact and release upload globs in builder
workflow. This enables electron-updater to locate manifest files
required for reporting available updates.

Manifests are generated by electron-builder but were excluded from
uploads.

Signed-off-by: Martin Wimpress <code@wimpress.io>
…dled rejection

- Remove duplicate error logging from try/catch and error event handler
- Swallow re-thrown error from checkForUpdates() with .catch(() => {})
- Filter "No published versions" to [info] level instead of [error]

Prevents unhandled promise rejection warnings when GitHub releases are
not yet published. The autoUpdater still checks for updates; missing
manifests log as info-level and do not disrupt the app.

Signed-off-by: Martin Wimpress <code@wimpress.io>
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 11 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/integrations/notifications/index.ts">

<violation number="1" location="src/integrations/notifications/index.ts:24">
P2: Handle downloadArtwork rejections even when the timeout wins; otherwise a late rejection becomes an unhandled promise rejection.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Add .catch() to downloadArtwork promise inside Promise.race to prevent
unhandled rejection if the timeout wins the race. Maintains existing
error handling pattern with warn-level logging.

Signed-off-by: Martin Wimpress <code@wimpress.io>
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

0 issues found across 1 file (changes from recent commits).

Requires human review: Contains a significant rewrite of the artwork module, lifecycle event management in notifications, and CI/CD workflow modifications which require human review.

@flexiondotorg flexiondotorg merged commit 30095e8 into main Mar 25, 2026
12 checks passed
@flexiondotorg flexiondotorg deleted the refine branch March 25, 2026 21:43
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