Screen flash on macOS caused by repeated osascript Terminal theme polling

Resolved 💬 4 comments Opened Mar 2, 2026 by dennisreiche4-prog Closed Mar 6, 2026

Description

Claude Code periodically spawns osascript to query Terminal's theme settings:

osascript -e tell application "Terminal" to name of current settings of front window

Each invocation creates a short-lived WindowServer GUI connection (~20-150ms) that causes a visible full-screen flash on macOS. The flash appears as a brief brightness spike — like a screenshot shutter effect.

Reproduction

  1. Run Claude Code v2.1.63 in macOS Terminal.app
  2. Observe periodic screen flashes (every ~20-60 seconds, more frequent during active command execution)
  3. Monitor with: log stream --predicate 'eventMessage CONTAINS "ConnectionDebug"' --style compact
  4. Each flash corresponds to a [ ConnectionDebug ] New conn / Closing conn pair from a short-lived osascript PID

Evidence

Captured via process monitoring:

=== osascript PID: 3429 ===
PARENT PID 1465: claude
Command: osascript -e tell application "Terminal" to name of current settings of front window

WindowServer ConnectionDebug log:

15:23:02.985 [ ConnectionDebug ] New conn 0xa91df, PID 3429 in session 257 on console
15:23:03.008 [ ConnectionDebug ] Closing conn 0xa91df, PID 3429 — already dead (short-lived)

Each osascript invocation:

  1. Spawns process
  2. Makes TCC (privacy) permission check
  3. Opens WindowServer GUI connection
  4. Closes connection and exits within milliseconds
  5. WindowServer compositor does a brief full-screen redraw → visible flash

Environment

  • Claude Code: 2.1.63
  • macOS: Sequoia 15.7.4 (Build 24G517)
  • Mac: Mac16,5 (M4 Max)
  • Terminal: macOS Terminal.app
  • Display: Samsung S32B80P (4608x2592) + built-in display — flash occurs on both

Suggested Fix

  • Cache the Terminal theme result instead of polling via osascript repeatedly
  • Or use defaults read com.apple.Terminal to read theme without spawning a GUI process
  • Or subscribe to appearance change notifications (NSAppearance) instead of polling
  • Or add a config option to disable Terminal theme detection

Workaround

None currently available. Switching to a non-Terminal.app terminal (iTerm2, etc.) may avoid the osascript polling but untested.

🤖 Generated with Claude Code

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