Window & Tray Management
Relevant source files
The following files were used as context for generating this wiki page:
Augenblick utilizes the Tauri framework to manage its desktop interface, specifically focusing on a custom-styled window and a persistent system tray icon. The system is designed to provide a "hidden" application experience where the main window can be dismissed to the tray and quickly recalled. This lifecycle involves coordinating window visibility, macOS-specific activation policies, and state persistence to ensure the application feels integrated with the host operating system.
The window management logic handles custom decorations, such as the titlebar overlay and drag regions, while the tray management provides quick access to note creation and recent documents even when the main interface is closed.
Sources: src-tauri/src/lib.rs, plans/migration.md:120-130
Window Configuration & Lifecycle
The main application window is configured with specific visual constraints to support a minimalist aesthetic. It uses a hidden title bar with an overlay style, allowing the frontend to define its own titlebar and drag regions.
Window Properties
| Property | Value | Description |
|---|---|---|
| Title | "Augenblick" | The default window title. |
| Default Size | 800 x 600 | Initial window dimensions. |
| Drag & Drop | Disabled | Native file drag-and-drop onto the window is disabled. |
| Hidden Title | Enabled | Hides the native OS title text. |
| Titlebar Style | Overlay | Overlays the titlebar controls on top of the content. |
Sources: src-tauri/tauri.conf.json:20-28, plans/migration.inventory.md:188-193
Lifecycle & Activation Policy
On macOS, the application starts with an Accessory activation policy, meaning it does not show in the Dock by default. When the window is shown, the policy is updated to Regular so the user can interact with it via the Dock and Task Switcher. When hidden, it reverts to Accessory.
The application handles the onCloseRequested event by preventing default closure and instead hiding the window, unless the user explicitly chooses to quit from the menu or tray.
Sources: src-tauri/src/lib.rs:26-30, src/App.tsx:280-300, plans/migration.inventory.md:209-214
Tray Management
The system tray (or menu bar on macOS) serves as the persistent anchor for the application. It provides a dynamic menu that reflects the user's current notes and provides global actions.
Tray Menu Structure
The tray menu is reconstructed dynamically when the user hovers over the icon to ensure the list of notes is current.
- Standard Actions: "New note", "Show all notes", and "Quit".
- Pinned Notes: A dedicated section for notes marked as pinned in the database.
- Recent Notes: A list of the 5 most recently interacted-with unpinned notes.
Sources: src-tauri/src/lib.rs:207-251, plans/migration.inventory.md:167-175
Event Handling
Tray interactions emit specific events to the frontend, which then executes the corresponding business logic.
| Tray Event | Payload | Frontend Action |
|---|---|---|
tray-new-note | None | Creates a new draft and shows the window. |
tray-show-all | None | Switches view to "notes" and shows the window. |
tray-select-note | note_id | Loads the specific note and focuses the window. |
tray-quit | None | Prompts for unsaved changes before exiting. |
Sources: src-tauri/src/lib.rs:134-160, src/App.tsx:320-350
Visual Chrome & Drag Regions
Because the native titlebar is hidden, the application implements a custom drag region to allow users to move the window.
CSS Implementation
A fixed overlay is placed at the top of the application shell. It is inset to avoid overlapping macOS window controls (traffic lights).
.tauri-titlebar-drag-region {
position: fixed;
left: 80px;
right: 0;
top: 0;
height: 52px;
z-index: 70;
}
Sources: plans/migration.inventory.md:195-200, plans/migration.md:65-70
Interaction Logic
The drag region handles mouse events to interface with the Tauri runtime:
- Left Click + Drag: Calls
startDragging()to move the window. - Double Click: Calls
toggleMaximize()to expand or restore the window size.
Sources: plans/migration.inventory.md:201-205, src/App.tsx:440-445
State Persistence (Window State)
The application utilizes a window-state plugin to remember the window's position and size between sessions.
- Restore & Clamp: Upon launch, the app restores the previous state. A custom "clamp" algorithm ensures the window remains within the bounds of currently connected monitors to prevent it from being lost if the display configuration changed.
- Sanitization: The state is sanitized before saving to ensure only valid coordinates and sizes are persisted.
Sources: src-tauri/src/lib.rs:34-35, plans/migration.inventory.md:223-230
Summary
Window and Tray management in Augenblick is centered on a "hidden-by-default" workflow. The backend handles the native system integrations—tray menu construction, macOS activation policies, and window state restoration—while the frontend manages the user-facing chrome, including custom drag regions and closing prompts. This coordination ensures that even when the window is hidden, the application remains accessible and responsive to system-level events.