diffstalkerd 0.13.5 → 0.13.7

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,75 @@ 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.7] - 2026-10-13
9
+
10
+ ### Fixed
11
+
12
+ - **The stack strip in Compare no longer shows backup and scratch branches
13
+ as layers.** A local branch that was never pushed, pointing at an older
14
+ commit inside a PR (a `backup/*` branch, say), split that PR into several
15
+ layers. And when such a branch sat at the same commit as a PR's branch,
16
+ the strip could name the layer after it. Now, once branches are pushed,
17
+ only pushed ones make layers, and a pushed name wins. A stack where
18
+ nothing is pushed yet works as before.
19
+ - **The repo picker now ranks a bare-repo project by its worktrees.** For
20
+ a project laid out as a bare repo with worktrees around it, the picker
21
+ read the age from the bare repo's own files, which sit untouched for
22
+ months, so a project you worked in minutes ago showed as months old and
23
+ sorted near the bottom. The age is now the newest activity in any of
24
+ the project's worktrees.
25
+
26
+ ## [0.13.6] - 2026-10-01
27
+
28
+ ### Added
29
+
30
+ - **The daemon's errors can be traced now.** Before, a failed stage or push,
31
+ a watcher error or a broken refresh left no line anywhere, and a daemon the
32
+ terminal UI started threw all its output away. Now every log line has a
33
+ timestamp and a level, errors print their stack and cause, and each failure
34
+ names its repo and file. A daemon the terminal UI starts writes to
35
+ `~/.local/state/diffstalker/diffstalkerd.log` (moved to `.log.1` past 1 MB
36
+ when the next one starts); under systemd it is the journal. `--debug` also
37
+ logs every refused request. File names and remote URLs are made safe in the
38
+ log: newlines are escaped and credentials are removed. In the web UI, every
39
+ error the page shows also lands in the browser console with its detail. See
40
+ `docs/logging.md`.
41
+ - **Compare can show one PR of a stack.** If the branches between the base
42
+ and HEAD form a stack of pull requests (for example made with `gh stack`),
43
+ Compare lists them in a strip. Pick one and the diff shows just that PR:
44
+ its own branch against the branch below it. The stack comes from git, not
45
+ from GitHub, so no network or login is needed.
46
+
47
+ ### Changed
48
+
49
+ - **Wire changes in the daemon API.** `GET /media` takes `staged=true|false`
50
+ (was `0|1`). `GET /compare/file` names its row with `uncommitted=` (was
51
+ `side=`); `side` now only means the tree on `/blob`. `POST /repos` answers
52
+ 404 for a path that does not exist (was 400). A repo whose directory is
53
+ deleted while open answers 410 with the reason, instead of a 500 on every
54
+ request. Unknown API paths get a JSON 404 instead of the web page.
55
+ `?base=` is checked like every other ref. A pull or push with no upstream
56
+ is a 409 with git's message (was a 500).
57
+ - **bun 1.4.2** for development and CI. bun 1.3 could deadlock on a named
58
+ pipe in a watched folder, which is what hung the 0.13.5 release run.
59
+ - **Faster:** the lists compute their keyboard tab stop once per render
60
+ instead of once per row (2000 rows: from 108 ms to under 0.1 ms per
61
+ render); a refresh runs three fewer git processes; Compare runs its git
62
+ reads in parallel (about 20% faster).
63
+
64
+ ### Fixed
65
+
66
+ - **Files with a tab, a quote, a backslash or a non-ASCII letter in their
67
+ name** disappeared from Compare and History, and could lose their counts in
68
+ Changes: git quotes such names and nothing unquoted them.
69
+ - **Compare no longer offers `refs/stash` or local branches as a base.** Only
70
+ remote-tracking branches qualify.
71
+ - **Opening a History link highlights its commit.** When the log loaded while
72
+ the link's commit was being looked up, the files showed but no row was
73
+ selected.
74
+ - **A connection error from the repo you just left** could no longer push the
75
+ repo you switched to into reconnecting.
76
+
8
77
  ## [0.13.5] - 2026-09-29
9
78
 
10
79
  ### Added
package/README.md CHANGED
@@ -55,6 +55,8 @@ Options:
55
55
  package ships it there. Missing dir → API-only, non-fatal)
56
56
  --no-update-check Never ask npm which version is latest; GET /version
57
57
  then reports the running version only
58
+ --debug Also log debug lines (every refused request, every
59
+ ignored follow target) to stderr. See docs/logging.md
58
60
  --version, -v Print the running version and exit
59
61
  --help, -h Show this help
