diffstalkerd 0.12.3 → 0.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,158 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.13.1] - 2026-08-26
9
+
10
+ ### Changed
11
+
12
+ - **Compare's "include uncommitted" is now three independent toggles: staged,
13
+ unstaged, untracked.** One switch could not answer the question a reader
14
+ actually has — "what am I about to commit" and "what have I touched" are
15
+ different reviews, and with one flag there was no way to tell which of the
16
+ three a row belonged to, or to leave one of them out. Each folded-in row is
17
+ now tagged with the side it came from and its ref-pair label names that
18
+ side's own comparison (`HEAD → index`, `index → working tree`,
19
+ `HEAD → working tree`, `nothing → new file`). Staged and unstaged asked for
20
+ together are still read as ONE `git diff HEAD`, never two diffs — a file
21
+ changed on both sides is one row, not two chunks of which only the first
22
+ survives.
23
+ - **Wire:** `GET /compare?uncommitted=` is replaced by
24
+ `?staged=&unstaged=&untracked=`, and `GET /compare/file?uncommitted=` by
25
+ `?side=staged|unstaged|both|untracked`. A `CompareFileDiff`'s
26
+ `isUncommitted: boolean` becomes `uncommitted?: UncommittedSide`.
27
+ - **Whole-file mode works on an untracked compare row.** It used to ask git
28
+ for a diff of a file git does not track and get nothing back; the row is now
29
+ read from disk, which is what its hunks were already doing.
30
+ - The TUI's `u` key still toggles all three categories at once — the
31
+ per-category control is the web UI's.
32
+
33
+ ## [0.13.0] - 2026-08-26
34
+
35
+ ### Added
36
+
37
+ - **`diffstalker link` — print a web-UI URL for a place in a repo.** For
38
+ pointing someone at code instead of pasting a copy of it, and written for a
39
+ coding agent as much as for a person: `diffstalker link` gives the journal
40
+ (a whole session in one place), `diffstalker link src/App.vue` the explorer,
41
+ and `changes` / `history` / `compare` take the anchor each of those views
42
+ understands. The command exists because a hand-written diffstalker URL fails
43
+ silently — a non-view-first path names no place, an `at` that matches nothing
44
+ leaves the view aimed at nothing — so it proves every part against the daemon
45
+ first: the repo, the file, the `u:`/`s:` side a changes row is actually on,
46
+ the short hash a commit-ish resolves to. Anything it cannot prove is an error
47
+ on stderr with a non-zero exit, not a URL that breaks in someone's browser.
48
+ - **`GET /health` reports the port the web UI is reachable on** (`http.port`,
49
+ null when the daemon bound only a socket). A socket client could not
50
+ otherwise tell whether a browser URL exists at all; `diffstalker link` says
51
+ so plainly instead of guessing a port.
52
+ - **`GET /resolve?path=`** — can this exact path be opened, and as which
53
+ worktree, without opening it. It shares one resolver with `POST /repos` so
54
+ the two can never disagree, but requires the path to EXIST: git resolves a
55
+ missing path to its parent worktree, which would make a typo look openable.
56
+ - **Whole-file mode in the web UI.** A `whole file` toggle in each diff header
57
+ (Changes, Compare, History) draws that one file in full — every line
58
+ numbered, the changed ones marked in place — instead of hunks with three
59
+ lines of context.
60
+ It is for reading a change in the context of the file it happened in, which
61
+ is the one thing `view file` could not do: it gave you the file and dropped
62
+ every change marker.
63
+ You never pick a ref. The view already fixes the pair and the mode inherits
64
+ it. It applies to one file at a time — the anchored one — which is what lets
65
+ it live in the URL as `whole=<path>`, so F5 lands in the same view, a link
66
+ shares it, and Back turns it off. Untracked files do not offer it (their diff is
67
+ already the whole file); binary files and diffs withheld over the size cap
68
+ disable it with the reason, and keep their hunks on screen.
69
+ In History it is the only correct answer to "show me this in context":
70
+ `view file` there opens TODAY's copy of the path, which is different bytes
71
+ than the historical diff is about. A file over the per-file diff cap keeps
72
+ its hunks and says why on the toggle, rather than replacing a working diff
73
+ with a "not shown" notice.
74
+ The Explorer gains the mirror of `view file` — a `show changes` button, shown
75
+ only for a file that actually has one — so the trip between reading a file
76
+ and reading its diff finally goes both ways. The Explorer renders no diff and
77
+ holds no ref. See `docs/whole-file-mode.md`.
78
+ - **Every diff header now says what it is comparing.** `index → working tree`,
79
+ `HEAD → index`, `origin/main…HEAD`, `a1b2c3d^ → a1b2c3d`. Each view always
80
+ fixed a ref pair and none of them said which, which is what made the question
81
+ feel unanswerable. It also separates Compare's two kinds of row: committed
82
+ ones sit against the merge-base, uncommitted ones against HEAD.
83
+ - **Syntax highlighting is document-wide in whole-file mode.** With full
84
+ context each side of the diff is a complete file, so a block comment stays a
85
+ comment for all twenty of its lines instead of being re-tokenized row by row.
86
+ Hunk views keep per-line highlighting — a hunk interleaves two file versions
87
+ and has no single valid document to feed the highlighter.
88
+ - **`GET /repos/:id/compare/file?path=&base=&uncommitted=&whole=`** and
89
+ `path`/`whole` on **`GET /repos/:id/commits/:hash/diff`** — one file's diff
90
+ inside a comparison or a commit, which the stacked views need because they
91
+ pull a range whole and split it client-side. Both carry BOTH sides of a
92
+ rename in the pathspec: scoped to the new path alone, git reports a rename as
93
+ a plain add, which at full context would turn a two-line edit into a whole
94
+ file of additions.
95
+ - **`GET /repos/:id/diff?whole=true`** — the wire behind it. Requires `path`
96
+ (400 without one: a wide whole-tree diff is unbounded work behind an
97
+ unthrottled GET), and is never annotated with hunk edit times, because a
98
+ whole-file diff is one hunk per file and stamping it would write keys the
99
+ daemon's own `-U3` refresh never produces — the file would read back as
100
+ edited just now.
101
+
102
+ ### Changed
103
+
104
+ - **The repo picker is one input over one list.** The header panel used to
105
+ stack three lists (open on daemon, discovered, recent) with a path field
106
+ above them and a filter buried in the middle that narrowed only the
107
+ discovered list — four ways in, and no obvious one. Now: one input at the
108
+ top that filters everything at once, one list with the open repos first
109
+ under an `OPEN` label, and the discovered repos behind a single control
110
+ that is collapsed by default and says how many revealing will add. Typing
111
+ a name searches every source including discovered; typing an absolute path
112
+ grows an **Open** button, but only once the daemon confirms the path is
113
+ precisely a repository it can open. Arrows move, Enter opens, the first
114
+ Escape clears and the second closes. The empty state mounts the same
115
+ picker, so the two cannot drift apart.
116
+ - Two behaviours were dropped with it. The path field no longer starts
117
+ prefilled with the active repo's path — in an input that also filters, a
118
+ prefill would narrow the list to the repo you are already in. And the empty
119
+ state's recents now wait for their worktree lookup like every other list,
120
+ instead of painting straight from localStorage: that is what keeps a
121
+ three-worktree project from reading as three repos there and one everywhere
122
+ else.
123
+
124
+ ### Fixed
125
+
126
+ - **A repo directory literally named `~` produced a link to a different
127
+ repo.** The URL grammar documented that such a segment is written `%7E`, but
128
+ `encodeURIComponent` leaves `~` alone (it is an unreserved character), so a
129
+ repo at `/~/x` wrote `/~/x` and read back as `$HOME/x`. The sentinel is now
130
+ escaped explicitly. Found by extracting the grammar into
131
+ `@diffstalker/core/view/urlGrammar` — one copy shared by the web client and
132
+ `diffstalker link`, with a round-trip test — instead of two copies that could
133
+ disagree about a URL without either erroring.
134
+ - **Compare with "include uncommitted" dropped the uncommitted changes to any
135
+ file the branch's commits already touched.** The compare returns such a file
136
+ twice — once for the committed side, once for the working tree — but the file
137
+ tree keyed leaves by path and merged the two into one row, so the second
138
+ entry's diff never reached the view. On a branch where you edit the files you
139
+ have been committing to (the normal case), ticking the box added nothing. The
140
+ tree now gives every entry its own row, and both views key compare rows by
141
+ side + path the way the Changes list already does.
142
+ - **Untracked files never showed in the compare at all.** `git diff` does not
143
+ report them, and nothing else looked. They now appear as new-file diffs, with
144
+ the same gitignore filter the Changes view applies, so both views agree on
145
+ what counts as untracked.
146
+ - **A file with both staged and unstaged edits showed only the staged half.**
147
+ The uncommitted side was read as two separate diffs and de-duplicated by path,
148
+ so the unstaged chunk was thrown away while the stats still counted its lines.
149
+ It is one `git diff HEAD` now: staged and unstaged together, in one entry,
150
+ with stats that match what is drawn.
151
+ - **A `diff.context` setting in your git config changed what diffstalker
152
+ showed.** Context width is not cosmetic here — it decides where hunks merge
153
+ and split, so it moved the per-file hunk badges, the identity a hunk's edit
154
+ time is keyed by, and the patches built for staging. Only the journal's diff
155
+ pinned it; every other read took git's default. All of them pin `-U3` now, so
156
+ the same repo reads the same everywhere. If you have `diff.context` set, this
157
+ re-keys your hunks once: existing edit times restamp and hunk badges shift,
158
+ one time.
159
+
8
160
  ## [0.12.3] - 2026-08-12
