Skip to content

Tell a program the appearance when a tab attaches - #43

Merged
Lakr233 merged 2 commits into
mainfrom
fix/theme-report-on-attach
Oct 31, 2026
Merged

Lakr233 merged 2 commits into
mainfrom
fix/theme-report-on-attach

Conversation

@Lakr233

@Lakr233 Lakr233 commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

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 n only 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 by XPCDaemonTransport after an attach has delivered its output.
  • TerminalSessionStore sends 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 to make harness), full make test passes.
  • On a vphone guest (iOS 26.4, roothide): a probe enabling 2031 and logging its input, opened with ighostvt-cli new, then the app cold-launched to adopt it. 1.6.22: nothing received. This build: ESC[?997;1n in dark, ESC[?997;2n in light.

🤖 Generated with Claude Code

Lakr233 and others added 2 commits October 31, 2026 02:03
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>
@Lakr233
Lakr233 merged commit 177b1d5 into main Oct 31, 2026
6 checks passed
@Lakr233
Lakr233 deleted the fix/theme-report-on-attach branch October 31, 2026 03:08
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