Files

31 lines
1.2 KiB
Swift

import AppKit
import SwiftUI
/// Column D: the agent terminal over a plain shell, split at `layout.agentFraction`.
public struct AgentColumn: View {
let model: WorkspaceModel
public init(model: WorkspaceModel) {
self.model = model
}
public var body: some View {
GeometryReader { proxy in
VStack(spacing: 0) {
TerminalPane(kind: .agent, store: model.terminal, scale: model.layout.textScale)
.frame(height: proxy.size.height * model.layout.agentFraction)
Splitter(.horizontal) { model.layout.dragAgentSplit(by: $0, height: proxy.size.height) }
TerminalPane(kind: .shell, store: model.terminal, scale: model.layout.textScale)
}
}
// A new project brings a new store, and with it fresh panes and processes.
.id(ObjectIdentifier(model.terminal))
.background(Palette.panel)
.onChange(of: model.focusRequest) { _, request in
guard request?.target == .panel(.terminal), let view = model.terminal.agent as? NSView else { return }
view.window?.makeFirstResponder(view)
model.focusTaken(.panel(.terminal))
}
}
}