Skip to content

Tags, file versions, hooks' PATH, ssh's questions, colored code, and lighter diffs - #10

Merged
progresshans merged 22 commits into
developfrom
feature/five-gaps-and-faster-diffs
Dec 2, 2026
Merged

progresshans merged 22 commits into
developfrom
feature/five-gaps-and-faster-diffs

Conversation

@progresshans

Copy link
Copy Markdown
Owner

Five things a local Git client was missing, and diffs that open and scroll with less work. Tags can be deleted, a file can be put back the way a commit has it, hooks run with the login shell's PATH, Kaern answers what ssh asks, and diffs color their code. Then a speed pass over all of it: opening a file, showing the next one, scrolling a diff and a repository's first load each do less.

Seven branches are merged here, one merge commit each, because they change the same files (CHANGELOG, suite.py, GitRunner, AppModel, the diff's rows) and were tried together as one build. A feature can still be taken out by reverting its merge.

Why

  • A review against GitKraken and Fork turned up gaps that send you back to a terminal: a tag can't be deleted, a file can't be taken back to an older version, a hook that calls a tool from nvm or mise fails in Kaern only, a key with a passphrase reads as "SSH key not accepted", and a diff is one color.
  • With the code colored, files opened slowly. Measuring found three causes, one of them in the hooks work, and then that scrolling a diff was heavy with or without colors.

Change

  • Delete a tag (feature/delete-tags). A tag's right-click menu has Delete and Delete Here and on origin….
    • Delete is undone with ⌘Z, an annotated tag's message included.
    • Deleting on the remote asks first. Kaern asks the remote whether it has the tag before pushing the deletion, because git reports success for a tag that isn't there; then it deletes here only and says so.
  • Restore Version at… (feature/restore-file-version), in a commit's file menu. The version lands in the working copy, 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 before.
  • Hooks find what the login shell finds (feature/hooks-login-path). git runs with the login shell's PATH ahead of the app's own (GitSearchPath, shared by every copy of the runner).
    • A command that can start a hook waits while the app is still reading that PATH.
    • The Command Log says when a command ran with it.
    • A repository's first load doesn't wait: git worktree list counted as a command that starts hooks, so every launch held each tab on "loading" until the login shell had answered. Of git worktree, only add waits now.
  • Kaern answers what ssh asks (feature/ssh-prompts). SSH_ASKPASS is Kaern's own executable, which hands the question to the running app over a Unix socket with a token.
    • A window asks for a key's passphrase, whether to trust a new host (with its fingerprint), or a security key's PIN. A wrong passphrase is asked again.
    • The passphrase can be kept in the Keychain; Settings › Advanced lists the keys and forgets them.
    • A command Kaern runs on its own, auto-fetch for one, never shows a window: it stops with a note, and the status bar says why.
    • Failures say what happened: a locked key, an unknown host, a changed host key, a cancelled question (no error).
    • git's own HTTPS questions are turned down, so Sign In works as before.
  • Diffs color their code (feature/syntax-highlighting). A lexer in KaernKit, no dependency: about 30 languages as tables and line rules, with the colors of Xcode's default themes. Settings › Diff turns it off.
    • A line is colored when its row is drawn, a hunk side at a time, not the whole file before the first screenful shows.
    • The Focus drawer, a file's history and a stash keep their rows as Review does. They made them again on every pass.
  • Showing another file in Review makes no new file list (feature/review-file-switch-does-less). Every change of Review's state remade the list, with all its hunks; only a change of the compare does now. The check for a Git LFS pointer looks before it copies a diff's lines.
  • Diffs scroll with less work (feature/thin-diff-rows).
    • A Button in a lazy list has SwiftUI work out the window's keyboard focus order again each time one scrolls in or out. Stage Hunk / Unstage Hunk and the two halves of a file header's Open button are now labels that act as a plain button does (plainPress): the same look idle, held down and disabled, and letting go elsewhere does nothing. They are no longer stops of Full Keyboard Access's Tab; VoiceOver has them as buttons.
    • A line row was about forty views. It is its texts, placed by one layout, over one drawing of the numbers, gutters, ✓, fills and stripes.
    • Two things the old rows did are gone: a line number of five digits wrapped and made its row two lines tall (it is drawn narrower), and on a width that leaves half a pixel over, the line between Split's sides stepped a pixel from row to row.
  • Debug driver and checks: new checks t_tags, t_restore, t_loginpath, t_sshprompts, t_syntax and t_linepick.
    • t_loginpath holds the login PATH back, as a slow shell does (-KaernLoginPathHeld, loginPath). A test instance was given its PATH at once, which is why no check saw the first load wait.
    • t_linepick picks lines and presses the hunk button with clicks through the window (mouseDown, mouseUp). The other checks pick lines by asking the model.
  • CHANGELOG: entries under New, Improved and Fixed.

Measured

In a Debug test instance, in millions of instructions (wall time moves with what else the Mac does):

before after
Open a 1,689-line Swift file in Review, colors on 1,540 about 870
The same in the Focus drawer 1,100 about 490
Scroll 9,600 pt, Split, a file of 188 small hunks 12,500 7,250
Scroll 9,600 pt, Split, one hunk of 1,700 lines 8,500 5,900
Scroll 9,600 pt, Unified, a file of 188 small hunks 11,100 7,000
Scroll 9,600 pt, All Files over 80 small files 18,400 9,200

Checked

  • The tree of this branch is the tree of the build that was tried (the same tree hash).
  • With the five features merged, before the speed pass: all 58 flow checks, KaernKit's 228 tests, and Debug and Release builds without warnings.
  • After each later change, the checks of what it touches. On the final tree: t_linepick, t_openin, t_syntax, t_marks, t_sidescroll, t_stash, t_explore, t_review5, t_review7, t_arrows, t_loginpath, t_sshprompts, t_tags, t_restore, t_firstload and t_isolation passed; so did KaernKit's suites for the lexer, the login PATH and the LFS pointer check.
  • The new line rows against the old ones, pixel by pixel: 38,282 pairs of pictures (Split and Unified, with and without line picking, picked lines, wrapped, on one line, scrolled sideways, four widths, light and dark), and again at 125 % zoom and with a 16 pt font. On widths of whole pixels every pair is the same but for the five-digit numbers. In the window, fills come out one or two of 255 off.
  • The hunk button as a label against the Button: pictures of the window idle and held down are the same to the pixel.
  • t_loginpath on the code before the first-load fix stopped at the launch, the tabs still loading after 60 s.

Not checked

  • The full flow suite and the Release build on the final tree: left to this PR's CI.
  • ssh with a real key that has a passphrase, and the real Keychain. The check uses a stand-in ssh that asks as ssh does, and a test instance keeps passphrases in memory.
  • A real login shell in a check: the check gives a stand-in PATH.
  • Scrolling with the pointer over the diff. A test instance ignores the pointer, and hover was the larger cost when the history list was measured.

🤖 Generated with Claude Code

progresshans and others added 17 commits November 30, 2026 15:42
A tag's right-click menu (the sidebar's Tags, a tag's label in the history) had no way to delete it: only ⌘Z right
after Create Tag Here… did. It now has, as a branch's menu does:

- Delete (⌫): the tag goes from the repository, and ⌘Z makes it again with the object it had, so an annotated tag
  keeps its message and signature (⇧⌘Z deletes it again while it's still that one). The remote keeps its copy, so a
  fetch brings the tag back while the remote has it.
- Delete Here and on origin…: asks first, since Kaern can't undo a change on a remote, then deletes it there and
  here. A tag the remote doesn't have goes from here only, and the toast says so.

KaernKit's deleteRemoteTag names the tag in full (refs/tags/<name>), so a branch with the same name stays, and asks
the remote first with ls-remote, because a push deleting a ref the remote doesn't have succeeds all the same.

Checked: a KaernKit test (delete, restore as the same annotated tag, delete on a bare remote beside a same-named
branch, and again when it's gone) and the new flow check t_tags (both menu items, ⌘Z, ⇧⌘Z, the question, a tag
only here); both passed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A commit's file (its details, Review's chips and headers) can be opened at that version, but there was no way to put
the file back that way. Its right-click menu now has Restore Version at <commit>, below Open Version at:

- The version goes into the working copy, unstaged: the index keeps HEAD's, so the change shows in Unstaged Files to
  review and stage.
- The file's own changes, staged or not, go to Stashes first, as Discard keeps them ("Before restoring <file> from
  <commit>"), and the toast says so.
- ⌘Z takes the version back while the file is still it, then puts the file's changes back and drops the kept copy;
  ⇧⌘Z restores it again. A file HEAD doesn't have goes again.
- A file the commit deleted restores the version before, from the parent (the version Open Version at and Blame at
  already use there), and comes back as a new file.

KaernKit: restoreVersion(of:at:message:) (discard with a kept copy, then git restore --source=<commit> --worktree,
so filters such as LFS apply) and undoRestore. A file with conflicts is refused.

Checked: KaernKit tests (a clean file, one with staged and unstaged changes, a file HEAD deleted, ⌘Z refused once the
file changed, a path the commit hasn't) and the new flow check t_restore (the menu item, the index, the kept copy,
⌘Z, ⇧⌘Z, a deleted file from the parent); all passed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Kaern ran git with the PATH a Mac app gets (/usr/bin:/bin:/usr/sbin:/sbin) and the Homebrew folders. A hook that calls
npx, lint-staged, pre-commit or anything from nvm, volta, asdf, mise, pyenv or ~/.local/bin found nothing there, and
the commit failed with "command not found" in Kaern only, while Terminal committed fine.

LoginPath already asks the login shell for its PATH once a launch, for the agents; git gets it too now:

- KaernKit's GitSearchPath, shared by every copy of the runner (GitRunner.searchPath): the app says it's reading the
  PATH (expect) and hands it over (provide). Each command runs with the login shell's folders first, then Kaern's own;
  `git log`'s stream too.
- A command that can start a hook (commit, merge, rebase, cherry-pick, revert, am, push, pull, checkout, switch,
  worktree, clone) waits while the PATH is being read, so one in Kaern's first moments doesn't fail where Terminal
  wouldn't. Others go on at once. A shell that can't be read (6 s) leaves Kaern's PATH, as before.
- LoginPath is asked before the repositories open. git-lfs found only on that PATH counts as installed.
- The Command Log says "PATH from your login shell" for a command that ran with it.
- A test instance goes by Kaern's PATH, or by the one a check gives it (-KaernLoginPath).

Checked: KaernKit tests (a pre-commit hook fails on Kaern's PATH, then waits for and finds its tool on the login
shell's; an unreadable shell changes nothing; the folders' order) and the new flow check t_loginpath (a hook calling a
tool only the given PATH has lets Kaern's commit through), with t_openin, t_firstload, t_activity, t_historyfail and
t_isolation; all passed, and the build has no warnings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…y key

git starts ssh without a terminal, and ssh had no one to ask. A key with a passphrase (not in the agent or the
Keychain) and a server ssh hadn't seen both failed, and Kaern said the server didn't accept the SSH key.

Now ssh asks Kaern (KaernKit's GitAskpass): every command runs with SSH_ASKPASS set to Kaern's own executable and
SSH_ASKPASS_REQUIRE=force. Started that way (KAERN_ASKPASS set), Kaern doesn't start the app: it hands the question
to the running one over a Unix socket in the temporary folder, with a token, and prints the answer (main.swift,
AskpassClient). The app answers on the main actor, one question at a time (AskpassCenter), in a window over its
windows (AskpassWindowController), since a question can come from a repository no window shows:

- A passphrase: Unlock, with "Remember in my Keychain" (one item per key file). A saved one answers by itself; asked
  again by the same ssh, it was wrong, so it goes and you're asked, "That passphrase didn't unlock the key".
- A new host: its key type and fingerprint, Connect or Cancel; ssh then remembers it.
- A security key's PIN, a touch notice (gone when ssh ends it), a yes-or-no, anything else as typed.
- A background command (auto-fetch, refreshes) gets no window: a saved passphrase still answers, otherwise the asker
  leaves a note on ssh's error output and the command fails.
- git's own HTTPS questions are turned down, so Sign In works as before (git's "unable to read askpass response"
  line is left out of the message). core.askPass and GIT_ASKPASS, when set, still come first.
- A question whose asker goes away (ssh ended it, Stop) leaves the window.

GitFailure tells the new cases apart: a locked key in the background, a host key nobody confirmed, a changed host
key (the message says how to check it and copies ssh-keygen -R), and a question you cancelled, which ends the
command without an alert and notes no fetch problem. The first three pause auto-fetch, as a rejected key does.
Settings › Advanced › SSH says what Kaern does and lists the keys whose passphrase it remembers, with Forget. A test
instance keeps passphrases in memory, never in the Keychain, and its window sits beside the screen like the others.

Checked: KaernKit tests (the prompts read, the failures told apart, the variables reaching a stand-in ssh with what
the user did or nothing in the background, git's own question turned down) and the whole KaernKit suite (214), and
the new flow check t_sshprompts in light and dark: a stand-in ssh (core.sshCommand) asks through the real asker; the
new host, Connect, a wrong passphrase asked again, the right one remembered, the next fetch without a question,
Cancel without an alert, and auto-fetch failing on the locked key without a window and pausing. Also t_activity,
t_shallow, t_clone, t_settings, t_isolation, t_pullrebase, t_publishfail and t_remotemore; all passed, no warnings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffs showed code in one color. Review, Focus's drawer, file history and stashes now color keywords, strings,
comments, numbers, types, functions, attributes and directives, with the colors of Xcode's default light and dark
themes (K.syn…), on top of the line and changed-word backgrounds. Settings › Diff › "Color the code: keywords,
strings, comments" turns it off (KaernDiffSyntax, on by default).

KaernKit's SyntaxHighlighter reads a line at a time, so it needs nothing but the lines a diff has: each language is
a table (keywords, types, constants, comments, quotes) plus a few rules a line can follow: attributes and decorators,
preprocessor lines and directives, $variables, YAML/TOML/INI keys and sections, JSON keys, CSS properties and colors,
Rust lifetimes and macros, a markup reader for HTML/XML (tags, attributes, entities, comments) and one for Markdown
(headings, lists, quotes, code). A comment or string that goes on carries to the next line; the old side (unchanged
and deleted lines) and the new side (unchanged and added lines) of a hunk are each read in order, and unchanged lines
take the new side's colors. A quote right after a letter starts no string in YAML and shell scripts (Kaern's, don't).
Lines over 1,500 characters (minified code) aren't colored. The language comes from the file's name or extension;
other files stay as they were. No dependency: about 30 languages in one file, 20,600 lines of Swift in 0.09 s
(release build).

DiffRowItem carries each line's colors next to its changed words, built once per file in Review's row cache; the
dump's phase5 `syntax` lists the colored pieces of the file Review shows.

Checked: KaernKit tests (the language by name; Swift, Python, JavaScript, C, YAML, shell, JSON, HTML, Markdown, Rust,
Lua and SQL lines; carried comments and strings; long lines) and the new flow check t_syntax in light and dark (a Swift
file in Split and Unified, a workflow's YAML keys, the setting off and on), with the review, explore, stash and settings
checks. Not a full parser: a hunk that starts inside a comment or a string colors its first lines as code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…hole file first

Opening a file with colored code took about twice the work of opening it without: the rows of the whole file (up to
2,000 lines of it) are made to show the forty that fit, and every line of them was read by the highlighter first, on
the main thread, the unchanged lines twice (once for each side). The Focus drawer, a file's history and a stash did it
again on every pass of their views, as they kept no rows.

Now a row carries where to ask for its colors (HunkSyntax), and a hunk's side is read when one of its rows is drawn,
as far down as that row and a hundred lines more (KaernKit's SyntaxLines: what a line is depends only on the lines
before it). The Focus drawer, the file history and the stash view keep their rows as Review does (DiffRowCache, now
beside the rows), so the word-by-word comparison of edited lines isn't redone on every pass there either. A line's
length is checked in bytes before its Characters are counted.

Measured in a Debug test instance on a 1,689-line Swift file with 188 hunks, in millions of instructions (colors
off in brackets): Review, One File 1,540 → 930 (740); the Focus drawer 1,100 → 480 (440); the same file as a new
one in the drawer 610 → 190 (145). What is left is per line on screen.

SyntaxTests reads 5,000 lines a line at a time, in and out of order, against reading them all; the checks that
show diffs passed (t_syntax, t_sidescroll, t_explore, t_stash, t_arrows, t_marks, t_review7, t_openin).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Every change of Review's state counted as new input for the files it lists, so showing another file (or one file
instead of all) made the whole list again: each file of the selection with its hunks, compared with the last list
hunk by hunk. Of that state the files are made from the compare alone; now only a change of the compare counts.

Making the list also asked every file's diff whether it is a Git LFS pointer, twice, and each ask copied all the
diff's lines three times over to look for a pointer's first line. The lines are now looked through first and copied
only when that line is there. This still runs when the files do change: a refresh of the working copy while Review
or the Focus drawer shows it, another commit.

Sampled in a Debug test instance while Review went through three files 18 times (a working copy with two
1,700-line Swift files): making the list took 153 of 3,157 ms of the main thread's work, now 3 of 3,441.

IndicatorTests: an ordinary diff, a line that only mentions a pointer's first line, and a file that became a
pointer. The checks of Review and the marks passed (7).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The commands that wait while the app reads the login shell's PATH (the ones that can start a hook) included all of
`git worktree`, and `git worktree list` is part of every repository's first load. So at every launch each tab stayed
on "loading", its history read but not shown, until the login shell had answered: about half a second with an
ordinary zsh setup, up to the six seconds Kaern gives a slow one. Of `git worktree` only `add` waits now (it checks
out, which runs post-checkout); `GitSearchPath.waits(for:)` decides.

The flow checks never saw it: a test instance was given its PATH at once. t_loginpath now holds it back, as a login
shell that takes its time (`-KaernLoginPathHeld YES`, given with the driver's `loginPath`): every tab has to be past
its first load before it comes, and the commit started meanwhile waits for it and then finds the hook's tool. On
the code before this the check stopped at the launch, the tabs still loading after 60 s.

SearchPathTests lists a repository's worktrees while the PATH is still expected. t_loginpath, t_firstload,
t_isolation, t_worktreemenu, t_nestedworktree and t_activity passed.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ndow's focus order worked out again

A `Button` takes part in the window's keyboard focus order, and each one that comes into a lazy list or leaves it
has SwiftUI work that order out again over every control in the window (FocusBridge.updateDefaultKeyViewLoop). A
diff scrolls its buttons in and out all the time: Stage Hunk / Unstage Hunk on every hunk of a working copy's file,
and the two halves of the Open button on every file header of All Files. Scrolling All Files over many small files
spent a quarter of its work there; a `Button` on a hunk cost as much as four line rows. Neither a button style of
its own nor `.focusable(false)` changes that.

These three are now labels that act as a plain button does (`plainPress`, Views/Common/PlainPress.swift): held down
the label dims to three quarters, letting go over it runs the action, letting go elsewhere doesn't, disabled it is
at half and takes no press, and VoiceOver has it as a button. Pictures of the window with the hunk button idle and
held down are the same to the pixel as with the `Button`. What is given up: these three are no stops of Full
Keyboard Access's Tab.

In millions of instructions for 9,600 pt of scrolling in a Debug test instance: a file of 188 small hunks, Split,
12,500 → 10,200; All Files over 80 small files 18,400 → 11,700, the turns longer than 16 ms 46 → 22.

t_linepick is new: clicks through the window pick lines in Split (each side its own) and Unified, with ⌘ and ⇧, an
unchanged line picks nothing, and Unstage Hunk unstages on a click and does nothing when let go of elsewhere (the
driver's new `mouseDown` / `mouseUp`). The other checks picked lines by asking the model. It passed, with t_openin
(which clicks both halves of the Open button) and t_review7.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
A line row was about forty views: the line numbers in their gutters, the ✓ of a staged line, a unified line's
marker, the fills, the stripes of a side without a line and the accent edge of a picked one, in stacks inside
stacks with flexible frames, and an empty tooltip on every text. Making and measuring them as they scroll into
view was most of what scrolling a diff cost. Now a row is its texts, put in their columns by one layout that
measures each once (DiffRowLayout), over one drawing of everything else (DiffRowDrawing, a Canvas, redrawn only
when what it shows changes). In Split a click still picks the side it is on: each changed side has its own area.

The drawing puts every piece where the views were, to the pixel. Compared in a test instance, the old rows kept
beside the new ones while this was written (ImageRenderer pairs of the working copy's 11 files: Split and Unified,
with and without line picking, picked lines, wrapped, on one line, scrolled sideways, four widths, light and dark,
38,282 pairs, and again at 125 % zoom and with a 16 pt font): on widths of whole pixels every pair is the same but
for two things, both the old rows':
- A line number of five digits (or a shorter one with a big font) didn't fit its column, wrapped onto a second line
  and made its row two lines tall. The drawing draws it narrower instead.
- On a width that leaves half a pixel over, the stack gave that pixel to the side whose text could stretch less,
  so the line between the sides (and a line's wrapping) stepped a pixel from row to row. The drawing gives it to
  the old side in every row; such widths are where the rest of the differing pairs were.
In the window, fills come out one or two of 255 off (they are drawn into one layer now, not blended as layers).

VoiceOver reads a row's numbers from the drawing ("Old line 14, new line 14, staged"); they were texts.

In millions of instructions for 9,600 pt of scrolling in a Debug test instance, the old rows against the new in one
build: Split 12,500 → 9,300 (a file of 188 small hunks) and 8,600 → 6,000 (one hunk of 1,700 lines); Unified
11,200 → 8,800 and 9,900 → 7,300; All Files over 80 small files 18,400 → 9,200 with the commit before, and its
turns longer than 16 ms 46 → 4.

The comparison (DiffRowParity, the driver's diffParity) and the old rows aren't in the code: they are kept with the
notes. 17 checks of diffs passed in light and dark, t_linepick among them: its clicks pick the same lines at the
same places as on the old rows.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
…diffs

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
…d-faster-diffs

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
…ster-diffs

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
…diffs

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
…-faster-diffs

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
…er-diffs

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
…-gaps-and-faster-diffs

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-30T18:34:03.712915Z 8c78187 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b23ec7ee18

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +112 to +114
let status = try await git(["status", "--porcelain=v2", "-z", "--untracked-files=all", "--", ":(literal)" + path])
var record: DiscardRecord?
if let entry = StatusParser.parse(status.stdout).entries.first(where: { $0.path == path }) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve ignored local files before restoring historical versions

If a previously tracked file is now ignored and exists locally, this status query returns no entry, so restoration proceeds without preserving its contents. For example, after removing a config file from Git and ignoring it, restoring its historical version silently overwrites the user's local config; Undo then deletes it because HEAD does not contain the path. I reproduced this with the exact status and restore commands. git status -h distinguishes --untracked-files ("show untracked files") from --ignored ("show ignored files"), so --untracked-files=all does not cover this case. Detect and preserve existing ignored files, or refuse to overwrite them.

Useful? React with 👍 / 👎.

Comment on lines +129 to +131
let now = try? await git(["hash-object", "--path=\(restore.path)", "--", restore.path]).text
.trimmingCharacters(in: .whitespacesAndNewlines)
guard now == restore.blob else {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Hash the link itself when validating a restored symlink

When the restored file is a symbolic link, this command hashes the destination file's contents rather than the link-target text stored in Git's blob. I reproduced different hashes immediately after restoring an otherwise untouched symlink, so Undo incorrectly reports that the file changed and cannot restore the previous link or its saved changes. A dangling link also fails this check. Handle symlinks separately by hashing their link-target text; git hash-object -h documents --stdin as "read the object from stdin", which allows that text to be hashed without following the link.

Useful? React with 👍 / 👎.

Comment thread Kaern/Askpass/AskpassCenter.swift Outdated
Comment on lines +39 to +44
retry = given[key].map { $0.asker == request.asker && Date().timeIntervalSince($0.at) < 30 } ?? false
// The saved one, unless it was just turned down; then it goes, and you're asked.
if retry {
SSHPassphrases.forget(key)
} else if let saved = SSHPassphrases.saved(for: key) {
given[key] = (request.asker, Date())

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Track passphrase retries separately for each SSH process

If two repositories fetch concurrently using the same key and its saved passphrase is outdated, each SSH process overwrites the other's given[key] entry. Alternating requests from processes A and B therefore always look like first attempts, repeatedly returning the rejected saved passphrase instead of asking the user. I reproduced this sequence against the actual AskpassCenter implementation with stubbed storage and window dependencies: all six requests received the outdated passphrase and no question appeared. Since activity is restricted per repository rather than globally, overlapping fetches in separate tabs can encounter this. Track attempts by both key and asker so another connection cannot erase retry history.

Useful? React with 👍 / 👎.

progresshans and others added 4 commits November 30, 2026 21:15
…t is in the file's way

Restore Version kept the file's own changes by what `git status` lists for its path, and then let `git restore` write
the version. Two things of the user's weren't in that list, and went without a word:

- A file git ignores. A config taken out of the repository and ignored is still there, with contents of one's own,
  and status doesn't list ignored files (`--untracked-files=all` is about untracked ones). The old version was written
  over it, and ⌘Z then deleted the file, as HEAD hasn't the path. Now a file at the path that git doesn't track is
  kept like an untracked one, ignored or not: its contents go to Stashes (the copy's list of untracked files leaves
  the standard excludes out for it), and ⌘Z brings them back.
- What stands where the file or one of its folders has to be. `git restore` puts a file where it's told whatever is
  there: a folder at the path goes with all that's in it, and a file or a link named as one of the path's folders goes
  for the folder. Restore Version now says so and does nothing ("docs is a folder now. Move it away first.").

Codex's review of PR 10 found the first; the second came up looking for what else status doesn't show.
RestoreVersionTests has the three cases: on the code before, the ignored file's contents were gone after ⌘Z.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
⌘Z of Restore Version takes the file back only while it is still the version that was written, which it checked with
`git hash-object <path>`. For a symbolic link that reads what the link points to, and a link's blob is where it
points: the two never match, so ⌘Z said the file had changed and left the link and the kept changes where they were.
A link to nowhere couldn't be read at all. A link is now hashed as git stores it, from its target's path.

Codex's review of PR 10 found it. RestoreVersionTests restores a link and a link to nowhere and takes each back.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
… at once too

Kaern tells that a saved passphrase no longer fits by the same ssh asking for the same key again. It kept one note
per key: the ssh that asked last. Two commands at once with one key (a fetch in each of two tabs) ask in turn, so
each one's second question read as the other's first: the saved passphrase went out again and again, both commands
failed, and nobody was asked.

The notes are per ssh and per key now, with what was given (`AskpassAttempts` in KaernKit, which says what to do
with a question). That also settles what came next: the first ssh's retry asks, the answer is saved, and the second
ssh's retry would have taken that new passphrase for the one that failed and deleted it. An ssh turned down with an
older saved passphrase is now given the one saved since. And an answer in the window serves every ssh waiting with
the same key's question: one key, one passphrase.

Codex's review of PR 10 found the first part. AskpassTests has the sequences. t_sshprompts now changes the key's
passphrase and fetches in two tabs at once: Kaern asks once and both go through. On the code before, it waited for
a question that never came.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
The check clicked Unstage Hunk at a fixed place, 16 pt before the diff's right edge. With a mouse attached, and on
the CI runners, the scroll bar always shows and takes 17 pt, so the button ends that much further left: the click
fell beside it, and the check waited 90 s for a hunk to be unstaged (PR 10's flow job; the other 58 checks passed).
It now tries from the right, clear of the bar, until a click unstages, with the hold-and-let-go-elsewhere before
each try. It passed with scroll bars always shown (-AppleShowScrollBars Always: the button at 1094) and as this Mac
has them (1102).

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7f30001f72

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +125 to +126
record = try await discard(paths: paths, untracked: entry.isUntracked ? [entry.path] : [], keepingStaged: false,
message: message)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve local contents alongside a staged deletion

When a file has a staged deletion but still exists locally—for example, after git rm --cached (git rm -h: “only remove from the index”)—status returns both a deletion entry and an untracked entry for the same path. Selecting only the first entry passes untracked: [] to discard, so the record contains the staged deletion but no patch or untracked-file restoration for the local contents. Undo then applies that deletion and drops the backup stash, leaving the local file missing. I reproduced this with the exact snapshot, restore, and undo commands. Account for both entries and preserve the on-disk contents separately, or refuse this state before modifying anything.

Useful? React with 👍 / 👎.

…what is in a file's way

Discard took the caller's word for which paths are untracked, and that word
came from git status. Status says less than there can be at a path, and
`git restore` writes over all of it without a word:

- A staged deletion can leave the file on disk (`git rm --cached`, or a new
  file at a renamed one's old name). Status lists the path twice, or only
  the deletion when the file is ignored. Discard put HEAD's file over it,
  then ⌘Z deleted that and dropped the copy. Restore Version discards
  first, so it lost the file the same way. Such a file is now kept in the
  copy's working-tree part, so Stashes shows the path once, and ⌘Z brings
  it back. The disk is asked whether a file is there, since on a disk that
  takes `Config` and `config` for one name the file can be spelled another
  way by now.
- A folder with files of its own where a deleted file was, or a file where
  the deleted file's folder was, went for the file. Discard stops there and
  names what is in the way. ⌘Z does the same when it puts an untracked file
  back.
- Before the first commit git makes no stash, so an untracked file was
  deleted without a copy. Discard throws nothing away there now.
- A file that became a folder of tracked files, or the other way round,
  stopped the copy and the restore with a git error. Both go through.

`discard(paths:keepingStaged:message:)` reads HEAD, the index and the disk
itself, so its `untracked:` and `ignored:` are gone.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
@progresshans
progresshans merged commit b27fb80 into develop Dec 2, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant