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: address antigravity review findings on the subject switcher and API scope
[._.]/ Adam Eivy86be1d72978d
diff --git a/client/src/components/privacy/SubjectSwitcher.jsx b/client/src/components/privacy/SubjectSwitcher.jsxindex 7971e1e5c2..99224a69bc 100644--- a/client/src/components/privacy/SubjectSwitcher.jsx+++ b/client/src/components/privacy/SubjectSwitcher.jsx@@ -1,5 +1,5 @@import { Users, Settings2 } from 'lucide-react';-import { SUBJECT_RELATIONSHIPS, labelFor } from './constants';+import { SELF_SUBJECT_ID, SUBJECT_RELATIONSHIPS, labelFor } from './constants';// Whose PII is on screen (#3658). The API scopes each read to ONE subject, so// this switcher IS the Privacy Center's subject filter, not a per-tab control.@@ -9,7 +9,12 @@ import { SUBJECT_RELATIONSHIPS, labelFor } from './constants';// being ambiguous.export default function SubjectSwitcher({ subjects, subjectId, onChange, onManage }) {const active = subjects.find((s) => s.id === subjectId);- const isSelf = !active || active.isSelf;+ // Derive "is this me?" from the id, NOT from the resolved row. The tabs fetch+ // on `subjectId` immediately, so deciding from `active` would leave the bar+ // styled as self — with no warning — for the whole window before the subject+ // list arrives, while someone else's PII is already on screen. An id we can't+ // resolve (stale `?subject=` deep link) is likewise not self.+ const isSelf = subjectId === SELF_SUBJECT_ID;return (<div className={`flex flex-wrap items-center gap-2 px-3 py-2 rounded-lg border ${@@ -39,7 +44,7 @@ export default function SubjectSwitcher({ subjects, subjectId, onChange, onManag{!isSelf && (<span className="text-[11px] text-port-warning">- Viewing {active.displayName}’s records — not your own+ Viewing {active ? `${active.displayName}’s` : 'another household member’s'} records — not your own</span>)}diff --git a/client/src/components/privacy/SubjectsDrawer.jsx b/client/src/components/privacy/SubjectsDrawer.jsxindex b8d56c3666..799c10d78e 100644--- a/client/src/components/privacy/SubjectsDrawer.jsx+++ b/client/src/components/privacy/SubjectsDrawer.jsx@@ -37,10 +37,18 @@ function ConsentTrail({ subjectId }) {.catch(() => setConsents('error'));}, [open, consents, subjectId]);+ // Collapsing clears a failed read so re-expanding retries. Without this the+ // 'error' value is never null again, the fetch effect early-returns forever,+ // and the row is stuck on the failure message for the drawer's lifetime.+ const toggle = () => setOpen((o) => {+ if (o && consents === 'error') setConsents(null);+ return !o;+ });+return (<div className="mt-2"><button- onClick={() => setOpen((o) => !o)}+ onClick={toggle}className="inline-flex items-center gap-1 text-[11px] text-gray-500 hover:text-gray-300">{open ? <ChevronDown size={12} /> : <ChevronRight size={12} />} Consent recorddiff --git a/client/src/components/privacy/SubjectsDrawer.test.jsx b/client/src/components/privacy/SubjectsDrawer.test.jsxindex c756aabdaa..f0749bcdc1 100644--- a/client/src/components/privacy/SubjectsDrawer.test.jsx+++ b/client/src/components/privacy/SubjectsDrawer.test.jsx@@ -75,6 +75,24 @@ describe('SubjectsDrawer', () => {await waitFor(() => expect(screen.getByText(/scans and opt-outs are refused/i)).toBeInTheDocument());});+ it('retries a failed consent read when the row is collapsed and reopened', async () => {+ getPrivacySubjectConsents.mockRejectedValueOnce(new Error('network'));+ renderDrawer();+ const trigger = screen.getAllByRole('button', { name: /Consent record/i })[1];++ fireEvent.click(trigger);+ await waitFor(() => expect(screen.getByText(/Couldn’t load the consent record/i)).toBeInTheDocument());++ // Collapse + reopen must re-fetch, not stay stuck on the failure forever.+ getPrivacySubjectConsents.mockResolvedValueOnce([+ { id: 'c-1', subjectId: 'sub-2', scope: 'pii_vault', method: 'verbal', note: '', grantedAt: null },+ ]);+ fireEvent.click(trigger);+ fireEvent.click(trigger);+ await waitFor(() => expect(screen.getByText(/Verbal/)).toBeInTheDocument());+ expect(getPrivacySubjectConsents).toHaveBeenCalledTimes(2);+ });+it('warns that deleting a member cascades their records', async () => {deletePrivacySubject.mockResolvedValue({ ok: true });const onDeleted = vi.fn();diff --git a/client/src/pages/Privacy.test.jsx b/client/src/pages/Privacy.test.jsxindex f20797cdc6..3852647d45 100644--- a/client/src/pages/Privacy.test.jsx+++ b/client/src/pages/Privacy.test.jsx@@ -1,5 +1,5 @@import { describe, it, expect, vi, beforeEach } from 'vitest';-import { render, screen, waitFor, fireEvent } from '@testing-library/react';+import { render, screen, waitFor, fireEvent, act } from '@testing-library/react';import { MemoryRouter, Routes, Route } from 'react-router';// ── Mock the API surface ─────────────────────────────────────────────────────@@ -74,7 +74,9 @@ vi.mock('../services/api', () => ({}));import Privacy from './Privacy';-import { revealVaultRecord, getVaultRecords, getPrivacyStatus } from '../services/api';+import {+ revealVaultRecord, getVaultRecords, getPrivacyStatus, getPrivacySubjects,+} from '../services/api';const SELF_ID = '00000000-0000-4000-8000-000000000001';@@ -176,6 +178,23 @@ describe('Privacy Center', () => {expect(screen.getByLabelText('Subject')).toHaveValue('sub-2');});+ it('flags a non-self scope immediately, before the subject list resolves', async () => {+ // The tabs fetch on subjectId right away, so a bar that waits for the+ // subject list to decide "is this me?" shows someone else's PII under+ // self styling for the whole load window.+ let resolveSubjects;+ getPrivacySubjects.mockReturnValueOnce(new Promise((r) => { resolveSubjects = r; }));+ renderAt('/privacy/vault?subject=sub-2');+ await waitFor(() => expect(screen.getByText(/not your own/i)).toBeInTheDocument());+ // Settle the deferred fetch inside act so the late state update lands here.+ await act(async () => { resolveSubjects([]); });+ });++ it('flags an unresolvable subject rather than treating it as self', async () => {+ renderAt('/privacy/vault?subject=deleted-subject');+ await waitFor(() => expect(screen.getByText(/not your own/i)).toBeInTheDocument());+ });+it('keeps a stale ?subject deep link labeled rather than blank', async () => {renderAt('/privacy/vault?subject=deleted-subject');const select = await screen.findByLabelText('Subject');diff --git a/client/src/services/apiPrivacy.js b/client/src/services/apiPrivacy.jsindex d57ac7ad62..288be769b9 100644--- a/client/src/services/apiPrivacy.js+++ b/client/src/services/apiPrivacy.js@@ -12,8 +12,12 @@ import { request } from './apiCore.js';// `self` subject, so omitting it reproduces the single-subject v1 behavior// exactly. There is no "all subjects" mode — the API scopes to exactly one.const scoped = (path, { subjectId, ...rest } = {}, params = {}) => {+ // Only override when the caller actually passed one — a bare `subjectId` key+ // here would clobber a `params.subjectId` with `undefined`, silently+ // re-scoping `getPrivacyOrgs({ subjectId })` back to `self`.const qs = new URLSearchParams(- Object.entries({ ...params, subjectId }).filter(([, v]) => v != null && v !== ''),+ Object.entries({ ...params, ...(subjectId === undefined ? {} : { subjectId }) })+ .filter(([, v]) => v != null && v !== ''),).toString();return [qs ? `${path}?${qs}` : path, rest];};