diffstalkerd 0.10.0 → 0.12.0

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,174 @@ 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.12.0] - 2026-08-09
9
+
10
+ ### Added
11
+
12
+ - **Settings panel** in the web UI (gear in the header, or `,`). It separates
13
+ what belongs to this browser (theme) from what belongs to the daemon's
14
+ machine (below), and says which is which. The theme picker moved into it
15
+ from the header, where a permanently parked select cost more room than a
16
+ set-once choice earns.
17
+ - **Watch directories**: point diffstalker at the folder you keep projects in,
18
+ and every git repository in it appears in the repo switcher ready to open —
19
+ no more typing an absolute path per repo. The setting lives with the daemon
20
+ (`~/.config/diffstalker/daemon.json`), so every client sees the same list and
21
+ it survives a restart. New endpoints `GET`/`PUT /settings`, `GET /discovered`
22
+ and `POST /discovered/rescan`, plus `settings-change` / `discovery-change` on
23
+ the daemon SSE channel.
24
+
25
+ A **Browse…** button picks the directory by walking the daemon's own
26
+ filesystem (new `GET /browse`, directory names only, repos marked so you can
27
+ pick their parent). It has to work that way: a browser is never handed a real
28
+ path by its own file pickers, so nothing client-side could name a directory
29
+ the daemon could then open.
30
+
31
+ Discovery lists repos, it never opens them. The scan runs no git at all: a
32
+ directory holding `.git` is a repo, its branch comes from `.git/HEAD`, and
33
+ its last activity from the git dir's mtimes. It looks at the root's children
34
+ and one level deeper, stops at the first `.git` (so submodules are never
35
+ listed as projects), skips dot-dirs and `node_modules`, and is capped at 500
36
+ with the cap reported. Each root is watched, so a fresh clone shows up
37
+ without a reload.
38
+
39
+ The list is ordered most-recently-touched first, with the age beside each
40
+ path: a projects folder is mostly archaeology, so anything untouched for six
41
+ months sinks and dims rather than competing with this week's work. Past eight
42
+ projects the list grows a filter field.
43
+
44
+ ### Fixed
45
+
46
+ A sweep of small things across the web UI — the kind that only show up in real
47
+ use:
48
+
49
+ - The header and the status bar phrased one dropped connection two different
50
+ ways at the same moment; they now share the one sentence.
51
+ - Escape closing a panel used to drop focus on the floor, so the arrow keys
52
+ stopped working: the file-list filter, and the outline popover, now hand
53
+ focus back to where it came from.
54
+ - Escape in the settings panel's directory browser closed the whole panel
55
+ (and the path you had typed). It backs out of the browser first.
56
+ - The journal's commit fold was mouse-only despite announcing itself as a
57
+ button — Enter and Space work now, and it takes a tab stop.
58
+ - Pressing `o` in the Explorer with no file open did nothing at all, though
59
+ the help advertises it; it now opens the popover, which says "No file open."
60
+ - The outline said "Outline not loaded." while it was still loading, which
61
+ reads as a verdict. It says "Loading outline…", and a failed request lands
62
+ on the real unavailable state instead of spinning forever.
63
+ - A failed *optional* outline re-read replaced the file you were reading with
64
+ one line of error text. The file stays.
65
+ - The Explorer's filter toggles kept the same tooltip whichever way they were
66
+ set, so the tooltip described the opposite of what a click would do.
67
+ - A long branch name painted straight over the arrow and the ahead/behind
68
+ counts instead of ellipsizing.
69
+ - Adding a watch directory that was already there looked exactly like a
70
+ successful add (the daemon dedupes silently); it now says so. A refusal no
71
+ longer greets you again the next time you open the panel.
72
+ - Browsing to a path that does not exist opened a dead picker with every
73
+ button disabled; it falls back to home and still says why. Two quick clicks
74
+ on a slow mount could land you in the folder you did not pick.
75
+ - Truncation and naming: the filter chip said "1 changed files", the clean-tree
76
+ line was not a sentence and named two of its three cases, the Discovered list
77
+ called repos "projects" while the settings panel called them repos, the
78
+ outline squeezed away the symbol name to keep its parent, and the browse
79
+ bar chopped paths with no ellipsis.
80
+ - Accessibility: the activity rail announced the Changes tab as "(12)" in the
81
+ icon-only band, the tree-refresh and parent-directory glyphs had no name, and
82
+ arrowing through search hits announced nothing.
83
+ - The daemon's save failure read "Could not save settings: Error: EACCES…",
84
+ with the exception's own prefix glued into the sentence.
85
+
86
+ ## [0.11.0] - 2026-08-06
87
+
88
+ ### Added
89
+
90
+ - **Search file contents across the repo** (Ctrl/⌘+Shift+F, or bare `F`), in the
91
+ web UI. Literal text, not a pattern — `git grep -F`, so there is no regex to
92
+ learn and none to hang the daemon. Results group by file with line numbers;
93
+ Enter opens the file in the Explorer scrolled to the matching line. The corpus
94
+ is the same as the file finder's: tracked plus untracked, never gitignored.
95
+ Bounded server-side — 500 results, 20 per file, 4 MiB, 5 seconds — and it says
96
+ when it hit a limit rather than quietly showing you less.
97
+
98
+ - **Better hunk headers for the languages git ships regexes for.** The
99
+ `@@ ... @@ <context>` text names the function a hunk is inside, but git only
100
+ guesses well when a gitattributes file opts the path into one of its built-in
101
+ drivers, which most repos never set up. diffstalker now supplies that default
102
+ itself, at the lowest priority, so a repo's own `.gitattributes` still wins.
103
+ Python goes from `class Widget:` to `def render(self):`; Java from
104
+ `public class Widget {` to `public void render() {`; Ruby, Go, Rust, C#, PHP
105
+ and the rest likewise. **TypeScript, JavaScript and Vue are unaffected** —
106
+ git ships no driver for them, and borrowing another language's does not work.
107
+
108
+ - **`/` narrows the changed-file list, in the web UI.** Type to hide the rows
109
+ you are not looking at; the diff stack narrows with the list, so it also
110
+ shortens the page. It is a filter, not a search: no syntax, no scopes, and it
111
+ only ever hides rows from the set already on screen. The count always names
112
+ its corpus ("4 of 214 changed files"), a filter matching nothing says so
113
+ rather than looking like a clean tree, and the query resets when the repo
114
+ changes under you (follow mode). Esc clears it.
115
+
116
+ - **`e` expands every large diff at once, in the web UI.** A file past 1500
117
+ changed lines starts behind a "Load diff" gate, which also hides it from the
118
+ browser's own find-in-page. One key mounts all of them, so Ctrl+F then
119
+ reaches the whole changeset. It does nothing when nothing is gated.
120
+
121
+ ### Fixed
122
+
123
+ - **A commit no longer dies mid-hook, and a fetch no longer dies mid-transfer.**
124
+ The idle timeout added alongside the funcname drivers applied to every git
125
+ call, including ones that are legitimately silent for a long time: git only
126
+ writes progress to a terminal, so a pre-commit hook running a test suite, or a
127
+ pack being negotiated, looks identical to a hang. Hook-running and remote
128
+ operations now get a much larger budget; local reads keep the short one. Both
129
+ are still bounded.
130
+ - **Content search no longer 500s on a huge matched line, a NUL, a newline, or a
131
+ very long query.** An over-budget result now returns what it found and says it
132
+ is partial; a query git cannot take literally is refused with a clear message
133
+ instead of surfacing as a server error. Searching also no longer needs git
134
+ 2.38 — the per-file cap is counted locally rather than passed to `git grep`.
135
+ - **diffstalker no longer displaces your own global gitattributes.** The
136
+ generated funcname defaults are only injected when you have no per-user
137
+ attributes of your own; previously they took priority over yours and silently
138
+ dropped every rule you had defined, textconv and merge drivers included.
139
+ - **The terminal UI no longer misses a file-list change that lands mid-fetch.**
140
+ A status change arriving while `/files` was in flight was swallowed by the
141
+ reply that overtook it, leaving the finder showing a list that predated it.
142
+ - **`/` is inert in views that have no filter.** It used to set invisible state
143
+ on Journal, History, Compare and Explorer, which then appeared as an
144
+ already-open filter on returning to Changes.
145
+ - **A hung git command can no longer wedge a request forever.** Every git
146
+ invocation now has an idle timeout — 10 seconds for local reads, 10 minutes
147
+ for anything running your hooks or talking to a remote. Without it a stuck
148
+ credential prompt or an unresponsive remote held its queued operation open
149
+ for the life of the process.
150
+ - **Ctrl+C now quits from the file finder too.** It was the one place in the
151
+ terminal UI where the universal exit did nothing: the finder's text input
152
+ takes over the keyboard and swallows control characters, so the app-level
153
+ binding never saw the key.
154
+ - **The terminal UI no longer refetches the whole file list on every watcher
155
+ tick.** A status change now just marks the list stale, and the finder fetches
156
+ it when it opens. On a busy tree that was one round-trip per tick for a list
157
+ nobody was looking at.
158
+ - **Pressing the finder key repeatedly on a slow daemon no longer stacks up
159
+ finder windows.** The modal slot is now claimed before the file list is
160
+ fetched, not after.
161
+ - **A file whose name contains blessed markup no longer corrupts the finder.**
162
+ Result text is escaped before it is drawn.
163
+ - **The version indicator no longer freezes at whatever was true when the tab
164
+ opened.** It was pulled only when the event stream connected, so a tab left
165
+ open on a second monitor — the way this is meant to be used — never asked
166
+ again and kept reporting "up to date" indefinitely. It now re-asks hourly
167
+ while connected, and stops when the stream closes. The daemon still caches
168
+ npm's answer for six hours, so this costs one local request an hour.
169
+ - **A tab now notices when the daemon under it was restarted on a new
170
+ version.** The web UI ships inside the daemon package, so the daemon's own
171
+ version identifies the bundle: when it changes, the page is older than the
172
+ API it is calling and the status bar says so and asks for a reload. It never
173
+ reloads on its own — this is a tool people leave open to keep looking at
174
+ something.
175
+
8
176
  ## [0.10.0] - 2026-08-03
