diffstalkerd 0.11.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,7 +5,83 @@ 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
- ## [Unreleased]
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.
9
85
 
10
86
  ## [0.11.0] - 2026-08-06
11
87
 
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
  ```