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

feat(settings): per-instance display-name fallback in Settings tab (#239)

[._.]/ Adam Eivy72a0a4f24002
diff --git a/CLAUDE.md b/CLAUDE.md
index f67130b0ee..5f0ffbd27d 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -148,6 +148,7 @@ When working **directly in the Claude Code TUI** with the user driving, edit the
- **No try/catch** - errors bubble to centralized middleware. **Exception:** PTY/child-process/`setTimeout`/`setInterval` callbacks and any code that runs *outside* the Express request lifecycle. An uncaught throw there crashes the Node process (there is no `next(err)` to bubble to). At those boundaries, wrap hook invocation in try/catch and log via the emoji-prefixed `console.error` style. Async event handlers that mutate shared module-level state (e.g. the TUI spawner's `handleData`) must also be serialized — chain them onto a per-session/per-actor `Promise.resolve()` queue rather than firing concurrently, otherwise interleaved awaits race on shared buffers.
- **No window.alert/confirm** - use inline confirmations or toast notifications
+- **Form labels need `htmlFor`/`id` pairing** - when adding a settings/config form field, wire `<label htmlFor="...">` to an `id="..."` on the input — screen readers and click-to-focus both depend on the association. The visual `block`/`mb-1` styling alone doesn't establish it.
- **Linkable routes for all views** - tabbed pages use URL params, not local state (e.g., `/devtools/history` not `/devtools` with tab state)
- **Functional programming** - no classes, use hooks in React
- **Zod validation** - all route inputs validated via `lib/validation.js`
@@ -169,7 +170,7 @@ When working **directly in the Claude Code TUI** with the user driving, edit the
- Arrays/objects: gate on `Array.isArray(parsed?.field)` / `typeof parsed?.field === 'object'` before deciding to fall back to the original.
- Keep server-side merges and the client's `pick` helpers mirrored — a one-sided change breaks the round-trip.
- **Schema parity when adding fields.** When you add a field to a sanitizer, `createXxx`, or a payload shape, update the corresponding Zod schema (`server/lib/aiToolkit/validation.js` for toolkit shapes, `server/lib/validation.js` for PortOS routes) in the same change. Wire validation into POST and PUT (PUT can use `schema.partial()`); the PortOS convention is *all* inputs validated — an exported-but-unwired sub-schema creates false confidence. For polymorphic stores like `PUT /api/settings` that accept any sub-object, validate the relevant slice with `schema.partial()` when its key is present in the request body (see `server/routes/settings.js` for the `backupConfigSchema.partial()` pattern). Tolerate UI sentinels (`endpoint: ''` for CLI providers) with `z.preprocess(v => v === '' ? undefined : v, …)`. When a service migrates legacy keys on read, the schema must still accept the legacy shape so older clients don't 400 before the migration runs.
-- **Silent vs. toasting API requests.** The `request()` helper in `client/src/services/apiCore.js` toasts errors by default. When a caller already owns its own error UI — either via `useAsyncAction` (which toasts on throw) or a `.catch(() => fallback)` that intentionally swallows the failure — pass `{ silent: true }` to the API helper so the toast only fires from one layer. Add an `options` parameter to new API wrappers so callers can opt into silent mode.
+- **Silent vs. toasting API requests.** The `request()` helper in `client/src/services/apiCore.js` toasts errors by default. When a caller already owns its own error UI — either via `useAsyncAction` (which toasts on throw) or a `.catch(() => fallback)` that intentionally swallows the failure — pass `{ silent: true }` to the API helper so the toast only fires from one layer. Add an `options` parameter to new API wrappers so callers can opt into silent mode. **Custom catch ⇒ `silent: true`.** When you have a custom error toast in `.catch()`, you MUST pass `{ silent: true }` — otherwise both the helper and your custom catch fire and the user sees two toasts back-to-back. If you DON'T have a custom toast, omit `silent` and let the helper handle it (single layer wins either way).
- **"Run Now" actions must gate on saved state, not the form input.** When a settings page has a companion "Run this now" button that triggers a server action reading server-side settings (not the local form values), the button must be gated on the *saved* value, not the in-memory input. Track a parallel `saved*` state for each setting the action depends on, update it on successful save, and use it for the action's enabled gate. Disable the action while the form is dirty *or* a save is in flight — a tooltip-only warning is missed on touch and produces surprising "I edited X and ran, but X didn't apply" bugs.
- **In-flight saves must gate dependent actions, not just the form.** When a field's PATCH is async and a button triggers server-side work that reads that field (auto-run, regenerate, etc.), the button must disable while the PATCH is in flight — not just while the input is "dirty." Otherwise the user picks a new value, the input clears, and they click the action before the server has the new value persisted. Track a `<field>Saving` boolean alongside the action's other disable predicates, set it before the PATCH and clear it in `.finally()`. See `PipelineIssue.jsx` `lengthProfileSaving` for the canonical example.
- **Async PATCH races on shared records — serialize writes server-side.** When two write paths can mutate the same record concurrently (e.g. a blur-save plus an explicit "Render" button against `stages.comicPages.cover`), client-side guards (refs, `onMouseDown`, status checks) are unreliable — keyboard activation, status==='unknown' stalls, and `loadState → modify → saveState` interleaving all defeat them. The correct fix is to serialize writes at the *file* level on the server (every PATCH awaits the previous one to settle before reading state, so it merges against the freshest persisted record). See `issueWriteTail` in `server/services/pipeline/issues.js`. A `Map<recordId, Promise>` is *not* enough — two writes to different record ids share the same JSON state file and can still clobber each other; collapse the queue to a single tail per shared file.
diff --git a/DONE.md b/DONE.md
index b0bd889446..b57ba98379 100644
--- a/DONE.md
+++ b/DONE.md
@@ -4,6 +4,10 @@ Archive of completed work. For active roadmap, see [PLAN.md](./PLAN.md). For pro
---
+## 2026-05-16
+
+- **Sharing display-name settings — discoverable from the Settings tab structure** — New `client/src/components/settings/SharingTab.jsx` mirrors the display-name + bio strip from the Sharing page top so users can find the source-attribution fields under `/settings/sharing` as well. Standalone tab uses a vertical card layout with a textarea (not single-line input) for the 2000-char bio. Wired into `client/src/pages/Settings.jsx` TABS + switch, sidebar in `client/src/components/Layout.jsx`, and `server/lib/navManifest.js` (`nav.settings.sharing`) so it's reachable from sidebar, `⌘K`, and voice. The existing Sharing page top strip stays in place — both surfaces hit the same `sharingDisplayName` / `sharingBio` settings keys.
+
## 2026-05-12
- **Civitai / Z-Image follow-ups — six post-merge cleanups** — Six items off the "Civitai LoRA / Z-Image-Turbo follow-ups" backlog in one pass.
diff --git a/PLAN.md b/PLAN.md
index 4855318e1a..aa34d9e032 100644
--- a/PLAN.md
+++ b/PLAN.md
@@ -10,7 +10,6 @@ For project goals, see [GOALS.md](./GOALS.md). For completed work, see [DONE.md]
V1 landed: buckets, ShareToButton on Pipeline + UniverseBuilder + MediaCollection, OriginBadge, exporter with full gen-metadata fidelity, importer with `auto-merge` + `inbox` modes, chokidar watcher, configurable `sharingDisplayName` source attribution, nav-manifest registration. V1.1: id-preserving inserts (`insertSeriesWithId` / `insertIssueWithId` / `insertUniverseWithId`) so re-shares LWW-merge instead of duplicating; `overridden[]` outcome surfaced via socket → global `useSharingNotifications` toast; round-trip integration tests. V1.2: schema versioning — `SHARING_SCHEMA_VERSION` stamped on every manifest + bucket.json, `producedByVersion` (PortOS app version) on every manifest, importer refuses future-version manifests with a clear toast + cursor-mark, bucket cards warn when remote schema > local. V1.3: subscription model for series + universe — toggle on/off in ShareToButton with real state indicators, persistent (bucket, record) tuples in `data/sharing/subscriptions.json`, deterministic-filename manifests that overwrite on re-export, auto-re-export on edit via `recordEvents` (debounced 3s), `unlink` → `handleUnshare` flow that propagates "stop sharing" to recipients without reverting their local copies, content-aware cursor (`processedById` map). V1.4: collection-aware universe shares — `mediaCollections.universeId` field links a collection to its parent universe, exporter bundles the collection (record + items + assets + media-job records) when a universe is shared, importer find-or-creates the local collection and unions the items in, item-add/remove emits `recordEvents` on the linked universe so subscriptions auto-re-export when peer adds new images. See `~/.claude/plans/new-high-priority-task-valiant-wall.md` for design. Remaining follow-ups:
-- [ ] **Per-instance display-name fallback inside the Sharing page.** Settings save flow currently lives on the Sharing page top strip; mirror it into the existing Settings tab structure (`client/src/components/settings/`) so the field is discoverable from both surfaces.
- [ ] **Manifest archive pruning.** A bucket lived long enough accumulates thousands of manifests under `<bucket>/manifests/`. Add a per-bucket retention policy (e.g. keep last 500 manifests, archive the rest into `manifests/.archive/` or drop entirely once cursor advances past them).
- [ ] **Route-level tests for `server/routes/sharing.js`.** Bucket CRUD + export + inbox actions + subscriptions are exercised through the service layer in integration.test.js + subscriptions.test.js, but the HTTP surface (Zod rejection, error mapping) is uncovered. Add a `server/routes/sharing.test.js` to lock the JSON contract.
- [ ] **Auto-unsubscribe on local record delete.** Today if the user deletes a subscribed series/universe, the subscription in `data/sharing/subscriptions.json` becomes an orphan — next re-export attempt logs an error but the entry persists. Hook `deleteSeries` / `deleteUniverse` to call `unsubscribe()` for every subscription where `recordId === id`. Surface the unshare in the UI so the user sees "Removed from N bucket(s)" alongside the deletion toast.
diff --git a/client/src/components/Layout.jsx b/client/src/components/Layout.jsx
index 832891f241..46639353bb 100644
--- a/client/src/components/Layout.jsx
+++ b/client/src/components/Layout.jsx
@@ -285,6 +285,7 @@ const navItems = [
{ to: '/settings/mortalloom', label: 'MortalLoom', icon: Activity },
{ to: '/prompts', label: 'Prompts', icon: FileText },
{ to: '/ai', label: 'Providers', icon: Bot },
+ { to: '/settings/sharing', label: 'Sharing', icon: Share2 },
{ to: '/settings/telegram', label: 'Telegram', icon: MessageSquare },
{ to: '/settings/voice', label: 'Voice', icon: Mic }
]
diff --git a/client/src/components/settings/SharingTab.jsx b/client/src/components/settings/SharingTab.jsx
new file mode 100644
index 0000000000..ce29634657
--- /dev/null
+++ b/client/src/components/settings/SharingTab.jsx
@@ -0,0 +1,102 @@
+import { useEffect, useState } from 'react';
+import { Save, Loader2, Users } from 'lucide-react';
+import toast from '../ui/Toast';
+import BrailleSpinner from '../BrailleSpinner';
+import { getSettings, updateSettings } from '../../services/api';
+
+export function SharingTab() {
+ const [loading, setLoading] = useState(true);
+ const [displayName, setDisplayName] = useState('');
+ const [bio, setBio] = useState('');
+ const [savedDisplayName, setSavedDisplayName] = useState('');
+ const [savedBio, setSavedBio] = useState('');
+ const [saving, setSaving] = useState(false);
+
+ useEffect(() => {
+ getSettings({ silent: true })
+ .then((settings) => {
+ const display = settings?.sharingDisplayName || '';
+ const b = settings?.sharingBio || '';
+ setDisplayName(display);
+ setBio(b);
+ setSavedDisplayName(display);
+ setSavedBio(b);
+ })
+ .catch(() => toast.error('Failed to load settings'))
+ .finally(() => setLoading(false));
+ }, []);
+
+ const dirty = displayName !== savedDisplayName || bio !== savedBio;
+
+ const handleSave = async () => {
+ setSaving(true);
+ const patch = {
+ sharingDisplayName: displayName.trim(),
+ sharingBio: bio.trim(),
+ };
+ const merged = await updateSettings(patch).catch(() => null);
+ setSaving(false);
+ if (!merged) return;
+ setDisplayName(patch.sharingDisplayName);
+ setBio(patch.sharingBio);
+ setSavedDisplayName(patch.sharingDisplayName);
+ setSavedBio(patch.sharingBio);
+ toast.success('Saved');
+ };
+
+ if (loading) return <BrailleSpinner />;
+
+ return (
+ <div className="space-y-6">
+ <div className="bg-port-card border border-port-border rounded-lg p-4 sm:p-6">
+ <div className="flex items-center gap-2 mb-2">
+ <Users size={16} className="text-port-accent" />
+ <h3 className="text-lg font-semibold text-white">Sharing identity</h3>
+ </div>
+ <p className="text-sm text-gray-400 mb-4">
+ This display name is stamped as the <em>source</em> on every share you send through the Sharing page.
+ Recipients see it as attribution. Each bucket can override this with its own display name + bio.
+ </p>
+ <div className="space-y-3">
+ <div>
+ <label htmlFor="sharing-display-name" className="block text-xs uppercase tracking-wider text-gray-500 mb-1">Display name</label>
+ <input
+ id="sharing-display-name"
+ type="text"
+ value={displayName}
+ onChange={(e) => setDisplayName(e.target.value)}
+ placeholder="Display name (e.g. atomantic)"
+ maxLength={120}
+ className="w-full sm:max-w-md px-3 py-2 bg-port-bg border border-port-border rounded text-white text-sm"
+ />
+ </div>
+ <div>
+ <label htmlFor="sharing-bio" className="block text-xs uppercase tracking-wider text-gray-500 mb-1">Bio (optional)</label>
+ <textarea
+ id="sharing-bio"
+ value={bio}
+ onChange={(e) => setBio(e.target.value)}
+ placeholder="Optional bio / contact note (visible to recipients)"
+ maxLength={2000}
+ rows={3}
+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded text-white text-sm resize-y"
+ />
+ </div>
+ <div>
+ <button
+ type="button"
+ onClick={handleSave}
+ disabled={!dirty || saving}
+ className="inline-flex items-center justify-center gap-2 min-h-[40px] px-4 py-2 bg-port-accent/20 hover:bg-port-accent/30 text-port-accent rounded-lg text-sm transition-colors disabled:opacity-40 disabled:cursor-not-allowed"
+ >
+ {saving ? <Loader2 size={14} className="animate-spin" /> : <Save size={14} />}
+ {saving ? 'Saving...' : 'Save'}
+ </button>
+ </div>
+ </div>
+ </div>
+ </div>
+ );
+}
+
+export default SharingTab;
diff --git a/client/src/pages/Settings.jsx b/client/src/pages/Settings.jsx
index 26179af2d7..35367378e6 100644
--- a/client/src/pages/Settings.jsx
+++ b/client/src/pages/Settings.jsx
@@ -4,12 +4,14 @@ import { DatabaseTab } from '../components/settings/DatabaseTab';
import { TelegramTab } from '../components/settings/TelegramTab';
import { GeneralTab } from '../components/settings/GeneralTab';
import { MortalLoomTab } from '../components/settings/MortalLoomTab';
+import { SharingTab } from '../components/settings/SharingTab';
import { VoiceTab } from '../components/settings/VoiceTab';
const TABS = [
{ id: 'general', label: 'General' },
{ id: 'backup', label: 'Backup' },
{ id: 'database', label: 'Database' },
+ { id: 'sharing', label: 'Sharing' },
{ id: 'voice', label: 'Voice' },
{ id: 'telegram', label: 'Telegram' },
{ id: 'mortalloom', label: 'MortalLoom' }
@@ -40,6 +42,7 @@ export default function Settings() {
case 'general': return <GeneralTab />;
case 'backup': return <BackupTab />;
case 'database': return <DatabaseTab />;
+ case 'sharing': return <SharingTab />;
case 'voice': return <VoiceTab />;
case 'telegram': return <TelegramTab />;
case 'mortalloom': return <MortalLoomTab />;
diff --git a/client/src/services/apiSystem.js b/client/src/services/apiSystem.js
index 2885c436fc..a22f34c59c 100644
--- a/client/src/services/apiSystem.js
+++ b/client/src/services/apiSystem.js
@@ -22,10 +22,11 @@ export const clearIgnoredVersions = () => request('/update/ignore', { method: 'D
export const executePortosUpdate = () => request('/update/execute', { method: 'POST' });
// Settings
-export const getSettings = () => request('/settings');
-export const updateSettings = (data) => request('/settings', {
+export const getSettings = (options) => request('/settings', options);
+export const updateSettings = (data, options) => request('/settings', {
method: 'PUT',
- body: JSON.stringify(data)
+ body: JSON.stringify(data),
+ ...options
});
// Usage
diff --git a/server/lib/navManifest.js b/server/lib/navManifest.js
index 56815c1bea..de6046efc6 100644
--- a/server/lib/navManifest.js
+++ b/server/lib/navManifest.js
@@ -126,6 +126,7 @@ export const NAV_COMMANDS = [
{ id: 'nav.settings.database', path: '/settings/database', label: 'Database', section: 'Settings', aliases: ['settings-database', 'database'] },
{ id: 'nav.settings.general', path: '/settings/general', label: 'General', section: 'Settings', aliases: ['settings', 'settings-general', 'general'] },
{ id: 'nav.settings.mortalloom', path: '/settings/mortalloom', label: 'MortalLoom', section: 'Settings', aliases: ['settings-mortalloom', 'mortalloom'] },
+ { id: 'nav.settings.sharing', path: '/settings/sharing', label: 'Sharing', section: 'Settings', aliases: ['settings-sharing', 'sharing-settings'], keywords: ['display name', 'bio', 'attribution', 'identity', 'source'] },
{ id: 'nav.settings.telegram', path: '/settings/telegram', label: 'Telegram', section: 'Settings', aliases: ['settings-telegram', 'telegram'] },
{ id: 'nav.settings.voice', path: '/settings/voice', label: 'Voice', section: 'Settings', aliases: ['settings-voice', 'voice', 'voice-settings'], keywords: ['mic', 'microphone', 'speech', 'tts', 'whisper', 'kokoro'] },