Repository navigation
fix | switch appearance without a terminal's IO thread waiting forever on its own mailbox (#cm-120.2) - #7
Merged
Merged
Conversation
…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
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 amode 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
iothreads both in the queue-full waitof the same BlockingQueue push, the other 78 idle.
(upstream's text).
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
tryin Thread.zig), so later messages waited for thenext wakeup.
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 was still waiting after 2 s on a full termio mailbox".
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