How muxy-app/muxy works
Muxy is a multi-target Swift repository centered on a macOS SwiftUI app, with a companion iOS client, a remote server layer, a shared protocol/DTO package, and a small C wrapper around Ghostty’s terminal engine.
1. Top-level product boundaries
- Muxy: the main macOS app.
- MuxyMobile: iOS companion app for remote connection.
- MuxyServer: remote server implementation that exposes workspace/VCS data and actions to the mobile client.
- MuxyShared: transport types and protocol messages shared by desktop and mobile.
- GhosttyKit: C module map + wrapper used to bridge Swift to libghostty.
2. Desktop app shell
- The macOS app is a SwiftUI application rooted at MuxyApp.swift, with the primary UI assembled in Views/MainWindow.swift, Sidebar, Workspace, Terminal, VCS, Editor, Settings, and NotificationPanel.
- The app is strongly state-driven: views consume model objects and services rather than talking directly to the filesystem, Git, or Ghostty.
3. Workspace as the core domain
- The central UX concept is a project-based workspace that persists tabs, splits, focus, and pane layout per project.
- Core state types include AppState, WorkspaceSnapshot, Project, Worktree, TerminalTab, VCSTabState, EditorTabState, DiffViewerTabState, SplitNode, TabArea, and ViewportState.
- Reducer-style logic under Models/WorkspaceReducer governs workspace mutation, focus changes, tab/split operations, and project lifecycle events.
4. Terminal subsystem
- Terminal rendering and interaction are backed by Ghostty/libghostty via GhosttyKit, with GhosttyService and GhosttyRuntimeEventAdapter translating engine events into app state.
- The UI layer for this is in Views/Terminal and Models/TerminalPaneState, TerminalSearchState, TextBackingStore, and TerminalViewRegistry.
- This subsystem is responsible for shell sessions, search within terminal output, and pane ownership/attachment inside the workspace layout.
5. Git/VCS subsystem
- Git functionality is isolated under Services/Git and includes process execution, status parsing, diff parsing, commit log parsing, PR parsing, metadata caching, and repository/worktree management.
- The UI for this lives in Views/VCS, including commit history, diff viewer, split/unified diff rendering, branch creation, and PR creation.
- The architecture keeps Git as a service boundary: Git commands are run and parsed into models, then surfaced through tab state and view-specific DTOs.
6. File tree, editor, and project management
- File navigation and editing are separate from terminal and Git: FileTreeService, FileSystemOperations, FileSearchService, and ProjectOpenService feed the sidebar, file tree, and editor views.
- The editor is a native SwiftUI/AppKit bridge (CodeEditorRepresentable, EditorPane) paired with EditorSettings.
- Projects and worktrees are persisted and presented through ProjectStore, WorktreeStore, ProjectPersistence, WorktreePersistence, and related models, making project selection a first-class architectural layer.
7. Persistence and local stores
- The app uses lightweight persistence services rather than a single database: CodableFileStore, JSONFilePersistence, WorkspacePersistence, KeyBindingPersistence, NotificationStore, PaneOwnershipStore, ProjectLogoStorage, and ApprovedDevicesStore.
- These stores back user preferences, workspace layout, key bindings, notification history, and remote-device trust decisions.
- The result is a set of small, bounded local state stores aligned with the app’s domain objects.
8. Input, commands, and keyboard customization
- Shortcut handling is a dedicated subsystem: KeyBinding, KeyCombo, ShortcutContext, ShortcutActionDispatcher, and the Commands package define command routing and conflict-aware key mapping.
- Views under Settings/KeyboardShortcutsSettingsView and supporting components provide user-facing configuration.
- Modifier-key monitoring and view helpers indicate the app maps global and context-sensitive shortcuts into workspace actions rather than relying on standard menu-only flows.
9. Themes, appearance, and app chrome
- Theme selection is centralized in ThemeService, with bundled Ghostty theme assets and a ThemePicker.
- UI appearance settings are separated into settings views and shared theme/model types.
- The architecture treats theming as a cross-cutting concern that affects terminal rendering and general UI presentation.
10. Notifications and automation hooks
- Notifications are modeled explicitly (MuxyNotification, NotificationSettings, NotificationNavigator) and can be delivered through NotificationSocketServer.
- MuxyNotificationHooks and bundled scripts under Resources/scripts support automation/integration with external AI/tooling workflows.
- This sits adjacent to the core workspace model so notifications can reference project/worktree context.
11. Remote access architecture
- The mobile story is not just a second UI; it is a remote control/client-server subsystem.
- MuxyServer exposes workspace, VCS, and notification state over a custom protocol implemented in MuxyShared (MuxyMessage, MuxyProtocol, DTOs for projects, workspaces, VCS status, worktrees, notifications).
- MuxyMobile includes connection management, device credentials, workspace/project pickers, and screens for remote terminal/VCS/worktree interaction.
- PairingRequestCoordinator, RemoteServerDelegate, MobileServerService, and NotificationSocketServer suggest a trust/pairing model for device access.
12. External integrations and operational tooling
- UpdateService indicates Sparkle-based auto-update support.
- AIProviderIntegration, Providers/ClaudeCodeProvider.swift, Providers/OpenCodeProvider.swift, and the repo scripts point to optional AI-tool integration, but these are secondary to the core terminal/workspace architecture.
- CI/CD and release workflows exist under .github/workflows, reflecting separate release paths for desktop and iOS targets.
13. How data flows through the app
- User input enters through SwiftUI views and shortcut dispatch.
- Commands mutate workspace reducers and local stores.
- Services perform side effects: shell/Ghostty sessions, Git commands, filesystem queries, persistence writes, or remote protocol I/O.
- Parsed results are converted into shared models/state and rendered back through tabbed workspace views, terminal panes, editor panes, and VCS screens.
14. Key architectural takeaway
- Muxy is organized around a stateful workspace core with clearly separated service boundaries for terminal, Git, filesystem, persistence, and remote connectivity.
- The macOS app is the source of truth; the iOS app is a controlled client over a shared protocol; and most subsystems are modeled as independently testable services feeding a reducer-driven UI.
Main entry points: Workspace.swift Workspace UI · WorkspaceReducer.swift Workspace Reducer · TerminalPane.swift Terminal UI · AppState.swift App State
Components 22
Muxy Desktop
macOS SwiftUI app with workspace, terminal, Git, editor, and local persistence.
- App Shell · Entry point and top-level app wiring for the macOS client.
Muxy/MuxyApp.swift - Main Window · Primary desktop window that assembles the workspace chrome and panes.
Muxy/Views/MainWindow.swift - Workspace UI · Workspace shell, split containers, tab areas, and drag/drop handling.
Muxy/Views/Workspace/Workspace.swift - Workspace Reducer · Reducer-style mutation logic for workspace, focus, tabs, splits, and project lifecycle.
Muxy/Models/WorkspaceReducer.swift - App State · Core application and workspace state container used across the desktop app.
Muxy/Models/AppState.swift - Terminal UI · Terminal pane views and registry for rendering shell sessions inside the workspace.
Muxy/Views/Terminal/TerminalPane.swift - Ghostty Service · Coordinates Ghostty runtime events and terminal session attachment in app state.
Muxy/Services/GhosttyService.swift - Git Service · Git process execution, parsing, repository state, diff loading, and worktree management.
Muxy/Services/Git/GitRepositoryService.swift - VCS Views · Commit history, diff viewer, branch creation, and pull request UI.
Muxy/Views/VCS/VCSTabView.swift - File Tree · File navigation, search, clipboard, and project-opening services feeding the sidebar and editor.
Muxy/Services/FileTreeService.swift - Editor · Native editor bridge and editor pane used for file editing inside the app.
Muxy/Views/Editor/EditorPane.swift - Project Store · Project and worktree persistence, selection, and setup support for the workspace model.
Muxy/Services/ProjectStore.swift - Local Stores · Small file-backed stores for workspace layout, key bindings, notifications, device trust, and related state.
Muxy/Services/WorkspacePersistence.swift - Shortcuts · Key binding models, shortcut context, and command dispatch into workspace actions.
Muxy/Services/ShortcutActionDispatcher.swift - Theme Service · Theme selection and app-wide appearance coordination, including terminal styling.
Muxy/Services/ThemeService.swift - Notifications · Notification models, navigator, hooks, and socket server for workspace-adjacent alerts and automation.
Muxy/Services/NotificationStore.swift
Remote Access
iOS client and server pair for workspace and VCS access over a custom protocol.
- Server · Remote server process that exposes workspace and VCS state to mobile clients.
MuxyServer/MuxyRemoteServer.swift - Client Conn · Per-client connection handling and routing for the remote server.
MuxyServer/ClientConnection.swift - Mobile App · Companion iOS app for remote workspace, terminal, VCS, and project control.
MuxyMobile/MuxyMobileApp.swift - Connection Manager · Handles pairing, device credentials, and remote workspace/VCS communication from iOS.
MuxyMobile/ConnectionManager.swift
Shared Protocol
DTOs and message types shared between desktop, server, and mobile targets.
- Shared Types · Messages, protocol params, and DTOs shared across desktop, server, and mobile targets.
MuxyShared/MuxyProtocol.swift
Terminal Bridge
C wrapper around Ghostty’s engine used by the desktop terminal subsystem.
- GhosttyKit · Module map and C wrapper that expose libghostty to Swift.
GhosttyKit/GhosttyKit.c
Connections 23
- App Shell → Main Window: builds · The app entry point constructs the main desktop window.
- Main Window → Workspace UI: hosts · Main window embeds the workspace shell and its panes.
- Workspace UI → Workspace Reducer: reads state · Workspace views render and react to reducer-managed state.
- Workspace Reducer → App State: mutates · Reducer logic updates the core app/workspace state.
- Workspace UI → Terminal UI: shows · Workspace layout contains terminal panes and tab areas.
- Terminal UI → Ghostty Service: drives · Terminal views delegate engine/session work to the terminal service.
- Ghostty Service → GhosttyKit: bridges · Service talks to the Ghostty C wrapper and runtime events.
- Workspace UI → VCS Views: shows · Workspace hosts VCS tabs and diff views.
- VCS Views → Git Service: queries · VCS views consume Git-derived models and diff data.
- Workspace UI → Editor: shows · Workspace includes editor panes for file editing.
- Editor → File Tree: opens files · Editor and sidebar source file navigation from the file tree service.
- File Tree → Project Store: uses · File and project operations are scoped by project/worktree state.
- Project Store → Local Stores: persists · Project and worktree state is stored through local file-backed persistence.
- Workspace Reducer → Shortcuts: invoked by · Shortcut actions dispatch into workspace mutations and navigation.
- Shortcuts → App State: dispatches · Key bindings and commands map to app/workspace actions.
- Theme Service → Terminal UI: styles · Theme selection affects terminal rendering and app appearance.
- Notifications → Local Stores: stores · Notification history and trust decisions are persisted locally.
- Server → Client Conn: accepts · The remote server manages client connections and request routing.
- Mobile App → Connection Manager: uses · The iOS app communicates through its connection manager.
- Connection Manager → Shared Types: encodes · Mobile client sends and receives shared protocol messages.
- Client Conn → Shared Types: decodes · Server connections interpret the shared protocol and DTOs.
- Server → App State: reflects · Remote server exposes workspace/VCS state derived from the desktop domain model.
- Notifications → Shared Types: shares · Notifications also flow through shared DTOs for remote transport.