Skip to content

fix: reduce clicks/keystrokes -- web restore, open, config, error msgs - #23

Merged
adeelahmad merged 5 commits into
masterfrom
ux-pass
Oct 10, 2026
Merged

adeelahmad merged 5 commits into
masterfrom
ux-pass

Conversation

@adeelahmad

Copy link
Copy Markdown
Owner

Summary

Five real bugs found during a UX friction audit (goal: fewer clicks and keystrokes for common tasks), each fixed test-first in its own worktree then folded here:

  • Web UI restore was dead code. HistoryView.Versions was never populated, history.html had no click target on file rows, and app.js never called the already-fully-implemented /api/versions//api/download//api/restore. Restoring a file was only possible by hand-crafting API requests in devtools. Now: click a file in history, pick a version, download or restore it -- verified end to end in a real browser.
  • snapback open was broken on macOS. It hard-coded xdg-open, which doesn't exist on darwin, so the command silently did nothing on the exact platform this project is developed on. Now branches on runtime.GOOS, mirroring the pattern internal/web/command.go already used.
  • link/seed's "outside configured roots" error was a dead end. It named the rejected directory but gave no next step, forcing a trip to the docs to learn the roots[] YAML shape. Now includes a copy-pasteable snippet with the real path substituted in.
  • The Config page silently misassigned new roots to cfg.Repositories[0].ID regardless of how many repositories were configured -- a real correctness bug for any multi-repository setup, not just a cosmetic one. Now accepts an optional path=<repository id> suffix per line; single-repository setups are unaffected.
  • The global --config flag was silently ignored unless it was the very first argument. snapback status --config /path would silently fall back to the default config with no warning. Now parsed anywhere in the argument list before subcommand dispatch.

Test plan

  • Each fix built test-first (RED confirmed failing, then GREEN) in its own worktree
  • gofmt -l clean
  • go vet ./... clean
  • golangci-lint run ./... -- 0 issues
  • go build ./... clean
  • go test -race ./... -- all packages pass, zero regressions
  • Web restore flow additionally verified manually end to end in a real browser against live test data

internal/cli/open.go shelled out to xdg-open unconditionally, which does
not exist on macOS, so `snapback open <dir>` silently failed for every
macOS user. Mirror the platform branch internal/web/command.go already
uses for its own "open in browser" opener: pick `open` on darwin,
`xdg-open` on linux (unchanged), and return a clear error naming the
directory path on any other GOOS instead of a confusing exec failure.
File rows on /history had no click target and HistoryView.Versions was
never set, so the Versions panel, Download and Restore were dead code.

- handleHistory gives each non-directory entry its root-relative path.
- history.html renders that as a versions-open button carrying root and
  file (the parameters /api/versions reads), and an empty hidden Versions
  panel when nothing is prefetched.
- app.js fetches /api/versions on click, lists each copy with a Download
  link to /api/download and a restore form for /api/restore, and shows
  the restored path from the response with an Open in file manager button.
- Restore forms now send root, which /api/restore needs to resolve file.
…snippet

ErrOutsideRoots only named the rejected directory, forcing a trip to
docs-site/configuration.md to learn the roots[] YAML shape. Policy only
carries each root's ID and local path (no repository info reaches it from
cmd/snapback's wiring), so the repository_id is a placeholder the user
fills in; the id and local_path are real, derived from the given directory.
run() only recognized --config when it was literally args[0], so a user
typing e.g. "snapback status --config X" had the flag silently fall through
as a positional argument and the command ran against the default config
instead -- no warning, no error. Scan the full arg list for --config /
--config=PATH once before dispatch, strip it, and feed the resolved path
into the same env.ConfigPath every subcommand already reads; error (exit 2)
if --config has no value, instead of swallowing it.
Every new root typed into the Config page's "Roots" textarea was silently
assigned to cfg.Repositories[0], regardless of how many repositories are
configured. A new root's line now accepts an optional "=<repository id>"
suffix to choose the repository explicitly; with exactly one repository
configured the suffix is still unnecessary, matching today's behavior. An
existing root's line is always treated as its literal local path (never
split), so an edit to an existing root can't be misread as a repository
suffix or have "=" silently stripped from its path. An unresolved or
missing repository choice is now a clear, re-rendered form error instead
of a silent misassignment.
@adeelahmad
adeelahmad merged commit 3018a2b into master Oct 10, 2026
13 checks passed
@adeelahmad
adeelahmad deleted the ux-pass branch October 10, 2026 21:18
github-actions Bot pushed a commit that referenced this pull request Oct 10, 2026
## [1.6.2](v1.6.1...v1.6.2) (2026-10-10)

### Bug Fixes

* reduce clicks/keystrokes -- web restore, open, config, error msgs ([#23](#23)) ([3018a2b](3018a2b))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant