ZDDC/browse/js
ZDDC c240bf30a5 feat(browse): persist selection + show-hidden in URL
The browse SPA's URL bar now reflects the currently-selected node and
the show-hidden toggle, so:

  - bookmarking / copy-pasting the URL re-opens the same view
  - reload (forced by the admin-mode toggle, which has to reload to
    pick up the elevation cookie) lands the user back on the same
    selection with intermediates expanded
  - browser back/forward walks history correctly, re-applying both
    the scope AND the file/hidden state at each step

Implementation:
  events.js: syncURLToSelection() — builds <scope>/?file=<rel>&hidden=1
    via URLSearchParams (with %2F → '/' so the URL bar reads cleanly)
    and history.replaceState's it. Called from every selectedId set
    site (single-click, arrow-key nav, right-click), from the show-
    hidden toggle, and after rescopeServer's scope pushState so the
    new scope keeps the hidden flag.
  app.js bootstrap: reads ?hidden=1 in addition to the existing
    auto-flip-on-dotfile logic, so an explicit hidden toggle survives
    reload.
  app.js popstate: re-walks ?file= via openDeepLink so back/forward
    restore not just the scope but the selection + expansion path.
    Also re-applies hidden=1.

Choice: replaceState (not pushState) on selection changes — the only
"intentional" navigation step is the scope rescope (already pushState).
A long click sequence shouldn't pollute history.

What this doesn't cover: sibling folders the user expanded that aren't
on the path-to-selection. Persisting that needs sessionStorage; for
"as much as possible without overcomplicating" the URL-only state
captures scope, selected node, and the path-to-selection (auto-
expanded by the deep-link walker) — the most common case.

FS-API mode (offline / file://) is a no-op — no shareable URL.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-18 17:00:20 -05:00
..
accept-transmittal.js feat: reviewing/ lifecycle — Plan Review endpoint, virtual received window, browse context-menu workflows 2026-05-15 16:08:04 -05:00
app.js feat(browse): persist selection + show-hidden in URL 2026-05-18 17:00:20 -05:00
create-transmittal.js feat: reviewing/ lifecycle — Plan Review endpoint, virtual received window, browse context-menu workflows 2026-05-15 16:08:04 -05:00
download.js refactor: virtual file extensions for subtree zip + MD conversion 2026-05-14 12:23:37 -05:00
events.js feat(browse): persist selection + show-hidden in URL 2026-05-18 17:00:20 -05:00
grid.js feat(zddc): Phase 4b — grid mode driven by cascade default_tool 2026-05-11 16:15:25 -05:00
hovercard.js feat(browse): extension chip under tree icon + archive refs in hovercard 2026-05-18 08:18:01 -05:00
init.js feat(browse): SPA overhaul — context menu, YAML editor, icons, hovercard, deep links, autofilter 2026-05-14 12:12:42 -05:00
loader.js feat(browse): editors honor server-side write authority + don't steal focus 2026-05-18 09:42:36 -05:00
plan-review.js feat: reviewing/ lifecycle — Plan Review endpoint, virtual received window, browse context-menu workflows 2026-05-15 16:08:04 -05:00
preview-markdown.js fix(browse): trim markdown read-only banner + drop YAML front-matter placeholder 2026-05-18 09:47:21 -05:00
preview-yaml.js refactor(audit): pre-release cleanup pass 2026-05-18 16:28:07 -05:00
preview.js feat(browse): SPA overhaul — context menu, YAML editor, icons, hovercard, deep links, autofilter 2026-05-14 12:12:42 -05:00
stage.js feat: reviewing/ lifecycle — Plan Review endpoint, virtual received window, browse context-menu workflows 2026-05-15 16:08:04 -05:00
tree.js fix(browse): propagate writable bit into tree nodes 2026-05-18 16:47:57 -05:00
upload.js feat: reviewing/ lifecycle — Plan Review endpoint, virtual received window, browse context-menu workflows 2026-05-15 16:08:04 -05:00