Files
pad/web
xarmian 08b6d94d30 feat(web): revalidate attachment strip content on parent restore (TASK-2511)
The item attachment strip has no SSE subscription — its only live inputs are
the in-process delete/upload buses — so a restore that happened while this
browser was elsewhere never reaches it, and its rows keep rendering from the
pre-archive fetch (thumb URLs work again by accident, metadata may be stale).

Thread `parentArchived` from ItemDetail (the same signal the timeline U1 and the
surface host DR-14 take, so it covers BULK archive/restore whose
`items_bulk_updated` carries no item_id) and reconcile the CONTENT gap
(PLAN-2392 3c-iii U2):

- RESTORE (true->false edge): `revalidateAfterRestore` re-fetches the attachment
  list and MERGES it over the current rows — a DIFFERENT, gentler path than the
  load effect's non-retry rerun, which blanks attachments/expanded/pendingDelete/
  deletedIds/pendingUploads synchronously. It never blanks (rows stay painted
  until replaced), preserves the tombstones / pending uploads / expanded-overflow
  / open confirmation the reset path would wipe, recomputes the continuation
  count off the fresh `total`, and clears a stale load error on success. A failed
  revalidation is swallowed (not surfaced as the blocking error row) — the strip
  already holds a good pre-archive list.

- ARCHIVE (false->true edge): a content no-op. Tiles keep their painted bytes;
  the interaction paths already fail server-side (DR-14's 404 correction).

Edge correctness:
- The archived latch is keyed to VIEW IDENTITY, not just the boolean: the strip
  persists across item switches, so an archived item A -> active item B is also a
  true->false transition — reseeding the latch on any view-key change keeps a
  SWITCH from firing a duplicate racing load (round-3 P2).
- `inFlightDeletes` (ref-counted, so a concurrent second delete of the same id
  can't be cleared early) excludes a row whose optimistic removal has run but
  whose tombstone broadcast — post-await in `performDelete` — hasn't yet, so a
  restore refetch landing in that window can't repaint the just-removed tile
  (round-3 P1).
- The revalidation DEFERS to a load already fetching THIS view (per-view counter,
  since the api client has no request abort and a stale prior-view load lingers):
  that load returns fresh-enough data, and superseding it would strand the strip
  empty if the revalidation then failed.

Latches are plain `let`s read/written under `untrack` (the Svelte self-write
trap). Adds the strip's `parentArchived` prop mount in ItemDetail. 22 new unit
tests; each guard mutation-verified.

Claude-Session: https://claude.ai/code/session_01WFBYxdBuSZs2tjipATxAZu
2026-08-11 02:16:38 +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
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