Skip to content

mocactl: input box not anchored to bottom; window resize corrupts the TUI #596

Closed

Description

@esnible

Symptoms

In the interactive mocactl TUI:

  1. The input (message) box is not drawn consistently at the bottom of the terminal.
  2. Changing the window size corrupts the display (stray or duplicated box borders, history wrapped wrong).

Analysis

This comes from reading the code. It hasn't been reproduced in a debugger yet.

The TUI knows the width but not the height. packages/mocactl/src/app.tsx:108 reads useWindowSize().columns and passes it to markdown wrapping, tool previews and the status line. Nothing reads rows, and nothing limits how tall the live part of the screen can get.

Why the box moves. Ink doesn't pin anything to the bottom of the screen. Settled history is printed once through <Static> (src/views/Chat.tsx:57), and Ink redraws the "live" area below it in place: the streaming reply, any overlay, the input box and the status line.

  • Short transcript: the box sits right under the last message, partway up the screen.
  • Long streaming reply: the reply stays in the live area until it settles, so the live area can grow taller than the window. Ink can't erase lines that have scrolled off the top, so it clears the whole screen and repaints on every frame. The box jumps and flickers.

Why resizing corrupts the display.

  • History isn't reprinted. Old messages were wrapped at the old width, and the terminal re-wraps them itself. redraw() (src/app.tsx:222) clears the screen and bumps staticKey to reprint history, but only theme/display changes, $EDITOR, the banner and session switches call it, not a resize.
  • Ink erases the previous frame using its line count. After the window narrows, those lines wrap onto more rows, so some aren't erased. The full-width border of the input box breaks first.

Proposed fix

  1. Redraw on resize. When width (and rows) from useWindowSize() change, wait about 100 ms for the resize to finish, then call the existing redraw(). Skip the initial render.
  2. Limit the live area to the window height. Read rows, and show only the last lines of a streaming reply that fit above the input box and status line. The full text still goes to history through <Static> once it settles.
  3. (Out of scope unless 1 and 2 aren't enough) Pin the box to the bottom even with a short transcript. That needs a full-screen layout that manages its own scrolling, which replaces the print-once history design in spec §6.1.

Tests

Use the TTY-like fake stdout in packages/mocactl/test/app.test.tsx (mountInteractive, which already sets columns/rows):

  • Changing columns and emitting resize clears the screen and reprints history once, after the delay.
  • A streaming reply taller than rows renders within the height limit, and the input box and status line are the last lines of the frame.

Activity

  1. self-assigned this
    on Oct 23, 2026
  2. added
    bug
    on Oct 23, 2026
  3. added a commit that references this issue on Oct 28, 2026
    5e17c13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions