@@ -145,7 +145,7 @@ test("open file tab browses, searches, and tracks missing files", async ({ page
145145 const panel = page . locator ( "#review-panel" )
146146 const sidebar = panel . locator ( '[data-slot="session-review-v2-sidebar"]' )
147147 const sidebarToggle = panel . getByRole ( "button" , { name : "Toggle file tree" } )
148- const contextButton = page . getByRole ( "button" , { name : "View context usage " } )
148+ const contextButton = page . getByRole ( "button" , { name : "Toggle session context " } )
149149 const openFile = panel . getByRole ( "button" , { name : "Open file" } )
150150 const tab = ( name : string ) => panel . getByRole ( "tab" , { name, exact : true } )
151151 await contextButton . click ( )
@@ -311,7 +311,7 @@ test("context closes the side region only when its button opened it", async ({ p
311311 } )
312312 const panel = page . locator ( "#review-panel" )
313313 const toggle = page . getByRole ( "button" , { name : "Toggle review" , exact : true } )
314- const contextButton = page . getByRole ( "button" , { name : "View context usage " } )
314+ const contextButton = page . getByRole ( "button" , { name : "Toggle session context " } )
315315 const context = panel . getByRole ( "tab" , { name : "Context" , exact : true } )
316316
317317 await contextButton . click ( )
@@ -335,6 +335,83 @@ test("context closes the side region only when its button opened it", async ({ p
335335 await expect ( panel . locator ( "#session-side-panel-review-tab" ) ) . toHaveAttribute ( "aria-selected" , "true" )
336336} )
337337
338+ test ( "context hides free-model cost but keeps paid-model zero cost" , async ( { page } ) => {
339+ const cases = [
340+ { id : "ses_context_free" , title : "Free model" , model : "free" , cost : 0 , usage : false , text : "0" } ,
341+ { id : "ses_context_paid" , title : "Paid model" , model : "paid" , cost : 0 , usage : false , text : "0·$0.00" } ,
342+ { id : "ses_context_used" , title : "Paid usage" , model : "paid" , cost : 1.25 , usage : true , text : "2k·$1.25" } ,
343+ { id : "ses_context_free_used" , title : "Free usage" , model : "free" , cost : 0 , usage : true , text : "2k" } ,
344+ { id : "ses_context_mixed" , title : "Previously paid" , model : "free" , cost : 1.25 , usage : true , text : "2k·$1.25" } ,
345+ { id : "ses_context_unknown" , title : "Unknown pricing" , model : "missing" , cost : 0 , usage : false , text : "0·$0.00" } ,
346+ { id : "ses_context_output" , title : "Output pricing" , model : "output" , cost : 0 , usage : false , text : "0·$0.00" } ,
347+ // The root's model is free, but its subagent spent on a paid model: the family total shows.
348+ { id : "ses_context_family" , title : "Paid subagent" , model : "free" , cost : 0 , usage : true , text : "2k·$1.25" } ,
349+ // A completed compaction resets the context until the next reply reports usage, as in the TUI.
350+ { id : "ses_context_compacted" , title : "Compacted" , model : "paid" , cost : 1.25 , usage : true , text : "0·$1.25" } ,
351+ ]
352+
353+ await openSession ( page , {
354+ name : "ContextPricing" ,
355+ provider : provider (
356+ { id : "free" , name : "Free" , cost : { input : 0 , output : 0 } } ,
357+ { id : "paid" , name : "Paid" , cost : { input : 1 , output : 3 } } ,
358+ { id : "output" , name : "Output" , cost : { input : 0 , output : 1 } } ,
359+ ) ,
360+ sessions : [
361+ ...cases . map ( ( item ) => ( {
362+ id : item . id ,
363+ title : item . title ,
364+ model : { id : item . model , providerID : "opencode" } ,
365+ cost : item . cost ,
366+ } ) ) ,
367+ {
368+ id : "ses_context_family_child" ,
369+ parentID : "ses_context_family" ,
370+ title : "Subagent run" ,
371+ model : { id : "paid" , providerID : "opencode" } ,
372+ cost : 1.25 ,
373+ } ,
374+ ] ,
375+ pageMessages : ( id ) => ( {
376+ items : cases . flatMap ( ( item ) : SessionMessageInfo [ ] =>
377+ item . id === id && item . usage
378+ ? [
379+ {
380+ id : `msg_${ item . id } ` ,
381+ type : "assistant" ,
382+ agent : "build" ,
383+ model : { id : item . model , providerID : "opencode" } ,
384+ tokens : { input : 1500 , output : 500 , reasoning : 0 , cache : { read : 0 , write : 0 } } ,
385+ content : [ { type : "text" , text : "Done." } ] ,
386+ time : { created : 1 , completed : 2 } ,
387+ } ,
388+ ...( item . id === "ses_context_compacted"
389+ ? [
390+ {
391+ id : `msg_${ item . id } _compaction` ,
392+ type : "compaction" as const ,
393+ status : "completed" as const ,
394+ reason : "manual" as const ,
395+ summary : "Current state" ,
396+ recent : "" ,
397+ time : { created : 3 } ,
398+ } ,
399+ ]
400+ : [ ] ) ,
401+ ]
402+ : [ ] ,
403+ ) ,
404+ } ) ,
405+ } )
406+ const button = page . getByRole ( "button" , { name : "Toggle session context" , exact : true } )
407+
408+ for ( const item of cases ) {
409+ await page . locator ( "[data-titlebar-tab-slot]" , { hasText : item . title } ) . click ( )
410+ await expectSessionTitle ( page , item . title )
411+ await expect ( button ) . toHaveText ( item . text )
412+ }
413+ } )
414+
338415test ( "file tree expands Windows paths and scrolls long names in both directions" , async ( { page } ) => {
339416 const directory = "C:/OpenCode/OpenFileExpand"
340417 const longFilename = "a-very-long-file-name-that-must-overflow-the-file-sidebar-instead-of-being-truncated.ts"
@@ -864,7 +941,7 @@ test("restores review state and the side-panel tab per session", async ({ page }
864941 await page . getByRole ( "option" , { name : "Branch changes" } ) . click ( )
865942 await page . getByRole ( "button" , { name : "beta.ts" } ) . click ( )
866943 await selectedFile ( "beta.ts" )
867- await page . getByRole ( "button" , { name : "View context usage " } ) . click ( )
944+ await page . getByRole ( "button" , { name : "Toggle session context " } ) . click ( )
868945 await selectedTab ( "Context" )
869946
870947 await switchSession ( "Gamma review state" )
0 commit comments