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, macOSThe 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
@Observablemanagers. There is no required view-model layer. AppStatecreates the long-lived managers (MenuBarManager,MenuBarItemManager,ProfileManager,HIDEventManagerand 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,ThawLayoutand app-local rule types, so they can be tested without a live menu bar. - Protocols such as
MenuBarBackendlive inMenuBarModel.Thaw/MenuBar/Backendsselects 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
| Path | What it holds | Package dependencies |
|---|---|---|
Thaw/ | The app: menu bar logic, settings, panels, input, permissions | Local libraries and external runtime/UI packages |
packages/MenuBarModel/ | Menu bar items, sections, identity, move planning and the backend protocols | Nothing |
packages/ThawLayout/ | The layout solver: saved section order, where new items go | MenuBarModel |
packages/ThawCapture/ | Item image capture with ScreenCaptureKit, and the client for the capture service | MenuBarModel, ThawConcurrency |
packages/ThawConcurrency/ | Timeouts and one-shot continuations | Nothing |
packages/ThawAX/ | Accessibility reading: ThawAXCore, ThawAXClient and the ThawAXHelper process | No 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 capture | ThawCapture |
ThawTests/ | App-level Swift Testing tests; packages also have their own test targets | App 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/
| Folder | What 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
| Concern | Entry points |
|---|---|
| Startup and subsystem lifetime | AppDelegate, AppState |
| Item inventory and cache | Items/Manager, Items/Model |
| Saved order and move planning | ThawLayout, LayoutMoveSequencePlanner |
| Layout writes and automatic repair | RepairOrchestrator, MenuBarPositionStoreProvider |
| Hide, reveal and section policy | MenuBarManager, RuntimeSectionContextAdapter |
| Item images | Items/Capture, ThawCapture, MenuBarCaptureService |
| Display and Space changes | Environment |
| Settings and profiles | Settings/Models, Defaults |
| Automation and sender authorization | SettingsURIParser, 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.
| Component | Connection to the app | Responsibility |
|---|---|---|
ThawAXHelper | Standard input/output pipes through ThawAXClient | Accessibility observations |
MenuBarCaptureService | XPC | Image capture in a recyclable process |
ThawExtraHelper | Launched as separate stand-in apps | Apple-item replacements with separate owning bundles |
| Settings child process | Standard input/output pipes | On by default (SettingsInOwnProcess); exits when its last window closes |
ThawControls | Darwin notifications for commands, App Group snapshot for state | Control Center controls |
ThawCtl | thaw:// URLs | Command-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
.settingsChangedso 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
AppStatecreates 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:
SettingsLinkEndpointignores changes made during that reload. A page that writes defaults later, from its own task or queue, sends a.settingsChangedthe 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:
ThawAXHelperreads 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.swiftinThawAXCore). - 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.
RepairOrchestratorschedules repair and layout work throughRepairLane. Item moves can obtain a permit while holding the move semaphore.- Manual arrangement selects
ReadOnlyPositionStore. Explicit Layout edits use the scopedforLayoutEditpath; 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.unsequencedexists 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
| Interface | Direction | Notes |
|---|---|---|
thaw:// URL scheme | Inbound | Automation and deep links. Only allowlisted settings can be changed, and Thaw checks the sending app’s signature. See URI schemes |
| Sparkle appcast HTTPS | Outbound | Update metadata and downloads over TLS, controlled by update consent and settings |
| What’s New HTTPS | Outbound | Release notes from raw.githubusercontent.com, controlled by the separate notes setting. See Network access |
| Accessibility and Screen Recording | System | Accessibility is required to move items; Screen Recording is optional and used for captures |
| Menu Bar Layout Access | System | The one file where macOS 27 keeps the menu bar’s order, picked by the user |
| Crowdin | Outside the app | Translations, never at runtime |
| GitHub Releases and Homebrew | Distribution | Install and upgrade channels |
Data and persistence
- Settings use
UserDefaults; profiles also use Thaw’s Application Support folder. Both stay on the Mac.Defaults.Keyraw 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.shto 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.ymlruns SwiftLint, the tests and SonarCloud. Actions shared across the organization live inthaw-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.
Related organization repositories
Thaw also ships from these repositories, which matters when reviewing the supply chain:
| Repository | Role |
|---|---|
| thaw-app/Thaw | Application source, issues, DMG releases, CI |
| thaw-app/updates | The Sparkle appcast, update archives and deltas |
| thaw-app/brand-assets | Shared brand artwork and README badges |
| thaw-app/org-ci | Reusable GitHub Actions, such as the Sparkle release |
| thaw-app/raycast-extension | Official Raycast extension |
Related documents
- Agent workflow: approvals, checks and reporting
- Coding standards: implementation, tests and writing
- Development: build and test commands
- Assurance case: the threat model and the security argument
- URI schemes: every
thaw://link - Security Policy, shared with Floe: reporting, support and dependency rules
- Governance: project roles and the organization’s repositories
Coding standards
How code in Thaw 3 is written. The contribution guidelines cover issues, pull requests and sign-off, and Development has the build and test commands.
Make your app work with Thaw
For developers of apps with menu bar items. How Thaw tells your items apart on macOS 27, how to keep them where people put them, and how to let each one be hidden on its own.