Skip to content

Commit 1b63729

Browse files
🤖 fix: make context usage tooltip slider interactive (#1210)
## Problem The context usage indicator near ChatInput showed a slider on hover that **looked** interactive but wasn't draggable. The slider only became interactive when clicking to open the popover. This was confusing because: 1. The hover tooltip showed a slider that couldn't be dragged 2. The click popover showed the same slider that *could* be dragged 3. The two overlays had different background colors and text sizes, making it unclear they were different modes ## Solution Make both hover and click show the identical interactive slider: - Tooltip now passes the full `autoCompaction` config instead of just the threshold number - Popover styled to exactly match tooltip (background, border, shadow, text size) - Removed ~63 lines of dead code (`HorizontalThresholdIndicator` component and `autoCompactionThreshold` prop) --- _Generated with `mux` • Model: `anthropic:claude-opus-4-5` • Thinking: `high`_
1 parent df2aade commit 1b63729

File tree

3 files changed

+7
-70
lines changed

3 files changed

+7
-70
lines changed

src/browser/components/ContextUsageIndicatorButton.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,15 @@ export const ContextUsageIndicatorButton: React.FC<ContextUsageIndicatorButtonPr
6464
</PopoverTrigger>
6565
</TooltipTrigger>
6666
<TooltipContent side="bottom" align="end" className="w-80">
67-
<ContextUsageBar data={data} autoCompactionThreshold={autoCompaction?.threshold} />
67+
<ContextUsageBar data={data} autoCompaction={autoCompaction} />
6868
</TooltipContent>
6969
</Tooltip>
7070

71-
<PopoverContent side="bottom" align="end" className="w-80 overflow-visible p-3">
71+
<PopoverContent
72+
side="bottom"
73+
align="end"
74+
className="bg-modal-bg border-separator-light w-80 overflow-visible rounded px-[10px] py-[6px] text-[11px] font-normal shadow-[0_2px_8px_rgba(0,0,0,0.4)]"
75+
>
7276
<ContextUsageBar data={data} autoCompaction={autoCompaction} />
7377
</PopoverContent>
7478
</Popover>

src/browser/components/RightSidebar/ContextUsageBar.tsx

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,19 @@
11
import React from "react";
22
import { TokenMeter } from "./TokenMeter";
3-
import {
4-
HorizontalThresholdSlider,
5-
HorizontalThresholdIndicator,
6-
type AutoCompactionConfig,
7-
} from "./ThresholdSlider";
3+
import { HorizontalThresholdSlider, type AutoCompactionConfig } from "./ThresholdSlider";
84
import { formatTokens, type TokenMeterData } from "@/common/utils/tokens/tokenMeterUtils";
95

106
interface ContextUsageBarProps {
117
data: TokenMeterData;
128
/** Auto-compaction settings for threshold slider */
139
autoCompaction?: AutoCompactionConfig;
14-
/** Show text-only indicator for auto-compaction threshold (for tooltips) */
15-
autoCompactionThreshold?: number;
1610
showTitle?: boolean;
1711
testId?: string;
1812
}
1913

2014
const ContextUsageBarComponent: React.FC<ContextUsageBarProps> = ({
2115
data,
2216
autoCompaction,
23-
autoCompactionThreshold,
2417
showTitle = true,
2518
testId,
2619
}) => {
@@ -32,10 +25,6 @@ const ContextUsageBarComponent: React.FC<ContextUsageBarProps> = ({
3225

3326
const showWarning = !data.maxTokens;
3427

35-
// Show read-only indicator when threshold provided but no interactive config
36-
const showReadOnlyIndicator =
37-
autoCompactionThreshold !== undefined && !autoCompaction && data.maxTokens;
38-
3928
return (
4029
<div data-testid={testId} className="relative flex flex-col gap-1">
4130
<div className="flex items-baseline justify-between">
@@ -54,9 +43,6 @@ const ContextUsageBarComponent: React.FC<ContextUsageBarProps> = ({
5443
<div className="relative w-full py-2">
5544
<TokenMeter segments={data.segments} orientation="horizontal" />
5645
{autoCompaction && data.maxTokens && <HorizontalThresholdSlider config={autoCompaction} />}
57-
{showReadOnlyIndicator && (
58-
<HorizontalThresholdIndicator threshold={autoCompactionThreshold} />
59-
)}
6046
</div>
6147

6248
{showWarning && (

src/browser/components/RightSidebar/ThresholdSlider.tsx

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -279,56 +279,3 @@ export const HorizontalThresholdSlider: React.FC<{ config: AutoCompactionConfig
279279
export const VerticalThresholdSlider: React.FC<{ config: AutoCompactionConfig }> = ({ config }) => (
280280
<ThresholdSlider config={config} orientation="vertical" />
281281
);
282-
283-
// ----- Read-only indicator (for tooltips) -----
284-
285-
interface ThresholdIndicatorProps {
286-
/** Threshold percentage (0-100). 100 means disabled. */
287-
threshold: number;
288-
}
289-
290-
/**
291-
* A read-only visual indicator showing the auto-compaction threshold position.
292-
* Shows the same notch markers as the interactive slider, but without drag functionality.
293-
* Designed for use in tooltips where interaction isn't possible.
294-
*/
295-
export const HorizontalThresholdIndicator: React.FC<ThresholdIndicatorProps> = ({ threshold }) => {
296-
const isEnabled = threshold < DISABLE_THRESHOLD;
297-
const color = isEnabled ? "var(--color-plan-mode)" : "var(--color-muted)";
298-
299-
// Container covers the full bar area
300-
const containerStyle: React.CSSProperties = {
301-
position: "absolute",
302-
top: 0,
303-
bottom: 0,
304-
left: 0,
305-
right: 0,
306-
zIndex: 50,
307-
pointerEvents: "none",
308-
};
309-
310-
// Indicator positioning
311-
const indicatorStyle: React.CSSProperties = {
312-
position: "absolute",
313-
pointerEvents: "none",
314-
display: "flex",
315-
alignItems: "center",
316-
left: `${threshold}%`,
317-
top: "50%",
318-
transform: "translate(-50%, -50%)",
319-
flexDirection: "column",
320-
};
321-
322-
// Line between triangles
323-
const lineStyle: React.CSSProperties = { width: 1, height: 6, background: color };
324-
325-
return (
326-
<div style={containerStyle}>
327-
<div style={indicatorStyle}>
328-
<Triangle direction="down" color={color} />
329-
<div style={lineStyle} />
330-
<Triangle direction="up" color={color} />
331-
</div>
332-
</div>
333-
);
334-
};

0 commit comments

Comments
 (0)