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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: keep Story Builder import intake alive across an intake tab switch (#3904)
[._.]/ Adam Eivybbb2966bbfa0
diff --git a/.changelog/next/fixed-issue-3904.md b/.changelog/next/fixed-issue-3904.mdnew file mode 100644index 0000000000..90fe390415--- /dev/null+++ b/.changelog/next/fixed-issue-3904.md@@ -0,0 +1 @@+- Story Builder no longer discards a pasted manuscript and its analysis preview when you switch between the Seed and Import intake tabs; the active tab is now deep-linkable via `?intake=`.diff --git a/client/src/hooks/README.md b/client/src/hooks/README.mdindex f906d55b1e..0194a7d5d7 100644--- a/client/src/hooks/README.md+++ b/client/src/hooks/README.md@@ -103,6 +103,7 @@ grep -i "what you want to do" client/src/hooks/README.md| `useCooldownTick` | 1-second ticker over a `{ id: epochMs }` cooldown map; fires `onAllExpired` once when every deadline passes. | Rate-limit countdown labels that need to refetch when the last cooldown clears (agents tabs pattern). || `useDrawerTab` | Deep-linkable `[activeTab, setActiveTab]` for a tabbed `<Drawer>`, backed by a caller-named URL search param (falls back to a default on stale/missing). | A tabbed config drawer whose open section should be shareable/bookmarkable — use with `<Drawer tabs>`; don't re-roll the search-param plumbing. || `useFieldDraft` | Local input draft that commits on blur. | Bible-editor-style single-field input that must dedupe sibling races. |+| `useStoryImportIntake` | Story Builder "Import a finished work" intake: the form fields plus the analyze → commit → create-session workflow, in one `{ ...state, patch, analyze, retryIssues, importAndBuild }` bag. | Call from the always-mounted Story Builder index and pass down as `intake` — holding this in the panel loses the manuscript and analysis on an intake tab flip (#3904). || `useRowDraft` | Multi-column row draft (analogue of `useFieldDraft`). | Multi-column row that commits as a unit. || `usePendingListRows` | List-of-rows where a new row is held client-side until a required column fills, then promoted to `onChange`. | Editable list whose nameless rows would otherwise be dropped by the server sanitizer (WardrobeSection, CharacterDetailEditor list sections). || `useKeyboardControls` | Keyboard binding for CyberCity mode toggle. | CyberCity-specific. |diff --git a/client/src/hooks/index.js b/client/src/hooks/index.jsindex eb0dece8ad..01c93dba1f 100644--- a/client/src/hooks/index.js+++ b/client/src/hooks/index.js@@ -153,6 +153,8 @@ export * from './useLockToggle.js';export { default as usePersistedOptions } from './usePersistedOptions.js';export * from './usePersistedOptions.js';export * from './useScrollLock.js';+export { default as useStoryImportIntake } from './useStoryImportIntake.js';+export * from './useStoryImportIntake.js';export * from './useSwipeNav.js';export { default as useUrlParams } from './useUrlParams.js';export * from './useValidTab.js';diff --git a/client/src/hooks/useStoryImportIntake.js b/client/src/hooks/useStoryImportIntake.jsnew file mode 100644index 0000000000..d9fc93fcaf--- /dev/null+++ b/client/src/hooks/useStoryImportIntake.js@@ -0,0 +1,155 @@+import { useCallback, useEffect, useState } from 'react';+import toast from '../components/ui/Toast';+import {+ analyzeImport, commitImport, retryImporterIssues, createStorySession,+} from '../services/api';++// Mirror Importer.jsx's commit picker — only these arc fields are sent on commit.+const ARC_FIELDS_TO_COMMIT = ['logline', 'summary', 'protagonistArc', 'themes', 'shape'];++export const pickArcFields = (arc) => {+ if (!arc) return null;+ const out = {};+ for (const k of ARC_FIELDS_TO_COMMIT) if (arc[k] !== undefined) out[k] = arc[k];+ return out;+};++export const IMPORT_INTAKE_INITIAL = {+ universeName: '',+ seriesName: '',+ contentType: 'comic-script',+ source: '',+ llm: { provider: '', model: '' },+ preview: null,+ analyzing: false,+ retrying: false,+ committing: false,+ // Set after a partial commit (universe/series/arc/canon persisted, issues+ // rolled back). The retry then drops arc + seasons + canon so it only+ // re-creates the issues — re-sending the full payload would clobber the+ // persisted state and risk duplicate issues. Mirrors Importer.jsx.+ arcAlreadyPersisted: false,+ // Set once commitImport fully succeeds (issues created) but createStorySession+ // then failed — a re-click must skip commitImport entirely and resume at+ // session creation, otherwise it re-creates the already-created issues and+ // overwrites the arc.+ committed: false,+};++// Story Builder "Import a finished work" intake: every field the import form+// collects, plus the analyze → commit → create-session workflow over them.+//+// This lives OUTSIDE the import panel on purpose (#3904). The Story Builder+// index renders its Seed and Import intake tabs by swapping components, so the+// import panel unmounts on every tab flip — holding the manuscript (up to 50k+// chars), the form fields, and a minute-long analysis result in that panel's+// own `useState` meant one click on "Start from an idea" destroyed all of it.+// Calling this hook from the always-mounted index keeps the state alive across+// tab switches AND lets an in-flight analyze/commit resolve into live state+// instead of into an unmounted component.+export default function useStoryImportIntake(onCreated) {+ const [state, setState] = useState(IMPORT_INTAKE_INITIAL);+ // `patch` takes a partial (or a function of the previous state returning one)+ // so callers never have to spread the whole bag.+ const patch = useCallback((next) => {+ setState((prev) => ({ ...prev, ...(typeof next === 'function' ? next(prev) : next) }));+ }, []);++ const { preview } = state;+ // Any path that clears the preview (analyze, Re-analyze) is a fresh attempt,+ // so the retry/committed state can't survive it — centralize the reset here.+ useEffect(() => {+ if (preview) return;+ setState((prev) => (prev.arcAlreadyPersisted || prev.committed+ ? { ...prev, arcAlreadyPersisted: false, committed: false }+ : prev));+ }, [preview]);++ const analyze = useCallback(async () => {+ const { universeName, seriesName, contentType, source, llm } = state;+ if (!universeName.trim() || !seriesName.trim() || !source.trim()) {+ toast.error('Universe name, series name, and source text are required'); return;+ }+ patch({ analyzing: true, preview: null });+ const res = await analyzeImport(+ {+ universeName: universeName.trim(), seriesName: seriesName.trim(), contentType, source,+ providerOverride: llm.provider || undefined, modelOverride: llm.model || undefined,+ },+ { silent: true },+ ).catch((err) => { toast.error(err?.message || 'Analyze failed'); return null; });+ patch({ analyzing: false, ...(res ? { preview: res } : {}) });+ }, [state, patch]);++ const retryIssues = useCallback(async () => {+ const { contentType, source, seriesName, llm } = state;+ patch({ retrying: true });+ const res = await retryImporterIssues(+ {+ contentType, source, seriesName: seriesName.trim(), arcSummary: state.preview?.arcPreview?.summary || '',+ providerOverride: llm.provider || undefined, modelOverride: llm.model || undefined,+ },+ { silent: true },+ ).catch((err) => { toast.error(err?.message || 'Retry failed'); return null; });+ patch((prev) => ({+ retrying: false,+ ...(res ? { preview: { ...prev.preview, issueProposals: res.issueProposals || [], issueSplitFailed: false } } : {}),+ }));+ }, [state, patch]);++ const importAndBuild = useCallback(async () => {+ const { preview: p, contentType, seriesName, universeName, llm, committed, arcAlreadyPersisted } = state;+ if (!p) return;+ const issues = p.issueProposals || [];+ if (issues.length === 0) { toast.error('No issues were extracted — retry the issue split or adjust the source'); return; }+ patch({ committing: true });+ // Skip commitImport when a prior click already committed (only the later+ // createStorySession failed) — re-running it would duplicate the+ // already-created issues and overwrite the arc. Resume at session creation.+ if (!committed) {+ // On an arcAlreadyPersisted retry the server kept arc/seasons/canon from+ // the failed commit, so resend issues only — re-sending the full payload+ // would clobber the persisted state and risk duplicate issues.+ const base = { universeId: p.universe.id, seriesId: p.series.id, issues, contentType };+ const payload = arcAlreadyPersisted+ ? { ...base, canonSelections: { characters: [], places: [], objects: [] }, arc: null, seasons: [] }+ : {+ ...base,+ canonSelections: {+ characters: p.canonPreview?.characters || [],+ places: p.canonPreview?.places || [],+ objects: p.canonPreview?.objects || [],+ },+ arc: pickArcFields(p.arcPreview),+ seasons: p.seasonsPreview || [],+ };+ const result = await commitImport(payload, { silent: true }).catch((err) => {+ if (err?.code === 'IMPORTER_PARTIAL_COMMIT_ISSUES' && err?.context?.arcAlreadyPersisted) {+ patch({ arcAlreadyPersisted: true });+ toast.warning('Arc + seasons saved; issues failed and were rolled back. Click again to re-create the issues only — the arc won\'t be re-sent.');+ return null;+ }+ toast.error(err?.message || 'Import failed');+ return null;+ });+ if (!result) { patch({ committing: false }); return; }+ patch({ arcAlreadyPersisted: false, committed: true });+ }+ const session = await createStorySession({+ intakeMode: 'import',+ title: seriesName.trim() || universeName.trim(),+ // Seed from the extracted arc so the idea step has context and the+ // universe-aesthetic expand has a real starter (the imported universe+ // otherwise only has a name).+ seedIdea: (p.arcPreview?.summary || p.arcPreview?.logline || '').slice(0, 4000),+ universeId: p.universe.id,+ seriesId: p.series.id,+ // Persist the picker choice so every in-wizard operation uses it too.+ llm: { provider: llm.provider || null, model: llm.model || null },+ }, { silent: true }).catch((err) => { toast.error(err?.message || 'Failed to start the builder'); return null; });+ patch({ committing: false });+ if (session) onCreated(session);+ }, [state, patch, onCreated]);++ return { ...state, patch, analyze, retryIssues, importAndBuild };+}diff --git a/client/src/pages/StoryBuilder.jsx b/client/src/pages/StoryBuilder.jsxindex 417c9a136c..ae8209dd48 100644--- a/client/src/pages/StoryBuilder.jsx+++ b/client/src/pages/StoryBuilder.jsx@@ -27,7 +27,7 @@ import {generateStoryStep, refineStoryStep, setStoryIssueLock, generateStoryIssues,setStorySessionSync, reconcileStorySession,getUniverse, getPipelineSeries, listPipelineIssues,- analyzeImport, commitImport, retryImporterIssues, IMPORTER_CONTENT_TYPES,+ IMPORTER_CONTENT_TYPES,getProviders, listCatalogIngredientsByIds,} from '../services/api';import ArcCanvas from '../components/pipeline/ArcCanvas';@@ -35,21 +35,18 @@ import { useArcCanvasSync } from '../hooks/useArcCanvasSync';import { BEAT_KIND_COLORS, getBeatKindColor } from '../lib/beatColors';import { getCatalogType, payloadSnippet } from '../lib/catalogTypes';import { useCatalogTypes } from '../hooks/useCatalogTypes.jsx';--// Mirror Importer.jsx's commit picker — only these arc fields are sent on commit.-const ARC_FIELDS_TO_COMMIT = ['logline', 'summary', 'protagonistArc', 'themes', 'shape'];+import useDrawerTab from '../hooks/useDrawerTab';+import useStoryImportIntake from '../hooks/useStoryImportIntake';// Bible fields the embedded arc step flushes before an ArcCanvas generate/verify.// The Story Builder edits these on their own steps (not inside the arc step), so// the flush is usually a no-op — kept for API-shape parity with ArcCanvas's// contract. Module-level so the `useArcCanvasSync` callbacks keep a stable identity.const ARC_FLUSH_FIELDS = ['name', 'logline', 'premise', 'styleNotes', 'issueCountTarget', 'universeId'];-const pickArcFields = (arc) => {- if (!arc) return null;- const out = {};- for (const k of ARC_FIELDS_TO_COMMIT) if (arc[k] !== undefined) out[k] = arc[k];- return out;-};++// Intake tabs on the index view. The active one lives in `?intake=` (via+// useDrawerTab) rather than local state so it's shareable and reload-safe.+const INTAKE_TABS = ['seed', 'import'];const CONTENT_TYPE_LABELS = {'short-story': 'Short story', novel: 'Novel', screenplay: 'Screenplay', 'comic-script': 'Comic script',@@ -165,7 +162,7 @@ function StoryBuilderIndex() {const [sessionsLoading, setSessionsLoading] = useState(true);const [sessionsError, setSessionsError] = useState(null);const [sessionsReloadTick, setSessionsReloadTick] = useState(0);- const [mode, setMode] = useState('seed');+ const [mode, setMode] = useDrawerTab('intake', 'seed', INTAKE_TABS);const [title, setTitle] = useState('');const [seedIdea, setSeedIdea] = useState('');const [creating, setCreating] = useState(false);@@ -236,7 +233,12 @@ function StoryBuilderIndex() {if (created) navigate(`/story-builder/${created.id}/idea`);};- const onCreated = (session) => navigate(`/story-builder/${session.id}/idea`);+ const onCreated = useCallback((session) => navigate(`/story-builder/${session.id}/idea`), [navigate]);++ // Import intake state lives HERE, not inside <ImportPanel> — the panel unmounts+ // whenever the user flips to the "Start from an idea" tab, which used to throw+ // away the pasted manuscript and the minute-long analysis preview (#3904).+ const intake = useStoryImportIntake(onCreated);const tabClass = (id) => `px-4 py-2 text-sm rounded-t border-b-2 ${mode === id ? 'border-port-accent text-white' : 'border-transparent text-gray-400 hover:text-gray-200'@@ -311,7 +313,7 @@ function StoryBuilderIndex() {</button></div>) : (- <ImportPanel onCreated={onCreated} />+ <ImportPanel intake={intake} />)}</section>@@ -365,115 +367,20 @@ function StoryBuilderIndex() {// ── Import intake (reuses the Importer's analyze → commit) ──────────────────-function ImportPanel({ onCreated }) {- const [universeName, setUniverseName] = useState('');- const [seriesName, setSeriesName] = useState('');- const [contentType, setContentType] = useState('comic-script');- const [source, setSource] = useState('');- const [llm, setLlm] = useState({ provider: '', model: '' });- const [analyzing, setAnalyzing] = useState(false);- const [preview, setPreview] = useState(null);- const [retrying, setRetrying] = useState(false);- const [committing, setCommitting] = useState(false);- // Set after a partial commit (universe/series/arc/canon persisted, issues- // rolled back). The retry then drops arc + seasons + canon so it only- // re-creates the issues — re-sending the full payload would clobber the- // persisted state and risk duplicate issues. Mirrors Importer.jsx.- const [arcAlreadyPersisted, setArcAlreadyPersisted] = useState(false);- // Set once commitImport fully succeeds (issues created) but createStorySession- // then failed — a re-click must skip commitImport entirely and resume at- // session creation, otherwise it re-creates the already-created issues and- // overwrites the arc.- const [committed, setCommitted] = useState(false);- // Any path that clears the preview (analyze, Re-analyze) is a fresh attempt,- // so the retry/committed state can't survive it — centralize the reset here.- useEffect(() => { if (!preview) { setArcAlreadyPersisted(false); setCommitted(false); } }, [preview]);+// Presentational half of the import intake. Every field and the whole+// analyze → commit → create-session workflow live in `useStoryImportIntake`,+// called by the always-mounted StoryBuilderIndex and handed down as `intake` —+// this component unmounts on every intake tab flip, so state held here would be+// destroyed by a single click on "Start from an idea" (#3904).+function ImportPanel({ intake }) {+ const {+ universeName, seriesName, contentType, source, llm,+ analyzing, preview, retrying, committing, arcAlreadyPersisted, committed,+ patch, analyze, retryIssues, importAndBuild,+ } = intake;const types = IMPORTER_CONTENT_TYPES || ['short-story', 'novel', 'screenplay', 'comic-script'];- const analyze = async () => {- if (!universeName.trim() || !seriesName.trim() || !source.trim()) {- toast.error('Universe name, series name, and source text are required'); return;- }- setAnalyzing(true); setPreview(null);- const res = await analyzeImport(- {- universeName: universeName.trim(), seriesName: seriesName.trim(), contentType, source,- providerOverride: llm.provider || undefined, modelOverride: llm.model || undefined,- },- { silent: true },- ).catch((err) => { toast.error(err?.message || 'Analyze failed'); return null; });- setAnalyzing(false);- if (res) setPreview(res);- };-- const retryIssues = async () => {- setRetrying(true);- const res = await retryImporterIssues(- {- contentType, source, seriesName: seriesName.trim(), arcSummary: preview?.arcPreview?.summary || '',- providerOverride: llm.provider || undefined, modelOverride: llm.model || undefined,- },- { silent: true },- ).catch((err) => { toast.error(err?.message || 'Retry failed'); return null; });- setRetrying(false);- if (res) setPreview((p) => ({ ...p, issueProposals: res.issueProposals || [], issueSplitFailed: false }));- };-- const importAndBuild = async () => {- if (!preview) return;- const issues = preview.issueProposals || [];- if (issues.length === 0) { toast.error('No issues were extracted — retry the issue split or adjust the source'); return; }- setCommitting(true);- // Skip commitImport when a prior click already committed (only the later- // createStorySession failed) — re-running it would duplicate the- // already-created issues and overwrite the arc. Resume at session creation.- if (!committed) {- // On an arcAlreadyPersisted retry the server kept arc/seasons/canon from- // the failed commit, so resend issues only — re-sending the full payload- // would clobber the persisted state and risk duplicate issues.- const base = { universeId: preview.universe.id, seriesId: preview.series.id, issues, contentType };- const payload = arcAlreadyPersisted- ? { ...base, canonSelections: { characters: [], places: [], objects: [] }, arc: null, seasons: [] }- : {- ...base,- canonSelections: {- characters: preview.canonPreview?.characters || [],- places: preview.canonPreview?.places || [],- objects: preview.canonPreview?.objects || [],- },- arc: pickArcFields(preview.arcPreview),- seasons: preview.seasonsPreview || [],- };- const result = await commitImport(payload, { silent: true }).catch((err) => {- if (err?.code === 'IMPORTER_PARTIAL_COMMIT_ISSUES' && err?.context?.arcAlreadyPersisted) {- setArcAlreadyPersisted(true);- toast.warning('Arc + seasons saved; issues failed and were rolled back. Click again to re-create the issues only — the arc won\'t be re-sent.');- return null;- }- toast.error(err?.message || 'Import failed');- return null;- });- if (!result) { setCommitting(false); return; }- setArcAlreadyPersisted(false);- setCommitted(true);- }- const session = await createStorySession({- intakeMode: 'import',- title: seriesName.trim() || universeName.trim(),- // Seed from the extracted arc so the idea step has context and the- // universe-aesthetic expand has a real starter (the imported universe- // otherwise only has a name).- seedIdea: (preview.arcPreview?.summary || preview.arcPreview?.logline || '').slice(0, 4000),- universeId: preview.universe.id,- seriesId: preview.series.id,- // Persist the picker choice so every in-wizard operation uses it too.- llm: { provider: llm.provider || null, model: llm.model || null },- }, { silent: true }).catch((err) => { toast.error(err?.message || 'Failed to start the builder'); return null; });- setCommitting(false);- if (session) onCreated(session);- };-const canon = preview?.canonPreview || {};const issueCount = preview?.issueProposals?.length || 0;@@ -485,23 +392,23 @@ function ImportPanel({ onCreated }) {</p><div className="flex items-center justify-between gap-2 flex-wrap"><span className="text-xs text-gray-500">Provider/model used for this import and every later step:</span>- <ProviderModelPicker value={llm} onChange={setLlm} />+ <ProviderModelPicker value={llm} onChange={(next) => patch({ llm: next })} /></div><div className="grid grid-cols-1 sm:grid-cols-2 gap-3"><div><label htmlFor="imp-uni" className="block text-sm text-gray-400 mb-1">Universe name</label>- <input id="imp-uni" type="text" value={universeName} onChange={(e) => setUniverseName(e.target.value)}+ <input id="imp-uni" type="text" value={universeName} onChange={(e) => patch({ universeName: e.target.value })}placeholder="e.g. Giant" className="w-full bg-port-bg border border-port-border rounded px-3 py-2" /></div><div><label htmlFor="imp-ser" className="block text-sm text-gray-400 mb-1">Series name</label>- <input id="imp-ser" type="text" value={seriesName} onChange={(e) => setSeriesName(e.target.value)}+ <input id="imp-ser" type="text" value={seriesName} onChange={(e) => patch({ seriesName: e.target.value })}placeholder="e.g. Giant" className="w-full bg-port-bg border border-port-border rounded px-3 py-2" /></div></div><div><label htmlFor="imp-type" className="block text-sm text-gray-400 mb-1">Content type</label>- <select id="imp-type" value={contentType} onChange={(e) => setContentType(e.target.value)}+ <select id="imp-type" value={contentType} onChange={(e) => patch({ contentType: e.target.value })}className="w-full bg-port-bg border border-port-border rounded px-3 py-2">{types.map((t) => <option key={t} value={t}>{CONTENT_TYPE_LABELS[t] || t}</option>)}</select>@@ -510,7 +417,7 @@ function ImportPanel({ onCreated }) {<label htmlFor="imp-src" className="block text-sm text-gray-400 mb-1">Source text <span className="text-gray-600">({source.length.toLocaleString()} chars)</span></label>- <textarea id="imp-src" value={source} onChange={(e) => setSource(e.target.value)} rows={8}+ <textarea id="imp-src" value={source} onChange={(e) => patch({ source: e.target.value })} rows={8}placeholder="Paste the full script / manuscript here…"className="w-full bg-port-bg border border-port-border rounded px-3 py-2 font-mono text-xs" /></div>@@ -549,7 +456,7 @@ function ImportPanel({ onCreated }) {{committing ? <Loader2 className="w-4 h-4 animate-spin" /> : <Check className="w-4 h-4" />}{committed ? 'Retry starting the builder' : arcAlreadyPersisted ? 'Retry issues & start building' : 'Import & start building'}</button>- <button onClick={() => setPreview(null)} disabled={committing}+ <button onClick={() => patch({ preview: null })} disabled={committing}className="text-sm text-gray-400 hover:text-white px-2">Re-analyze</button></div></div>diff --git a/client/src/pages/StoryBuilder.test.jsx b/client/src/pages/StoryBuilder.test.jsxindex 089f76fc2f..0d50dba73f 100644--- a/client/src/pages/StoryBuilder.test.jsx+++ b/client/src/pages/StoryBuilder.test.jsx@@ -425,6 +425,53 @@ describe('StoryBuilder — index', () => {await waitFor(() => expect(screen.getByText(/Retry issue split/)).toBeTruthy());expect(screen.getByRole('button', { name: /Import & start building/ }).disabled).toBe(true);});++ it('import tab: a round trip through the seed tab keeps the typed intake and the analysis preview (#3904)', async () => {+ const { fireEvent } = await import('@testing-library/react');+ api.analyzeImport.mockResolvedValue({+ universe: { id: 'u1', name: 'Example Universe' }, series: { id: 's1' },+ canonPreview: { characters: [{ name: 'A' }], places: [], objects: [] },+ arcPreview: { logline: 'A courier outruns the tide.', summary: 'S' }, seasonsPreview: [],+ issueProposals: [{ number: 1, title: 'One' }],+ });+ renderAt('/story-builder');++ fireEvent.click(await screen.findByText('Import a finished work'));+ fireEvent.change(await screen.findByLabelText('Universe name'), { target: { value: 'Example Universe' } });+ fireEvent.change(screen.getByLabelText('Series name'), { target: { value: 'Example Series' } });+ fireEvent.change(screen.getByLabelText(/Source text/), { target: { value: 'PAGE ONE. A long manuscript.' } });+ fireEvent.click(screen.getByRole('button', { name: /^Analyze$/ }));++ // The minute-long analysis landed.+ expect(await screen.findByText(/Extracted “Example Universe”/)).toBeTruthy();+ expect(api.analyzeImport).toHaveBeenCalledTimes(1);++ // Flip to the seed tab and back — this used to unmount <ImportPanel> and+ // destroy the manuscript, the form fields, and the preview with it.+ fireEvent.click(screen.getByText('Start from an idea'));+ expect(await screen.findByLabelText('Universe / story name')).toBeTruthy();+ fireEvent.click(screen.getByText('Import a finished work'));++ // Everything survived, and no second analyze was needed to get it back.+ expect(await screen.findByText(/Extracted “Example Universe”/)).toBeTruthy();+ expect(screen.getByLabelText('Universe name').value).toBe('Example Universe');+ expect(screen.getByLabelText('Series name').value).toBe('Example Series');+ expect(screen.getByLabelText(/Source text/).value).toBe('PAGE ONE. A long manuscript.');+ expect(api.analyzeImport).toHaveBeenCalledTimes(1);+ });++ it('intake tab: ?intake=import deep-links straight to the import form (#3904)', async () => {+ renderAt('/story-builder?intake=import');+ expect(await screen.findByLabelText('Universe name')).toBeTruthy();+ // The seed form is the one that was replaced, not merely hidden alongside it.+ expect(screen.queryByLabelText('Universe / story name')).toBeNull();+ });++ it('intake tab: an unknown ?intake= value degrades to the seed tab, not a blank panel (#3904)', async () => {+ renderAt('/story-builder?intake=bogus');+ expect(await screen.findByLabelText('Universe / story name')).toBeTruthy();+ expect(screen.queryByLabelText('Universe name')).toBeNull();+ });});describe('StoryBuilder — detail stepper', () => {