9
161
 
10
162
  ### Added
package/README.md CHANGED
@@ -192,24 +192,26 @@ values are rejected with a 400 so they can never be parsed as git flags.
192
192
 
193
193
  | Method | Path | What |
194
194
  | ------ | -------------------------- | ------------------------------------------------ |
195
- | GET | `/health` | `{ok, ready}` |
195
+ | GET | `/health` | `{ok, ready, home, http: {port}, symbols}` — `http.port` is the loopback port a browser reaches the web UI on, or null when only a socket is bound (what `diffstalker link` needs to build a URL at all) |
196
196
  | GET | `/version` | `{current, latest, status, install}` — the running version against npm's `latest` dist-tag (`current` \| `outdated` \| `ahead` \| `unknown`). The npm lookup is cached (6h, 5min after a failure) and only ever runs when this endpoint is called; `--no-update-check` skips it, leaving `latest: null`. `install` is `{method, package, command}` — how this daemon was installed (`npm` \| `bun` \| `pnpm` \| `yarn` \| `pacman` \| `unknown`) and the one command that updates it, detected once from where the daemon's own files live. An install nothing owns reports `unknown` with a null command rather than a guess |
197
197
  | GET | `/repos` | List open repos (`id`, `path`, `branch`) |
198
198
  | POST | `/repos` | Open a repo: `{"path": "/abs/path"}` → `{id, path}` (201 created, 200 already open) |
