You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 7dd0636
Browse filesBrowse the repository at this point in the historyBrowse files
diff: run git when the built-in panel would, never at the session's start (#94594)
* diff: the session's start asks nothing of the repository; /diff or the first edit pins it when it comes
* diff: git runs when the built-in panel's would: one rev-parse at first need, the tree walked only for an open pane, nothing after a turn or a refused tool
* diff: a shell command that failed or was cut short still refreshes an open pane, an edit that did opens nothing, and a probe /clear overtook pins nothing
Copy file name to clipboardExpand all lines: mods/diff/README.md
+24-15Lines changed: 24 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,11 +11,11 @@ click puts that file's hunks at the top; the list also scrolls under the
11
11
built-in's list keys (`ctrl+up`/`ctrl+down`, `opt+up`/`opt+down`), and
12
12
`ctrl+x b` moves the comparison base on, as the built-in's chord does: both
13
13
through Buttons that declare the engine's own actions. The pane refreshes
14
-
as Claude edits, runs shell commands and finishes turns, and while it is
15
-
open it polls the repository's HEAD so a commit or checkout made elsewhere
16
-
shows too. The first successful edit of a session opens the pane by itself
17
-
where the terminal is wide enough (144 columns when the person never chose,
18
-
110 when they kept it open before; a person who closed it is left alone).
14
+
as Claude edits and runs shell commands, and while it is open it polls
15
+
the repository's HEAD so a commit or checkout made elsewhere shows too.
16
+
The first successful edit of a session opens the pane by itself where the
17
+
terminal is wide enough (144 columns when the person never chose, 110 when
18
+
they kept it open before; a person who closed it is left alone).
19
19
20
20
Under the fullscreen layout a terminal under 110 columns gets the
21
21
built-in's line asking for a wider one and nothing opens. Without that
@@ -36,28 +36,37 @@ the default branch; the base line under the header names a base other than
36
36
the session's, and the choice is kept per repository in the plugin's store.
37
37
A picker shows one earlier turn's edits instead of the working tree, read
38
38
from the session's messages. Files that changed before the session started
39
-
(by their timestamp, among the paths already dirty at the start), and noise
40
-
(lockfiles, generated and test files), are listed apart and folded until
41
-
asked for; a rename lists as git prints it. Outside a git repository
42
-
`/diff` says so and does nothing else.
39
+
(by their timestamp, among the paths already dirty when the pane first
40
+
read the repository), and noise (lockfiles, generated and test files), are
41
+
listed apart and folded until asked for; a rename lists as git prints it.
42
+
Outside a git repository `/diff` says so and does nothing else.
43
+
44
+
Git runs when the built-in panel's would: nothing at the session's start;
45
+
one `git rev-parse`, in the directory the session started in, when `/diff`
46
+
or the first edit a pane has room to open on first needs the repository
47
+
(an answer of no repository is kept too, until `/clear` or `/resume`
48
+
forgets it); and the working tree is read only by a fetch for a pane that
49
+
is open, after an edit that landed or a shell command that ran. The one
50
+
read the built-in has no counterpart for is a `git status` at a pane's
51
+
first fetch, which stands in for the change time the built-in dates a
52
+
moved file by.
43
53
44
54
`hooks/register.ts` is the module; everything under `hooks/` is its parts.
45
55
46
56
## What it hooks
47
57
48
58
| event | what the hook does |
49
59
| --- | --- |
50
-
|`session.start`| Binds the engine once, registers `/diff` (a session where another `/diff` is listed leaves the plugin idle), and pins the repository. |
60
+
|`session.start`| Binds the engine once and registers `/diff` (a session where another `/diff` is listed leaves the plugin idle); asks nothing of the repository, which `/diff` or the first edit pins when it comes. |
51
61
|`ui.render` of `PromptHint`| Reads the terminal's width, which decides whether the first edit opens the pane. |
52
62
|`ui.render` of `Pane`| Draws the pane: docked, the header, base line, source picker, file list and toggles over the window of hunks; inline, the dialog. |
53
-
|`command.run` of `diff`|Opens or closes the pane (focused and closing on Escape without the fullscreen layout), says which, and remembers the choice. |
63
+
|`command.run` of `diff`|Pins the repository when none is, opens or closes the pane (focused and closing on Escape without the fullscreen layout), says which, and remembers the choice. |
54
64
|`ui.close` of the pane | Backs out of the dialog's detail view instead of closing; else remembers the person's close as `/diff`'s. |
55
65
|`ui.scroll` of the pane | Docked, moves the hunks under the pinned header and list (three rows a wheel tick, a page a page key), or the list when the wheel is over it, and keeps the engine's window still. |
56
66
|`ui.focus` in the pane | In the dialog's list, selects the file the ring lands on, re-centres the five rows on it, and lands the ring where that row now sits. |
57
-
|`command.run` of `clear`, `resume`| Closes the pane and forgets the session's state. |
58
-
|`tool.call` of `Edit`, `Write`, `NotebookEdit`| After the edit, refreshes an open pane; the session's first successful edit opens it. |
59
-
|`tool.call` of `Bash`, `PowerShell`| After the command, refreshes an open pane. |
60
-
|`turn.complete`| Refreshes an open pane. |
67
+
|`command.run` of `clear`, `resume`| Closes the pane and forgets the session's state, the pinned repository with it. |
68
+
|`tool.call` of `Edit`, `Write`, `NotebookEdit`| After an edit that landed (not refused, not failed), refreshes an open pane; the session's first such edit opens it, pinning the repository then if the terminal has the room. |
69
+
|`tool.call` of `Bash`, `PowerShell`| After a command that was not refused, failed and interrupted ones too, refreshes an open pane. |
61
70
|`prompt.submit`| Adds the armed file's hunks to the prompt's context and disarms. |
0 commit comments