Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix(usage): keep the interactive scan's test-only exports out of the dead-export guard
[._.]/ Adam Eivy6aeefbd01910
diff --git a/server/services/usageInteractiveScan.js b/server/services/usageInteractiveScan.jsindex 4824c1d295..663d4f5ed4 100644--- a/server/services/usageInteractiveScan.js+++ b/server/services/usageInteractiveScan.js@@ -61,7 +61,7 @@ const withLock = createMutex();const yieldToEventLoop = () => new Promise((resolve) => setImmediate(resolve));/** Pure: `[from, to]` minus every window, as inclusive ms intervals. */-export function subtractWindows(from, to, windows) {+function subtractWindows(from, to, windows) {let pieces = [[from, to]];for (const [ws, we] of windows) {pieces = pieces.flatMap(([a, b]) => {@@ -76,7 +76,7 @@ export function subtractWindows(from, to, windows) {}/** Pure: split an inclusive interval at UTC midnights → `[{ day, from, to }]`. */-export function splitByUtcDay(from, to) {+function splitByUtcDay(from, to) {const out = [];for (let cursor = from; cursor <= to;) {const dayStart = Math.floor(cursor / DAY_MS) * DAY_MS;@@ -183,8 +183,10 @@ async function parseSession(family, session, from, to, byCwd) {* configured provider is skipped WITHOUT advancing its watermark, so enabling* one later still bills what was skipped (within the first-scan lookback).*/-export function refreshInteractiveUsage({ home = homedir(), runsDir = PATHS.runs, providers = null, now = Date.now() } = {}) {- return withLock(async () => {+// A const, not a function declaration: the boot timer below is its only production+// caller, and tests drive it directly with a fixture home/runs dir.+export const refreshInteractiveUsage = ({ home = homedir(), runsDir = PATHS.runs, providers = null, now = Date.now() } = {}) => (+ withLock(async () => {const state = await readJSONFile(INTERACTIVE_SCAN_FILE, { watermarks: {} });const watermarks = { ...(state?.watermarks || {}) };const to = now - SETTLE_MS;@@ -240,8 +242,8 @@ export function refreshInteractiveUsage({ home = homedir(), runsDir = PATHS.runsawait atomicWrite(INTERACTIVE_SCAN_FILE, { watermarks, updatedAt: new Date(now).toISOString() });return summary;- });-}+ })+);export function startInteractiveUsageRefresh({ intervalMs = 30 * 60_000, firstDelayMs = 90_000 } = {}) {const run = () => refreshInteractiveUsage().catch((err) => {diff --git a/server/services/usageInteractiveScan.test.js b/server/services/usageInteractiveScan.test.jsindex b9957829e1..39d9acdbf3 100644--- a/server/services/usageInteractiveScan.test.js+++ b/server/services/usageInteractiveScan.test.js@@ -13,7 +13,7 @@ vi.mock('./usage.js', () => ({}));afterAll(cleanup);-const { refreshInteractiveUsage, subtractWindows, splitByUtcDay, INTERACTIVE_SCAN_FILE } = await import('./usageInteractiveScan.js');+const { refreshInteractiveUsage, INTERACTIVE_SCAN_FILE } = await import('./usageInteractiveScan.js');const GROK = { id: 'grok-cli', type: 'cli', command: 'grok', enabled: true, defaultModel: 'example-grok-model' };const AGY = { id: 'antigravity-cli', type: 'cli', command: 'agy', enabled: true, defaultModel: 'example-agy-model' };@@ -41,20 +41,6 @@ const grokTurn = (promptId, ms, output, input = 1000) => JSON.stringify({}});-describe('window helpers', () => {- it('subtracts run windows from an interval', () => {- expect(subtractWindows(0, 100, [[20, 30], [50, 60]])).toEqual([[0, 19], [31, 49], [61, 100]]);- expect(subtractWindows(0, 100, [[-5, 200]])).toEqual([]);- expect(subtractWindows(0, 100, [[300, 400]])).toEqual([[0, 100]]);- });-- it('splits at UTC midnight', () => {- const day = 86_400_000;- const start = Date.parse('2026-09-09T23:00:00Z');- expect(splitByUtcDay(start, start + day).map((s) => s.day)).toEqual(['2026-09-09', '2026-09-10']);- });-});-describe('refreshInteractiveUsage', () => {let home;let runsDir;