adds nice git interface

This commit is contained in:
2026-10-30 13:21:45 +01:00
parent b9c03a7637
commit caec81e762
107 changed files with 6466 additions and 3992 deletions
+25 -28
View File
@@ -5,7 +5,6 @@ import Observation
/// Which column has keyboard focus: drives the active-panel tint and arrow-key navigation.
public enum Panel: String, Sendable, CaseIterable {
case sourceControl
case explorer
case editor
case terminal
@@ -13,42 +12,36 @@ public enum Panel: String, Sendable, CaseIterable {
/// The column layout one project remembers between launches.
public struct ColumnLayoutSnapshot: Codable, Sendable, Equatable {
public var sourceControlWidth: Double
public var explorerWidth: Double
public var agentWidth: Double
public var fluid: Bool
public var gitVisible: Bool
public var explorerVisible: Bool
public var fileVisible: Bool
public var claudeVisible: Bool
public init(sourceControlWidth: Double, explorerWidth: Double, agentWidth: Double, fluid: Bool,
visibility: ColumnVisibility = .all) {
self.sourceControlWidth = sourceControlWidth
public init(explorerWidth: Double, agentWidth: Double, fluid: Bool, visibility: ColumnVisibility = .all) {
self.explorerWidth = explorerWidth
self.agentWidth = agentWidth
self.fluid = fluid
gitVisible = visibility.sourceControl
explorerVisible = visibility.explorer
fileVisible = visibility.editor
claudeVisible = visibility.agent
}
/// Older snapshots only know `gitVisible`; a missing flag means shown.
/// A missing visibility flag means shown. Snapshots from before the Git view also hold
/// `sourceControlWidth` and `gitVisible`; they are ignored.
public init(from decoder: Decoder) throws {
let c = try decoder.container(keyedBy: CodingKeys.self)
sourceControlWidth = try c.decode(Double.self, forKey: .sourceControlWidth)
explorerWidth = try c.decode(Double.self, forKey: .explorerWidth)
agentWidth = try c.decode(Double.self, forKey: .agentWidth)
fluid = try c.decode(Bool.self, forKey: .fluid)
gitVisible = try c.decodeIfPresent(Bool.self, forKey: .gitVisible) ?? true
explorerVisible = try c.decodeIfPresent(Bool.self, forKey: .explorerVisible) ?? true
fileVisible = try c.decodeIfPresent(Bool.self, forKey: .fileVisible) ?? true
claudeVisible = try c.decodeIfPresent(Bool.self, forKey: .claudeVisible) ?? true
}
public var visibility: ColumnVisibility {
ColumnVisibility(sourceControl: gitVisible, explorer: explorerVisible, editor: fileVisible, agent: claudeVisible)
ColumnVisibility(explorer: explorerVisible, editor: fileVisible, agent: claudeVisible)
}
public static func key(root: String) -> String { "helder.layout:" + root }
@@ -91,12 +84,14 @@ public struct UserDefaultsLayoutStore: LayoutPersisting, @unchecked Sendable {
@Observable
@MainActor
public final class LayoutStore {
public private(set) var widths = ColumnWidths(sourceControl: 236, explorer: 288, agent: 480)
public private(set) var widths = ColumnWidths(explorer: 288, agent: 480)
/// The agent pane's share of the right column; persisted across launches.
public private(set) var agentFraction: Double
public private(set) var windowWidth: Double = 1680
/// The title bar's pane toggles; ⌘G flips Source Control.
/// The title bar's pane toggles; ⌘1–⌘3 flip them.
public private(set) var visibility = ColumnVisibility.all
/// ⌘G: the full-screen Git view over the whole window. Not persisted; the columns stay mounted under it.
public private(set) var isGitViewOpen = false
/// ⌘L: columns re-fit on resize and focus. A manual splitter drag turns this off.
public private(set) var fluid = true
/// ⌘.: dotfiles show in the tree and the search.
@@ -145,25 +140,23 @@ public final class LayoutStore {
self.root = root
activePanel = nil
focusZone = .neutral
isGitViewOpen = false
let saved = persistence?.load(root: root)
visibility = saved?.visibility ?? .all
fluid = saved?.fluid ?? true
if let saved, !saved.fluid {
widths = ColumnWidths(sourceControl: clamp(saved.sourceControlWidth, ColumnLayout.sourceControlRange),
explorer: clamp(saved.explorerWidth, ColumnLayout.explorerRange),
widths = ColumnWidths(explorer: clamp(saved.explorerWidth, ColumnLayout.explorerRange),
agent: max(saved.agentWidth, ColumnLayout.minEditorWidth))
}
refit()
}
public var snapshot: ColumnLayoutSnapshot {
ColumnLayoutSnapshot(sourceControlWidth: widths.sourceControl, explorerWidth: widths.explorer,
agentWidth: widths.agent, fluid: fluid, visibility: visibility)
ColumnLayoutSnapshot(explorerWidth: widths.explorer, agentWidth: widths.agent, fluid: fluid, visibility: visibility)
}
public func isVisible(_ panel: Panel) -> Bool {
switch panel {
case .sourceControl: visibility.sourceControl
case .explorer: visibility.explorer
case .editor: visibility.editor
case .terminal: visibility.agent
@@ -178,7 +171,6 @@ public final class LayoutStore {
public func setVisible(_ panel: Panel, _ visible: Bool) {
guard isVisible(panel) != visible else { return }
switch panel {
case .sourceControl: visibility.sourceControl = visible
case .explorer: visibility.explorer = visible
case .editor: visibility.editor = visible
case .terminal: visibility.agent = visible
@@ -188,6 +180,18 @@ public final class LayoutStore {
save()
}
public func openGitView() {
isGitViewOpen = true
}
public func closeGitView() {
isGitViewOpen = false
}
public func toggleGitView() {
isGitViewOpen.toggle()
}
public func toggleFluid() {
fluid.toggle()
refit()
@@ -221,11 +225,6 @@ public final class LayoutStore {
refit()
}
public func dragSourceControl(by delta: Double) {
fluid = false
widths.sourceControl = clamp(widths.sourceControl + delta, ColumnLayout.sourceControlRange)
}
public func dragExplorer(by delta: Double) {
fluid = false
widths.explorer = clamp(widths.explorer + delta, ColumnLayout.explorerRange)
@@ -267,12 +266,10 @@ public final class LayoutStore {
guard isVisible(panel) else { return nil }
let splitter = ColumnLayout.splitterWidth
let v = visibility
let explorerStart = v.sourceControl ? widths.sourceControl + splitter : 0
let flexStart = explorerStart + (v.explorer ? widths.explorer + splitter : 0)
let flexStart = v.explorer ? widths.explorer + splitter : 0
let agentStart = v.editor ? max(flexStart, windowWidth - widths.agent) : flexStart
switch panel {
case .sourceControl: return 0...widths.sourceControl
case .explorer: return explorerStart...(explorerStart + widths.explorer)
case .explorer: return 0...widths.explorer
case .editor: return flexStart...max(flexStart, v.agent ? agentStart - splitter : windowWidth)
case .terminal: return agentStart...max(agentStart, windowWidth)
}