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: derive Sharing tab from URL param, history-safe (#2389)
Adam Eivy0f895b32a22c
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex d50873b61a..8bd89e2125 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -81,3 +81,5 @@- **Rounds and Music Video can now turn a reference audio file into MIDI locally via MuScriptor.** MuScriptor (github.com/muscriptor/muscriptor) is a multi-instrument audio → MIDI transcription model that runs in an opt-in venv (`INSTALL_MUSCRIPTOR=1 bash scripts/setup-image-video.sh`, weights auto-download from HuggingFace on first use; small/medium/large tiers). A new shared service (`server/services/audioMidiTranscription.js` + the `scripts/transcribe_muscriptor.py` sidecar, same STAGE:/RESULT: wire protocol as the music-gen sidecars) exposes the kickoff/SSE/cancel job shape in both features: a Rounds reference with attached audio gains a **Transcribe MIDI** control (the resulting `.mid` lands as `references[].midiFilename` on Save, cleared with the audio like segments), and a Music Video project gains a **MIDI** toolbar button + download link (`project.midiTranscription` is persisted server-side on completion and invalidated when the audio source changes, exactly like `audioAnalysis`). When the venv isn't provisioned the kickoff 503s with the install hint instead of a bare spawn error.- **[issue-2386] ffmpeg render errors are now separated into pre-spawn and post-spawn, so a failed kill can no longer let a replacement render overlap the live process.** The music-video and timeline renderers both routed every `'error'` event through the same immediate finalizer — which released the per-project render mutex and dropped process ownership. But `'error'` fires for two very different cases: a genuine pre-spawn failure (ENOENT — the child never started, no `'close'` follows) and a *later* child-process error such as a failed kill while ffmpeg is still running. Releasing the mutex on the latter let a re-render spawn and overlap the still-live ffmpeg. Both services now track spawn state (a `'spawn'` listener sets a flag) and finalize immediately only for pre-spawn errors; a post-spawn error is recorded but retains process + project-mutex ownership until the pending `'close'` runs the sole terminal finalization. A shared `terminal` guard makes terminal handling exactly-once across the error and close paths, and both handlers wrap their body per the child-process-callback convention. Covered by new error-to-close sequence tests before and after spawn in both services.++- **[issue-2389] The Sharing page's per-bucket detail tab (Inbox / Activity / Settings) is now URL-derived and history-safe.** The sub-tab was held in component-local `useState('inbox')`, so it wasn't deep-linkable and browser back/forward could disagree with the visible tab. It now derives from a validated `?tab=` search param via `useDrawerTab('tab', 'inbox', BUCKET_TAB_IDS)` — a direct link opens the named tab, a stale/hand-edited value degrades to Inbox, and switching buckets (a fresh route without the query) resets to Inbox. New render tests cover the direct-link, invalid-fallback, and back/forward cases.diff --git a/client/src/pages/Sharing.jsx b/client/src/pages/Sharing.jsxindex e427394374..1e0464bd27 100644--- a/client/src/pages/Sharing.jsx+++ b/client/src/pages/Sharing.jsx@@ -17,6 +17,7 @@ import InlineConfirmRow from '../components/ui/InlineConfirmRow';import { FormField } from '../components/ui/FormField';import { formatDateTime } from '../utils/formatters';import { useConfirmDelete } from '../hooks/useConfirmDelete';+import useDrawerTab from '../hooks/useDrawerTab';import FolderPicker from '../components/FolderPicker';import DuplicatesTab from '../components/sharing/DuplicatesTab';import ConflictsTab from '../components/sharing/ConflictsTab';@@ -51,6 +52,11 @@ export const SECTIONS = [{ id: 'conflicts', label: 'Conflicts', icon: GitMerge, path: '/sharing/conflicts' },];+// Per-bucket detail sub-tabs. Held in the `?tab=` URL search param (not local+// state) so the open view is deep-linkable, reload-safe, and stays in sync with+// browser back/forward — a stale/hand-edited value degrades to Inbox.+export const BUCKET_TAB_IDS = ['inbox', 'activity', 'settings'];+function SharingHeader({ active }) {return (<>@@ -100,7 +106,9 @@ function SharingBuckets({ selectedId }) {const [showAdd, setShowAdd] = useState(false);const [form, setForm] = useState(emptyForm);const [creating, setCreating] = useState(false);- const [activeTab, setActiveTab] = useState('inbox'); // inbox | activity | settings+ // Active detail sub-tab lives in the URL (`?tab=inbox|activity|settings`) so it's+ // deep-linkable and history-safe; a stale/invalid value degrades to Inbox.+ const [activeTab, setActiveTab] = useDrawerTab('tab', 'inbox', BUCKET_TAB_IDS);// Display name + bio settings — used as the source attribution on outgoing shares.const [sharingDisplayName, setSharingDisplayName] = useState('');diff --git a/client/src/pages/Sharing.test.jsx b/client/src/pages/Sharing.test.jsxindex f74c191dc2..cb0f50a89c 100644--- a/client/src/pages/Sharing.test.jsx+++ b/client/src/pages/Sharing.test.jsx@@ -1,4 +1,6 @@-import { describe, it, expect, vi } from 'vitest';+import { describe, it, expect, vi, beforeEach } from 'vitest';+import { render, screen, waitFor, act } from '@testing-library/react';+import { createMemoryRouter, RouterProvider } from 'react-router-dom';// Sharing.jsx pulls in socket.io-client at module scope (auto-connects).// Stub it so the test runner doesn't try to open a network socket.@@ -16,7 +18,8 @@ vi.mock('../services/api', () => ({updateSettings: vi.fn(),}));-import { isLiveSubscription } from './Sharing';+import Sharing, { isLiveSubscription } from './Sharing';+import * as api from '../services/api';const NOW = Date.parse('2026-05-18T12:00:00Z');@@ -54,3 +57,64 @@ describe('isLiveSubscription', () => {expect(isLiveSubscription(undefined, NOW)).toBe(false);});});++// The per-bucket detail sub-tab (Inbox | Activity | Settings) is derived from the+// `?tab=` URL search param — not component-local state — so it's deep-linkable+// and stays in sync with browser back/forward.+describe('Sharing bucket detail tab (URL-derived)', () => {+ beforeEach(() => {+ vi.clearAllMocks();+ api.listShareBuckets.mockResolvedValue({+ buckets: [{ id: 'b1', name: 'Bucket One', path: '/tmp/b1', mode: 'inbox' }],+ localSchemaVersion: 1,+ });+ api.getSettings.mockResolvedValue({});+ api.listShareInbox.mockResolvedValue({ items: [] });+ api.listShareActivity.mockResolvedValue({ manifests: [] });+ });++ // Routes mirror App.jsx so `useParams()` resolves section + bucketId.+ const routes = [+ { path: '/sharing', element: <Sharing /> },+ { path: '/sharing/:section', element: <Sharing /> },+ { path: '/sharing/:section/:bucketId', element: <Sharing /> },+ ];+ const renderAt = (entries, initialIndex = entries.length - 1) => {+ const router = createMemoryRouter(routes, { initialEntries: entries, initialIndex });+ render(<RouterProvider router={router} />);+ return router;+ };++ it('renders the tab named by the URL param on a direct link', async () => {+ renderAt(['/sharing/buckets/b1?tab=activity']);+ await waitFor(() => expect(screen.getByText('Bucket One')).toBeInTheDocument());+ // Activity tab content — not the Inbox empty-state.+ expect(screen.getByText('No share activity yet.')).toBeInTheDocument();+ expect(screen.queryByText('No pending imports.')).not.toBeInTheDocument();+ });++ it('falls back to the Inbox tab for a stale/invalid param', async () => {+ renderAt(['/sharing/buckets/b1?tab=bogus']);+ await waitFor(() => expect(screen.getByText('Bucket One')).toBeInTheDocument());+ expect(screen.getByText('No pending imports.')).toBeInTheDocument();+ expect(screen.queryByText('No share activity yet.')).not.toBeInTheDocument();+ });++ it('follows browser back/forward between tabs', async () => {+ const router = renderAt([+ '/sharing/buckets/b1?tab=inbox',+ '/sharing/buckets/b1?tab=settings',+ ], 1);+ // Start on Settings (last history entry).+ await waitFor(() => expect(screen.getByText('Import mode')).toBeInTheDocument());++ // Back → Inbox tab.+ await act(async () => { await router.navigate(-1); });+ await waitFor(() => expect(screen.getByText('No pending imports.')).toBeInTheDocument());+ expect(screen.queryByText('Import mode')).not.toBeInTheDocument();++ // Forward → Settings tab again.+ await act(async () => { await router.navigate(1); });+ await waitFor(() => expect(screen.getByText('Import mode')).toBeInTheDocument());+ });+});