9
177
 
10
178
  ### Added
package/README.md CHANGED
@@ -217,13 +217,18 @@ values are rejected with a 400 so they can never be parsed as git flags.
217
217
  | GET | `/repos/:id/files` | All tracked + untracked (not ignored) paths: the fuzzy-finder source |
218
218
  | GET | `/repos/:id/journal?since=` | Append-only edit journal: `{epoch, prunedBefore, entries}`; `since=<seq>` returns only entries with a higher seq (all when omitted) |
219
219
  | GET | `/repos/:id/events` | SSE: `snapshot` on connect, then `state-change` events from the file watcher and `journal-append {entries}` per journal observation |
220
- | GET | `/events` | Daemon-scope SSE: `snapshot` (open repos) on connect, then `repo-opened` / `repo-closed` / `follow-change` |
220
+ | GET | `/events` | Daemon-scope SSE: `snapshot` (open repos) on connect, then `repo-opened` / `repo-closed` / `follow-change` / `settings-change` / `discovery-change` |
221
221
  | GET | `/follow` | Follow state: `{targetFile, enabled, followedRepoId, followedPath}` |
222
+ | GET | `/settings` | Daemon settings: `{watchRoots, persisted}`. `persisted: false` means this daemon holds them in memory only (no settings file) |
223
+ | GET | `/discovered` | Repos found under the watch directories: `{roots: [{path, repos: [{path, name, branch, lastActivity}], error, capped}]}`. See [Watch directories](#watch-directories) |
224
+ | GET | `/browse?path=` | One directory level of the daemon's filesystem, for picking a watch directory: `{path, parent, home, entries: [{name, path, isRepo}]}`. Directory names only — no files, no dot directories. No `path` starts at the daemon's home; 400 for a relative path, 404 for one it cannot read |
222
225
 
223
226
  ### Mutations (all respond `{state, result?}`)
224
227
 
225
228
  | Method | Path | Body / behavior |
226
229
  | ------ | -------------------------- | ------------------------------------------------ |
230
+ | PUT | `/settings` | Replace the settings: `{"watchRoots": ["/abs/dir", "~/projects"]}` → `{watchRoots, persisted}`. Whole document, not a patch. Each path is expanded, made absolute and checked to be an existing directory; a refusal is a 400 naming the path, and nothing is saved |
231
+ | POST | `/discovered/rescan` | Re-walk every watch directory now and return the new `{roots}` (filesystem only, no git processes) |
227
232
  | POST | `/repos/:id/stage` | `{"path": "file.txt"}` — stage one file (404 when not in status) |
228
233
  | POST | `/repos/:id/unstage` | `{"path": "file.txt"}` — unstage one file |
229
234
  | POST | `/repos/:id/stage-all` | Stage everything |
@@ -391,6 +396,51 @@ sec-fetch-dest`, and either `cache-control: no-store` (`side=worktree`, whose
391
396
  bytes can change under us) or `cache-control: private, no-cache` plus an
392
397
  `etag` of the object id (`side=index|head`, which are immutable).
393
398
 
399
+ ## Watch directories
400
+
401
+ A watch directory is a folder the user keeps projects in. The daemon scans
402
+ each configured one for git repositories and keeps that list live, so a
403
+ client can offer "your projects" instead of an empty path field — a browser
404
+ cannot browse the daemon's filesystem, and this is what replaces typing an
405
+ absolute path every time.
406
+
407
+ Discovery LISTS repos; it never opens them. Opening is what starts a
408
+ watcher and git state per repo, so a folder with fifty projects would
409
+ otherwise cost fifty of each. A discovered repo is `{path, name, branch}`
410
+ until a client calls `POST /repos` for it.
411
+
412
+ The scan is filesystem-only — no git process. A directory holding a `.git`
413
+ entry is a repo, and its branch is read from `.git/HEAD` (a short sha when
414
+ detached). It looks at the root's children, and one level further inside a
415
+ child that is not itself a repo (so `~/projects/work/thing` is found), and
416
+ stops descending as soon as it finds a repo — a repo's own subdirectories,
417
+ submodules included, are never listed as projects. Dot directories,
418
+ `node_modules` and friends are skipped, symlinked directories are not
419
+ followed, and the list is capped (500 repos, reported as `capped: true`
420
+ rather than silently trimmed). A leftover worktree directory whose git dir
421
+ has been pruned is dropped: it would only produce "not a git repository"
422
+ when clicked.
423
+
424
+ A client picks a watch directory through `GET /browse`, which walks the
425
+ daemon's directories one level at a time. That has to happen here: a browser
426
+ is never handed a real path by its own file pickers (`webkitdirectory` gives
427
+ relative names, `showDirectoryPicker` a bare handle), so the one thing this
428
+ API needs — an absolute path on the daemon's machine — is exactly what the
429
+ page cannot produce.
430
+
431
+ Each root also gets a chokidar watcher one level deep, so a clone appearing
432
+ in the folder shows up without anyone reloading; directory add/remove is
433
+ the only thing it reacts to, debounced. The watcher deliberately does not
434
+ look inside a repo's `.git`, so a branch label can lag a checkout made
435
+ elsewhere — `POST /discovered/rescan` is how a client refreshes it.
436
+
437
+ Settings persist in `~/.config/diffstalker/daemon.json` (or
438
+ `$XDG_CONFIG_HOME`), written atomically and re-read at startup. A root that
439
+ is configured but currently unreadable (an unmounted disk) keeps its place
440
+ in the settings and is reported with an `error` — it is never quietly
441
+ dropped. Both `/settings` and `/discovered` are served on every transport,
442
+ including a `--port` listener: the settings UI lives in the web client.
443
+
394
444
  ## Follow mode
395
445
 
396
446
  The daemon owns the truth, clients decide policy. It watches ONE hook file
@@ -426,4 +476,6 @@ curl --unix-socket "$SOCK" -X POST -d '{"path": "file.txt"}' http://localhost/re
426
476
  curl --unix-socket "$SOCK" -N http://localhost/repos/<id>/events
427
477
  curl --unix-socket "$SOCK" -N http://localhost/events
428
478
  curl --unix-socket "$SOCK" http://localhost/follow
479
+ curl --unix-socket "$SOCK" -X PUT -d '{"watchRoots": ["~/projects"]}' http://localhost/settings
480
+ curl --unix-socket "$SOCK" http://localhost/discovered
429
481
  ```