mirror of
https://github.com/jarrodwatts/claude-hud.git
synced 2026-05-21 15:52:37 +00:00
22 lines
969 B
JavaScript
22 lines
969 B
JavaScript
import { formatBytes } from '../../memory.js';
|
|
import { label, getQuotaColor, quotaBar, RESET } from '../colors.js';
|
|
import { getAdaptiveBarWidth } from '../../utils/terminal.js';
|
|
export function renderMemoryLine(ctx) {
|
|
const display = ctx.config?.display;
|
|
const colors = ctx.config?.colors;
|
|
if (ctx.config?.lineLayout !== 'expanded') {
|
|
return null;
|
|
}
|
|
if (display?.showMemoryUsage !== true) {
|
|
return null;
|
|
}
|
|
if (!ctx.memoryUsage) {
|
|
return null;
|
|
}
|
|
const memoryLabel = label('Approx RAM', colors);
|
|
const percentColor = getQuotaColor(ctx.memoryUsage.usedPercent, colors);
|
|
const percent = `${percentColor}${ctx.memoryUsage.usedPercent}%${RESET}`;
|
|
const bar = quotaBar(ctx.memoryUsage.usedPercent, getAdaptiveBarWidth(), colors);
|
|
return `${memoryLabel} ${bar} ${formatBytes(ctx.memoryUsage.usedBytes)} / ${formatBytes(ctx.memoryUsage.totalBytes)} (${percent})`;
|
|
}
|
|
//# sourceMappingURL=memory.js.map
|