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: restart the drill in place when Continue's next recommendation is the current page (#3428)
[._.]/ Adam Eivya2d940d45e42
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 8781bb1827..8cc9ccfa7f 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -45,3 +45,4 @@- ~90 new falsifiability-verified tests across the changed surfaces; creative-director autopilot runs gain a 45-minute idle backstop- **Manuscript issue tabs show which issues hold an unsaved edit.** Sections only persist onBlur, so typing in issue 3 and tabbing to issue 7 left the pending text with no cue anywhere on screen. The saved-content baselines the unload guard already tracked are now state rather than a bare ref, so the tab strip subscribes to them: an issue with content drifting from its last server-confirmed save gets a dot (and an "unsaved edits" tooltip) that clears when the save lands — and stays put when the save fails. (#3399)- **Switching manuscript formats no longer discards an unsaved section edit.** Sections save onBlur, but a format switch replaced the whole section list — and its baselines — so an edit that hadn't blurred (or whose save had failed) was dropped, and switching back refetched the server's older text. The switch now flushes pending saves first and aborts if one fails, leaving the text and its tab dot on screen. Saves are also queued per section, so the blur save and the switch's flush can't PATCH the same text twice and snapshot a redundant version. (#3399)+- **"Continue Today's Routine" no longer dead-ends on the drill you just finished.** The handler navigated straight to the top recommendation's deep link with no check that it pointed somewhere else — and a sub-50% run makes the drill just missed the very item the scheduler resurfaces first, so Continue on Element Flash re-navigated to the URL already in the address bar and left the completion panel untouched. A self-referential recommendation now restarts the drill in place: a `run` nonce goes into the query string (preserving unrelated params like Morse's `?ref=`) and flows into the key of every surface the handler drives — Elements, Morse, Wordplay, and memory practice — so the drill remounts for a fresh run. Recommendations pointing elsewhere navigate exactly as before, and the comparison is path-only so a deep link carrying its own query string is still recognized as self-referential. (#3428)diff --git a/client/src/components/meatspace/tabs/PostTab.continueRoutine.test.jsx b/client/src/components/meatspace/tabs/PostTab.continueRoutine.test.jsxnew file mode 100644index 0000000000..3d3868c289--- /dev/null+++ b/client/src/components/meatspace/tabs/PostTab.continueRoutine.test.jsx@@ -0,0 +1,191 @@+import { describe, it, expect, vi, beforeEach } from 'vitest';+import { useState } from 'react';+import { render, screen, fireEvent, act } from '@testing-library/react';+import { MemoryRouter, Routes, Route, useLocation } from 'react-router';+import PostTab from './PostTab';++// Issue #3428 — "Continue Today's Routine" is shared by four practice surfaces+// and dead-ends whenever the top recommendation deep-links to the page already+// in view. That contract lives in PostTab, not in any one drill, so the drills+// are stubbed here: each surface is a two-state panel whose "complete" state is+// LOCAL, exactly like the real drills' internal progress. If the restart fails+// to remount the surface, the stub stays on its completion panel — the same+// symptom the real ElementFlashMode shows.+//+// (The end-to-end version against the real Element Flash quiz lives in+// PostTab.test.jsx; this file covers the other three routes plus the handler's+// edge cases without dragging in WebAudio and per-drill fixtures.)++const settle = () => act(async () => {});++const { getPostRecommendations } = vi.hoisted(() => ({+ getPostRecommendations: vi.fn().mockResolvedValue({ recommendations: [] }),+}));++vi.mock('../../../services/api', () => ({+ getPostConfig: () => Promise.resolve({}),+ getPostRecommendations,+ getPostSessions: () => Promise.resolve([]),+ getPostStats: () => Promise.resolve(null),+}));++vi.mock('../../../hooks/usePostSession', () => ({+ usePostSession: () => ({+ state: 'idle',+ drills: [],+ currentDrillIndex: 0,+ currentDrill: null,+ drillCount: 0,+ drillResults: [],+ reset: vi.fn(),+ }),+}));++// A stand-in drill: "Finish" flips it to the completion panel (local state, so a+// remount resets it), and the panel offers the shared Continue action.+function SurfaceStub({ label, onContinue }) {+ const [done, setDone] = useState(false);+ if (!done) return <button onClick={() => setDone(true)}>Finish {label}</button>;+ return (+ <div>+ <div>{label} complete</div>+ <button onClick={() => onContinue()}>Continue Today's Routine</button>+ </div>+ );+}++vi.mock('../post/MorseTrainer', () => ({+ default: ({ onContinue }) => <SurfaceStub label="Morse" onContinue={onContinue} />,+ MORSE_MODE_IDS: ['copy', 'head-copy', 'send'],+}));+vi.mock('../post/WordplayTrainer', () => ({+ default: ({ onContinue }) => <SurfaceStub label="Wordplay" onContinue={onContinue} />,+}));+vi.mock('../post/MemoryPractice', () => ({+ default: ({ onContinue }) => <SurfaceStub label="Memory" onContinue={onContinue} />,+ MEMORY_PRACTICE_MODE_IDS: ['spaced', 'sequence'],+}));+vi.mock('../post/ElementsSong', () => ({+ default: ({ onContinue }) => <SurfaceStub label="Elements" onContinue={onContinue} />,+ ELEMENTS_MODE_IDS: ['learn', 'element-study', 'element-flash', 'fill-blank'],+}));+// PostTab's remaining imports are unreachable on the routes exercised here, but+// they still have to resolve — stub the ones that pull in heavy dependencies.+vi.mock('../../RapidReader', () => ({ RapidReaderModal: () => null }));++function LocationProbe() {+ const loc = useLocation();+ return <div data-testid="loc">{loc.pathname}{loc.search}</div>;+}++const renderAt = (path, props) => render(+ <MemoryRouter initialEntries={[path]}>+ <Routes>+ <Route path="/post/*" element={<><PostTab {...props} /><LocationProbe /></>} />+ </Routes>+ </MemoryRouter>,+);++const recommend = (deepLink) => getPostRecommendations.mockResolvedValueOnce({+ recommendations: [{ id: 'rec-1', kind: 'memory-due', title: 'Practice this again', deepLink, priority: 0 }],+});++// Drive one surface from "finish the drill" through "Continue".+async function finishAndContinue(label) {+ fireEvent.click(screen.getByText(`Finish ${label}`));+ await settle();+ expect(screen.getByText(`${label} complete`)).toBeInTheDocument();+ fireEvent.click(screen.getByText("Continue Today's Routine"));+ await settle();+}++describe('PostTab continueDailyRoutine', () => {+ beforeEach(() => {+ getPostRecommendations.mockReset();+ getPostRecommendations.mockResolvedValue({ recommendations: [] });+ });++ it('restarts the Morse drill in place, preserving the ?ref reference tab', async () => {+ recommend('/post/morse/copy');+ renderAt('/post/morse/copy?ref=list', { tab: 'morse', subtab: 'copy' });+ await settle();++ await finishAndContinue('Morse');++ expect(screen.getByText('Finish Morse')).toBeInTheDocument();+ expect(screen.queryByText('Morse complete')).not.toBeInTheDocument();+ expect(screen.getByTestId('loc').textContent).toBe('/post/morse/copy?ref=list&run=1');+ });++ it('restarts the Wordplay trainer in place', async () => {+ recommend('/post/wordplay/anagram');+ renderAt('/post/wordplay/anagram', { tab: 'wordplay', subtab: 'anagram' });+ await settle();++ await finishAndContinue('Wordplay');++ expect(screen.getByText('Finish Wordplay')).toBeInTheDocument();+ expect(screen.getByTestId('loc').textContent).toBe('/post/wordplay/anagram?run=1');+ });++ it('restarts memory practice in place', async () => {+ recommend('/post/memory/raven/spaced');+ renderAt('/post/memory/raven/spaced', { tab: 'memory', subtab: 'raven', mode: 'spaced' });+ await settle();++ await finishAndContinue('Memory');++ expect(screen.getByText('Finish Memory')).toBeInTheDocument();+ expect(screen.getByTestId('loc').textContent).toBe('/post/memory/raven/spaced?run=1');+ });++ it('compares only the deepLink path, so a query-carrying self-link still restarts', async () => {+ recommend('/post/morse/copy?ref=tree');+ renderAt('/post/morse/copy', { tab: 'morse', subtab: 'copy' });+ await settle();++ await finishAndContinue('Morse');++ expect(screen.getByText('Finish Morse')).toBeInTheDocument();+ expect(screen.getByTestId('loc').textContent).toBe('/post/morse/copy?run=1');+ });++ it('bumps the nonce on each successive same-page continue', async () => {+ recommend('/post/morse/copy');+ renderAt('/post/morse/copy?run=1', { tab: 'morse', subtab: 'copy' });+ await settle();++ await finishAndContinue('Morse');++ expect(screen.getByTestId('loc').textContent).toBe('/post/morse/copy?run=2');+ });++ it('still navigates away when the recommendation points at a different surface', async () => {+ recommend('/post/memory/raven/spaced');+ renderAt('/post/morse/copy', { tab: 'morse', subtab: 'copy' });+ await settle();++ await finishAndContinue('Morse');++ expect(screen.getByTestId('loc').textContent).toBe('/post/memory/raven/spaced');+ });++ it('falls back to the launcher when there is nothing to recommend', async () => {+ renderAt('/post/morse/copy', { tab: 'morse', subtab: 'copy' });+ await settle();++ await finishAndContinue('Morse');++ expect(screen.getByTestId('loc').textContent).toBe('/post/launcher');+ });++ it('routes a launcher recommendation through the autostart param, not a restart', async () => {+ recommend('/post/launcher');+ renderAt('/post/morse/copy', { tab: 'morse', subtab: 'copy' });+ await settle();++ await finishAndContinue('Morse');++ expect(screen.getByTestId('loc').textContent).toBe('/post/launcher?continue=rec-1');+ });+});diff --git a/client/src/components/meatspace/tabs/PostTab.jsx b/client/src/components/meatspace/tabs/PostTab.jsxindex 461d914047..4076c690c8 100644--- a/client/src/components/meatspace/tabs/PostTab.jsx+++ b/client/src/components/meatspace/tabs/PostTab.jsx@@ -41,6 +41,13 @@ export const MEMORY_SUBROUTES = [];const MEMORY_SUBROUTE_IDS = MEMORY_SUBROUTES.map((s) => s.id);+// A recommendation's deepLink may carry its own query string / hash; only the+// PATH decides whether it points at a different surface than the one in view.+const deepLinkPath = (deepLink) => String(deepLink || '').split(/[?#]/)[0];++// Query param carrying the restart nonce (see `restartInPlace` below).+const RUN_PARAM = 'run';+export default function PostTab({ tab = 'launcher', subtab, mode }) {const navigate = useNavigate();const location = useLocation();@@ -83,6 +90,19 @@ export default function PostTab({ tab = 'launcher', subtab, mode }) {if (started) navigate('/post/session/run');}+ // The top recommendation deep-links to the page already in view — which a+ // sub-50% run legitimately produces, since the drill just missed is the very+ // item the scheduler resurfaces first. `navigate()` to the current URL is a+ // no-op, so bump a `run` nonce instead: it flows into each practice surface's+ // key below and remounts the drill for a fresh run. Unrelated params survive+ // (Morse threads its `?ref=` reference tab through the URL).+ function restartInPlace() {+ const params = new URLSearchParams(location.search);+ const current = Number(params.get(RUN_PARAM));+ params.set(RUN_PARAM, String(Number.isFinite(current) ? current + 1 : 1));+ navigate(`${location.pathname}?${params}`);+ }+// Save success either continues the daily recommendation chain or opens the// deep-linkable saved result. The run id === session id.async function continueDailyRoutine() {@@ -92,8 +112,10 @@ export default function PostTab({ tab = 'launcher', subtab, mode }) {navigate('/post/launcher');return;}- if (recommendation.deepLink && recommendation.deepLink !== '/post/launcher') {- navigate(recommendation.deepLink);+ const target = deepLinkPath(recommendation.deepLink);+ if (target && target !== '/post/launcher') {+ if (target === location.pathname) restartInPlace();+ else navigate(recommendation.deepLink);return;}navigate(`/post/launcher?continue=${encodeURIComponent(recommendation.id)}`);@@ -119,6 +141,11 @@ export default function PostTab({ tab = 'launcher', subtab, mode }) {}}+ // Restart nonce set by `restartInPlace`. Folded into the key of every surface+ // `continueDailyRoutine` can target, so a same-page "continue" remounts the+ // drill instead of leaving its completion screen on screen.+ const runNonce = new URLSearchParams(location.search).get(RUN_PARAM) || '';+const currentDrillConfig = session.drills[session.currentDrillIndex];const activeType = currentDrillConfig?.type || session.currentDrill?.type;const isLlmDrill = activeType ? LLM_DRILL_TYPES.includes(activeType) : false;@@ -242,6 +269,7 @@ export default function PostTab({ tab = 'launcher', subtab, mode }) {// mirroring the Morse trainer's `:mode` routing.return (<WordplayTrainer+ key={`run:${runNonce}`}config={config}onConfigUpdate={setConfig}mode={subtab}@@ -261,6 +289,7 @@ export default function PostTab({ tab = 'launcher', subtab, mode }) {// must not silently reset the other back to its default.return (<MorseTrainer+ key={`run:${runNonce}`}mode={morseMode}onSelectMode={(id) => navigate(`/post/morse/${id}${location.search}`)}onExitMode={() => navigate(`/post/morse${location.search}`)}@@ -294,6 +323,7 @@ export default function PostTab({ tab = 'launcher', subtab, mode }) {const elementsMode = ELEMENTS_MODE_IDS.includes(mode) ? mode : null;return (<ElementsSong+ key={`run:${runNonce}`}item={elementsItem}mode={elementsMode}onSelectMode={(id) => navigate(`/post/memory/elements/${id}`)}@@ -311,7 +341,7 @@ export default function PostTab({ tab = 'launcher', subtab, mode }) {// from clean state without a manual reset.return (<MemoryPractice- key={`${subtab}:${practiceMode || 'picker'}`}+ key={`${subtab}:${practiceMode || 'picker'}:${runNonce}`}itemId={subtab}item={memoryItem?.id === subtab ? memoryItem : null}mode={practiceMode}diff --git a/client/src/components/meatspace/tabs/PostTab.test.jsx b/client/src/components/meatspace/tabs/PostTab.test.jsxindex 2ff12be268..bc6aab3b88 100644--- a/client/src/components/meatspace/tabs/PostTab.test.jsx+++ b/client/src/components/meatspace/tabs/PostTab.test.jsx@@ -229,4 +229,36 @@ describe('PostTab memory deep-linking (issue #3249)', () => {expect(getPostRecommendations).toHaveBeenCalledWith(1);expect(screen.getByTestId('loc').textContent).toBe('/post/morse/copy');});++ // Issue #3428: a sub-50% run legitimately makes the drill just finished the+ // top recommendation again, so its deepLink is the page already in view.+ // Navigating there is a no-op — Continue must restart the drill instead of+ // leaving the completion panel on screen.+ it('restarts the drill in place when the next recommendation deep-links to the current page', async () => {+ getPostRecommendations.mockResolvedValueOnce({ recommendations: [{+ id: 'memory-due:elements-song',+ kind: 'memory-due',+ title: 'Elements: due for review',+ deepLink: '/post/memory/elements/element-flash',+ priority: 0,+ }] });+ renderMemory('/post/memory/elements/element-flash?ref=list', { subtab: 'elements', mode: 'element-flash' });+ await settle();++ // Skip the only question (ELEMENTS_ITEM has a single-element map) to land on+ // the completion panel with a sub-50% score.+ fireEvent.click(screen.getByLabelText('Skip'));+ fireEvent.click(screen.getByText('Next'));+ await settle();+ expect(screen.getByText('Element Flash Complete')).toBeInTheDocument();++ fireEvent.click(screen.getByText("Continue Today's Routine"));+ await settle();++ // Fresh run: progress back at the first question, completion panel gone —+ // and the unrelated ?ref= param survives the restart.+ expect(screen.getByText('1 / 1')).toBeInTheDocument();+ expect(screen.queryByText('Element Flash Complete')).not.toBeInTheDocument();+ expect(screen.getByTestId('loc').textContent).toBe('/post/memory/elements/element-flash?ref=list&run=1');+ });});