Fix terminal resize bug

Fix resize handling in TerminalView component and update related tests
This commit is contained in:
2026-07-25 14:54:57 +02:00
parent 6a87c4635f
commit da907b880e
4 changed files with 117 additions and 32 deletions

View File

@ -111,16 +111,14 @@ describe("WebAgentCell — refitSignal (ticket #61 web regression)", () => {
const { rerender } = renderCell(agent, seeded.id, { refitSignal: 1 });
await waitFor(() => expect(launchSpy).toHaveBeenCalledTimes(1));
const fitCallsAtMount = fitSpy.mock.calls.length;
expect(fitCallsAtMount).toBeGreaterThan(0);
fitSpy.mockClear();
// jsdom reports a zero-size layout box, which the coalesced refit
// deliberately skips — give the inner xterm container a real size so the
// refit below actually reaches `fit.fit()`.
const container = screen.getByTestId("web-agent-cell").querySelector(
'[data-testid="terminal-view"]',
)!.firstElementChild as HTMLElement;
'[data-testid="terminal-xterm-container"]',
) as HTMLElement;
Object.defineProperty(container, "clientWidth", { value: 400, configurable: true });
Object.defineProperty(container, "clientHeight", { value: 200, configurable: true });
@ -130,7 +128,7 @@ describe("WebAgentCell — refitSignal (ticket #61 web regression)", () => {
</DIProvider>,
);
await waitFor(() => expect(fitSpy.mock.calls.length).toBeGreaterThan(fitCallsAtMount));
await waitFor(() => expect(fitSpy).toHaveBeenCalled());
// The whole point: refit must never relaunch the agent's PTY.
expect(launchSpy).toHaveBeenCalledTimes(1);

View File

@ -384,8 +384,6 @@ describe("LiveProjectPanel — cellLayoutVersion (ticket #61 web regression)", (
const archiRow = screen.getByText("Archi").closest("li")!;
fireEvent.click(within(archiRow).getByRole("button", { name: "Ouvrir" }));
await screen.findByTestId("web-agent-cell");
// First cell mounted: at least the one guaranteed fit-on-mount happened.
expect(fitSpy.mock.calls.length).toBeGreaterThan(0);
// Switch to a different agent's cell — the panel shows one cell at a time,
// so this replaces (unmounts A, mounts B) rather than adding a second.
@ -398,8 +396,9 @@ describe("LiveProjectPanel — cellLayoutVersion (ticket #61 web regression)", (
// jsdom reports a zero-size layout box, which the refit deliberately skips
// — give the freshly-mounted cell's inner xterm container a real size so
// the refitSignal-driven refit actually reaches `fit.fit()`.
const containerB = cellB.querySelector('[data-testid="terminal-view"]')!
.firstElementChild as HTMLElement;
const containerB = cellB.querySelector(
'[data-testid="terminal-xterm-container"]',
) as HTMLElement;
Object.defineProperty(containerB, "clientWidth", { value: 400, configurable: true });
Object.defineProperty(containerB, "clientHeight", { value: 200, configurable: true });