Repository navigation
Tell a program the appearance when a tab attaches - #43
Merged
Merged
Conversation
A program that turned on color-scheme reports (mode 2031) before a tab attached — Claude Code does at startup — never heard this device's light or dark: Ghostty reports a scheme change only when its config changes, and a tab's config is applied before the attach's output turns the mode on. The program kept the background it first read until the appearance was switched by hand. Each tab now follows mode 2031 through the output it receives (ThemeReportMode), and once an attach has delivered its output, sends the current scheme (CSI ? 997 ; 1/2 n) when the mode is on. A rebuilt replay's preamble carries the mode, so this needs nothing from the host. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Symptom
Claude Code (and anything else that enables mode 2031 and asks OSC 11) running in a session a tab attaches to — first connect, cold launch, another device — kept the light/dark it read at startup. Switching the appearance locally once fixed it.
Cause
Ghostty sends
CSI ? 997 ; 1/2 nonly when its config changes and mode 2031 is on. A tab's config is applied before the attach's output arrives, while the mode is still off, so the report is dropped and the program is never told.Fix (app only)
ThemeReportMode/ThemeReportTracker: follow DEC private mode 2031 through received output (set/reset among other params, RIS, split across chunks; a replay replaces the state).TerminalTransportEvent.attachSettled: emitted byXPCDaemonTransportafter an attach has delivered its output.TerminalSessionStoresends the current scheme (AppearancePreference.isDark) when the mode is on at that point.No protocol change: since 1.6.22 a rebuilt replay's preamble restores 2031 (
TerminalReplayState.trackedDECModes), and a continuation keeps the tab's own state. A pre-1.6.22 host's raw replay may have lost the set — then nothing is sent, as before.Testing
Tests/ThemeReports(added tomake harness), fullmake testpasses.ighostvt-cli new, then the app cold-launched to adopt it. 1.6.22: nothing received. This build:ESC[?997;1nin dark,ESC[?997;2nin light.🤖 Generated with Claude Code