v2.4.1 release: scratchpad polish + demo cleanup

Maintenance release, no framework API changes.

Scratchpad: Kill All Sound (⌘K) rename, mode-switch desync fix,
code-completion prefix filtering restored (⌃Space Show Completions).
Demos: GUIDemo voices + CLI EventPattern BlipVoice moved into
Synthesizers/, EventPattern demo split into makeLead/makeBass, GUIDemo
doc drift fixed (conductor default). LyrebirdScratch gains a SwiftPM
package so the workspace shows it like GUIDemo (.xcodeproj kept for
distribution). Linux live-coding scratchpad documented.
This commit is contained in:
2026-12-03 11:39:40 -08:00
parent 6da3615707
commit ec72bd3a4c
29 changed files with 510 additions and 110 deletions
@@ -130,6 +130,12 @@ public struct LyrebirdScratchView: View {
// Settle a `.queued` readiness badge once its swap has fired.
model.refreshQueuedState()
}
// The mode Picker binds `evalMode` directly (synchronous, desync-free);
// its side-effects run here, outside the view-update pass, so mutating
// several @Published properties at once is allowed.
.onChange(of: model.evalMode) { previous, mode in
model.applyModeSwitchSideEffects(from: previous, to: mode)
}
}
/// The editor column: engine controls, editor, status, engine panel.
@@ -393,14 +399,14 @@ public struct LyrebirdScratchView: View {
/// evaluators. Routes through ``LyrebirdScratchModel/switchMode(to:)`` so the
/// seed placeholder follows the mode.
private var modePicker: some View {
Picker("Mode", selection: Binding(
get: { model.evalMode },
// Defer to the next main-actor tick: the Picker's `set` runs inside
// SwiftUI's view-update pass, and `switchMode` mutates @Published
// state ("Publishing changes from within view updates is not
// allowed"). Scheduling it off the current pass avoids that.
set: { newMode in Task { @MainActor in model.switchMode(to: newMode) } }
)) {
// Bind `evalMode` directly: the segmented control writes one @Published
// value synchronously, so the displayed segment and `model.evalMode`
// can't desync (the old deferred-`Task` set let a re-render — e.g. the
// @Published burst from ⌘K's kill — revert the segment before the Task
// applied the switch, after which `switchMode`'s equality guard ate the
// next click and the toggle appeared stuck). The mode's side-effects run
// from `.onChange(of: model.evalMode)` on the body, off the update pass.
Picker("Mode", selection: $model.evalMode) {
ForEach(ScratchEvalMode.allCases, id: \.self) { mode in
Text(mode.title).tag(mode)
}
@@ -604,6 +610,15 @@ final class ScratchTextView: NSTextView {
onManualComplete?()
}
/// Menu-driven completion trigger (Edit ▸ Show Completions, ⌃Space). Routed
/// down the responder chain to the focused editor so the menu item needs no
/// explicit target; funnels to the same async-fetch path as Esc / F5 rather
/// than AppKit's bare `complete(_:)`, so the candidates are fetched before
/// the window opens.
@objc func scratchShowCompletions(_ sender: Any?) {
onManualComplete?()
}
/// Width of the line-number gutter drawn by ``ScratchLineNumberGutter``.
/// `ScratchEditor.configure` reserves this as the text view's left inset so
/// the gutter overlay doesn't cover the text.