Skip to content

Commit 919bcfb

Browse files
committed
🤖 refactor: remove VerticalTokenMeter component
Now that we have the context usage indicator in the chat area, the VerticalTokenMeter in the right sidebar is no longer needed. Removed: - VerticalTokenMeter.tsx component - ChatMetaSidebar.tsx (only existed to show the meter when collapsed) - Related imports and usage in RightSidebar.tsx -229 lines
1 parent b98b323 commit 919bcfb

File tree

3 files changed

+0
-230
lines changed

3 files changed

+0
-230
lines changed

src/browser/components/ChatMetaSidebar.tsx

Lines changed: 0 additions & 84 deletions
This file was deleted.

src/browser/components/RightSidebar.tsx

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,12 @@ import React from "react";
22
import { RIGHT_SIDEBAR_TAB_KEY, RIGHT_SIDEBAR_COLLAPSED_KEY } from "@/common/constants/storage";
33
import { usePersistedState } from "@/browser/hooks/usePersistedState";
44
import { useWorkspaceUsage, useWorkspaceStatsSnapshot } from "@/browser/stores/WorkspaceStore";
5-
import { useProviderOptions } from "@/browser/hooks/useProviderOptions";
65
import { useResizeObserver } from "@/browser/hooks/useResizeObserver";
76
import { useFeatureFlags } from "@/browser/contexts/FeatureFlagsContext";
8-
import { useAutoCompactionSettings } from "@/browser/hooks/useAutoCompactionSettings";
97
import { ErrorBoundary } from "./ErrorBoundary";
108
import { CostsTab } from "./RightSidebar/CostsTab";
119
import { StatsTab } from "./RightSidebar/StatsTab";
12-
import { VerticalTokenMeter } from "./RightSidebar/VerticalTokenMeter";
1310
import { ReviewPanel } from "./RightSidebar/CodeReview/ReviewPanel";
14-
import { calculateTokenMeterData } from "@/common/utils/tokens/tokenMeterUtils";
1511
import { sumUsageHistory, type ChatUsageDisplay } from "@/common/utils/tokens/usageAggregator";
1612
import { matchesKeybind, KEYBINDS, formatKeybind } from "@/browser/utils/ui/keybinds";
1713
import { Tooltip, TooltipTrigger, TooltipContent } from "./ui/tooltip";
@@ -160,8 +156,6 @@ const RightSidebarComponent: React.FC<RightSidebarProps> = ({
160156

161157
const usage = useWorkspaceUsage(workspaceId);
162158

163-
const { options } = useProviderOptions();
164-
const use1M = options.anthropic?.use1MContext ?? false;
165159
const chatAreaSize = useResizeObserver(chatAreaRef);
166160

167161
const baseId = `right-sidebar-${workspaceId}`;
@@ -172,10 +166,6 @@ const RightSidebarComponent: React.FC<RightSidebarProps> = ({
172166
const statsPanelId = `${baseId}-panel-stats`;
173167
const reviewPanelId = `${baseId}-panel-review`;
174168

175-
// Use lastContextUsage for context window display (last step = actual context size)
176-
const lastUsage = usage?.liveUsage ?? usage?.lastContextUsage;
177-
const model = lastUsage?.model ?? null;
178-
179169
// Calculate session cost for tab display
180170
const sessionCost = React.useMemo(() => {
181171
const parts: ChatUsageDisplay[] = [];
@@ -206,17 +196,6 @@ const RightSidebarComponent: React.FC<RightSidebarProps> = ({
206196
return total > 0 ? total : null;
207197
})();
208198

209-
// Auto-compaction settings: threshold per-model
210-
const { threshold: autoCompactThreshold, setThreshold: setAutoCompactThreshold } =
211-
useAutoCompactionSettings(workspaceId, model);
212-
213-
// Memoize vertical meter data calculation to prevent unnecessary re-renders
214-
const verticalMeterData = React.useMemo(() => {
215-
return lastUsage
216-
? calculateTokenMeterData(lastUsage, model ?? "unknown", use1M, true)
217-
: { segments: [], totalTokens: 0, totalPercentage: 0 };
218-
}, [lastUsage, model, use1M]);
219-
220199
// Calculate if we should show collapsed view with hysteresis
221200
// Strategy: Observe ChatArea width directly (independent of sidebar width)
222201
// - ChatArea has min-width: 750px and flex: 1
@@ -265,20 +244,6 @@ const RightSidebarComponent: React.FC<RightSidebarProps> = ({
265244
// Between thresholds: maintain current state (no change)
266245
}, [chatAreaWidth, selectedTab, showCollapsed, setShowCollapsed, width]);
267246

268-
// Single render point for VerticalTokenMeter
269-
// Shows when: (1) collapsed, OR (2) Review tab is active
270-
const showMeter = showCollapsed || selectedTab === "review";
271-
const autoCompactionProps = React.useMemo(
272-
() => ({
273-
threshold: autoCompactThreshold,
274-
setThreshold: setAutoCompactThreshold,
275-
}),
276-
[autoCompactThreshold, setAutoCompactThreshold]
277-
);
278-
const verticalMeter = showMeter ? (
279-
<VerticalTokenMeter data={verticalMeterData} autoCompaction={autoCompactionProps} />
280-
) : null;
281-
282247
return (
283248
<SidebarContainer
284249
collapsed={showCollapsed}
@@ -301,11 +266,6 @@ const RightSidebarComponent: React.FC<RightSidebarProps> = ({
301266
/>
302267
)}
303268

304-
{/* Render meter when Review tab is active */}
305-
{selectedTab === "review" && (
306-
<div className="bg-sidebar flex w-5 shrink-0 flex-col">{verticalMeter}</div>
307-
)}
308-
309269
<div className="flex min-w-0 flex-1 flex-col">
310270
<div
311271
className="border-border-light flex gap-1 border-b px-2 py-1.5"
@@ -442,8 +402,6 @@ const RightSidebarComponent: React.FC<RightSidebarProps> = ({
442402
</div>
443403
</div>
444404
</div>
445-
{/* Render meter in collapsed view when sidebar is collapsed */}
446-
<div className={cn("h-full", showCollapsed ? "flex" : "hidden")}>{verticalMeter}</div>
447405
</SidebarContainer>
448406
);
449407
};

src/browser/components/RightSidebar/VerticalTokenMeter.tsx

Lines changed: 0 additions & 104 deletions
This file was deleted.

0 commit comments

Comments
 (0)