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: explain why the Story Builder "Next" button is blocked (#3908)
[._.]/ Adam Eivya6f9ca048568
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex f5b9139971..da57fe4d02 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -39,6 +39,8 @@## Changed+- The Story Builder's footer "Next >" button now says why it can't be clicked. It was inert whenever the active step was unlocked or had gone stale, but carried no tooltip and no accessible description — and since the step rail beside it is deliberately un-gated, a dead Next read as a bug rather than as guidance. It now carries a `title` plus a screen-reader hint naming the actual blocker ("Lock this step to advance to the next step." vs. "An upstream step changed — re-lock this step to advance."), and uses `aria-disabled` instead of `disabled` so keyboard and screen-reader users can still reach the button and hear the reason.+- The AI provider/model dropdown on the Digital Twin personality panel — the one shown before any traits have been analyzed — now carries a screen-reader label. It sat in a centered row next to the Analyze Traits button with no `id`, no `<label htmlFor>` and no `aria-label`, so focusing it announced only an option string like "Example Provider - example-model" with nothing saying what the choice was for. A visually hidden `<label htmlFor="personality-model-select">AI Provider & Model</label>` now names it without changing the layout.- `docs/PORTS.md` now matches the code it documents. The allocation table labelled `portos-ui`'s port 5554 `ui`, but the baseline app entry in `server/services/apps.js` has always registered it as `devUi` — so anyone matching the doc against `/api/apps` output saw a label that wasn't there. The recommended-range table was drifting the other way: it opened the core block at 5554, leaving the `:5553` loopback HTTP mirror undocumented as a reserved port, and closed it at 5560, which put `portos-db` on 5561 inside the "reserved for PortOS extensions" band. Core services now read 5553-5561 with extensions starting at 5562, and the common-labels list gained the `api-local` and `devUi` entries the table already uses.diff --git a/client/src/pages/StoryBuilder.jsx b/client/src/pages/StoryBuilder.jsxindex aa7314941a..ff25071707 100644--- a/client/src/pages/StoryBuilder.jsx+++ b/client/src/pages/StoryBuilder.jsx@@ -1,4 +1,4 @@-import { useState, useEffect, useCallback, useMemo, useRef } from 'react';+import { useState, useEffect, useCallback, useId, useMemo, useRef } from 'react';import { useParams, useNavigate, useSearchParams, useLocation, Link } from 'react-router';import PageSkeleton from '../components/ui/PageSkeleton';import { filterSelectableModels } from '../utils/providers';@@ -1063,6 +1063,15 @@ function IssuesPanel({ session, series, issues, onChanged }) {// ── Detail view: stepper + active panel ─────────────────────────────────────+// Why the footer "Next >" button is (or isn't) actionable. The rail is un-gated+// — this button is the *conventional* path, so a disabled state with no stated+// reason reads as a bug rather than as guidance (#3908).+function nextButtonReason({ locked, stale }) {+ if (stale) return 'An upstream step changed — re-lock this step to advance.';+ if (!locked) return 'Lock this step to advance to the next step.';+ return 'Go to the next step.';+}+function StoryBuilderDetail({ storyId, stepParam }) {const navigate = useNavigate();const [steps, setSteps] = useState([]);@@ -1158,6 +1167,9 @@ function StoryBuilderDetail({ storyId, stepParam }) {const activeStep = steps[activeIdx];const stepState = session?.steps?.[activeStepId] || { status: 'pending', locked: false };const isStale = staleSteps.includes(activeStepId);+ const nextHintId = useId();+ const nextBlocked = !stepState.locked || isStale;+ const nextReason = nextButtonReason({ locked: stepState.locked, stale: isStale });// Navigation is advisory, not gated: the user may start from any point and// work the steps out of order (e.g. start from a drafted comic script and@@ -1419,13 +1431,25 @@ function StoryBuilderDetail({ storyId, stepParam }) {</button>)}{activeIdx < steps.length - 1 && (- <button- onClick={() => goToStep(stepIds[activeIdx + 1])}- disabled={!stepState.locked || isStale}- className="inline-flex items-center gap-1 text-sm bg-port-accent hover:bg-port-accent/80 disabled:opacity-40 text-white px-3 py-1.5 rounded"- >- Next <ChevronRight className="w-4 h-4" />- </button>+ <>+ {/* `aria-disabled` (not `disabled`) keeps the button focusable so+ keyboard/screen-reader users can reach it and hear the reason via+ the sr-only hint; `title` covers the mouse case. Same pattern as+ ExtractCanonButton.jsx. */}+ <button+ type="button"+ onClick={nextBlocked ? undefined : () => goToStep(stepIds[activeIdx + 1])}+ aria-disabled={nextBlocked || undefined}+ aria-describedby={nextHintId}+ title={nextReason}+ className={`inline-flex items-center gap-1 text-sm bg-port-accent hover:bg-port-accent/80 text-white px-3 py-1.5 rounded ${+ nextBlocked ? 'opacity-40 cursor-not-allowed' : ''+ }`}+ >+ Next <ChevronRight className="w-4 h-4" />+ </button>+ <span id={nextHintId} className="sr-only">{nextReason}</span>+ </>)}</div></div>diff --git a/client/src/pages/StoryBuilder.test.jsx b/client/src/pages/StoryBuilder.test.jsxindex c7136a502b..a9b87864d4 100644--- a/client/src/pages/StoryBuilder.test.jsx+++ b/client/src/pages/StoryBuilder.test.jsx@@ -395,10 +395,66 @@ describe('StoryBuilder — detail stepper', () => {});renderAt('/story-builder/stb-1/idea');await waitFor(() => expect(screen.getByRole('heading', { name: 'Idea' })).toBeTruthy());- // Idea not locked → primary action is "Lock & continue" and Next is disabled.+ // Idea not locked → primary action is "Lock & continue" and Next is blocked.expect(screen.getByText('Lock & continue')).toBeTruthy();const next = screen.getByRole('button', { name: /Next/i });- expect(next.disabled).toBe(true);+ expect(next.getAttribute('aria-disabled')).toBe('true');+ });++ it('explains WHY Next is blocked via title + an aria-describedby hint, and ignores clicks while blocked', async () => {+ // The step rail is un-gated, so a silently-dead "Next" reads as a bug. The+ // reason must reach mouse (title), keyboard and screen-reader users (#3908).+ 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: [],+ });+ renderAt('/story-builder/stb-1/idea');+ await waitFor(() => expect(screen.getByRole('heading', { name: 'Idea' })).toBeTruthy());++ const next = screen.getByRole('button', { name: /Next/i });+ const reason = 'Lock this step to advance to the next step.';+ expect(next.getAttribute('title')).toBe(reason);+ const hint = document.getElementById(next.getAttribute('aria-describedby'));+ expect(hint.textContent).toBe(reason);+ // The accessible NAME is still "Next" — the reason is supplementary.+ expect(next.textContent).toContain('Next');++ // aria-disabled keeps it focusable, so the click handler must be inert.+ fireEvent.click(next);+ expect(api.setStoryCurrentStep).not.toHaveBeenCalled();+ });++ it('names staleness (not the lock) as the Next blocker when the locked step went stale', async () => {+ api.getStorySession.mockResolvedValue({+ id: 'stb-1', title: 'Salt Run', currentStep: 'idea', seedIdea: 'seed',+ universeId: 'u1', seriesId: 's1', steps: mkSteps({ idea: { locked: true } }), staleSteps: ['idea'],+ });+ renderAt('/story-builder/stb-1/idea');+ await waitFor(() => expect(screen.getByRole('heading', { name: 'Idea' })).toBeTruthy());++ const next = screen.getByRole('button', { name: /Next/i });+ expect(next.getAttribute('aria-disabled')).toBe('true');+ expect(next.getAttribute('title')).toContain('re-lock this step');+ expect(document.getElementById(next.getAttribute('aria-describedby')).textContent)+ .toContain('re-lock this step');+ });++ it('drops the blocked state (and advances) once the step is locked and fresh', 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({ idea: { locked: true } }), staleSteps: [],+ });+ renderAt('/story-builder/stb-1/idea');+ await waitFor(() => expect(screen.getByRole('heading', { name: 'Idea' })).toBeTruthy());++ const next = screen.getByRole('button', { name: /Next/i });+ expect(next.getAttribute('aria-disabled')).toBeNull();+ expect(next.getAttribute('title')).toBe('Go to the next step.');++ await act(async () => { fireEvent.click(next); });+ await waitFor(() => expect(api.setStoryCurrentStep).toHaveBeenCalledWith('stb-1', 'universeAesthetic', expect.anything()));});it('shows "Generate reader map" when empty and "Re-generate" once content exists', async () => {