-
Notifications
You must be signed in to change notification settings - Fork 960
fix(desktop): stop silently routing electronTrpc font-settings query through host-service #3394
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,23 +1,23 @@ | ||
| 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, | ||
| }, | ||
| ); | ||
| const { data: fontSettings } = useQuery({ | ||
| queryKey: ["electron", "settings", "getFontSettings"], | ||
| queryFn: () => electronTrpcClient.settings.getFontSettings.query(), | ||
| staleTime: 30_000, | ||
| }); | ||
|
Comment on lines
+16
to
+20
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The new
The same issue exists in One way to close the gap without restructuring provider wiring: add a matching queryClient.invalidateQueries({ queryKey: ["electron", "settings", "getFontSettings"] });Alternatively, use |
||
|
|
||
| return useMemo(() => { | ||
| const theme = terminalTheme ?? fallbackTheme; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: Cache invalidation is broken for these vanilla
useQuerycalls. ThequeryKeyhere (["electron", "settings", "getFontSettings"]) doesn't match the tRPC-generated key structure ([["settings", "getFontSettings"], { input: undefined, type: "query" }]), so whenFontSettingSectioncallsutils.settings.getFontSettings.invalidate()after saving, it won't invalidate these entries. Users will see stale font settings for up to 30 s (thestaleTime) after changing them.Two options:
getQueryKeyfrom@trpc/react-queryto derive the exact tRPC key and pass it here, so the existinginvalidate()covers these entries automatically.queryClient.invalidateQueries({ queryKey: ["electron", "settings", "getFontSettings"] })inFontSettingSection'sonSettledcallback alongside the existingutilscall.The same issue applies to
WorkspaceDiff.tsxandCodeEditor.tsx.Prompt for AI agents