88// The run happens in this tab. There is no workflow engine and no batch endpoint in this
99// deployment, so the browser is the orchestrator; the UI says that before you press Run and says
1010// exactly what happened if you leave.
11- import { useCallback , useEffect , useLayoutEffect , useMemo , useRef , useState } from 'react' ;
11+ import { useCallback , useEffect , useMemo , useRef , useState } from 'react' ;
1212import ReactMarkdown from 'react-markdown' ;
1313import remarkGfm from 'remark-gfm' ;
1414import { Download , HelpCircle , Home } from 'lucide-react' ;
1515import { PaneResizer , useResizablePane , useDialog } from 'reifyui' ;
16- import { SheetGrid , FilePreview , fitRowHeights } from 'reifyui' ;
16+ import { SheetGrid , FilePreview } from 'reifyui' ;
1717import { containerFileUrl , getResponse , lastAssistantText , sessionTurns } from 'reifyui/harness' ;
1818import {
1919 defaultAgentId , getSheet , isPending , markViewed , renameSheet , runnableHarnesses , saveSheet ,
@@ -36,10 +36,6 @@ const SAVE_DEBOUNCE_MS = 400;
3636const STATUS_POLL_MS = 2000 ; // while a turn is live: the grid fills in as it is written
3737const STATUS_IDLE_MS = 10000 ; // while nothing is: still notices a turn started elsewhere
3838const RELOAD_POLL_MS = 4000 ;
39- // The line height and vertical padding the grid lays a cell out with (reifyui's sheet.css sets
40- // line-height: 18px). They turn a measured height into a number of lines for --shg-clamp.
41- const CLAMP_LINE = 18 ;
42- const CLAMP_PAD = 10 ;
4339const now = ( ) => Math . floor ( Date . now ( ) / 1000 ) ;
4440
4541const escapeRe = ( s ) => String ( s ) . replace ( / [ . * + ? ^ $ { } ( ) | [ \] \\ ] / g, '\\$&' ) ;
@@ -106,7 +102,6 @@ export function SheetPage({ id: routeId, seed }) {
106102 idRef . current = id ;
107103 const runnerRef = useRef ( null ) ;
108104 const exportRef = useRef ( null ) ;
109- const gridRef = useRef ( null ) ;
110105 const mirrored = useRef ( '' ) ; // the session title we last asserted
111106 const save = useRef ( { timer : null , inFlight : false , backoff : 0 , wanted : null } ) ;
112107
@@ -385,14 +380,10 @@ export function SheetPage({ id: routeId, seed }) {
385380 runnerRef . current = null ;
386381 setRunning ( false ) ;
387382
388- // The answers are on screen now, so their real height is measurable. Rows the run touched
389- // grow to fit what is in them — the text and the file cards — rather than staying at the
390- // height they had when they were empty.
391- const touched = [ ...new Set ( p . cells . map ( ( c ) => c . rowId ) ) ] ;
392- const heights = fitRowHeights ( gridRef . current , { rowIds : touched } ) ;
393-
383+ // No row heights are written here. The grid fits every row to its tallest cell on each
384+ // render, so an answer has its room the moment it lands; a height stored after the run
385+ // would pin the row and stop it refitting when its column is resized or its text edited.
394386 const done = JSON . parse ( JSON . stringify ( sheetRef . current ) ) ;
395- for ( const r of done . rows || [ ] ) if ( heights [ r . id ] ) r . height = heights [ r . id ] ;
396387 if ( done . run ?. id === rid ) {
397388 done . run = {
398389 ...done . run ,
@@ -404,53 +395,6 @@ export function SheetPage({ id: routeId, seed }) {
404395 }
405396 } , [ env , concurrency , commit , dialog ] ) ;
406397
407- // ── how many lines of text a cell has room for ────────────────────────────
408- // The grid derives --shg-clamp from a row's STORED height, falling back to 34px — one line —
409- // for any row never explicitly sized. But a row is usually tall because of ONE column: an agent
410- // cell keeping its files under its answer. Every other cell then showed a single ellipsised
411- // line above a block of empty row, and the taller the neighbour, the more space went to waste.
412- //
413- // Three things have to be true at once, and each is a trap on its own:
414- //
415- // The basis cannot be the RENDERED height. More lines makes the row taller, which allows more
416- // lines: measured live the rows climb 92 → 137 → 182 and never settle. So every clamp goes
417- // back to one line before measuring, making the basis the height the row's OTHER content
418- // needs — a quantity the clamp cannot influence.
419- //
420- // The basis cannot be the <td>. A table cell is stretched to its row and reports the row
421- // height for every column, which makes them all look equally full. The measurement is taken
422- // on the text's own box, which sizes to its content.
423- //
424- // The count cannot be shared by the row. A cell carrying files under its text has far less
425- // room than one carrying nothing, and one number for both is the bug restated.
426- //
427- // Set on each <td>: a custom property resolves from the nearest ancestor, so this wins over the
428- // row-level value the grid sets, for both this kit's answer text and the grid's own value cell.
429- useLayoutEffect ( ( ) => {
430- const trs = gridRef . current ?. querySelectorAll ( 'tbody tr[data-row-id]' ) ;
431- if ( ! trs ?. length ) return ;
432- const rows = [ ...trs ] ;
433- for ( const tr of rows ) for ( const td of tr . children ) td . style . setProperty ( '--shg-clamp' , '1' ) ;
434- const plan = rows . map ( ( tr ) => ( {
435- base : tr . offsetHeight , // one reflow, every clamp at its floor
436- cells : [ ...tr . children ] . map ( ( td ) => {
437- const txt = td . querySelector ( '[data-shg-clamp-text]' ) ;
438- const box = txt ?. parentElement ;
439- return { td, extra : box ? Math . max ( 0 , box . scrollHeight - txt . offsetHeight ) : 0 } ;
440- } ) ,
441- } ) ) ;
442- for ( const { base, cells } of plan ) {
443- const floorLines = Math . max ( 1 , Math . floor ( ( base - CLAMP_PAD ) / CLAMP_LINE ) ) ;
444- // The height the row needs for the cell carrying the most beside its text to still get the
445- // row's baseline count. Every other cell then fills THAT, which is the whole point.
446- const need = Math . max ( ...cells . map ( ( c ) => c . extra ) ) + floorLines * CLAMP_LINE + CLAMP_PAD ;
447- for ( const { td, extra } of cells ) {
448- td . style . setProperty ( '--shg-clamp' , String ( Math . max ( floorLines ,
449- Math . floor ( ( need - extra - CLAMP_PAD ) / CLAMP_LINE ) ) ) ) ;
450- }
451- }
452- } ) ;
453-
454398 const stopRun = useCallback ( ( ) => { runnerRef . current ?. stop ( ) ; } , [ ] ) ;
455399
456400 // Leaving mid-run stops the walk. Say so with the platform's own guard rather than inventing a
@@ -650,7 +594,7 @@ export function SheetPage({ id: routeId, seed }) {
650594 ) }
651595 </ div >
652596 ) : (
653- < div className = "sh-grid" ref = { gridRef } >
597+ < div className = "sh-grid" >
654598 < SheetGrid
655599 sheet = { sheet }
656600 onChange = { onGridChange }
0 commit comments