mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-03 14:09:42 +02:00
The header chip previously only repopulated on reload from per-browser localStorage, so a fresh browser (or cleared storage) stayed blank until a session next rendered telemetry. Store the latest broadcast telemetry process-wide (plan-usage-latest.ts) and include it as `planUsage` in getLightState — the per-connection SSE init snapshot — so handleInit paints the chip immediately on every fresh load / reconnect, authoritative over the localStorage restore. Null until the first telemetry of the process. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
23 lines
764 B
TypeScript
23 lines
764 B
TypeScript
/**
|
|
* @fileoverview Process-wide last-known plan-usage telemetry (account-global).
|
|
*
|
|
* The status-telemetry route writes the latest broadcast value here; the SSE
|
|
* init snapshot (`getLightState`) replays it so the header "Plan Usage Limits"
|
|
* chip shows immediately on a fresh page load / SSE reconnect — before any new
|
|
* statusline render arrives, and without relying on per-browser localStorage.
|
|
*
|
|
* Null until the first telemetry of the process; cleared naturally on restart.
|
|
*
|
|
* @module plan-usage-latest
|
|
*/
|
|
|
|
let latest: Record<string, unknown> | null = null;
|
|
|
|
export function setLatestPlanUsage(value: Record<string, unknown>): void {
|
|
latest = value;
|
|
}
|
|
|
|
export function getLatestPlanUsage(): Record<string, unknown> | null {
|
|
return latest;
|
|
}
|