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: editable link URL + optional title/tags on add, fix Other Links filter

Adam Eivy3807aa8cce76
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 0f6e6a1cbe..db560925a4 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -10,6 +10,8 @@ TBD
- **Brain → Links search**: a keyword search box on the Links tab filters the saved links list in real time across title, URL, description, and tags (case-insensitive). It composes with the existing GitHub/Other category tabs, includes a clear (×) affordance, and shows a distinct "no links match" empty state separate from the "no links saved yet" state. Filtering is client-side over the already-loaded list, so there are no extra round-trips and no server changes.
- **Unified Story Builder** (`/story-builder`): a new guided page that walks a story from idea → universe aesthetic → plot arc → reader map → characters → issues → production as one linear flow. Each step is LLM-assisted with an AI-refinement affordance and ends with an explicit lock before the next unlocks; going back to revise an earlier step soft-flags the downstream locked steps as "stale" (integrity gate) so nothing silently drifts — without destroying their content. The builder is a thin conductor over the existing Universe / Series / Issue records (no data duplication); heavy per-issue production hands off to the existing Pipeline issue page. Reachable from the sidebar (Create → Story Builder), ⌘K, and voice. The intro screen supports two intake modes: **start from a seed idea**, or **import a finished work** (comic script / screenplay / novel / short story) — the importer reverse-engineers it into a universe, arc, characters, and issues, then drops you into the wizard to review and lock each stage. An **AI provider/model picker** at the top of the builder (and the import tab) drives every operation — idea expand, aesthetic, arc, reader map, character refine, and the import analysis — persisted on the session so one selection applies throughout. The **characters step generates a styled preview image per character** (world style fused with the character descriptor, via the same render path as the Universe Builder) and shows it alongside each character so you can eyeball that the world and character styles read correctly together.
+- **Brain → Links: optional title & tags on quick-add**: the Links tab quick-add form now has a collapsible "Add title & tags (optional)" section so a link can be saved with a custom title and tags up front, instead of only being editable after the fact. Collapsed by default to keep the paste-and-go flow clean.
+- **Brain → Links: edit a link's URL**: the per-link edit form now exposes the URL alongside the title (each with a visible label so they're unambiguous even when the title defaults to the URL). Changing the URL re-derives the GitHub repo metadata, guards against duplicate URLs (409), and resets stale clone state so a cloned repo's local path can't point at the wrong target.
- **Base style image (style probe)** on a universe: generate a canonical image from the universe's embrace/avoid influences as the positive/negative prompt, with no character or subject — to preview the world's base visual emphasis. `styleNotes` is intentionally NOT mixed into the probe prompt because it never reaches the image model on any downstream prompt (canon refs, variations, sheets, comic pages) — including it would misrepresent what those renders will look like. Triggerable from both the Universe Builder (under the style/influences editor) and the Story Builder's Universe Aesthetic step; the result persists on the universe (`styleImageRefs`) so both surfaces share it. Includes a "Regenerate" affordance to re-roll the probe once an image already exists (new filenames append to `styleImageRefs[]` so prior renders survive as walk-back fallbacks).
- **Reader Map** on a series arc (`series.arc.readerMap`): a distinct audience-experience roadmap — hooks, payoffs, emotional beats, and cliffhangers across the arc — built on top of the Vonnegut story shape, separate from the protagonist arc. Generated and refined via the new Story Builder reader-map step (also preserved by arc regeneration).
- Local LLMs: when an Ollama model pull fails with `412: requires a newer version of Ollama`, PortOS now auto-upgrades Ollama in place and retries the install — no confirm click. On macOS with `/Applications/Ollama.app` present, this downloads the latest `Ollama-darwin.zip` directly from GitHub releases, force-kills the running Ollama, replaces the `.app` bundle, strips quarantine, relaunches, and polls `/api/version` until the new binary is serving. (The old brew-only path silently left the old binary running, because `/usr/local/bin/ollama` symlinks into the `.app` bundle — even a successful `brew upgrade` doesn't change which binary is on disk inside the `.app`.) On Linux it still re-runs the official Ollama install script; for headless macOS installs (brew formula only, no `.app`), it still runs `brew upgrade ollama`. The UI now shows a prominent yellow warning banner with live step-by-step progress for the whole upgrade flow, instead of a quiet inline confirm row. Failed `brew` runs now also surface the actual stderr (e.g. `Error: ollama not installed`) instead of just an exit code.
@@ -18,6 +20,7 @@ TBD
## Fixed
+- **Brain → Links "Other Links" filter showed GitHub repos**: the filter sent `isGitHubRepo=false` as a query string, but the route schema used `z.coerce.boolean()` — and `Boolean("false")` is `true`, so "Other Links" behaved identically to "GitHub Repos". The schema now parses the string explicitly so `"false"` → `false`.
- **Story Builder data-loss fixes** surfaced by the local-review pass on the unified-story-builder branch:
- `generateStep('plotArc')` was wholesale-replacing `series.arc` and `series.seasons` via a plain `updateSeries({ arc, seasons })`, which silently dropped per-field arc locks, locked seasons, and orphaned every child issue attached to a renamed/removed season. Route through `commitSeasonsWithRemap` (same helper the Arc Canvas regenerator uses) so locks are honored and orphaned issues are remapped via normalized title → number → positional fallback.
- `resolveVerifyIssues` (the auto-resolve path off the Arc Canvas verify panel) was silently wiping `series.arc.readerMap`: the LLM payload doesn't author the reader map, so omitting it from the sanitizeArc call defaulted the field to `null` and `commitSeasonsWithRemap`'s `mergeArcWithLocks` only restores fields when their per-field lock is `true`. A user who'd generated a reader map without locking it lost the entire map the first time they auto-resolved a finding. The sibling `generateArcOverview` already had this fix; `resolveVerifyIssues` drifted from it despite the "Mirrors `resolveVerifyIssues`" comment.
diff --git a/client/src/components/brain/tabs/LinksTab.jsx b/client/src/components/brain/tabs/LinksTab.jsx
index cf125c59b5..07b76f37f4 100644
--- a/client/src/components/brain/tabs/LinksTab.jsx
+++ b/client/src/components/brain/tabs/LinksTab.jsx
@@ -16,7 +16,9 @@ import {
FolderOpen,
Tag,
ShieldCheck,
- Search
+ Search,
+ ChevronDown,
+ ChevronUp
} from 'lucide-react';
import BrailleSpinner from '../../BrailleSpinner';
import toast from '../../ui/Toast';
@@ -42,6 +44,9 @@ const CLONE_STATUS_STYLES = {
export default function LinksTab({ onRefresh }) {
const [inputUrl, setInputUrl] = useState('');
+ const [inputTitle, setInputTitle] = useState('');
+ const [inputTags, setInputTags] = useState('');
+ const [showDetails, setShowDetails] = useState(false);
const [sending, setSending] = useState(false);
const [links, setLinks] = useState([]);
const [total, setTotal] = useState(0);
@@ -106,8 +111,14 @@ export default function LinksTab({ onRefresh }) {
}
}
+ const payload = { url };
+ const title = inputTitle.trim();
+ if (title) payload.title = title;
+ const tags = inputTags.split(',').map(t => t.trim()).filter(Boolean);
+ if (tags.length) payload.tags = tags;
+
setSending(true);
- const result = await api.createBrainLink({ url }).catch(err => {
+ const result = await api.createBrainLink(payload).catch(err => {
if (err.message?.includes('already exists')) {
toast.error('This URL is already saved');
} else {
@@ -121,6 +132,9 @@ export default function LinksTab({ onRefresh }) {
const isGitHub = result.isGitHubRepo;
toast.success(isGitHub ? 'GitHub repo added - cloning in background' : 'Link saved');
setInputUrl('');
+ setInputTitle('');
+ setInputTags('');
+ setShowDetails(false);
fetchLinks();
onRefresh?.();
}
@@ -129,6 +143,7 @@ export default function LinksTab({ onRefresh }) {
const handleEdit = (link) => {
setEditingId(link.id);
setEditForm({
+ url: link.url,
title: link.title,
description: link.description || '',
linkType: link.linkType,
@@ -137,7 +152,14 @@ export default function LinksTab({ onRefresh }) {
};
const handleSaveEdit = async (linkId) => {
+ const url = editForm.url?.trim();
+ if (!url) {
+ toast.error('URL cannot be empty');
+ return;
+ }
+
const updates = {
+ url,
title: editForm.title,
description: editForm.description,
linkType: editForm.linkType,
@@ -145,7 +167,11 @@ export default function LinksTab({ onRefresh }) {
};
const result = await api.updateBrainLink(linkId, updates).catch(err => {
- toast.error(err.message || 'Failed to update');
+ if (err.message?.includes('already exists')) {
+ toast.error('Another link already uses this URL');
+ } else {
+ toast.error(err.message || 'Failed to update');
+ }
return null;
});
@@ -252,6 +278,44 @@ export default function LinksTab({ onRefresh }) {
)}
</button>
</div>
+ <button
+ type="button"
+ onClick={() => setShowDetails(v => !v)}
+ className="mt-2 flex items-center gap-1 text-xs text-gray-400 hover:text-white transition-colors"
+ >
+ {showDetails ? <ChevronUp size={12} /> : <ChevronDown size={12} />}
+ {showDetails ? 'Hide title & tags' : 'Add title & tags (optional)'}
+ </button>
+
+ {showDetails && (
+ <div className="mt-2 space-y-2">
+ <div>
+ <label htmlFor="link-title" className="sr-only">Title</label>
+ <input
+ id="link-title"
+ type="text"
+ value={inputTitle}
+ onChange={(e) => setInputTitle(e.target.value)}
+ placeholder="Title (defaults to repo name or URL)"
+ className="w-full px-3 py-2 bg-port-card border border-port-border rounded-lg text-white text-sm placeholder-gray-500 focus:outline-hidden focus:border-port-accent"
+ disabled={sending}
+ />
+ </div>
+ <div>
+ <label htmlFor="link-tags" className="sr-only">Tags</label>
+ <input
+ id="link-tags"
+ type="text"
+ value={inputTags}
+ onChange={(e) => setInputTags(e.target.value)}
+ placeholder="Tags (comma-separated)"
+ className="w-full px-3 py-2 bg-port-card border border-port-border rounded-lg text-white text-sm placeholder-gray-500 focus:outline-hidden focus:border-port-accent"
+ disabled={sending}
+ />
+ </div>
+ </div>
+ )}
+
<p className="mt-2 text-xs text-gray-500">
Paste any URL. GitHub repos will be automatically cloned for local reference.
</p>
@@ -318,14 +382,29 @@ export default function LinksTab({ onRefresh }) {
<div className="flex items-start justify-between gap-3 mb-2">
{editingId === link.id ? (
<div className="flex-1 space-y-2">
- <input
- type="text"
- value={editForm.title}
- onChange={(e) => setEditForm({ ...editForm, title: e.target.value })}
- className="w-full px-2 py-1 bg-port-bg border border-port-border rounded text-white text-sm"
- placeholder="Title"
- autoFocus
- />
+ <div>
+ <label htmlFor={`link-url-${link.id}`} className="block text-xs text-gray-400 mb-1">URL</label>
+ <input
+ id={`link-url-${link.id}`}
+ type="url"
+ value={editForm.url}
+ onChange={(e) => setEditForm({ ...editForm, url: e.target.value })}
+ className="w-full px-2 py-1 bg-port-bg border border-port-border rounded text-white text-sm"
+ placeholder="https://example.com"
+ />
+ </div>
+ <div>
+ <label htmlFor={`link-title-${link.id}`} className="block text-xs text-gray-400 mb-1">Title</label>
+ <input
+ id={`link-title-${link.id}`}
+ type="text"
+ value={editForm.title}
+ onChange={(e) => setEditForm({ ...editForm, title: e.target.value })}
+ className="w-full px-2 py-1 bg-port-bg border border-port-border rounded text-white text-sm"
+ placeholder="Title"
+ autoFocus
+ />
+ </div>
<textarea
value={editForm.description}
onChange={(e) => setEditForm({ ...editForm, description: e.target.value })}
diff --git a/server/lib/brainValidation.js b/server/lib/brainValidation.js
index cf918b5629..1821e0f83a 100644
--- a/server/lib/brainValidation.js
+++ b/server/lib/brainValidation.js
@@ -360,6 +360,7 @@ export const linkInputSchema = z.object({
// Update Link input schema (partial)
export const linkUpdateInputSchema = z.object({
+ url: z.string().url().optional(),
title: z.string().min(1).max(500).optional(),
description: z.string().max(2000).optional(),
linkType: linkTypeEnum.optional(),
@@ -369,7 +370,12 @@ export const linkUpdateInputSchema = z.object({
// Links query schema
export const linksQuerySchema = z.object({
linkType: linkTypeEnum.optional(),
- isGitHubRepo: z.coerce.boolean().optional(),
+ // Query params arrive as strings; z.coerce.boolean() treats any non-empty
+ // string (including "false") as true, so parse the string value explicitly.
+ isGitHubRepo: z.preprocess(
+ v => (typeof v === 'string' ? v === 'true' : v),
+ z.boolean()
+ ).optional(),
limit: z.coerce.number().int().min(1).max(100).optional().default(50),
offset: z.coerce.number().int().min(0).optional().default(0)
});
diff --git a/server/lib/brainValidation.test.js b/server/lib/brainValidation.test.js
index a7636739ba..c49dc5fd46 100644
--- a/server/lib/brainValidation.test.js
+++ b/server/lib/brainValidation.test.js
@@ -26,6 +26,7 @@ import {
inboxQuerySchema,
linkRecordSchema,
linkInputSchema,
+ linkUpdateInputSchema,
linksQuerySchema,
brainSyncQuerySchema,
brainSyncPushSchema
@@ -501,6 +502,24 @@ describe('brainValidation.js', () => {
});
});
+ describe('linkUpdateInputSchema', () => {
+ it('should accept a url-only update', () => {
+ const result = linkUpdateInputSchema.safeParse({ url: 'https://example.com/new' });
+ expect(result.success).toBe(true);
+ expect(result.data.url).toBe('https://example.com/new');
+ });
+
+ it('should accept a title-only update (url omitted)', () => {
+ const result = linkUpdateInputSchema.safeParse({ title: 'New title' });
+ expect(result.success).toBe(true);
+ expect(result.data.url).toBeUndefined();
+ });
+
+ it('should reject an invalid url', () => {
+ expect(linkUpdateInputSchema.safeParse({ url: 'not-valid' }).success).toBe(false);
+ });
+ });
+
describe('linksQuerySchema', () => {
it('should apply defaults', () => {
const result = linksQuerySchema.safeParse({});
@@ -515,6 +534,12 @@ describe('brainValidation.js', () => {
expect(result.data.isGitHubRepo).toBe(true);
});
+ it('should coerce the string "false" to false (not true)', () => {
+ const result = linksQuerySchema.safeParse({ isGitHubRepo: 'false' });
+ expect(result.success).toBe(true);
+ expect(result.data.isGitHubRepo).toBe(false);
+ });
+
it('should filter by linkType', () => {
const result = linksQuerySchema.safeParse({ linkType: 'documentation' });
expect(result.success).toBe(true);
diff --git a/server/routes/brain.js b/server/routes/brain.js
index 461521307a..b28e35f354 100644
--- a/server/routes/brain.js
+++ b/server/routes/brain.js
@@ -608,10 +608,37 @@ async function cloneRepoInBackground(linkId, url) {
*/
router.put('/links/:id', asyncHandler(async (req, res) => {
const data = validateRequest(linkUpdateInputSchema, req.body);
- const link = await brainService.updateLink(req.params.id, data);
- if (!link) {
+
+ const existing = await brainService.getLinkById(req.params.id);
+ if (!existing) {
throw new ServerError('Link not found', { status: 404, code: 'NOT_FOUND' });
}
+
+ // When the URL changes, re-derive the GitHub-specific fields so the link
+ // type / repo metadata stay consistent with the new target.
+ if (data.url && data.url !== existing.url) {
+ const duplicate = await brainService.getLinkByUrl(data.url);
+ if (duplicate && duplicate.id !== existing.id) {
+ throw new ServerError('Link with this URL already exists', {
+ status: 409,
+ code: 'DUPLICATE_URL',
+ context: { existingId: duplicate.id }
+ });
+ }
+
+ const parsed = githubCloner.parseGitHubUrl(data.url);
+ data.isGitHubRepo = !!parsed;
+ data.gitHubOwner = parsed?.owner || null;
+ data.gitHubRepo = parsed?.repo || null;
+
+ // The previous clone (if any) belongs to the old URL — reset clone state so
+ // it doesn't point at the wrong repo. The user can re-clone the new target.
+ data.localPath = null;
+ data.cloneStatus = 'none';
+ data.cloneError = null;
+ }
+
+ const link = await brainService.updateLink(req.params.id, data);
res.json(link);
}));