Compare commits

...
@@ -567,6 +567,43 @@ describe("createTerminal", () => {
expect(state.grid[0][1].char).toBe("");
});
it("clears restored fullscreen content when the application leaves the alternate screen", async () => {
const exitOutput = "\x1b[?1049lPROMPT";
const session = trackSession(
await createTerminal({
workspaceId: "ws-test",
cwd: realpathSync(tmpdir()),
cols: 80,
rows: 10,
command: process.execPath,
args: [
"-e",
`process.stdout.write('SHELL\\r\\n\\x1b[?1049h\\x1b[2J\\x1b[HFULLSCREEN'); process.stdin.setRawMode(true); process.stdin.on('data', () => process.stdout.write(${JSON.stringify(exitOutput)}));`,
],
}),
);
const state = await waitForState(session, (current) => getRowText(current, 0) === "FULLSCREEN");
session.send({ type: "input", data: "q" });
const exited = await waitForState(session, (current) => getRowText(current, 1) === "PROMPT");
const expected = getLines(exited).join("\n").trim();
expect(expected).toBe("SHELL\nPROMPT");
const restored = new xterm.Terminal({ cols: 80, rows: 10, allowProposedApi: true });
try {
await new Promise<void>((resolve) =>
restored.write(renderTerminalSnapshotToAnsi(state), resolve),
);
expect(restored.buffer.active.getLine(0)?.translateToString(true)).toBe("FULLSCREEN");
await new Promise<void>((resolve) => restored.write(exitOutput, resolve));
const visible = Array.from({ length: restored.rows }, (_, row) =>
restored.buffer.active.getLine(row)?.translateToString(true),
).join("\n");
expect(visible).not.toContain("FULLSCREEN");
expect(visible.trim()).toBe(expected);
} finally {
restored.dispose();
}
});
it("captures exit diagnostics from the terminal buffer", async () => {
const session = trackSession(
await createTerminal({