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: make Goals Tree toolbar easier to tap (#9713)
Adam Eivy09132b3b39d0
diff --git a/client/src/components/goals/GoalsTreeView.browser.test.js b/client/src/components/goals/GoalsTreeView.browser.test.jsnew file mode 100644index 0000000000..b60957b476--- /dev/null+++ b/client/src/components/goals/GoalsTreeView.browser.test.js@@ -0,0 +1,135 @@+// @vitest-environment node+import { afterAll, beforeAll, describe, expect, it } from 'vitest';+import { existsSync } from 'node:fs';+import { mkdtemp, rm } from 'node:fs/promises';+import { createRequire } from 'node:module';+import { tmpdir } from 'node:os';+import { join } from 'node:path';+import { fileURLToPath } from 'node:url';+import { createServer } from 'vite';+import react from '@vitejs/plugin-react';++const require = createRequire(import.meta.url);+// Prefer the client dev dependency; linked worktrees can also use the same+// pinned driver from the server without installing into shared node_modules.+const { chromium } = require(require.resolve('playwright-core', { paths: [+ fileURLToPath(new URL('../../..', import.meta.url)),+ fileURLToPath(new URL('../../../../server', import.meta.url)),+] }));+const chrome = [process.env.CHROME_PATH, chromium.executablePath(),+ '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',+ '/usr/bin/google-chrome', '/usr/bin/chromium', '/usr/bin/chromium-browser',+].find(path => path && existsSync(path));++// This fixture exercises the real toolbar and Tailwind CSS with synthetic goals.+// Only WebGL is replaced: the canvas stub retains the production sizing props.+describe.skipIf(!chrome)('Goals Tree touch targets', () => {+ let server, browser, browserTemp, origin;+ beforeAll(async () => {+ browserTemp = await mkdtemp(join(tmpdir(), 'goals-touch-'));+ server = await createServer({+ configFile: false,+ cacheDir: join(browserTemp, 'vite-cache'),+ root: fileURLToPath(new URL('../../..', import.meta.url)),+ plugins: [react(), {+ name: 'goals-touch-fixture',+ enforce: 'pre',+ resolveId(id) {+ if (id === '/goals-fixture.jsx') return '\0goals-fixture.jsx';+ if (id === '@react-three/fiber') return '\0canvas-stub';+ if (id.endsWith('/useProviderModels')) return '\0provider-stub';+ },+ load(id) {+ if (id === '\0canvas-stub') return `+ import React from 'react';+ export const Canvas = ({ style }) => React.createElement('div', { 'data-testid': 'canvas', style });+ export const useFrame = () => {};+ export const useThree = () => null;+ export const extend = () => {};+ `;+ if (id === '\0provider-stub') return `+ export default () => ({ providers: [], selectedProviderId: '', selectedModel: '',+ availableModels: [], setSelectedProviderId: () => {}, setSelectedModel: () => {}, loading: false });+ `;+ if (id !== '\0goals-fixture.jsx') return;+ return `+ import React from 'react';+ import { createRoot } from 'react-dom/client';+ import GoalsTreeView from '/src/components/goals/GoalsTreeView.jsx';+ import '/src/index.css';+ const data = { flat: [+ { id: 'example-1', title: 'Example apex', category: 'mastery', horizon: 'lifetime', goalType: 'apex' },+ { id: 'example-2', title: 'Example craft', category: 'creative', horizon: '3-year', parentId: 'example-1' },+ { id: 'example-3', title: 'Example practice', category: 'mastery', horizon: '5-year', parentId: 'example-1' },+ ] };+ createRoot(document.getElementById('root')).render(React.createElement(GoalsTreeView, { data, onRefresh: () => {} }));+ `;+ },+ configureServer(vite) {+ vite.middlewares.use('/goals-test', async (_req, res) => {+ res.setHeader('Content-Type', 'text/html');+ res.end(await vite.transformIndexHtml('/goals-test',+ '<style>html,body,#root{height:100%;margin:0}</style><div id="root"></div><script type="module" src="/goals-fixture.jsx"></script>'));+ });+ },+ }],+ server: { host: '127.0.0.1', port: 0 },+ });+ await server.listen();+ origin = server.resolvedUrls.local[0];+ browser = await chromium.launch({ executablePath: chrome, headless: true,+ env: { ...process.env, TMPDIR: browserTemp, TMP: browserTemp, TEMP: browserTemp } });+ }, 60000);+ afterAll(async () => {+ try { await browser?.close(); }+ finally {+ await server?.close();+ if (browserTemp) await rm(browserTemp, { recursive: true, force: true });+ }+ });++ it.each([[360, 800], [768, 1024], [1440, 900]])('keeps targets usable at %sx%s', async (width, height) => {+ const page = await browser.newPage({ viewport: { width, height } });+ try {+ // No live API or external service is reachable from this fixture.+ await page.route('**/*', route => {+ const url = new URL(route.request().url());+ return url.origin === new URL(origin).origin && !url.pathname.startsWith('/api/')+ ? route.continue() : route.fulfill({ contentType: 'application/json', body: '{}' });+ });+ await page.goto(origin + 'goals-test');+ const names = ['Creative', 'Family', 'Health', 'Financial', 'Legacy', 'Mastery', 'Labels', 'Add', 'Organize'];+ const boxes = [];+ for (const name of names) {+ const button = page.getByRole('button', { name, exact: true });+ await button.waitFor();+ const box = await button.boundingBox();+ expect(box.width).toBeGreaterThanOrEqual(44);+ expect(box.height).toBeGreaterThanOrEqual(44);+ expect(box.x).toBeGreaterThanOrEqual(0);+ expect(box.x + box.width).toBeLessThanOrEqual(width);+ boxes.push(box);+ expect(await button.evaluate(el => {+ const r = el.getBoundingClientRect();+ return [-20, 20].every(offset => el.contains(document.elementFromPoint(r.x + r.width / 2 + offset, r.y + r.height / 2)));+ })).toBe(true);+ }+ for (let i = 0; i < boxes.length; i++) for (let j = i + 1; j < boxes.length; j++) {+ const a = boxes[i], b = boxes[j];+ expect(a.x + a.width <= b.x || b.x + b.width <= a.x || a.y + a.height <= b.y || b.y + b.height <= a.y).toBe(true);+ }+ const canvas = await page.getByTestId('canvas').boundingBox();+ expect(canvas.y).toBeGreaterThanOrEqual(Math.max(...boxes.map(b => b.y + b.height)));+ expect(canvas.height).toBeGreaterThan(height / 2);+ await page.getByRole('button', { name: 'Creative', exact: true }).click();+ await page.waitForFunction(() => document.body.textContent.includes('2 nodes'));+ const labels = page.getByRole('button', { name: 'Labels', exact: true });+ await labels.click();+ expect(await labels.getAttribute('aria-pressed')).toBe('false');+ await page.getByRole('button', { name: 'Add', exact: true }).click();+ const form = await page.getByRole('textbox', { name: 'New goal title' }).boundingBox();+ expect(form.y).toBeGreaterThan(Math.max(...boxes.map(b => b.y + b.height)));+ expect(await page.getByRole('button', { name: 'Organize', exact: true }).isDisabled()).toBe(true);+ } finally { await page.close(); }+ }, 60000);+});diff --git a/client/src/components/goals/GoalsTreeView.jsx b/client/src/components/goals/GoalsTreeView.jsxindex 1c117979e3..310740b454 100644--- a/client/src/components/goals/GoalsTreeView.jsx+++ b/client/src/components/goals/GoalsTreeView.jsx@@ -342,145 +342,148 @@ export default function GoalsTreeView({ data, onRefresh }) {return (<div className="h-full flex relative">- <div className="flex-1 relative">+ <div className="flex-1 min-w-0 min-h-0 relative flex flex-col">{/* Filter bar */}- <div className="absolute top-2 sm:top-3 left-2 sm:left-3 right-2 sm:right-3 z-10 flex items-center gap-1.5 sm:gap-2 flex-wrap">- <div className="relative">- <Search className="absolute left-2 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-gray-500" />- <input- type="text"- value={searchQuery}- onChange={e => setSearchQuery(e.target.value)}- placeholder="Search..."- aria-label="Search goals"- className="bg-port-card/90 backdrop-blur border border-port-border rounded-lg pl-7 pr-3 py-1.5 text-sm text-white w-32 sm:w-48"- />- </div>- {Object.entries(CATEGORY_CONFIG).map(([key, cfg]) => {- const Icon = cfg.icon;- return (- <button- key={key}- onClick={() => toggleCategory(key)}- className={`flex items-center gap-1 px-1.5 sm:px-2 py-1 rounded-lg text-xs font-medium border transition-colors ${- categoryFilters[key]- ? `${cfg.bg} ${cfg.color} border-transparent`- : 'bg-port-card/60 text-gray-600 border-port-border'- }`}- title={cfg.label}- >- <Icon className="w-3 h-3" />- <span className="max-sm:sr-only">{cfg.label}</span>- </button>- );- })}- <button- onClick={() => setShowLabels(v => !v)}- aria-pressed={showLabels}- aria-label="Labels"- title={showLabels ? 'Hide goal names' : 'Show goal names'}- className={`flex items-center gap-1 px-1.5 sm:px-2 py-1 rounded-lg text-xs font-medium border transition-colors ${- showLabels- ? 'bg-port-accent/20 text-port-accent border-transparent'- : 'bg-port-card/60 text-gray-600 border-port-border'- }`}- >- <Type className="w-3 h-3" />- <span className="hidden sm:inline">Labels</span>- </button>- <button- onClick={() => setShowNewGoal(!showNewGoal)}- className="flex items-center gap-1 px-2 py-1 rounded-lg text-xs font-medium bg-port-accent text-white"- >- <Plus className="w-3 h-3" />- Add- </button>- {(data?.flat?.length ?? 0) >= 2 && (- <div className="flex items-center gap-2">- <div className="hidden sm:block">- <ProviderModelSelector- providers={providers}- selectedProviderId={selectedProviderId}- selectedModel={selectedModel}- availableModels={availableModels}- onProviderChange={setSelectedProviderId}- onModelChange={setSelectedModel}- label="AI Provider"- disabled={organizing || providersLoading}- compact- />- </div>- <button- onClick={handleOrganize}- disabled={organizing || !selectedProviderId}- className="flex items-center gap-1 px-2 py-1 rounded-lg text-xs font-medium bg-amber-500/20 text-amber-400 hover:bg-amber-500/30 disabled:opacity-50"- title="Use AI to organize goals into a hierarchy with an apex north-star goal"- >- <Wand2 className={`w-3 h-3 ${organizing ? 'animate-spin' : ''}`} />- {organizing ? 'Analyzing...' : 'Organize'}- </button>+ <div className="relative z-10 shrink-0 m-2 sm:m-3">+ <div className="flex items-center gap-1.5 sm:gap-2 flex-wrap">+ <div className="relative">+ <Search className="absolute left-2 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-gray-500" />+ <input+ type="text"+ value={searchQuery}+ onChange={e => setSearchQuery(e.target.value)}+ placeholder="Search..."+ aria-label="Search goals"+ className="bg-port-card/90 backdrop-blur border border-port-border rounded-lg pl-7 pr-3 py-1.5 text-sm text-white w-32 sm:w-48"+ /></div>- )}- </div>+ {Object.entries(CATEGORY_CONFIG).map(([key, cfg]) => {+ const Icon = cfg.icon;+ return (+ <button+ key={key}+ onClick={() => toggleCategory(key)}+ className={`flex items-center justify-center shrink-0 min-w-11 min-h-11 gap-1 px-1.5 sm:px-2 py-1 rounded-lg text-xs font-medium border transition-colors ${+ categoryFilters[key]+ ? `${cfg.bg} ${cfg.color} border-transparent`+ : 'bg-port-card/60 text-gray-600 border-port-border'+ }`}+ title={cfg.label}+ >+ <Icon className="w-3 h-3" />+ <span className="max-sm:sr-only">{cfg.label}</span>+ </button>+ );+ })}+ <button+ onClick={() => setShowLabels(v => !v)}+ aria-pressed={showLabels}+ aria-label="Labels"+ title={showLabels ? 'Hide goal names' : 'Show goal names'}+ className={`flex items-center justify-center shrink-0 min-w-11 min-h-11 gap-1 px-1.5 sm:px-2 py-1 rounded-lg text-xs font-medium border transition-colors ${+ showLabels+ ? 'bg-port-accent/20 text-port-accent border-transparent'+ : 'bg-port-card/60 text-gray-600 border-port-border'+ }`}+ >+ <Type className="w-3 h-3" />+ <span className="hidden sm:inline">Labels</span>+ </button>+ <button+ onClick={() => setShowNewGoal(!showNewGoal)}+ className="flex items-center justify-center shrink-0 min-w-11 min-h-11 gap-1 px-2 py-1 rounded-lg text-xs font-medium bg-port-accent text-white"+ >+ <Plus className="w-3 h-3" />+ Add+ </button>+ {(data?.flat?.length ?? 0) >= 2 && (+ <div className="flex min-w-0 max-w-full flex-wrap items-center gap-2">+ <div className="hidden sm:block min-w-0">+ <ProviderModelSelector+ providers={providers}+ selectedProviderId={selectedProviderId}+ selectedModel={selectedModel}+ availableModels={availableModels}+ onProviderChange={setSelectedProviderId}+ onModelChange={setSelectedModel}+ label="AI Provider"+ disabled={organizing || providersLoading}+ compact+ />+ </div>+ <button+ onClick={handleOrganize}+ disabled={organizing || !selectedProviderId}+ className="flex items-center justify-center shrink-0 min-w-11 min-h-11 gap-1 px-2 py-1 rounded-lg text-xs font-medium bg-amber-500/20 text-amber-400 hover:bg-amber-500/30 disabled:opacity-50"+ title="Use AI to organize goals into a hierarchy with an apex north-star goal"+ >+ <Wand2 className={`w-3 h-3 ${organizing ? 'animate-spin' : ''}`} />+ {organizing ? 'Analyzing...' : 'Organize'}+ </button>+ </div>+ )}+ </div>- {/* New goal form */}- {showNewGoal && (- <div className="absolute top-12 left-3 z-10 bg-port-card border border-port-border rounded-lg p-3 w-72 max-w-[calc(100vw-1rem)] space-y-2 shadow-lg">- <input- type="text"- value={newGoal.title}- onChange={e => setNewGoal({ ...newGoal, title: e.target.value })}- placeholder="Goal title..."- aria-label="New goal title"- className="w-full bg-port-bg border border-port-border rounded px-2 py-1.5 text-sm text-white"- onKeyDown={e => e.key === 'Enter' && handleCreateGoal()}- disabled={isCreating}- />- <textarea- value={newGoal.description}- onChange={e => setNewGoal({ ...newGoal, description: e.target.value })}- placeholder="Description..."- aria-label="New goal description"- rows={2}- className="w-full bg-port-bg border border-port-border rounded px-2 py-1.5 text-sm text-white resize-none"- disabled={isCreating}- />- <div className="flex gap-2">- <select- value={newGoal.horizon}- onChange={e => setNewGoal({ ...newGoal, horizon: e.target.value })}- aria-label="New goal horizon"- className="flex-1 bg-port-bg border border-port-border rounded px-2 py-1 text-sm text-white"+ {/* New goal form */}+ {showNewGoal && (+ <div className="absolute top-full mt-2 left-0 z-10 bg-port-card border border-port-border rounded-lg p-3 w-72 max-w-[calc(100vw-1rem)] space-y-2 shadow-lg">+ <input+ type="text"+ value={newGoal.title}+ onChange={e => setNewGoal({ ...newGoal, title: e.target.value })}+ placeholder="Goal title..."+ aria-label="New goal title"+ className="w-full bg-port-bg border border-port-border rounded px-2 py-1.5 text-sm text-white"+ onKeyDown={e => e.key === 'Enter' && handleCreateGoal()}disabled={isCreating}- >- {HORIZON_OPTIONS.map(h => <option key={h.value} value={h.value}>{h.label}</option>)}- </select>- <select- value={newGoal.category}- onChange={e => setNewGoal({ ...newGoal, category: e.target.value })}- aria-label="New goal category"- className="flex-1 bg-port-bg border border-port-border rounded px-2 py-1 text-sm text-white"+ />+ <textarea+ value={newGoal.description}+ onChange={e => setNewGoal({ ...newGoal, description: e.target.value })}+ placeholder="Description..."+ aria-label="New goal description"+ rows={2}+ className="w-full bg-port-bg border border-port-border rounded px-2 py-1.5 text-sm text-white resize-none"disabled={isCreating}- >- {Object.entries(CATEGORY_CONFIG).map(([k, v]) => (- <option key={k} value={k}>{v.label}</option>- ))}- </select>- </div>- <div className="flex gap-2">- <button- onClick={handleCreateGoal}- disabled={!newGoal.title.trim() || isCreating}- className="px-3 py-1 text-sm rounded bg-port-accent text-white disabled:opacity-50"- >- Create- </button>- <button onClick={() => setShowNewGoal(false)} className="px-3 py-1 text-sm rounded bg-port-border text-gray-300">- Cancel- </button>+ />+ <div className="flex gap-2">+ <select+ value={newGoal.horizon}+ onChange={e => setNewGoal({ ...newGoal, horizon: e.target.value })}+ aria-label="New goal horizon"+ className="flex-1 bg-port-bg border border-port-border rounded px-2 py-1 text-sm text-white"+ disabled={isCreating}+ >+ {HORIZON_OPTIONS.map(h => <option key={h.value} value={h.value}>{h.label}</option>)}+ </select>+ <select+ value={newGoal.category}+ onChange={e => setNewGoal({ ...newGoal, category: e.target.value })}+ aria-label="New goal category"+ className="flex-1 bg-port-bg border border-port-border rounded px-2 py-1 text-sm text-white"+ disabled={isCreating}+ >+ {Object.entries(CATEGORY_CONFIG).map(([k, v]) => (+ <option key={k} value={k}>{v.label}</option>+ ))}+ </select>+ </div>+ <div className="flex gap-2">+ <button+ onClick={handleCreateGoal}+ disabled={!newGoal.title.trim() || isCreating}+ className="px-3 py-1 text-sm rounded bg-port-accent text-white disabled:opacity-50"+ >+ Create+ </button>+ <button onClick={() => setShowNewGoal(false)} className="px-3 py-1 text-sm rounded bg-port-border text-gray-300">+ Cancel+ </button>+ </div></div>- </div>- )}+ )}++ </div>{/* Organization panel */}<OrganizePanel@@ -539,7 +542,7 @@ export default function GoalsTreeView({ data, onRefresh }) {camera={{ position: [0, 15, 40], fov: 60 }}onPointerDown={(e) => { dragStartRef.current = { x: e.clientX, y: e.clientY }; }}onPointerMissed={handlePointerMissed}- style={{ background: 'rgb(var(--port-bg))' }}+ style={{ background: 'rgb(var(--port-bg))', flex: 1, minHeight: 0 }}><GoalScenegraph={graph}diff --git a/client/src/components/goals/GoalsTreeView.test.jsx b/client/src/components/goals/GoalsTreeView.test.jsxindex 329d037afd..35f532f9cb 100644--- a/client/src/components/goals/GoalsTreeView.test.jsx+++ b/client/src/components/goals/GoalsTreeView.test.jsx@@ -126,6 +126,15 @@ describe('labels toggle', () => {});});+it('opens and dismisses the create form without creating a goal', async () => {+ const user = userEvent.setup();+ await renderTree();+ await user.click(screen.getByRole('button', { name: 'Add' }));+ expect(screen.getByRole('textbox', { name: 'New goal title' })).toBeVisible();+ await user.click(screen.getByRole('button', { name: 'Cancel' }));+ expect(screen.queryByRole('textbox', { name: 'New goal title' })).not.toBeInTheDocument();+});+describe('empty state', () => {it('skips the canvas when there is nothing to lay out', async () => {await renderTree({ flat: [] });@@ -150,6 +159,20 @@ describe('handleOrganize error toasting', () => {Object.assign(providerState, { providers: [], selectedProviderId: '', selectedModel: '', availableModels: [] });});+ it('disables organization while a request is pending', async () => {+ const user = userEvent.setup();+ let finish;+ organizeGoals.mockImplementation(() => new Promise(resolve => { finish = resolve; }));+ await renderTree();+ await user.click(screen.getByRole('button', { name: /organize/i }));+ const pending = screen.getByRole('button', { name: /analyzing/i });+ expect(pending).toBeDisabled();+ await user.click(pending);+ expect(organizeGoals).toHaveBeenCalledTimes(1);+ await act(async () => { finish(null); });+ expect(screen.getByRole('button', { name: /organize/i })).toBeEnabled();+ });+it('asks the API helper to stay silent and toasts the failure exactly once', async () => {const user = userEvent.setup();organizeGoals.mockRejectedValue(new Error('Organization failed'));