Skip to content

fix | switch appearance without a terminal's IO thread waiting forever on its own mailbox (#cm-120.2) - #7

Merged
tom-rigelblu merged 1 commit into
mainfrom
cm-120.2-ghostty
Nov 11, 2026
Merged

tom-rigelblu merged 1 commit into
mainfrom
cm-120.2-ghostty

Conversation

@tom-rigelblu

Copy link
Copy Markdown

Takes upstream ghostty-org's fix, 297507f ("termio: send the config
change color scheme report directly", Fixes ghostty-org#14833, 2026-10-24), with
its exact text and position, so the sync that brings it keeps one copy.
manaflow-ai/ghostty main doesn't carry it yet (checked 2026-11-09).

The IO thread is the only thread that drains a surface's termio mailbox.
While it handled .change_config, StreamHandler.changeConfig queued a
mode 2031 color_scheme_report into that same mailbox with a blocking
send. When the mailbox was full, the IO thread waited on itself forever,
and the main thread's next push for that surface waited behind it: a
light/dark switch froze the app. A cmux hang sample from 2026-11-05 shows
exactly that: main and one of 79 io threads both in the queue-full wait
of the same BlockingQueue push, the other 78 idle.

  • src/termio/stream_handler.zig: changeConfig no longer queues the report
    (upstream's text).
  • src/termio/Termio.zig: changeConfig writes it last, with
    colorSchemeReportLocked(td, false), inside the renderer lock it already
    holds (upstream's text). A failed write is logged and the config change
    still completes. Before, a failed queued report ended the IO thread's
    drain pass (the try in Thread.zig), so later messages waited for the
    next wakeup.
  • src/global.zig: tmpDirPath returns "/tmp" in tests with no global
    state, like the file's other builtin.is_test fallbacks, so a test can
    build a real Termio. Ours, like both tests; upstream's commit has none.

Tests, each seen failing first:

  • "changeConfig returns on a full termio mailbox": red on ed5c48f,
    "changeConfig was still waiting after 2 s on a full termio mailbox".
  • "changeConfig writes one mode 2031 report with the new theme and queues
    none": the terminal starts dark and switches to light. With the
    queued send put back it finds nothing; with the report written before
    the new config is swapped in it finds the old theme, "\x1b[?997;1n",
    where it expects "\x1b[?997;2n".
    Mutations: dropping the new call turns the second test red alone;
    putting the queued send back turns both red.

🤖 Generated with Claude Code

https://claude.ai/code/session_019faQDfp9Q3KPyaDHXEosfG

…r on its own mailbox (#cm-120.2)

Takes upstream ghostty-org's fix, 297507f ("termio: send the config
change color scheme report directly", Fixes ghostty-org#14833, 2026-10-24), with
its exact text and position, so the sync that brings it keeps one copy.
manaflow-ai/ghostty main doesn't carry it yet (checked 2026-11-09).

The IO thread is the only thread that drains a surface's termio mailbox.
While it handled `.change_config`, StreamHandler.changeConfig queued a
mode 2031 color_scheme_report into that same mailbox with a blocking
send. When the mailbox was full, the IO thread waited on itself forever,
and the main thread's next push for that surface waited behind it: a
light/dark switch froze the app. A cmux hang sample from 2026-11-05 shows
exactly that: main and one of 79 `io` threads both in the queue-full wait
of the same BlockingQueue push, the other 78 idle.

- src/termio/stream_handler.zig: changeConfig no longer queues the report
  (upstream's text).
- src/termio/Termio.zig: changeConfig writes it last, with
  colorSchemeReportLocked(td, false), inside the renderer lock it already
  holds (upstream's text). A failed write is logged and the config change
  still completes. Before, a failed queued report ended the IO thread's
  drain pass (the `try` in Thread.zig), so later messages waited for the
  next wakeup.
- src/global.zig: tmpDirPath returns "/tmp" in tests with no global
  state, like the file's other builtin.is_test fallbacks, so a test can
  build a real Termio. Ours, like both tests; upstream's commit has none.

Tests, each seen failing first:
- "changeConfig returns on a full termio mailbox": red on ed5c48f,
  "changeConfig was still waiting after 2 s on a full termio mailbox".
- "changeConfig writes one mode 2031 report with the new theme and queues
  none": the terminal starts dark and switches to light. With the
  queued send put back it finds nothing; with the report written before
  the new config is swapped in it finds the old theme, "\x1b[?997;1n",
  where it expects "\x1b[?997;2n".
Mutations: dropping the new call turns the second test red alone;
putting the queued send back turns both red.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019faQDfp9Q3KPyaDHXEosfG
@tom-rigelblu
tom-rigelblu merged commit 2d7dc61 into main Nov 11, 2026
@changeset-bot

changeset-bot Bot commented Nov 11, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 1cb1aaa

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

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.

Config reload freezes Ghostty indefinitely when the IO mailbox is full

1 participant