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

fix: keep Reverse Outline scene selection in the URL instead of local state (#3868)

[._.]/ Adam Eivy9050f1e3a059
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index c4a8e04252..74060938d4 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -44,3 +44,4 @@
- The memory list and timeline endpoints now validate their query strings against the Zod schemas that were written for them. Both handlers had been hand-parsing `req.query`, so the declared bounds went unenforced: an unknown memory type, a garbled `limit`, or a nonsense date range was quietly accepted and passed to the database. Both schemas now also accept the comma-separated, string-valued form a query string actually arrives in, and the list `limit` ceiling is 500 — the bound the route has always enforced in practice — rather than the 100 its schema claimed. The timeline endpoint also finally honours an `appId` filter, which both of its backends have always supported but the hand-written parsing never passed along.
- Agents run on an API provider (LM Studio, raw OpenAI/Anthropic — anything with no native filesystem tools) now receive the per-directory `CLAUDE.md` files too, not just the global and repo-root ones. Those agents read nothing off disk on their own, so a convention that lived in `server/CLAUDE.md` or `client/src/CLAUDE.md` reached them as a pointer with no contents — which is how relocating a backup rsync-exclude rule out of the root file silently removed a data-loss guard from that whole class of agent. Nested files are now discovered under the workspace and spliced in after the root one, each labeled with its repo-relative path, bounded to 10 files and 5 levels deep and skipping vendored, generated, and runtime trees.
- The Node version PortOS requires is now written down in exactly one place and checked before anything slow runs. The floor was copied into five sites that could drift apart — both setup scripts, `.nvmrc`, the CI workflows and the README — while the install path the README actually documents (`npm run setup`, `npm start`) checked none of them, so an unsupported Node installed happily for several minutes and then failed inside Vite with an error that never named the cause. `scripts/checkNodeVersion.js` now owns the number (22.12), runs first in the root `setup`, `start` and `dev` scripts so an old Node fails in the first second, and a drift test holds the other sites to it — the shell gates and the README to the floor exactly, `.nvmrc` and CI to at-or-above it, since running CI on 24 while supporting 22.12 is a preference rather than a mistake. All four `package.json` files now declare `engines` as well.
+- The Pipeline's Reverse Outline map now keeps the selected scene in the URL (`?scene=<id>`) instead of component state, so the open scene detail survives a reload and can be linked to or shared. A stale id — after regenerating the outline, say — falls back to the "click a marker" placeholder rather than a blank card, and regenerating clears the selection outright.
diff --git a/client/src/pages/PipelineReverseOutline.jsx b/client/src/pages/PipelineReverseOutline.jsx
index df0583cada..98f53ec0ca 100644
--- a/client/src/pages/PipelineReverseOutline.jsx
+++ b/client/src/pages/PipelineReverseOutline.jsx
@@ -21,6 +21,7 @@ import {
pipelineReverseOutlineSseUrl,
} from '../services/api';
import { usePipelineProgress } from '../hooks/usePipelineProgress';
+import useUrlParams from '../hooks/useUrlParams';
import { buildPlotlineGrid, sceneComponentCount } from '../lib/reverseOutlineGrid.js';
const RUN_ENDED = new Set(['complete', 'canceled', 'cancelled', 'error']);
@@ -33,7 +34,9 @@ export default function PipelineReverseOutline() {
const [loading, setLoading] = useState(true);
const [active, setActive] = useState(false);
const [starting, setStarting] = useState(false);
- const [selected, setSelected] = useState(null); // selected scene (detail panel)
+ // Scene selection lives in the URL (`?scene=<sceneId>`) so the open detail
+ // panel is shareable, bookmarkable, and survives a reload.
+ const [searchParams, updateParams] = useUrlParams();
const activeRunIdRef = useRef(null);
// Load series + outline, and re-attach to an in-flight run on (re)mount.
@@ -81,7 +84,8 @@ export default function PipelineReverseOutline() {
const handleGenerate = async (force) => {
setStarting(true);
- setSelected(null);
+ // The regenerated outline mints new scene ids — drop the stale selection.
+ updateParams({ scene: null }, { replace: true });
// Await the POST so the run is registered server-side BEFORE the SSE
// subscription connects — otherwise the progress stream 404s on attach.
const res = await generateReverseOutline(seriesId, { force }, { silent: true }).catch((err) => {
@@ -111,6 +115,10 @@ export default function PipelineReverseOutline() {
const hasOutline = outline?.status === 'complete' && scenes.length > 0;
const busy = active || starting;
const { rows } = buildPlotlineGrid(scenes, plotlines);
+ // A stale/deleted `?scene=` id resolves to null — the detail panel falls back
+ // to its "click a marker" placeholder instead of rendering a blank card.
+ const selected = scenes.find((s) => s.id === searchParams.get('scene')) || null;
+ const handleSelect = (scene) => updateParams({ scene: scene.id });
return (
<div className="h-full overflow-y-auto p-4 md:p-6">
@@ -161,7 +169,7 @@ export default function PipelineReverseOutline() {
) : (
<div className="flex flex-col gap-4">
<PlotlineLegend rows={rows} />
- <PlotlineGrid rows={rows} scenes={scenes} selected={selected} onSelect={setSelected} />
+ <PlotlineGrid rows={rows} scenes={scenes} selected={selected} onSelect={handleSelect} />
<SceneDetail scene={selected} plotlines={plotlines} seriesId={seriesId} navigate={navigate} />
<p className="text-xs text-gray-500">
{scenes.length} scenes · {plotlines.length} plotlines
diff --git a/client/src/pages/PipelineReverseOutline.selection.test.jsx b/client/src/pages/PipelineReverseOutline.selection.test.jsx
new file mode 100644
index 0000000000..543c095567
--- /dev/null
+++ b/client/src/pages/PipelineReverseOutline.selection.test.jsx
@@ -0,0 +1,80 @@
+import { describe, it, expect, vi, beforeEach } from 'vitest';
+import { render, screen, waitFor } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import { MemoryRouter, Routes, Route, useLocation } from 'react-router';
+import PipelineReverseOutline from './PipelineReverseOutline';
+
+const getPipelineSeries = vi.fn();
+const getReverseOutline = vi.fn();
+const getReverseOutlineStatus = vi.fn();
+
+vi.mock('../services/api', () => ({
+ getPipelineSeries: (...a) => getPipelineSeries(...a),
+ getReverseOutline: (...a) => getReverseOutline(...a),
+ generateReverseOutline: vi.fn(),
+ cancelReverseOutline: vi.fn(),
+ getReverseOutlineStatus: (...a) => getReverseOutlineStatus(...a),
+ pipelineReverseOutlineSseUrl: () => '/sse',
+}));
+
+vi.mock('../hooks/usePipelineProgress', () => ({ usePipelineProgress: () => ({ latest: null }) }));
+vi.mock('../components/ui/Toast', () => ({ default: { error: vi.fn(), success: vi.fn(), warning: vi.fn() } }));
+
+const OUTLINE = {
+ status: 'complete',
+ plotlines: [{ id: 'pl-1', label: 'Main thread', kind: 'main', color: '#ff0000' }],
+ scenes: [
+ { id: 'sc-1', plotlineId: 'pl-1', heading: 'Opening scene', summary: 'The first beat.', issueNumber: 1 },
+ { id: 'sc-2', plotlineId: 'pl-1', heading: 'Second scene', summary: 'The second beat.', issueNumber: 2 },
+ ],
+};
+
+function LocationProbe() {
+ const { search } = useLocation();
+ return <span data-testid="search">{search}</span>;
+}
+
+function renderAt(entry = '/pipeline/series/ser-1/reverse-outline') {
+ return render(
+ <MemoryRouter initialEntries={[entry]}>
+ <Routes>
+ <Route
+ path="/pipeline/series/:seriesId/reverse-outline"
+ element={<><PipelineReverseOutline /><LocationProbe /></>}
+ />
+ <Route path="/pipeline" element={<div>Pipeline index</div>} />
+ </Routes>
+ </MemoryRouter>,
+ );
+}
+
+beforeEach(() => {
+ getPipelineSeries.mockReset().mockResolvedValue({ id: 'ser-1', name: 'Example Series' });
+ getReverseOutline.mockReset().mockResolvedValue(OUTLINE);
+ getReverseOutlineStatus.mockReset().mockResolvedValue({ active: false });
+});
+
+describe('PipelineReverseOutline scene selection', () => {
+ it('opens the detail panel from a ?scene= deep link', async () => {
+ renderAt('/pipeline/series/ser-1/reverse-outline?scene=sc-2');
+ expect(await screen.findByText('Second scene')).toBeInTheDocument();
+ expect(screen.getByText('The second beat.')).toBeInTheDocument();
+ });
+
+ it('writes the clicked scene into the URL instead of local state', async () => {
+ const user = userEvent.setup();
+ renderAt();
+ await screen.findAllByText('Main thread');
+ expect(screen.getByText(/Click a scene marker/)).toBeInTheDocument();
+
+ await user.click(screen.getByTitle('Opening scene'));
+
+ await waitFor(() => expect(screen.getByTestId('search')).toHaveTextContent('scene=sc-1'));
+ expect(screen.getByText('The first beat.')).toBeInTheDocument();
+ });
+
+ it('falls back to the placeholder when ?scene= names a scene that no longer exists', async () => {
+ renderAt('/pipeline/series/ser-1/reverse-outline?scene=sc-gone');
+ expect(await screen.findByText(/Click a scene marker/)).toBeInTheDocument();
+ });
+});