Files
luma/Luma/Engine+InstrumentUIs.swift
Ole André Vadla Ravnås c5d2ff7050 core: Replace Workspace with per-document Engine
EngineRegistry caches one Engine per working-project URL.
MainWindowView.init does a pure lookup, so SwiftUI's
view-tree re-evaluations cannot open extra ProjectStores
that race the live one's BEGIN IMMEDIATE and crash via
try!.

UI-state persistence (collapse flag, sidebar selection,
session detail section, etc.) lives on Engine for GTK to
adopt. SQLite has a 5s busy timeout. Engine open failures
surface as an error view.

TargetPicker is host @State injected via environment.
Global instrument-UI defaults register at app startup;
per-engine instrument and local-notifier hookups live in
Engine extensions.
2026-05-11 21:15:47 +02:00

31 lines
919 B
Swift

import Foundation
import LumaCore
extension Engine {
func attachInstrumentUIs() {
guard enginesWithInstrumentUIs.insert(ObjectIdentifier(self)).inserted else { return }
let registry = InstrumentUIRegistry.shared
for pack in hookPacks.packs {
registry.register(for: "hook-pack:\(pack.id)", ui: HookPackUI(pack: pack))
}
refreshCustomInstrumentUIs()
customInstruments.observers.append { [weak self] in
self?.refreshCustomInstrumentUIs()
}
}
private func refreshCustomInstrumentUIs() {
let registry = InstrumentUIRegistry.shared
for def in customInstruments.defs {
registry.register(
for: "custom:\(def.id.uuidString)",
ui: CustomInstrumentUI(defID: def.id)
)
}
}
}
@MainActor
private var enginesWithInstrumentUIs: Set<ObjectIdentifier> = []