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
feat: route each sub-shell at /shell/:sessionId so reload preserves the active shell
[._.]/ Adam Eivya68a3912a45a
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 3d565e6d76..06bbf21d73 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -2,6 +2,16 @@## Added+- **Shell — UUID-based URLs for each sub-shell session.** The shell page now+ mounts at `/shell/:sessionId` in addition to `/shell`, and mirrors the active+ session id into the URL whenever a session is started, attached, or switched.+ Reload preserves the active shell, the URL is shareable as a deep link, and+ browser back/forward + manual URL paste switch between live sessions.+ Stopping or killing the active session (or its PTY exiting with no remaining+ sessions) clears the URL back to `/shell`. The pre-existing `?session=<uuid>`+ query-param (one-shot "attach to this session") still works alongside the+ new path param.+- **Universe Canon page — lock toggle, tag chips, and "from series" badge on every card.**Phase 2a of the Universe-as-Canon UI. Each `CanonCard` (used on both theUniverse Canon page and the per-series Nouns page) now renders:diff --git a/client/src/App.jsx b/client/src/App.jsxindex a9d1b2c317..b4469da5c7 100644--- a/client/src/App.jsx+++ b/client/src/App.jsx@@ -168,6 +168,7 @@ export default function App() {<Route path="settings/:tab" element={<Settings />} /><Route path="uploads" element={<Uploads />} /><Route path="shell" element={<Shell />} />+ <Route path="shell/:sessionId" element={<Shell />} /><Route path="browser" element={<BrowserPage />} /><Route path="insights" element={<Navigate to="/insights/overview" replace />} /><Route path="insights/:tab" element={<Insights />} />diff --git a/client/src/pages/Shell.jsx b/client/src/pages/Shell.jsxindex 12cb4d7f67..82fc07811a 100644--- a/client/src/pages/Shell.jsx+++ b/client/src/pages/Shell.jsx@@ -1,5 +1,5 @@import { useEffect, useRef, useState, useCallback } from 'react';-import { useSearchParams } from 'react-router-dom';+import { useSearchParams, useParams, useNavigate } from 'react-router-dom';import { Terminal } from '@xterm/xterm';import { FitAddon } from '@xterm/addon-fit';import { WebLinksAddon } from '@xterm/addon-web-links';@@ -44,12 +44,17 @@ const shortId = (id) => id?.slice(0, 6) ?? '';export default function Shell() {const [searchParams, setSearchParams] = useSearchParams();+ const { sessionId: urlSessionId } = useParams();+ const navigate = useNavigate();const terminalRef = useRef(null);const termInstanceRef = useRef(null);const fitAddonRef = useRef(null);const sessionIdRef = useRef(null);const initialOptsRef = useRef(null);const hasInitializedRef = useRef(false);+ // Mirror urlSessionId into a ref so callbacks (activateSession, handleSessions) can read the+ // latest URL without forcing the heavy socket-listener effect to re-bind on every URL change.+ const urlSessionIdRef = useRef(urlSessionId);const socket = useSocket();const [connected, setConnected] = useState(false);const [sessions, setSessions] = useState([]);@@ -61,6 +66,8 @@ export default function Shell() {const dropdownRef = useRef(null);const sessionsRef = useRef([]);+ useEffect(() => { urlSessionIdRef.current = urlSessionId; }, [urlSessionId]);+// Read query params once on mount for initial session optionsuseEffect(() => {if (initialOptsRef.current) return;@@ -225,11 +232,20 @@ export default function Shell() {return () => disposable.dispose();}, [socket]);+ const clearActiveSession = useCallback(() => {+ sessionIdRef.current = null;+ setActiveSessionId(null);+ setConnected(false);+ }, []);+const activateSession = useCallback((sessionId) => {sessionIdRef.current = sessionId;setActiveSessionId(sessionId);setConnected(true);- }, []);+ if (urlSessionIdRef.current !== sessionId) {+ navigate(`/shell/${sessionId}`, { replace: true });+ }+ }, [navigate]);const startSession = useCallback(() => {if (!socket?.connected) return;@@ -257,37 +273,31 @@ export default function Shell() {const stopSession = useCallback(() => {if (socket && sessionIdRef.current) {socket.emit('shell:stop', { sessionId: sessionIdRef.current });- sessionIdRef.current = null;- setActiveSessionId(null);- setConnected(false);+ clearActiveSession();if (termInstanceRef.current) {termInstanceRef.current.writeln('\r\n\x1b[33m[Session killed]\x1b[0m');}+ navigate('/shell', { replace: true });}- }, [socket]);+ }, [socket, navigate, clearActiveSession]);const killOtherSession = useCallback((sessionId) => {if (!socket) return;socket.emit('shell:stop', { sessionId });- // If killing the active session via tab X, clean up local state tooif (sessionId === sessionIdRef.current) {- sessionIdRef.current = null;- setActiveSessionId(null);- setConnected(false);+ clearActiveSession();if (termInstanceRef.current) {termInstanceRef.current.writeln('\r\n\x1b[33m[Session killed]\x1b[0m');}+ navigate('/shell', { replace: true });}- }, [socket]);+ }, [socket, navigate, clearActiveSession]);const switchToSession = useCallback((sessionId) => {if (sessionId === sessionIdRef.current) return;- // Detach current display (don't kill)- sessionIdRef.current = null;- setActiveSessionId(null);- setConnected(false);+ clearActiveSession();attachToSession(sessionId);- }, [attachToSession]);+ }, [attachToSession, clearActiveSession]);// Handle socket connection and shell session eventsuseEffect(() => {@@ -301,9 +311,7 @@ export default function Shell() {const handleDisconnect = () => {// Clear session state so reconnect auto-reattaches- sessionIdRef.current = null;- setActiveSessionId(null);- setConnected(false);+ clearActiveSession();};const handleSessions = (sessionList) => {@@ -313,12 +321,16 @@ export default function Shell() {if (!hasInitializedRef.current) {hasInitializedRef.current = true;const opts = initialOptsRef.current || {};+ const urlSid = urlSessionIdRef.current;// If we have initial opts (cwd/cmd), always create a new sessionif (opts.session && sessionList.some(s => s.sessionId === opts.session)) {attachToSession(opts.session);initialOptsRef.current = {};} else if (opts.cwd || opts.cmd) {startSession();+ } else if (urlSid && sessionList.some(s => s.sessionId === urlSid)) {+ // URL points at a live session — attach to that one+ attachToSession(urlSid);} else if (sessionList.length > 0 && !sessionIdRef.current) {// Attach to most recent existing sessionconst latest = sessionList[sessionList.length - 1];@@ -364,9 +376,7 @@ export default function Shell() {const handleShellExit = ({ sessionId: sid, code }) => {if (sid === sessionIdRef.current) {- setConnected(false);- sessionIdRef.current = null;- setActiveSessionId(null);+ clearActiveSession();if (termInstanceRef.current) {termInstanceRef.current.writeln(`\r\n\x1b[33m[Shell exited with code ${code}]\x1b[0m`);}@@ -374,6 +384,8 @@ export default function Shell() {const remaining = sessionsRef.current.filter(s => s.sessionId !== sid);if (remaining.length > 0) {setTimeout(() => attachToSession(remaining[remaining.length - 1].sessionId), 100);+ } else {+ navigate('/shell', { replace: true });}}};@@ -409,7 +421,16 @@ export default function Shell() {// Don't kill session on unmount — it persists server-sidesessionIdRef.current = null;};- }, [socket, startSession, attachToSession, activateSession]);+ }, [socket, startSession, attachToSession, activateSession, navigate, clearActiveSession]);++ // React to URL changes after init (browser back/forward, manual URL paste).+ // If the URL points at a known session that isn't currently displayed, switch to it.+ useEffect(() => {+ if (!hasInitializedRef.current) return;+ if (!urlSessionId) return;+ if (!sessionsRef.current.some(s => s.sessionId === urlSessionId)) return;+ switchToSession(urlSessionId);+ }, [urlSessionId, switchToSession]);return (<div className="h-full flex flex-col p-4 md:p-6">