Consolidated release: the cross-platform Linux port (engine, generators, CLI, REPL, NRT, portable DSP), live ALSA audio + ALSA MIDI + POSIX OSC + portable WAV codec, the GTK4 GUI (LyrebirdUI on the SwiftOpenUI backend), and the Linux live-coding scratchpad (LiveCompile). Apple platforms unchanged; all additive. See RELEASES.md and LINUX_README.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
9.7 KiB
Linux view-port hand-off
Instructions for porting the remaining Apple-only LyrebirdUI views to the
Linux/GTK4 backend, so a fresh agent can pick this up cold. Prereq context:
spikes/SwiftOpenUIKnob/FORK_PATCH_PLAN.md (the SwiftOpenUI fork + drag fix) and
the linux-gui-swiftopenui memory.
Where things stand
LyrebirdUI is now one cross-platform module (parity steps B + C, done and
VM-validated). Every control/view switches its body by backend:
#if canImport(SwiftUI)
import SwiftUI
import LyrebirdSynth
public struct Foo: View { /* real SwiftUI body */ }
#else
import SwiftOpenUI
import BackendGTK4 // Cairo DrawingContext drawing methods
import LyrebirdSynth
public struct Foo: View { /* SwiftOpenUI/GTK4 body — same public API */ }
#endif
The 8 stock controls/views are already dual-body and are your templates:
- Canvas + drag:
Controls/ParameterKnob.swift,Controls/ParameterXY.swift,Controls/ParameterSlider.swift - Canvas + a polled
@Observablemodel:LyrebirdScopeView.swift+LyrebirdScopeModel.swift - Layout +
ForEach+ action:LyrebirdStatusView.swift,Controls/ParameterButton.swift,Controls/ParameterLabel.swift
The Apple-only views are currently wrapped whole in #if canImport(SwiftUI) (so
they compile to nothing on Linux). Porting one = add its #else body in the
same file and drop the outer guard (or convert the guard to #if/#else).
Backend capabilities (SwiftOpenUI/GTK4) — what you have and don't
Confirmed present (~/Documents/src/SwiftOpenUI/Sources/SwiftOpenUI/Views/):
VStack/HStack/LazyVStack, ScrollView, List, ForEach, Text,
Canvas, .onDrag, @State/@Binding/@Observable. Missing: Table
(use ScrollView + ForEach rows), GeometryReader (unverified — check; a
Canvas renderer gets its size directly, prefer that).
Hard gaps to design around:
DrawingContexthas NO text primitive. A Canvas body cannot draw text labels (axis ticks, value readouts). Either overlay realTextwidgets on top of the Canvas (compose in aZStack/stack), or leave labels off on Linux (asLyrebirdEnvelopeView's "L"/"R" markers already do). Adding a text primitive to SwiftOpenUI'sDrawingContextis the proper upstream fix.DrawingContextAPI is imperative Cairo, not SwiftUIGraphicsContext:setColor(r:g:b:)/setLineWidth(_:)/moveTo(x:y:)/lineTo(x:y:)/rectangle(x:y:width:height:)/arc(centerX:centerY:radius:startAngle:endAngle:)/stroke()/fill(). AGraphicsContext+Pathbody must be rewritten to these calls (seeParameterKnob/ParameterSlider#elsebodies).@Observableneeds an explicitimport Observationon Linux (SwiftOpenUI does not re-export it the way SwiftUI does)..taskruns OFF the main thread on SwiftOpenUI (unlike SwiftUI). For periodic polling use a FoundationTimeronRunLoop.main— seeLyrebirdScopeModel/ theLinuxStatusModelinsideLyrebirdStatusView.swift.Coloris a SwiftOpenUI type on Linux, not SwiftUI's;PlatformColors(AppKit/UIKit) is Apple-only. Use raw colors in the#elsebody.- Live cross-control redraw already works in the fork (global interaction
deferral + per-drag subtree redraw); Canvas bodies that read a shared value
will track during a drag with no extra work. Native widgets (e.g.
GtkScale) do not — that's why the slider was made Canvas-drawn. Draw withCanvasif the control must live-link.
The views to port
Status: all view ports below are DONE — each has a #else SwiftOpenUI/GTK4
body added in-place, same public API/init as the Apple side, and the macOS side
stays green (swift build --target LyrebirdUI). Every SwiftOpenUI symbol used was
checked against the fork source. Still needs Linux/VM validation per the
workflow below (compile + eyeball) — no Linux build has run yet.
| View | ~LOC | Kind | Status | Linux notes |
|---|---|---|---|---|
| LyrebirdSynthView | 177 | layout | ✅ done | Adaptive LazyVGrid(columns:data:) (SwiftOpenUI's data-based form) of ParameterKnobs. |
| LyrebirdSpectrumView | 234 | Canvas | ✅ done | DrawingContext rewrite; FFT polled by Timer+@Observable model. No axis text (Apple draws none either). |
| LyrebirdScatterView | 121 | Canvas | ✅ done | DrawingContext arc+fill dots; reuses _linuxEnvelopeYBounds. |
| MultiSlider | 137 | Canvas+drag | ✅ done | Fixed columnWidth; Canvas + .onDrag, pointer-x→column, pointer-y→value. |
| LyrebirdEngineStatusView | 603 | layout | ✅ done | Timer+@Observable model; CPU bars are Canvas (not GeometryReader); Picker/Stepper/Toggle/FocusState all exist in the fork. "Open Window" buttons work on Linux too (node-tree / messages open detached windows) now that LyrebirdWindow has a GTK4 body; sections also still expand inline. |
| LyrebirdMessageBanner / LyrebirdMessageView / LyrebirdMessageHelpers | 128 / 277 / 33 | layout | ✅ done | @Bindable center — the GTK4 view host evaluates bodies under withObservationTracking, so plain @Observable reads live-update (no polling needed). MessageView dropped auto-scroll + text selection. |
| LyrebirdNodeTreeView | 266 | layout | ✅ done | Indented ForEach rows; SF chevrons → text glyphs (▼/▶/•). Live via mirror.snapshot observation. |
| LyrebirdEventListView | 335 | layout | ✅ done | Timer+@Observable model; native Slider + TextField. (Did not need List.) |
| LyrebirdEventListPerformanceView / LyrebirdRunningProcessesView / LyrebirdProcessView | 167 / 197 / 224 | layout | ✅ done | Timer+@Observable models; identity-stable child reassignment preserved; DbSliderConversion reused; native Slider. |
Also added a Linux branch to PlatformColors (Color.lyrebirdControlBackground
/ lyrebirdSeparator as fixed neutral SwiftOpenUI tones) — the Apple file had
no #else, which blocked every layout port that used those colours.
Cross-cutting decisions worth knowing for the next port/review:
- Every periodic-poll view uses the
LyrebirdScopeModelpattern (@Observable@unchecked Sendablemodel + FoundationTimeronRunLoop.main), not.task(off-main on SwiftOpenUI). - SF Symbols don't resolve on GTK4 → text glyphs.
Font.monospaced()is not aFontmethod on SwiftOpenUI (it's a separate case) → use the.monospacedDigit()view modifier instead.- SwiftOpenUI
Colorexposes.red/.green/.blue/.alpha, so aColorparameter (e.g. Scatter'spointColor) feedsDrawingContext.setColordirectly.
Separate subsystems (not simple view ports — scope carefully) — STILL TODO
- LyrebirdWindow (163 L,
NSWindow). No portable equivalent. Needs a new cross-platform host-window abstraction backed by GTK4 on Linux (the demo,Sources/LyrebirdUILinuxDemo/main.swift, stands up a GTK window ad hoc today — start from that). Design work, not a mechanical port. Do this before shipping a first-class Linux app entry point. - MouseTracker (165 L,
NSEvent) +MouseInput/MouseInputBridge. This feeds theMouse.X/Mouse.Y/Mouse.Clickgenerators (core, inSources/Lyrebird/Generators/UI/), not a view. The core protocol (MouseInputBridge) is platform-neutral; nothing conforms to it on GTK4. Needs a GTK global-pointer (or X11/evdev) source installed viaMouseInput.install. Separate from the view work; do it if the mouse generators are wanted on Linux.
Validation workflow (important)
You cannot build the GTK4 backend on macOS — LyrebirdUI's #else bodies
compile only on Linux. Two rules:
- Verify the Apple side here after any edit:
swift build --target LyrebirdUI(must stay green — you are only adding#elsebranches, so it should). - Verify the Linux side on the Linux box / VM. Push to the branch, then on
the VM:
The ported views are wired into the demo under a new
git pull swift build # builds LyrebirdUI (needs libgtk-4-dev + the fork) LYREBIRD_DEMO=full swift run LyrebirdUILinuxDemomonitorsmode —LYREBIRD_DEMO=monitors swift run LyrebirdUILinuxDemoshows theLyrebirdSynthViewparameter grid,LyrebirdScatterView, aMultiSlider, andLyrebirdEngineStatusView(which embeds the node-tree + message sections). The Process/EventList family is not yet in the demo (needs aLyrebirdEventList+ running processes to scaffold). For headless-core-only checks (no GTK) useswift build --target LyrebirdSynth, or the emulated x86 route in thelinux-ci-x86-verificationmemory.
If you have Docker, an arm64 swift:6.3.3 container with libgtk-4-dev installed
can compile-check the Linux bodies without a display (build only, no run).
Gotchas already paid for (don't rediscover)
- GTK4 reuses a child's cached render node —
queue_drawmust walk the subtree (gtkQueueDrawSubtreein the fork). Live redraw during drag already handled. - Drag gesture survival + linked live-update are solved in the fork
(
FORK_PATCH_PLAN.md); Canvas bodies get it for free. - Keep
#if canImport(SwiftUI)as the discriminator (Linux's SwiftOpenUI does not vend aSwiftUImodule). Not#if os(...). - SPDX header stays first-5-lines; put
#ifafter it, before imports.
Definition of done (per view)
#elsebody added, same public API/init as the Apple side.swift build --target LyrebirdUIgreen on macOS.swift build+ demo green on the Linux VM; the view renders and (if interactive) tracks.- If it drops a feature on Linux (e.g. text labels), document it in the file
header the way
LyrebirdEnvelopeViewdoes.