Skip to content

feat(tray): add now playing section with playback controls#53

Merged
flexiondotorg merged 6 commits intomainfrom
now-playing
Mar 26, 2026
Merged

feat(tray): add now playing section with playback controls#53
flexiondotorg merged 6 commits intomainfrom
now-playing

Conversation

@flexiondotorg
Copy link
Copy Markdown
Member

Summary

Adds a comprehensive Now Playing section to the tray context menu, displaying current playback information and providing intuitive controls. The feature mirrors Discord's pause timeout behaviour and includes a volume submenu with percentage display.

Changes

  • Add Now Playing section showing track metadata, artist, and album
  • Implement playback control buttons with state-aware labels (Play/Pause, Next, Previous)
  • Add volume submenu with percentage display and mute toggle
  • Implement metadata truncation (32 characters, split on ( or [)
  • Add 30-second pause timeout to auto-resume playback
  • Fix Pango markup escaping for Linux tooltip compatibility
  • Fix ampersand handling in menu labels on Linux
  • Add comprehensive test coverage for menu label truncation
  • Update SPECIFICATION.md with feature documentation
  • Add localisation strings for all new menu items

Testing

  • Manual verification of now playing display with various track lengths
  • Playback control interaction testing
  • Volume control slider testing
  • Pause timeout behaviour validation (30s mirror of Discord)
  • Linux-specific Pango markup and ampersand escaping verification
  • Test coverage for truncateMenuLabel function

Related Issues

Implements tray Now Playing feature as specified in SPECIFICATION.md

Add tray tooltip functionality to display the currently playing track
name and artist. Updates tooltip on track changes and resets when
playback stops.

- Add updateTrayTooltip function to format and display track metadata
- Listen to nowPlayingItemDidChange events and update tooltip with
  track information
- Listen to playbackStateDidChange events to clear tooltip when
  playback ends
- Ignore null payloads in nowPlayingItemDidChange to prevent tooltip
  reset during track transitions
- Include debug logging for tooltip updates

Signed-off-by: Martin Wimpress <code@wimpress.io>
- Add Now Playing section at top of tray context menu with track name,
  artist, and album using Linux-specific glyphs
- Implement playback controls (Previous/Play/Pause/Next) with
  state-aware icons and Linux glyph symbols
- Add Volume submenu with radio items (Mute/25%/50%/75%/100%) showing
  current volume level as percentage
- Implement metadata truncation: split on first `(` or `[`,
  hard-truncate at 32 chars with ellipsis
- Rebuild menu on track change, playback state change, and volume change
- Clear Now Playing section after 30 seconds of pause to mirror Discord
  integration behaviour
- Add i18n support with 20 new tray.json records across 32 languages

Signed-off-by: Martin Wimpress <code@wimpress.io>
- Add test suite for metadata truncation logic
- Verify splitting on `(` and `[` characters
- Confirm 32-character hard truncation with ellipsis
- Ensure edge cases are handled (empty strings, already short values)

Signed-off-by: Martin Wimpress <code@wimpress.io>
- Replace & with fullwidth ampersand (U+FF06) in track/artist/album
  names to prevent Pango markup entity parsing on Linux
- Add sanitiseLinuxLabel helper and apply on Linux for menu labels only
- Retain Pango escaping for tooltip text which is handled separately
- Add test coverage for sanitiseLinuxLabel with 4 test cases

Signed-off-by: Martin Wimpress <code@wimpress.io>
- Document Now Playing section with metadata items and glyphs
- Document playback controls (Previous/Play/Pause/Next)
- Document Volume submenu with preset levels
- Document metadata truncation at 32 characters
- Document menu rebuild triggers and pause timeout behavior
- Document Tray subsection with Linux glyph conventions

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.

4 issues found across 7 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="AGENTS.md">

<violation number="1" location="AGENTS.md:208">
P3: The documented total translation record count is incorrect (29 vs actual 30), which makes the i18n reference inconsistent.</violation>
</file>

<file name="docs/SPECIFICATION.md">

<violation number="1" location="docs/SPECIFICATION.md:748">
P3: The Tray glyph convention says no `U+1F000+` codepoints are used, but this same section includes `🞂` and `🕪` (`U+1F782`/`U+1F56A`). Update the sentence so the spec matches the documented labels.</violation>
</file>

<file name="src/tray.ts">

<violation number="1" location="src/tray.ts:53">
P3: truncateMenuLabel can exceed the maxLength because it appends the ellipsis after taking maxLength characters. Trim to maxLength - 1 before adding the ellipsis so the final label stays within the limit.</violation>
</file>

<file name="src/main.ts">

<violation number="1" location="src/main.ts:404">
P2: The async artwork download can race across track changes and apply stale Now Playing data to the tray. Guard against outdated async completions before updating state.</violation>
</file>

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

- Add staleness guard to artwork download handler to prevent overwriting
  current track state with stale async results on rapid track changes
- Correct translation record count from 29 to 30 in AGENTS.md
- Clarify tray glyph convention in SPECIFICATION.md: seven glyphs use
  Unicode blocks in U+1F000+ range, not all below as previously stated

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 3 files (changes from recent commits).

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/main.ts">

<violation number="1" location="src/main.ts:407">
P2: Avoid reference-identity checks for stale artwork guards; compare a deterministic track key instead so equivalent payload objects don't incorrectly cancel artwork updates.

(Based on your team's feedback about avoiding reference-identity guards in artwork update paths.) [FEEDBACK_USED]</violation>
</file>

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

@flexiondotorg flexiondotorg merged commit bd1f5c1 into main Mar 26, 2026
12 checks passed
@flexiondotorg flexiondotorg deleted the now-playing branch March 26, 2026 02:56
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