60
62
  ```
@@ -78,7 +80,10 @@ A browser can only reach the daemon over TCP (`--port`), not a unix socket, and
78
80
  the daemon sends no CORS headers — so the web UI is served same-origin from the
79
81
  daemon itself. `GET /` and any unmatched non-API GET path return the SPA's
80
82
  `index.html` (client-side routing); hashed `/assets/*` are served with a long
81
- immutable cache. The REST/SSE API always takes precedence over static files.
83
+ immutable cache. The REST/SSE API always takes precedence over static files,
84
+ and an unknown path under an API prefix (`/health`, `/version`, `/repos`,
85
+ `/resolve`, `/worktrees`, `/events`, `/follow`, `/settings`, `/discovered`,
86
+ `/browse`) is a JSON 404, never the SPA page.
82
87
 
83
88
  Without `--socket`, the daemon binds a unix socket at
84
89
  `$XDG_RUNTIME_DIR/diffstalker/diffstalkerd.sock`. The directory is created
@@ -182,11 +187,15 @@ Every mutation responds with the unified envelope `{state, result?}`:
182
187
  operations. Status codes: 400 for invalid input (missing fields,
183
188
  flag-shaped refs, resets past the root), 404 for unknown repo ids / files
184
189
  not in status, 409 when the repo state refuses the operation (conflicts,
185
- rejected pushes, an operation already in progress, nothing to abort), 500
190
+ rejected pushes, an operation already in progress, nothing to abort), 410
191
+ when the repo is open but its directory is gone or is no longer a git repo
192
+ (`{error}` says which; `GET /status`, `GET /repos/:id/events` and
193
+ `DELETE /repos/:id` still answer, so a client can see why and let go), 500
186
194
  for real failures.
187
195
 
188
- Ref-like fields (`name`, `hash`, `branch`) must not start with `-`; such
189
- values are rejected with a 400 so they can never be parsed as git flags.
196
+ Ref-like values (the body fields `name`, `hash`, `branch` and the `base`
197
+ query param) must not be empty or start with `-`; such values are rejected
198
+ with a 400 so they can never be parsed as git flags.
190
199
 
191
200
  ### Reads
192
201
 
@@ -195,7 +204,7 @@ values are rejected with a 400 so they can never be parsed as git flags.
195
204
  | 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
205
  | 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
206
  | GET | `/repos` | List open repos (`id`, `path`, `branch`) |
198
- | POST | `/repos` | Open a repo: `{"path": "/abs/path"}` → `{id, path}` (201 created, 200 already open) |
207
+ | POST | `/repos` | Open a repo: `{"path": "/abs/path"}` → `{id, path}` (201 created, 200 already open). 400 for a relative path or a directory that is not a git repository, 404 when the path does not exist. One missing last segment under a repo still opens the repo above it (`<repo>/nope` opens `<repo>`); a path missing more than one level deep (`<repo>/nope/deeper`) is a 404 |
199
208
  | DELETE | `/repos/:id` | Close a repo (refcounted per open) |
200
209
  | 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
210
  | 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) |
@@ -211,11 +220,13 @@ values are rejected with a 400 so they can never be parsed as git flags.
211
220
  | GET | `/repos/:id/base-branches` | Candidate compare bases (remote branches in recent history) |
212
221
  | GET | `/repos/:id/compare/base` | Effective compare base: `{base}` (persisted choice or discovered default, null when none) |
213
222
  | 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) |
214
- | 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 |
215
- | 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` |
216
- | 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` |
217
- | 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 |
218
- | 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) |
223
+ | GET | `/repos/:id/compare?base=&head=&staged=&unstaged=&untracked=` | Base-vs-head `CompareDiff` (three-dot: `merge-base(base, head)...head`); 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. `head` defaults to HEAD and is checked exactly as `base` is (400 `Unknown head ref: …`); naming one reads a single layer of a stack (see `/compare/stack`). 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. Uncommitted work only exists against HEAD, so any of the three flags together with `head` is a 400 |
224
+ | GET | `/repos/:id/compare/count?base=&head=` | How many commits `/compare` would list, as `{baseBranch, commits}`, without building the diff (what badges the Compare tab). Same `base` and `head` resolution and the same 400/422 answers as `/compare` |
225
+ | GET | `/repos/:id/compare/stack?base=` | The stack of branches from the base (the trunk) up to HEAD and above it, as git topology shows it: `{trunk, layers, forkedAbove}`, layers bottom to top, each `{name, refs, tip, commits, isHead}` (`CompareStack` in `@diffstalker/core/types/stack`; rules in `docs/stacked-compare.md`). `base` resolves exactly as on `/compare`; a base with no common history is an empty `layers`, not a 422. The HEAD layer is always present, named after the checked-out branch or `HEAD` when detached. Branches above HEAD that fork are left out and `forkedAbove` says so. A remote-tracking copy of a local branch is folded into that branch's layer, never a layer of its own. The walk is capped at 1000 first-parent commits from the merge-base: a layer deeper than that is not seen, and the lowest layer that is seen then counts its commits from the cut |
226
+ | GET | `/repos/:id/compare/file?path=&base=&head=&uncommitted=&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. `uncommitted` names the row's own comparison with the same word the row carries in `/compare`'s `files[].uncommitted` — `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. (It is not called `side`: on this API `side` is always one tree, `worktree` \| `index` \| `head`, as on `/blob` and `/media`.) Same rename-preserving pathspec as above. `head` narrows the committed range as on `/compare`, and is a 400 together with `uncommitted`. 400 without `path`, or on an unknown `uncommitted` |
227
+ | 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 or on the git directory; 404 when the dir does not exist; 400 `Not a directory (a file): …` when the path exists but is not a directory). The git directory is never listed, even with `hidden=true` |
228
+ | 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; 404 when the path does not exist; 400 `Not a regular file (a directory): …` (or a FIFO, a socket, a device) when it exists but is not a regular file, and 400 when it resolves outside the repo root or addresses the git directory |
229
+ | 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` is required and spelled `true` or `false` like every boolean param. 404 when the path is not in status. See [Image bytes](#image-bytes) |
219
230
  | GET | `/repos/:id/blob?path=&side=&v=` | Raw image bytes for `<img src>`; `side` is `worktree` \| `index` \| `head`, `v` is an ignored cache key. Only PNG/JPEG/GIF, typed from magic bytes. Status-independent (no `git status`), so a clean committed image is reachable. See [Image bytes](#image-bytes) |
220
231
  | GET | `/repos/:id/files` | All tracked + untracked (not ignored) paths: the fuzzy-finder source |
221
232
  | GET | `/repos/:id/journal?since=` | Append-only edit journal: `{epoch, prunedBefore, entries}`; `since=<seq>` returns only entries with a higher seq (all when omitted) |
@@ -255,7 +266,15 @@ values are rejected with a 400 so they can never be parsed as git flags.
255
266
 
256
267
  A conflicted `pull`/`cherry-pick` leaves the repo stopped mid-operation;
257
268
  `GET /status` reports it in `operationInProgress` and `POST /abort`
258
- returns the repo to its pre-operation state — no shell required.
269
+ returns the repo to its pre-operation state — no shell required. The
270
+ failing mutation refreshes the shared state before it answers, so the
271
+ `state-change` event carries the wedge too, and `/status` serves that same
272
+ cached state rather than re-reading the git dir. For an operation started
273
+ from a shell the value lags by the watcher's debounce plus one refresh
274
+ (roughly 150–250 ms after HEAD or the index changes): a `/status` read in
275
+ that window still shows the previous value. A failed git operation's
276
+ `{error}` is git's own message (a rejected push, a patch that does not
277
+ apply); the daemon log records the same text.
259
278
 
260
279
  History, compare, and explorer data are stateless, pulled on demand: the
261
280
  daemon never holds a client's selection, loaded history, or tree expansion.
@@ -280,6 +299,14 @@ included: the response is byte-identical to the plain one.
280
299
  Repo ids are stable hashes of the worktree root, so a cached id still
281
300
  addresses the same repo after a daemon restart.
282
301
 
302
+ Every `path` on the wire — in status entries, hunk counts, compare and
303
+ commit rows — is the raw path, exactly as `git status` spells it, even when
304
+ git C-quotes it in patch text (a tab, a double quote, a backslash, a
305
+ non-ASCII name): the daemon reads git's list outputs with `-z` and unquotes
306
+ `diff --git` headers. The header lines inside a `DiffResult` keep git's
307
+ quoting, because a hunk patch built from them must be one `git apply`
308
+ accepts.
309
+
283
310
  ### One stream per tab
284
311
 
285
312
  There are two event streams: `GET /events` for the daemon (open repos,
@@ -421,7 +448,7 @@ bytes it is going to write.
421
448
 
422
449
  | Status | Cause |
423
450
  | ------ | ----- |
424
- | 400 | empty/NUL path, a leading `-` (git option) or `:` (pathspec magic), traversal, a symlink escaping the root, any `.git` path, a non-regular file (directory, symlink, gitlink, FIFO), a bad `side`, a `staged` that is not `0`/`1` |
451
+ | 400 | empty/NUL path, a leading `-` (git option) or `:` (pathspec magic), traversal, a symlink escaping the root, any `.git` path, a non-regular file (directory, symlink, gitlink, FIFO), a bad `side`, a `staged` that is missing or not `true`/`false` |
425
452
  | 403 | `Sec-Fetch-Site` present and cross-site, or `Sec-Fetch-Dest` present and not `image` (`/blob` only — `/media` is JSON and the SPA's own `fetch` sends `Sec-Fetch-Dest: empty`). Both absent passes, so `curl` and the Node client are unaffected |
426
453
  | 404 | unknown repo, or the path does not exist on that side. `/media` also 404s a path with no status entry |
427
454
  | 413 | over the byte, dimension, pixel or frame cap |