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
+34 -15
View File
@@ -9,8 +9,8 @@ public enum ContextTarget: Sendable, Equatable {
case directory(path: String)
/// A file row in the Git view; a deleted file has nothing to open.
case gitRow(path: String, isDeleted: Bool)
/// The caret beside the Git view's Commit button.
case commitMenu
/// A row in the Git view's Branches panel; `current` is the checked-out branch.
case branch(name: String, remote: Bool, current: String, isDirty: Bool)
/// The empty space under the tree: the project folder itself.
case projectRoot
case terminal(TerminalKind, hasSelection: Bool)
@@ -19,7 +19,7 @@ public enum ContextTarget: Sendable, Equatable {
switch self {
case let .editor(reference, _, _): reference.path
case let .file(path), let .directory(path), let .gitRow(path, _): path
case .projectRoot, .terminal, .commitMenu: ""
case .projectRoot, .terminal, .branch: ""
}
}
}
@@ -36,7 +36,8 @@ public enum ContextAction: Sendable, Equatable {
case openFile(String)
/// Reverts unstaged changes: modified and deleted files come back from the index, new files are removed.
case gitDiscard([String])
case commit(andPush: Bool)
/// The Git view's Clean up: every unstaged change reverted to the index, every untracked file and folder removed.
case gitCleanUp
/// Opens the Diff of the open file at this line.
case showDiff(String, line: Int)
case rename(String, isDirectory: Bool)
@@ -52,16 +53,20 @@ public enum ContextAction: Sendable, Equatable {
case bouwen(String)
/// Reads a Markdown file's prose aloud.
case readAloudFile(String)
/// Runs `tail -f` on a `.log` file in the Explorer's tail block, replacing any running tail.
case tailLog(String)
case readAloudText(String)
/// Sends the editor selection to Plak as it is, code and all.
case plak(String)
/// Sends the pane's selection to Plak; the text is fetched when the item runs.
case plakTerminalSelection(TerminalKind)
/// Merges this branch into the current one.
case mergeBranch(String)
/// Destructive items read in amber-deep.
public var isDestructive: Bool {
switch self {
case .gitDiscard, .delete: true
case .gitDiscard, .gitCleanUp, .delete: true
default: false
}
}
@@ -69,7 +74,7 @@ public enum ContextAction: Sendable, Equatable {
/// The menu's main item, set in bold.
public var isEmphasized: Bool {
switch self {
case .openFile, .commit(andPush: true): true
case .openFile: true
default: false
}
}
@@ -78,7 +83,15 @@ public enum ContextAction: Sendable, Equatable {
/// A menu entry, or a separator between groups.
public enum ContextMenuEntry: Sendable, Equatable {
case action(ContextAction, label: String)
/// Shown dimmed with its `hint` as tooltip; the keyboard skips it and a click does nothing.
case disabled(ContextAction, label: String, hint: String)
case separator
/// The keyboard can land on it.
public var isSelectable: Bool {
if case .action = self { return true }
return false
}
}
public enum ContextActions {
@@ -86,8 +99,9 @@ public enum ContextActions {
public static func header(for target: ContextTarget, projectName: String) -> String {
switch target {
case let .file(path), let .gitRow(path, _): path
case let .branch(name, _, _, _): name
case .projectRoot: projectName + "/"
case .editor, .directory, .terminal, .commitMenu: ""
case .editor, .directory, .terminal: ""
}
}
@@ -110,7 +124,7 @@ public enum ContextActions {
.action(.revealInFinder(""), label: "Show in Finder"),
]
case let .file(path):
return fileHead(path) + readAloudFile(path) + [
return fileHead(path) + readAloudFile(path) + tailLog(path) + [
.separator,
.action(.rename(path, isDirectory: false), label: "Rename file"),
.action(.revealInFinder(path), label: "Show in Finder"),
@@ -136,19 +150,20 @@ public enum ContextActions {
.separator, .action(.plakTerminalSelection(kind), label: "Plak")] : []
let waitWhat: [ContextMenuEntry] = hasSelection && kind == .agent
? [.separator, .action(.waitWhat(kind), label: "Wait what?")] : []
return (hasSelection ? [.action(.copyTerminalSelection(kind), label: "Copy")] : [])
+ [.action(.pasteIntoTerminal(kind), label: "Paste")] + readAloud + waitWhat
let paste: [ContextMenuEntry] = kind == .tail ? [] : [.action(.pasteIntoTerminal(kind), label: "Paste")]
return (hasSelection ? [.action(.copyTerminalSelection(kind), label: "Copy")] : []) + paste + readAloud + waitWhat
case let .gitRow(path, isDeleted):
let open: [ContextMenuEntry] = isDeleted ? [] : [.action(.openFile(path), label: "Open in editor"), .separator]
return open + [
.action(.passOnReference(path, code: nil), label: "Pass on reference"),
.action(.copyReference(path), label: "Copy reference"),
]
case .commitMenu:
return [
.action(.commit(andPush: false), label: "Commit"),
.action(.commit(andPush: true), label: "Commit and push"),
]
case let .branch(name, remote, current, isDirty):
if !remote && name == current { return [] }
let label = "Merge into \(current)"
return [isDirty
? .disabled(.mergeBranch(name), label: label, hint: "Commit or discard your changes first")
: .action(.mergeBranch(name), label: label)]
}
}
@@ -163,6 +178,10 @@ public enum ContextActions {
FileType.isMarkdown(path) ? [.separator, .action(.readAloudFile(path), label: "Read aloud")] : []
}
private static func tailLog(_ path: String) -> [ContextMenuEntry] {
(path as NSString).pathExtension.lowercased() == "log" ? [.separator, .action(.tailLog(path), label: "Tail log")] : []
}
/// Selected Markdown is read as prose; a selection with no prose left, such as one code block, is read as it is.
private static func readAloudSelection(_ code: String, path: String) -> [ContextMenuEntry] {
let prose = FileType.isMarkdown(path) ? MarkdownSpeech.plainText(MarkdownParser.parse(code)) : ""