Fix terminal color query replies

Answer OSC color queries from the daemon and suppress browser-side replies so response bytes do not race back into the shell prompt as user input.
This commit is contained in:
Mohamed Boudra
2026-05-26 09:32:15 +07:00
parent 48d4e3e408
commit 6e56ee9e32
5 changed files with 136 additions and 0 deletions
@@ -319,6 +319,9 @@ describe("terminal emulator runtime in a real browser", () => {
{ name: "DSR-?6", bytes: "\x1b[?6n" },
{ name: "DECRQM", bytes: "\x1b[1$p" },
{ name: "DECRQM-?", bytes: "\x1b[?1$p" },
{ name: "OSC-10-foreground-color", bytes: "\x1b]10;?\x07" },
{ name: "OSC-11-background-color", bytes: "\x1b]11;?\x07" },
{ name: "OSC-12-cursor-color", bytes: "\x1b]12;?\x07" },
])("does not emit a PTY input reply for $name", async ({ bytes }) => {
await page.viewport(900, 600);
const mounted = createTerminalHost({ width: 720, height: 360 });
@@ -301,6 +301,9 @@ export class TerminalEmulatorRuntime {
{ prefix: "?", intermediates: "$", final: "p" },
() => true,
);
for (const code of [10, 11, 12]) {
terminal.parser.registerOscHandler(code, (data) => data.trim() === "?");
}
};
registerProtocolQuerySuppression();