@devries-cameron20 / t3code-1 / commits / 2cde3f770b
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(web): terminal tells the shell its new width as soon as you release a resize drag (#19395)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Theo Browne committed Oct 14, 2026 at 04:34 UTC 2cde3f770bbf7a6ed9d52a6b1f64a471c0303a5a
2 files changed +44
apps/web/src/terminal/ghostty/surface.test.ts
+24
@@ -540,6 +540,30 @@ describe("GhosttyTerminalSurface visibility", () => {
540 expect(resizePty).toHaveBeenCalledOnce();
541 });
542
543 + it("sends the settled grid when a resize drag is released", async () => {
544 + const harness = createHarness();
545 + const onResize = vi.fn<(cols: number, rows: number) => void>();
546 + const surface = await harness.create({ onResize });
547 + vi.advanceTimersByTime(150);
548 + onResize.mockClear();
549 +
550 + // Mid-drag, the grid reflows locally while the PTY waits for the debounce.
551 + harness.mount.clientWidth = 120;
552 + harness.resize();
553 + expect(surface.cols).toBe(14);
554 + expect(onResize).not.toHaveBeenCalled();
555 +
556 + // The release writes the final width before the observer reports it.
557 + harness.mount.clientWidth = 96;
558 + window.dispatchEvent(new Event("pointerup"));
559 + expect(onResize).toHaveBeenCalledExactlyOnceWith(11, 6);
560 +
561 + harness.resize();
562 + vi.advanceTimersByTime(150);
563 + window.dispatchEvent(new Event("pointerup"));
564 + expect(onResize).toHaveBeenCalledOnce();
565 + });
566 +
567 it("replays the current grid on reveal when a hidden host becomes ready", async () => {
568 const harness = createHarness();
569 const onResize = vi.fn<(cols: number, rows: number) => void>();
apps/web/src/terminal/ghostty/surface.ts
+20
@@ -942,6 +942,22 @@ export class GhosttyTerminalSurface {
942 }, 150);
943 }
944
945 + /**
946 + * Releasing a panel, drawer, or split divider settles the size, so the PTY
947 + * hears it now instead of after the debounce. Otherwise typing right after
948 + * the release reaches a shell that still lays out the old width.
949 + */
950 + private readonly onWindowPointerRelease = () => {
951 + if (this.disposed || this.resizeNotifyTimer === null) return;
952 + // The drag hook writes the release position before this bubbles to window,
953 + // so fit now rather than wait a frame for the observer.
954 + this.fit();
955 + if (this.resizeNotifyTimer === null) return;
956 + window.clearTimeout(this.resizeNotifyTimer);
957 + this.resizeNotifyTimer = null;
958 + this.options.onResize(this.cols, this.rows);
959 + };
960 +
961 focus(): void {
962 if (this.disposed || !this.visible) return;
963 this.input.focus({ preventScroll: true });
@@ -1843,6 +1859,8 @@ export class GhosttyTerminalSurface {
1859 this.scrollbar.addEventListener("pointerup", this.onScrollbarPointerUp);
1860 this.scrollbar.addEventListener("pointercancel", this.onScrollbarPointerUp);
1861 this.scrollbar.addEventListener("keydown", this.onScrollbarKeyDown);
1862 + window.addEventListener("pointerup", this.onWindowPointerRelease);
1863 + window.addEventListener("pointercancel", this.onWindowPointerRelease);
1864 }
1865
1866 private removeEvents(): void {
@@ -1869,6 +1887,8 @@ export class GhosttyTerminalSurface {
1887 this.scrollbar.removeEventListener("pointerup", this.onScrollbarPointerUp);
1888 this.scrollbar.removeEventListener("pointercancel", this.onScrollbarPointerUp);
1889 this.scrollbar.removeEventListener("keydown", this.onScrollbarKeyDown);
1890 + window.removeEventListener("pointerup", this.onWindowPointerRelease);
1891 + window.removeEventListener("pointercancel", this.onWindowPointerRelease);
1892 }
1893
1894 private scrollViewport(deltaRows: number): void {