Files
luma/Luma/Instruments/CustomInstrumentUI.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

51 lines
1.4 KiB
Swift

import SwiftUI
import LumaCore
struct CustomInstrumentUI: InstrumentUI {
let defID: UUID
func makeConfigEditor(
configJSON: Binding<Data>,
engine: Engine,
selection: Binding<SidebarItemID?>
) -> AnyView {
let id = defID
let cfgBinding = Binding<CustomInstrumentConfig>(
get: {
(try? CustomInstrumentConfig.decode(from: configJSON.wrappedValue))
?? CustomInstrumentConfig(defID: id)
},
set: { newValue in
configJSON.wrappedValue = newValue.encode()
}
)
return AnyView(
CustomInstrumentConfigView(
defID: id,
config: cfgBinding,
engine: engine,
selection: selection
)
)
}
func renderEvent(
_ event: RuntimeEvent,
engine: Engine,
selection: Binding<SidebarItemID?>
) -> AnyView {
if case .jsValue(let v) = event.payload {
return AnyView(
JSInspectValueView(
value: v,
sessionID: event.sessionID ?? UUID(),
engine: engine,
selection: selection
)
.font(.system(.footnote, design: .monospaced))
)
}
return AnyView(Text(String(describing: event.payload)))
}
}