mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 12:54:20 +01:00
feat(frontend): show context usage on the composer model pill
The model pill shows the context percentage with a tone meter, and the model picker gains a context strip with a Compact action.
This commit is contained in:
1 parent
36d35cc974
commit
52162d5c4a
14 files changed
+438
-13
No files matched your search
@@ -0,0 +1,29 @@
|
||||
import { cn } from '@/lib/utils'
|
||||
import { CONTEXT_USAGE_BG_CLASS, contextUsageTone } from '@/lib/contextUsage'
|
||||
|
||||
interface ContextUsageMeterProps {
|
||||
percentage: number | null
|
||||
className?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Two-pixel context-window meter: a muted track with a tone-coloured fill sized to `min(percentage, 100)`.
|
||||
* Purely decorative, so the surrounding readout carries the accessible label.
|
||||
*/
|
||||
export function ContextUsageMeter({ percentage, className }: ContextUsageMeterProps) {
|
||||
const width = percentage === null ? 0 : Math.min(percentage, 100)
|
||||
|
||||
return (
|
||||
<div
|
||||
data-testid="context-usage-meter"
|
||||
aria-hidden="true"
|
||||
className={cn('h-0.5 w-full overflow-hidden bg-border/50', className)}
|
||||
>
|
||||
<div
|
||||
data-testid="context-usage-meter-fill"
|
||||
className={cn('h-full', CONTEXT_USAGE_BG_CLASS[contextUsageTone(percentage)])}
|
||||
style={{ width: `${width}%` }}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user