Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
dbc9f78
feat: delete a tag here, or here and on its remote
progresshans Nov 30, 2026
2aae499
feat: restore a file the way a commit has it
progresshans Nov 30, 2026
df52bba
fix: git and its hooks run with the login shell's PATH, as in Terminal
progresshans Nov 30, 2026
f2e6d8b
feat: answer what ssh asks: a key's passphrase, a new host, a securit…
progresshans Nov 30, 2026
36072ba
feat: color the code in diffs by its language
progresshans Nov 30, 2026
1070a24
perf: a diff's code is colored when its rows are drawn, not for the w…
progresshans Nov 30, 2026
dc47b75
perf: showing another file in Review makes no new file list
progresshans Nov 30, 2026
2c7adc1
fix: a repository's first load doesn't wait for the login shell's PATH
progresshans Nov 30, 2026
792e060
perf: the buttons in a diff's hunk and file headers don't have the wi…
progresshans Nov 30, 2026
d6c75cf
perf: a diff's line row is its text over one drawing
progresshans Nov 30, 2026
49ec8be
Merge branch 'feature/delete-tags' into feature/five-gaps-and-faster-…
progresshans Nov 30, 2026
9d24b67
Merge branch 'feature/restore-file-version' into feature/five-gaps-an…
progresshans Nov 30, 2026
e216447
Merge branch 'feature/hooks-login-path' into feature/five-gaps-and-fa…
progresshans Nov 30, 2026
bc4ee4f
Merge branch 'feature/ssh-prompts' into feature/five-gaps-and-faster-…
progresshans Nov 30, 2026
1ea2f65
Merge branch 'feature/syntax-highlighting' into feature/five-gaps-and…
progresshans Nov 30, 2026
9a98c45
Merge branch 'feature/thin-diff-rows' into feature/five-gaps-and-fast…
progresshans Nov 30, 2026
b23ec7e
Merge branch 'feature/review-file-switch-does-less' into feature/five…
progresshans Nov 30, 2026
634ef0b
fix: Restore Version keeps an ignored file's contents, and leaves wha…
progresshans Nov 30, 2026
7fcc2d8
fix: ⌘Z takes back a symbolic link Restore Version restored
progresshans Nov 30, 2026
fd5d4c9
fix: each ssh's second passphrase question is its own retry, with two…
progresshans Nov 30, 2026
7f30001
test: t_linepick looks for the hunk's button, which a scroll bar moves
progresshans Nov 30, 2026
8c78187
fix: Discard keeps a file a staged deletion left on disk, and leaves …
progresshans Nov 30, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@ What changed in each version of Kaern. A version's section is what its update wi
- Settings › Open In: choose the editor and the terminal, leave out of the Open menus what you don't use, and add
any other app, a command to run in your terminal, or a link (Customize Menu… in the ▾ goes there). Open in
Terminal used to always open Terminal.
- Delete a tag from its right-click menu, in the sidebar or the history. Delete takes it from your repository, and
⌘Z brings it back. Delete Here and on origin… takes it from the remote too, after asking.
- Put a file back the way a commit has it: right-click the file in that commit and choose Restore Version at….
It lands in your changes, unstaged. The file's own changes go to Stashes first, and ⌘Z puts everything back. A
file the commit deleted comes back as it was just before.
- When ssh needs to ask something, Kaern asks you in a window: your SSH key's passphrase, whether to trust a server
it hasn't seen (with its key's fingerprint), or a security key's PIN. Kaern can remember the passphrase in your
Keychain; Settings › Advanced lists the keys and forgets them. Auto-fetch never asks: a locked key pauses it, and
the status bar says why.
- Diffs color the code by its language: keywords, strings, comments, numbers, types and functions, in Review, Focus,
file history and stashes, with the colors of Xcode's default themes. Swift, Objective-C, C and C++, C#, Java,
Kotlin, Go, Rust, JavaScript and TypeScript, Python, Ruby, PHP, shell scripts, SQL, HTML and XML, CSS, JSON, YAML,
TOML, Markdown, Dockerfiles, Makefiles and more. Settings › Diff turns it off.

