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: show the YouTube setup check's operator requirement inline (#13097)
Adam Eivyfd30d5ddcf8d
diff --git a/client/src/components/brain/tabs/YoutubeTab.jsx b/client/src/components/brain/tabs/YoutubeTab.jsxindex 3b5f0a10f3..9d25584e05 100644--- a/client/src/components/brain/tabs/YoutubeTab.jsx+++ b/client/src/components/brain/tabs/YoutubeTab.jsx@@ -15,6 +15,8 @@ import {syncYoutubePlaylists,} from '../../../services/api';+const NEEDS_OPERATOR_NOTE = 'Setup check needs an operator session, or a local connection when no password is set.';+// Brain → YouTube (#2153). Opt-in, machine-local ingestion of YouTube watch// history into the activity timeline. OFF by default — the YouTube watch-history// API is gone, so this scrapes the signed-in history page in the managed browser.@@ -55,10 +57,15 @@ export function YoutubeTab() {const handleCheckSetup = async () => {setChecking(true);- const result = await getYoutubeSetupCheck({ silent: true }).catch(() => null);+ // The check drives the signed-in browser, so the server gates it (#13097);+ // a refused caller sees the note inline rather than a toast.+ const result = await getYoutubeSetupCheck({ silent: true, hostControlOptional: true }).catch((err) => (+ err?.code === 'HOST_CONTROL_FORBIDDEN' ? { ok: false, needsOperator: true, error: NEEDS_OPERATOR_NOTE } : null+ ));setChecking(false);setSetup(result);if (result?.ok) toast.success('Signed into YouTube in the managed browser');+ else if (result?.needsOperator) return;else if (result) toast.error(result.error || 'YouTube not ready');else toast.error('Setup check failed');};diff --git a/client/src/components/brain/tabs/YoutubeTab.test.jsx b/client/src/components/brain/tabs/YoutubeTab.test.jsxnew file mode 100644index 0000000000..504b5444d1--- /dev/null+++ b/client/src/components/brain/tabs/YoutubeTab.test.jsx@@ -0,0 +1,48 @@+import { beforeEach, describe, expect, it, vi } from 'vitest';+import { act, fireEvent, render, screen } from '@testing-library/react';++const api = vi.hoisted(() => ({+ getYoutubeStatus: vi.fn(),+ getYoutubeSetupCheck: vi.fn(),+ syncYoutube: vi.fn(),+ getYoutubePlaylists: vi.fn(),+ syncYoutubePlaylists: vi.fn(),+}));+const toast = vi.hoisted(() => Object.assign(vi.fn(), { success: vi.fn(), error: vi.fn() }));+vi.mock('../../../services/api', () => api);+vi.mock('../../ui/Toast', () => ({ default: toast }));+vi.mock('../../../hooks/useSyncSourceSettings', () => ({+ useSyncSourceSettings: () => ({+ loading: false, loadError: null, retry: vi.fn(), enabled: false, setEnabled: vi.fn(), intervalMinutes: 480,+ setIntervalMinutes: vi.fn(), saving: false, status: null, setStatus: vi.fn(), dirty: false, save: vi.fn(),+ }),+}));+vi.mock('../../../hooks', () => ({+ useVideoDownload: () => ({ active: false, percent: 0, stage: null, context: null, start: vi.fn(), cancel: vi.fn() }),+}));++import { YoutubeTab } from './YoutubeTab';++describe('YoutubeTab setup check', () => {+ beforeEach(() => {+ vi.clearAllMocks();+ api.getYoutubePlaylists.mockResolvedValue({ snapshot: null });+ });++ it('shows the needs-operator note with no toast when the gated check is refused', async () => {+ api.getYoutubeSetupCheck.mockRejectedValue(Object.assign(new Error('Host control requires an operator session.'), { code: 'HOST_CONTROL_FORBIDDEN', status: 403 }));+ render(<YoutubeTab />);+ fireEvent.click(screen.getByRole('button', { name: 'Check setup' }));+ expect(await screen.findByText(/Setup check needs an operator session/)).toBeInTheDocument();+ expect(api.getYoutubeSetupCheck).toHaveBeenCalledWith({ silent: true, hostControlOptional: true });+ expect(toast.error).not.toHaveBeenCalled();+ expect(screen.queryByText('Setup check failed')).not.toBeInTheDocument();+ });++ it('still toasts an ordinary setup-check failure', async () => {+ api.getYoutubeSetupCheck.mockRejectedValue(new Error('offline'));+ render(<YoutubeTab />);+ await act(async () => { fireEvent.click(screen.getByRole('button', { name: 'Check setup' })); });+ expect(toast.error).toHaveBeenCalledWith('Setup check failed');+ });+});