fix(desktop): open in IDE broken in v2 workspaces — isolate workspaceTrpc React context

Merged
SA
4mo ago
+33-2071

Summary

Fixes SUPER-1599: "Open in IDE" failing with No procedure found on path "external.openInApp" since the latest release.

Root cause: every createTRPCReact() client shares @trpc/react-query's default React context, so workspaceTrpc.Provider (mounted by the v2 WorkspaceProvider) shadowed the electron IPC provider for any electronTrpc hook rendered under it — the hook silently resolved the host-service HTTP client, which has no external router. #5824 exposed this by moving the open-in button, window controls, and a getPlatform query into the v2 workspace subtree. The same mechanism also left platform undefined in the v2 page (hiding window controls on Windows/Linux).

Fix (structural, not per-callsite):

  • Give workspaceTrpc its own React context via createTRPCReact({ context }), so the two providers can never collide. All electronTrpc hooks now work anywhere in the tree; #5824's moved components need no changes.
  • useV2FileSearch was the one bare workspaceTrpc hook outside any WorkspaceClientProvider (v1 CommandPalette mounts) — it previously coasted on the shared context and would throw under the isolated one. Converted to a plain useQuery over the provider's imperative client via a new useMaybeWorkspaceClient(), which returns null outside the provider.
  • Removed the now-stale shared-context caveat comment in the v2 layout.

Audited all other workspaceTrpc hook call sites: everything else renders under a WorkspaceClientProvider (v2 workspace tree, or self-wrapping dialogs/settings sections).

Test Plan

  • bun run lint exits 0
  • Full monorepo bun run typecheck passes (35/35)
  • v2 workspace: sidebar "Open in " button opens the worktree; copy path works
  • v1 workspace: CMD+P file search still works (CommandPalette mounts without a WorkspaceClientProvider)
  • Windows/Linux v2 workspace: window min/max/close controls render and work

https://claude.ai/code/session_018igf49z4TsXxgbdKH6t3Nf


Summary by cubic

Fixes SUPER-1599: “Open in IDE” in v2 workspaces by isolating the workspaceTrpc React context so electronTrpc hooks resolve correctly. Keeps v1 CommandPalette file search working without a WorkspaceClientProvider and restores window controls on Windows/Linux.

  • Bug Fixes
    • Gave workspaceTrpc its own React context via createTRPCReact({ context }), preventing collisions with electronTrpc; fixes “No procedure found on path 'external.openInApp'” and restores platform detection in v2.
    • Converted useV2FileSearch to a plain useQuery over the provider’s imperative client; added useMaybeWorkspaceClient() to safely run outside a WorkspaceClientProvider.
    • Removed mock-heavy packages/trpc router tests and dropped the package test script to stop CI failures when @superset/db/client loads without a root DATABASE_URL.

Summary by CodeRabbit

  • Bug Fixes
    • Improved workspace command palette file search reliability and timing.
    • Search now only runs when a workspace is available and the search term is non-empty.
    • Preserved existing results/loading behavior, including empty-state placeholders.
  • Refactor
    • Improved workspace client handling in UI screens that may run outside a workspace context.
    • Adjusted workspace search to use the workspace client directly to avoid query routing conflicts.
  • Tests / Chores
    • Added test runner setup and default CI database environment variables.