### Improved

Expand All @@ -28,6 +41,9 @@ What changed in each version of Kaern. A version's section is what its update wi
its sections scrolls on its own, and so do the panel's Unstaged Files and Staged Files. While everything fits,
nothing changes. When it doesn't, drag the line between two of them to give one more room; Kaern keeps the
heights for next time, and a double-click on the line shares the room out again.
- Diffs scroll with less work: a file's lines take about a third less to bring into view, a file of many small
hunks about 40 % less, and All Files over many files about half. It shows most where scrolling a long diff
stuttered.

### Fixed

Expand All @@ -39,8 +55,28 @@ What changed in each version of Kaern. A version's section is what its update wi
the submodule out, as it does with `ignore = all`. It read "?" before.
- Quick Look opened again right after closing it (Space twice in a row) stays open. Before, it closed again at
once.
- Hooks find what your login shell finds. Kaern runs git with your login shell's PATH, as Terminal does, so a
pre-commit hook that calls npx, lint-staged or a tool from nvm, mise or `~/.local/bin` no longer fails with
"command not found" in Kaern only. The Command Log says when a command ran with it.
- Discard keeps a file that `git rm --cached` left on disk. Git lists such a file twice, as a staged deletion and
as a new file. Discarding the deletion put the committed file over it, and ⌘Z then deleted it. Now what was in
the file goes to Stashes with the rest, and ⌘Z brings it back. The same goes for a new file at a renamed file's
old name.
- Discard leaves what has taken a deleted file's place: a folder there with files of its own, or a file where the
deleted file's folder was. Git removes those to put the file back, so Kaern stops and names what is in the way.
- Before a repository's first commit, Discard deleted a new file without a copy, since git can't make a stash yet.
It discards nothing there now and says why.
- Discarding a file that became a folder of files, or a folder that became a file, works. It stopped with an error
before.
- An SSH failure says what happened. A key with a passphrase, or a server ssh hadn't seen, used to read as "SSH
key not accepted". A server whose host key changed now says how to check it, and a question you cancel ends
without an error.
- Blame on a file that a commit deleted, from that commit's right-click menu, shows the file as it was before the
commit. It showed an empty blame.
- A line number of five digits (from line 10,000 on, or a shorter one with a big diff font) no longer wraps onto a
second line and makes its row twice as tall: it is drawn a little narrower.
- In Split, when the diff's width leaves half a pixel over, the line between the two sides is straight. It stepped
a pixel left and right from row to row.

## [1.0.1] - 2026-11-19

