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

refactor([tabpills-pipelineissue-status-dot-trailing-slot]): TabPills trailing slot + migrate PipelineIssue stage tabs

[._.]/ Adam Eivyce6242f3f03d
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 89eb52e380..d92d806529 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -44,6 +44,7 @@
- **`canonPrompt` shared helper (`server/lib/canonPrompt.js` + `client/src/lib/canonPrompt.js` mirror).** Single source of truth for per-kind canon descriptor field precedence. Exports `shortCanonDescriptorFragments` (UI-summary scope), `richCanonDescriptorFragments` (render-prompt scope), `descriptorForCanonEntry` (flattened short string), and `hasCanonDescriptorContent` (rich-field union for "has anything to render?" gates). Migrated four call sites: `synthesizeCanonPrompt` in `server/services/universeBuilder.js`, `KINDS[].descFor` in `client/src/components/universe/UniverseCanonSection.jsx`, `canonEntryHasContent` in `client/src/pages/UniverseBuilder.jsx`, and `settingFrags` in `server/lib/scenePrompt.js` + client mirror. Minor cosmetic uniformity: lowercase `palette:`/`era:`/`weather:`/`significance:` prefixes in canon render prompts are now capitalized to match the UI descriptor format — case-only change, no functional impact on diffusion models. 29 new tests in `server/lib/canonPrompt.test.js`.
- **`TabPills` UI primitive (`client/src/components/ui/TabPills.jsx`).** Consolidates ten duplicated tab-nav patterns — two local `TabNav` components (UniverseBuilder, StoryboardPanel) plus eight inline tab-button blocks (Brain, Calendar, ChiefOfStaff, DigitalTwin, MediaGen, Messages, Settings, Wiki). Two variants (`underline` default, `pills`) with knobs for the call-site quirks (`runningKind` per-tab spinner, `stretch` flex-1 equal-width, `mobileDropdown` `<select>` fallback, `hideLabelOnMobile` icon-only at < sm, `controlsIdPrefix` for `aria-controls` wiring, `listRef`+`onScroll` for ChiefOfStaff's scroll-arrow overlay). Covered by 7 vitest cases. Minor intentional visual unification across the surface area: StoryboardPanel active tab text-port-accent (was text-white), ChiefOfStaff and Settings gained the standard `bg-port-accent/5` active wash + `hover:bg-port-card` inactive.
+- **`TabPills` — `trailing` slot for per-tab status indicators.** Added an optional `t.trailing` ReactNode rendered after the count in both `underline` and `pills` variants. Migrates `PipelineIssue.jsx`'s 11th inlined tab-row (the only remaining outlier — its per-tab status dot didn't fit the prior shape) onto the shared primitive, replacing 22 lines of bespoke `<button>` markup with the standard underline-variant render. Also brings the row's mobile touch targets (`min-h-[44px]`) and icon size (16 vs 14) in line with the rest of the app. +1 vitest case asserting DOM-order (`trailing` follows `count`).
- **CoS — explicit `init()` instead of module-level auto-init.** `server/services/cos.js` previously called `init()` at the bottom of the module, gated by `NODE_ENV !== 'test' && VITEST !== 'true'` so unit tests didn't spin up listeners/timers. The guard was a "test hack in the prod boot path" — `init` is now exported and called explicitly from `server/index.js` alongside `automationScheduler.init()` / `agentActionExecutor.init()` / etc. Test imports of `cos.js` no longer have side effects, and the prod boot path no longer branches on test-env vars.
- **`LoraPicker` extracted** (`client/src/components/imageGen/LoraPicker.jsx`). The LoRA multi-select previously inlined in `ImageGen.jsx` is now a shared component used by both the standalone Image Gen page and the Universe Builder batch-render form.
- **`ImageGenSettingsForm` extended** with `showLoras` + `showStylePreset` props (mounts `LoraPicker` / `StylePresetPicker`) and the previously-hidden CFG / quantize / model-defaults reset.
diff --git a/DONE.md b/DONE.md
index 078b39ca0a..f389de58d8 100644
--- a/DONE.md
+++ b/DONE.md
@@ -10,6 +10,7 @@ For active roadmap see [PLAN.md](./PLAN.md). For project goals see [GOALS.md](./
### 2026-05-18
+- **[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.
- **[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 8061cb6e9d..916e09a763 100644
--- a/PLAN.md
+++ b/PLAN.md
@@ -103,7 +103,6 @@ _Nothing currently parked — pick the next item from the Backlog._
### Code quality / dedup (from `/simplify` passes)
-- [ ] [tabpills-pipelineissue-status-dot-trailing-slot] **Extend `<TabPills>` with a `trailing` slot to migrate `PipelineIssue.jsx`.** That page's tab row renders a per-tab status dot (`<span className="w-1.5 h-1.5 rounded-full ${STATUS_DOT[status]}" />`) after the label (see `client/src/pages/PipelineIssue.jsx:298-319`). Add an optional `t.trailing` ReactNode to the tab shape (rendered after the count), then migrate the call site. Defer until the next time a tab-bar variant lands so the API surface grows in response to a concrete second user, not in anticipation.
- [ ] [more-resolveproviderandmodel-migration-candidates] **More `resolveProviderAndModel` migration candidates.** When the helper landed in `server/lib/promptRunner.js` (universe-builder PR), three additional pure two-step provider-resolution chains were left alone to keep scope tight: `server/services/agentContentGenerator.js#runAIGeneration` (line ~80–90), `server/services/agentPersonalityGenerator.js` (line ~68–79), `server/services/loops.js` (line ~64–77). All three are textbook fits (no `enabled` gate, no typed-error throw mid-chain). Migration is one-import + 5-line collapse per file.
- [ ] [extract-assertprovider-provider-errormessage-code] **Extract `assertProvider(provider, { errorMessage, code, status })` helper.** After the `resolveProviderAndModel` migration there are now 4 `if (!provider) throw …` sites with varying error shapes (`Error` vs `ServerError`, `status: 400/503`, codes `NO_PROVIDER`/`UNIVERSE_PROMOTE_NO_PROVIDER`/etc.). One helper that takes the error-shape args would consolidate without forcing each caller to share the same error type.
- [ ] [extract-mergeexpandintodraft-draft-result-from] **Extract `mergeExpandIntoDraft(draft, result)` from `UniverseBuilder.jsx#handleExpand`.** The function is ~150 lines mixing pure-merge logic (categories, sheets, canon, locks) with I/O shell (API call, setDraft, auto-save, toast). Pull the merge into a top-level pure helper so the I/O surface shrinks and the merge is unit-testable. Deferred from Phase B `/simplify` to keep that PR tightly scoped.
diff --git a/client/src/components/ui/TabPills.jsx b/client/src/components/ui/TabPills.jsx
index f3adca9389..02faba6756 100644
--- a/client/src/components/ui/TabPills.jsx
+++ b/client/src/components/ui/TabPills.jsx
@@ -5,7 +5,8 @@
// spinner; `stretch` makes each tab `flex-1` (StoryboardPanel); `mobileDropdown`
// collapses to a `<select>` below `sm` (UniverseBuilder); `controlsIdPrefix`
// wires `aria-controls` (and `id="tab-<id>"`) to matching tabpanels — pass
-// `'tabpanel'` to mirror ChiefOfStaff's wiring.
+// `'tabpanel'` to mirror ChiefOfStaff's wiring. `t.trailing` is an optional
+// ReactNode rendered after the count (e.g. PipelineIssue's per-stage status dot).
import { Loader2 } from 'lucide-react';
const SIZE = {
@@ -91,6 +92,7 @@ export default function TabPills({
{t.count}
</span>
)}
+ {t.trailing}
</button>
);
})}
@@ -147,6 +149,7 @@ export default function TabPills({
{t.count}
</span>
)}
+ {t.trailing}
</button>
);
})}
diff --git a/client/src/components/ui/TabPills.test.jsx b/client/src/components/ui/TabPills.test.jsx
index c6cdef8642..b056b36636 100644
--- a/client/src/components/ui/TabPills.test.jsx
+++ b/client/src/components/ui/TabPills.test.jsx
@@ -107,3 +107,25 @@ describe('TabPills — runningKind', () => {
expect(container.querySelector('.lucide-loader-2, .lucide-loader-circle')).toBeTruthy();
});
});
+
+describe('TabPills — trailing slot', () => {
+ it('renders t.trailing inside the tab button after the count, in both variants', () => {
+ const tabs = [
+ { id: 'a', label: 'A', count: 2, trailing: <span data-testid="dot-a" /> },
+ { id: 'b', label: 'B', trailing: <span data-testid="dot-b" /> },
+ ];
+ // underline variant
+ const { rerender } = render(<TabPills tabs={tabs} activeTab="a" onChange={() => {}} />);
+ const aBtn = screen.getByRole('tab', { name: /A/i });
+ expect(within(aBtn).getByTestId('dot-a')).toBeInTheDocument();
+ // Count node sits before the trailing node in DOM order so the dot trails it.
+ const children = Array.from(aBtn.children);
+ const countIdx = children.findIndex((c) => c.textContent === '2');
+ const dotIdx = children.findIndex((c) => c.getAttribute('data-testid') === 'dot-a');
+ expect(countIdx).toBeGreaterThanOrEqual(0);
+ expect(dotIdx).toBeGreaterThan(countIdx);
+ // pills variant: same contract
+ rerender(<TabPills variant="pills" tabs={tabs} activeTab="a" onChange={() => {}} />);
+ expect(within(screen.getByRole('tab', { name: /B/i })).getByTestId('dot-b')).toBeInTheDocument();
+ });
+});
diff --git a/client/src/pages/PipelineIssue.jsx b/client/src/pages/PipelineIssue.jsx
index d68d6fbebd..1c948d9f30 100644
--- a/client/src/pages/PipelineIssue.jsx
+++ b/client/src/pages/PipelineIssue.jsx
@@ -14,6 +14,7 @@ import {
} from 'lucide-react';
import toast from '../components/ui/Toast';
import Modal from '../components/ui/Modal';
+import TabPills from '../components/ui/TabPills';
import {
getPipelineIssue, getPipelineSeries, updatePipelineIssue,
startPipelineAutoRunText, cancelPipelineAutoRunText,
@@ -191,12 +192,15 @@ export default function PipelineIssue() {
// the strip uncluttered. Showing the audio data still works for users
// who navigate to `/pipeline/issues/:id/audio` directly.
.filter((id) => id !== 'audio' || series?.targetFormat !== 'comic')
- .map((id) => ({
- id,
- label: PIPELINE_STAGE_LABELS[id],
- Icon: STAGE_ICONS[id],
- status: issue?.stages?.[id]?.status || 'empty',
- })), [issue, series?.targetFormat]);
+ .map((id) => {
+ const status = issue?.stages?.[id]?.status || 'empty';
+ return {
+ id,
+ label: PIPELINE_STAGE_LABELS[id],
+ icon: STAGE_ICONS[id],
+ trailing: <span className={`w-1.5 h-1.5 rounded-full ${STATUS_DOT[status] || STATUS_DOT.empty}`} aria-hidden="true" />,
+ };
+ }), [issue, series?.targetFormat]);
if (loading) return <div className="p-6 text-gray-500 text-sm">Loading issue…</div>;
if (!issue) return null;
@@ -295,28 +299,12 @@ export default function PipelineIssue() {
</div>
{/* Stage tabs */}
- <div className="flex border-b border-port-border overflow-x-auto" role="tablist">
- {stageTabs.map(({ id, label, Icon, status }) => {
- const isActive = id === stageId;
- return (
- <button
- key={id}
- onClick={() => navigate(`/pipeline/issues/${issueId}/${id}`)}
- role="tab"
- aria-selected={isActive}
- className={`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors whitespace-nowrap ${
- isActive
- ? 'text-port-accent border-b-2 border-port-accent bg-port-accent/5'
- : 'text-gray-400 hover:text-white hover:bg-port-card'
- }`}
- >
- <Icon size={14} aria-hidden="true" />
- {label}
- <span className={`w-1.5 h-1.5 rounded-full ${STATUS_DOT[status] || STATUS_DOT.empty}`} aria-hidden="true" />
- </button>
- );
- })}
- </div>
+ <TabPills
+ tabs={stageTabs}
+ activeTab={stageId}
+ onChange={(id) => navigate(`/pipeline/issues/${issueId}/${id}`)}
+ ariaLabel="Pipeline stages"
+ />
{/* Active stage panel */}
<div className="flex-1 overflow-auto p-4 md:p-6">