mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-12 01:50:49 +08:00
重构主控编排与运行时预热链路,统一工作区提示词/专家调度协议并补齐 wiki 记忆注入与写回闭环。
同时收敛启动与运维脚本默认行为(含 wiki worker)、更新 Admin 可观测性与相关测试,降低首轮时延并提高运行稳定性。 Made-with: Cursor
This commit is contained in:
parent
4a23b715a2
commit
dbbe3add6a
14438 changed files with 2693620 additions and 2546 deletions
|
|
@ -0,0 +1,94 @@
|
|||
import AppKit
|
||||
import SwiftUI
|
||||
|
||||
final class HighlightedMenuItemHostView: NSView {
|
||||
private var baseView: AnyView
|
||||
private let hosting: NSHostingView<AnyView>
|
||||
private var targetWidth: CGFloat
|
||||
private var tracking: NSTrackingArea?
|
||||
private var hovered = false {
|
||||
didSet { self.updateHighlight() }
|
||||
}
|
||||
|
||||
init(rootView: AnyView, width: CGFloat) {
|
||||
self.baseView = rootView
|
||||
self.hosting = NSHostingView(rootView: AnyView(rootView.environment(\.menuItemHighlighted, false)))
|
||||
self.targetWidth = max(1, width)
|
||||
super.init(frame: .zero)
|
||||
|
||||
self.addSubview(self.hosting)
|
||||
self.hosting.autoresizingMask = [.width, .height]
|
||||
self.updateSizing()
|
||||
}
|
||||
|
||||
@available(*, unavailable)
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
override var intrinsicContentSize: NSSize {
|
||||
let size = self.hosting.fittingSize
|
||||
return NSSize(width: self.targetWidth, height: size.height)
|
||||
}
|
||||
|
||||
override func updateTrackingAreas() {
|
||||
super.updateTrackingAreas()
|
||||
TrackingAreaSupport.resetMouseTracking(on: self, tracking: &self.tracking, owner: self)
|
||||
}
|
||||
|
||||
override func mouseEntered(with event: NSEvent) {
|
||||
_ = event
|
||||
self.hovered = true
|
||||
}
|
||||
|
||||
override func mouseExited(with event: NSEvent) {
|
||||
_ = event
|
||||
self.hovered = false
|
||||
}
|
||||
|
||||
override func layout() {
|
||||
super.layout()
|
||||
self.hosting.frame = self.bounds
|
||||
}
|
||||
|
||||
override func draw(_ dirtyRect: NSRect) {
|
||||
if self.hovered {
|
||||
NSColor.selectedContentBackgroundColor.setFill()
|
||||
self.bounds.fill()
|
||||
}
|
||||
super.draw(dirtyRect)
|
||||
}
|
||||
|
||||
func update(rootView: AnyView, width: CGFloat) {
|
||||
self.baseView = rootView
|
||||
self.targetWidth = max(1, width)
|
||||
self.updateHighlight()
|
||||
}
|
||||
|
||||
private func updateHighlight() {
|
||||
self.hosting.rootView = AnyView(self.baseView.environment(\.menuItemHighlighted, self.hovered))
|
||||
self.updateSizing()
|
||||
self.needsDisplay = true
|
||||
}
|
||||
|
||||
private func updateSizing() {
|
||||
let width = max(1, self.targetWidth)
|
||||
self.hosting.frame.size.width = width
|
||||
let size = self.hosting.fittingSize
|
||||
self.frame = NSRect(origin: .zero, size: NSSize(width: width, height: size.height))
|
||||
self.invalidateIntrinsicContentSize()
|
||||
}
|
||||
}
|
||||
|
||||
struct MenuHostedHighlightedItem: NSViewRepresentable {
|
||||
let width: CGFloat
|
||||
let rootView: AnyView
|
||||
|
||||
func makeNSView(context _: Context) -> HighlightedMenuItemHostView {
|
||||
HighlightedMenuItemHostView(rootView: self.rootView, width: self.width)
|
||||
}
|
||||
|
||||
func updateNSView(_ nsView: HighlightedMenuItemHostView, context _: Context) {
|
||||
nsView.update(rootView: self.rootView, width: self.width)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue