Render panel header glyphs through the resolved-icon path (#8558)

Closed
BO
2mo ago
+167-9

Summary

  • What changed? The markdown viewer and file preview headers (PanelFilePathHeader) now draw their leading file icon and every trailing action glyph through CmuxResolvedIconImage instead of the SwiftUI symbol path. The glyph tint becomes an explicit NSColor carried by a new panelHeaderIconTint environment value, so .foregroundColor(.secondary) is dropped from PanelHeaderIconButton, MarkdownTypographyControl, and FileExternalOpenHeaderMenuButton.
  • Why? Fixes #8558. On macOS 15 the SwiftUI symbol path rasterizes these glyphs fully transparent while the buttons keep their frames and hit areas, so the entire upper-right action group is invisible but still responds to clicks.

Root cause

Reproduced deterministically on macOS 15.7.4 (Apple Silicon), Xcode 16.4. In a markdown panel the whole header action group and the leading doc.richtext icon render blank, in every state — before and after the app-activation cycle from the report.

Three instrumented builds narrowed it down:

  1. The controls exist. Giving PanelHeaderIconGlyph a colored background shows all six button frames laid out and empty. The 20×20 frame and contentShape(Rectangle()) survive whether or not a glyph draws, which is exactly the "invisible but clickable" symptom.
  2. It is not the tint. Forcing .foregroundStyle(.red) on the glyph changes nothing, so this is not a tint resolving to the background color.
  3. It is not CmuxSystemSymbolImage's image resolution. Painting the nil-image fallback branch green shows it is never taken — the NSImage resolves fine. Setting cacheMode = .never plus recache() on the cached image does not help either, so a poisoned shared raster is not the cause.

A side-by-side render of all three paths in the live header settles it:

pathresult
Image(systemName:)blank
CmuxSystemSymbolImage (shared template NSImage)blank
CmuxResolvedIconImageglyph renders

So the SwiftUI symbol path itself fails to rasterize in this header context, and the AppKit renderer introduced in #7729 does not. CmuxResolvedIconRenderer draws into an explicit bitmap context under appearance.performAsCurrentDrawingAppearance, verifies the output contains visible pixels, and re-renders on window attachment and effective-appearance changes.

The tint has to be explicit rather than a hierarchical style: the AppKit-backed icon resolves the window appearance, not the panel's SwiftUI colorScheme override, so .secondary would no longer track the panel theme. PanelFilePathHeader publishes the panel's theme foreground at 0.55 alpha; disabled glyphs keep the color at reduced alpha.

Relationship to existing work

This is the same surface and the same approach as #9144, which has been open since 29 July and is currently conflicting with main. That PR's analysis and its choice of the resolved-icon path informed this one; close whichever you prefer. Related reports of the same class: #8352, #7725, #4476.

Scope is deliberately limited to the panel header. Other CmuxSystemSymbolImage call sites are untouched.

Testing

  • Local dogfood. Tagged debug build, markdown panel opened via the debug CLI. Before: leading icon and all six action glyphs blank. After: all render, and they survive deactivating and reactivating the app.
  • Added cmuxTests/PanelHeaderIconGlyphTests.swift (Swift Testing, wired into the cmuxTests target; scripts/lint-pbxproj-test-wiring.sh passes): request construction (symbol source, size, explicit tint, disabled alpha, fallback tint), theme-tint derivation, and a parameterized pass rendering every header symbol under both aqua and darkAqua, asserting the renderer reports visible pixels.
  • I could not execute the unit tests locally. xcodebuild test -scheme cmux-unit aborts in swift-frontend while deserializing the cmux_DEV module (While finishing conformance for protocol conformance GhosttyNSView: TerminalRenderedFrameReceiving → While cross-referencing conformance for 'NSResponder' → abort). I verified this is not caused by this change: the identical crash reproduces on the unmodified base commit, on a clean derivedDataPath, in a compile batch that contains none of my files. It is Xcode 16.4 / Swift 6.1.2 on my machine; CI pins its own Xcode. Please let CI run the suite.
  • No red/green regression commit pair. The failure is an OS-level rasterization failure in the SwiftUI symbol path that a unit test cannot observe — the same symbols render fine in an isolated SwiftUI harness on this machine. The renderer-level visibility assertions are the meaningful guard.
  • Localization audit: icon rendering only. No user-facing strings added, changed, or removed; all String(localized:) labels, help text, and accessibility labels are untouched, so no Resources/Localizable.xcstrings or web/messages/*.json changes are needed.

Note on the base commit

This branch is based on 5734a451c rather than current main because main has not compiled since 04ff18eea (14 Aug):

  • Sources/Workspace+PanelLifecycle.swift:455 passes workspaceID: to TerminalController.cleanupSurfaceState, which takes (surfaceIds:paneIds:).
  • Sources/TerminalController+MobileSurfaces.swift references panelArtifactAuthorizationStore, which is not declared anywhere in the repository, plus three non-exhaustive switches over the new MobileSurfaceKind cases.

5734a451c is an ancestor of main, so this PR's diff is just the one commit. Happy to rebase once main builds again.

Checklist

  • I tested the change locally
  • I added or updated tests for behavior changes
  • I updated docs/changelog if needed (none needed)
  • I requested bot reviews after my latest commit
  • All code review bot comments are resolved
  • All human review comments are resolved

Fixes #8558.

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Summary by cubic

Render panel header icons through the resolved AppKit path with an explicit tint to fix invisible-but-clickable glyphs on macOS 15. Old: SwiftUI symbol path produced transparent glyphs; new: CmuxResolvedIconImage draws visible pixels; side effect: tint now comes from a new environment value.

  • Switches the leading file icon and all trailing header actions in PanelFilePathHeader to CmuxResolvedIconImage (16×16 lead, 13×13 glyphs) and publishes panelHeaderIconTint.
  • Drops .foregroundColor(.secondary) from header buttons; derives tint from the header theme foreground at 0.55 alpha; disabled state keeps color, reduces alpha by 0.45; falls back to NSColor.secondaryLabelColor.
  • Adds PanelHeaderIconGlyphTests covering request construction, tint derivation, and visible-pixel rendering for all header symbols in aqua and darkAqua.
  • Scope limited to panel headers; other CmuxSystemSymbolImage call sites unchanged.

Fixes #8558.

Summary by CodeRabbit

  • Style

    • Improved panel header icon appearance across light and dark themes.
    • Applied consistent tinting, sizing, disabled-state transparency, and secondary emphasis to header icons.
    • Updated file preview and typography controls to use the resolved icon appearance.
  • Tests

    • Added coverage for icon tinting, sizing, disabled states, theme changes, and visible rendering.