Skip to content

fix(player): open and reveal the PodNotes view from "Play with PodNotes" (#84)#198

Merged
chhoumann merged 1 commit into
masterfrom
chhoumann/84-play-with-podnotes-broken
Jun 16, 2026
Merged

fix(player): open and reveal the PodNotes view from "Play with PodNotes" (#84)#198
chhoumann merged 1 commit into
masterfrom
chhoumann/84-play-with-podnotes-broken

Conversation

@chhoumann

Copy link
Copy Markdown
Owner

Summary

Right-clicking an audio file and choosing Play with PodNotes now reliably opens and reveals the PodNotes player and starts playback, even when the PodNotes pane is closed or hidden in a collapsed sidebar.

Closes #84.

Background

Issue #84 (filed on Obsidian 1.4.1 / PodNotes 2.10.8) reported three symptoms: the action didn't open the player pane, didn't play, and showed a broken miniature with DOMException: The element has no supported sources.

The playback-source half was already fixed by #100 / #184, which replaced in-memory blob: URLs with app.vault.getResourcePath() and replaced an extension regex that matched every file with an explicit allow-list. I verified this on current master in a real Obsidian instance (isolated e2e vault, real MP3): with the PodNotes pane already open, the file plays — valid app:// src, audio.error is null, readyState 1, real duration, currentTime advances.

The remaining half still reproduced: with the pane closed, clicking Play with PodNotes did nothing visible — no leaf opened and nothing played:

{ "leavesAfterClose": 0, "playItemFound": true,
  "leavesAfterClick": 0, "podcastViewInDomAfterClick": false, "audioPresent": false }

Root cause: the handler set the currentEpisode and viewState stores, but those only update an already-mounted Svelte view. When the view was closed (or hidden in a collapsed sidebar) nothing reacted, so the file played to no visible player — exactly the "doesn't open associated pane" symptom.

The fix

In src/getContextMenuHandler.ts, after setting the stores, ensure the player view is open and revealed via a small revealPodcastView(app) helper:

  • reuse an existing VIEW_TYPE leaf when present, otherwise open one in the right sidebar with getRightLeaf(false).setViewState(...);
  • workspace.revealLeaf(leaf) — which also surfaces a leaf hidden inside a collapsed sidebar.

This mirrors the existing Show PodNotes command and onLayoutReady in main.ts. Setting the stores before opening the leaf is what lets a freshly mounted EpisodePlayer read viewState = Player / currentEpisode on first render and autoplay the app:// resource. main.ts is untouched — the change stays in the context-menu handler.

Verification

Post-fix runtime repro (same isolated vault, pane closed before the click):

{ "leavesAfterClose": 0, "playItemFound": true,
  "leavesAfterClick": 1, "podcastViewInDomAfterClick": true,
  "audioPresent": true, "audioPlaying": true, "leafIsRevealed": true }

The already-open path is unchanged (it falls into the existing-leaf branch and just reveals), so there's no regression there.

  • Local file used: a 3s 440 Hz sine MP3 (Audio/test-tone.mp3) generated with ffmpeg, played from the file-explorer context menu.
  • Runtime: real Obsidian via the isolated worktree e2e vault (npm run obsidian:e2e), triggering the real file-menu event and invoking the captured item's onClick.

New tests

src/getContextMenuHandler.test.ts covers: the item is offered only for audio files, the current episode is wired with the app:// resource URL, and both reveal paths (reuse an existing leaf vs. open a new one).

Gates (Node 22)

npm run lint, format:check, typecheck, build, and test (457 tests) all pass.

Release / migration impact

None. No settings, storage, API, or URI changes — purely the context-menu playback flow.

…s play (#84)

Selecting 'Play with PodNotes' on an audio file set the currentEpisode and
viewState stores but never opened or revealed the PodNotes view. When the
view was closed or hidden in a collapsed sidebar nothing reacted, so the
action silently did nothing — the file played to no visible player. This is
the remaining half of issue #84; the no-supported-sources/blob playback half
was fixed by #100.

Open the right-sidebar view when no leaf exists and reveal it (which also
surfaces a leaf hidden in a collapsed sidebar), mirroring the 'Show PodNotes'
command and onLayoutReady. Keep the fix in getContextMenuHandler.ts; main.ts
is untouched.

Add unit tests covering the audio-only menu item, current-episode wiring, and
both reveal paths (existing leaf vs. opening a new one).
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying podnotes with  Cloudflare Pages  Cloudflare Pages

Latest commit: d024780
Status: ✅  Deploy successful!
Preview URL: https://d1dc76bc.podnotes.pages.dev
Branch Preview URL: https://chhoumann-84-play-with-podno.podnotes.pages.dev

View logs

@chhoumann chhoumann merged commit 5953625 into master Jun 16, 2026
2 checks passed
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.

[Bug] Play with podnotes dosnt seems to work

1 participant