From c612e7c08cf118489ed991684657fe5bc3262d77 Mon Sep 17 00:00:00 2001 From: Dante Date: Thu, 8 Oct 2026 18:13:05 +0000 Subject: [PATCH] FE-3297 refactor(auth): use bridge types 0.5.0 and report Desktop workspace refresh failures (#20531) This PR closes out two follow-ups from FE-3297. It moves the Desktop host bridge types to `@comfyorg/comfyui-desktop-bridge-types` 0.5.0, and it reports a refresh failure that was previously swallowed. **Why:** - 0.5.0, published with Comfy-Org/Comfy-Desktop#1671, adds `switchWorkspace` to `ComfyDesktop2AuthBridge`. Since #20500 we have kept a local copy of that one member, which can now go. - A CodeRabbit finding on #20484 (deferred so the approved head would not be reset): when the tab follows a Desktop workspace switch and the list refresh fails, the failure was swallowed by `.catch(() => undefined)`. **How:** - Pin 0.5.0, with the release-age exclusion moved from 0.4.0 to 0.5.0. `DesktopHostAuthBridge` is now the package type with `switchWorkspace` made optional. Desktop builds older than #1671 do not ship that method, and the account menu already falls back to a fixed workspace row for them. - `followDesktopHostWorkspace` reports the refresh failure via `reportError` (`error_refreshing_workspaces_for_desktop_host`). The tab still keeps no active workspace, which is the fail-closed behaviour Christian asked for on #20484. No UI change, so there are no AS IS/TO BE screenshots. - The new store test (a failed refresh is reported and the active workspace stays null) fails on `main` and passes here. - Desktop host, auth store, workspace store and account popover suites: 318 tests pass. - `pnpm typecheck:app` is clean. --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> (cherry picked from commit 45e4e161d191b48bc8e03785929587e908924385) --- pnpm-lock.yaml | 12 ++++++------ pnpm-workspace.yaml | 4 ++-- .../auth/desktopHost/desktopHostAuthBridge.ts | 11 ++++++----- .../stores/teamWorkspaceStore.test.ts | 19 +++++++++++++++++++ .../workspace/stores/teamWorkspaceStore.ts | 7 ++++++- 5 files changed, 39 insertions(+), 14 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ecd8041314d..6668bee5efc 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -25,8 +25,8 @@ catalogs: specifier: 0.3.6 version: 0.3.6 '@comfyorg/comfyui-desktop-bridge-types': - specifier: 0.4.0 - version: 0.4.0 + specifier: 0.5.0 + version: 0.5.0 '@comfyorg/comfyui-electron-types': specifier: 0.6.2 version: 0.6.2 @@ -520,7 +520,7 @@ importers: version: 0.3.6 '@comfyorg/comfyui-desktop-bridge-types': specifier: 'catalog:' - version: 0.4.0 + version: 0.5.0 '@comfyorg/comfyui-electron-types': specifier: 'catalog:' version: 0.6.2 @@ -2003,8 +2003,8 @@ packages: '@comfyorg/comfy-multi-player@0.3.6': resolution: {integrity: sha512-6mC4E43YH+58gV4I+tmUR4pIYxqUeiY8ShS1WjjDEYxsBKGbzU1rRNGZHKgrzP3cOKGzK/JSP663/SIN50kfeQ==} - '@comfyorg/comfyui-desktop-bridge-types@0.4.0': - resolution: {integrity: sha512-o692svyRg63dLisVcpEJRzIUK2m/T538eYZhoXFF2e+RBCScU4MHLk9FutZyjW+DCQxv0hGunBOs96Qffs+UcQ==} + '@comfyorg/comfyui-desktop-bridge-types@0.5.0': + resolution: {integrity: sha512-IlLhbbNaDwTw1JjE+7Z2OlejrE4zcfzORJdaF3mtkzSjCFdK+j8Nuf9XYX78S3vz+uqmxXtn35gDR4amHv7shw==} '@comfyorg/comfyui-electron-types@0.6.2': resolution: {integrity: sha512-r3By5Wbizq8jagUrhtcym79HYUTinsvoBnYkFFWbUmrURBWIaC0HduFVkRkI1PNdI76piW+JSOJJnw00YCVXeg==} @@ -10659,7 +10659,7 @@ snapshots: dependencies: yjs: 13.6.32 - '@comfyorg/comfyui-desktop-bridge-types@0.4.0': {} + '@comfyorg/comfyui-desktop-bridge-types@0.5.0': {} '@comfyorg/comfyui-electron-types@0.6.2': {} diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index e5781f1b802..5f522002397 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -16,7 +16,7 @@ catalog: '@astrojs/mdx': ^7.0.5 '@astrojs/sitemap': ^3.7.3 '@astrojs/vue': ^7.0.2 - '@comfyorg/comfyui-desktop-bridge-types': 0.4.0 + '@comfyorg/comfyui-desktop-bridge-types': 0.5.0 '@comfyorg/comfyui-electron-types': 0.6.2 '@comfyorg/sdk': 0.2.0 '@customerio/cdp-analytics-browser': ^0.5.3 @@ -209,7 +209,7 @@ overrides: # Transitional - drop each entry once that version is older than the release-age gate. minimumReleaseAgeExclude: - - '@comfyorg/comfyui-desktop-bridge-types@0.4.0' + - '@comfyorg/comfyui-desktop-bridge-types@0.5.0' - '@comfyorg/comfy-multi-player@0.3.6' patchedDependencies: diff --git a/src/platform/auth/desktopHost/desktopHostAuthBridge.ts b/src/platform/auth/desktopHost/desktopHostAuthBridge.ts index bec9d81804a..60d11d5a801 100644 --- a/src/platform/auth/desktopHost/desktopHostAuthBridge.ts +++ b/src/platform/auth/desktopHost/desktopHostAuthBridge.ts @@ -5,8 +5,9 @@ import type { export type DesktopHostAuthState = ComfyDesktop2AuthState -/** `switchWorkspace` lands with bridge types 0.5.0 (Comfy-Desktop #1671). */ -export interface DesktopHostAuthBridge extends ComfyDesktop2AuthBridge { - /** Absent on Desktop builds before Comfy-Desktop #1671. */ - switchWorkspace?(workspaceId: string): Promise -} +/** `switchWorkspace` is absent on Desktop builds before Comfy-Desktop #1671. */ +export type DesktopHostAuthBridge = Omit< + ComfyDesktop2AuthBridge, + 'switchWorkspace' +> & + Partial> diff --git a/src/platform/workspace/stores/teamWorkspaceStore.test.ts b/src/platform/workspace/stores/teamWorkspaceStore.test.ts index 80c912a80c8..4a55629f61e 100644 --- a/src/platform/workspace/stores/teamWorkspaceStore.test.ts +++ b/src/platform/workspace/stores/teamWorkspaceStore.test.ts @@ -2400,6 +2400,25 @@ describe('useTeamWorkspaceStore', () => { expect(store.activeWorkspaceId).toBeNull() }) + it('reports a failed refresh and keeps no active workspace', async () => { + const store = useTeamWorkspaceStore() + await store.initialize() + const failure = new Error('list failed') + mockWorkspaceApi.list.mockRejectedValue(failure) + + pushHostState(hostOn(mockMemberWorkspace.id)) + + await vi.waitFor(() => + expect(reportError).toHaveBeenCalledWith( + failure, + expect.objectContaining({ + errorType: 'error_refreshing_workspaces_for_desktop_host' + }) + ) + ) + expect(store.activeWorkspaceId).toBeNull() + }) + it('follows a switch made in Desktop', async () => { mockWorkspaceApi.list.mockResolvedValue({ workspaces: [ diff --git a/src/platform/workspace/stores/teamWorkspaceStore.ts b/src/platform/workspace/stores/teamWorkspaceStore.ts index 8ce967f0d17..4f736bfa32c 100644 --- a/src/platform/workspace/stores/teamWorkspaceStore.ts +++ b/src/platform/workspace/stores/teamWorkspaceStore.ts @@ -1062,7 +1062,12 @@ export const useTeamWorkspaceStore = defineStore('teamWorkspace', () => { const isListed = () => workspaces.value.some((w) => w.id === hostWorkspaceId) if (!isListed()) { - await refreshWorkspaces().catch(() => undefined) + await refreshWorkspaces().catch((error: unknown) => + reportError(error, { + errorType: 'error_refreshing_workspaces_for_desktop_host', + surface: 'workspace' + }) + ) if ( isStaleIdentity(generation) || desktopHostUser.value?.workspaceId !== hostWorkspaceId