# Architecture Decision Record

Short entries. Status is one of Accepted, Superseded or Deferred.

## D-01 Rust workspace with an engine crate that knows nothing about UI or projects — Accepted

The engine is driven only by `EngineCommand`s and reports only `EngineEvent`s plus lock-free status atomics. This keeps it testable offline and lets the CLI harness and the app share it.

## D-02 Mixing in our own callback; DirectSound-style per-cart OS buffers are rejected — Accepted

One cpal output stream. All voices mix into it: gain/pan ramps, sample-accurate fades and loops, and a safety limiter. Wait-free command and event transfer uses `rtrb` SPSC rings. Retired `Arc` sample buffers are returned on a third ring and dropped off the audio thread.

## D-03 UI framework: egui/eframe — Superseded (D-39, D-44)

egui was chosen for v1 because:

- An immediate-mode grid with 60 Hz live state is simple and fast to build.
- It is a single code base on macOS, Windows and Linux.
- It has no JS toolchain (Tauri) and no licence decision (Slint).

Accepted cost: weaker accessibility and less native look. The UI is a separate crate, so it can be replaced.

## D-04 v1 asset residency: fully decoded and resampled to the engine rate at load — Accepted (v1), revised by D-37

This is the simplest model that guarantees no I/O or decoding at trigger time. Streaming from disk is deferred until real projects show memory pressure. 48 kHz stereo f32 is about 23 MB per minute. Since D-37 this holds for short files and compressed formats; long WAV/AIFF files are streamed.

## D-05 Retrigger, exclusive groups, stop-others-on-play are executed inside the engine — Accepted

The engine resolves them atomically at the start of a block when it receives `Play`, so there are no races between "is it playing?" queries and commands. The policy enum: `restart`, `overlap`, `toggle_stop`, `ignore`.

## D-06 Control layer shared behind a `Mutex` (non-RT) — Accepted (v1)

The UI thread and the MIDI callback thread both call into `bubble-control` under one mutex. The audio thread never takes it. Lock hold times are kept short: the UI copies a view snapshot instead of rendering under the lock. Revisit if measurements show MIDI latency affected by UI work.

## D-07 Engine sample rate = device rate; assets re-prepared on change — Accepted

Assets are resampled at load to the running stream's rate. On device or rate change the app rebuilds the engine and re-arms carts. Carts show "Loading" until ready.

## D-08 Project format v1 — Accepted

Implemented now: project, settings, outputs (single `main`), assets with fingerprint and absolute hint, pages with cells, carts (label, colour, asset, gain, mute, loop, retrigger, fades, exclusive group, stop-others), bindings (key, MIDI note/CC). Unknown fields are preserved via `#[serde(flatten)]` maps. play_next and hold_to_play are implemented. Trims are edited in the Audio Setup window. Still deferred: play_delay and fade_out_at_end (stored, not acted on).

## D-09 Native menus with muda; in-window menu only on Linux — Accepted (user request, 2026-10-18)

egui cannot draw OS menus. `muda` (from the Tauri project) gives the macOS system menu bar and the Windows window menu. On Linux it requires a GTK window, so the same menu model is drawn with egui there. The UI builds one `Menu` model per frame, and the native menu is rebuilt only when that model changes (hash). Settings that were floating windows (audio device, buffer size, MIDI ports, behaviour options) are now native submenus and check items. Master gain and default fade-out live in the side panel.

## D-10 File dialogs are asynchronous — Accepted (bug fix)

Synchronous `rfd` dialogs ran a nested modal loop inside the egui/winit callback. On macOS this re-entered winit and aborted the app (`panic_cannot_unwind` in `ApplicationDelegate::maybe_queue_event`, two crash reports on 2026-10-18). Dialogs are now created on the UI thread (shown as sheets), awaited on a helper thread, and their results applied as intents on a later frame.

## D-11 Unsaved work survives every exit path — Accepted (bug fix)

A system quit (Dock, AppleScript, logout) skips `close_requested`, so the unsaved-changes dialog never shows. `App::on_exit` writes `<project>.bubble.autosave`, or `Recovered/Untitled-<session>.bubble` for untitled projects. It never overwrites the project itself. On start-up a newer autosave is offered for Restore or Discard. Saving and an explicit "Quit without saving" remove the autosave.

## D-12 Projects are opened off the UI thread — Accepted (bug fix)

Reading a file in a privacy-protected macOS folder can block until the user answers a system prompt. Opening on the UI thread left the app without a window. Project loads now run on a helper thread, with "opening…" in the status bar.

## D-13 Undo = project snapshots — Accepted

The controller pushes a clone of the project before each change (depth 100). Edits with the same key within 1 s coalesce, so a slider drag is one step. Restoring a snapshot re-arms only assets the cache does not have. Projects are small (KB–MB), so snapshots are cheap and much simpler than inverse commands.

## D-14 blake3 in pure-Rust mode — Accepted

The default `blake3` build compiles C/assembly and needed MSVC's `lib.exe` even to type-check for Windows. The `pure` feature removes every native toolchain requirement. Fingerprints hash at most 2 MiB per file, so the speed difference is irrelevant.

## D-15 Legacy `.dta` import is a separate one-shot crate — Accepted

`dta-import` (library + `dta-import` CLI) reads reference sessions (format 99) read-only and writes a normal `*.bubble` project plus a migration report (`<name>.import-report.json` and `.md`). The app never loads `.dta` directly. It rejects any file whose cart records or option blocks do not end where the framing says. Notes:

