diff --git a/.agents/skills/superset-settings/SKILL.md b/.agents/skills/superset-settings/SKILL.md index 33cf3edabdc..d6e8c04739c 100644 --- a/.agents/skills/superset-settings/SKILL.md +++ b/.agents/skills/superset-settings/SKILL.md @@ -131,7 +131,7 @@ Booleans accept `true/false/on/off/1/0/yes/no`. | Section | Keys | | --- | --- | -| behavior | `confirmOnQuit`, `fileOpenMode` (`split-pane\|new-tab`), `showResourceMonitor`, `openLinksInApp`, `defaultEditor` (vscode, cursor, zed, ...) | +| behavior | `confirmOnQuit`, `fileOpenMode` (`split-pane\|new-tab`), `showResourceMonitor`, `showUsageInSidebar`, `openLinksInApp`, `defaultEditor` (vscode, cursor, zed, ...) | | git | `branchPrefixMode` (`none\|github\|author\|custom`), `branchPrefixCustom`, `worktreeBaseDir`; host-wide, written through the local host service, so the app (or `superset start`) must be running | | notifications | `selectedRingtoneId` (shamisen, arcade, ping, quick, doowap, woman, african, afrobeat, edm, comeback, shabala), `notificationSoundsMuted`, `notificationVolume` (0-100) | | terminal | `terminalLinkBehavior` (`external-editor\|file-viewer`), `terminalParkedRuntimeCap` (2-64), `showPresetsBar`, `useCompactTerminalAddButton`, `autoApplyDefaultPreset`, `waitForSetupBeforeAgent` | diff --git a/apps/desktop/src/lib/trpc/routers/settings/index.ts b/apps/desktop/src/lib/trpc/routers/settings/index.ts index 24226cb26fd..27fcfc958f9 100644 --- a/apps/desktop/src/lib/trpc/routers/settings/index.ts +++ b/apps/desktop/src/lib/trpc/routers/settings/index.ts @@ -55,6 +55,7 @@ import { DEFAULT_OPEN_LINKS_IN_APP, DEFAULT_SHOW_PRESETS_BAR, DEFAULT_SHOW_RESOURCE_MONITOR, + DEFAULT_SHOW_USAGE_IN_SIDEBAR, DEFAULT_TERMINAL_COPY_ON_SELECT, DEFAULT_TERMINAL_LINK_BEHAVIOR, DEFAULT_TERMINAL_PARKED_RUNTIME_CAP, @@ -1107,6 +1108,30 @@ export const createSettingsRouter = () => { return { success: true }; }), + getShowUsageInSidebar: publicProcedure.query(() => { + const row = getSettings(); + return row.showUsageInSidebar ?? DEFAULT_SHOW_USAGE_IN_SIDEBAR; + }), + + setShowUsageInSidebar: publicProcedure + .input(z.object({ enabled: z.boolean() })) + .mutation(({ input }) => { + // Target the row getSettings() reads: legacy DBs can hold a non-1 + // row id, and upserting id 1 there would split settings across + // two rows. + const { id } = getSettings(); + localDb + .insert(settings) + .values({ id, showUsageInSidebar: input.enabled }) + .onConflictDoUpdate({ + target: settings.id, + set: { showUsageInSidebar: input.enabled }, + }) + .run(); + + return { success: true }; + }), + getWorktreeBaseDir: publicProcedure.query(() => { const row = getSettings(); return row.worktreeBaseDir ?? null; diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/DashboardSidebar/components/DashboardSidebarHeader/DashboardSidebarHeader.tsx b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/DashboardSidebar/components/DashboardSidebarHeader/DashboardSidebarHeader.tsx index 15a3f18ce67..149594c465d 100644 --- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/DashboardSidebar/components/DashboardSidebarHeader/DashboardSidebarHeader.tsx +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/DashboardSidebar/components/DashboardSidebarHeader/DashboardSidebarHeader.tsx @@ -17,6 +17,7 @@ import { HiOutlineClipboardDocumentList } from "react-icons/hi2"; import { LuClock, LuFileText, + LuGauge, LuLayers, LuPlus, LuPuzzle, @@ -50,6 +51,10 @@ import { useTasksFilterStore, } from "renderer/routes/_authenticated/_dashboard/tasks/stores/tasks-filter-state"; import { useHostWorkspaces } from "renderer/routes/_authenticated/providers/HostWorkspacesProvider"; +import { + getUsageLastSection, + usageSectionPath, +} from "renderer/routes/_authenticated/settings/usage/utils/usageLastSection"; import { STROKE_WIDTH_THICK } from "renderer/screens/main/components/WorkspaceSidebar/constants"; import { useOpenEmptyProjectModal, @@ -204,6 +209,8 @@ export function DashboardSidebarHeader({ }; const isPagesEnabled = useFeatureFlagEnabled(FEATURE_FLAGS.PAGES) ?? false; + const { data: isUsageInSidebarEnabled } = + electronTrpc.settings.getShowUsageInSidebar.useQuery(); const handlePagesClick = () => { navigate({ to: "/pages" }); @@ -227,6 +234,12 @@ export function DashboardSidebarHeader({ }); }; + const handleUsageClick = () => { + // Reopen whichever Usage section (token / machine resources) was + // visited last. + navigate({ to: usageSectionPath(getUsageLastSection()) }); + }; + if (isCollapsed) { return (