Skip to content

Add a shared presentation system for themes and bar layout #55

Closed

Description

@M4n0x

Problem and scope

Provide generic theme-controlled presentation for existing widgets and popups, plus correct bar decorations across widgets and displays. Tonhalle Line is the acceptance case: a light 16 pt clock, styled popup elements, a workspace underline below the bar, and an all-four-edge brass outline in AeroSpace tailing mode. Theme switching must remove the old appearance without changing widget behavior.

This issue consolidates #56 and #57. Their requirements and original evidence remain active here.

The property names below describe proposed API, not settings available today. Scope is explicit roles, workspace defaults, mode states and bar decorations. Widget definitions continue to own content, actions and row/column structure. Broad type/ID selectors, theme-defined layout variants, a new horizontal layout algorithm and speculative caching/indexing infrastructure are deferred.

Presentation contract and precedence

Add an optional role to widgets and layout/popup blocks. Start with a documented vocabulary: time, primary, secondary, key, value, heading, button, meter, separator. Reject unknown role names; omitting a role retains today's behavior.

A top-level roles maps these names to styles. Built-in supplies an empty fallback for each role; a selected theme may style any subset. User configuration/includes/profiles may override them. Widget packages may annotate their widgets/blocks with roles, but do not define global role styles. Theme role styles cannot change actions, providers, visibility, display filters or layout structure.

Add workspaceDefaults for indicator, indicatorStyle, cell style and appStyle. Merge them beneath each widget's own workspace, preserving existing state aliases and user choices such as app glyph mappings.

Style precedence, lowest to highest:

  • Widget: defaults → role style → widget style → other widgets' output widgetStyles in configuration order → own output style/color.
  • Block: inherited style → role style → block style → output style selected by styleSource/styleField. Role box properties apply to that block, without leaking background, padding or dimensions into its children.
  • Popup: preserve defaults → popupDefaults → widget's explicit style → popup style; do not inherit the bar widget's role. Popup blocks resolve their own roles.
  • Workspace: workspaceDefaults → widget workspace.
  • Bar: configured bar.style → script barStyle overrides in configuration order.

Preserve existing configuration composition and merge/null semantics. Apply active states after these base layers: data → workspace → mode → named mode alias → hover → open, preserving nested-state behavior. The bar consumes mode states; this issue does not activate previously ignored group states. An explicit widget style beats its role's base style; an active state still beats a base value, as today.

Migration is opt-in: annotate the time clock separately from the date (both have type clock), and annotate popup elements before expecting role styling. A widget's explicit font still reaches its popup; a time role's font does not. Horizontal music-popup structure remains a widget definition and can use the same roles under every theme.

Mode state: configuration maps names, themes own appearance

Expose reserved mode and mode.<alias> style states. mode means a connected AeroSpace binding mode other than main. A user-owned modeAliases mapping optionally activates a semantic alias; unmapped non-main modes activate only mode. Scripts/rules cannot set these reserved mode states as data states; document migration for colliding custom state names. Themes cannot define the mapping.

For example, user configuration contains:

{ "modeAliases": { "tailing": "command" } }

Tonhalle Line owns the visual rule:

{
  "bar": {
    "style": {
      "states": {
        "mode.command": {
          "borderEdges": "all",
          "borderColor": "@token.warning"
        }
      }
    }
  }
}

Leaving tailing removes that alias state and restores the applicable base/remaining-state border, including its edges. Switching themes while the alias remains active resolves the incoming theme's rules and tokens. An active mode state takes precedence over a script's plain barStyle; document that interaction.

Use an event-driven style update, not a profile condition or configuration reload:

  • With workspaceSource: aerospace, keep one connection while workspaces, active-display widgets, aerospaceMode subscribers or active presentation rules need it.
  • Read the current mode on connect/reconnect; do not wait for the next change.
  • Clear mode state on disconnect, source switch or stop; no AeroSpace mode state applies under yabai.
  • Publish mode changes independently of workspace refresh. A mode-only change does not restart sources or close popups.
  • Share the mode across displays; hover/open state stays local to the actual widget instance.

Geometry

Outline: add bar.style.borderEdges: bottom (existing default) or all. Draw the full outline just inside the visible strip, following margin and corner radius, without changing panel size, clearance or clicks. A notch or system menu bar may obscure part of the top edge. Update both the actual bar and Customize's theme-card preview.

Underline: add indicatorStyle.placement: cell (existing behavior) or belowBar. With belowBar, the underline's top is the visible bar background's bottom plus offsetY, independent of cell height. Its horizontal span follows the visible cell and is clipped to its owning widget's visible region.

A per-display decoration layer sits outside the bar-content clip. Use anchors from visible instances only, excluding hidden measurement copies and overflowed widgets; account for scrolling constrained widgets. Keep layout, drawing and hit bounds distinct. Reserve the maximum required outside extent across configured states so focus/mode changes do not resize panels. Do not stretch the background or move labels to make room. Preserve indicator animation, Reduce Motion and pixel alignment under display scaling.