- The reference "gain offset −10 dB" becomes the project's **master gain** (−10 dB), and cart gains stay as stored. Folding the offset into every cart would give the same output, but cart values would differ from what the operator set, and it would double-attenuate with a −10 dB master default.
- Missing assets keep the drive-mapped path (or the bare file name) as `path`, and the original Windows path as `absolute_hint` with `platform: "windows"`.
- Reference fade law 1 ("logarithmic") maps to `exponential`, and 0 maps to `linear`.
- Hot-keys map to the app's egui key names. Numpad keys become digit keys because egui does not tell them apart.
- Hot-key, MIDI, group, stop-on-play, play-next, mute and pan values are imported, but flagged in the report as unconfirmed until a known-value save confirms their encoding.

## D-16 Variable-speed playback in the mixer — Accepted

Each voice has a fractional read position and a ramped rate (0–4×). It reads with linear interpolation once the rate is not exactly 1. At 1× the integer path is unchanged and bit-exact. Speed changes ramp, so the speed bar can slow a cart to a standstill and spin it back up like a record player. The floating bar copies the reference's layout (manual p. 238–239): `x1` | ◀ slider ▶ | `x0`, up to four bars, actual speed in the title, and an `@` time prefix on the tile. Right-clicking `x0` or `x1` sets the cart's slow-down or speed-up time (`slowdown_ms`, `speedup_ms`; both default to 2 s, and speed-up may be 0 = instant). When `x0` reaches 0 % the cart ends (the controller sees its voices at speed 0 and kills them, which is silent at that point). The next click, touch, hotkey or MIDI play therefore starts from the In point at the preset speed. A press while the cart is still slowing snaps it back to real time (10 ms ramp) and carries on, as the reference's `x1`/scrollbar cancel a slow-down. Right-clicking `x0` or `x1` swaps the bar's contents for a row of times, because a popup menu would be clipped by the small window. The slider is logarithmic over 25–400 %, so 100 % sits in the middle, matching the reference's thumb position at x1. A voice at speed 0 keeps its slot and position. Live speed bar moves are not saved, but the cart's preset speed (25–400 %) is. Pitch changes with speed. Time-stretching would need a different algorithm and was not requested.

## D-17 Per-cart meters come from the audio thread's block peaks — Accepted

The mixer keeps each voice's absolute sample peak (after gain and pan, before master and limiter) in atomics, and the UI swaps them to zero once per frame. The Audio Setup meter applies PPM ballistics in the UI: instant rise and a 20 dB / 1.7 s fall (IEC 60268-10 Type I style), with a 1.5 s peak hold. The colours are as requested: green below −18 dBFS, orange from −18 to −10, red above −10. The audio thread does no allocation or locking for this.

## D-18 Secondary windows are native OS windows — Accepted (UX fix)

Audio Setup, Project Settings, Page Settings, Speed Bar, Log, Diagnostics and Missing Files are egui immediate viewports, so they are real windows with platform title bars. On macOS the close button is on the left, and Cmd+W closes them. Confirmations and errors are modal sheets inside the main window, and the main window is brought to the front when the quit prompt appears. The cart side panel was removed: everything it held is in the Cart Setup window (waveform, meter, sound, cart, triggers), with right-click quick edit for the common settings. Keys pressed while a secondary window has focus still reach cart triggers. Hold-to-play carts are released when no Bubble window has focus, because key-up events cannot be seen then.

## D-19 Learned triggers toggle by default — Accepted (bug fix)

A learned key previously used Play, which restarts a cart. Pressing the hotkey of a looping cart again therefore restarted it, and it never stopped. New triggers now take the action of a mouse click (Toggle in the default mouse mode). Each trigger's action can be changed in the side panel. OS key-repeat events are ignored.

## D-20 Tile typography is a project setting — Accepted

The label typeface, label size, small-text size and alignment are stored in `settings.display`, so a project looks the same on any machine that has the font. Fonts are loaded from known system font files, only listed when present, and the built-in font is the fallback. New projects get 8 unnamed exclusive groups (G1–G8) and a −10 dB master level.

## D-21 System fonts and MM:SS clocks — Accepted (UX)

The interface uses the platform's own font (San Francisco and SF Mono on macOS, Segoe UI and Consolas on Windows, Noto or DejaVu on Linux), loaded from the system font files, with egui's bundled fonts kept as fallbacks for symbols. Tile times read MM:SS (H:MM:SS from an hour). Durations and countdowns round up, so a 0.9 s cart shows 00:01 and a countdown reaches 00:00 as the cart ends. Editing windows show tenths (MM:SS.s).

## D-22 Output level saved in projects — Accepted

The output level stays a project setting, as the reference's gain offset is part of the session. Projects saved before the −10 dB default stored 0 dB explicitly, so they keep 0 dB until it is changed in Audio → Output Level, which shows the current value in its title.

## D-23 Reference packages (`.pkg`) import through `dta-import` — Accepted

A package is the session plus the audio it uses (layout verified against a real 18-button package; notes in the investigation folder, `08-package-format.md`). `dta-import` recognises a package by its contents, extracts each embedded file once into `Audio/` next to the new project (an identical existing file is reused; a different file with the same name gets a numbered name, so nothing is overwritten), and maps every cart to its extracted file by the exact original path before any searching. Cart records and session options use the `.dta` decoders. Button images and converter information in the package are not imported.

