Skip to content

Skip fully hidden forms to stop terminal capability-reply leaks - #38

Merged
polymorcodeus merged 3 commits into
mainfrom
shelf-list-tty-leak
Sep 25, 2026
Merged

polymorcodeus merged 3 commits into
mainfrom
shelf-list-tty-leak

Conversation

@polymorcodeus

Copy link
Copy Markdown
Owner

Summary

Adds a NonInteractive screen contract so forms with no visible groups skip tea.NewProgram entirely. Fixes the
stray ^[[?2026;2$y^[[?2027;2$y escape replies leaking into the shell prompt after interactive shelf list runs.

What's new

  • model.NonInteractive - a screen whose form has nothing to ask implements SkipProgram() bool; runProgram
    prints its ResultView directly instead of starting a program that quits instantly.
  • Completed by construction - the all-hidden shelf list form is marked huh.StateCompleted in its constructor,
    so the result view renders without a program run.
  • Shared result tail - runProgram's error and completion handling is factored into printResult, used by both
    the program and skip paths.

Behavior changes / guardrails

  • Root cause is upstream: a tea program that quits within milliseconds races the terminal's mode 2026/2027
    capability replies into the tty buffer (If tea program quits too early, garbage chars are printed charmbracelet/bubbletea#1590). Skipping the program removes the race instead of
    timing around it.
  • Only shelf list is affected; collection list and mark list keep visible selector groups and still run
    interactively.
  • Visible output is unchanged (spinner, banner, completed-view box), minus a sub-millisecond empty alt-screen flash.

Testing

  • New internal/model unit test pins SkipProgram per action and verifies the list result renders immediately after
    construction.
  • A pty harness emulating kitty's query replies reproduces the leak 5/5 before the fix and 0/5 after, with identical
    result output.
  • make check runs fmt, vet, lint, and tests; all green.

@polymorcodeus polymorcodeus self-assigned this Sep 25, 2026
@polymorcodeus
polymorcodeus merged commit f9bd7f6 into main Sep 25, 2026
4 checks passed
@polymorcodeus
polymorcodeus deleted the shelf-list-tty-leak branch September 25, 2026 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant