@@ -178,8 +178,17 @@ describe("renderChatComposer context usage", () => {
178178 expect ( container . textContent ) . not . toContain ( "Est. cost" ) ;
179179 } ) ;
180180
181- it ( "falls back from an unmatched session provider to the response quota group" , ( ) => {
182- const container = renderComposer ( {
181+ it ( "uses response provenance only when the session provider is absent" , ( ) => {
182+ const session = {
183+ key : "main" ,
184+ kind : "direct" ,
185+ updatedAt : null ,
186+ totalTokens : 1_000 ,
187+ contextTokens : 200_000 ,
188+ model : "gateway-injected" ,
189+ modelProvider : "openclaw" as string | undefined ,
190+ } ;
191+ const composerProps = {
183192 messages : [
184193 { role : "user" , content : "hi" } ,
185194 {
@@ -191,19 +200,9 @@ describe("renderChatComposer context usage", () => {
191200 } ,
192201 ] ,
193202 sessions : {
194- sessions : [
195- {
196- key : "main" ,
197- kind : "direct" ,
198- updatedAt : null ,
199- totalTokens : 1_000 ,
200- contextTokens : 200_000 ,
201- model : "gateway-injected" ,
202- modelProvider : "openclaw" ,
203- } ,
204- ] ,
203+ sessions : [ session ] ,
205204 defaults : { contextTokens : 200_000 } ,
206- } as never ,
205+ } ,
207206 providerUsage : {
208207 modelAuthStatusResult : {
209208 ts : Date . now ( ) ,
@@ -231,16 +230,23 @@ describe("renderChatComposer context usage", () => {
231230 ] ,
232231 } ,
233232 } ,
234- } ) ;
235-
236- expect (
233+ } ;
234+ const providerNames = ( container : HTMLElement ) =>
237235 [ ...container . querySelectorAll ( "[data-chat-usage-provider='true']" ) ] . map ( ( row ) =>
238236 row . textContent ?. replace ( / \s + / g, " " ) . trim ( ) ,
239- ) ,
240- ) . toEqual ( [ "Provider: OpenAI" , "Provider: Claude" ] ) ;
241- expect ( container . textContent ) . not . toContain ( "Est. cost" ) ;
242- expect ( container . textContent ) . not . toContain ( "Cost by Type" ) ;
237+ ) ;
238+
239+ const container = renderComposer ( composerProps as never ) ;
240+
241+ expect ( providerNames ( container ) ) . toEqual ( [ "Provider: Claude" , "Provider: OpenAI" ] ) ;
242+ expect ( container . textContent ) . toContain ( "Cost by Type" ) ;
243243 expect ( container . textContent ) . not . toContain ( "Model:" ) ;
244+
245+ session . modelProvider = undefined ;
246+ expect ( providerNames ( renderComposer ( composerProps as never ) ) ) . toEqual ( [
247+ "Provider: OpenAI" ,
248+ "Provider: Claude" ,
249+ ] ) ;
244250 } ) ;
245251
246252 it ( "omits the cost-by-type section when every recorded cost is zero" , ( ) => {
0 commit comments