adds claude-generated commit messages and a recent commits panel to the git view - adds log tailing in the explorer, branch merging and a clean up button

This commit is contained in:
2026-11-04 10:07:52 +01:00
parent 600d4874d2
commit cc6651c08a
49 changed files with 1944 additions and 180 deletions
+78 -41
View File
@@ -2,7 +2,7 @@ import AppKit
import HelderCore
import SwiftUI
/// The message field over the author, the ⌘↵ hint and the Commit split button.
/// The message field over Gen. Commit Message, the author, the ⌘↵ hint and the three commit buttons.
struct GitCommitBlock: View {
let model: WorkspaceModel
let store: SourceControlStore
@@ -22,12 +22,13 @@ struct GitCommitBlock: View {
}
.animation(Metrics.colorTransition, value: isFocused)
HStack(spacing: 16) {
GenerateMessageButton(model: model, store: store)
if let author = store.author {
Text(author).typeRole(Typography.path).foregroundStyle(Palette.textMuted).lineLimit(1)
}
Text("⌘↵ commits").typeRole(Typography.path).foregroundStyle(Palette.text4).fixedSize()
Spacer(minLength: 0)
CommitSplitButton(model: model, store: store)
CommitButtons(model: model, store: store)
}
.padding(.leading, 16)
.padding(.trailing, 14)
@@ -43,57 +44,93 @@ struct GitCommitBlock: View {
}
}
/// `Commit N files` plus a caret that opens Commit / Commit and push. Amber only when git would accept it,
/// but both parts always run, so git's own refusal shows in the console.
private struct CommitSplitButton: View {
/// `Gen. Commit Message`: the Claude CLI writes the message for the staged changes. Dims while nothing is staged
/// and while a message is being written.
private struct GenerateMessageButton: View {
let model: WorkspaceModel
let store: SourceControlStore
@State private var mainHovered = false
@State private var caretHovered = false
@State private var caretFrame = CGRect.zero
@State private var hovered = false
var body: some View {
let ready = store.canCommitNow
let count = store.stagedPathCount
HStack(spacing: 0) {
Button { model.perform(.commit) } label: {
Text(count > 0 ? "Commit \(count) file\(count == 1 ? "" : "s")" : "Nothing staged")
let color = hovered ? Palette.text1 : Palette.text3
Button { model.perform(.generateCommitMessage) } label: {
HStack(spacing: 7) {
SparkGlyph()
.stroke(color, style: StrokeStyle(lineWidth: 1.1 * 12 / 16, lineJoin: .round))
.frame(width: 12, height: 12)
Text(store.isGeneratingMessage ? "Generating…" : "Gen. Commit Message")
.typeRole(Typography.gitCommitButton)
.padding(.horizontal, 18)
.frame(minWidth: GitMetrics.commitButtonMinWidth)
.frame(height: GitMetrics.commitButton)
.background(fill(ready: ready, hovered: mainHovered))
.contentShape(Rectangle())
.foregroundStyle(color)
}
.buttonStyle(.plain)
.pointerHand()
.tracksHover($mainHovered)
Button(action: openMenu) {
GitIconView(icon: .chevronDown, size: 14)
.frame(width: GitMetrics.commitButton, height: GitMetrics.commitButton)
.background(fill(ready: ready, hovered: caretHovered))
.overlay(alignment: .leading) { Rectangle().fill(Palette.editor).frame(width: Metrics.hairline) }
.contentShape(Rectangle())
}
.buttonStyle(.plain)
.pointerHand()
.tracksHover($caretHovered)
.background(GlobalFrameReader(frame: $caretFrame))
.padding(.horizontal, 12)
.frame(height: GitMetrics.commitButton)
.background(hovered ? Palette.hover : .clear, in: RoundedRectangle(cornerRadius: Metrics.radiusSmall))
.overlay(RoundedRectangle(cornerRadius: Metrics.radiusSmall).strokeBorder(Palette.raised, lineWidth: Metrics.hairline))
.contentShape(Rectangle())
}
.buttonStyle(.plain)
.pointerHand()
.tracksHover($hovered)
.disabledLook(!store.canGenerateMessage)
.fixedSize()
}
}
/// `Add, Stage & Commit` and `Commit N files` beside the primary `Commit and push`. The last two dim while nothing is staged;
/// with files staged they always run, so git's refusal of an empty message shows in the console.
private struct CommitButtons: View {
let model: WorkspaceModel
let store: SourceControlStore
@State private var stageAllHovered = false
@State private var commitHovered = false
@State private var pushHovered = false
var body: some View {
let count = store.stagedPathCount
HStack(spacing: 8) {
secondaryButton("Add, Stage & Commit", command: .stageAllAndCommit, hovered: $stageAllHovered)
.disabledLook(!store.canStageAllAndCommit)
HStack(spacing: 8) {
secondaryButton(count > 0 ? "Commit \(count) file\(count == 1 ? "" : "s")" : "Nothing staged",
command: .commit, hovered: $commitHovered)
Button { model.perform(.commitAndPush) } label: {
Text("Commit and push")
.typeRole(Typography.gitCommitButton)
.foregroundStyle(store.canCommitNow ? Palette.badgeText : Palette.textMuted)
.padding(.horizontal, 18)
.frame(height: GitMetrics.commitButton)
.background(pushFill, in: RoundedRectangle(cornerRadius: Metrics.radiusSmall))
.contentShape(Rectangle())
}
.buttonStyle(.plain)
.pointerHand()
.tracksHover($pushHovered)
}
.disabledLook(count == 0)
}
.foregroundStyle(ready ? Palette.badgeText : Palette.textMuted)
.clipShape(RoundedRectangle(cornerRadius: Metrics.radiusSmall))
.fixedSize()
}
private func fill(ready: Bool, hovered: Bool) -> Color {
if ready { return hovered ? Palette.amberDeep : Palette.amber }
return hovered ? Palette.commitIdleHover : Palette.raised
private func secondaryButton(_ title: String, command: Command, hovered: Binding<Bool>) -> some View {
Button { model.perform(command) } label: {
Text(title)
.typeRole(Typography.gitCommitButton)
.foregroundStyle(hovered.wrappedValue ? Palette.text1 : Palette.text3)
.padding(.horizontal, 18)
.frame(minWidth: GitMetrics.commitButtonMinWidth)
.frame(height: GitMetrics.commitButton)
.background(hovered.wrappedValue ? Palette.hover : .clear, in: RoundedRectangle(cornerRadius: Metrics.radiusSmall))
.overlay(RoundedRectangle(cornerRadius: Metrics.radiusSmall).strokeBorder(Palette.raised, lineWidth: Metrics.hairline))
.contentShape(Rectangle())
}
.buttonStyle(.plain)
.pointerHand()
.tracksHover(hovered)
}
/// The menu hangs under the caret, right-aligned to it.
private func openMenu() {
let anchor = CGPoint(x: caretFrame.maxX - Metrics.contextMenuWidth, y: caretFrame.maxY + 4)
model.perform(.showContextMenu(.commitMenu, anchor: anchor))
private var pushFill: Color {
if store.canCommitNow { return pushHovered ? Palette.amberDeep : Palette.amber }
return pushHovered ? Palette.commitIdleHover : Palette.raised
}
}