@causyne/agent 1.20.112 → 1.20.116
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/ARCHITECTURE.md +29 -0
- package/package.json +1 -1
- package/src/agentLoop.js +72 -37
- package/src/agentLoop.ts +70 -38
- package/src/browser/browserRuntime.js +13 -8
- package/src/browser/browserRuntime.ts +16 -8
- package/src/browser/causyneBrowser.js +7 -2
- package/src/browser/causyneBrowser.ts +8 -2
- package/src/browser/searchProviders.js +18 -7
- package/src/browser/searchProviders.ts +17 -5
- package/src/browser/snapshotWindow.js +1 -1
- package/src/browser/snapshotWindow.ts +1 -1
- package/src/browser/urlPolicy.js +21 -10
- package/src/browser/urlPolicy.ts +19 -10
- package/src/browser/workspacePreview.js +13 -1
- package/src/browser/workspacePreview.ts +11 -1
- package/src/computerUse/visionGrounding.js +31 -27
- package/src/computerUse/visionGrounding.ts +27 -27
- package/src/continuum/ui/continuumPicker.js +14 -6
- package/src/continuum/ui/continuumPicker.ts +13 -6
- package/src/continuum/ui/continuumPickerView.js +24 -15
- package/src/continuum/ui/continuumPickerView.ts +24 -16
- package/src/observer/advisory.js +32 -22
- package/src/observer/advisory.ts +30 -18
- package/src/observer/coldObserver.js +21 -33
- package/src/observer/coldObserver.ts +20 -33
- package/src/observer/evidence.js +20 -13
- package/src/observer/evidence.ts +21 -13
- package/src/observer.js +47 -12
- package/src/observer.ts +50 -18
- package/src/pluginsFactory/discovery.js +28 -16
- package/src/pluginsFactory/discovery.ts +29 -16
- package/src/pluginsFactory/pluginsFactory.js +213 -38
- package/src/pluginsFactory/pluginsFactory.ts +218 -39
- package/src/pluginsFactory/strategy.js +26 -16
- package/src/pluginsFactory/strategy.ts +34 -19
- package/src/pluginsFactory/templates.js +183 -62
- package/src/pluginsFactory/templates.ts +174 -54
- package/src/timeMachine.js +43 -22
- package/src/timeMachine.ts +44 -22
- package/src/tool-scripts/desktop_act.applescript +1 -0
- package/src/tools/computerUse.js +23 -10
- package/src/tools/computerUse.ts +19 -8
- package/src/tools/desktopAct.js +12 -1
- package/src/tools/pluginsFactory.js +108 -5
- package/src/tools/pluginsFactory.ts +115 -5
- package/src/tui/CausyneRotor.js +24 -10
- package/src/tui/CausyneRotor.ts +25 -10
- package/src/tui/activityLayout.js +9 -5
- package/src/tui/activityLayout.ts +9 -5
- package/src/tui/ask.js +34 -14
- package/src/tui/banner.js +55 -18
- package/src/tui/banner.ts +52 -17
- package/src/tui/block.js +47 -20
- package/src/tui/block.ts +54 -27
- package/src/tui/chatRenderer.js +135 -83
- package/src/tui/chatboxClipboard.js +12 -5
- package/src/tui/chatboxClipboard.ts +10 -4
- package/src/tui/clipboardImage.js +52 -42
- package/src/tui/clipboardImage.ts +50 -39
- package/src/tui/clipboardSync.js +12 -1
- package/src/tui/clipboardSync.ts +9 -1
- package/src/tui/codeProgress.js +57 -26
- package/src/tui/codeProgress.ts +57 -25
- package/src/tui/codeStreamRenderer.js +59 -14
- package/src/tui/codeStreamRenderer.ts +58 -14
- package/src/tui/commandPresentation.js +9 -2
- package/src/tui/commandPresentation.ts +9 -2
- package/src/tui/completion.js +45 -23
- package/src/tui/composerControls.js +21 -10
- package/src/tui/composerControls.ts +18 -10
- package/src/tui/composerGeometry.js +6 -4
- package/src/tui/composerGeometry.ts +6 -4
- package/src/tui/consoleGuard.js +29 -7
- package/src/tui/consoleGuard.ts +28 -7
- package/src/tui/dialogs.js +134 -71
- package/src/tui/diff.js +8 -4
- package/src/tui/history.js +6 -5
- package/src/tui/home.js +25 -13
- package/src/tui/homeView.js +37 -18
- package/src/tui/homeView.ts +38 -18
- package/src/tui/inlineSlash.js +6 -5
- package/src/tui/inlineSlash.ts +6 -5
- package/src/tui/keys.js +33 -17
- package/src/tui/layout.js +27 -9
- package/src/tui/layout.ts +26 -9
- package/src/tui/lineEditor.js +49 -23
- package/src/tui/markdownMath.js +64 -14
- package/src/tui/markdownMath.ts +69 -13
- package/src/tui/messageActionPlacement.js +28 -13
- package/src/tui/messageActionPlacement.ts +28 -13
- package/src/tui/messageInteraction.js +111 -46
- package/src/tui/messageInteraction.ts +115 -47
- package/src/tui/modelPicker.js +44 -15
- package/src/tui/modelPicker.ts +48 -15
- package/src/tui/observerPicker.js +56 -13
- package/src/tui/observerPicker.ts +73 -30
- package/src/tui/overlay.js +79 -35
- package/src/tui/overlay.ts +81 -34
- package/src/tui/prompt.js +162 -94
- package/src/tui/runningLight.js +1 -1
- package/src/tui/runningLight.ts +1 -1
- package/src/tui/scrollInteraction.js +64 -36
- package/src/tui/scrollInteraction.ts +70 -37
- package/src/tui/selectList.js +60 -32
- package/src/tui/sessionLayout.js +11 -3
- package/src/tui/sessionLayout.ts +10 -3
- package/src/tui/sessionPicker.js +74 -46
- package/src/tui/sessionPicker.ts +73 -48
- package/src/tui/sessionPickerView.js +32 -19
- package/src/tui/sessionPickerView.ts +31 -18
- package/src/tui/sessionSidebar.js +87 -57
- package/src/tui/sessionSidebar.ts +90 -54
- package/src/tui/setup.js +28 -3
- package/src/tui/setup.ts +27 -3
- package/src/tui/skillAuthoring.js +11 -5
- package/src/tui/skillAuthoring.ts +11 -5
- package/src/tui/smartLinkClick.js +75 -23
- package/src/tui/smartLinkClick.ts +86 -26
- package/src/tui/stage.js +47 -16
- package/src/tui/stage.ts +53 -18
- package/src/tui/stageSurface.js +120 -49
- package/src/tui/statusLine.js +85 -53
- package/src/tui/statusLine.ts +82 -46
- package/src/tui/terminalInputFramer.js +5 -2
- package/src/tui/text.js +117 -46
- package/src/tui/text.ts +113 -43
- package/src/tui/textLayout.js +6 -4
- package/src/tui/textLayout.ts +11 -5
- package/src/tui/theme.js +17 -8
- package/src/tui/thinkingBox.js +95 -95
- package/src/tui/thinkingBox.ts +105 -80
- package/src/tui/toolActivityPolicy.js +8 -1
- package/src/tui/toolActivityPolicy.ts +7 -1
- package/src/tui/toolDisplay.js +15 -6
- package/src/tui/toolDisplay.ts +16 -6
- package/src/tui/toolOutputNormalizer.js +16 -3
- package/src/tui/toolOutputNormalizer.ts +13 -3
- package/src/tui/transcript.js +15 -9
- package/src/tui/turnRail.js +156 -67
- package/src/tui/turnRail.ts +155 -58
- package/src/tui/usageCard.js +80 -45
- package/src/tui/usageCard.ts +81 -46
- package/src/tui/viewport.js +48 -23
- package/src/tui/viewport.ts +48 -27
- package/src/tui/viewportAnchor.js +2 -2
- package/src/tui/viewportAnchor.ts +2 -2
- package/src/tui/workspaceFileIndex.js +8 -6
- package/src/tui/workspaceFileIndex.ts +8 -6
- package/src/tui/workspaceSwitch.js +13 -10
- package/src/tui/workspaceSwitch.ts +11 -7
package/src/tui/block.js
CHANGED
|
@@ -27,6 +27,12 @@ import { visibleWidth, padEnd, truncate, wrap } from './text.js';
|
|
|
27
27
|
// Columns between the bar and the text. opencode uses paddingLeft={2} inside its
|
|
28
28
|
// bordered box; one column belongs to the bar, so the gutter is one more.
|
|
29
29
|
const GUTTER = 1;
|
|
30
|
+
function finiteWidth(width, fallback = 80) {
|
|
31
|
+
return typeof width === 'number' && Number.isFinite(width) ? Math.floor(width) : fallback;
|
|
32
|
+
}
|
|
33
|
+
function collapseLine(value) {
|
|
34
|
+
return String(value == null ? '' : value).replace(/[\r\n]+/g, ' ');
|
|
35
|
+
}
|
|
30
36
|
/**
|
|
31
37
|
* Render `lines` as one block with a left accent bar.
|
|
32
38
|
* Uses a continuous unbroken box-drawing heavy rule (barHeavy '┃')
|
|
@@ -36,21 +42,25 @@ const GUTTER = 1;
|
|
|
36
42
|
* @param options configuration options
|
|
37
43
|
* @returns rows, each exactly `width` columns wide
|
|
38
44
|
*/
|
|
39
|
-
export function barBlock(lines,
|
|
45
|
+
export function barBlock(lines, options = {}) {
|
|
46
|
+
const { width = 80, role = 'accent', filled = true, surface = 'surface', punctuate = false } = options || {};
|
|
47
|
+
void punctuate;
|
|
40
48
|
// Use continuous heavy vertical line ('┃') for clean, solid, unbroken alignment.
|
|
41
49
|
// Box-drawing characters connect seamlessly across lines in all terminal fonts without line-height leading gaps.
|
|
42
50
|
const glyph = GLYPHS.barHeavy || GLYPHS.bar || '┃';
|
|
43
51
|
const barWidth = visibleWidth(glyph);
|
|
44
|
-
const body = Math.max(1, width - barWidth - GUTTER);
|
|
52
|
+
const body = Math.max(1, finiteWidth(width) - barWidth - GUTTER);
|
|
45
53
|
const bar = paint(role, glyph);
|
|
46
54
|
const gutter = ' '.repeat(GUTTER);
|
|
47
|
-
return lines.map((
|
|
55
|
+
return (Array.isArray(lines) ? lines : []).map((rawLine) => {
|
|
48
56
|
// Clip first, then pad: a line longer than the block would otherwise push
|
|
49
57
|
// the fill past the right edge and wrap, which is the failure ChatPrompt
|
|
50
58
|
// clampRows() exists to prevent one layer up.
|
|
59
|
+
const line = collapseLine(rawLine);
|
|
51
60
|
const clipped = visibleWidth(line) > body ? truncate(line, body, GLYPHS.ellipsis) : line;
|
|
52
61
|
const padded = padEnd(clipped, body);
|
|
53
|
-
const
|
|
62
|
+
const tailReset = !filled && clipped.includes('\x1b[') ? '\x1b[0m' : '';
|
|
63
|
+
const inner = filled ? fill(surface, gutter + padded) : gutter + padded + tailReset;
|
|
54
64
|
return bar + inner;
|
|
55
65
|
});
|
|
56
66
|
}
|
|
@@ -61,20 +71,26 @@ export function barBlock(lines, { width = 80, role = 'accent', filled = true, su
|
|
|
61
71
|
* rows individually (the prompt editor, a status row) use barBlock directly.
|
|
62
72
|
*/
|
|
63
73
|
export function blockOf(text, options = {}) {
|
|
64
|
-
const
|
|
74
|
+
const safeOptions = options || {};
|
|
75
|
+
const safeWidth = Math.max(4, finiteWidth(safeOptions.width));
|
|
65
76
|
const glyph = GLYPHS.barHeavy || GLYPHS.bar || '┃';
|
|
66
|
-
const inner = Math.max(1,
|
|
77
|
+
const inner = Math.max(1, safeWidth - visibleWidth(glyph) - GUTTER);
|
|
67
78
|
const lines = wrap(String(text == null ? '' : text), inner);
|
|
68
|
-
return barBlock(lines.length ? lines : [''],
|
|
79
|
+
return barBlock(lines.length ? lines : [''], { ...safeOptions, width: safeWidth });
|
|
69
80
|
}
|
|
70
81
|
/**
|
|
71
82
|
* A bordered panel with its title inset into the top border.
|
|
72
83
|
*/
|
|
73
|
-
export function panel(rows,
|
|
74
|
-
const
|
|
84
|
+
export function panel(rows, options = {}) {
|
|
85
|
+
const { width = 80, title = '', role = 'rule' } = options || {};
|
|
86
|
+
const inner = Math.max(4, finiteWidth(width) - 2);
|
|
75
87
|
const h = GLYPHS.hLine;
|
|
76
|
-
const
|
|
77
|
-
const
|
|
88
|
+
const cleanTitle = collapseLine(title).trim();
|
|
89
|
+
const maxTitleChars = inner - 3;
|
|
90
|
+
const boundedTitle = cleanTitle && maxTitleChars >= 3
|
|
91
|
+
? truncate(cleanTitle, maxTitleChars, GLYPHS.ellipsis)
|
|
92
|
+
: '';
|
|
93
|
+
const clippedLabel = boundedTitle ? ` ${boundedTitle} ` : '';
|
|
78
94
|
const lead = clippedLabel ? h : '';
|
|
79
95
|
const trail = h.repeat(Math.max(0, inner - visibleWidth(clippedLabel) - visibleWidth(lead)));
|
|
80
96
|
const top = paint(role, GLYPHS.topLeft + lead)
|
|
@@ -82,9 +98,11 @@ export function panel(rows, { width = 80, title = '', role = 'rule' } = {}) {
|
|
|
82
98
|
+ paint(role, trail + GLYPHS.topRight);
|
|
83
99
|
const bottom = paint(role, GLYPHS.bottomLeft + h.repeat(inner) + GLYPHS.bottomRight);
|
|
84
100
|
const side = paint(role, GLYPHS.vLine);
|
|
85
|
-
const middle = rows.map((
|
|
101
|
+
const middle = (Array.isArray(rows) ? rows : []).map((rawRow) => {
|
|
102
|
+
const row = collapseLine(rawRow);
|
|
86
103
|
const clipped = visibleWidth(row) > inner ? truncate(row, inner, GLYPHS.ellipsis) : row;
|
|
87
|
-
|
|
104
|
+
const borderReset = clipped.includes('\x1b[') ? '\x1b[0m' : '';
|
|
105
|
+
return side + padEnd(clipped, inner) + borderReset + side;
|
|
88
106
|
});
|
|
89
107
|
return [top, ...middle, bottom];
|
|
90
108
|
}
|
|
@@ -92,15 +110,24 @@ export function panel(rows, { width = 80, title = '', role = 'rule' } = {}) {
|
|
|
92
110
|
* `9.2K (5%)` — what the context window has left, at a glance.
|
|
93
111
|
*/
|
|
94
112
|
export function contextMeter(usedTokens, limitTokens) {
|
|
95
|
-
const
|
|
96
|
-
const
|
|
113
|
+
const rawUsed = Number(usedTokens);
|
|
114
|
+
const rawLimit = Number(limitTokens);
|
|
115
|
+
const used = Number.isFinite(rawUsed) ? rawUsed : 0;
|
|
116
|
+
const limit = Number.isFinite(rawLimit) ? rawLimit : 0;
|
|
97
117
|
if (used <= 0)
|
|
98
118
|
return '';
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
119
|
+
const rounded = Math.round(used);
|
|
120
|
+
let compact;
|
|
121
|
+
if (rounded < 1000) {
|
|
122
|
+
compact = String(rounded);
|
|
123
|
+
}
|
|
124
|
+
else if (used < 9950) {
|
|
125
|
+
compact = `${(used / 1000).toFixed(1)}K`;
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
const thousands = Math.round(used / 1000);
|
|
129
|
+
compact = thousands < 1000 ? `${thousands}K` : `${(used / 1000000).toFixed(1)}M`;
|
|
130
|
+
}
|
|
104
131
|
if (limit <= 0)
|
|
105
132
|
return compact;
|
|
106
133
|
return `${compact} (${Math.round((used / limit) * 100)}%)`;
|
package/src/tui/block.ts
CHANGED
|
@@ -30,6 +30,14 @@ import { visibleWidth, padEnd, truncate, wrap } from './text.js';
|
|
|
30
30
|
// bordered box; one column belongs to the bar, so the gutter is one more.
|
|
31
31
|
const GUTTER = 1;
|
|
32
32
|
|
|
33
|
+
function finiteWidth(width: number | undefined, fallback = 80): number {
|
|
34
|
+
return typeof width === 'number' && Number.isFinite(width) ? Math.floor(width) : fallback;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function collapseLine(value: unknown): string {
|
|
38
|
+
return String(value == null ? '' : value).replace(/[\r\n]+/g, ' ');
|
|
39
|
+
}
|
|
40
|
+
|
|
33
41
|
export interface BarBlockOptions {
|
|
34
42
|
width?: number;
|
|
35
43
|
role?: string;
|
|
@@ -47,29 +55,33 @@ export interface BarBlockOptions {
|
|
|
47
55
|
* @param options configuration options
|
|
48
56
|
* @returns rows, each exactly `width` columns wide
|
|
49
57
|
*/
|
|
50
|
-
export function barBlock(lines: string[], {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
58
|
+
export function barBlock(lines: string[], options: BarBlockOptions | null = {}): string[] {
|
|
59
|
+
const {
|
|
60
|
+
width = 80,
|
|
61
|
+
role = 'accent',
|
|
62
|
+
filled = true,
|
|
63
|
+
surface = 'surface',
|
|
64
|
+
punctuate = false
|
|
65
|
+
} = options || {};
|
|
66
|
+
void punctuate;
|
|
57
67
|
// Use continuous heavy vertical line ('┃') for clean, solid, unbroken alignment.
|
|
58
68
|
// Box-drawing characters connect seamlessly across lines in all terminal fonts without line-height leading gaps.
|
|
59
69
|
const glyph = GLYPHS.barHeavy || GLYPHS.bar || '┃';
|
|
60
70
|
|
|
61
71
|
const barWidth = visibleWidth(glyph);
|
|
62
|
-
const body = Math.max(1, width - barWidth - GUTTER);
|
|
72
|
+
const body = Math.max(1, finiteWidth(width) - barWidth - GUTTER);
|
|
63
73
|
const bar = paint(role, glyph);
|
|
64
74
|
const gutter = ' '.repeat(GUTTER);
|
|
65
75
|
|
|
66
|
-
return lines.map((
|
|
76
|
+
return (Array.isArray(lines) ? lines : []).map((rawLine) => {
|
|
67
77
|
// Clip first, then pad: a line longer than the block would otherwise push
|
|
68
78
|
// the fill past the right edge and wrap, which is the failure ChatPrompt
|
|
69
79
|
// clampRows() exists to prevent one layer up.
|
|
80
|
+
const line = collapseLine(rawLine);
|
|
70
81
|
const clipped = visibleWidth(line) > body ? truncate(line, body, GLYPHS.ellipsis) : line;
|
|
71
82
|
const padded = padEnd(clipped, body);
|
|
72
|
-
const
|
|
83
|
+
const tailReset = !filled && clipped.includes('\x1b[') ? '\x1b[0m' : '';
|
|
84
|
+
const inner = filled ? fill(surface, gutter + padded) : gutter + padded + tailReset;
|
|
73
85
|
return bar + inner;
|
|
74
86
|
});
|
|
75
87
|
}
|
|
@@ -80,12 +92,13 @@ export function barBlock(lines: string[], {
|
|
|
80
92
|
* The convenience form for plain prose. Callers that have already styled their
|
|
81
93
|
* rows individually (the prompt editor, a status row) use barBlock directly.
|
|
82
94
|
*/
|
|
83
|
-
export function blockOf(text: string, options: BarBlockOptions = {}): string[] {
|
|
84
|
-
const
|
|
95
|
+
export function blockOf(text: string, options: BarBlockOptions | null = {}): string[] {
|
|
96
|
+
const safeOptions = options || {};
|
|
97
|
+
const safeWidth = Math.max(4, finiteWidth(safeOptions.width));
|
|
85
98
|
const glyph = GLYPHS.barHeavy || GLYPHS.bar || '┃';
|
|
86
|
-
const inner = Math.max(1,
|
|
99
|
+
const inner = Math.max(1, safeWidth - visibleWidth(glyph) - GUTTER);
|
|
87
100
|
const lines = wrap(String(text == null ? '' : text), inner);
|
|
88
|
-
return barBlock(lines.length ? lines : [''],
|
|
101
|
+
return barBlock(lines.length ? lines : [''], { ...safeOptions, width: safeWidth });
|
|
89
102
|
}
|
|
90
103
|
|
|
91
104
|
export interface PanelOptions {
|
|
@@ -97,11 +110,16 @@ export interface PanelOptions {
|
|
|
97
110
|
/**
|
|
98
111
|
* A bordered panel with its title inset into the top border.
|
|
99
112
|
*/
|
|
100
|
-
export function panel(rows: string[],
|
|
101
|
-
const
|
|
113
|
+
export function panel(rows: string[], options: PanelOptions | null = {}): string[] {
|
|
114
|
+
const { width = 80, title = '', role = 'rule' } = options || {};
|
|
115
|
+
const inner = Math.max(4, finiteWidth(width) - 2);
|
|
102
116
|
const h = GLYPHS.hLine;
|
|
103
|
-
const
|
|
104
|
-
const
|
|
117
|
+
const cleanTitle = collapseLine(title).trim();
|
|
118
|
+
const maxTitleChars = inner - 3;
|
|
119
|
+
const boundedTitle = cleanTitle && maxTitleChars >= 3
|
|
120
|
+
? truncate(cleanTitle, maxTitleChars, GLYPHS.ellipsis)
|
|
121
|
+
: '';
|
|
122
|
+
const clippedLabel = boundedTitle ? ` ${boundedTitle} ` : '';
|
|
105
123
|
const lead = clippedLabel ? h : '';
|
|
106
124
|
const trail = h.repeat(Math.max(0, inner - visibleWidth(clippedLabel) - visibleWidth(lead)));
|
|
107
125
|
|
|
@@ -111,9 +129,11 @@ export function panel(rows: string[], { width = 80, title = '', role = 'rule' }:
|
|
|
111
129
|
const bottom = paint(role, GLYPHS.bottomLeft + h.repeat(inner) + GLYPHS.bottomRight);
|
|
112
130
|
|
|
113
131
|
const side = paint(role, GLYPHS.vLine);
|
|
114
|
-
const middle = rows.map((
|
|
132
|
+
const middle = (Array.isArray(rows) ? rows : []).map((rawRow) => {
|
|
133
|
+
const row = collapseLine(rawRow);
|
|
115
134
|
const clipped = visibleWidth(row) > inner ? truncate(row, inner, GLYPHS.ellipsis) : row;
|
|
116
|
-
|
|
135
|
+
const borderReset = clipped.includes('\x1b[') ? '\x1b[0m' : '';
|
|
136
|
+
return side + padEnd(clipped, inner) + borderReset + side;
|
|
117
137
|
});
|
|
118
138
|
|
|
119
139
|
return [top, ...middle, bottom];
|
|
@@ -123,14 +143,21 @@ export function panel(rows: string[], { width = 80, title = '', role = 'rule' }:
|
|
|
123
143
|
* `9.2K (5%)` — what the context window has left, at a glance.
|
|
124
144
|
*/
|
|
125
145
|
export function contextMeter(usedTokens: number, limitTokens: number): string {
|
|
126
|
-
const
|
|
127
|
-
const
|
|
146
|
+
const rawUsed = Number(usedTokens);
|
|
147
|
+
const rawLimit = Number(limitTokens);
|
|
148
|
+
const used = Number.isFinite(rawUsed) ? rawUsed : 0;
|
|
149
|
+
const limit = Number.isFinite(rawLimit) ? rawLimit : 0;
|
|
128
150
|
if (used <= 0) return '';
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
151
|
+
const rounded = Math.round(used);
|
|
152
|
+
let compact: string;
|
|
153
|
+
if (rounded < 1000) {
|
|
154
|
+
compact = String(rounded);
|
|
155
|
+
} else if (used < 9950) {
|
|
156
|
+
compact = `${(used / 1000).toFixed(1)}K`;
|
|
157
|
+
} else {
|
|
158
|
+
const thousands = Math.round(used / 1000);
|
|
159
|
+
compact = thousands < 1000 ? `${thousands}K` : `${(used / 1000000).toFixed(1)}M`;
|
|
160
|
+
}
|
|
134
161
|
if (limit <= 0) return compact;
|
|
135
162
|
return `${compact} (${Math.round((used / limit) * 100)}%)`;
|
|
136
163
|
}
|