Files
pad/web
xarmian 10b99dec2e feat(attachments): viewer deletion subscription — advance or close by identity (TASK-2477)
The image Lightbox subscribes to the deletion bus and reconciles a delete by
IDENTITY (DR-5c): the shown image is tracked by id, the index derived, so a
delete advances to a survivor or closes — never lands on a position that now
names a different member.

- The index-based `current` state is replaced by `shownId` (the shown image's
  id) + a `tombstones` Set. `survivors` = navigable minus tombstones (composes
  with D's unsafe/unresolved exclusions — a fallback-arm entry is deletable too);
  `shownIndex` derives from `shownId` (falls to 0 when it dangles); prev/next
  write `shownId`. Tombstones are per-instance and never reset — every producer
  keys the mount, so a reopen is a fresh empty set (no cross-open leakage).
- handleDeletion(uuid): idempotent; a delete NOT in the surviving set (unsafe/
  unresolved, another item's attachment, a dangling shown id) is tombstoned and
  ignored (no advance, no closing an already-empty viewer). An in-set delete
  advances `shownId` to the entry that followed the deleted one (wrap when the
  last) when the SHOWN one went, closes when zero survive, and leaves `shownId`
  put otherwise (identity, not index — deleting an earlier image keeps the same
  one shown). The id-keyed zoom-reset fires exactly on a real advance.
- ONE path for both origins: the toolbar's own Delete announces on the bus (the
  descriptor's `announceAttachmentDeleted`), identical to an external delete, so
  the survivor logic can't tell them apart. The C1 close-on-delete latch is
  retired (the viewer had no survivor logic then); the toolbar ctx now omits
  `onDeleted` (that stays the panel's). The listener is disposed in the same
  teardown that releases the backdrop lease.

Tests: the DR-5c case table (only/zero-left → close, one-left, deleting-shown →
advance, wrap-around, deleting-earlier → same image by identity, reopen clears
tombstones), plus delete-during-drag, delete racing the confirm drill-down, a
non-image fallback delete, the dangling-id / empty-viewer guard cases, and a
two-image toolbar integration in the strip suite (confirm → api → announce →
advance). The strip's events mock now fans `announceAttachmentDeleted` out to
listeners, matching production.

Claude-Session: https://claude.ai/code/session_01WFBYxdBuSZs2tjipATxAZu
2026-08-08 17:23:29 +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