From b244843f6611d5d821a486cf9a05da5b31984a39 Mon Sep 17 00:00:00 2001 From: Satya Patel Date: Sun, 12 Apr 2026 18:45:04 -0700 Subject: [PATCH 1/2] fix(desktop): route font-settings query via imperative electron tRPC client @trpc/react-query falls back to a module-level singleton React context when createTRPCReact is called without an explicit context. In the v2 workspace, nesting overrides that singleton and silently routes electronTrpc.*.useQuery calls through the workspace HTTP link, producing "No procedure found on path settings.getFontSettings" against host-service. Switch the three v2 render paths (useTerminalAppearance, WorkspaceDiff, and v1 CodeEditor which is reused in v2's FilePane renderers) to use electronTrpcClient.settings.getFontSettings.query() wrapped in a plain @tanstack/react-query useQuery, matching the rest of v2. --- .../WorkspaceDiff/WorkspaceDiff.tsx | 15 ++++++++++----- .../useTerminalAppearance.ts | 18 +++++++++++------- .../components/CodeEditor/CodeEditor.tsx | 19 ++++++++++++------- 3 files changed, 33 insertions(+), 19 deletions(-) diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/DiffPane/components/WorkspaceDiff/WorkspaceDiff.tsx b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/DiffPane/components/WorkspaceDiff/WorkspaceDiff.tsx index 36a0ea4b899..a9fd89a550a 100644 --- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/DiffPane/components/WorkspaceDiff/WorkspaceDiff.tsx +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/DiffPane/components/WorkspaceDiff/WorkspaceDiff.tsx @@ -1,9 +1,9 @@ import { MultiFileDiff } from "@pierre/diffs/react"; import { toast } from "@superset/ui/sonner"; import { workspaceTrpc } from "@superset/workspace-client"; +import { useQuery } from "@tanstack/react-query"; import { memo, useMemo } from "react"; import { useCopyToClipboard } from "renderer/hooks/useCopyToClipboard"; -import { electronTrpc } from "renderer/lib/electron-trpc"; import { electronTrpcClient } from "renderer/lib/trpc-client"; import { getDiffsTheme, @@ -47,10 +47,15 @@ export const WorkspaceDiff = memo(function WorkspaceDiff({ onOpenFile, }: WorkspaceDiffProps) { const activeTheme = useResolvedTheme(); - const { data: fontSettings } = electronTrpc.settings.getFontSettings.useQuery( - undefined, - { staleTime: 30_000 }, - ); + // Uses the imperative electron tRPC client rather than electronTrpc.X.useQuery + // because @trpc/react-query's default React context is a module-level + // singleton — nesting workspaceTrpc.Provider overrides it and silently + // routes electronTrpc hooks through the host-service HTTP link. + const { data: fontSettings } = useQuery({ + queryKey: ["electron", "settings", "getFontSettings"], + queryFn: () => electronTrpcClient.settings.getFontSettings.query(), + staleTime: 30_000, + }); const shikiTheme = getDiffsTheme(activeTheme); const parsedEditorFontSize = typeof fontSettings?.editorFontSize === "number" diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/TerminalPane/hooks/useTerminalAppearance/useTerminalAppearance.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/TerminalPane/hooks/useTerminalAppearance/useTerminalAppearance.ts index 7752879a07b..c9c8d110d4d 100644 --- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/TerminalPane/hooks/useTerminalAppearance/useTerminalAppearance.ts +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/TerminalPane/hooks/useTerminalAppearance/useTerminalAppearance.ts @@ -1,23 +1,27 @@ +import { useQuery } from "@tanstack/react-query"; import { useMemo } from "react"; -import { electronTrpc } from "renderer/lib/electron-trpc"; import { DEFAULT_TERMINAL_FONT_FAMILY, DEFAULT_TERMINAL_FONT_SIZE, getDefaultTerminalAppearance, type TerminalAppearance, } from "renderer/lib/terminal/appearance"; +import { electronTrpcClient } from "renderer/lib/trpc-client"; import { useTerminalTheme } from "renderer/stores/theme"; const fallbackTheme = getDefaultTerminalAppearance().theme; export function useTerminalAppearance(): TerminalAppearance { const terminalTheme = useTerminalTheme(); - const { data: fontSettings } = electronTrpc.settings.getFontSettings.useQuery( - undefined, - { - staleTime: 30_000, - }, - ); + // Uses the imperative electron tRPC client rather than electronTrpc.X.useQuery + // because @trpc/react-query's default React context is a module-level + // singleton — nesting workspaceTrpc.Provider overrides it and silently + // routes electronTrpc hooks through the host-service HTTP link. + const { data: fontSettings } = useQuery({ + queryKey: ["electron", "settings", "getFontSettings"], + queryFn: () => electronTrpcClient.settings.getFontSettings.query(), + staleTime: 30_000, + }); return useMemo(() => { const theme = terminalTheme ?? fallbackTheme; diff --git a/apps/desktop/src/renderer/screens/main/components/WorkspaceView/components/CodeEditor/CodeEditor.tsx b/apps/desktop/src/renderer/screens/main/components/WorkspaceView/components/CodeEditor/CodeEditor.tsx index 475d6496400..f713de1e689 100644 --- a/apps/desktop/src/renderer/screens/main/components/WorkspaceView/components/CodeEditor/CodeEditor.tsx +++ b/apps/desktop/src/renderer/screens/main/components/WorkspaceView/components/CodeEditor/CodeEditor.tsx @@ -23,8 +23,9 @@ import { lineNumbers, } from "@codemirror/view"; import { cn } from "@superset/ui/utils"; +import { useQuery } from "@tanstack/react-query"; import { type MutableRefObject, useEffect, useRef } from "react"; -import { electronTrpc } from "renderer/lib/electron-trpc"; +import { electronTrpcClient } from "renderer/lib/trpc-client"; import type { CodeEditorAdapter } from "renderer/screens/main/components/WorkspaceView/ContentView/components"; import { getCodeSyntaxHighlighting } from "renderer/screens/main/components/WorkspaceView/utils/code-theme"; import { useResolvedTheme } from "renderer/stores/theme"; @@ -179,12 +180,16 @@ export function CodeEditor({ const onSaveRef = useRef(onSave); // Guards against re-entrant onChange calls triggered by the value-sync effect's own dispatch. const isExternalUpdateRef = useRef(false); - const { data: fontSettings } = electronTrpc.settings.getFontSettings.useQuery( - undefined, - { - staleTime: 30_000, - }, - ); + // Uses the imperative electron tRPC client rather than electronTrpc.X.useQuery + // because @trpc/react-query's default React context is a module-level + // singleton — when rendered inside v2's workspaceTrpc.Provider the nested + // provider overrides it and silently routes these hooks through the + // host-service HTTP link. + const { data: fontSettings } = useQuery({ + queryKey: ["electron", "settings", "getFontSettings"], + queryFn: () => electronTrpcClient.settings.getFontSettings.query(), + staleTime: 30_000, + }); const editorFontFamily = fontSettings?.editorFontFamily ?? undefined; const editorFontSize = fontSettings?.editorFontSize ?? undefined; const activeTheme = useResolvedTheme(); From 03f3c3d5badc8c9cbc0a4d070a042df843fef707 Mon Sep 17 00:00:00 2001 From: Satya Patel Date: Sun, 12 Apr 2026 19:31:12 -0700 Subject: [PATCH 2/2] chore(desktop): drop explanatory comments from font-settings workaround --- .../DiffPane/components/WorkspaceDiff/WorkspaceDiff.tsx | 4 ---- .../hooks/useTerminalAppearance/useTerminalAppearance.ts | 4 ---- .../WorkspaceView/components/CodeEditor/CodeEditor.tsx | 5 ----- 3 files changed, 13 deletions(-) diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/DiffPane/components/WorkspaceDiff/WorkspaceDiff.tsx b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/DiffPane/components/WorkspaceDiff/WorkspaceDiff.tsx index a9fd89a550a..6ffec2df82f 100644 --- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/DiffPane/components/WorkspaceDiff/WorkspaceDiff.tsx +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/DiffPane/components/WorkspaceDiff/WorkspaceDiff.tsx @@ -47,10 +47,6 @@ export const WorkspaceDiff = memo(function WorkspaceDiff({ onOpenFile, }: WorkspaceDiffProps) { const activeTheme = useResolvedTheme(); - // Uses the imperative electron tRPC client rather than electronTrpc.X.useQuery - // because @trpc/react-query's default React context is a module-level - // singleton — nesting workspaceTrpc.Provider overrides it and silently - // routes electronTrpc hooks through the host-service HTTP link. const { data: fontSettings } = useQuery({ queryKey: ["electron", "settings", "getFontSettings"], queryFn: () => electronTrpcClient.settings.getFontSettings.query(), diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/TerminalPane/hooks/useTerminalAppearance/useTerminalAppearance.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/TerminalPane/hooks/useTerminalAppearance/useTerminalAppearance.ts index c9c8d110d4d..d4a1f4d9e98 100644 --- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/TerminalPane/hooks/useTerminalAppearance/useTerminalAppearance.ts +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/TerminalPane/hooks/useTerminalAppearance/useTerminalAppearance.ts @@ -13,10 +13,6 @@ const fallbackTheme = getDefaultTerminalAppearance().theme; export function useTerminalAppearance(): TerminalAppearance { const terminalTheme = useTerminalTheme(); - // Uses the imperative electron tRPC client rather than electronTrpc.X.useQuery - // because @trpc/react-query's default React context is a module-level - // singleton — nesting workspaceTrpc.Provider overrides it and silently - // routes electronTrpc hooks through the host-service HTTP link. const { data: fontSettings } = useQuery({ queryKey: ["electron", "settings", "getFontSettings"], queryFn: () => electronTrpcClient.settings.getFontSettings.query(), diff --git a/apps/desktop/src/renderer/screens/main/components/WorkspaceView/components/CodeEditor/CodeEditor.tsx b/apps/desktop/src/renderer/screens/main/components/WorkspaceView/components/CodeEditor/CodeEditor.tsx index f713de1e689..1aeae0e15cc 100644 --- a/apps/desktop/src/renderer/screens/main/components/WorkspaceView/components/CodeEditor/CodeEditor.tsx +++ b/apps/desktop/src/renderer/screens/main/components/WorkspaceView/components/CodeEditor/CodeEditor.tsx @@ -180,11 +180,6 @@ export function CodeEditor({ const onSaveRef = useRef(onSave); // Guards against re-entrant onChange calls triggered by the value-sync effect's own dispatch. const isExternalUpdateRef = useRef(false); - // Uses the imperative electron tRPC client rather than electronTrpc.X.useQuery - // because @trpc/react-query's default React context is a module-level - // singleton — when rendered inside v2's workspaceTrpc.Provider the nested - // provider overrides it and silently routes these hooks through the - // host-service HTTP link. const { data: fontSettings } = useQuery({ queryKey: ["electron", "settings", "getFontSettings"], queryFn: () => electronTrpcClient.settings.getFontSettings.query(),