Skip to content

Commit b328d2d

Browse files
authored
🤖 feat: add auto-compaction threshold indicator to context bar (#1206)
Shows a small vertical tick mark on the context usage bar at the auto-compaction threshold position. Hidden when disabled. --- _Generated with `mux` • Model: `mux-gateway:anthropic/claude-opus-4-5` • Thinking: `high`_
1 parent 0d5f0d7 commit b328d2d

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

‎src/browser/components/ContextUsageIndicatorButton.tsx‎

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@ import { TokenMeter } from "./RightSidebar/TokenMeter";
66
import type { AutoCompactionConfig } from "./RightSidebar/ThresholdSlider";
77
import { formatTokens, type TokenMeterData } from "@/common/utils/tokens/tokenMeterUtils";
88

9+
/** Compact threshold tick mark for the button view */
10+
const CompactThresholdIndicator: React.FC<{ threshold: number }> = ({ threshold }) => {
11+
if (threshold >= 100) return null;
12+
13+
return (
14+
<div
15+
className="bg-plan-mode pointer-events-none absolute top-0 z-50 h-full w-px"
16+
style={{ left: `${threshold}%` }}
17+
/>
18+
);
19+
};
20+
921
interface ContextUsageIndicatorButtonProps {
1022
data: TokenMeterData;
1123
autoCompaction?: AutoCompactionConfig;
@@ -19,6 +31,8 @@ export const ContextUsageIndicatorButton: React.FC<ContextUsageIndicatorButtonPr
1931

2032
if (data.totalTokens === 0) return null;
2133

34+
const isAutoCompactionEnabled = autoCompaction && autoCompaction.threshold < 100;
35+
2236
const ariaLabel = data.maxTokens
2337
? `Context usage: ${formatTokens(data.totalTokens)} / ${formatTokens(data.maxTokens)} (${data.totalPercentage.toFixed(
2438
1
@@ -32,15 +46,20 @@ export const ContextUsageIndicatorButton: React.FC<ContextUsageIndicatorButtonPr
3246
<PopoverTrigger asChild>
3347
<button
3448
aria-label={ariaLabel}
35-
className="hover:bg-sidebar-hover flex h-6 w-20 cursor-pointer items-center rounded px-1"
49+
className="hover:bg-sidebar-hover flex h-6 cursor-pointer items-center rounded px-1"
3650
type="button"
3751
>
38-
<TokenMeter
39-
segments={data.segments}
40-
orientation="horizontal"
41-
className="h-2"
42-
trackClassName="bg-dark"
43-
/>
52+
<div className="relative h-2 w-20">
53+
<TokenMeter
54+
segments={data.segments}
55+
orientation="horizontal"
56+
className="h-2"
57+
trackClassName="bg-dark"
58+
/>
59+
{isAutoCompactionEnabled && (
60+
<CompactThresholdIndicator threshold={autoCompaction.threshold} />
61+
)}
62+
</div>
4463
</button>
4564
</PopoverTrigger>
4665
</TooltipTrigger>

0 commit comments

Comments
 (0)