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

feat([issue-1995]): preserve ?ref reference tab across Morse mode transitions

[._.]/ Adam Eivyb049974bd93a
diff --git a/client/src/components/meatspace/tabs/PostTab.jsx b/client/src/components/meatspace/tabs/PostTab.jsx
index 6184ab02bd..fa0b9029bb 100644
--- a/client/src/components/meatspace/tabs/PostTab.jsx
+++ b/client/src/components/meatspace/tabs/PostTab.jsx
@@ -1,5 +1,5 @@
import { useState, useEffect } from 'react';
-import { useNavigate } from 'react-router-dom';
+import { useNavigate, useLocation } from 'react-router-dom';
import { Loader } from 'lucide-react';
import { getPostConfig, getPostSessions, getPostStats } from '../../../services/api';
import { usePostSession } from '../../../hooks/usePostSession';
@@ -18,6 +18,7 @@ import { LLM_DRILL_TYPES } from '../post/constants';
export default function PostTab({ tab = 'launcher', subtab }) {
const navigate = useNavigate();
+ const location = useLocation();
const [config, setConfig] = useState(null);
const [recentSessions, setRecentSessions] = useState([]);
const [stats, setStats] = useState(null);
@@ -161,11 +162,15 @@ export default function PostTab({ tab = 'launcher', subtab }) {
// The `:mode` sub-route (copy/send) is the source of truth; an unknown
// segment degrades to the mode grid instead of a blank panel.
const morseMode = MORSE_MODE_IDS.includes(subtab) ? subtab : null;
+ // Preserve the current `?ref=` search param across mode transitions so the
+ // selected reference tab (tree/length/list) survives entering/exiting a
+ // mode — both mode and reference view are deep-linkable, so switching one
+ // must not silently reset the other back to its default.
return (
<MorseTrainer
mode={morseMode}
- onSelectMode={(id) => navigate(`/post/morse/${id}`)}
- onExitMode={() => navigate('/post/morse')}
+ onSelectMode={(id) => navigate(`/post/morse/${id}${location.search}`)}
+ onExitMode={() => navigate(`/post/morse${location.search}`)}
onBack={() => navigate('/post/launcher')}
/>
);
diff --git a/client/src/components/meatspace/tabs/PostTab.test.jsx b/client/src/components/meatspace/tabs/PostTab.test.jsx
new file mode 100644
index 0000000000..dd0792793d
--- /dev/null
+++ b/client/src/components/meatspace/tabs/PostTab.test.jsx
@@ -0,0 +1,65 @@
+import { describe, it, expect, vi } from 'vitest';
+import { render, screen, fireEvent } from '@testing-library/react';
+import { MemoryRouter, Routes, Route, useLocation } from 'react-router-dom';
+import PostTab from './PostTab';
+
+// PostTab pulls config/sessions/stats on mount and drives a session hook; stub
+// both so the component renders in isolation. The Morse tab doesn't depend on
+// any of this data — it's the pure routing surface under test here.
+vi.mock('../../../services/api', () => ({
+ getPostConfig: () => Promise.resolve(null),
+ 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(),
+ }),
+}));
+
+// Surfaces the live URL so the test can assert mode transitions keep the ?ref
+// query param — the "mode AND reference view are both deep-linkable" contract.
+function LocationProbe() {
+ const loc = useLocation();
+ return <div data-testid="loc">{loc.pathname}{loc.search}</div>;
+}
+
+describe('PostTab morse deep-linking', () => {
+ // A wildcard route keeps the probe mounted after navigation moves the URL to a
+ // different /post/morse* path (PostTab's tab/subtab arrive as props here, so the
+ // fixed element re-renders while LocationProbe reports the new location).
+ it('preserves the ?ref reference tab when entering a mode from the grid', () => {
+ render(
+ <MemoryRouter initialEntries={['/post/morse?ref=list']}>
+ <Routes>
+ <Route path="/post/*" element={<><PostTab tab="morse" /><LocationProbe /></>} />
+ </Routes>
+ </MemoryRouter>,
+ );
+ // Pick the Send mode from the grid — the ?ref=list selection must survive.
+ fireEvent.click(screen.getByText('Send'));
+ expect(screen.getByTestId('loc').textContent).toBe('/post/morse/send?ref=list');
+ });
+
+ it('preserves the ?ref reference tab when exiting a mode back to the grid', () => {
+ render(
+ <MemoryRouter initialEntries={['/post/morse/send?ref=length']}>
+ <Routes>
+ <Route path="/post/*" element={<><PostTab tab="morse" subtab="send" /><LocationProbe /></>} />
+ </Routes>
+ </MemoryRouter>,
+ );
+ // Check surfaces the send-drill feedback, whose "Pick Mode" button exits the
+ // mode back to the grid; ?ref=length must not reset to tree on the way out.
+ fireEvent.click(screen.getByText('Check'));
+ fireEvent.click(screen.getByText('Pick Mode'));
+ expect(screen.getByTestId('loc').textContent).toBe('/post/morse?ref=length');
+ });
+});