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: deep-link Tribe tabs and pair form labels (#2522)
Adam Eivye24423762a9d
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex cafbaf7230..bacbd975ba 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -12,3 +12,4 @@- **[issue-2510] MidiPianoRoll: clear the stale hover overlay when the transcription data changes.** The piano-roll kept its hovered note/chord identity (objects from the previous parse) when the `data`/`chords` props swapped on a mounted instance, so a re-transcription or Retry while a hover was active and the pointer sat still would keep stroking the old note at coordinates mapped into the new file until the next pointer move or Escape. A `useEffect` now drops the hover identity whenever `data`/`chords` change.- **[issue-2513] Block loopback/metadata hosts in Layered Intelligence custom `http` sources.** `fetchHttpSource` used a bare `fetch` with only an `http(s)` scheme check, so a hand-edited config could point a custom source at `127.0.0.1`, `169.254.169.254`, or `metadata.google.internal` and exfiltrate up to 8KB into the reasoner prompt. It now routes through the shared SSRF-guarded `fetchPublicText` (default posture): loopback, link-local, and cloud-metadata hosts are blocked and redirects are revalidated, while LAN/Tailscale hosts stay intentionally allowed for this single-user tool.- **[issue-2516] Database sync: remove shell interpolation from the dump import.** The active→inactive backend sync built a `bash -c "sed … \"${dumpFile}\" | psql … -U ${pgUser} -d ${pgDb}"` string that interpolated the dump path, port, user, and database name into a shell command — any shell metacharacter in those values (env-derived or surfacing from the export pipeline) was injectable into `psql`. The import now streams the dump through `spawn('psql', argv)` with no shell: the dump is read and piped to psql's stdin, and the pg17-only directives (`\restrict`/`\unrestrict`/`SET transaction_timeout`) the old `sed` stage stripped are filtered in-process. No user- or env-derived value ever reaches a shell string.+- **[issue-2522] Deep-link Tribe tabs and fix form label associations.** The Tribe page's active section (Circle / Map / Care Queue / Focus) lived in local `useState`, so a section couldn't be shared, bookmarked, or survive a reload. It now reads from a `?tab=` URL search param (default `circle` omitted for a clean `/tribe`) with a valid-tab fallback for stale/unknown values — matching the PromptManager convention. Separately, the `StylePresetPicker` style-preset `<label>` and the Loops "Interval" `<label>` had no `htmlFor`/`id` pairing; both now associate with their control via a `useId()`-generated id so click-to-focus and screen readers work.diff --git a/client/src/components/media/StylePresetPicker.jsx b/client/src/components/media/StylePresetPicker.jsxindex 110aeca13d..0fda42edaf 100644--- a/client/src/components/media/StylePresetPicker.jsx+++ b/client/src/components/media/StylePresetPicker.jsx@@ -1,4 +1,4 @@-import { useEffect, useMemo, useState } from 'react';+import { useEffect, useId, useMemo, useState } from 'react';import { Palette, X } from 'lucide-react';import { listImageStylePresets } from '../../services/apiSystem';@@ -10,6 +10,8 @@ export default function StylePresetPicker({label = 'Style preset',}) {const [presets, setPresets] = useState([]);+ // Unique per instance so multiple pickers on one page each pair label→select.+ const selectId = useId();useEffect(() => {let cancelled = false;@@ -45,7 +47,7 @@ export default function StylePresetPicker({return (<div className={className}><div className="flex items-center justify-between mb-1">- <label className="text-xs font-medium text-gray-400 flex items-center gap-1">+ <label htmlFor={selectId} className="text-xs font-medium text-gray-400 flex items-center gap-1"><Palette className="w-3 h-3" /> {label}</label>{value && (@@ -61,6 +63,7 @@ export default function StylePresetPicker({)}</div><select+ id={selectId}value={value || ''}onChange={handleChange}disabled={disabled || presets.length === 0}diff --git a/client/src/pages/Loops.jsx b/client/src/pages/Loops.jsxindex b24f26a365..1f692ae3a3 100644--- a/client/src/pages/Loops.jsx+++ b/client/src/pages/Loops.jsx@@ -1,4 +1,4 @@-import { useState, useEffect, useRef, useCallback } from 'react';+import { useState, useEffect, useRef, useCallback, useId } from 'react';import {RefreshCw, Play, Square, Trash2, Plus, Clock, Zap, ChevronDown, ChevronRight,Bot, AlertCircle, CheckCircle, Loader2@@ -49,6 +49,9 @@ function CreateLoopForm({ providers, onCreated }) {const [cwd, setCwd] = useState('');const [creating, setCreating] = useState(false);const [expanded, setExpanded] = useState(false);+ // Pairs the "Interval" label with the custom-interval input for click-to-focus+ // and screen-reader association (the preset buttons carry their own names).+ const customIntervalId = useId();const handleSubmit = async (e) => {e.preventDefault();@@ -90,7 +93,7 @@ function CreateLoopForm({ providers, onCreated }) {<div className="flex flex-wrap gap-3 items-end"><div>- <label className="block text-xs text-gray-400 mb-1">Interval</label>+ <label htmlFor={customIntervalId} className="block text-xs text-gray-400 mb-1">Interval</label><div className="flex gap-1">{INTERVAL_PRESETS.map(p => (<button@@ -107,6 +110,7 @@ function CreateLoopForm({ providers, onCreated }) {</button>))}<input+ id={customIntervalId}type="text"value={customInterval}onChange={e => setCustomInterval(e.target.value)}diff --git a/client/src/pages/Tribe.jsx b/client/src/pages/Tribe.jsxindex 23e7ae1899..c948adb090 100644--- a/client/src/pages/Tribe.jsx+++ b/client/src/pages/Tribe.jsx@@ -1,4 +1,5 @@import { useEffect, useMemo, useRef, useState } from 'react';+import { useSearchParams } from 'react-router-dom';import {Calendar,Clock,@@ -43,6 +44,9 @@ const TABS = [{ id: 'focus', label: 'Focus', icon: Heart },];+const TAB_IDS = TABS.map((tab) => tab.id);+const DEFAULT_TAB = 'circle';+const emptyDraft = () => ({id: null,name: '',@@ -648,7 +652,19 @@ export default function Tribe() {const [draft, setDraft] = useState(emptyDraft);const [query, setQuery] = useState('');const [ringFilter, setRingFilter] = useState('all');- const [activeTab, setActiveTab] = useState('circle');+ // Active tab lives in the URL (`?tab=`) so a section is shareable, bookmarkable,+ // and reload-safe. Unknown/stale values fall back to the default tab. The+ // default is omitted from the URL to keep `/tribe` clean.+ const [searchParams, setSearchParams] = useSearchParams();+ const rawTab = searchParams.get('tab');+ const activeTab = TAB_IDS.includes(rawTab) ? rawTab : DEFAULT_TAB;+ const setActiveTab = (next) => {+ const resolved = typeof next === 'function' ? next(activeTab) : next;+ const params = new URLSearchParams(searchParams);+ if (resolved === DEFAULT_TAB) params.delete('tab');+ else params.set('tab', resolved);+ setSearchParams(params, { replace: true });+ };const [loading, setLoading] = useState(true);const [saving, setSaving] = useState(false);// Bumped by every "Add / new relationship" trigger so the form can bediff --git a/client/src/pages/Tribe.test.jsx b/client/src/pages/Tribe.test.jsxnew file mode 100644index 0000000000..8934f2983f--- /dev/null+++ b/client/src/pages/Tribe.test.jsx@@ -0,0 +1,66 @@+import { describe, it, expect, vi, beforeEach } from 'vitest';+import { render, screen, waitFor, fireEvent } from '@testing-library/react';+import { MemoryRouter, useLocation } from 'react-router-dom';++vi.mock('../services/api', () => ({+ getTribePeople: vi.fn(() => Promise.resolve({ people: [] })),+}));++vi.mock('../services/socket', () => ({+ default: { on: vi.fn(), off: vi.fn(), emit: vi.fn() },+}));++import Tribe from './Tribe';+import * as api from '../services/api';++// Surfaces the current URL (path + search) so tests can assert deep-link state.+function LocationProbe() {+ const location = useLocation();+ return <div data-testid="location">{location.pathname + location.search}</div>;+}++const renderAt = (entry) =>+ render(+ <MemoryRouter initialEntries={[entry]}>+ <Tribe />+ <LocationProbe />+ </MemoryRouter>+ );++describe('Tribe deep-linkable tabs', () => {+ beforeEach(() => {+ api.getTribePeople.mockClear();+ // localStorage is used for the legacy-import path; keep it empty.+ window.localStorage.clear();+ });++ it('opens the tab named in the URL (?tab=focus)', async () => {+ renderAt('/tribe?tab=focus');+ // FocusPanel is the only tab that renders the "Energy Mix" panel.+ expect(await screen.findByText('Energy Mix')).toBeTruthy();+ });++ it('falls back to the default Circle tab for an unknown tab value', async () => {+ renderAt('/tribe?tab=bogus');+ // The Circle tab owns the "Search relationships" filter input.+ expect(await screen.findByPlaceholderText('Search relationships')).toBeTruthy();+ });++ it('writes the active tab to the URL when a tab is selected', async () => {+ renderAt('/tribe');+ await screen.findByPlaceholderText('Search relationships');+ fireEvent.click(screen.getByRole('tab', { name: /Focus/i }));+ await waitFor(() =>+ expect(screen.getByTestId('location').textContent).toBe('/tribe?tab=focus')+ );+ });++ it('omits the default tab from the URL when returning to Circle', async () => {+ renderAt('/tribe?tab=focus');+ await screen.findByText('Energy Mix');+ fireEvent.click(screen.getByRole('tab', { name: /Circle/i }));+ await waitFor(() =>+ expect(screen.getByTestId('location').textContent).toBe('/tribe')+ );+ });+});