@@ -17,6 +17,7 @@ import { buildModelsFirstCatalog, modelOptionId } from "./model-catalog.js";
1717import { hydrateHistoryRows } from "./history-hydrate.js" ;
1818import { MAX_RETAINED_STREAM_ROWS } from "./long-log.js" ;
1919import { enterSubagentObserve } from "./shell/observe.js" ;
20+ import { transcriptMarker } from "./shell/transcript.js" ;
2021
2122function makeFakeSessionPort ( ) : {
2223 readonly sends : string [ ] ;
@@ -146,9 +147,9 @@ describe("mountProductHost", () => {
146147 role : "assistant" ,
147148 text : `row-${ total - 1 } ` ,
148149 } ) ;
149- // Pre-sliced to the cap, so the append loop never trips retention
150- // eviction: no churn, no dropped-rows marker on resume.
151- expect ( host . shell . streamLogBase ) . toBe ( 0 ) ;
150+ const dropped = total - MAX_RETAINED_STREAM_ROWS ;
151+ expect ( host . shell . streamLogBase ) . toBe ( dropped ) ;
152+ expect ( transcriptMarker ( host . shell ) ) . toBeDefined ( ) ;
152153 } finally {
153154 host . dispose ( ) ;
154155 }
@@ -173,6 +174,7 @@ describe("mountProductHost", () => {
173174 text : `small-${ total - 1 } ` ,
174175 } ) ;
175176 expect ( host . shell . streamLogBase ) . toBe ( 0 ) ;
177+ expect ( transcriptMarker ( host . shell ) ) . toBeUndefined ( ) ;
176178 } finally {
177179 host . dispose ( ) ;
178180 }
@@ -200,12 +202,12 @@ describe("mountProductHost", () => {
200202 } ,
201203 ] ;
202204 emitter . emit ( "history.hydrate" , blocks ) ;
203- // Folding merges the pair inside hydration, so the row-level slice keeps
204- // and drops whole merged rows: 605 texts + 1 merged row → newest 600.
205- // A block-level slice would split the pair and paint 599 rows instead.
206- const expected = hydrateHistoryRows ( blocks ) . slice (
207- - MAX_RETAINED_STREAM_ROWS ,
208- ) ;
205+ // Folding merges the pair inside hydration, so retention evicts whole
206+ // merged rows: 605 texts + 1 merged row → newest 600. A block-level
207+ // slice would split the pair and paint 599 rows instead.
208+ const allRows = hydrateHistoryRows ( blocks ) ;
209+ const expected = allRows . slice ( - MAX_RETAINED_STREAM_ROWS ) ;
210+ const dropped = allRows . length - expected . length ;
209211 expect ( expected . length ) . toBe ( MAX_RETAINED_STREAM_ROWS ) ;
210212 expect ( host . shell . streamLog ) . toEqual ( expected ) ;
211213 expect ( host . shell . streamLog [ 0 ] ) . toEqual ( {
@@ -215,7 +217,9 @@ describe("mountProductHost", () => {
215217 const last = host . shell . streamLog [ host . shell . streamLog . length - 1 ] ;
216218 expect ( last ?. pending ) . not . toBe ( true ) ;
217219 expect ( last ?. text ) . toBe ( "done cut-1" ) ;
218- expect ( host . shell . streamLogBase ) . toBe ( 0 ) ;
220+ expect ( dropped ) . toBeGreaterThan ( 0 ) ;
221+ expect ( host . shell . streamLogBase ) . toBe ( dropped ) ;
222+ expect ( transcriptMarker ( host . shell ) ) . toBeDefined ( ) ;
219223 } finally {
220224 host . dispose ( ) ;
221225 }
@@ -246,7 +250,11 @@ describe("mountProductHost", () => {
246250 ) ;
247251 expect ( host . shell . parentStreamLog ) . toEqual ( expected ) ;
248252 expect ( host . shell . parentStreamLog ?. length ) . toBe ( MAX_RETAINED_STREAM_ROWS ) ;
249- expect ( host . shell . parentStreamLogBase ) . toBe ( 0 ) ;
253+ expect ( host . shell . parentStreamLogBase ) . toBe (
254+ total - MAX_RETAINED_STREAM_ROWS ,
255+ ) ;
256+ expect ( host . shell . streamLogBase ) . toBe ( 0 ) ;
257+ expect ( transcriptMarker ( host . shell ) ) . toBeUndefined ( ) ;
250258 } finally {
251259 host . dispose ( ) ;
252260 }
0 commit comments