fix(frontend): refit web agent cells after opening a new one (#61 web regression)

The web shell never adopted the desktop's #61 fix: WebAgentCell/WebWorkspace
didn't pass any refitSignal to TerminalView, so a cell opened after another
kept a stale xterm scaling — desktop "fixed" it via an incidental window
resize, but mobile has no such escape hatch.

- TerminalView: a refit landing on a transient 0x0 container now reschedules
  on the next few frames instead of giving up for good (bounded retries),
  closing the independent timing gap Architect identified. refitSignal stays
  the single explicit-refit mechanism; the terminal/PTY is never recreated,
  and resize is still pushed to the PTY only when rows/cols actually change.
- WebAgentCell: new optional refitSignal prop, forwarded to TerminalView
  as-is (no key change, no remount).
- WebWorkspace/LiveProjectPanel: new cellLayoutVersion counter, the web
  equivalent of desktop useLayout.layoutVersion, bumped on every cell
  open/close and forwarded as refitSignal to the visible WebAgentCell.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-21 21:21:52 +02:00
parent a197197a90
commit 3a18556ffa
6 changed files with 354 additions and 9 deletions

View File

@ -39,9 +39,16 @@ interface WebAgentCellProps {
cwd: string;
/** Layout leaf id, when the caller tracks one (drives the singleton guard). */
nodeId?: string;
/**
* Bumped by the caller after a web cell opens/closes (ticket #61 web
* regression) — the web equivalent of desktop `useLayout.layoutVersion`.
* Forwarded to {@link TerminalView} as-is; never changes this component's
* `key`, so the terminal/PTY is never recreated by it.
*/
refitSignal?: number;
}
export function WebAgentCell({ projectId, agentId, cwd, nodeId }: WebAgentCellProps) {
export function WebAgentCell({ projectId, agentId, cwd, nodeId, refitSignal }: WebAgentCellProps) {
const { agent } = useGateways();
const [sessionId, setSessionId] = useState<string | null>(null);
// Input API of the mounted xterm (#69), used by the mobile key bar. Stays
@ -85,6 +92,7 @@ export function WebAgentCell({ projectId, agentId, cwd, nodeId }: WebAgentCellPr
sessionId={sessionId}
onSessionId={setSessionId}
onReady={setInputApi}
refitSignal={refitSignal}
/>
</div>
<TerminalKeyBar api={inputApi} />