Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

address review: full-card overlay label + actions outside <label>; p-3 parity

[._.]/ Adam Eivy0a8a159ca8f3
diff --git a/DONE.md b/DONE.md
index d69cf68f93..49b9c01b43 100644
--- a/DONE.md
+++ b/DONE.md
@@ -13,7 +13,7 @@ For active roadmap see [PLAN.md](./PLAN.md). For project goals see [GOALS.md](./
- **[tabpills-pipelineissue-status-dot-trailing-slot] Extend `<TabPills>` with a `trailing` slot to migrate `PipelineIssue.jsx`.** Added an optional `t.trailing` ReactNode to the tab shape, rendered after the count in both `underline` and `pills` variants of `client/src/components/ui/TabPills.jsx`. Migrated `client/src/pages/PipelineIssue.jsx`'s previously-inlined stage tab row (the 11th outlier — its per-tab `STATUS_DOT[status]` indicator didn't fit the prior contract) onto `<TabPills>`, with the status dot supplied via `trailing`. Net 22-line bespoke `<button>` block collapsed onto the shared primitive; the row also picks up the standard mobile touch-target (`min-h-[44px]`) and icon size (16 vs 14) used elsewhere. +1 vitest case in `TabPills.test.jsx` pins the DOM-order contract (`trailing` follows `count`) in both variants; all 78 client tests pass.
- **[sharing-inbox-live-subscription-badge] "🔄 live" badge on inbox subscription rows.** Subscription rows in the Sharing → Inbox tab now show a small green "live" pill (spinning RefreshCw icon + label) when `item.subscription` is truthy AND `item.receivedAt` is within the last 5 minutes. Re-exports fire on every record edit with a 3s server-side debounce and propagate via chokidar in <1s, so a row received that recently is a real-time signal that the sender is actively editing. Pure `isLiveSubscription(item, now=Date.now())` helper exported from `client/src/pages/Sharing.jsx` (handles null/undefined inputs + unparseable `receivedAt` + one-shot shares without throwing); 5 new vitest cases in `Sharing.test.jsx` cover all four exit paths. Badge placement is inline in the row's metadata strip alongside source/kind/timestamp; freshness is computed on render so the badge naturally decays when the page re-renders (via socket updates) past the 5-min mark. All 82 client tests pass.
- **[nounsstage-cheaper-seriesnamemap-fetch] NounsStage seriesNameMap — avoid the heavy canon-usage fetch.** `NounsStage.jsx` was calling `GET /api/universe-builder/:id/canon-usage` purely to extract `seriesNameMap` for the CanonCard "from <series>" chip, which makes the server iterate every linked series × every issue × 3 prose matchers — O(series × issues × matchers) work for what should be O(series). Picked option (a) from the PLAN: new `GET /api/universe-builder/:id/series-names` endpoint returns `[{id,name}]` for linked series only, with no per-issue prose scan and no matchers. Backed by `listLinkedSeriesNames` in `server/services/canonUsage.js` (validates the universe via `getUniverse` so 404s mirror the heavier endpoint, then `listSeries().filter(s.universeId === id).map(s ⇒ ({id, name}))`). Client helper `getUniverseSeriesNames` in `apiUniverseBuilder.js`; `NounsStage` builds the map locally with `Object.fromEntries(list.map(...))`. `UniverseCanonSection` continues to use `canon-usage` because it actually needs the per-entry usage counts. +3 vitest cases in `canonUsage.test.js` (linked-series filter + ignores issues; empty result for no-linked universe; 404 for missing universe).
-- **[importer-review-ui-extract-canoncard-once-universe] Importer review UI shares the canon-card shell.** `Importer.jsx#CanonReviewSection` no longer hand-rolls its own checkbox card — it renders through the shared `EntryCard` primitive (the post-Phase-2 shell that `CanonCard` and `VariationCard` already render through). The full `CanonCard` contract (id-bearing entries, image refs, lock/refine/wardrobes, intExt/timeOfDay chips) doesn't fit the importer's pre-commit LLM output, so the cleanest "extract" was to lift the visual primitive instead. `EntryCard.jsx` gains a new `selectable={{ selected, onToggle, label? }}` slot: when provided, the card wraps its row in a `<label>`, renders an aria-labelled checkbox column, and swaps the `locked` accent for select-on (`border-port-accent bg-port-accent/5`) vs. select-off (`border-port-border opacity-60`) styling — matching the inline card's prior look pixel-for-pixel so importer users see no visual diff. 6 vitest cases in new `client/src/components/universe/EntryCard.test.jsx` cover: checkbox omitted when `selectable` is null, `selected`-bound state, `onToggle` fires on click, selected vs. unselected accent class application, and the generic-label fallback when `selectable.label` is omitted. All 83 client tests pass; client build succeeds.
+- **[importer-review-ui-extract-canoncard-once-universe] Importer review UI shares the canon-card shell.** `Importer.jsx#CanonReviewSection` no longer hand-rolls its own checkbox card — it renders through the shared `EntryCard` primitive (the post-Phase-2 shell that `CanonCard` and `VariationCard` already render through). The full `CanonCard` contract (id-bearing entries, image refs, lock/refine/wardrobes, intExt/timeOfDay chips) doesn't fit the importer's pre-commit LLM output, so the cleanest "extract" was to lift the visual primitive instead. `EntryCard.jsx` gains a new `selectable={{ selected, onToggle, label? }}` slot: when provided, the card overlays a `<label htmlFor>` across the padded surface (so the entire bordered card area toggles the checkbox, matching the prior inline card's full-card click target), renders an aria-labelled checkbox column with a unique `useId`, and swaps the `locked` accent for select-on (`border-port-accent bg-port-accent/5`) vs. select-off (`border-port-border opacity-60`) styling. Selectable mode uses `p-3` padding to match the pre-extract Importer card's spacing; `actions` and clickable (`onClick`) `thumbnail` slots sit on a `relative z-10` layer above the overlay so they stay independently clickable without nesting interactive controls inside a `<label>` (invalid HTML). 9 vitest cases in new `client/src/components/universe/EntryCard.test.jsx` cover: checkbox omitted when `selectable` is null, `selected`-bound state, `onToggle` fires on click, selected vs. unselected accent class application, the generic-label fallback, full-card overlay click toggles selection, action buttons stay outside the label and fire independently, and `p-3` spacing parity. All client tests pass; client build succeeds.
- **[sharing-inbox-orphans-on-peer-instance-id-rotation] Cull rotation-orphan inbox rows.** Closes the regression introduced by `[sharing-v2-per-sender-subscription-filenames]`: a peer that rotates its `senderInstanceId` (factory reset / new device) would otherwise leave its old identity's inbox row stranded forever, because the per-sender dedup keys on the new id. `applyInbox` in `server/services/sharing/importer.js` now culls cross-sender orphans on every subscription-manifest arrival when (a) same `(recordKind, recordId, source)`, (b) DIFFERENT `senderInstanceId`, and (c) existing row's `createdAt` older than the 30-day `ROTATION_CULL_MS` window. The window is conservative — two legitimately distinct peers sharing the same display name (e.g. both devices named "MacBook") would only be culled after a month of one going silent. 4 new integration tests in `integration.test.js` (cull at 60 days, preserve at 2 days, preserve different-source-old, and a freshness-gate early-return regression that asserts the cull still persists when the `inbox-has-newer` short-circuit fires). 79 sharing tests pass.
- **[content-addressed-asset-dedup-today-asset-copies] Content-addressed asset dedup.** Share-bucket asset blobs are now stored content-addressed at `<bucket>/assets/blobs/<sha256>` (sidecar metadata at `<sha256>.metadata.json`) instead of filename-addressed at `assets/{images,videos}/<filename>`. Two manifests referencing identical bytes under different filenames now share one on-disk blob — every additional reference is a no-op file-existence check on the same hash. New shared helper `sha256File` in `server/lib/fileUtils.js` (one-shot < 512 KB / streaming ≥ 512 KB); `server/services/backup.js#generateManifest` migrated to the same helper (its inline reimplementation deleted). Path/sidecar helpers (`bucketBlobsDir`, `bucketBlobPath`, `bucketBlobSidecarPath`, `imageSidecarName`, `IMAGE_EXT_RE`) live in `server/services/sharing/buckets.js` so storage-layout changes touch one file. `exporter.js#copyAssetIfPresent` computes the hash and returns `{ kind, ref, hash }` per asset; `importer.js#copyAssetsLocally` resolves bucket paths via a `resolveBucketAssetPaths` helper that prefers `assets/blobs/<hash>` when present and falls back to legacy `assets/{kind}/<filename>` for v1 manifests still in-bucket. `SHARING_SCHEMA_VERSION` bumped 1 → 2; bucket layout adds `assets/blobs/` in `ensureBucketLayout`. `annotationsSync.js#listBucketAssetKeys` now derives the user-facing filename set by scanning manifests' `assetRefs` (with the legacy dir scan retained as a fall-through for v1 buckets). Coverage: 4 new unit tests in `fileUtils.test.js` (small/large split, cross-path identical-bytes equality, distinct-bytes inequality) + 2 new integration tests in `integration.test.js` (two manifests with different filenames + identical bytes share one blob and import cleanly; v1 manifest without `hash` field still imports via legacy path) + updated existing integration assertions to expect `assets/blobs/<hash>` paths. All 249 server test files / 5452 tests pass. Two performance follow-ups captured in PLAN.md: per-source hash caching on the exporter, and per-bucket manifest-scan caching on the annotation flush path.
diff --git a/PLAN.md b/PLAN.md
index 955b1a666b..98114ab591 100644
--- a/PLAN.md
+++ b/PLAN.md
@@ -17,7 +17,7 @@ _Nothing currently parked — pick the next item from the Backlog._
### Importer (deferred research)
-- [ ] [importer-canonprompt-preview-fragments-helper] **Share a per-kind preview-fragments helper between Importer and `canonPrompt.js`.** Importer's `CanonReviewSection` callsite (`client/src/pages/Importer.jsx:467-495`) inlines `renderSubtitle` + `renderBody` for each of characters/places/objects. Existing `client/src/lib/canonPrompt.js` already centralizes short/rich descriptor fragments for the render-prompt scope but doesn't fit pre-commit preview: (a) Importer wants ALL visible fields (`personality`, `background`, `role`, `slugline`) for the user to judge before committing — wider than `shortCanonDescriptorFragments`; (b) `normalizeKind` accepts `'setting'` but not `'places'` (the importer's canonSelections key), so a drop-in call would silently return `[]`. Add a `previewCanonFragments(kind, entry, { includeAll: true })` variant and teach `normalizeKind` to alias `'places' → 'settings'`. Then collapse the Importer's three inline `renderBody`/`renderSubtitle` callbacks onto the helper. Deferred from `[importer-review-ui-extract-canoncard-once-universe]`.
+- [ ] [importer-canonprompt-preview-fragments-helper] **Share a per-kind preview-fragments helper between Importer and `canonPrompt.js`.** Importer's three `CanonReviewSection` callsites (`client/src/pages/Importer.jsx:468-496`) inline `renderSubtitle` + `renderBody` for each of characters/places/objects. Existing `client/src/lib/canonPrompt.js` already centralizes short/rich descriptor fragments for the render-prompt scope but doesn't fit pre-commit preview: (a) Importer wants ALL visible fields (`personality`, `background`, `role`, `slugline`) for the user to judge before committing — wider than `shortCanonDescriptorFragments`; (b) `normalizeKind` accepts `'setting'` but not `'places'` (the importer's canonSelections key), so a drop-in call would silently return `[]`. Add a `previewCanonFragments(kind, entry, { includeAll: true })` variant and teach `normalizeKind` to alias `'places' → 'settings'`. Then collapse the Importer's three inline `renderBody`/`renderSubtitle` callbacks onto the helper. Deferred from `[importer-review-ui-extract-canoncard-once-universe]`.
- [ ] [chunked-extraction-for-source-200k-chars-today-s] **Chunked extraction for source > 200K chars.** Today's `IMPORTER_SOURCE_CHAR_LIMIT` hard-rejects. Once a real import hits the cap, route through per-chunk canon extraction + rolling synopsis. **Investigate chunk-overlap / merge strategy first — research-required, not a drop-in feature.** Plan sketch: pick a chunk size that fits all three importer prompts (canon/arc/issue-proposal) under the smallest provider's context window after overhead; per-chunk canon-extract feeds back into `existingCanon` for the next chunk so dedup is rolling; rolling synopsis is generated after each chunk and prepended as `priorSynopsis` to the next; arc-extract runs against the final concatenated synopsis, not the raw source; issue-proposal honors chunk boundaries only when a chapter/issue marker straddles them. Open questions: (a) is overlap needed at all, or are chapter markers reliable enough to clean-cut at? (b) how to merge per-chunk arcs when chunks disagree on theme/protagonist? (c) progress UI — single bar or per-chunk? Defer until a real import actually hits the 200K cap; the hard-reject + "trim source" guidance is acceptable for now.
### Universe-as-Canon — Phase 2 + extensions
diff --git a/client/src/components/universe/EntryCard.jsx b/client/src/components/universe/EntryCard.jsx
index 644368709f..826efb6b4a 100644
--- a/client/src/components/universe/EntryCard.jsx
+++ b/client/src/components/universe/EntryCard.jsx
@@ -14,7 +14,13 @@
* into a checkbox-driven selection card (used by the Importer review for
* pre-commit canon picks). Selected accent matches `locked`'s family;
* unselected dims with `opacity-60` so picked vs. dropped reads at a glance.
+ * Implementation: an overlay `<label htmlFor>` sits above the padded card
+ * surface so the entire bordered area toggles the checkbox; `actions` and
+ * clickable (`onClick`) thumbnails sit on a `relative z-10` layer above the
+ * overlay so they remain independently clickable without nesting interactive
+ * controls inside a `<label>` (invalid HTML).
*/
+import { useId } from 'react';
import { Star } from 'lucide-react';
export default function EntryCard({
@@ -26,37 +32,48 @@ export default function EntryCard({
footer = null,
selectable = null,
}) {
+ const reactId = useId();
+ const checkboxId = selectable ? `entry-card-cb-${reactId}` : undefined;
const isSelected = selectable ? selectable.selected : false;
const borderClass = selectable
? (isSelected ? 'border-port-accent bg-port-accent/5' : 'border-port-border opacity-60')
: (locked ? 'border-port-accent/40' : 'border-port-border');
+ // Match the pre-extract Importer card spacing (p-3) in selectable mode so
+ // the visual diff vs. the inline card it replaces is genuinely zero.
+ const paddingClass = selectable ? 'p-3' : 'p-2';
- const row = (
- <div className="flex items-start gap-3">
+ return (
+ <li className={`relative rounded border bg-port-bg/60 ${paddingClass} ${borderClass}`}>
{selectable ? (
- <input
- type="checkbox"
- checked={isSelected}
- onChange={selectable.onToggle}
+ <label
+ htmlFor={checkboxId}
aria-label={selectable.label || 'Select entry'}
- className="mt-1 accent-port-accent shrink-0"
+ className="absolute inset-0 cursor-pointer"
/>
) : null}
- {thumbnail ? <EntryCardThumbnail {...thumbnail} /> : null}
- <div className="flex-1 min-w-0">
- {title}
- {body}
+ <div className="flex items-start gap-3">
+ {selectable ? (
+ <input
+ id={checkboxId}
+ type="checkbox"
+ checked={isSelected}
+ onChange={selectable.onToggle}
+ aria-label={selectable.label || 'Select entry'}
+ className="relative z-10 mt-1 accent-port-accent shrink-0"
+ />
+ ) : null}
+ {thumbnail ? (
+ <div className={thumbnail.onClick ? 'relative z-10' : undefined}>
+ <EntryCardThumbnail {...thumbnail} />
+ </div>
+ ) : null}
+ <div className="flex-1 min-w-0">
+ {title}
+ {body}
+ </div>
+ {actions ? <div className="relative z-10 shrink-0">{actions}</div> : null}
</div>
- {actions ? <div className="shrink-0">{actions}</div> : null}
- </div>
- );
-
- return (
- <li className={`rounded border bg-port-bg/60 p-2 ${borderClass}`}>
- {selectable ? (
- <label className="cursor-pointer block">{row}</label>
- ) : row}
- {footer}
+ {footer ? <div className="relative z-10">{footer}</div> : null}
</li>
);
}
diff --git a/client/src/components/universe/EntryCard.test.jsx b/client/src/components/universe/EntryCard.test.jsx
index 23c53a55c0..8605f3e493 100644
--- a/client/src/components/universe/EntryCard.test.jsx
+++ b/client/src/components/universe/EntryCard.test.jsx
@@ -69,4 +69,49 @@ describe('EntryCard — selectable mode', () => {
));
expect(screen.getByRole('checkbox', { name: 'Select entry' })).toBeInTheDocument();
});
+
+ it('clicking the padded card area (outside the checkbox) toggles selection', () => {
+ const onToggle = vi.fn();
+ const { container } = render(wrapInList(
+ <EntryCard
+ title={<div>Lyra</div>}
+ selectable={{ selected: false, onToggle, label: 'Include Lyra' }}
+ />,
+ ));
+ // The overlay label spans the entire padded card surface — clicking it
+ // (not the checkbox itself) must still toggle.
+ const overlay = container.querySelector('label');
+ expect(overlay).not.toBeNull();
+ fireEvent.click(overlay);
+ expect(onToggle).toHaveBeenCalledTimes(1);
+ });
+
+ it('keeps action buttons outside the checkbox label so they remain independently clickable', () => {
+ const onToggle = vi.fn();
+ const onAction = vi.fn();
+ render(wrapInList(
+ <EntryCard
+ title={<div>Lyra</div>}
+ selectable={{ selected: false, onToggle, label: 'Include Lyra' }}
+ actions={<button onClick={onAction}>Edit</button>}
+ />,
+ ));
+ // Sanity: the button is NOT nested inside the <label> (invalid HTML).
+ const button = screen.getByRole('button', { name: 'Edit' });
+ expect(button.closest('label')).toBeNull();
+ fireEvent.click(button);
+ expect(onAction).toHaveBeenCalledTimes(1);
+ expect(onToggle).not.toHaveBeenCalled();
+ });
+
+ it('uses p-3 padding in selectable mode to match the pre-extract Importer card', () => {
+ const { container } = render(wrapInList(
+ <EntryCard
+ title={<div>Lyra</div>}
+ selectable={{ selected: false, onToggle: () => {} }}
+ />,
+ ));
+ const li = container.querySelector('li');
+ expect(li.className).toMatch(/(^|\s)p-3(\s|$)/);
+ });
});