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
@@ -78,7 +78,8 @@ struct ContextMenuOverlay: View {
ContextMenuSeparator()
case let .action(action, label):
ContextMenuRow(label, systemImage: Self.symbol(for: action), iconTint: Self.tint(for: action).color,
isHighlighted: highlighted == index, isDestructive: action.isDestructive)
isHighlighted: highlighted == index, isDestructive: action.isDestructive,
isEmphasized: action.isEmphasized)
.onHover { inside in if inside { highlighted = index } }
.onTapGesture { onPerform(action) }
}
@@ -109,11 +110,11 @@ struct ContextMenuOverlay: View {
nonisolated static func tint(for action: ContextAction) -> MenuIconTint {
switch action {
case .copyReference, .copyTerminalSelection, .pasteIntoTerminal, .readAloudFile, .readAloudText, .readAloudTerminalSelection,
.plak, .plakTerminalSelection: .plain
case .newFile, .newFolder, .stage: .add
case .copyFileName, .unstage, .revealInFinder: .modify
case .passOnReference, .passOnFileName, .bouwen, .waitWhat, .openDiff, .showDiff, .rename: .rename
case .discard, .delete: .danger
.plak, .plakTerminalSelection, .openFile, .commit: .plain
case .newFile, .newFolder: .add
case .copyFileName, .revealInFinder: .modify
case .passOnReference, .passOnFileName, .bouwen, .waitWhat, .showDiff, .rename: .rename
case .gitDiscard, .delete: .danger
}
}
@@ -125,13 +126,14 @@ struct ContextMenuOverlay: View {
case .readAloudFile, .readAloudText, .readAloudTerminalSelection: "speaker.wave.2"
case .plak, .plakTerminalSelection: "note.text.badge.plus"
case .copyReference, .copyFileName, .copyTerminalSelection: "doc.on.doc"
case .openFile: "doc.text"
case .commit(andPush: false): "checkmark"
case .commit(andPush: true): "arrow.up.to.line"
case .pasteIntoTerminal: "doc.on.clipboard"
case .newFile: "doc.badge.plus"
case .newFolder: "folder.badge.plus"
case .stage: "plus"
case .unstage: "minus"
case .openDiff, .showDiff: "arrow.left.arrow.right"
case .discard: "arrow.uturn.backward"
case .showDiff: "arrow.left.arrow.right"
case .gitDiscard: "arrow.uturn.backward"
case .rename: "pencil"
case .revealInFinder: "folder"
case .delete: "trash"
@@ -26,6 +26,7 @@ public struct OverlayHost: View {
activeText: path.map { model.editor?.text(for: $0) ?? "" } ?? "",
showHidden: model.layout.showHidden),
changedPaths: model.changedPaths,
isFullScreen: model.layout.isFullScreen,
onOpen: { model.perform(.open($0.path, OpenOptions(line: $0.line))) },
onClose: dismiss
)
+7 -11
View File
@@ -290,20 +290,16 @@ public final class SearchModel {
// MARK: Layout
/// Column widths: the focused column takes 70%; at rest this file is 230, files 250,
/// and a side column never drops below 180.
public static func widths(total: CGFloat, columns: [Column], focused: Column) -> [Column: CGFloat] {
let restingSide: [Column: CGFloat] = [.thisFile: 230, .files: 250]
let minimumSide: CGFloat = 180
/// Fixed column widths that never follow the focus: 30 · 45 · 25 with this file, else 65 · 35.
public static func widths(total: CGFloat, columns: [Column]) -> [Column: CGFloat] {
var widths: [Column: CGFloat] = [:]
if focused == .project {
for side in columns where side != .project { widths[side] = restingSide[side] }
if columns.contains(.thisFile) {
widths[.thisFile] = (total * 0.30).rounded()
widths[.files] = (total * 0.25).rounded()
} else {
widths[focused] = (total * 0.7).rounded()
for side in columns where side != .project && side != focused { widths[side] = minimumSide }
widths[.files] = (total * 0.35).rounded()
}
let used = widths.values.reduce(0, +)
widths[.project] = max(0, total - used)
widths[.project] = max(0, total - widths.values.reduce(0, +))
return widths
}
}
+10 -6
View File
@@ -7,6 +7,8 @@ struct SearchOverlay: View {
@State private var model: SearchModel
/// Paths with a git change get a dot in the files column.
var changedPaths: Set<String>
/// Full screen hides the traffic lights, so the query bar reclaims their inset.
var isFullScreen: Bool
var onOpen: (SearchModel.Target) -> Void
var onClose: () -> Void
@@ -14,15 +16,17 @@ struct SearchOverlay: View {
@State private var parkedPointer: CGPoint?
@State private var hoveredGroup: String?
init(model: SearchModel, changedPaths: Set<String>, onOpen: @escaping (SearchModel.Target) -> Void, onClose: @escaping () -> Void) {
init(model: SearchModel, changedPaths: Set<String>, isFullScreen: Bool,
onOpen: @escaping (SearchModel.Target) -> Void, onClose: @escaping () -> Void) {
_model = State(initialValue: model)
self.changedPaths = changedPaths
self.isFullScreen = isFullScreen
self.onOpen = onOpen
self.onClose = onClose
}
var body: some View {
OverlayShell(.inset, onDismiss: onClose) {
OverlayShell(.fullScreen, onDismiss: onClose) {
VStack(spacing: 0) {
queryBar.zIndex(1)
columns
@@ -54,7 +58,8 @@ struct SearchOverlay: View {
.padding(.leading, 12)
.hairline(.leading)
}
.padding(.horizontal, 18)
.padding(.leading, isFullScreen ? 18 : Metrics.trafficLightInset)
.padding(.trailing, 18)
.frame(height: Metrics.searchQueryBar)
.hairline(.bottom)
}
@@ -85,7 +90,7 @@ struct SearchOverlay: View {
private var columns: some View {
GeometryReader { proxy in
let widths = SearchModel.widths(total: proxy.size.width, columns: model.columns, focused: model.column)
let widths = SearchModel.widths(total: proxy.size.width, columns: model.columns)
HStack(spacing: 0) {
if model.columns.contains(.thisFile) {
thisFileColumn.frame(width: widths[.thisFile])
@@ -95,7 +100,6 @@ struct SearchOverlay: View {
divider
filesColumn.frame(width: widths[.files])
}
.animation(Metrics.colorTransition, value: model.column)
}
}
@@ -263,7 +267,7 @@ struct SearchOverlay: View {
TypeBadge(path: match.path)
VStack(alignment: .leading, spacing: 1) {
Text(SearchHighlight.name(PathUtils.basename(match.path), indices: match.nameIndices, selected: selected))
.typeRole(selected ? Typography.rowSelected : Typography.sourceControlRow)
.typeRole(selected ? Typography.rowSelected : Typography.rowSmall)
.lineLimit(1)
if !directory.isEmpty {
Text(directory + "/").typeRole(Typography.meta).foregroundStyle(Palette.text4).lineLimit(1).truncationMode(.head)
@@ -19,7 +19,10 @@ public enum ShortcutCatalog {
ShortcutRow(keys: ["⌘", "↑↓"], label: "Move through a list"),
ShortcutRow(keys: ["↵"], label: "Open the selected item"),
ShortcutRow(keys: ["⌘", "←→"], label: "Column left or right"),
ShortcutRow(keys: ["↑↓"], label: "Git or Explorer: move the row cursor"),
ShortcutRow(keys: ["↑↓"], label: "Explorer: move the row cursor"),
ShortcutRow(keys: ["⌘", "1"], label: "Explorer column on or off"),
ShortcutRow(keys: ["⌘", "2"], label: "File column on or off"),
ShortcutRow(keys: ["⌘", "3"], label: "Claude column on or off"),
ShortcutRow(keys: ["⇧", "⌘", "O"], label: "Open a recent project"),
ShortcutRow(keys: ["⌘", "O"], label: "Open a project folder"),
ShortcutRow(keys: ["⇧", "⌘", "N"], label: "Open a new window"),
@@ -30,9 +33,9 @@ public enum ShortcutCatalog {
ShortcutRow(keys: ["⌘", "→"], label: "Pass the selection to the agent"),
]),
ShortcutGroup(title: "Git", rows: [
ShortcutRow(keys: ["⌘", "G"], label: "Open or close the Git view"),
ShortcutRow(keys: ["⌘", "C"], label: "Focus the commit message"),
ShortcutRow(keys: ["⌘", "↵"], label: "Commit the staged files"),
ShortcutRow(keys: ["⌘", "G"], label: "Source Control column on or off"),
ShortcutRow(keys: ["⌘", "P"], label: "Push the current branch"),
]),
ShortcutGroup(title: "File", rows: [
@@ -46,7 +49,7 @@ public enum ShortcutCatalog {
ShortcutRow(keys: ["⌘", "+"], label: "Zoom in"),
ShortcutRow(keys: ["⌘", "−"], label: "Zoom out"),
ShortcutRow(keys: ["⌘", "0"], label: "Actual size"),
ShortcutRow(keys: ["Esc"], label: "Close an overlay or a split view"),
ShortcutRow(keys: ["Esc"], label: "Close an overlay, then the Git view"),
]),
]
}