## D-24 Multiple outputs: machine-defined letters, one stream per device — Accepted

As in the reference, outputs are set up per machine (Settings → Outputs): tick channel ranges on any device (stereo pairs, single mono channels, or 5.1 groups of six), give them optional aliases and order them. The order gives the letters: Output A, Output B, … A cart stores only its letter, so a project plays on whatever "Output B" is on the machine it is opened on; a letter not set up there falls back to Output A. Every output is shared with other applications (WASAPI shared mode on Windows, CoreAudio and ALSA/PipeWire as normal), never exclusive.

The app opens one stream (and mixer) per distinct device, with as many channels as its outputs need, all at one sample rate: **48 kHz by default** (Settings → Sample Rate), 32-bit float when the device offers it (CoreAudio always does). The mixer works in 32-bit float throughout. Assets are resampled once to that rate, which is why every device must run at it; a device that cannot is reported and its outputs fall back to Output A. Each voice writes to its output's channel range: mono sums L+R at half level each; stereo is the normal L/R path; 5.1 routes a six-channel source channel for channel (other sources to its front L/R). Exclusive groups and stop-others act across devices: the controller sends the matching stop to every other device's mixer. The safety limiter is per device, so outputs that share a device share its limiter.

The project-level `outputs` bus list from an earlier draft was removed; cart `output` is now a letter A–Z. The legacy importer maps a reference cart's output device index to the same letter (flagged unconfirmed) and imports speed (25–400 %) instead of dropping it.

## D-25 Vector-first graphics; one logo source — Accepted (UX)

The logo is a single SVG (`assets/logo.svg`): a play button inside a bubble, with two trailing bubbles. Everything else comes from it: the app draws the mark with vector shapes (`logo.rs`, used on the empty-project welcome card), the window/Dock icon is rendered from the SVG at build time (`build.rs`, pure-Rust `resvg`), and the macOS `.icns` is rendered by `bubble-icon` and packed with `iconutil` in the bundle script. No bitmaps are committed. The interface itself is drawn by egui as vector shapes and text in the system font, so it scales to any display and to View → Interface Size.

## D-26 Sessions are self-contained folders — Accepted (replaces "start untitled")

Like a DAW project: File → New Session asks for a name and location and creates `Name/Name.bubble` with `Name/Audio/`. Every audio file that enters a session (drop, assign, relink, SpotOn import) is copied into `Audio/` on a background thread before it is assigned; an identical file already there is reused, a different one with the same name is numbered, nothing is overwritten, and copies are written to a temporary name first. Opening a session whose audio lives elsewhere collects it into `Audio/` too. Save As creates a new folder with copies. This makes a `.pkg`-style archive unnecessary for day-to-day work: the folder is the package (zip it to hand it over). File → Open accepts `.bubble`, `.dta` and `.pkg`; the SpotOn formats are imported into a new session folder. The window title shows "Bubble - Name > Last saved at 09:00" (or "Unsaved changes …"), replacing the info row under the title.

## D-27 Drops land under the pointer — Accepted (bug fix)

winit 0.30 reports dragged files without a position and macOS sends no mouse moves during a drag, so drops always went to cell 1. The app now reads the system cursor (`mouse_position`) while files hover and on drop, maps it into the window, highlights the target cell, and assigns from there. Verified with a Finder drag onto cell 5.

## D-28 Control buttons — Accepted

A cart can be a control button (`control: stop_group | stop_page | stop_all`): no audio, but label, colour, group and triggers work as for any cart, so a group can be stopped from a tile, key or MIDI note without the reference's silent-file workaround. Stop Group fades every cart in the button's group on every output device. Suggested next: a Fade Group with its own fade time, and Next/Previous Page buttons.

## D-29 Cart Setup edits are a draft — Accepted (UX)

Cart Setup works on a copy: preview (Space or ▶) plays the copy on the cart's own voice, OK keeps it, Cancel discards it, and closing the window with changes asks first. Trim edits can no longer be lost or committed by accident.

## D-30 Operator feedback round (2026-10-20) — Accepted

Superseded in part by D-62: Escape no longer fades or stops anything.

