@@ -106,16 +106,16 @@ const { createInitialStatus, applyRefreshResults } = require(path.join(OUT, 'cor
106106
107107// === Status bar text: all no-data ===
108108
109- test ( 'formatStatusBarText: all disabled returns no local usage ' , ( ) => {
109+ test ( 'formatStatusBarText: all disabled returns local history label ' , ( ) => {
110110 const status = createInitialStatus ( [ ] ) ;
111111 const t = formatStatusBarText ( status ) ;
112- assert . strictEqual ( t , 'PromptFuel: no local usage ' ) ;
112+ assert . strictEqual ( t , 'PromptFuel: local history ' ) ;
113113} ) ;
114114
115- test ( 'formatStatusBarText: all no-data returns no local usage ' , ( ) => {
115+ test ( 'formatStatusBarText: all no-data returns local history label ' , ( ) => {
116116 const status = createInitialStatus ( [ 'claude' , 'codex' ] ) ;
117117 const t = formatStatusBarText ( status ) ;
118- assert . strictEqual ( t , 'PromptFuel: no local usage ' ) ;
118+ assert . strictEqual ( t , 'PromptFuel: local history ' ) ;
119119} ) ;
120120
121121// === Status bar text: loaded states ===
@@ -136,7 +136,7 @@ test('formatStatusBarText: loaded shows compact aggregate with local suffix', ()
136136 ) ;
137137 const t = formatStatusBarText ( status ) ;
138138 assert . ok ( t . includes ( '5.0K' ) , `expected "5.0K" in "${ t } "` ) ;
139- assert . ok ( t . includes ( 'local' ) , `expected "local" suffix in "${ t } "` ) ;
139+ assert . ok ( t . includes ( 'local history ' ) , `expected "local history " suffix in "${ t } "` ) ;
140140 assert . ok ( ! t . includes ( ' | ' ) , `should not include per-provider pipe separator in "${ t } "` ) ;
141141} ) ;
142142
@@ -160,7 +160,7 @@ test('formatStatusBarText: mixed providers shows single aggregate', () => {
160160 const t = formatStatusBarText ( status ) ;
161161 assert . ok ( t . startsWith ( 'PromptFuel:' ) , `expected "PromptFuel:" prefix in "${ t } "` ) ;
162162 assert . ok ( t . includes ( '5.0K' ) , `expected aggregate "5.0K" in "${ t } "` ) ;
163- assert . ok ( t . includes ( 'local' ) , `expected "local" suffix in "${ t } "` ) ;
163+ assert . ok ( t . includes ( 'local history ' ) , `expected "local history " suffix in "${ t } "` ) ;
164164 assert . ok ( ! t . includes ( ' | ' ) , `should not include per-provider pipe separator in "${ t } "` ) ;
165165} ) ;
166166
@@ -176,7 +176,7 @@ test('formatStatusBarText: both loaded shows single aggregate total', () => {
176176 ) ;
177177 const t = formatStatusBarText ( status ) ;
178178 assert . ok ( t . includes ( '15.5K' ) , `expected aggregate "15.5K" in "${ t } "` ) ;
179- assert . ok ( t . includes ( 'local' ) , `expected "local" suffix in "${ t } "` ) ;
179+ assert . ok ( t . includes ( 'local history ' ) , `expected "local history " suffix in "${ t } "` ) ;
180180 assert . ok ( ! t . includes ( ' | ' ) , `should not include per-provider pipe separator in "${ t } "` ) ;
181181} ) ;
182182
@@ -189,7 +189,17 @@ test('formatStatusBarText: large token counts use M suffix', () => {
189189 ) ;
190190 const t = formatStatusBarText ( status ) ;
191191 assert . ok ( t . includes ( '2.5M' ) , `expected "2.5M" in "${ t } "` ) ;
192- assert . ok ( t . includes ( 'local' ) , `expected "local" suffix in "${ t } "` ) ;
192+ assert . ok ( t . includes ( 'local history' ) , `expected "local history" suffix in "${ t } "` ) ;
193+ } ) ;
194+
195+ test ( 'formatStatusBarText: billion token counts use B suffix' , ( ) => {
196+ const status = applyRefreshResults (
197+ createInitialStatus ( [ 'claude' ] ) ,
198+ [ { providerId : 'claude' , status : 'ok' , totalTokens : 6700000000 , totalAssistantMessages : 10 , filesFound : 5 } ] ,
199+ ) ;
200+ const t = formatStatusBarText ( status ) ;
201+ assert . ok ( t . includes ( '6.7B' ) , `expected "6.7B" in "${ t } "` ) ;
202+ assert . ok ( t . includes ( 'local history' ) , `expected "local history" suffix in "${ t } "` ) ;
193203} ) ;
194204
195205test ( 'formatStatusBarText: small token counts show raw number' , ( ) => {
@@ -199,7 +209,7 @@ test('formatStatusBarText: small token counts show raw number', () => {
199209 ) ;
200210 const t = formatStatusBarText ( status ) ;
201211 assert . ok ( t . includes ( '500' ) , `expected "500" in "${ t } "` ) ;
202- assert . ok ( t . includes ( 'local' ) , `expected "local" suffix in "${ t } "` ) ;
212+ assert . ok ( t . includes ( 'local history ' ) , `expected "local history " suffix in "${ t } "` ) ;
203213} ) ;
204214
205215// === Disabled provider omitted ===
@@ -256,7 +266,7 @@ test('formatTooltip: includes Local history only disclaimer', () => {
256266test ( 'formatTooltip: includes Live quota not enabled disclaimer' , ( ) => {
257267 const status = createInitialStatus ( [ 'claude' ] ) ;
258268 const tooltip = formatTooltip ( status ) ;
259- assert . ok ( tooltip . includes ( 'Live quota not enabled' ) , `expected "Live quota not enabled" in tooltip` ) ;
269+ assert . ok ( tooltip . includes ( 'Live quota not enabled yet ' ) , `expected "Live quota not enabled yet " in tooltip` ) ;
260270} ) ;
261271
262272test ( 'formatTooltip: includes Snapshots not included disclaimer' , ( ) => {
@@ -510,6 +520,7 @@ test('applyRefreshResults: sets lastRefreshedMs on each refresh', () => {
510520 { providerId : 'claude' , status : 'ok' , totalTokens : 100 , totalAssistantMessages : 1 , filesFound : 1 } ,
511521 ] ) ;
512522 assert . ok ( updated . lastRefreshedMs >= before , 'lastRefreshedMs should be recent' ) ;
523+ assert . ok ( updated . localHistoryLastRefreshedMs >= before , 'localHistoryLastRefreshedMs should be recent' ) ;
513524} ) ;
514525
515526test ( 'applyRefreshResults: second refresh updates lastRefreshedMs' , ( ) => {
@@ -522,6 +533,7 @@ test('applyRefreshResults: second refresh updates lastRefreshedMs', () => {
522533 { providerId : 'claude' , status : 'ok' , totalTokens : 200 , totalAssistantMessages : 2 , filesFound : 1 } ,
523534 ] ) ;
524535 assert . ok ( updated . lastRefreshedMs >= firstRefresh , 'second refresh should update timestamp' ) ;
536+ assert . ok ( updated . localHistoryLastRefreshedMs >= firstRefresh , 'second refresh should update local timestamp' ) ;
525537} ) ;
526538
527539test ( 'applyRefreshResults: preserves enabledProviderIds' , ( ) => {
@@ -701,7 +713,7 @@ test('formatStatusBarText: fallback to local history when no live quota', () =>
701713 [ { providerId : 'claude' , status : 'ok' , totalTokens : 5000 , totalAssistantMessages : 2 , filesFound : 1 } ] ,
702714 ) ;
703715 const t = formatStatusBarText ( status ) ;
704- assert . ok ( t . includes ( 'local' ) , `expected "local" suffix "${ t } "` ) ;
716+ assert . ok ( t . includes ( 'local history ' ) , `expected "local history " suffix "${ t } "` ) ;
705717} ) ;
706718
707719test ( 'formatStatusBarText: live quota unavailable falls back to local history' , ( ) => {
@@ -717,7 +729,7 @@ test('formatStatusBarText: live quota unavailable falls back to local history',
717729 } ,
718730 ] ) ;
719731 const t = formatStatusBarText ( updated ) ;
720- assert . ok ( t . includes ( 'local' ) , `expected "local" suffix when live quota unavailable "${ t } "` ) ;
732+ assert . ok ( t . includes ( 'local history ' ) , `expected "local history " suffix when live quota unavailable "${ t } "` ) ;
721733} ) ;
722734
723735test ( 'formatStatusBarText: live quota error falls back to local history' , ( ) => {
@@ -734,7 +746,7 @@ test('formatStatusBarText: live quota error falls back to local history', () =>
734746 } ,
735747 ] ) ;
736748 const t = formatStatusBarText ( updated ) ;
737- assert . ok ( t . includes ( 'local' ) , `expected "local" suffix when live quota error "${ t } "` ) ;
749+ assert . ok ( t . includes ( 'local history ' ) , `expected "local history " suffix when live quota error "${ t } "` ) ;
738750 assert . ok ( ! t . includes ( 'secret' ) , `should not leak secrets "${ t } "` ) ;
739751 assert . ok ( ! t . includes ( '.jsonl' ) , `should not leak file paths "${ t } "` ) ;
740752} ) ;
@@ -806,6 +818,42 @@ test('formatTooltip: live quota shows Local history refreshed timestamp', () =>
806818 assert . ok ( tooltip . includes ( 'Local history refreshed:' ) , `expected "Local history refreshed:" in tooltip` ) ;
807819} ) ;
808820
821+ test ( 'applyLiveQuotaResults: preserves local history timestamp separately' , ( ) => {
822+ const status = applyRefreshResults (
823+ createInitialStatus ( [ 'claude' ] ) ,
824+ [ { providerId : 'claude' , status : 'ok' , totalTokens : 5000 , totalAssistantMessages : 2 , filesFound : 1 } ] ,
825+ ) ;
826+ const localHistoryRefreshed = status . localHistoryLastRefreshedMs ;
827+ const updated = applyLiveQuotaResults ( status , [ syntheticLiveQuota ] ) ;
828+ assert . strictEqual ( updated . localHistoryLastRefreshedMs , localHistoryRefreshed ) ;
829+ assert . ok ( typeof updated . liveQuotaLastRefreshedMs === 'number' , 'expected live quota timestamp' ) ;
830+ } ) ;
831+
832+ test ( 'applyLiveQuotaResults: normalizes window labels, reset countdown, and status' , ( ) => {
833+ const status = createInitialStatus ( [ 'claude' ] ) ;
834+ const updated = applyLiveQuotaResults ( status , [ syntheticLiveQuota ] ) ;
835+ const window = updated . liveQuotaStates [ 0 ] . windows [ 0 ] ;
836+ assert . strictEqual ( window . label , '5h' ) ;
837+ assert . strictEqual ( window . status , 'available' ) ;
838+ assert . ok ( typeof window . resetInMs === 'number' , 'expected resetInMs' ) ;
839+ } ) ;
840+
841+ test ( 'applyLiveQuotaResults: stores sanitized unavailable message only' , ( ) => {
842+ const status = createInitialStatus ( [ 'claude' ] ) ;
843+ const updated = applyLiveQuotaResults ( status , [
844+ {
845+ providerId : 'claude' ,
846+ windows : [ ] ,
847+ freshness : 'error' ,
848+ error : 'raw /path/to/file.jsonl secret-token' ,
849+ } ,
850+ ] ) ;
851+ const liveState = updated . liveQuotaStates [ 0 ] ;
852+ assert . strictEqual ( liveState . status , 'error' ) ;
853+ assert . strictEqual ( liveState . sanitizedMessage , 'Live quota unavailable' ) ;
854+ assert . strictEqual ( liveState . error , undefined ) ;
855+ } ) ;
856+
809857test ( 'formatTooltip: stale freshness shown correctly' , ( ) => {
810858 const staleLiveQuota = {
811859 ...syntheticLiveQuota ,
0 commit comments