Skip to content

Commit 3abe2bf

Browse files
sheets: every cell wraps, and every row fits its content on load, edit and column resize
The grid showed a long value as one line with an ellipsis, and the only rows that grew were the ones a run had just touched: the run measured them once and stored their heights. reifyui 0.8.4 wraps every cell and lets the table fit each row to its tallest cell, up to eight lines, past which the cell scrolls inside itself. So the kit stops doing that work. The run no longer writes row heights: a stored height now means a row someone sized, and it would stop the row refitting when its column is resized or its text edited. The layout effect that worked out a line clamp for every cell on every render is gone with the clamp. An agent cell's answer, and the live text of a running cell, wrap the way the grid's own text does. package.json and the lock take reifyui 0.8.4 (npm ci, npm test 64 of 64 and npm run build pass on node 22, the image's version). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent c50c629 commit 3abe2bf

5 files changed

Lines changed: 22 additions & 78 deletions

File tree

‎kits/sheets/app/package-lock.json‎

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎kits/sheets/app/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"react-dom": "^18.3.1",
1616
"react-file-icon": "^1.6.0",
1717
"react-markdown": "^9.0.1",
18-
"reifyui": "^0.8.3",
18+
"reifyui": "^0.8.4",
1919
"remark-gfm": "^4.0.0",
2020
"xlsx": "^0.18.5"
2121
},

‎kits/sheets/app/src/components/HarnessCell.jsx‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// What an agent cell looks like in the grid.
22
//
3-
// Mounted through SheetGrid's renderCell slot, inside the cell's own value box, so the row-height
4-
// line clamp and the cell chrome still apply.
3+
// Mounted through SheetGrid's renderCell slot, inside the cell's own value box, so the cell chrome
4+
// still applies and the row fits this cell the way it fits any other: the answer wraps, the row
5+
// grows to it up to the grid's cap, and past the cap the cell scrolls.
56
//
67
// Every state here is a state the run genuinely produces. There is no percentage and no estimate:
78
// the server exposes no queue — past its concurrency limit turns are accepted and block silently,
@@ -81,22 +82,22 @@ export function HarnessCell({ cell, live, readOnly, onRun, onPreviewFile }) {
8182
return (
8283
<span className="hcell failed" title={cell.error || ''}>
8384
<span className="hcell-dot failed" />
84-
<span className="hcell-txt" data-shg-clamp-text>{cell.error || 'This cell failed.'}</span>
85+
<span className="hcell-txt">{cell.error || 'This cell failed.'}</span>
8586
{tools}
8687
</span>
8788
);
8889
}
8990
if (status === 'skipped') {
9091
return (
9192
<span className="hcell skipped" title={cell.error || ''}>
92-
<span className="hcell-txt" data-shg-clamp-text>{cell.error || 'Skipped.'}</span>
93+
<span className="hcell-txt">{cell.error || 'Skipped.'}</span>
9394
{tools}
9495
</span>
9596
);
9697
}
9798
return (
9899
<span className="hcell">
99-
<span className="hcell-txt" data-shg-clamp-text><AnswerText value={cell.value} /></span>
100+
<span className="hcell-txt"><AnswerText value={cell.value} /></span>
100101
<Artifacts artifacts={cell.artifacts} onPreview={onPreviewFile} />
101102
{tools}
102103
</span>

‎kits/sheets/app/src/pages/SheetPage.jsx‎

Lines changed: 6 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
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';
1212
import ReactMarkdown from 'react-markdown';
1313
import remarkGfm from 'remark-gfm';
1414
import { Download, HelpCircle, Home } from 'lucide-react';
1515
import { PaneResizer, useResizablePane, useDialog } from 'reifyui';
16-
import { SheetGrid, FilePreview, fitRowHeights } from 'reifyui';
16+
import { SheetGrid, FilePreview } from 'reifyui';
1717
import { containerFileUrl, getResponse, lastAssistantText, sessionTurns } from 'reifyui/harness';
1818
import {
1919
defaultAgentId, getSheet, isPending, markViewed, renameSheet, runnableHarnesses, saveSheet,
@@ -36,10 +36,6 @@ const SAVE_DEBOUNCE_MS = 400;
3636
const STATUS_POLL_MS = 2000; // while a turn is live: the grid fills in as it is written
3737
const STATUS_IDLE_MS = 10000; // while nothing is: still notices a turn started elsewhere
3838
const 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;
4339
const now = () => Math.floor(Date.now() / 1000);
4440

4541
const 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}

‎kits/sheets/app/src/styles/app.css‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,16 +114,15 @@
114114
took a fixed slice of every cell and the answer was ellipsised to pay for it, in every row,
115115
whether that row produced a file or not. */
116116
.hcell { display: flex; flex-direction: column; align-items: stretch; gap: 5px; min-width: 0; width: 100%; }
117-
.hcell-txt {
118-
min-width: 0; overflow: hidden; text-overflow: ellipsis;
119-
display: -webkit-box; -webkit-box-orient: vertical;
120-
-webkit-line-clamp: var(--shg-clamp, 1); line-clamp: var(--shg-clamp, 1);
121-
}
117+
/* The answer in full, the way the grid draws its own text: its line breaks kept, a long word or
118+
address broken at the cell's edge, on the grid's 18px line. The grid's value box caps the
119+
cell's height and scrolls past it, so nothing here clamps or ellipsises. */
120+
.hcell-txt { min-width: 0; line-height: 18px; white-space: pre-wrap; overflow-wrap: anywhere; }
122121
.hcell-link { font-size: 12px; color: var(--brand-ink); text-decoration: none; }
123122
.hcell-link:hover { text-decoration: underline; }
124123
.hcell.failed .hcell-txt { color: #B91C1C; }
125124
.hcell.skipped .hcell-txt { color: var(--mute-2); font-style: italic; }
126-
.hcell-live { color: var(--mute); font-size: 12px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
125+
.hcell-live { color: var(--mute); font-size: 12px; line-height: 18px; min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
127126

128127
.hcell-dot { width: 7px; height: 7px; border-radius: 999px; flex: none; margin-top: 5px; }
129128
.hcell-dot.queued { background: var(--mute-2); }

0 commit comments

Comments
 (0)