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([story-builder-goto-step-gate-divergence]): don't navigate when a step pointer move is rejected
[._.]/ Adam Eivyd9930d55aa2a
diff --git a/client/src/pages/StoryBuilder.jsx b/client/src/pages/StoryBuilder.jsxindex 91380110bf..20bfcb5701 100644--- a/client/src/pages/StoryBuilder.jsx+++ b/client/src/pages/StoryBuilder.jsx@@ -1070,7 +1070,10 @@ function StoryBuilderDetail({ storyId, stepParam }) {const nextId = stepIds[activeIdx + 1];setStoryCurrentStep(storyId, nextId, { silent: true }).then(() => navigate(`/story-builder/${storyId}/${nextId}`))- .catch(() => {});+ // The lock succeeded, but the pointer move was re-gated/rejected. Stay+ // put (don't strand the URL ahead of the persisted currentStep) and+ // resync so the rail reflects the server's actual pointer.+ .catch(() => { toast.error('Locked, but could not advance'); reload(); });}},lockedMessage: `${activeStep?.label || 'Step'} locked`,@@ -1081,8 +1084,12 @@ function StoryBuilderDetail({ storyId, stepParam }) {const goToStep = async (id) => {// Free navigation — any step is reachable. Upstream lock/stale state is// surfaced as a warning on the step (not a block), so a user can jump to a- // later step and backfill the earlier ones.- await setStoryCurrentStep(storyId, id, { silent: true }).catch(() => {});+ // later step and backfill the earlier ones. Navigate only AFTER the server+ // accepts the pointer move — otherwise a rejected re-gate (deleted session,+ // invalid step) strands the URL on a step the persisted currentStep never+ // advanced to. On rejection, resync so the rail reflects the real pointer.+ const ok = await setStoryCurrentStep(storyId, id, { silent: true }).then(() => true).catch(() => false);+ if (!ok) { toast.error('Could not switch step'); reload(); return; }navigate(`/story-builder/${storyId}/${id}`);};diff --git a/client/src/pages/StoryBuilder.test.jsx b/client/src/pages/StoryBuilder.test.jsxindex 2445381665..9b407f2164 100644--- a/client/src/pages/StoryBuilder.test.jsx+++ b/client/src/pages/StoryBuilder.test.jsx@@ -280,6 +280,44 @@ describe('StoryBuilder — detail stepper', () => {await waitFor(() => expect(api.setStoryCurrentStep).toHaveBeenCalledWith('stb-1', 'universeAesthetic', expect.anything()));});+ it('manual step click: a rejected pointer move stays put and resyncs (no navigation)', async () => {+ const { fireEvent } = await import('@testing-library/react');+ api.getStorySession.mockResolvedValue({+ id: 'stb-1', title: 'Salt Run', currentStep: 'idea', seedIdea: 'seed',+ universeId: 'u1', seriesId: 's1', steps: mkSteps(), staleSteps: [], llm: { provider: '', model: '' },+ });+ // Server re-gate rejects the pointer move (e.g. session deleted out-of-band).+ api.setStoryCurrentStep.mockRejectedValue(new Error('gate rejected'));+ renderAt('/story-builder/stb-1/idea');+ await waitFor(() => expect(screen.getByRole('heading', { name: 'Idea' })).toBeTruthy());+ const callsBefore = api.getStorySession.mock.calls.length;++ fireEvent.click(screen.getByRole('button', { name: /Plot Arc/i }));+ await waitFor(() => expect(api.setStoryCurrentStep).toHaveBeenCalledWith('stb-1', 'plotArc', expect.anything()));+ // Rejection → resync (reload refetches the session) and the URL never advances,+ // so the heading stays on Idea instead of stranding ahead of currentStep.+ await waitFor(() => expect(api.getStorySession.mock.calls.length).toBeGreaterThan(callsBefore));+ expect(screen.getByRole('heading', { name: 'Idea' })).toBeTruthy();+ });++ it('"Lock & continue": a rejected pointer move keeps the lock but does not advance', async () => {+ const { fireEvent } = await import('@testing-library/react');+ api.getStorySession.mockResolvedValue({+ id: 'stb-1', title: 'Salt Run', currentStep: 'idea', seedIdea: 'seed',+ universeId: 'u1', seriesId: 's1', steps: mkSteps(), staleSteps: [], llm: { provider: '', model: '' },+ });+ api.setStoryCurrentStep.mockRejectedValue(new Error('gate rejected'));+ renderAt('/story-builder/stb-1/idea');+ await waitFor(() => expect(screen.getByRole('heading', { name: 'Idea' })).toBeTruthy());+ fireEvent.click(screen.getByText('Lock & continue'));+ await waitFor(() => expect(api.lockStoryStep).toHaveBeenCalledWith('stb-1', 'idea', expect.anything()));+ // The auto-advance attempt fires…+ await waitFor(() => expect(api.setStoryCurrentStep).toHaveBeenCalledWith('stb-1', 'universeAesthetic', expect.anything()));+ // …but is rejected, so the URL stays on Idea (navigation is gated on .then()).+ await waitFor(() => expect(api.getStorySession.mock.calls.length).toBeGreaterThan(1));+ expect(screen.getByRole('heading', { name: 'Idea' })).toBeTruthy();+ });+it('characters step: renders a per-character preview slot and generates a styled preview image', async () => {const { fireEvent } = await import('@testing-library/react');api.getStorySession.mockResolvedValue({