Skip to content

Render a blank bootstrap state until first output after open/reset#154

Open
aliceisjustplaying wants to merge 1 commit into
coder:mainfrom
aliceisjustplaying:pix/bootstrap-blank-on-open-reset
Open

Render a blank bootstrap state until first output after open/reset#154
aliceisjustplaying wants to merge 1 commit into
coder:mainfrom
aliceisjustplaying:pix/bootstrap-blank-on-open-reset

Conversation

@aliceisjustplaying
Copy link
Copy Markdown

Summary

Render a theme-colored blank bootstrap state until the first real terminal output after open() and reset().

Problem

While debugging PiClaw terminal reopen behavior, I reproduced a separate visual issue in standalone ghostty-web:

  • open() / dispose() / reopen() could start with an undesirable first frame
  • reset() could also briefly expose content that did not represent the intended clean startup state

That meant there was a real application-side handoff bug to fix downstream, but there was also a library-level presentation issue that reproduced outside PiClaw.

What this PR changes

In lib/terminal.ts this PR:

  • adds a small bootstrap render buffer
  • creates blank terminal cells using the current theme foreground/background colors
  • arms that blank state during open() before the first render
  • re-arms the blank state during reset()
  • clears the bootstrap state on the first real write
  • routes the render loop through the bootstrap-aware buffer so the renderer sees the blank state until real terminal content exists

Why this approach

The goal is to make the initial terminal frame deterministic and visually clean without requiring application-specific hide/reveal timing.

Instead of relying on a consumer to hide the host until output arrives, the library itself can expose a stable blank startup surface until the terminal receives real content.

Testing

Validated locally in two ways:

  1. directly in the ghostty-web source checkout while iterating on the bootstrap behavior
  2. downstream in PiClaw after pinning vendoring to the forked commit and rebuilding the vendored asset

Scope note

This PR is intentionally limited to startup/reset rendering behavior.

— Pix (PiClaw, openai-codex/gpt-5.4)

diegosouzapw added a commit to diegosouzapw/ghostty-web that referenced this pull request May 24, 2026
Before the first call to write() (or after reset()), render a blank
canvas filled with the theme background colour instead of showing
a transparent/black frame. This eliminates the flash of unstyled
content on open().

- Add parseCssColorToRgb() for hex and rgb() CSS colour parsing
- Add createBlankBootstrapCells() to build a dummy blank frame
- Add bootstrapBuffer proxy IRenderable that delegates to WASM once
  bootstrapCells is null
- armBootstrapBlank(): sets bootstrapCells from current theme on open()/reset()
- disarmBootstrapBlank(): clears bootstrapCells on first write()
- All render paths now use bootstrapBuffer instead of wasmTerm directly
- Fix pre-existing biome lint issues in viewport/iris test files


Inspired-by: coder#154

Co-authored-by: alice <aliceisjustplaying@gmail.com>
@diegosouzapw
Copy link
Copy Markdown

Hi @aliceisjustplaying! 👋

Your work on this PR inspired a commit in my fork diegosouzapw/ghostty-web.
I ported the bootstrap blank state approach and added you as co-author in the corresponding commit — thank you for the contribution!

I'm working on OmniRoute, a project that provides free access to LLM models, and I'm planning to use ghostty-web as the terminal component there. Your work is part of what makes that possible. 🙏

Feel free to check it out — contributions and feedback are very welcome!

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.

2 participants