- File drags use the system cursor throughout (egui's pointer is stale during an OS drag) and redraw continuously while files hover, so the highlight follows and the drop lands under the pointer.
- Tiles: steady yellow border while playing (no pulsing), purple while fading out, progress bar drawn last inside the border; the bottom text row no longer moves; "Out A" comes first, trim marks after it. Looping carts count down to the loop point.
- STOP ALL in the bottom bar stops immediately without fades (Esc still fades).
- Fade lengths are chosen in seconds from a list (zero, 0.1–0.9, 1–5 by 0.5) or typed; fade-out is in quick edit, both in Cart Setup.
- Cart Setup transport: drawn icons; play/pause (pause = speed 0, holding position); to-In and stop cut without fade-out; preview keeps the fade-in. Gain, mute and speed act live on the preview. The window comes to the front whenever it is opened.
- PPM scale: −60 at the bottom, −18 at half height, −10 at two thirds, 0 at the top; green to −18 inclusive, orange to −10, red above. Meter and waveform follow the light/dark theme.
- SpotOn imports can be appended to the open session. Reassign Cart Outputs replaces the reference's Output Assignment dialog.

## D-31 De-click starts; fading loops end — Accepted (audio)

A voice that starts on a non-silent sample (an In point set mid-waveform, a file that does not start at zero) gets a 1.5 ms linear ramp unless the cart already fades in longer; carts starting from silence play sample-exact. A looping cart that is fading out no longer wraps: it plays at most to its Out point and ends (reason "stopped", so play-next does not fire). (Changed by D-67: a stopped loop fades out fully, looping on across the join.) The de-click length is an engine setting (`EngineConfig::declick_ms`).

Also: PPM −10 dBFS moved to three quarters of the scale; gain sliders are −12 … +12 dB with 0 in the middle (values outside are kept, the knob pins at the end); dialogs share one button bar (separator, primary on the right) and small windows size themselves to their content.

## D-32 Robustness: lost devices, memory, crashes — Accepted (audio, app)

- A failed output stream no longer stops every output: streams on working devices keep running, the lost device's outputs move to the system default output (their carts show the output as an amber badge), and the device list is checked every 2 s. Once the device is back and nothing is playing, its outputs return to it.
- Prepared audio may use up to half the machine's RAM. A file that would not fit is refused with an error instead of exhausting memory (estimated before decoding; checked while decoding when the length is unknown).
- A panic writes a crash report (`Crashes/` in the app's data folder), autosaves unsaved work when the session is reachable, and the next launch says so. `BUBBLE_CRASH_TEST=1` triggers a test crash.

## D-33 Session setting "Audio files: Keep as imported / Convert to WAV" — Accepted (project)

Audio is always played from memory, decoded once when a session opens; playback costs the same either way. "Convert to WAV" moves that work to the moment a file is added: it is converted once to 32-bit float WAV at the engine's sample rate (default 48 kHz), saved next to the original in the session's Audio folder, and the asset points at the WAV, so opening the session later needs no decoding or resampling. Trims are stored in source frames, so they are rescaled for converted assets. Originals are kept, so undo stays consistent. Files already WAV at the engine rate are left alone. Turning the setting on, or opening a session that has it on, offers to convert files that are not converted yet; audio added while it is on is converted straight away.

## D-34 Cart Setup: play from here, loop-point audition, live loop and trims — Accepted (audio, app)

⌥/Alt-click or middle-click in the waveform plays from that point (the reference uses the middle button; trackpads have none), and dragging with either keeps moving it; plain clicks still set In (left) and Out (right). P plays from 3 s before Out, so with Loop on the Out→In join is heard at once. The engine moves a voice with a 2 ms crossfade to a copy of itself at the new position (`Seek`), keeping gain, speed (a paused voice stays paused), pan and looping. While previewing, Loop on/off and In/Out changes apply to the playing voice (`SetLoop`, `SetRegion`); a looping voice left past a new Out goes to In. Restarts and seeks are not logged as endings.

## D-35 Appearance and window place are per-machine preferences — Accepted (app)

View → Appearance offers Follow System (default), Light and Dark; it is a machine preference, not part of a session, so a session looks right on whichever machine opens it. The main window's position, size and maximised state are saved to preferences a second after they stop changing (and on exit) and restored at launch, in logical points so the interface zoom does not shrink or grow the window. A maximised window keeps the place it returns to when un-maximised. Empty cells are drawn a shade lighter in dark mode so they stay visible.

## D-36 Low-end and Windows performance — Accepted (app, audio)

Superseded in part by D-48: the renderer line below is from the egui app; D-48 sets the renderer now.

- Renderer: OpenGL (glow) on Windows and Linux, wgpu (Metal) on macOS; `BUBBLE_RENDERER=wgpu|glow` overrides. GPUs without DirectX 12 or Vulkan (e.g. Intel HD 3000) and virtual machines made wgpu draw on the CPU.
- Idle redraw every 5 s (was 250 ms); 30 fps only while something plays or a meter moves. On a machine drawing in software each frame costs real CPU.
- 16-bit audio at the engine rate is held as 16-bit (exact; detected from the decoded samples, so lossy and 24-bit stay float). A 32-file session went from 1.40 GB to 0.98 GB.
- The Windows audio thread is promoted to real-time ("Pro Audio" MMCSS, falling back to time-critical priority) via cpal's `realtime` feature; CoreAudio already runs the callback on a real-time thread.
- Windows uses the in-window menu bar (follows light/dark; Win32 menu bars do not), with its own keyboard shortcuts.
- Touch: in edit mode a tap selects and plays on release, press-and-hold opens quick edit.
- A session or SpotOn file passed at launch (dropped on Bubble.exe, Open With) opens. Error messages are selectable and can be copied.

## D-37 Long files stream from disk; a pre-roll head stays in memory — Accepted (audio)

Holding every file decoded cost about 1 GB for a 32-file session, too much for old 4 GB machines. Like SpotOn (one ~1.3 s buffer per cart, refilled from an open file while playing), Bubble now keeps only the start of long files in memory and streams the rest.

- **What streams.** WAV and AIFF files of 30 s or more (`PrepareOptions::stream_min_secs`). Shorter files (stings, effects) and compressed formats (MP3, AAC, FLAC, Ogg) are still decoded whole at load, as before: simplest and safest, and their seeks are not sample-exact. "Convert to WAV" (D-33) makes any file streamable.
- **Heads.** Each streamed asset keeps a 2 s pre-roll at the engine rate (`Head`, 16-bit when the source is 16-bit at the engine rate) from the file start and from every cart's In point, plus the In point being edited in Cart Setup. A trigger plays from the head at once, never waiting for the disk. After a trim edit the asset is prepared again in the background with the new heads (it stays playable meanwhile). `Playable` is the shared, immutable thing a voice plays: resident buffer or heads + file.
- **Reader.** One disk-reader thread (`Streamer`) serves every voice of every output. A trigger opens a `VoiceStream` on the control thread (allocating its `rtrb` ring, 4 s at the engine rate) and the reader starts filling at once from where the head ends — before the engine even sees the Play. The reader keeps its own decoder and streaming resampler per voice (rubato `Async` sinc, chunked), fills the emptiest ring first, and polls every 4 ms when idle. Several voices of one cart (Overlap, Restart's fade-out) each have their own stream.
- **Jumps.** A loop wrap, `SetRegion` or `Seek` sends the reader a request: an epoch-tagged position in an atomic. The reader seeks, then acknowledges with the number of samples it had written before switching, so the voice drops exactly the stale samples still in the ring. The In head covers each loop wrap while the reader repositions. A seek's copy voice plays from a head if the target is in one, and takes the stream over when the old position has faded (2 ms); a target outside every head waits a few ms for the disk (counted as `stream_wait_frames`, not an underrun).
- **Exact positions.** Resampled streams line up with a whole-file resample: decoding restarts at a source frame whose engine position is a whole number (a multiple of the rate ratio's denominator), 512 frames early so the filter settles. Heads are made by the same decoder, so head and stream join seamlessly; tests check streamed output against in-memory playback through loops, seeks, speed changes (0–400 %, pause) and resampling.
- **Underruns.** The audio thread never blocks, allocates or frees for streaming. A voice whose data is not there plays silence and holds its place (and its fade-in) until the data comes; a voice that is stopping still fades and ends. Underruns are counted in `Diagnostics` (`stream_underruns`, `stream_underrun_frames`) and shown in Audio Diagnostics. A file that turns out shorter than stated (replaced on disk) ends the voice as at its Out point.
- **Waveform.** Cart Setup's overview (and Top and tail's bounds at −20 dBFS) is read from the file once on a background thread when first needed and kept for the session; a flat placeholder shows meanwhile. Not cached on disk: one read per file per session is cheap (a 5-minute WAV in well under a second), and writing cache files beside a user's session would need managing.
- **Memory.** "Audio memory" now counts resident files plus heads. On a replica of the 31-file "pkg am" session (926 MB of WAV, same formats, lengths and trims), the app's `footprint` after loading fell from 748 MB (926 MB of audio held, release build of `main`) to 102 MB (22 MB of heads). Each playing streamed voice adds its ring: 1.5 MB for 4 s of 48 kHz stereo.

Not done: streaming for FLAC/MP3 (needs exact seeks verified per format); thread priority for the reader (normal priority keeps 4 s ahead easily).

## D-38 Licence: GPLv3 or later — Accepted (project)

Bubble is open source under the GNU General Public License, version 3 or (at your option) any later version (`LICENSE`, `license = "GPL-3.0-or-later"` in the workspace). This also lets Bubble use Slint under its GPLv3 licence, with no attribution widget required.

## D-39 Interface toolkit: move from egui to Slint, after disk streaming — Accepted (app)

A Slint prototype of the main screen (`claude/great-nobel-4b1434`, `crates/bubble-slint-proto`) was tried on a Windows Surface with touch: taps and press-and-hold registered reliably in every mode, the interface looked finished and responded well, and the OpenGL (femtovg) renderer performed best; the software renderer is kept as a fallback for machines without usable OpenGL (its partial-redraw glitch after minimising must be fixed by forcing a full redraw on restore). egui stays acceptable on macOS but handles hybrid mouse/touch Windows devices poorly. CPU and memory were similar on macOS; audio dominates memory either way, which disk streaming addresses. The port starts after disk streaming is tested: main window first (cart wall, pages, touch, menus, OS file drop via the winit accessor, window place), then Cart Setup and the settings windows, then egui is retired. Engine, control and project crates are unchanged.

## D-40 Shared application core (`bubble-core`) — Accepted (app)

Everything Bubble does that is not drawing lives in `bubble-core`, so the egui interface and the Slint interface share one implementation: the `Core` type (session open, save, autosave and recovery; background jobs for copying, importing and converting; audio outputs with device fallback and reconnection; MIDI; file dialogs; preferences; the single-instance guard; cloud-folder checks; crash reports; the log) and the `Intent`s an interface sends. An interface draws from `Core::snapshot()`, sends `Intent`s to `Core::apply`, and answers the questions in `Core::prompts` (errors, recovery, import choice, WAV conversion offer, discard confirmation, New Session). Selection changes the core asks for arrive in `Core::select`; `Core::watch_audio` returns when it next needs to run instead of scheduling redraws itself. The egui app holds a `Core` and reaches it through `Deref`. The rules from `docs/platform-audit.md` (dialogs owned by the main window, retrying saves, reporting failures, one instance, work off the interface thread) are implemented once, here.

## D-41 Slint main window (`bubble-slint`) — Accepted (app)

The main window is ported to Slint as a second binary, `crates/bubble-slint` (`Bubble Slint` in the release zips); the egui app stays complete until Cart Setup and the settings windows are ported. (Done: the Slint app is now Bubble, and the egui app is removed, D-44.)

- **Shared, not copied.** The menu model and its settings commands (`bubble_core::menu`) and what tiles, title, status line and busy strip say (`bubble_core::view`) moved from the egui app into `bubble-core`; both interfaces use them.
- **winit accessor** (`slint` feature `unstable-winit-030`, Slint pinned to 1.18.1): physical keys for hot keys (named as the egui app named them, so sessions keep working), focus loss (releases held carts), OS file drops (dropped at the cell under the pointer, read from the system as in the egui app), the window's place, theme and scale changes.
- **Menus.** Slint's `MenuBar` is native on macOS and Windows. macOS runs its shortcuts; elsewhere Bubble runs them itself so they never fire while a text field has the keyboard. A `MenuBar` cannot choose between an item and a submenu per model row, so each menu is a fixed list of slots (a run of items, then a submenu); separators use Slint's separator title.
- **In-window panels.** Quick edit, the core's prompts and the popup menus are drawn inside the main window (W2), rebuilt from Rust only when what they show changes from outside, so typing in them is never interrupted.
- **Redraw.** A timer ticks at 30 fps while carts play, 10 fps while busy, once a second otherwise; models are updated row by row, so Slint redraws only what changed. The whole window is repainted after a restore (software renderer).
- **Design** (2026-10-23, agreed on the "Bubble main window design" canvas): system font with plain figures; tiles with one icon row after an output badge, the state border and progress as one shape, a pulsing Learn border, "|" or Shift-Return line breaks; one non-modal busy popover for all background work (loading audio, copying, opening, importing, converting) instead of per-tile text; page tabs with the current page inverted and a yellow bar when something on it plays; PAGE STOP / ALL STOP; quick edit as a popover beside the cart (Label, Colour, Gain, Output, Fade Out, Group, Hotkey; Loop / Play Next / Stop All toggles; Copy, Paste, Replace File, Delete); native context menus with destructive items last; dialog buttons in each platform's order; cupertino widgets on macOS, fluent elsewhere, with flat buttons. View ▸ Interface Size is removed from both interfaces.

## D-42 Settings split by where they belong: this computer or the session — Accepted (app)

The settings grew one at a time, in menus and two windows. They are now in two places, by what they depend on:

- **Settings (this computer, `Prefs`):** appearance, page bar size, what a click on a cart does (mouse mode), the folder for new sessions; output level, the safety limiter, the outputs, sample rate and buffer size; MIDI ports. Output level, limiter and mouse mode moved here from the session: they belong to the room's speakers and the operator's hands, not to the show. A session saved before keeps them in its file (`settings.extra`); the first one opened on a machine that has not set them yet sets them, so nothing changes for whoever was using them. A SpotOn package's gain offset is reported on import instead of set.
- **Session Settings (`ProjectSettings`, groups, pages):** name, Audio Files, the default fade-out and On Retrigger for new carts, ending warning, the duplicate-hotkey rule and hotkey scope, tile appearance, groups, and each page's name and grid. Page Settings is gone: the tab menu and Session ▸ Grid Size set a page's grid.
- **Cart numbers count on across pages** (page 2 of a 4 × 6 session starts at 25), always; the unused per-page/continuous setting is gone. Reassign's button range uses the same numbers.
- **Menus hold commands, not settings.** Settings… (Bubble menu on a Mac, File elsewhere), Session Settings… (⌘, / Ctrl+,), Audio ▸ Output Level ▸ (kept for quick use in a show), Outputs… (Settings ▸ Audio). Pages are together in the Session menu (Add, Copy, Paste, Grid Size, Delete Page…, which asks).
- **Applying audio waits for Apply.** Changing outputs, sample rate or buffer size restarts audio and stops what plays, so in Settings they are a draft with Apply and Revert; everything else takes effect at once. Before, a click in the Sample Rate or Buffer Size menu restarted audio straight away.

## D-43 Sections: Intro, Main and Outro — Accepted (app)

A cart can play in three parts instead of one In–Out: an optional Intro played once, Main repeated, and an optional Outro played once to its end. It covers the WAV play lists seen in SpotOn sessions (an intro and a loop) plus an Outro; more parts, repeats on the Intro or Outro, counted repeats of Main and jumping between parts are left out.

- **Points.** Each part has its own In and Out (`Cart.sections`); none are shared. While Sections is on, the cart's own trim and Loop are not used; switched off, the points are kept.
- **Joins.** The mixer moves from one part to the next sample for sample, carrying the overshoot as a loop does, and keeps a pre-roll head at each part's In so a streamed file never waits at a join. A fade-out carries on across the joins.
- **Presses.** A touch, click, hotkey or MIDI press does what it always does (a click stops; a key or note follows On Retrigger), except during Main when the Outro follows the cart's own trigger: then it starts the Outro. With "New trigger" the Outro has a binding of its own (`Action::Outro`) and the cart's trigger is left as it is. The Outro starts at the end of Main's pass or at once (a short crossfade, as a seek). A press while the Outro is waiting for Main's end counts as a press during the Outro.
- **From files.** A WAV's `cue ` and `plst` chunks put a cart in sections when its file is added, replaced or first loaded (a cart that has never had Sections; one switched off stays off). Any repeat count above 1 (SpotOn's files use 999, up to 9999) is Main, repeated until stopped.
- **Cart Setup.** The Sections button shows chips under the waveform; the chip chosen points the In and Out boxes at that part, in its colour. Play auditions only that part, and the transport's loop loops it. Main's chevron opens its Outro options.

## D-44 The egui interface is removed — Accepted (app)

Every window is in Slint (main window, quick edit, Cart Setup, Settings, Session Settings, Speed Bar, Playout Log), so the egui app (`crates/bubble-app`) and the first Slint prototype (`crates/bubble-slint-proto`) are deleted, and egui and eframe leave the build. What only they needed goes with them: the settings the menus carried for an interface without Settings windows (sample rate, buffer size, duplicate-hotkey rule, hotkey scope) and the "not in this interface yet" marks. Releases are built only by GitHub Actions (`release.yml`, MSVC on Windows), so the local `scripts/release.sh` (GNU via zig, still building both apps) and `scripts/macos-dev-bundle.sh` are removed rather than kept in step. Hot-key names stay as the egui app stored them, so sessions open unchanged.

## D-45 Playing tiles read on any cart colour — Accepted (app)

A playing cart's ring sits inside the tile: 1 px dark, 4 px of the state colour (yellow playing, purple fading, red ending, magenta learning), 1 px dark, so it shows on a yellow cart too. Progress is chosen per computer (Settings ▸ General): an 8 px bar inside the ring on a dark track (the default), a dial by the time, or the countdown only; the space for the bar is kept while idle, so nothing moves when a cart starts, and without the bar the bottom row sits as far from the edge as the top row. Selection and quick edit's ring are outside the tile, 1–4 px into the 6 px gap, so neither touches a neighbour and two playing tiles side by side never merge. The MIDI note is an outlined chip before the hotkey's keycap, named as SpotOn names notes (C0 for note 0, so 60 is C5; " ch2" only off channel 1), and the MIDI icon is gone. Icons that do not fit collapse into "+N", most important kept (Paused, Muted, Hold, File changed, then trims, loop, delay, stop others, play next); hovering "+N" names the rest. The ring's lines, the bar and the outer ring are whole device pixels at every scale, and the bar's bottom corners follow the ring's inner curve. The time keeps one weight playing or not. The gap below the bottom row is measured from the time's baseline (the font's own metrics), so it matches the top on Windows and macOS. The clock is a conic-gradient disc with a hole, as tall as the figures and centred on them. The bottom row has one height whatever it shows, so the label never moves; its items are centred on the figures' middle, 12 px in from the sides. Main of a cart in sections counts down to its loop point, as a looping cart does (∞ was dropped); while Main plays, the icon row's loop icon (the same size and line) stands beside the time, so it appears when Main is reached and goes when the Outro is queued or the cart fades; a looping cart has its loop icon in the row already. Adapted from the design board's "Final tile", with its 8 px ring, 14 px padding and 6 px outer selection ring made smaller to fit small tiles and the 6 px gap.

## D-46 Ending warning belongs to the computer — Accepted (app)

The seconds before the end at which a playing cart turns red move from Session Settings to Settings ▸ General (`Prefs.ending_warning_s`, 3 s unless set), beside how playing carts show their progress: both are how this operator reads the wall. A session's own value (SpotOn files have none: its warning is a fixed 3 s) is no longer read; sessions saved before keep it in `settings.extra`, unused.

## D-47 A session's name is its file's name — Accepted (app)

The window title, Session Settings' title and Save As's suggested name use the session file's name ("CBS Italy" for `CBS Italy.bubble`), as operators know it from the file manager. Session Settings no longer has a Name field: the name inside the file went stale after Save As or a rename in Explorer, and the title with it. Save As writes the new file's name inside it, for older versions and other tools.

## D-48 Renderer: femtovg on OpenGL by default, others as fallbacks — Accepted (app, 2026-11-14)

Measured on the Surfaces with the graphics audit: femtovg on OpenGL is the fastest everywhere. femtovg on wgpu (Direct3D 12 on Windows) is the slowest and stalls 0.3–1.3 s when a window opens; the software renderer runs Cart Setup at 4–7 frames a second while playing. Both stay as fallbacks (`BUBBLE_RENDERER`, and the automatic relaunch with the other renderer if the window cannot open).

## D-49 No rounded clips or drop shadows over content that must stay sharp — Superseded (app, 2026-11-15)

Superseded by D-61.

A rounded `clip` and the Cart Setup playhead's drop shadow were drawn through off-screen layers, which came out blurred for a few frames on play and restart. Rounded clips over content were replaced by square clips with corners drawn over them, and the playhead lost its shadow.

## D-50 150 % is first class; the Cart Setup waveform is an image per device pixel — Accepted (app, 2026-11-15)

The Surfaces run at 150 %, where 1 dp is 1.5 pixels. Lines, rings and icons are placed on whole physical pixels at every scale from 100 to 200 %. The waveform is an image Bubble draws itself, one column per device pixel, so it looks the same on every renderer and never shimmers.

## D-51 Cart Setup to the owner's Windows spec — Accepted (app, 2026-11-16)

Cart Setup was rebuilt to the owner's design: a new header band and cards, LCD readouts in Cascadia Mono, eight colour squares, SVG icons, sharp at 100–200 %.

## D-52 Tiles keep their layout; text colour by contrast — Accepted (app, 2026-11-17)

After a trial of a new tiles spec, the tile layout (heights, icon row, time) stays as it was. Tile icons are SVGs, and label text is black or white, whichever has the better contrast on the cart's colour (black on orange and red).

## D-53 Cart Setup opens a fresh window each time — Accepted (app, 2026-11-17)

A hidden, reused Cart Setup window showed on the taskbar. Cart Setup is created when opened and its waveform is drawn after the window appears.

## D-54 Exit Bubble? shows the Bubble logo when nothing is playing — Accepted (app, 2026-11-17)

The warning symbol is kept for when carts are playing.

## D-55 No unrequested pop-ups during a show — Accepted (app, 2026-11-20)

An alert nobody asked for ("Volume low" after a device change, the cloud-folder warning, a crash report) waits until nothing has played for 2 seconds and no session is loading. The status line shows the problem meanwhile. A pop-up would take the keyboard and disable the main window mid-show.

## D-56 Hot keys work from every Bubble window — Accepted (app, 2026-11-20)

Bound keys trigger from the main window, the Speed Bar, the Playout Log, both Settings windows and Cart Setup, including while Cart Setup opens. A window keeps the key while text is being typed in it or a menu is open, and Cart Setup keeps its own keys (Space, I, O, P, the arrows, Enter). A held cart always lets go and nothing triggers twice.

## D-57 Disk work never holds up a trigger or the interface — Accepted (app, 2026-11-20)

Finding and checking files (adding, relinking, moving, converting, Save As) runs on a helper thread, never under the session lock or on the interface thread. Edits that need it wait in order behind it; triggers and other playing actions never wait. A check that does not answer in 15 seconds is given up and the operator told.

## D-58 Saving: autosave on its own thread, slow writes reported — Accepted (app, 2026-11-20)

Autosave writes on a thread of its own, so a stuck network folder cannot hold up Save, Save As or preferences. Any write still running after 10 seconds shows "Saving is taking a long time" in the status line. A Save never removes an autosave of newer edits.

## D-59 The log is written off-thread and kept — Accepted (app, 2026-11-20)

Log lines are queued to a writing thread (a full queue drops and counts lines rather than waiting). At about 4 MB the log moves to `bubble.1.log`, keeping three old files, instead of being emptied. A crash still writes its lines within a bounded wait.

## D-60 A window that fails to open never leaves the main window disabled — Accepted (app, 2026-11-20)

Cart Setup disables the main window while it opens. If it fails to open, or has not drawn after about 4 seconds, it is given up, the main window is enabled again and the operator told. A failing window's error is logged.

## D-61 Shadows and fades stay; layers are drawn on whole pixels — Accepted (app, 2026-11-20)

Supersedes D-49. The controls keep their shadows, fades and dimmed disabled states. Shadows are already drawn once and cached. The blur came from off-screen layers placed at a fractional pixel, so the renderer now rounds every layer's origin to a whole pixel (vendored change), which fixes them all with the look unchanged.

## D-62 Escape is an ordinary key — Accepted (app, 2026-11-20)

Escape never stops, fades or closes anything by itself. It can be assigned to a cart like any other key, from any Bubble window; while text is being typed it stays with the field. New sessions start with no key assignments (there used to be Escape → Stop All). Supersedes the Escape part of D-30.

## D-63 Quick edit to the owner's design — Accepted (app, 2026-11-21)

Quick edit is 296 × 403 dp, built from Cart Setup's parts: label, eight colour squares, group, hot key / MIDI / Learn cells, Loop and Play next, output (shown as "Output A"), fade out with its value beside it, a gain box with a hairline at 0 dB and the value as a stroke, and Cart Setup, Cut, Copy, Paste and Delete as icon buttons.

## D-64 Icons are Fluent SVGs; one shipped font — Accepted (app, 2026-11-21)

Every icon is a Fluent System Icons SVG drawn by one component, with hand-drawn pixel-grid files where an icon would be soft at 150 %. The Fluent icon font is removed. Bubble ships one font, Cascadia Mono, for the LCD readouts, and uses the system font for everything else.

## D-65 The selection ring has the same weight in both themes — Accepted (app, 2026-11-21)

A dark line on a light background reads thinner than a white one on dark, so the ring's outer line is 3 dp in light mode and 2 dp in dark.

## D-66 The product is BubbleWorks — Accepted (app, 2026-11-29, version 0.3.0)

The app's name is BubbleWorks wherever people see it: window titles, message boxes, menus, About, the log's first line, the file type name in Explorer, the release files (`BubbleWorks.exe`) and the docs. The interface crate is `crates/bubble-ui` and its program `BubbleWorks` (no "slint" in Bubble's own names; Slint stays credited as the toolkit). What users never see, or what would break, keeps "Bubble": the data folder (preferences, logs, backups and recovery carry on), the `.bubble` session ending (every session and file association keeps working), the default session folder, the internal crate names and the `BUBBLE_*` test switches. Releases are built for Windows x64 only for now.

## D-67 Fades out at a cart's own end, and across a loop's join — Accepted (engine, 2026-11-29)

A cart's fade-out applies whenever it stops: pressed to stop, or reaching its own end (its Out point, or the end of the file). It fades over its own fade-out time (or the session default), reaching silence at the end, and still counts as played to the end, so Play Next follows. A looping cart starts with its fade-in and fades out when stopped, but its loop point never fades in or out; a stopped loop keeps looping while its fade-out runs, so the fade is never cut short (this replaces the earlier rule that a fading loop ends at its Out point). The stored `fade_out_at_end` setting is not used.


## D-68 Every fade is logarithmic — Accepted (engine, 2026-11-29)

All fades (in, out on stop, out at a cart's end, Stop All, Page and Group) use the logarithmic curve: linear in dB from −60 dB, the reference player's default law. Imported short clips with quick fades sounded wrong on the gentler equal-power curve used before. There is no setting; the curve stored with each fade is kept in the session but not used. The short anti-click ramps (a few ms) stay linear.
