Skip to content

Commit 772eb0d

Browse files
luoxuanzaoQoder-AI
andauthored
feat(context): draw the usage meter as a full ring (#86)
The meter beside the composer swept a 240° arc from the upper-left around the bottom to the upper-right, so the gap at the top read as a broken circle and the same percentage covered less visual ground than a ring would. The gauge is now a complete circle that fills clockwise from 12 o'clock, drawn with two <circle> elements instead of an arc path. Only the shape changes. The percentage label, the hover tooltip with the token counts, and the pale-red warning state above 80% behave as before, and the existing dash-offset maths carries over since the fill length is still a fraction of the stroke's total length. Co-authored-by: QoderAI (Qwen 3.8 Max) <qoder_ai@qoder.com>
1 parent ded194f commit 772eb0d

2 files changed

Lines changed: 17 additions & 20 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ version with its date and start a fresh empty `[Unreleased]` above it.
1111

1212
## [Unreleased]
1313

14+
### Changed
15+
16+
- The context usage meter beside the composer is now a complete ring that fills
17+
clockwise from the top, replacing the 240° arc. The percentage, the hover
18+
tooltip, and the pale-red warning state above 80% are unchanged.
19+
1420
## [1.0.16] - 2026-09-29
1521

1622
### Changed

‎src/features/chat/ui/input-toolbar.ts‎

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ export class McpServerSelector {
681681

682682
export class ContextUsageMeter {
683683
private container: HTMLElement;
684-
private fillPath: SVGPathElement | null = null;
684+
private fillPath: SVGCircleElement | null = null;
685685
private percentEl: HTMLElement | null = null;
686686
private circumference: number = 0;
687687

@@ -703,19 +703,7 @@ export class ContextUsageMeter {
703703
const cx = size / 2;
704704
const cy = size / 2;
705705

706-
// 240° arc: from 150° to 390° (upper-left through bottom to upper-right)
707-
const startAngle = 150;
708-
const endAngle = 390;
709-
const arcDegrees = endAngle - startAngle;
710-
const arcRadians = (arcDegrees * Math.PI) / 180;
711-
this.circumference = radius * arcRadians;
712-
713-
const startRad = (startAngle * Math.PI) / 180;
714-
const endRad = (endAngle * Math.PI) / 180;
715-
const x1 = cx + radius * Math.cos(startRad);
716-
const y1 = cy + radius * Math.sin(startRad);
717-
const x2 = cx + radius * Math.cos(endRad);
718-
const y2 = cy + radius * Math.sin(endRad);
706+
this.circumference = 2 * Math.PI * radius;
719707

720708
const gaugeEl = this.container.createDiv({ cls: 'qoderian-context-meter-gauge' });
721709
const svg = gaugeEl.createSvg('svg', {
@@ -726,26 +714,29 @@ export class ContextUsageMeter {
726714
},
727715
});
728716

729-
const pathData = `M ${x1} ${y1} A ${radius} ${radius} 0 1 1 ${x2} ${y2}`;
730-
svg.createSvg('path', {
717+
svg.createSvg('circle', {
731718
cls: 'qoderian-meter-bg',
732719
attr: {
733-
d: pathData,
720+
cx: String(cx),
721+
cy: String(cy),
722+
r: String(radius),
734723
fill: 'none',
735724
'stroke-width': String(strokeWidth),
736-
'stroke-linecap': 'round',
737725
},
738726
});
739727

740-
const fillPath = svg.createSvg('path', {
728+
const fillPath = svg.createSvg('circle', {
741729
cls: 'qoderian-meter-fill',
742730
attr: {
743-
d: pathData,
731+
cx: String(cx),
732+
cy: String(cy),
733+
r: String(radius),
744734
fill: 'none',
745735
'stroke-width': String(strokeWidth),
746736
'stroke-linecap': 'round',
747737
'stroke-dasharray': String(this.circumference),
748738
'stroke-dashoffset': String(this.circumference),
739+
transform: `rotate(-90 ${cx} ${cy})`,
749740
},
750741
});
751742
this.fillPath = fillPath;

0 commit comments

Comments
 (0)