Skip to content

The agent that grows with you

feat(desktop): fold the compression count into the context meter

Brooklyn Nicholsonaa96575ed11c
diff --git a/apps/desktop/src/app/shell/compression-count-status.test.tsx b/apps/desktop/src/app/shell/compression-count-status.test.tsx
deleted file mode 100644
index bee4c19e13e..00000000000
--- a/apps/desktop/src/app/shell/compression-count-status.test.tsx
+++ /dev/null
@@ -1,25 +0,0 @@
-import { cleanup, fireEvent, render, screen } from '@testing-library/react'
-import { afterEach, describe, expect, it } from 'vitest'
-
-import { CompressionCountStatus } from './compression-count-status'
-
-afterEach(cleanup)
-
-describe('CompressionCountStatus', () => {
- it('renders an explicit zero with a count tooltip', async () => {
- render(<CompressionCountStatus count={0} />)
-
- const counter = screen.getByTestId('compression-count')
- expect(counter.textContent).toContain('0')
- expect(counter.getAttribute('aria-label')).toBe('Compressions: 0')
-
- fireEvent.pointerMove(counter, { pointerType: 'mouse' })
- expect((await screen.findByRole('tooltip')).textContent).toBe('Compressions: 0')
- })
-
- it('does not fabricate a count when live usage omits it', () => {
- const { container } = render(<CompressionCountStatus />)
-
- expect(container.innerHTML).toBe('')
- })
-})
diff --git a/apps/desktop/src/app/shell/compression-count-status.tsx b/apps/desktop/src/app/shell/compression-count-status.tsx
deleted file mode 100644
index 340b0685fba..00000000000
--- a/apps/desktop/src/app/shell/compression-count-status.tsx
+++ /dev/null
@@ -1,29 +0,0 @@
-import { Tip } from '@/components/ui/tooltip'
-import { useI18n } from '@/i18n'
-
-interface CompressionCountStatusProps {
- count?: number
-}
-
-/** Current live runtime count from `usage.compressions`.
- * Missing stays missing for older/cold usage snapshots; zero is real data. */
-export function CompressionCountStatus({ count }: CompressionCountStatusProps) {
- const { t } = useI18n()
-
- if (count === undefined) {
- return null
- }
-
- return (
- <Tip label={t.shell.statusbar.compressions(count)}>
- <div
- aria-label={t.shell.statusbar.compressions(count)}
- className="inline-flex h-full items-center gap-1 px-1.5 text-[0.6875rem] text-(--ui-text-tertiary)"
- data-testid="compression-count"
- >
- <span aria-hidden="true">πŸ—œοΈ</span>
- <span className="tabular-nums">{count}</span>
- </div>
- </Tip>
- )
-}
diff --git a/apps/desktop/src/app/shell/context-usage-panel.test.tsx b/apps/desktop/src/app/shell/context-usage-panel.test.tsx
index 8745c79acca..c2c6b1f9684 100644
--- a/apps/desktop/src/app/shell/context-usage-panel.test.tsx
+++ b/apps/desktop/src/app/shell/context-usage-panel.test.tsx
@@ -4,7 +4,7 @@ import { afterEach, describe, expect, it, vi } from 'vitest'
import type { ContextBreakdown, UsageStats } from '@/types/hermes'
-import { ContextUsagePanel } from './context-usage-panel'
+import { ContextMeterDetail, ContextUsagePanel } from './context-usage-panel'
import { useContextBreakdown } from './hooks/use-context-breakdown'
const usage: UsageStats = {
@@ -107,4 +107,30 @@ describe('ContextUsagePanel', () => {
expect(screen.getByText('47% Full')).toBeTruthy()
expect(screen.getByText('Conversation')).toBeTruthy()
})
+
+ it('reports the live compression count, zero included, and never invents one', () => {
+ const { rerender } = render(<ContextUsagePanel breakdown={breakdown} loading={false} usage={usage} />)
+
+ expect(screen.queryByTestId('context-panel-compressions')).toBeNull()
+
+ for (const compressions of [0, 3]) {
+ rerender(<ContextUsagePanel breakdown={breakdown} loading={false} usage={{ ...usage, compressions }} />)
+ expect(screen.getByTestId('context-panel-compressions').textContent).toBe(`Compressions: ${compressions}`)
+ }
+ })
+})
+
+describe('ContextMeterDetail', () => {
+ it('adds the count to the meter only once the session has compacted', () => {
+ for (const compressions of [undefined, 0]) {
+ const { container, unmount } = render(<ContextMeterDetail bar="[β–ˆβ–ˆβ–‘β–‘] 47%" compressions={compressions} />)
+
+ expect(container.textContent).toBe('[β–ˆβ–ˆβ–‘β–‘] 47%')
+ unmount()
+ }
+
+ render(<ContextMeterDetail bar="[β–ˆβ–ˆβ–‘β–‘] 47%" compressions={2} />)
+
+ expect(screen.getByTestId('context-meter-compressions').textContent).toBe('2')
+ })
})
diff --git a/apps/desktop/src/app/shell/context-usage-panel.tsx b/apps/desktop/src/app/shell/context-usage-panel.tsx
index f6041935364..bb4800a822d 100644
--- a/apps/desktop/src/app/shell/context-usage-panel.tsx
+++ b/apps/desktop/src/app/shell/context-usage-panel.tsx
@@ -1,6 +1,7 @@
import { compactNumber } from '@hermes/shared'
import { useMemo } from 'react'
+import { Codicon } from '@/components/ui/codicon'
import { useI18n } from '@/i18n'
import { cn } from '@/lib/utils'
import type { ContextBreakdown, ContextUsageCategory, UsageStats } from '@/types/hermes'
@@ -47,9 +48,21 @@ export function ContextUsagePanel({ breakdown, loading, usage }: ContextUsagePan
</span>
</div>
- <p className="text-[0.6875rem] text-foreground">
- {usage.context_estimated ? '~' : ''}
- {copy.percentFull(contextPercent)}
+ <p className="flex items-center justify-between gap-2 text-[0.6875rem] text-foreground">
+ <span>
+ {usage.context_estimated ? '~' : ''}
+ {copy.percentFull(contextPercent)}
+ </span>
+
+ {usage.compressions !== undefined && (
+ <span
+ className="inline-flex items-center gap-1 text-muted-foreground"
+ data-testid="context-panel-compressions"
+ >
+ <Codicon aria-hidden="true" name="layers" size="0.6875rem" />
+ {t.shell.statusbar.compressions(usage.compressions)}
+ </span>
+ )}
</p>
<ContextUsageBar categories={categories} segmentTotal={segmentTotal} />
@@ -75,6 +88,26 @@ export function ContextUsagePanel({ breakdown, loading, usage }: ContextUsagePan
)
}
+/** The statusbar meter's trailing `[bar] N%`, plus a quiet `layers N` once the
+ * live session has compacted β€” the same glyph the sidebar puts on rows that
+ * came from a compression, so the two read as one idea. Zero stays out of the
+ * meter (every fresh session would carry noise); the panel shows it. */
+export function ContextMeterDetail({ bar, compressions }: { bar: string; compressions?: number }) {
+ if (!compressions) {
+ return bar
+ }
+
+ return (
+ <span className="inline-flex items-center gap-1.5">
+ {bar}
+ <span className="inline-flex items-center gap-0.5 tabular-nums" data-testid="context-meter-compressions">
+ <Codicon aria-hidden="true" name="layers" size="0.6875rem" />
+ {compressions}
+ </span>
+ </span>
+ )
+}
+
function ContextUsageBar({
categories,
segmentTotal
diff --git a/apps/desktop/src/app/shell/hooks/use-statusbar-items.tsx b/apps/desktop/src/app/shell/hooks/use-statusbar-items.tsx
index d73b537a8c9..c1417c7e6b1 100644
--- a/apps/desktop/src/app/shell/hooks/use-statusbar-items.tsx
+++ b/apps/desktop/src/app/shell/hooks/use-statusbar-items.tsx
@@ -7,8 +7,7 @@ import { ProfileSwitcher } from '@/app/chat/sidebar/profile-dropdown-switcher'
import type { CommandCenterSection } from '@/app/command-center'
import { toggleTerminalPane } from '@/app/right-sidebar/terminal/reveal-focus'
import { useApprovalModeStatusbarItem } from '@/app/shell/approval-mode-menu'
-import { CompressionCountStatus } from '@/app/shell/compression-count-status'
-import { ContextUsagePanel } from '@/app/shell/context-usage-panel'
+import { ContextMeterDetail, ContextUsagePanel } from '@/app/shell/context-usage-panel'
import { GatewayMenuPanel } from '@/app/shell/gateway-menu-panel'
import { useContextBreakdown } from '@/app/shell/hooks/use-context-breakdown'
import { useSystemResourcesStatusbarItem } from '@/app/shell/system-resources-statusbar'
@@ -674,7 +673,7 @@ export function useStatusbarItems({
variant: 'text'
},
{
- detail: contextBar || undefined,
+ detail: contextBar ? <ContextMeterDetail bar={contextBar} compressions={currentUsage.compressions} /> : undefined,
// Never self-hide: the user opted this item in (it's hidden-by-
// default), so an empty label must render as a waiting placeholder,
// not a vanished item β€” an enabled-but-invisible toggle reads as
@@ -689,11 +688,6 @@ export function useStatusbarItems({
toggleLabel: copy.toggleContextUsage,
variant: 'menu'
},
- {
- hidden: contextItemHidden || currentUsage.compressions === undefined,
- id: 'compression-count',
- render: () => <CompressionCountStatus count={currentUsage.compressions} />
- },
{
icon: <Layers3 className="size-3" />,
id: 'cache-hit-rate',
@@ -751,7 +745,6 @@ export function useStatusbarItems({
contextBar,
contextBreakdown,
contextBreakdownLoading,
- contextItemHidden,
contextUsage,
copy,
currentUsage.compressions,