fix(settings): follow Embedded MPV support for search only while the settings page is open

The settings search service is provided in the root injector, so the
watch it started on its first use had no owner: with a login shell that
never answers it kept asking every 30 s until the app quit, long after
the settings page or the command palette that needed the answer was
closed. A failed recheck also ended the watch as if it were a final
answer, hiding the Embedded MPV rows for the rest of the session.

The service now separates the two uses. `ensureEmbeddedMpvSupportLoaded()`
is a single request again, for the command palette. The settings page
calls `followEmbeddedMpvSupport()` and ends it when the page is destroyed.
Only a final answer is kept: after an inconclusive one or a failed
request the next use asks again, for the palette's player commands too.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
4grayandClaude Fable 5.1 committed 2026-10-04 09:17:29 +02:00
1 parent 98eb267daa
commit cb8c289310
7 files changed
+178 -65

No files matched your search

@@ -247,6 +247,33 @@ describe('WorkspacePlayerCommandsContributor', () => {
expect(contributor.ensureEmbeddedMpvSupportLoaded()).toBeUndefined();
});
it('asks again after a failed request instead of giving up for the session', async () => {
const warn = jest.spyOn(console, 'warn').mockImplementation();
const contributor = bootstrap({
supportsManagedExternalPlayers: true,
supportsEmbeddedMpv: true,
});
const embedded = getRegistered(viewCommands).find(
(c) => c.id === 'switch-player-embedded-mpv'
);
electronStub?.getEmbeddedMpvSupport.mockRejectedValueOnce(
new Error('bridge failed')
);
try {
await contributor.ensureEmbeddedMpvSupportLoaded();
expect(resolveBoolean(embedded?.visible)).toBe(false);
await contributor.ensureEmbeddedMpvSupportLoaded();
expect(resolveBoolean(embedded?.visible)).toBe(true);
expect(electronStub?.getEmbeddedMpvSupport).toHaveBeenCalledTimes(
2
);
} finally {
warn.mockRestore();
}
});
it('switches to embedded MPV on run', () => {
bootstrap({
supportsManagedExternalPlayers: true,
@@ -120,9 +120,9 @@ export class WorkspacePlayerCommandsContributor {
}
private async loadEmbeddedMpvSupport(): Promise<void> {
// An inconclusive answer hides the command for now, but is not kept:
// the next palette open asks again.
let final = true;
// Only a final answer is kept. An inconclusive one, or a failed
// request, hides the command for now: the next palette open asks again.
let final = false;
try {
const support = await window.electron?.getEmbeddedMpvSupport?.();
this.embeddedMpvSupported.set(!!support?.supported);