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: add notes to saved brain links

[._.]/ Adam Eivy9df4af0bc78b
diff --git a/client/src/components/QuickBrainCapture.jsx b/client/src/components/QuickBrainCapture.jsx
index a70397fbe6..dccd932f68 100644
--- a/client/src/components/QuickBrainCapture.jsx
+++ b/client/src/components/QuickBrainCapture.jsx
@@ -34,6 +34,7 @@ export default function QuickBrainCapture() {
const [ingestOpts, setIngestOpts] = useState(defaultIngestOptions);
const [agentPrompt, setAgentPrompt] = useState('');
const [tagsInput, setTagsInput] = useState('');
+ const [linkNote, setLinkNote] = useState('');
// Server-side defaults for the checkboxes, so a user who always wants audio
// sets it once in settings instead of every capture.
@@ -66,6 +67,7 @@ export default function QuickBrainCapture() {
e?.preventDefault();
const text = input.trim();
if (!text || submittingRef.current) return;
+ const note = linkNote.trim();
if (isYoutube) {
if (nothingSelected) {
@@ -75,9 +77,11 @@ export default function QuickBrainCapture() {
// The ingest job is long-running and streams its own progress/toasts, so
// the input clears immediately and the widget stays usable.
setInput('');
+ setLinkNote('');
ingest.start({
url: text,
...ingestOpts,
+ ...(note ? { note } : {}),
agentPrompt: agentPrompt.trim(),
tags: tagsInput.split(',').map((t) => t.trim()).filter(Boolean),
});
@@ -97,10 +101,12 @@ export default function QuickBrainCapture() {
// the request honest about what will be stored.
// `intakeFor` re-derives from the submitted text, so a sticky tick can't ride
// along on a capture that is no longer a repo URL.
- const result = await api.captureBrainThought(text, undefined, undefined, {
+ const captureOptions = {
creative: creative && !isUrl,
repoIntake: repoIntake.intakeFor(text),
- }, { silent: true }).catch(err => {
+ };
+ if (note) captureOptions.note = note;
+ const result = await api.captureBrainThought(text, undefined, undefined, captureOptions, { silent: true }).catch(err => {
toast.error(err.message || 'Failed to capture');
setInput(prev => prev || text);
return null;
@@ -108,6 +114,7 @@ export default function QuickBrainCapture() {
if (result) {
toast.success(result.message || 'Captured');
repoIntake.setStudyContext('');
+ setLinkNote('');
}
submittingRef.current = false;
setIsSubmitting(false);
@@ -131,6 +138,7 @@ export default function QuickBrainCapture() {
return;
}
setInput(trimmed);
+ if (!parseBareUrl(trimmed)) setLinkNote('');
inputRef.current?.focus();
};
@@ -152,7 +160,11 @@ export default function QuickBrainCapture() {
type="text"
placeholder="Thought, URL, or YouTube link..."
value={input}
- onChange={e => setInput(e.target.value)}
+ onChange={e => {
+ const value = e.target.value;
+ setInput(value);
+ if (!parseBareUrl(value)) setLinkNote('');
+ }}
className="flex-1 min-w-0 px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white text-sm"
/>
<button
@@ -203,6 +215,23 @@ export default function QuickBrainCapture() {
</button>
</form>
+ {isUrl && (
+ <div className="mt-3">
+ <label htmlFor="quick-brain-note" className="block text-xs text-gray-400 mb-1">
+ Why are you saving this link? <span className="text-gray-600">(optional)</span>
+ </label>
+ <textarea
+ id="quick-brain-note"
+ rows={2}
+ maxLength={2000}
+ value={linkNote}
+ onChange={e => setLinkNote(e.target.value)}
+ placeholder="e.g. Read later, share with the team, or turn into a future task"
+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white text-sm resize-y"
+ />
+ </div>
+ )}
+
{isYoutube && showAdvanced && (
<div id="quick-brain-advanced" className="mt-3 pt-3 border-t border-port-border space-y-3">
<div className="flex flex-wrap gap-2">
diff --git a/client/src/components/QuickBrainCapture.test.jsx b/client/src/components/QuickBrainCapture.test.jsx
index fca498852d..b2a4a8c9a7 100644
--- a/client/src/components/QuickBrainCapture.test.jsx
+++ b/client/src/components/QuickBrainCapture.test.jsx
@@ -104,6 +104,20 @@ describe('QuickBrainCapture', () => {
await waitFor(() => expect(toast.success).toHaveBeenCalledWith('Saved to Links!'));
});
+ it('sends a trimmed note with a saved URL', async () => {
+ renderWidget();
+ type('https://example.com');
+ fireEvent.change(screen.getByLabelText(/Why are you saving this link/i), {
+ target: { value: ' Read this before planning the next release. ' },
+ });
+ fireEvent.click(screen.getByLabelText('Capture'));
+
+ await waitFor(() => expect(captureBrainThought).toHaveBeenCalled());
+ expect(captureBrainThought.mock.calls[0][3]).toMatchObject({
+ note: 'Read this before planning the next release.',
+ });
+ });
+
it('does not flag a URL as creative even when the sticky flag is on', async () => {
localStorage.setItem('brain.captureCreative', 'true');
renderWidget();
@@ -305,6 +319,10 @@ describe('QuickBrainCapture', () => {
type(YT);
await openAdvanced();
+ fireEvent.change(screen.getByLabelText(/Why are you saving this link/i), {
+ target: { value: ' Keep this for the next research session. ' },
+ });
+
fireEvent.change(screen.getByLabelText(/what should an agent do/i), {
target: { value: 'Review for writing-tool improvements.' },
});
@@ -318,6 +336,7 @@ describe('QuickBrainCapture', () => {
captureTranscript: true,
downloadVideo: false,
ingestAudio: false,
+ note: 'Keep this for the next research session.',
agentPrompt: 'Review for writing-tool improvements.',
// Blank entries dropped, surrounding whitespace trimmed.
tags: ['writing-tools', 'research'],
diff --git a/client/src/components/brain/tabs/InboxTab.jsx b/client/src/components/brain/tabs/InboxTab.jsx
index 63676d4433..87bf24dda6 100644
--- a/client/src/components/brain/tabs/InboxTab.jsx
+++ b/client/src/components/brain/tabs/InboxTab.jsx
@@ -48,6 +48,7 @@ const filedRecordTitle = (filed) => filed.destination === 'links' ? 'View in Lin
export default function InboxTab({ onRefresh, settings }) {
const navigate = useNavigate();
const [inputText, setInputText] = useState('');
+ const [linkNote, setLinkNote] = useState('');
// Previews the server's filing decision with the mirrored predicate it uses
// (client/src/lib/bareUrl.js), so the hint and the Creative lockout can't
// promise a destination the server won't pick.
@@ -110,6 +111,7 @@ export default function InboxTab({ onRefresh, settings }) {
e.preventDefault();
const text = inputText.trim();
if (!text) return;
+ const note = inputIsUrl ? linkNote.trim() : '';
// Guard against rapid double-clicks before React flushes the cleared input
const lastText = inputRef.current?.dataset.lastSubmit;
@@ -132,10 +134,12 @@ export default function InboxTab({ onRefresh, settings }) {
// `intakeFor` re-derives from the submitted text, so a sticky tick can't ride
// along on a capture that is no longer a repo URL.
- const result = await api.captureBrainThought(text, undefined, undefined, {
+ const captureOptions = {
creative: asCreative,
repoIntake: repoIntake.intakeFor(text),
- }, { silent: true }).catch(err => {
+ };
+ if (note) captureOptions.note = note;
+ const result = await api.captureBrainThought(text, undefined, undefined, captureOptions, { silent: true }).catch(err => {
toast.error(err.message || 'Failed to capture thought');
setEntries(prev => prev.filter(e => e.id !== tempId));
return null;
@@ -148,6 +152,7 @@ export default function InboxTab({ onRefresh, settings }) {
// A capture that was just a URL is filed to Links synchronously — no
// brain:classified event follows, so announce the outcome here.
if (result.link) toast.success(result.message || 'Saved to Links');
+ setLinkNote('');
repoIntake.setStudyContext('');
onRefresh?.();
}
@@ -322,7 +327,11 @@ export default function InboxTab({ onRefresh, settings }) {
ref={inputRef}
type="text"
value={inputText}
- onChange={(e) => setInputText(e.target.value)}
+ onChange={(e) => {
+ const value = e.target.value;
+ setInputText(value);
+ if (!parseBareUrl(value)) setLinkNote('');
+ }}
placeholder="One thought at a time..."
aria-label="New inbox thought"
className="flex-1 px-4 py-3 bg-port-card border border-port-border rounded-lg text-white placeholder-gray-500 focus:outline-hidden focus:border-port-accent"
@@ -353,6 +362,22 @@ export default function InboxTab({ onRefresh, settings }) {
<Send className="w-5 h-5" />
</button>
</div>
+ {inputIsUrl && (
+ <div className="mt-3">
+ <label htmlFor="inbox-link-note" className="block text-xs text-gray-400 mb-1">
+ Why are you saving this link? <span className="text-gray-600">(optional)</span>
+ </label>
+ <textarea
+ id="inbox-link-note"
+ rows={2}
+ maxLength={2000}
+ value={linkNote}
+ onChange={(e) => setLinkNote(e.target.value)}
+ placeholder="e.g. Read later, share with the team, or turn into a future task"
+ className="w-full px-3 py-2 bg-port-card border border-port-border rounded-lg text-white text-sm resize-y placeholder-gray-500 focus:outline-hidden focus:border-port-accent"
+ />
+ </div>
+ )}
<p className="mt-2 text-xs text-gray-500">
Capture a thought — type or use the mic. AI will classify and route it automatically.
{inputIsUrl && (repoIntake.repo
diff --git a/client/src/components/brain/tabs/InboxTab.test.jsx b/client/src/components/brain/tabs/InboxTab.test.jsx
new file mode 100644
index 0000000000..5e2c1f3891
--- /dev/null
+++ b/client/src/components/brain/tabs/InboxTab.test.jsx
@@ -0,0 +1,84 @@
+import { beforeEach, describe, expect, it, vi } from 'vitest';
+import { fireEvent, render, screen, waitFor } from '@testing-library/react';
+import { MemoryRouter } from 'react-router';
+
+vi.mock('../../../services/api', () => ({
+ getBrainInbox: vi.fn(),
+ captureBrainThought: vi.fn(),
+ getBrainInboxEntry: vi.fn(),
+ resolveBrainReview: vi.fn(),
+ fixBrainClassification: vi.fn(),
+ retryBrainClassification: vi.fn(),
+ updateBrainInboxEntry: vi.fn(),
+ deleteBrainInboxEntry: vi.fn(),
+ markBrainInboxDone: vi.fn(),
+ markBrainInboxSentToCatalog: vi.fn(),
+}));
+
+vi.mock('../../../services/socket', () => ({
+ default: { on: vi.fn(), off: vi.fn() },
+}));
+
+vi.mock('../../../hooks', () => ({
+ useLocalStorageBool: () => [false, vi.fn()],
+ useRepoIntake: () => ({
+ repo: null,
+ options: { malwareScan: false, learn: false },
+ managedApps: [],
+ targetAppId: 'portos-default',
+ setTargetAppId: vi.fn(),
+ studyContext: '',
+ setStudyContext: vi.fn(),
+ providerOverride: { providerId: '', model: '', effort: '' },
+ providers: [],
+ activeProviderId: '',
+ setProviderOverride: vi.fn(),
+ toggle: vi.fn(),
+ intakeFor: vi.fn(() => undefined),
+ }),
+}));
+
+vi.mock('../../ui/Toast', () => ({
+ default: Object.assign(vi.fn(), { success: vi.fn(), error: vi.fn(), warning: vi.fn(), info: vi.fn() }),
+}));
+
+vi.mock('../VoiceCapture', () => ({ default: () => null }));
+vi.mock('../RepoIntakeOptions', () => ({ default: () => null }));
+
+import { captureBrainThought, getBrainInbox } from '../../../services/api';
+import InboxTab from './InboxTab';
+
+beforeEach(() => {
+ vi.clearAllMocks();
+ getBrainInbox.mockResolvedValue({ entries: [], counts: {} });
+ captureBrainThought.mockResolvedValue({
+ inboxLog: {
+ id: 'inbox-url-1',
+ capturedText: 'https://example.com',
+ status: 'filed',
+ capturedAt: '2026-01-01T00:00:00.000Z',
+ },
+ link: { id: 'link-1' },
+ message: 'Saved to Links!',
+ });
+});
+
+describe('Brain inbox capture', () => {
+ it('sends an optional note when a URL is filed to Links', async () => {
+ render(<MemoryRouter><InboxTab /></MemoryRouter>);
+ await waitFor(() => expect(getBrainInbox).toHaveBeenCalled());
+
+ fireEvent.change(screen.getByLabelText('New inbox thought'), {
+ target: { value: 'https://example.com' },
+ });
+ fireEvent.change(screen.getByLabelText(/Why are you saving this link/i), {
+ target: { value: ' Share this with the team ' },
+ });
+ fireEvent.click(screen.getByLabelText('Capture thought'));
+
+ await waitFor(() => expect(captureBrainThought).toHaveBeenCalled());
+ expect(captureBrainThought.mock.calls[0][3]).toMatchObject({
+ note: 'Share this with the team',
+ });
+ });
+});
diff --git a/client/src/components/brain/tabs/LinksTab.jsx b/client/src/components/brain/tabs/LinksTab.jsx
index 9517d33072..9a0d371043 100644
--- a/client/src/components/brain/tabs/LinksTab.jsx
+++ b/client/src/components/brain/tabs/LinksTab.jsx
@@ -116,6 +116,7 @@ function cloneProgressPatch(fresh, current) {
export default function LinksTab({ onRefresh }) {
const [inputUrl, setInputUrl] = useState('');
const [inputTitle, setInputTitle] = useState('');
+ const [inputNote, setInputNote] = useState('');
const [inputTags, setInputTags] = useState('');
const [showDetails, setShowDetails] = useState(false);
const [sending, setSending] = useState(false);
@@ -233,6 +234,7 @@ export default function LinksTab({ onRefresh }) {
const haystack = [
link.title,
link.url,
+ link.note,
link.description,
...(link.tags || [])
].filter(Boolean).join(' ').toLowerCase();
@@ -253,6 +255,8 @@ export default function LinksTab({ onRefresh }) {
const payload = { url };
const title = inputTitle.trim();
if (title) payload.title = title;
+ const note = inputNote.trim();
+ if (note) payload.note = note;
const tags = inputTags.split(',').map(t => t.trim()).filter(Boolean);
if (tags.length) payload.tags = tags;
@@ -272,6 +276,7 @@ export default function LinksTab({ onRefresh }) {
toast.success(isGitHub ? 'GitHub repo added - cloning in background' : 'Link saved');
setInputUrl('');
setInputTitle('');
+ setInputNote('');
setInputTags('');
setShowDetails(false);
fetchLinks();
@@ -352,6 +357,7 @@ export default function LinksTab({ onRefresh }) {
url: link.url,
title: link.title,
description: link.description || '',
+ note: link.note || '',
linkType: link.linkType,
tags: link.tags?.join(', ') || ''
});
@@ -368,6 +374,7 @@ export default function LinksTab({ onRefresh }) {
url,
title: editForm.title,
description: editForm.description,
+ note: editForm.note,
linkType: editForm.linkType,
tags: editForm.tags ? editForm.tags.split(',').map(t => t.trim()).filter(Boolean) : []
};
@@ -499,7 +506,7 @@ export default function LinksTab({ onRefresh }) {
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)'}
+ {showDetails ? 'Hide link details' : 'Add title, note & tags (optional)'}
</button>
{showDetails && (
@@ -516,6 +523,21 @@ export default function LinksTab({ onRefresh }) {
disabled={sending}
/>
</div>
+ <div>
+ <label htmlFor="link-note" className="block text-xs text-gray-400 mb-1">
+ Why are you saving this? <span className="text-gray-600">(optional)</span>
+ </label>
+ <textarea
+ id="link-note"
+ rows={2}
+ maxLength={2000}
+ value={inputNote}
+ onChange={(e) => setInputNote(e.target.value)}
+ placeholder="e.g. Read later, share with the team, or turn into a future task"
+ 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 resize-y"
+ disabled={sending}
+ />
+ </div>
<div>
<label htmlFor="link-tags" className="sr-only">Tags</label>
<input
@@ -574,7 +596,7 @@ export default function LinksTab({ onRefresh }) {
type="text"
value={search}
onChange={(e) => setSearch(e.target.value)}
- placeholder="Search links by title, URL, description, or tag..."
+ placeholder="Search links by title, URL, note, description, or tag..."
aria-label="Search links"
className="w-full pl-9 pr-9 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"
/>
@@ -641,6 +663,19 @@ export default function LinksTab({ onRefresh }) {
placeholder="Description (optional)"
rows={2}
/>
+ <div>
+ <label htmlFor={`link-note-${link.id}`} className="block text-xs text-gray-400 mb-1">
+ Why are you saving this? <span className="text-gray-600">(optional)</span>
+ </label>
+ <textarea
+ id={`link-note-${link.id}`}
+ value={editForm.note}
+ onChange={(e) => setEditForm({ ...editForm, note: e.target.value })}
+ className="w-full px-2 py-1 bg-port-bg border border-port-border rounded text-white text-sm resize-y"
+ placeholder="Why are you saving this link?"
+ rows={2}
+ />
+ </div>
<div className="flex gap-2">
<select
aria-label="Link type"
@@ -706,6 +741,11 @@ export default function LinksTab({ onRefresh }) {
{link.description && (
<p className="text-sm text-gray-500 mt-1">{link.description}</p>
)}
+ {link.note && (
+ <p className="text-sm text-gray-400 mt-1">
+ <span className="text-gray-500">Note:</span> {link.note}
+ </p>
+ )}
</div>
<div className="flex items-center gap-1 shrink-0">
diff --git a/client/src/components/brain/tabs/LinksTab.test.jsx b/client/src/components/brain/tabs/LinksTab.test.jsx
index 87bbad6a74..bc62267982 100644
--- a/client/src/components/brain/tabs/LinksTab.test.jsx
+++ b/client/src/components/brain/tabs/LinksTab.test.jsx
@@ -1,5 +1,5 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
-import { act, render, screen } from '@testing-library/react';
+import { act, fireEvent, render, screen } from '@testing-library/react';
import { MemoryRouter } from 'react-router';
vi.mock('../../../services/api', () => ({
@@ -30,7 +30,7 @@ vi.mock('../links/BucketBoard', () => ({
},
}));
-import { getBrainLink, getBrainLinks, getBrainBuckets } from '../../../services/api';
+import { createBrainLink, getBrainLink, getBrainLinks, getBrainBuckets } from '../../../services/api';
import LinksTab from './LinksTab';
const link = (id, cloneStatus, overrides = {}) => ({
@@ -268,3 +268,34 @@ describe('LinksTab clone-status polling', () => {
expect(getBrainLink.mock.calls.length).toBeGreaterThan(beforeExtra);
});
});
+
+describe('LinksTab link creation form', () => {
+ it('sends an optional note with a directly saved link', async () => {
+ getBrainLinks.mockResolvedValue({ links: [] });
+ const created = link('new', 'none', {
+ url: 'https://example.com/article',
+ title: 'example.com',
+ isGitHubRepo: false,
+ });
+ createBrainLink.mockResolvedValue(created);
+ await renderTab();
+
+ fireEvent.click(screen.getByRole('button', { name: 'Add title, note & tags (optional)' }));
+ fireEvent.change(screen.getByLabelText('Link URL to save'), {
+ target: { value: 'https://example.com/article' },
+ });
+ fireEvent.change(screen.getByLabelText(/Why are you saving this/i), {
+ target: { value: ' Read this later ' },
+ });
+ await act(async () => {
+ fireEvent.click(screen.getByTitle('Save link'));
+ await Promise.resolve();
+ });
+
+ expect(createBrainLink).toHaveBeenCalled();
+ expect(createBrainLink.mock.calls[0][0]).toEqual({
+ url: 'https://example.com/article',
+ note: 'Read this later',
+ });
+ });
+});
diff --git a/client/src/hooks/README.md b/client/src/hooks/README.md
index 196bf9ac11..7dfa81dde6 100644
--- a/client/src/hooks/README.md
+++ b/client/src/hooks/README.md
@@ -205,7 +205,7 @@ grep -i "what you want to do" client/src/hooks/README.md
| `useVideoFileSrc` | `useVideoFileSrc(jobId, { enabled })` → `{ src, resolving, retry }`. Resolves a video-history **id** to the file it really points at (`/data/videos/<filename>`) via the by-id lookup `GET /api/video-gen/history/:id`. | Any surface rendering a video by history id where the id is NOT the filename stem — notably a CD `finalVideoId` (the timeline renderer mints `timeline-*.mp4` beside a `randomUUID()` id, so `/data/videos/<id>.mp4` 404s while `<id>.jpg` poster loads). Pass the result to `<ScenePreview src=…>`. Gate autoplay on `resolving`. |
| `useVoiceUiSync` | Keeps voice server's UI index in sync with current page. | Wire once at root for voice agent support. |
| `useMoltworldWs` | Moltworld WebSocket feed. | Moltworld surfaces only. |
-| `useYoutubeIngest` | One YouTube brain-ingest job slot: start/cancel + SSE progress + terminal-frame handling via `POST /api/brain/youtube/ingest`. Returns `{ active, percent, stage, start(body), cancel }` — `start` takes the whole payload (`{ url, captureTranscript, downloadVideo, ingestAudio, agentPrompt, tags }`), not a bare URL. `onComplete(ingest)` fires with the stored ingest record; non-fatal `warnings[]` on the terminal frame are toasted automatically. | Quick Capture's YouTube path, and any other surface that ingests a video into the brain. |
+| `useYoutubeIngest` | One YouTube brain-ingest job slot: start/cancel + SSE progress + terminal-frame handling via `POST /api/brain/youtube/ingest`. Returns `{ active, percent, stage, start(body), cancel }` — `start` takes the whole payload (`{ url, captureTranscript, downloadVideo, ingestAudio, note, agentPrompt, tags }`), not a bare URL. `onComplete(ingest)` fires with the stored ingest record; non-fatal `warnings[]` on the terminal frame are toasted automatically. | Quick Capture's YouTube path, and any other surface that ingests a video into the brain. |
| `useYoutubeTrackImport` | One YouTube-audio-import job slot (#1945): start/cancel + SSE progress + terminal-frame handling via `POST /api/tracks/import/youtube`. Returns `{ active, percent, start(url, context), cancel }`; `onComplete(track, context)` fires with the finished Track. Call once per UI surface that can independently kick off an import — a shared slot would let one surface's kickoff orphan another's in-flight job. | Any picker that lets a user paste a YouTube URL to create a Track (Music Video's create form and track-change row). |
| `useVideoGenFieldState` | Mutable VideoGen field values, setters, and lifecycle refs initialized from URL handoff values. | Internal state slice composed by `useVideoGenForm`; keep model reconciliation and submission behavior in their focused units. |
| `useVideoGenForm` | `useVideoGenForm({ models, status, availableLoras, grokEnabled })` → every VideoGen form field + setter, the URL-param prefill paths (ImageGen handoff, Continue, Remix, `?lora=`), the mode/backend transitions that clear stale inputs, the derived model/keyframe/IC gates (`extendModeBlocked`, `a2vModeBlocked`, `icLoraModeBlocked`, `keyframesError`), `applyRemix` / `applyResumedParams`, and `buildGeneratePayload()`. | The /media/video form — the single client-side source of truth for the payload `server/routes/videoGen.js` validates. Reuse it for any second entry point that generates video. |
diff --git a/client/src/hooks/useYoutubeIngest.js b/client/src/hooks/useYoutubeIngest.js
index ae998af5f6..ec5f09d34e 100644
--- a/client/src/hooks/useYoutubeIngest.js
+++ b/client/src/hooks/useYoutubeIngest.js
@@ -8,7 +8,7 @@ import useSseJobSlot from './useSseJobSlot.js';
* `useSseJobSlot`, like the video-download and track-import hooks.
*
* `start(body)` takes the whole ingest payload (`{ url, captureTranscript,
- * downloadVideo, ingestAudio, agentPrompt, tags }`) rather than a bare URL, so
+ * downloadVideo, ingestAudio, note, agentPrompt, tags }`) rather than a bare URL, so
* `trimStartArg` stays false and the payload passes through untouched.
*
* Non-fatal outcomes (no captions, a duplicate review task) ride along on the
diff --git a/client/src/services/apiBrain.js b/client/src/services/apiBrain.js
index 5086311df1..bc8305410f 100644
--- a/client/src/services/apiBrain.js
+++ b/client/src/services/apiBrain.js
@@ -13,10 +13,10 @@ export const updateBrainSettings = (settings, options = {}) => request('/brain/s
// `repoIntake` ({ malwareScan, learn, targetAppId, studyContext, providerId,
// model, effort }) is the capture box's post-clone agent opt-in; the server
// ignores it unless the text is a bare GitHub repo URL. Provider pins apply to
-// the optional repo study only.
-export const captureBrainThought = (text, providerOverride, modelOverride, { creative, repoIntake } = {}, options = {}) => request('/brain/capture', {
+// the optional repo study only. `note` is saved on a bare-URL link.
+export const captureBrainThought = (text, providerOverride, modelOverride, { creative, repoIntake, note } = {}, options = {}) => request('/brain/capture', {
method: 'POST',
- body: JSON.stringify({ text, providerOverride, modelOverride, creative, repoIntake }),
+ body: JSON.stringify({ text, providerOverride, modelOverride, creative, repoIntake, note }),
...options
});
export const getBrainInbox = (options = {}) => {
diff --git a/server/lib/apiRouteCatalog.generated.json b/server/lib/apiRouteCatalog.generated.json
index c05d9a20f7..176ccd8175 100644
--- a/server/lib/apiRouteCatalog.generated.json
+++ b/server/lib/apiRouteCatalog.generated.json
@@ -2378,7 +2378,7 @@
"sources": [
{
"source": "server/routes/brainCapture.js",
- "line": 71
+ "line": 73
}
]
},
@@ -2620,7 +2620,7 @@
"sources": [
{
"source": "server/routes/brainCapture.js",
- "line": 36
+ "line": 38
}
]
},
@@ -2631,7 +2631,7 @@
"sources": [
{
"source": "server/routes/brainCapture.js",
- "line": 127
+ "line": 129
}
]
},
@@ -2642,7 +2642,7 @@
"sources": [
{
"source": "server/routes/brainCapture.js",
- "line": 49
+ "line": 51
}
]
},
@@ -2653,7 +2653,7 @@
"sources": [
{
"source": "server/routes/brainCapture.js",
- "line": 114
+ "line": 116
}
]
},
@@ -2664,7 +2664,7 @@
"sources": [
{
"source": "server/routes/brainCapture.js",
- "line": 91
+ "line": 93
}
]
},
@@ -2675,7 +2675,7 @@
"sources": [
{
"source": "server/routes/brainCapture.js",
- "line": 81
+ "line": 83
}
]
},
@@ -2686,7 +2686,7 @@
"sources": [
{
"source": "server/routes/brainCapture.js",
- "line": 104
+ "line": 106
}
]
},
@@ -3049,7 +3049,7 @@
"sources": [
{
"source": "server/routes/brainCapture.js",
- "line": 61
+ "line": 63
}
]
},
diff --git a/server/lib/brainValidation.js b/server/lib/brainValidation.js
index d8dac4df3a..64d52c48b3 100644
--- a/server/lib/brainValidation.js
+++ b/server/lib/brainValidation.js
@@ -212,6 +212,9 @@ export const captureInputSchema = z.object({
text: z.string().min(1).max(10000),
providerOverride: z.string().optional(),
modelOverride: z.string().optional(),
+ // Optional context for a bare URL capture. It is stored on the link rather
+ // than treated as classifier input, so a saved link keeps why it matters.
+ note: z.string().max(2000).optional(),
// Opt-in flag: the user marked this note as a creative idea at capture time
// (vs a todo/reference). Creative notes are later batch-sendable into the
// creative catalog as ingredients (see catalog brain-bridge ingest).
@@ -434,6 +437,7 @@ export const linkRecordSchema = z.object({
url: z.string().url(),
title: z.string().min(1).max(500),
description: z.string().max(2000).optional().default(''),
+ note: z.string().max(2000).optional().default(''),
linkType: linkTypeEnum.default('other'),
tags: z.array(z.string().max(50)).optional().default([]),
// GitHub-specific fields
@@ -478,6 +482,7 @@ export const linkInputSchema = z.object({
url: z.string().url(),
title: z.string().min(1).max(500).optional(),
description: z.string().max(2000).optional(),
+ note: z.string().max(2000).optional(),
linkType: linkTypeEnum.optional(),
tags: z.array(z.string().max(50)).optional(),
bucketId: z.string().guid().nullable().optional(),
@@ -492,6 +497,7 @@ export const linkUpdateInputSchema = z.object({
url: z.string().url().optional(),
title: z.string().min(1).max(500).optional(),
description: z.string().max(2000).optional(),
+ note: z.string().max(2000).optional(),
linkType: linkTypeEnum.optional(),
tags: z.array(z.string().max(50)).optional(),
bucketId: z.string().guid().nullable().optional(),
@@ -810,6 +816,7 @@ export const youtubeIngestSchema = z.object({
captureTranscript: z.boolean().optional(),
downloadVideo: z.boolean().optional(),
ingestAudio: z.boolean().optional(),
+ note: z.string().max(2000).optional(),
agentPrompt: z.string().max(10000).optional(),
tags: z.array(z.string().min(1).max(60)).max(20).optional(),
priority: z.enum(['CRITICAL', 'HIGH', 'MEDIUM', 'LOW']).optional()
diff --git a/server/lib/brainValidation.test.js b/server/lib/brainValidation.test.js
index 1e0190786e..baffcbc203 100644
--- a/server/lib/brainValidation.test.js
+++ b/server/lib/brainValidation.test.js
@@ -438,6 +438,15 @@ describe('brainValidation.js', () => {
expect(result.success).toBe(true);
});
+ it('should accept an optional note for a URL capture', () => {
+ const result = captureInputSchema.safeParse({
+ text: 'https://example.com',
+ note: 'Read this before the next planning session',
+ });
+ expect(result.success).toBe(true);
+ expect(result.data.note).toBe('Read this before the next planning session');
+ });
+
it('should allow provider pins inside a repo-study intake', () => {
const result = captureInputSchema.safeParse({
text: 'https://github.com/example/repo',
@@ -499,6 +508,7 @@ describe('brainValidation.js', () => {
url: 'https://github.com/example/repo',
title: 'Example Repository',
description: 'A great example repo',
+ note: 'Review before sharing with the team',
linkType: 'github',
tags: ['reference'],
isGitHubRepo: true,
@@ -550,6 +560,15 @@ describe('brainValidation.js', () => {
expect(result.data.autoClone).toBe(true);
});
+ it('should accept a note', () => {
+ const result = linkInputSchema.safeParse({
+ url: 'https://example.com',
+ note: 'Save for later reading',
+ });
+ expect(result.success).toBe(true);
+ expect(result.data.note).toBe('Save for later reading');
+ });
+
it('should reject invalid URL', () => {
expect(linkInputSchema.safeParse({ url: 'not-valid' }).success).toBe(false);
});
@@ -588,6 +607,10 @@ describe('brainValidation.js', () => {
expect(result.data.url).toBeUndefined();
});
+ it('should accept a note-only update, including an intentional clear', () => {
+ expect(linkUpdateInputSchema.safeParse({ note: '' }).data.note).toBe('');
+ });
+
it('should reject an invalid url', () => {
expect(linkUpdateInputSchema.safeParse({ url: 'not-valid' }).success).toBe(false);
});
diff --git a/server/routes/brain.test.js b/server/routes/brain.test.js
index 720aa98d70..abc92d799a 100644
--- a/server/routes/brain.test.js
+++ b/server/routes/brain.test.js
@@ -360,6 +360,19 @@ describe('Brain Routes', () => {
expect(brainService.captureThought).toHaveBeenCalledWith('a sentient city', undefined, undefined, { creative: true });
});
+
+ it('should forward a URL note to the capture service', async () => {
+ brainService.captureThought.mockResolvedValue({ inboxLog: { id: 'inbox-004' } });
+
+ await request(app)
+ .post('/api/brain/capture')
+ .send({ text: 'https://example.com', note: 'Share this with the team' });
+
+ expect(brainService.captureThought).toHaveBeenCalledWith(
+ 'https://example.com', undefined, undefined,
+ { creative: undefined, note: 'Share this with the team' }
+ );
+ });
});
describe('GET /api/brain/inbox', () => {
@@ -1713,11 +1726,18 @@ describe('Brain Routes', () => {
brainService.createLinkFromUrl.mockImplementation(async (url, opts) => ({ id: 'l9', url, ...opts }));
const res = await request(app)
.post('/api/brain/links')
- .send({ url: 'https://www.example.com/parks', bucketId: '11111111-1111-4111-8111-111111111111' });
+ .send({
+ url: 'https://www.example.com/parks',
+ note: 'Share this with the team',
+ bucketId: '11111111-1111-4111-8111-111111111111'
+ });
expect(res.status).toBe(201);
expect(brainService.createLinkFromUrl).toHaveBeenCalledWith(
'https://www.example.com/parks',
- expect.objectContaining({ bucketId: '11111111-1111-4111-8111-111111111111' })
+ expect.objectContaining({
+ note: 'Share this with the team',
+ bucketId: '11111111-1111-4111-8111-111111111111'
+ })
);
});
diff --git a/server/routes/brainCapture.js b/server/routes/brainCapture.js
index f8bd2b1876..e9c6a33ff4 100644
--- a/server/routes/brainCapture.js
+++ b/server/routes/brainCapture.js
@@ -24,8 +24,10 @@ const router = Router();
* Capture a thought, classify it, and store it
*/
router.post('/capture', asyncHandler(async (req, res) => {
- const { text, providerOverride, modelOverride, creative, repoIntake } = validateRequest(captureInputSchema, req.body);
- const result = await brainService.captureThought(text, providerOverride, modelOverride, { creative, repoIntake });
+ const { text, providerOverride, modelOverride, creative, repoIntake, note } = validateRequest(captureInputSchema, req.body);
+ const captureOptions = { creative, repoIntake };
+ if (note !== undefined) captureOptions.note = note;
+ const result = await brainService.captureThought(text, providerOverride, modelOverride, captureOptions);
res.json(result);
}));
diff --git a/server/routes/brainYoutube.js b/server/routes/brainYoutube.js
index a92735a3ba..4f1fd023ef 100644
--- a/server/routes/brainYoutube.js
+++ b/server/routes/brainYoutube.js
@@ -18,7 +18,7 @@ const router = Router();
/**
* POST /api/brain/youtube/ingest
* Start an ingest. Body: { url, captureTranscript?, downloadVideo?, ingestAudio?,
- * agentPrompt?, tags?, priority? } → { jobId, videoId }
+ * note?, agentPrompt?, tags?, priority? } → { jobId, videoId }
*/
router.post('/ingest', asyncHandler(async (req, res) => {
const data = validateRequest(youtubeIngestSchema, req.body || {});
diff --git a/server/services/brain.js b/server/services/brain.js
index 4a7b77cd89..07c2d58dad 100644
--- a/server/services/brain.js
+++ b/server/services/brain.js
@@ -136,7 +136,7 @@ function safeParseJsonResponse(content) {
* Returns immediately after creating the inbox entry.
* AI classification runs in the background and emits a socket event on completion.
*/
-export async function captureThought(text, providerOverride, modelOverride, { creative = false, repoIntake = null } = {}) {
+export async function captureThought(text, providerOverride, modelOverride, { creative = false, repoIntake = null, note } = {}) {
// A capture that is nothing but a URL is a bookmark, not a thought: file it
// straight to Links exactly as the Links tab would, and skip the classifier
// LLM call entirely. This outranks the creative flag — a bare URL carries no
@@ -144,7 +144,7 @@ export async function captureThought(text, providerOverride, modelOverride, { cr
// Creative toggle for a URL rather than the two rules disagreeing.
const bareUrl = parseBareUrl(text);
if (bareUrl) {
- return captureUrlAsLink(bareUrl, text, repoIntake);
+ return captureUrlAsLink(bareUrl, text, { repoIntake, note });
}
const meta = await storage.loadMeta();
@@ -218,9 +218,9 @@ export async function captureThought(text, providerOverride, modelOverride, { cr
* an already-saved URL performs no clone, so there is no fresh clone for the
* agents to read and re-queueing them silently would be a surprise.
*/
-async function captureUrlAsLink(url, capturedText, repoIntake = null) {
+async function captureUrlAsLink(url, capturedText, { repoIntake = null, note } = {}) {
const existing = await storage.getLinkByUrl(url);
- const link = existing || await createLinkFromUrl(url, { repoIntake });
+ const link = existing || await createLinkFromUrl(url, { repoIntake, note });
// No `classification` block: nothing classified this — the destination was
// decided by shape, not by a model, so there is no confidence or extraction to
@@ -1081,7 +1081,7 @@ export async function cloneRepoInBackground(linkId, url) {
* link) — this always creates.
*/
export async function createLinkFromUrl(url, {
- title, description, linkType, tags, bucketId, bucketOrder, autoClone, repoIntake
+ title, description, note, linkType, tags, bucketId, bucketOrder, autoClone, repoIntake
} = {}) {
const parsed = githubCloner.parseGitHubUrl(url);
const isGitHubRepo = !!parsed;
@@ -1096,11 +1096,13 @@ export async function createLinkFromUrl(url, {
const defaultTitle = parsed
? `${parsed.owner}/${parsed.repo}`
: (hostnameFromUrl(url) || url);
+ const cleanNote = typeof note === 'string' ? note.trim() : '';
const link = await storage.createLink({
url,
title: title || defaultTitle,
description: description || '',
+ note: cleanNote,
linkType: linkType || (isGitHubRepo ? 'github' : 'other'),
tags: tags || [],
isGitHubRepo,
diff --git a/server/services/brain.test.js b/server/services/brain.test.js
index 8d4de2c3f0..f2882ffd36 100644
--- a/server/services/brain.test.js
+++ b/server/services/brain.test.js
@@ -288,6 +288,16 @@ describe('brain service', () => {
);
});
+ it('stores the capture note on a newly saved URL', async () => {
+ await captureThought('https://example.com', undefined, undefined, {
+ note: 'Read this before the next planning session',
+ });
+
+ expect(storage.createLink).toHaveBeenCalledWith(expect.objectContaining({
+ note: 'Read this before the next planning session',
+ }));
+ });
+
it('reuses an existing link instead of failing on a re-paste', async () => {
storage.getLinkByUrl.mockResolvedValue({ id: 'link-existing', title: 'example.com' });
@@ -469,11 +479,12 @@ describe('brain service', () => {
githubCloner.parseGitHubUrl.mockReturnValue({ owner: 'acme', repo: 'widgets', isGitHub: true });
await createLinkFromUrl('https://github.com/acme/widgets', {
- title: 'My Widgets', bucketId: 'bucket-1', autoClone: false
+ title: 'My Widgets', note: 'Use this as a reference', bucketId: 'bucket-1', autoClone: false
});
expect(storage.createLink).toHaveBeenCalledWith(expect.objectContaining({
title: 'My Widgets',
+ note: 'Use this as a reference',
bucketId: 'bucket-1',
cloneStatus: 'none'
}));
diff --git a/server/services/youtubeIngest.js b/server/services/youtubeIngest.js
index 62b1de5099..1a98f6026f 100644
--- a/server/services/youtubeIngest.js
+++ b/server/services/youtubeIngest.js
@@ -555,6 +555,7 @@ export function cancelYoutubeIngest(jobId) {
* @param {boolean} [opts.captureTranscript=true]
* @param {boolean} [opts.downloadVideo=false]
* @param {boolean} [opts.ingestAudio=false]
+ * @param {string} [opts.note] Optional reason for keeping the link.
* @param {string} [opts.agentPrompt] Non-empty → queue a CoS task pointed at the transcript.
* @param {string[]} [opts.tags]
* @param {string} [opts.priority] CoS task priority (defaults to the setting).
@@ -564,6 +565,7 @@ export async function startYoutubeIngest({
captureTranscript = true,
downloadVideo = false,
ingestAudio = false,
+ note = '',
agentPrompt = '',
tags = [],
priority,
@@ -589,6 +591,7 @@ export async function startYoutubeIngest({
const job = { id: jobId, clients: [], process: null, canceled: false };
ingestJobs.set(jobId, job);
const cleanTags = tags.map((t) => String(t).trim()).filter(Boolean);
+ const linkNote = typeof note === 'string' ? note.trim() : '';
const prompt = String(agentPrompt || '').trim();
console.log(`📺 YouTube ingest ${shortId(jobId)} — ${videoId} (transcript=${captureTranscript} video=${downloadVideo} audio=${ingestAudio})`);
@@ -761,6 +764,7 @@ export async function startYoutubeIngest({
linkType: 'reference',
tags: ['youtube', ...cleanTags],
};
+ if (linkNote) linkFields.note = linkNote;
// A reused link still has to pick up THIS ingest's tags and the resolved
// title/channel — otherwise tags typed on a re-ingest are silently dropped
// and a link first saved as a bare URL keeps its hostname title forever.