@@ -2201,6 +2201,40 @@ describe("OpenAIOAuthPlugin fetch handler", () => {
22012201 expect ( storageModule . loadAccounts ) . not . toHaveBeenCalled ( ) ;
22022202 } ) ;
22032203
2204+ it ( "uses the live account count when the cached footer hint is stale" , async ( ) => {
2205+ await enablePersistedFooter ( "full-email" ) ;
2206+ mockStorage . accounts = [
2207+ { accountId : "acc-1" , email : "user@example.com" , refreshToken : "refresh-token" } ,
2208+ { accountId : "acc-2" , email : "user2@example.com" , refreshToken : "refresh-2" } ,
2209+ ] ;
2210+ const accountsModule = await import ( "../lib/accounts.js" ) ;
2211+ const manager = await accountsModule . AccountManager . loadFromDisk ( ) as unknown as {
2212+ accounts : Array < {
2213+ index : number ;
2214+ accountId : string ;
2215+ email : string ;
2216+ refreshToken : string ;
2217+ } > ;
2218+ } ;
2219+ manager . accounts = [
2220+ { index : 0 , accountId : "acc-1" , email : "user@example.com" , refreshToken : "refresh-token" } ,
2221+ { index : 1 , accountId : "acc-2" , email : "user2@example.com" , refreshToken : "refresh-2" } ,
2222+ ] ;
2223+ vi . spyOn ( accountsModule . AccountManager , "loadFromDisk" ) . mockResolvedValue ( manager as never ) ;
2224+ const { plugin, sdk } = await setupPlugin ( ) ;
2225+
2226+ await sendPersistedAccountRequest ( sdk , "session-live-count" ) ;
2227+ manager . accounts = [
2228+ { index : 0 , accountId : "acc-1" , email : "user@example.com" , refreshToken : "refresh-token" } ,
2229+ ] ;
2230+
2231+ await sendPersistedAccountRequest ( sdk , "session-live-count" ) ;
2232+
2233+ expect ( ( await readPersistedAccountIndicator ( plugin , "session-live-count" ) ) . variant ) . toBe (
2234+ expectedFullIndicator ,
2235+ ) ;
2236+ } ) ;
2237+
22042238 it ( "decorates the last user message with a label-only indicator when configured" , async ( ) => {
22052239 await enablePersistedFooter ( "label-only" ) ;
22062240 const { plugin, sdk } = await setupPlugin ( ) ;
@@ -2300,6 +2334,20 @@ describe("OpenAIOAuthPlugin fetch handler", () => {
23002334 { accountId : "acc-1" , email : "user@example.com" , refreshToken : "refresh-token" } ,
23012335 { accountId : "acc-2" , email : "user2@example.com" , refreshToken : "refresh-2" } ,
23022336 ] ;
2337+ const accountsModule = await import ( "../lib/accounts.js" ) ;
2338+ const manager = await accountsModule . AccountManager . loadFromDisk ( ) as unknown as {
2339+ accounts : Array < {
2340+ index : number ;
2341+ accountId : string ;
2342+ email : string ;
2343+ refreshToken : string ;
2344+ } > ;
2345+ } ;
2346+ manager . accounts = [
2347+ { index : 0 , accountId : "acc-1" , email : "user@example.com" , refreshToken : "refresh-token" } ,
2348+ { index : 1 , accountId : "acc-2" , email : "user2@example.com" , refreshToken : "refresh-2" } ,
2349+ ] ;
2350+ vi . spyOn ( accountsModule . AccountManager , "loadFromDisk" ) . mockResolvedValue ( manager as never ) ;
23032351
23042352 const { plugin, sdk, mockClient } = await setupPlugin ( ) ;
23052353 await sendPersistedAccountRequest ( sdk , "session-switch" ) ;
0 commit comments