199
199
  | DELETE | `/repos/:id` | Close a repo (refcounted per open) |
200
200
  | GET | `/repos/:id/worktrees` | Registered worktrees (`path`, `branch`, `head`, `isBare`, `lastActivity`, `aheadOfBase`): main worktree, linked worktrees, and the bare entry in a bare-worktree layout |
201
201
  | GET | `/worktrees?path=` | Same as above, but for a raw filesystem path instead of an already-opened repo id (e.g. a recently-visited repo a client hasn't opened on this daemon) |
202
+ | GET | `/resolve?path=` | `{openable, root}` — can this exact path be opened, and as which worktree, without opening it. Same resolver as `POST /repos`, but the path must EXIST (git resolves a missing path to its parent worktree, which would make a typo look openable). A relative path is a 400; not-a-repo is a 200 answer |
202
203
  | GET | `/repos/:id/status` | Shared state: status, hunk counts, stash list, in-progress operation, error, working-file mtimes (path → mtimeMs; what browser clients build mtime-based auto mode on) |
203
- | GET | `/repos/:id/diff?path=&staged=` | Diff; whole tree without `path`, staged side with `staged=true`. Per-file cap: a file's diff over 256 KB or 5,000 lines is withheld — its headers are kept and its body becomes one `Large file — diff not shown (…)` line, the same shape git uses for `Binary files … differ`. Applies to every diff-bearing response (compare, commit diffs, journal) |
204
+ | GET | `/repos/:id/diff?path=&staged=&whole=` | Diff; whole tree without `path`, staged side with `staged=true`. `whole=true` draws ONE file in full instead of as hunks (wide context, so every unchanged line is present and the changed ones are marked in place) — it **requires** `path` (400 without one: a wide whole-tree diff is unbounded work behind an unthrottled GET), it is never annotated with hunk edit times (see the note under this table), and it is ignored for an untracked file, whose diff is the whole file already. Per-file cap: a file's diff over 256 KB or 5,000 lines is withheld — its headers are kept and its body becomes one `Large file — diff not shown (…)` line, the same shape git uses for `Binary files … differ`. Applies to every diff-bearing response (compare, commit diffs, journal), and it is what bounds a whole-file diff |
204
205
  | GET | `/repos/:id/history?count=` | Commit history (`CommitInfo[]`, default 100, ISO dates) |
205
206
  | GET | `/repos/:id/commits/:hash` | One commit by hash or short hash (404 on unknown) — what a link to a commit outside a client's loaded log resolves through |
206
- | GET | `/repos/:id/commits/:hash/diff` | Diff introduced by one commit (404 on unknown hash; merge and `--allow-empty` commits are 200 with an empty diff, matching the CLI) |
207
+ | GET | `/repos/:id/commits/:hash/diff?path=&whole=` | Diff introduced by one commit (404 on unknown hash; merge and `--allow-empty` commits are 200 with an empty diff, matching the CLI). `path` narrows to one file and `whole=true` widens its context to the whole file (400 without `path`). The pathspec carries BOTH sides of a rename, because scoping to the new path alone makes git report a rename as a plain add |
207
208
  | GET | `/repos/:id/head-message` | HEAD commit message for amend prefill: `{message}` (`""` when the repo has no commits) |
208
209
  | GET | `/repos/:id/branches` | Local branches (`name`, `current`, `tracking`) |
209
210
  | GET | `/repos/:id/base-branches` | Candidate compare bases (remote branches in recent history) |
210
211
  | GET | `/repos/:id/compare/base` | Effective compare base: `{base}` (persisted choice or discovered default, null when none) |
211
212
  | PUT | `/repos/:id/compare/base` | Persist the compare base: `{"branch": "origin/main"}` → `{base}`; the ref is validated first (400 on an unknown ref, nothing persisted) |
212
- | GET | `/repos/:id/compare?base=&uncommitted=` | Base-vs-HEAD `CompareDiff` (three-dot); base defaults to the effective base — a stale persisted base falls back to the discovered default, 422 when nothing usable resolves; an explicit unknown `base` is a 400; a base with no common history is a 422; `uncommitted=true` merges working-tree changes |
213
+ | GET | `/repos/:id/compare?base=&staged=&unstaged=&untracked=` | Base-vs-HEAD `CompareDiff` (three-dot); base defaults to the effective base — a stale persisted base falls back to the discovered default, 422 when nothing usable resolves; an explicit unknown `base` is a 400; a base with no common history is a 422. The three uncommitted categories are independent flags, each defaulting to false; a row folded in carries `uncommitted: 'staged' \| 'unstaged' \| 'both' \| 'untracked'`. `staged` and `unstaged` together are read as ONE `git diff HEAD` (side `both`), never two diffs |
214
+ | GET | `/repos/:id/compare/file?path=&base=&side=&whole=` | One file's diff inside a comparison, as a `DiffResult`. The stacked views pull a range whole and split it client-side, so they have no per-file request of their own to widen. `side` names the row's own comparison — `staged` (HEAD vs index), `unstaged` (index vs working tree), `both` (HEAD vs working tree) or `untracked` (read from disk, git diff would answer empty) — and absent means a committed row against the base. Compare's stack mixes them and they are genuinely different comparisons. Same rename-preserving pathspec as above. 400 without `path`, or on an unknown `side` |
213
215
  | GET | `/repos/:id/tree?dir=&hidden=&ignored=` | One directory level (`name`, `path`, `type`), gitignored/hidden filtered by default (`hidden=true` / `ignored=true` include them, mirroring the TUI toggles), files annotated with `gitStatus` + `staged`, changed dirs with `hasChanges` (400 outside the repo root, on a file, or on the git directory, 404 unknown dir). The git directory is never listed, even with `hidden=true` |
214
216
  | GET | `/repos/:id/file?path=` | File content for display with flags: `{content, binary, truncated, tooLarge, size, totalLines, media?}` — binary/oversized come back with empty content and the flag set, never prose; `media` carries the image verdict (`{image, refusal, version}`) when the bytes say something about it; 400 for anything that is not a regular file (directory, FIFO, device), resolves outside the repo root, or addresses the git directory |
215
217
  | GET | `/repos/:id/media?path=&staged=` | Image metadata for one changed file, both sides resolved server-side (renames included): `{old, new}`, each side `{path, side, bytes, oid, image, refusal, version}` or `null` when the file does not exist there. `staged` must be spelled `0` or `1`. 404 when the path is not in status. See [Image bytes](#image-bytes) |
@@ -264,6 +266,16 @@ at the display line limit. A merely large file that fits within the limit
264
266
  is served whole with `truncated: false` (the old TUI code conflated the
265
267
  two: a >100KB file used to be flagged truncated regardless).
266
268
 
269
+ Note on `whole=true` and hunk edit times: a whole-file diff is **never**
270
+ stamped. Stamping WRITES into the repo's shared hunk-time map, keyed by a
271
+ hash of each hunk's +/- body, and a whole-file diff is one hunk per file —
272
+ so it would write keys the manager's own `-U3` refresh never produces, and
273
+ the file would read back as edited just now. `/commits/:hash/diff` skips
274
+ stamping for the same reason. Whole-file mode therefore shows no per-hunk
275
+ age; the `-U3` read is a separate request and keeps all of it. Requesting
276
+ `whole=true` on an untracked file changes nothing at all, stamping
277
+ included: the response is byte-identical to the plain one.
278
+
267
279
  Repo ids are stable hashes of the worktree root, so a cached id still
268
280
  addresses the same repo after a daemon restart.
269
281