Expand Down
5 changes: 3 additions & 2 deletions Kaern/App/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
// acts on commands a test run sends to its sample repositories.
if SessionStore.testSessionPath != nil { DebugDriver.shared.start() }
#endif
// Your login shell's PATH: git and its hooks run with it, and the agents in the terminal are found on it.
// Asked before the repositories open, so a command that can start a hook knows to wait for it.
LoginPath.load()
AppModel.shared.launch()
QuickLookCopies.removeOld()
VersionCopies.removeOld()
TerminalCommands.removeOld()
// The agents in the terminal are found on your login shell's PATH (OpenAgents).
LoginPath.load()
// Release builds only (UpdateController.isAvailable).
UpdateController.shared.start()
}
Expand Down
2 changes: 2 additions & 0 deletions Kaern/App/AppModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ final class AppModel {
runner = GitRunner(executableURL: resolution.url,
extraEnvironment: testEnvironment,
removedEnvironment: launchUsesSSHAgent ? [] : ["SSH_AUTH_SOCK"],
searchPath: LoginPath.searchPath,
askpass: AskpassServer.shared.start(),
onCommand: { CommandLog.receive($0) })
Self.log.info("Using git at \(resolution.url.path(percentEncoded: false), privacy: .public) (\(resolution.source.rawValue, privacy: .public)), version \(resolution.version ?? "unknown", privacy: .public)")
startRepositories()
Expand Down
45 changes: 45 additions & 0 deletions Kaern/App/DebugDriver+Askpass.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#if DEBUG
import AppKit
import KaernKit

/// Debug commands for what ssh asks (`AskpassCenter`): answer the question the window shows, cancel it, the Keychain
/// checkbox, and forgetting what's saved (a test instance keeps it in memory).
extension DebugDriver {
static let askpassCommands: Set<String> = ["askpassAnswer", "askpassCancel", "askpassRemember", "askpassForget"]

func askpassCommand(_ command: String, _ args: [String]) {
let center = AskpassCenter.shared
switch command {
case "askpassAnswer":
// askpassAnswer [text…]: what was typed; nothing for Connect and Allow.
let text = args.joined(separator: " ")
center.respond(text.isEmpty ? nil : text)
case "askpassCancel":
center.cancel()
case "askpassRemember":
center.remember = args.first != "off"
case "askpassForget":
SSHPassphrases.forgetAll()
default:
break
}
}

/// The question shown (its kind and words), how many wait, how many the window showed, and the saved keys.
func askpassDump() -> [String: Any] {
let center = AskpassCenter.shared
var result: [String: Any] = [
"shown": center.shownCount, "waiting": center.questions.count, "saved": SSHPassphrases.keys,
"remember": center.remember, "window": AskpassWindowController.shared.window?.isVisible ?? false,
]
if let question = center.current {
result["kind"] = String("\(question.kind)".prefix { $0 != "(" })
result["question"] = "\(question.kind)"
result["action"] = question.action
result["repository"] = question.repository
result["retry"] = question.retry
}
return result
}
}
#endif
13 changes: 13 additions & 0 deletions Kaern/App/DebugDriver+Phase5.swift
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,19 @@ extension DebugDriver {
func sizes(_ value: [String: LFSSizes]) -> [String: String] {
value.mapValues { "\($0.old.map(String.init) ?? "-")→\($0.new.map(String.init) ?? "-")" }
}
// The code of the file Review shows, colored: its language and each line's pieces (Settings › Diff).
if let path = repository.review?.path, let file = repository.reviewFiles?.first(where: { $0.path == path }) {
let rows = DiffRowItem.rows(for: file, layout: .unified, limit: 60, words: false, syntax: AppSettings.diffSyntax)
result["syntax"] = [
"language": SyntaxHighlighter.language(forPath: path)?.name ?? "",
"lines": rows.compactMap { row -> String? in
guard case .unified(_, let line, _, _, let syntax) = row else { return nil }
let characters = Array(line.text)
return (syntax?.spans(of: line) ?? []).map { "\($0.kind):" + String(characters[$0.range.clamped(to: 0..<characters.count)]) }
.joined(separator: " | ")
},
] as [String: Any]
}
result["marks"] = [
"lfs": sizes(repository.workingMarks.lfsSizes),
"pointers": repository.workingMarks.lfsPointers.sorted(),
Expand Down
14 changes: 14 additions & 0 deletions Kaern/App/DebugDriver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,15 @@ final class DebugDriver {
holds(command, args)
case _ where DebugDriver.frameCommands.contains(command):
frames(command, args)
case _ where DebugDriver.askpassCommands.contains(command):
askpassCommand(command, args)
case "sidebar":
window?.showsSidebar = args.first != "off"
case "details":
window?.showsDetails = args.first != "off"
case "loginPath":
// The login shell's PATH a check held back arrives (`-KaernLoginPathHeld YES`).
LoginPath.provideHeld()
case "pane":
// pane sidebar|panel|drawer|list <size> — keeps that size, as a drag does (0: the board's).
let keys = ["sidebar": PaneSizes.sidebarKey, "panel": PaneSizes.panelKey, "drawer": PaneSizes.drawerKey, "list": PaneSizes.listKey]
Expand Down Expand Up @@ -267,6 +272,12 @@ final class DebugDriver {
if rest.contains("option") { flags.insert(.option) }
click(at: CGPoint(x: x, y: y), count: rest.first.flatMap { Int($0) } ?? 1, flags: flags)
}
case "mouseDown", "mouseUp":
// mouseDown x y | mouseUp x y — half a click each (window points, top-left origin): a button held down,
// then let go of somewhere else.
if args.count >= 2, let x = Double(args[0]), let y = Double(args[1]) {
mouse(command == "mouseDown" ? .leftMouseDown : .leftMouseUp, at: CGPoint(x: x, y: y))
}
case "drag":
// drag x1 y1 x2 y2 [sequence reply-file]. A retry only acknowledges the same drag.
guard args.count == 4 || args.count == 6 else { return }
Expand Down Expand Up @@ -1188,6 +1199,7 @@ final class DebugDriver {
"recent": app.recent.map(\.name),
"phase5": phase5Dump(window),
"phase6": phase6Dump(window),
"askpass": askpassDump(),
// The global git config and credential helpers git sees (TestSession).
"gitConfigEnvironment": (app.runner?.environment ?? [:]).filter { $0.key.hasPrefix("GIT_CONFIG") },
// Kaern's settings as this instance reads them: launch arguments over its own store.
Expand Down Expand Up @@ -1226,6 +1238,8 @@ final class DebugDriver {
"lastCommand": entries.last?.id.uuidString ?? "",
"commandCount": entries.count,
"fetchingAll": AutoFetcher.shared.isFetchingAll,
// The login shell's PATH hasn't come yet (a check holds it back).
"loginPathHeld": LoginPath.isHeld,
// Popovers, menus, Settings, the Command Log…: what is on screen besides the main windows.
"visibleWindows": NSApp.windows.filter(\.isVisible).map { "\(type(of: $0)) \($0.title)" },
"firstResponder": responder.map { String(describing: type(of: $0)) } ?? "",
Expand Down
35 changes: 35 additions & 0 deletions Kaern/App/FailureHelp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,37 @@ struct FailureHelp {
fixTitle: "How to Add an SSH Key",
fix: { NSWorkspace.shared.open(URL(string: "https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account")!) },
short: "SSH key not accepted")
case .sshKeyLocked(let host):
let name = host ?? repository?.remoteHost ?? "the server"
return FailureHelp(
message: "Your SSH key for \(name) is locked, and Kaern asks for its passphrase only for what you start yourself"
+ (auto ? ", so auto-fetch for \(repositoryName) is paused. Fetch once to unlock it; Kaern can remember the passphrase in your Keychain."
: ". Fetch to unlock it."),
fixTitle: repository == nil ? nil : "Fetch",
fix: repository.map { model in { model.from("Command Log") { model.fetch() } } },
short: "SSH key locked")
case .hostKeyUnknown(let host):
let name = host ?? repository?.remoteHost ?? "the server"
return FailureHelp(
message: "ssh hasn’t seen \(name)’s host key before, and nobody confirmed it"
+ (auto ? ", so auto-fetch for \(repositoryName) is paused." : ".") + " Fetch to see the key and connect.",
fixTitle: repository == nil ? nil : "Fetch",
fix: repository.map { model in { model.from("Command Log") { model.fetch() } } },
short: "new SSH host")
case .hostKeyChanged(let host):
let name = host ?? repository?.remoteHost ?? "the server"
return FailureHelp(
message: "\(name)’s host key isn’t the one ssh knows for it. If \(name) announced a new key, remove the old one "
+ "(ssh-keygen -R \(name)) and connect again. If it didn’t, someone may be in between: don’t connect.",
fixTitle: "Copy the Command",
fix: {
NSPasteboard.general.clearContents()
NSPasteboard.general.setString("ssh-keygen -R \(name)", forType: .string)
},
short: "SSH host key changed")
case .promptCancelled:
return FailureHelp(message: "You cancelled what ssh asked, so \(repositoryName) didn’t connect.", fixTitle: nil, fix: nil,
short: "cancelled")
case .network(let host):
return FailureHelp(
message: "Kaern couldn’t reach \(host ?? "the server"). Check the connection or VPN, then try again.",
Expand Down Expand Up @@ -84,6 +115,10 @@ struct FailureHelp {
"\(host ?? "The server") didn’t accept your SSH key. Add it to your account there, or clone with the HTTPS URL."
case .network(let host)?:
"Kaern couldn’t reach \(host ?? "the server"). Check the connection or VPN, then try again."
case .hostKeyChanged(let host)?:
"\(host ?? "The server")’s host key isn’t the one ssh knows for it. If it announced a new key, remove the old one (ssh-keygen -R \(host ?? "host")) and clone again."
case .promptCancelled?:
"You cancelled what ssh asked, so nothing was cloned."
default:
nil
}
Expand Down
40 changes: 36 additions & 4 deletions Kaern/App/OpenAgents.swift
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ extension RepositoryModel {
enum LoginPath {
private static var folders: [String] = []
private static var asked = false
/// What git and its hooks run with: this PATH, once read, ahead of Kaern's own (`GitRunner.searchPath`).
nonisolated static let searchPath = GitSearchPath()

/// Your login shell (the one Terminal starts).
static let shell: String = {
Expand All @@ -287,24 +289,54 @@ enum LoginPath {
return nil
}

/// Asks the login shell for its PATH, once a launch; the agents are looked for again when it answers. A test
/// instance goes by the usual places.
/// Asks the login shell for its PATH, once a launch: git and its hooks get it (a command that can start a hook
/// waits for the answer), and the agents are looked for again. A test instance goes by the usual places, or by
/// the PATH a check gives it (`-KaernLoginPath`): at once, or, with `-KaernLoginPathHeld YES`, when the check
/// says so (`loginPath`), as a login shell that takes its time.
static func load() {
guard !asked else { return }
asked = true
#if DEBUG
if SessionStore.testSessionPath != nil { return }
if SessionStore.testSessionPath != nil {
if let given = UserDefaults.standard.string(forKey: "KaernLoginPath") {
if UserDefaults.standard.bool(forKey: "KaernLoginPathHeld") {
held = given
searchPath.expect()
} else {
folders = given.split(separator: ":").map(String.init).filter { !$0.isEmpty }
searchPath.provide(given)
}
}
return
}
#endif
searchPath.expect()
let shell = shell
Task.detached(priority: .utility) {
guard let path = readPath(shell) else { return }
let path = readPath(shell)
searchPath.provide(path)
guard let path else { return }
await MainActor.run {
folders = path.split(separator: ":").map(String.init).filter { !$0.isEmpty }
OpenAgents.refresh()
}
}
}

#if DEBUG
/// The PATH a check holds back until it says `loginPath` (`-KaernLoginPathHeld YES`).
private static var held: String?
static var isHeld: Bool { held != nil }

/// The held PATH arrives, as the login shell's answer does.
static func provideHeld() {
guard let given = held else { return }
held = nil
folders = given.split(separator: ":").map(String.init).filter { !$0.isEmpty }
searchPath.provide(given)
}
#endif

/// The shell's PATH, written to a file so what its setup prints doesn't matter; nothing after 6 s.
nonisolated private static func readPath(_ shell: String) -> String? {
let file = FileManager.default.temporaryDirectory.appending(path: "kaern-path-\(UUID().uuidString)")
Expand Down
3 changes: 3 additions & 0 deletions Kaern/App/main.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import AppKit

// Started by ssh as its asker (`GitAskpass`): hand the question to the running Kaern, print the answer, end here.
AskpassClient.runIfAsked()

// Kaern runs on the AppKit app lifecycle: it creates its windows itself from its session file,
// and its menus are AppKit menus validated against the current window (see `MainMenu`).
let application = NSApplication.shared
Expand Down
Loading