Include the extra strip in native panel bounds, window clearance and documented AeroSpace/yabai gap calculations. Verify native click-through outside interactive widget bounds; a SwiftUI hit-test change alone is not proof. Popup placement must account for the visible bar/decorations and the opening instance's display.

Keep existing horizontal priority, group, notch and shrink/overflow policies. A new baseline system or sizing algorithm is not required here.

Efficiency and compatibility

Keep existing guarantees: shared sources, stable widget/instance identity, only changed presentation values published, instance-local hover/open, theme-only edits retaining running sources, and invalid edits retaining the last working configuration.

The repeated cross-widget style scan is real but not a measured bottleneck. Start by building ordered widgetStyles contributions once per update, preserving precedence and removal of stale targets. Separate decoration observation from layout so paint-only changes do not require application-level width measurement/planning. Visibility, font or size changes still replan affected displays.

Retain the hidden measuring copy initially. Add dependency indexes, rule compilation or measurement caches only after profiling demonstrates a need.

Preserve current popup lifecycle: a theme/configuration change closes the open popup; reopening uses the new theme. A mode-only change leaves it open. Existing app/workspace-switch dismissal remains unchanged.

Acceptance and regression checks

  • A time clock is Helvetica Neue Light 16 pt while ordinary labels remain 13 pt regular; a separate secondary date and popup text keep their intended styles. Unannotated widgets and missing theme-role definitions have compatible fallbacks.
  • Annotated popup headings, secondary text, buttons, rows and key/value columns, plus workspace cells/app glyphs/indicator styles, follow theme switching. Updating the widget layout and Tonhalle theme/examples is part of delivery.
  • A 2 pt underline appears immediately below a 38 pt bar and with a configured gap, across focus changes, scrolling/overflow, scales and displays; label/background geometry and panel size remain stable during state changes.
  • Entering mapped tailing produces all four outline edges in the theme's warning color; exit, disconnect, reconnect and theme switching restore/recompute the right appearance. Test without a workspace widget and with yabai.
  • Exercise at least 15 widgets on notched 1512 pt and unnotched 2560 pt display fixtures, including long labels, groups, hidden widgets and constrained widths, under existing overflow policies. Verify popup anchors on the correct instance.
  • Verify the full cascade, role/explicit-font popup isolation, state precedence, legacy script overrides and removal of stale cross-widget targets. Existing bottom borders and cell-relative indicators remain unchanged unless opted in.
  • A color-only mode change updates only affected presentation/decorations; a newly visible mode widget triggers layout where needed. Theme-only changes keep script/provider runners and the AeroSpace connection alive when still required.
  • Update decoder/schema parity and theme/package allowlists; composition through includes, templates, profiles and packages; shared CLI edits for roles, workspace defaults and mode aliases; Customize role/indicator/border controls and theme cards; Diagnostics/--query style origins; README and examples.
  • Record before/after rendering and performance observations for a representative multi-widget, two-display setup. Distinguish style computation, view invalidation and geometry work; do not require a new optimization subsystem or an unmeasured speedup.

Evidence and delivery

Verified against 3e621ba, v0.5.0-beta.72:

  • Theme validation rejects widget overrides/templates, including in theme profiles. Block resolution has no role lookup.
  • Allow workspace underlines to draw below the bar #56's offscreen reproduction: a 38 pt cell and 2 pt underline at offsets 0/1/2/4 show full/half/no/no line, even with 12 pt of host space below. BarView clips content and paints only the bottom border; panel sizing also limits the drawing area.
  • aerospaceMode currently reaches subscribers only while the workspace connection is running. Mode is private and not cleared on disconnect. bar.style.states decodes but is not applied by the bar resolver. Script-output colors do not resolve @token names.
  • updatePresentations and widgetStyleLayers repeat scans; existing PresentationTests already cover selective invalidation and popup-instance ownership.

Deliver in reviewable stages within this issue:

  1. Four-edge bar border, preserving the default.
  2. Mode lifecycle/states and user mapping, with the one-pass override aggregation.
  3. Below-bar workspace indicators and native geometry/hit behavior.
  4. Roles/workspace defaults, authoring controls, migration examples and Tonhalle configuration.

Stages 3 and 4 can be developed independently of the border/mode stages. Theme layout variants, general selectors, baseline redesign and replacement of the measuring copy are separate follow-ups if justified.

Earlier work: #19 / #26, #49, #15 / #50, #16 / #52. #56 and #57 remain consolidated here, not implemented or dropped. Architecture reviewed by Claude Opus 5.5 at Max effort.

Triaged by Codex (gpt-6-astra).

Activity

  1. added
    enhancement
    on Oct 17, 2026
  2. changed the title [-]Let themes style individual widgets, workspace indicators and popup elements[/-] [+]Let themes target bar, widget, workspace and popup presentation[/+] on Oct 17, 2026
  3. changed the title [-]Let themes target bar, widget, workspace and popup presentation[/-] [+]Add a shared presentation system for themes and bar layout[/+] on Oct 17, 2026
  4. M4n0x commented on Oct 22, 2026

    @M4n0x
    CollaboratorAuthor

    Implemented by #58 (68c7604), released in v0.5.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions