Skip to Content

Architecture

A map of Thaw’s main parts and where they trust each other, not an API reference. It describes Thaw 3, on this branch. Thaw 2 is on legacy/thaw-2.

Thaw is a native macOS menu bar manager written in Swift with AppKit and SwiftUI. It hides and shows menu bar items, finds them from the keyboard, switches layouts with profiles and changes how the menu bar looks.

Goals

  • Keep the menu bar usable, hiding what people don’t need and showing it on demand, without ever losing an item.
  • Work only on the Mac: no accounts, no telemetry and no tracking server.
  • When a thaw:// link asks to change settings and Thaw can’t confirm it is allowed, refuse it.
  • Stay compatible with current macOS releases. Thaw 3, on this branch, targets macOS 27. Thaw 2, on legacy/thaw-2, runs on macOS 26. Thaw 2.2 adds macOS 15.

How the code is organized

Thaw doesn’t follow a named pattern such as MVVM or Clean Architecture. The code is arranged like this:

SwiftUI / AppKit views
  → managers owned by AppState
      ├─ pure planners and models (MenuBarModel, ThawLayout, app-local rules)
      └─ backend adapters and service clients
          → PlatformRuntimeKit, helper processes, macOS

The arrows show who calls whom. Managers gather observations, ask the pure code for decisions, and apply those decisions through adapters. Pure planners must not call the adapters or read app state.

  • Views generally read state straight from @Observable managers. There is no required view-model layer.
  • AppState creates the long-lived managers (MenuBarManager, MenuBarItemManager, ProfileManager, HIDEventManager and others) and hands them to the rest of the app. Because almost everything reaches through it, new types should take the dependencies they need instead.
  • Decisions, such as which section an item belongs in or what order to write, live in pure functions in MenuBarModel, ThawLayout and app-local rule types, so they can be tested without a live menu bar.
  • Protocols such as MenuBarBackend live in MenuBarModel. Thaw/MenuBar/Backends selects runtime implementations and wraps operations such as position-store writes. These boundaries limit coupling to PlatformRuntimeKit, but the separation is incomplete: some managers and system code still import it directly. Prefer the existing boundaries when adding behavior.

A few types still combine too many responsibilities. Coding standards lists them and says where new code goes instead.

Repository layout

PathWhat it holdsPackage dependencies
Thaw/The app: menu bar logic, settings, panels, input, permissionsLocal libraries and external runtime/UI packages
packages/MenuBarModel/Menu bar items, sections, identity, move planning and the backend protocolsNothing
packages/ThawLayout/The layout solver: saved section order, where new items goMenuBarModel
packages/ThawCapture/Item image capture with ScreenCaptureKit, and the client for the capture serviceMenuBarModel, ThawConcurrency
packages/ThawConcurrency/Timeouts and one-shot continuationsNothing
packages/ThawAX/Accessibility reading: ThawAXCore, ThawAXClient and the ThawAXHelper processNo other package; client and helper use ThawAXCore
packages/ThawExtras/ThawExtraHelper, stand-ins for Apple items Thaw hides (Focus, AirDrop and others)Nothing
targets/ThawControls/Control Center controls that show hidden items or toggle Zen Mode
packages/ThawCtl/A command-line tool that turns commands into thaw:// URLs
targets/MenuBarCaptureService/The XPC service that hosts captureThawCapture
ThawTests/App-level Swift Testing tests; packages also have their own test targetsApp and library modules
packages/Fuzzing/libFuzzer targets; currently the thaw:// settings URI parser
scripts/Lint, coverage and release helpers used by CI
docs/User and developer documentation
.github/CI, release, issue and pull request templates

The table lists package dependencies, not Apple frameworks or every Xcode target relationship. Package.swift files and the Xcode project are the source of truth for the build graph.

Local packages do not depend on the app. ThawLayout and ThawCapture depend on other local packages. The controls, settings pages and onboarding pieces shared with Floe come from ThawUI, pinned to a tag. Keep app state out of packages. ThawAX and ThawExtras have no external package dependencies. Helper packaging and library search paths matter: ThawAX declares a static core product and an Xcode helper rpath in its manifest.

Outside packages are declared with Swift Package Manager and locked in Thaw.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved: PlatformRuntimeKit (as the prebuilt thaw-app/prk-bin), Sparkle, Ifrit, ThawUI, swift-algorithms, swift-async-algorithms and swift-subprocess. CompactSlider is locked there too, as a dependency of ThawUI.

Inside Thaw/

FolderWhat it holds
App/AppDelegate, AppState, App Intents, single-instance and quit handling
Items/The item manager: reading, caching, moving, grouping, spacing and saving items
MenuBar/Sections, the control items, appearance and backdrop, and the backends
Environment/Reacting to display, Space and arrangement changes
Input/Mouse and keyboard events, and hotkeys
Panels/Search, the Thaw Bar, the Layout editor, the swap bar and other floating panels
Settings/The settings model, profiles, the panes and settings search
System/Permissions, updates, thaw:// handling, script hooks and other system glue
RecordingWatch/Noticing when the camera, microphone or screen recording is in use
Onboarding/, UI/, Utilities/The first-run walkthrough, shared views and helpers

Where to start a change

ConcernEntry points
Startup and subsystem lifetimeAppDelegate, AppState
Item inventory and cacheItems/Manager, Items/Model
Saved order and move planningThawLayout, LayoutMoveSequencePlanner
Layout writes and automatic repairRepairOrchestrator, MenuBarPositionStoreProvider
Hide, reveal and section policyMenuBarManager, RuntimeSectionContextAdapter
Item imagesItems/Capture, ThawCapture, MenuBarCaptureService
Display and Space changesEnvironment
Settings and profilesSettings/Models, Defaults
Automation and sender authorizationSettingsURIParser, SettingsURIHandler, SettingsURISender

Runtime components

PlatformRuntimeKit is linked into the app process. The helpers below run in separate processes; being shipped inside the app bundle does not make them in-process services.

ComponentConnection to the appResponsibility
ThawAXHelperStandard input/output pipes through ThawAXClientAccessibility observations
MenuBarCaptureServiceXPCImage capture in a recyclable process
ThawExtraHelperLaunched as separate stand-in appsApple-item replacements with separate owning bundles
Settings child processStandard input/output pipesOn by default (SettingsInOwnProcess); exits when its last window closes
ThawControlsDarwin notifications for commands, App Group snapshot for stateControl Center controls
ThawCtlthaw:// URLsCommand-line entry into app automation

Startup and ownership

AppDelegate owns AppState. The normal menu bar stack starts only after the required permissions are available. AppState.bootstrapTask is a shared lazy task, so callers wait for the same setup rather than starting it twice. Settings and display state start before the menu bar stack, the item manager starts before image capture, and observers are installed after setup.

Keep this ordering when changing startup. Creating a manager must not assume that permission checks have passed or that its sibling managers are ready. The reduced-permission mode and the optional settings child process have separate startup paths; don’t start the full menu bar stack in either just to obtain a dependency.

The settings process

Settings runs as Thaw --settings <pane>: the same executable and bundle, started by the app with pipes for its standard input and output. It builds an AppState but never launches it, so whatever a page needs from the running menu bar goes through the app:

  • Preferences are written in the settings process. Both processes share the defaults domain, and a change sends .settingsChanged so the other side reads its settings again.
  • Live state, such as items, profiles and presentation, comes from the app as statuses. Actions go to the app as the page’s commands and requests, from a fixed list per page. Only the app reads the screen; it writes item pictures to a file the settings process reads.
  • Every manager AppState creates also exists in the settings process. Keep initializers free of work that only makes sense in the running app.
  • A side doesn’t echo back the defaults it writes while reading the other’s change: SettingsLinkEndpoint ignores changes made during that reload. A page that writes defaults later, from its own task or queue, sends a .settingsChanged the other side reads again. That’s harmless while reading settings is idempotent, so keep it that way.
  • macOS delivers thaw:// links to the app even while Settings is in front, so the settings process registers no handler for them.

How Thaw works with macOS 27’s menu bar

On macOS 27 the menu bar is drawn by Apple’s MenuBarAgent, and items have no windows of their own to move. Thaw works with it in four ways.

  • Hiding: PlatformRuntimeKit, a closed component, asks MenuBarAgent to hide an app’s items. macOS hides by app, so all of one app’s items hide together. With the Native hiding method, Thaw uses the per-app switches in System Settings instead. Frequent issues lists what each method can’t do.
  • Order: macOS keeps the menu bar’s order in one file. With Menu Bar Layout Access, the user picks that file and Thaw writes positions into it, so items move without the pointer moving. Writes go through a permit (Thaw/MenuBar/Backends). Where a write can’t place an item, Thaw falls back to a synthetic ⌘-drag.
  • Reading: ThawAXHelper reads the menu bar through Accessibility in its own process and answers the app over a pipe. MenuBarAgent’s own window lists every visible item with the process that owns it (MenuBarAgentWindow.swift in ThawAXCore).
  • Stand-ins: macOS hides by the bundle that owns an item, so each replacement for an Apple item comes from its own small app built from ThawExtraHelper.

Layout writes

The position table is shared system state, not an ordinary app preference. App code uses MenuBarPositionStoreProvider, which exposes a PermittedPositionStore. Its write methods require a StoreWritePermit.

  • RepairOrchestrator schedules repair and layout work through RepairLane. Item moves can obtain a permit while holding the move semaphore.
  • Manual arrangement selects ReadOnlyPositionStore. Explicit Layout edits use the scoped forLayoutEdit path; automatic repair must remain read-only.
  • A permit records admission to a write path. It does not prove that an old plan is still valid after waiting. Callers must honor cancellation and the orchestrator’s generation and interruption checks.
  • StoreWritePermit.unsequenced exists for remaining unsequenced writers and does not serialize them. It is migration debt, not a shortcut for new code.

These rules prevent automatic repair from undoing a person’s newer edit or bypassing their choice of Manual arrangement. SwiftLint’s store_write_needs_permit rule checks direct store access outside the allowed boundary.

Capture: MenuBarCaptureService

An XPC helper (com.stonerl.Thaw.MenuBarCaptureService) produces the images Thaw draws for menu bar items. It hosts the ScreenCaptureKit capture core from ThawCapture, so a leak in SkyLight, which loses a dictionary on every call, grows in the helper instead of the app. The app sends a typed CaptureServiceRequest (window IDs, a display’s menu bar hosting window or strip, or an owner’s bar window) and gets back a CaptureServiceReply with one frame or a failure. The helper exits after 1,800 successful captures or when the last client session closes, and a watchdog exits it when one capture outlives its budget; XPC relaunches it on the next call. The dictionary leak is separate from the Core Animation fence-port leak tracked as issue #933.

Backdrop composites also run in this helper, even when the legacy CaptureViaXPCService flag is off. They borrow a one-shot capture ticket so closing the panels does not stop the menu-bar backdrop. The helper rechecks window levels and bounds: ordinary windows are admitted only within a display’s menu-bar strip, while larger captures admit only desktop-level windows. Failed backdrop requests return no image, never an in-process SkyLight fallback.

External interfaces

InterfaceDirectionNotes
thaw:// URL schemeInboundAutomation and deep links. Only allowlisted settings can be changed, and Thaw checks the sending app’s signature. See URI schemes
Sparkle appcast HTTPSOutboundUpdate metadata and downloads over TLS, controlled by update consent and settings
What’s New HTTPSOutboundRelease notes from raw.githubusercontent.com, controlled by the separate notes setting. See Network access
Accessibility and Screen RecordingSystemAccessibility is required to move items; Screen Recording is optional and used for captures
Menu Bar Layout AccessSystemThe one file where macOS 27 keeps the menu bar’s order, picked by the user
CrowdinOutside the appTranslations, never at runtime
GitHub Releases and HomebrewDistributionInstall and upgrade channels

Data and persistence

  • Settings use UserDefaults; profiles also use Thaw’s Application Support folder. Both stay on the Mac. Defaults.Key raw values and encoded profile fields are compatibility contracts, not names to change during cleanup.
  • The system position table and Control Center’s app visibility preferences are separate from Thaw’s own settings. Access to one file does not grant access to the other.
  • Diagnostic logs are local files. Release builds follow the saved logging setting; Debug builds enable logging during bootstrap. Thaw never uploads them.
  • Thaw has no server of its own and no user accounts.

Build and release

  • Use Xcode to edit the project, and scripts/devrun.sh to build, install and launch Thaw Debug from /Applications. The script also stops an existing Thaw Debug. Ask before running it: separate app settings do not isolate the live menu bar. See Development.
  • CI: .github/workflows/ci.yml runs SwiftLint, the tests and SonarCloud. Actions shared across the organization live in thaw-app/org-ci.
  • Releases are signed with a Developer ID, notarized, packaged as ZIP and DMG, and added to the Sparkle appcast. See VERIFYING_RELEASES.md and RELEASES.md.
  • The source of record is thaw-app/Thaw.

Thaw also ships from these repositories, which matters when reviewing the supply chain:

RepositoryRole
thaw-app/ThawApplication source, issues, DMG releases, CI
thaw-app/updatesThe Sparkle appcast, update archives and deltas
thaw-app/brand-assetsShared brand artwork and README badges
thaw-app/org-ciReusable GitHub Actions, such as the Sparkle release
thaw-app/raycast-extensionOfficial Raycast extension

On this page