Files
pad/web
xarmian b447ce9938 feat(web): focus-follows-editing (activePane) on the full-page pane host (TASK-2181) (#986)
* feat(web): focus-follows-editing (activePane) on the full-page pane host (TASK-2181)

On the full-page item host, editing now FOLLOWS FOCUS: opening a pane keeps the
master editable and shows the pane as a read-only preview (DR-2); clicking a side
makes it the editable one and freezes the other. Exactly one side is editable at
any moment — the two-editor collision the freeze prevents still holds, now
dynamically. Builds on the TASK-2180 reactive freeze, so flipping `peeking` is a
cheap toggle (no editor remount).

- Host route ([collection]/[slug]/+page.svelte): adds `activePane: 'master'|'pane'`
  ($state, seeded viewport.isMobile ? 'pane' : 'master' for cold-load; forced to
  'pane' on the mobile-breakpoint transition). Master `peeking={!!openItemRef &&
  activePane==='pane'}`. First-open re-seeds the active side; drill / in-pane Back /
  ESC-pop set 'pane' via the controller's focusPaneRegion dep (single wire point).
  A document focusin classifier + capture-phase pointerdown activator flip
  activePane only on a CHANGED region, classifying against BOUND elements
  (itemPageEl / PaneHost.getPaneRegion()), exempting portalled surfaces (shared
  inExemptSurface) and ignoring bare-<body> drops.
- PaneHost.svelte: optional `activePane` prop (unset on the collection route →
  byte-identical). Forwards `peeking={activePane==='master'}` to its inner
  ItemDetail; exposes getPaneRegion(); the desktop focusin backstop only pulls
  focus back while activePane !== 'master' (so it no longer fights master
  activation; collection-route behavior preserved when the prop is unset).
- paneFocus.ts: extracts the shared inExemptSurface() set (reused by the mobile
  trap and the host classifier).
- ItemDetail.svelte: a FROZEN (peeking) instance never claims the singleton
  collectionStore.activeItem / editorStore — loadData gates setActiveItem +
  resetForDoc + setLastSaveTime on !peeking; onDestroy gates resetForDoc on
  !wasPeeking; the freeze-END reclaim is gated on itemMatchesRef and restores
  editorStore dirty/lastSaveTime from the instance's local shadows, so the
  singletons always follow the active side.
- +layout.svelte: fences the self-save-suppression's late setActiveItem
  continuation on the current activeItem (the ping-pong can switch sides mid-await).

Scope: full-page-host only; the collection route is untouched (pane stays always
editable there). No {#key} added (freeze is reactive). Known deferred R9
singleton-editorStore coupling for in-flight saves tracked in BUG-2184.

Claude-Session: https://claude.ai/code/session_01EZ6yr6pAUFb1uffan912ra

* fix(web): frozen side never writes singleton editorStore on remote collab; first-click drill from a frozen preview (TASK-2181)

Two in-scope fixes from an independent review pass:

1. A FROZEN (peeking) ItemDetail must not clobber the singleton editorStore that
   the ACTIVE side owns when REMOTE collab traffic syncs into its still-live Y.Doc.
   handleContentUpdate's collab path now gates editorStore.setDirty(true) on
   !peeking, and the collabFlusher save callback gates the singleton
   setLastSaveTime/setDirty(false) on !peeking. The per-instance shadows
   (localDirty/localLastSaveTime), the retain-alive snapshot persistence
   (collabFlusher.schedule), and the per-instance saveStatus/showSaved all stay
   unconditional — so the un-freeze END-reclaim still restores correct values and
   +layout's self-save suppression for the active item is no longer corrupted by a
   preview's background sync. (Distinct from BUG-2184's deferred pre-freeze
   continuation.)

2. A content-link / child-row drill from a FROZEN preview now works on the FIRST
   click. The focusin + capture-phase pointerdown detectors exclude navigable drill
   targets (isNavigableDrillTarget = closest('a[href]')), so they no longer flip
   activePane mid-gesture — which re-inited ChildItems' live dndzone (dragDisabled
   tracks the freeze) and swallowed the click. The click's own drill
   (navigatePaneTo → focusPaneRegion) sets activePane='pane', so the link drills AND
   activates the pane in one click. Exclusion covers BOTH detectors because
   Chromium/Firefox focus an <a> on mouse-click. Removed the capstone's
   pane-activation workaround and assert the first-click drill instead.

Claude-Session: https://claude.ai/code/session_01EZ6yr6pAUFb1uffan912ra
2026-07-20 13:37:42 -04:00
..
2026-03-26 01:52:36 +00:00
2026-03-26 01:52:36 +00:00
2026-03-26 01:52:36 +00:00
2026-03-26 01:52:36 +00:00
2026-03-26 01:52:36 +00:00

Pad Web UI

SvelteKit 2 + Svelte 5 frontend for Pad, compiled to static files and embedded into the Go binary.

Development

npm install
npm run dev          # Dev server at localhost:5173 (proxies API to localhost:7777)
npm run build        # Production build to build/
npm run check        # Type checking with svelte-check

When developing, run the Go backend separately with make dev from the project root.

Building for Production

Do not build in isolation. Always use make build from the project root — this builds the web frontend, then compiles the Go binary with the build output embedded via //go:embed.

Stack

  • Svelte 5 with runes ($state, $derived, $effect)
  • SvelteKit 2 with adapter-static (SPA mode)
  • Tiptap block editor with markdown round-trip
  • svelte-dnd-action for drag-and-drop in board/list views
  • SSE for real-time updates
  • TypeScript throughout

Structure

src/
  routes/                    SvelteKit pages
    +layout.svelte           App shell (sidebar + main)
    +page.svelte             Landing/redirect
    [workspace]/
      +page.svelte           Dashboard (collections, phases, activity)
      +layout.svelte         SSE connection per workspace
      [collection]/
        +page.svelte         Collection view (board/list)
      [collection]/[item]/
        +page.svelte         Item detail + editor
      conventions/            Purpose-built conventions page
      playbooks/              Purpose-built playbooks page
      settings/               Workspace settings
  lib/
    api/client.ts            HTTP API client
    components/
      layout/                Sidebar, navigation
      editor/                Tiptap editor, raw markdown editor
      fields/                FieldEditor, relation picker
      items/                 ItemCard, ItemDetail
      collections/           BoardView, ListView
      common/                StatusBadge, badges, modals
      search/                CommandPalette
      activity/              ActivityFeed
    stores/                  Svelte 5 reactive stores
      workspace.svelte.ts    Workspace state
      collections.svelte.ts  Collection + item state
      ui.svelte.ts           Sidebar, mobile state
    types/index.ts           TypeScript types and constants
  app.css                    Global styles and design tokens