diff --git a/apps/web/src/components/os/apps/LauncherApp.test.tsx b/apps/web/src/components/os/apps/LauncherApp.test.tsx index b48c9d9..343d3bb 100644 --- a/apps/web/src/components/os/apps/LauncherApp.test.tsx +++ b/apps/web/src/components/os/apps/LauncherApp.test.tsx @@ -1,16 +1,9 @@ /** - * Warm-Hive PR6b (B1) — LauncherApp A/B segmented toggle. + * LauncherApp — detect, launch, watch and stop external AI tools. * - * Variation A · Launch = the existing live detect/launch UI (preserved). - * Variation B · How memory is shared = a pure-UI explainer (flow diagram + - * three cards + an explicitly-labelled provenance example, no live data). - * - * These tests assert the toggle wiring and that Variation B carries the - * static explainer content WITHOUT fabricating a live recall. - * - * Agent hooks, the explainer and Waggle Room tasks are hidden in v1 by the - * memory feature map (ADR-0002). Most suites switch them on to keep the hidden - * code covered; the "v1 memory features" suite checks the default. + * Waggle Room tasks are hidden in v1 by the memory feature map (ADR-0002). + * Most suites switch them on to keep the hidden code covered; the "v1 memory + * features" suite checks the default. */ import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; import { render, screen, waitFor, cleanup, fireEvent, within } from '@testing-library/react'; @@ -20,7 +13,6 @@ const mocks = vi.hoisted(() => ({ detectTools: vi.fn(), getToolProcesses: vi.fn(), launchTool: vi.fn(), - manageHooks: vi.fn(), killTool: vi.fn(), runExternalToolTask: vi.fn(), streamToolOutput: vi.fn(() => () => {}), @@ -43,8 +35,6 @@ const detectionResp = { installed: true, installedPath: '/opt/homebrew/bin/claude', version: '2.4.0', - hooksInstalled: true, - hookPointerPath: '/home/.claude/hooks', }, ], }; @@ -55,7 +45,6 @@ beforeEach(() => { mocks.adapter.detectTools.mockResolvedValue(detectionResp); mocks.adapter.getToolProcesses.mockResolvedValue({ processes: [] }); mocks.adapter.launchTool.mockResolvedValue({ ok: true, pid: 123 }); - mocks.adapter.manageHooks.mockResolvedValue({ ok: true }); mocks.adapter.killTool.mockResolvedValue({ ok: true, pid: 123, reason: 'SIGTERM' }); mocks.adapter.runExternalToolTask.mockResolvedValue({ roomId: 'room-1', @@ -67,7 +56,7 @@ afterEach(() => { vi.clearAllMocks(); }); -describe('LauncherApp · A/B toggle', () => { +describe('LauncherApp · detection', () => { it('repaints detected tools on return and refreshes silently', async () => { const first = render(); expect(await screen.findByText('Claude Code')).toBeInTheDocument(); @@ -79,54 +68,11 @@ describe('LauncherApp · A/B toggle', () => { await waitFor(() => expect(mocks.adapter.detectTools.mock.calls.length).toBeGreaterThan(baseline)); }); - it('defaults to Variation A and renders the live launch UI', async () => { + it('renders the live launch UI', async () => { render(); - // The detected tool from the live adapter appears (Variation A). expect(await screen.findByText('Claude Code')).toBeInTheDocument(); expect(screen.getByText(/optional prompt/i)).toBeInTheDocument(); - // Toggle exists with both tabs, A selected. - const launchTab = screen.getByRole('tab', { name: /^launch$/i }); - const memTab = screen.getByRole('tab', { name: /how memory is shared/i }); - expect(launchTab).toHaveAttribute('aria-selected', 'true'); - expect(memTab).toHaveAttribute('aria-selected', 'false'); - }); - - it('switches to Variation B and renders the explainer (flow + cards), hiding the live UI', async () => { - render(); - await screen.findByText('Claude Code'); - fireEvent.click(screen.getByRole('tab', { name: /how memory is shared/i })); - - expect(screen.getByRole('tab', { name: /how memory is shared/i })).toHaveAttribute('aria-selected', 'true'); - // Explainer heading + flow nodes. - expect(screen.getByText(/how a launched agent shares the hive/i)).toBeInTheDocument(); - expect(screen.getByText('The hive')).toBeInTheDocument(); - expect(screen.getByText('hive-mind')).toBeInTheDocument(); - // Three explainer cards. - expect(screen.getByText(/it recalls on start/i)).toBeInTheDocument(); - expect(screen.getByText(/it commits as it works/i)).toBeInTheDocument(); - expect(screen.getByText(/reversible & local/i)).toBeInTheDocument(); - // The live launch UI (prompt box) is no longer mounted. - expect(screen.queryByText(/optional prompt/i)).not.toBeInTheDocument(); - }); - - it('labels the provenance example as an example (no fabricated live recall)', async () => { - render(); - await screen.findByText('Claude Code'); - fireEvent.click(screen.getByRole('tab', { name: /how memory is shared/i })); - const prov = screen.getByText(/remembered from Claude Code/i); - expect(prov).toHaveTextContent(/^example ·/i); - }); - - it('toggles back to Variation A and restores the live UI', async () => { - render(); - await screen.findByText('Claude Code'); - fireEvent.click(screen.getByRole('tab', { name: /how memory is shared/i })); - expect(screen.queryByText(/optional prompt/i)).not.toBeInTheDocument(); - - fireEvent.click(screen.getByRole('tab', { name: /^launch$/i })); - expect(screen.getByRole('tab', { name: /^launch$/i })).toHaveAttribute('aria-selected', 'true'); - await waitFor(() => expect(screen.getByText(/optional prompt/i)).toBeInTheDocument()); - expect(screen.getByText('Claude Code')).toBeInTheDocument(); + expect(screen.getByRole('button', { name: /^launch$/i })).toBeInTheDocument(); }); }); @@ -158,8 +104,6 @@ describe('LauncherApp · captured tasks', () => { installed: true, installedPath: '/usr/local/bin/codex', version: '0.144.1', - hooksInstalled: true, - hookPointerPath: '/home/.codex/hooks', capabilities: { interactiveLaunch: true, headlessTask: true, @@ -175,8 +119,6 @@ describe('LauncherApp · captured tasks', () => { installed: true, installedPath: '/usr/local/bin/hermes', version: '1.0.0', - hooksInstalled: true, - hookPointerPath: '/home/.hermes/hooks', capabilities: { interactiveLaunch: true, headlessTask: true, @@ -192,8 +134,6 @@ describe('LauncherApp · captured tasks', () => { installed: true, installedPath: '/Applications/Cursor.app', version: '1.0.0', - hooksInstalled: true, - hookPointerPath: '/home/.cursor/hooks', capabilities: { interactiveLaunch: true, headlessTask: false, @@ -209,8 +149,6 @@ describe('LauncherApp · captured tasks', () => { installed: false, installedPath: null, version: null, - hooksInstalled: false, - hookPointerPath: null, capabilities: { interactiveLaunch: true, headlessTask: true, @@ -274,7 +212,7 @@ describe('LauncherApp · captured tasks', () => { expect(onOpenRoom).toHaveBeenCalledWith('room-multi'); }); - it('labels a roadmap tool and offers no launch, task, or hook actions', async () => { + it('labels a roadmap tool and offers no launch or task actions', async () => { mocks.adapter.detectTools.mockResolvedValue({ platform: 'darwin', detectedAt: '2026-07-11T00:00:00.000Z', @@ -283,12 +221,9 @@ describe('LauncherApp · captured tasks', () => { displayName: 'Cursor', releaseStatus: 'roadmap', launchable: false, - hookCapable: false, installed: true, installedPath: '/Applications/Cursor.app', version: '1.0.0', - hooksInstalled: true, - hookPointerPath: '/home/.cursor/hooks', capabilities: { interactiveLaunch: true, headlessTask: false, @@ -306,10 +241,8 @@ describe('LauncherApp · captured tasks', () => { expect(within(card).getByText('Roadmap')).toBeInTheDocument(); expect(within(card).getByText(/detection retained for compatibility/i)).toBeInTheDocument(); expect(within(card).queryByText('Detect only')).not.toBeInTheDocument(); - expect(within(card).queryByText('Hooks active')).not.toBeInTheDocument(); expect(within(card).queryByRole('button', { name: /^launch$/i })).not.toBeInTheDocument(); expect(within(card).queryByRole('button', { name: /run task/i })).not.toBeInTheDocument(); - expect(within(card).queryByRole('button', { name: /install hooks/i })).not.toBeInTheDocument(); }); it('launches Hermes Desktop but excludes it and a broken CLI from captured teams', async () => { @@ -323,8 +256,6 @@ describe('LauncherApp · captured tasks', () => { installed: true, installedPath: 'C:\\tools\\codex.exe', version: '0.144.1', - hooksInstalled: true, - hookPointerPath: 'C:\\Users\\test\\.codex\\hooks.json', launchable: true, capabilities: { interactiveLaunch: true, @@ -341,8 +272,6 @@ describe('LauncherApp · captured tasks', () => { installed: true, installedPath: 'C:\\Users\\test\\AppData\\Local\\hermes\\bin\\hermes.cmd', version: null, - hooksInstalled: false, - hookPointerPath: null, launchable: false, diagnostic: 'Hermes failed its --version health check.', capabilities: { @@ -360,10 +289,7 @@ describe('LauncherApp · captured tasks', () => { installed: true, installedPath: 'C:\\Users\\test\\AppData\\Local\\hermes\\Hermes.exe', version: null, - hooksInstalled: false, - hookPointerPath: null, launchable: true, - hookCapable: false, capabilities: { interactiveLaunch: true, headlessTask: false, @@ -381,8 +307,6 @@ describe('LauncherApp · captured tasks', () => { const desktopCard = await screen.findByTestId('launcher-tool-hermes-desktop'); expect(within(desktopCard).getByRole('button', { name: /^launch$/i })).toBeInTheDocument(); expect(within(desktopCard).queryByRole('button', { name: /run task/i })).not.toBeInTheDocument(); - expect(within(desktopCard).queryByRole('button', { name: /install hooks/i })).not.toBeInTheDocument(); - expect(within(desktopCard).getByText(/launch only/i)).toBeInTheDocument(); const cliCard = screen.getByTestId('launcher-tool-hermes'); expect(within(cliCard).queryByRole('button', { name: /^launch$/i })).not.toBeInTheDocument(); @@ -395,31 +319,7 @@ describe('LauncherApp · captured tasks', () => { }); }); -describe('LauncherApp · hook cohort (#3)', () => { - it('offers hook actions for every real-hook tool (e.g. codex), not just claude-code', async () => { - // The 7 real-hook tools (claude-code, claude-desktop, codex, - // codex-desktop, cursor, hermes, openclaw) all ship a bin — the dock - // must expose hook install for each, mirroring the backend HOOKS_COHORT. - mocks.adapter.detectTools.mockResolvedValue({ - platform: 'darwin', - detectedAt: '2026-06-29T00:00:00.000Z', - tools: [ - { - id: 'codex', - displayName: 'Codex', - installed: true, - installedPath: '/usr/local/bin/codex', - version: '1.0.0', - hooksInstalled: false, - hookPointerPath: null, - }, - ], - }); - render(); - expect(await screen.findByText('Codex')).toBeInTheDocument(); - expect(screen.getByRole('button', { name: /install hooks/i })).toBeInTheDocument(); - }); - +describe('LauncherApp · launch', () => { it('offers launch for a detected third-party adapter and sends its raw prompt', async () => { mocks.adapter.detectTools.mockResolvedValue({ platform: 'linux', @@ -431,10 +331,7 @@ describe('LauncherApp · hook cohort (#3)', () => { installed: true, installedPath: '/usr/local/bin/foo', version: '1.0.0', - hooksInstalled: false, - hookPointerPath: null, launchable: true, - hookCapable: false, builtin: false, acceptsInlinePrompt: true, }, @@ -460,7 +357,6 @@ describe('LauncherApp · hook cohort (#3)', () => { }), ); }); - expect(screen.queryByRole('button', { name: /install hooks/i })).not.toBeInTheDocument(); expect(screen.queryByText(/launch and hook management arrive in Phase 4/i)).not.toBeInTheDocument(); }); @@ -476,10 +372,7 @@ describe('LauncherApp · hook cohort (#3)', () => { installedPath: 'C:\\Program Files\\WindowsApps\\OpenAI.Codex_26.623.19656.0_x64__2p2nqsd0c76g0\\app\\resources\\codex.exe', version: null, - hooksInstalled: false, - hookPointerPath: null, launchable: false, - hookCapable: true, diagnostic: 'Codex was found in WindowsApps, but Windows blocks command-line launch from that app alias. Install a PATH CLI build of Codex or launch Codex from Start, then refresh.', }, @@ -495,163 +388,7 @@ describe('LauncherApp · hook cohort (#3)', () => { expect(screen.queryByText(/adapter is not configured for launch/i)).not.toBeInTheDocument(); }); - it('shows actionable hook install stdout details such as the backup path', async () => { - mocks.adapter.detectTools.mockResolvedValue({ - ...detectionResp, - tools: [ - { - ...detectionResp.tools[0], - hooksInstalled: false, - hookPointerPath: null, - }, - ], - }); - mocks.adapter.manageHooks.mockResolvedValueOnce({ - ok: true, - action: 'install', - stdout: 'settings backed up: /home/.claude/settings.json.hive-mind-backup.2026-07-08T19-00-00Z\ninstall complete', - stderr: '', - code: 0, - }); - - render(); - fireEvent.click(await screen.findByRole('button', { name: /install hooks/i })); - - expect(await screen.findByText(/Claude Code: install OK/i)).toBeInTheDocument(); - expect(screen.getByText('Backup')).toBeInTheDocument(); - expect(screen.getByText(/settings\.json\.hive-mind-backup/i)).toBeInTheDocument(); - expect(screen.getByText('Recovery')).toBeInTheDocument(); - expect(screen.queryByText(/^stdout:/i)).not.toBeInTheDocument(); - }); - - it('shows hook failure stderr even when the route returns a generic error', async () => { - mocks.adapter.manageHooks.mockResolvedValueOnce({ - ok: false, - action: 'verify', - stdout: '', - stderr: 'missing hook pointer: /home/.claude/settings.json', - code: 1, - error: 'verify failed', - }); - - render(); - fireEvent.click(await screen.findByRole('button', { name: /^verify$/i })); - - expect(await screen.findByText(/verify failed/i)).toBeInTheDocument(); - expect(screen.getByText(/missing hook pointer/i)).toBeInTheDocument(); - expect(screen.getByText(/settings\.json/i)).toBeInTheDocument(); - }); - - it('summarizes long hook output instead of flooding the result panel', async () => { - mocks.adapter.manageHooks.mockResolvedValueOnce({ - ok: false, - action: 'verify', - stdout: '', - stderr: [ - 'failure detail 1: missing hook pointer', - 'failure detail 2: stale backup file', - 'failure detail 3: cli not trusted', - 'failure detail 4: config mismatch', - 'failure detail 5: lifecycle skipped', - 'failure detail 6: retry recommended', - 'failure detail 7: noisy internal trace', - 'failure detail 8: noisy internal trace', - ].join('\n'), - code: 1, - error: 'verify failed', - }); - - render(); - fireEvent.click(await screen.findByRole('button', { name: /^verify$/i })); - - expect(await screen.findByText(/verify failed/i)).toBeInTheDocument(); - expect(screen.getByText(/failure detail 1/i)).toBeInTheDocument(); - expect(screen.getByText('More output')).toBeInTheDocument(); - expect(screen.getByText(/2 additional hook output lines hidden/i)).toBeInTheDocument(); - expect(screen.queryByText(/failure detail 8/i)).not.toBeInTheDocument(); - expect(screen.getByText('Recovery')).toBeInTheDocument(); - }); - - it('shows recovery guidance when hook verify fails without stdout or stderr', async () => { - mocks.adapter.manageHooks.mockResolvedValueOnce({ - ok: false, - action: 'verify', - stdout: '', - stderr: '', - code: 1, - }); - - render(); - fireEvent.click(await screen.findByRole('button', { name: /^verify$/i })); - - expect(await screen.findByText(/verify failed \(exit 1\)/i)).toBeInTheDocument(); - expect(screen.getByText(/no hook output was returned/i)).toBeInTheDocument(); - expect(screen.getByText(/reinstall hooks/i)).toBeInTheDocument(); - }); - - it('summarizes hook verify check failures instead of showing raw check output', async () => { - mocks.adapter.manageHooks.mockResolvedValueOnce({ - ok: false, - action: 'verify', - stdout: [ - 'hive-mind/codex-hooks: verify', - ' [PASS] hooks.json exists — /home/.codex/hooks.json', - ' [FAIL] hook command trusted — manual approval required in Codex settings', - 'One or more checks failed.', - ].join('\n'), - stderr: '', - code: 1, - }); - - render(); - fireEvent.click(await screen.findByRole('button', { name: /^verify$/i })); - - expect(await screen.findByText(/verify failed \(exit 1\)/i)).toBeInTheDocument(); - expect(screen.getByText('Check failed')).toBeInTheDocument(); - expect(screen.getByText(/manual approval required in Codex settings/i)).toBeInTheDocument(); - expect(screen.getByText('Recovery')).toBeInTheDocument(); - expect(screen.queryByText(/\[FAIL\]/)).not.toBeInTheDocument(); - }); - - it('labels hook uninstall restore and cleanup details without implying install state', async () => { - mocks.adapter.detectTools.mockResolvedValue({ - ...detectionResp, - tools: [ - { - ...detectionResp.tools[0], - hooksInstalled: true, - hookPointerPath: '/home/.codex/hive-mind-install.json', - }, - ], - }); - mocks.adapter.manageHooks.mockResolvedValueOnce({ - ok: true, - action: 'uninstall', - stdout: [ - 'hive-mind/codex-hooks: uninstall', - ' - hooks.json: /home/.codex/hooks.json', - ' - restored from: /home/.codex/hooks.json.hive-mind-backup.2026-07-08T19-00-00Z', - ' - created removed: no', - ' - backup removed: yes', - ' - pointer removed: yes', - 'Done. hooks.json is byte-identical to pre-install state.', - ].join('\n'), - stderr: '', - code: 0, - }); - - render(); - fireEvent.click(await screen.findByRole('button', { name: /uninstall hooks/i })); - - expect(await screen.findByText(/Claude Code: uninstall OK/i)).toBeInTheDocument(); - expect(screen.getByText('Changed file')).toBeInTheDocument(); - expect(screen.getByText('Restored from')).toBeInTheDocument(); - expect(screen.getByText('Backup removed')).toBeInTheDocument(); - expect(screen.getByText('Pointer removed')).toBeInTheDocument(); - expect(screen.queryByText('Install pointer')).not.toBeInTheDocument(); - }); - - it('offers Claude Desktop launch and hook management from the shared manifest', async () => { + it('offers Claude Desktop launch from the shared manifest', async () => { mocks.adapter.detectTools.mockResolvedValue({ platform: 'darwin', detectedAt: '2026-07-08T00:00:00.000Z', @@ -662,8 +399,6 @@ describe('LauncherApp · hook cohort (#3)', () => { installed: true, installedPath: '/Applications/Claude.app', version: '1.2.3', - hooksInstalled: false, - hookPointerPath: null, }, ], }); @@ -672,15 +407,11 @@ describe('LauncherApp · hook cohort (#3)', () => { expect(await screen.findByText('Claude Desktop')).toBeInTheDocument(); expect(screen.getByRole('button', { name: /^launch$/i })).toBeInTheDocument(); - expect(screen.getByRole('button', { name: /install hooks/i })).toBeInTheDocument(); - expect(screen.getByRole('button', { name: /^verify$/i })).toBeInTheDocument(); - expect(screen.queryByText(/launch only/i)).not.toBeInTheDocument(); - expect(screen.queryByText(/hooks are not supported for Claude Desktop yet/i)).not.toBeInTheDocument(); }); }); describe('LauncherApp · v1 memory features (ADR-0002)', () => { - it('hides hook controls, the memory-sharing explainer and Room tasks; launch stays', async () => { + it('hides Room tasks; launch stays', async () => { features.enabled = false; mocks.adapter.detectTools.mockResolvedValue({ platform: 'darwin', @@ -692,8 +423,6 @@ describe('LauncherApp · v1 memory features (ADR-0002)', () => { installed: true, installedPath: '/usr/local/bin/codex', version: '0.144.1', - hooksInstalled: true, - hookPointerPath: '/home/.codex/hooks', capabilities: { interactiveLaunch: true, headlessTask: true, structuredProgress: true, resumable: true }, permissionModes: ['read-only', 'workspace-write', 'native'], }, @@ -704,10 +433,6 @@ describe('LauncherApp · v1 memory features (ADR-0002)', () => { expect(await screen.findByText('Codex CLI')).toBeInTheDocument(); expect(screen.getByRole('button', { name: /^launch$/i })).toBeInTheDocument(); - expect(screen.queryByRole('tablist', { name: /launcher view/i })).not.toBeInTheDocument(); - expect(screen.queryByText(/hooks active/i)).not.toBeInTheDocument(); - expect(screen.queryByRole('button', { name: /install hooks|uninstall hooks|^verify$/i })).not.toBeInTheDocument(); - expect(screen.queryByText(/launch only|hook management is not supported/i)).not.toBeInTheDocument(); expect(screen.queryByRole('button', { name: /run task/i })).not.toBeInTheDocument(); }); }); diff --git a/apps/web/src/components/os/apps/LauncherApp.tsx b/apps/web/src/components/os/apps/LauncherApp.tsx index b95cedc..0846845 100644 --- a/apps/web/src/components/os/apps/LauncherApp.tsx +++ b/apps/web/src/components/os/apps/LauncherApp.tsx @@ -3,28 +3,18 @@ * * Dock surface for the AI-OS tool launcher. Lists registered AI execution * surfaces while keeping roadmap integrations visibly inert. Each card - * includes detection status, hook-install status, - * and its supported actions: - * - * Launch in workspace X / Install hooks / Verify hooks / Uninstall hooks + * includes detection status and its supported actions (launch in the active + * workspace, watch, stop). * * Adapter contract: * adapter.detectTools() → /api/tools/detect * adapter.launchTool() → /api/tools/launch - * adapter.manageHooks() → /api/tools/hooks - * - * Warm-Hive PR6b (B1): two views behind a segmented toggle — - * Variation A · Launch — the live detect/launch/hooks/processes UI (below). - * Variation B · How memory is shared — a pure-UI explainer (flow diagram + - * three cards + a provenance example). Static, no backend, mirrors - * docs/design_handoff_waggle_app/design-files/screens/launcher.html. */ import { useState, useEffect, useCallback, useMemo } from 'react'; import { Rocket, RefreshCw, CheckCircle2, XCircle, AlertTriangle, - Play, Download, ShieldCheck, Trash2, Loader2, MessageSquare, Square, - Workflow, ArrowDownToLine, ArrowRight, ShieldCheck as ShieldCheckIcon, Hexagon, + Play, Loader2, MessageSquare, Square, Workflow, } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { Badge } from '@/components/ui/badge'; @@ -45,19 +35,15 @@ import { } from '@waggle/shared'; // #5 — derived from the shared manifest registry (single source of truth), -// replacing the hand-maintained local copies. LAUNCH_COHORT = launchable tools; -// HOOKS_COHORT = tools whose hive-mind hook package ships a bin (hookCapable). -// Hermes Desktop is intentionally excluded. Mirrors the backend cohorts, which -// derive from the same BUILTIN_TOOL_MANIFESTS. +// replacing the hand-maintained local copy. LAUNCH_COHORT = launchable tools. +// Mirrors the backend cohort, which derives from the same BUILTIN_TOOL_MANIFESTS. const LAUNCH_COHORT = BUILTIN_TOOL_MANIFESTS.filter((m) => m.launchable).map((m) => m.id); -const HOOKS_COHORT = BUILTIN_TOOL_MANIFESTS.filter((m) => m.hookCapable).map((m) => m.id); interface DetectedTool { id: string; displayName: string; releaseStatus?: ToolReleaseStatus; launchable?: boolean; - hookCapable?: boolean; builtin?: boolean; acceptsInlinePrompt?: boolean; capabilities?: ToolCapabilities; @@ -65,8 +51,6 @@ interface DetectedTool { installed: boolean; installedPath: string | null; version: string | null; - hooksInstalled: boolean; - hookPointerPath: string | null; diagnostic?: string; } @@ -76,10 +60,7 @@ interface DetectionResult { tools: DetectedTool[]; } -type ToolAction = 'launch' | 'run' | 'install' | 'verify' | 'uninstall'; - -/** Segmented-toggle view: A = the live launch UI; B = the memory-sharing explainer. */ -type LauncherView = 'a' | 'b'; +type ToolAction = 'launch' | 'run'; interface ActionState { toolId: string; @@ -91,13 +72,6 @@ interface ActionResult { action: ToolAction; ok: boolean; message: string; - details?: ActionDetail[]; -} - -interface ActionDetail { - label: string; - value: string; - tone?: 'attention' | 'recovery'; } interface LauncherAppProps { @@ -115,16 +89,13 @@ export function resetLauncherRouteCache(): void { launcherRouteCache.resetForTests(); } -const HOOK_PATH_RE = /([A-Za-z]:\\[^\s]+|\/[^\s]+)/; -const MAX_VISIBLE_HOOK_DETAILS = 6; - const toolCanLaunch = (tool: DetectedTool): boolean => tool.releaseStatus !== 'roadmap' && (tool.launchable ?? LAUNCH_COHORT.includes(tool.id)); const launchUnavailableMessage = (tool: DetectedTool): string => tool.releaseStatus === 'roadmap' - ? 'Roadmap integration. Detection retained for compatibility; launch, tasks, and hooks are deferred.' + ? 'Roadmap integration. Detection retained for compatibility; launch and tasks are deferred.' : tool.installed && tool.diagnostic ? 'Launch is blocked for this install. Follow the note above, then refresh.' : 'Detection ready. This adapter is not configured for launch.'; @@ -149,152 +120,9 @@ const toolCanRunCapturedTask = (tool: DetectedTool): boolean => tool.capabilities?.headlessTask === true && (tool.permissionModes?.length ?? 0) > 0; -const hookDetailLabel = (rawLabel: string): string => { - const label = rawLabel.trim().toLowerCase(); - if (label.includes('backup removed')) return 'Backup removed'; - if (label.includes('pointer removed')) return 'Pointer removed'; - if (label.includes('created removed')) return 'Created file removed'; - if (label.includes('backup')) return 'Backup'; - if (label.includes('pointer')) return 'Install pointer'; - if (label.includes('restored')) return 'Restored from'; - if (label.includes('settings') || label.includes('hooks.json') || label.includes('config')) return 'Changed file'; - if (label.includes('added hooks')) return 'Hooks added'; - if (label.includes('cli path')) return 'CLI path'; - return rawLabel.trim().replace(/^\w/, (c) => c.toUpperCase()); -}; - -const hookRecoveryDetail = (result?: { ok: boolean; action: ToolAction }): ActionDetail | null => { - if (!result) return null; - if (!result.ok) { - return { - label: 'Recovery', - value: result.action === 'verify' - ? 'Run Install hooks for this tool, then Verify again. If it still fails, use Uninstall hooks to restore the previous config, then reinstall hooks.' - : 'Retry the action. If it repeats, use Uninstall hooks to restore the previous config, then install again.', - tone: 'recovery', - }; - } - if (result.action === 'install') { - return { - label: 'Recovery', - value: 'Use Verify to inspect the install, or Uninstall hooks to restore the previous config.', - tone: 'recovery', - }; - } - if (result.action === 'uninstall') { - return { - label: 'Recovery', - value: 'Previous hook config was restored, or the Waggle-created config was removed.', - tone: 'recovery', - }; - } - return null; -}; - -const parseHookOutputDetails = (text: string | undefined, stream: 'stdout' | 'stderr'): ActionDetail[] => { - const lines = text?.trim().split(/\r?\n/).map((line) => line.trim()).filter(Boolean) ?? []; - const tone = stream === 'stderr' ? 'attention' : undefined; - - return lines - .map((line): ActionDetail | null => { - const check = line.match(/^\[(PASS|FAIL)\]\s+(.+?)(?:\s+(?:\u2014|-)\s+(.+))?$/); - if (check) { - const failed = check[1] === 'FAIL'; - const name = check[2].trim(); - const detail = check[3]?.trim(); - return { - label: failed ? 'Check failed' : 'Check passed', - value: detail ? `${name}: ${detail}` : name, - tone: failed ? 'attention' : tone, - }; - } - - const labeled = line.match(/^\s*-\s*([^:]+):\s*(.*)$/); - if (labeled) { - return { - label: hookDetailLabel(labeled[1]), - value: labeled[2].trim() || line, - tone, - }; - } - - if (/backup|backed up/i.test(line)) { - return { - label: 'Backup', - value: line.match(HOOK_PATH_RE)?.[1] ?? line, - tone, - }; - } - - if (stream === 'stderr') { - return { label: 'Needs attention', value: line, tone: 'attention' }; - } - - if ( - /^hive-mind\/.+:\s/.test(line) || - /^done\./i.test(line) || - /^run "/i.test(line) || - /^all checks passed\.$/i.test(line) || - /^one or more checks failed\.$/i.test(line) - ) { - return null; - } - - return { label: 'Output', value: line }; - }) - .filter((detail): detail is ActionDetail => Boolean(detail)); -}; - -const summarizeHookActionDetails = (details: ActionDetail[]): ActionDetail[] => { - const recoveryDetails = details.filter((detail) => detail.label === 'Recovery'); - const outputDetails = details.filter((detail) => detail.label !== 'Recovery'); - if (outputDetails.length <= MAX_VISIBLE_HOOK_DETAILS) return details; - - const visibleOutput = outputDetails.slice(0, MAX_VISIBLE_HOOK_DETAILS); - const hiddenCount = outputDetails.length - visibleOutput.length; - const hiddenHasAttention = outputDetails - .slice(MAX_VISIBLE_HOOK_DETAILS) - .some((detail) => detail.tone === 'attention'); - - return [ - ...visibleOutput, - { - label: 'More output', - value: `${hiddenCount} additional hook output ${hiddenCount === 1 ? 'line' : 'lines'} hidden. Run the hook action from a terminal for full output.`, - tone: hiddenHasAttention ? 'attention' : undefined, - }, - ...recoveryDetails, - ]; -}; - -const hookActionDetails = ( - stdout?: string, - stderr?: string, - result?: { ok: boolean; action: ToolAction }, -): ActionDetail[] => { - const details = [ - ...parseHookOutputDetails(stdout, 'stdout'), - ...parseHookOutputDetails(stderr, 'stderr'), - ]; - const recovery = hookRecoveryDetail(result); - if (recovery) { - details.push(recovery); - } - if (!result?.ok && details.length === 1 && recovery) { - details.unshift({ - label: 'Needs attention', - value: 'No hook output was returned.', - tone: 'attention', - }); - } - return summarizeHookActionDetails(details); -}; - const LauncherApp = ({ activeWorkspaceId, workspaces = [], onOpenRoom }: LauncherAppProps = {}) => { - const [view, setView] = useState('a'); - // ADR-0002: agent memory hooks and Waggle Room are hidden in v1 (memory - // feature map). Launch, watch and stop stay. - const hooksShown = hasMemoryFeature('agentHooks'); + // ADR-0002: Waggle Room is hidden in v1 (memory feature map). Launch, watch + // and stop stay. const roomShown = hasMemoryFeature('room'); const cachedDetection = launcherRouteCache.read('tools'); const [detection, setDetection] = useState(cachedDetection ?? null); @@ -435,67 +263,50 @@ const LauncherApp = ({ activeWorkspaceId, workspaces = [], onOpenRoom }: Launche [pidsByTool], ); - const doAction = useCallback( - async (tool: DetectedTool, action: Exclude) => { + const launchSelectedTool = useCallback( + async (tool: DetectedTool) => { + const action = 'launch'; setActiveAction({ toolId: tool.id, action }); setLastResult(null); try { - if (action === 'launch') { - if (!tool.installedPath) { - setLastResult({ - toolId: tool.id, - action, - ok: false, - message: 'Tool not installed. Cannot launch.', - }); - return; - } - // If a prompt is set AND the tool has a known prompt-arg - // shape, pass it through as CLI args. Otherwise launch - // bare and the prompt textarea is silently ignored for - // that tool. - const args = promptArgsForTool(tool.id, prompt) ?? undefined; - const sendsRawPrompt = !args && tool.acceptsInlinePrompt === true && prompt.trim().length > 0; - const r = await adapter.launchTool({ - id: tool.id, - installedPath: tool.installedPath, - workspaceId: activeWorkspaceId, - // Built-in tools send pre-computed args; a third-party adapter gets - // the raw prompt so the server can apply its promptArgTemplate (#5). - ...(args ? { args } : (sendsRawPrompt ? { prompt } : {})), - ...(watchMode ? { observe: true } : {}), - }); - const promptNote = (args || sendsRawPrompt) ? ' with prompt' : ''; + if (!tool.installedPath) { setLastResult({ toolId: tool.id, action, - ok: r.ok, - message: r.ok - ? `Launched ${tool.displayName}${promptNote} (pid ${r.pid})` - : (r.error ?? 'Launch failed'), + ok: false, + message: 'Tool not installed. Cannot launch.', }); - // Clear the prompt after a successful launch — avoid sending - // the same text twice by accident. - if (r.ok && (args || sendsRawPrompt)) setPrompt(''); - // Watch mode (⌘K deep-link): auto-open the live output pane. - if (r.ok && watchMode) setOpenPaneToolId(tool.id); - } else { - const r = await adapter.manageHooks({ id: tool.id, action }); - setLastResult({ - toolId: tool.id, - action, - ok: r.ok, - message: r.ok - ? `${tool.displayName}: ${action} OK` - : (r.error || r.stderr || `${action} failed (exit ${r.code})`), - details: hookActionDetails(r.stdout, r.stderr, { ok: r.ok, action }), - }); - // Refresh detection after install/uninstall so hook status - // updates on screen without waiting for user click. - if (action === 'install' || action === 'uninstall') { - await refresh(); - } + return; } + // If a prompt is set AND the tool has a known prompt-arg + // shape, pass it through as CLI args. Otherwise launch + // bare and the prompt textarea is silently ignored for + // that tool. + const args = promptArgsForTool(tool.id, prompt) ?? undefined; + const sendsRawPrompt = !args && tool.acceptsInlinePrompt === true && prompt.trim().length > 0; + const r = await adapter.launchTool({ + id: tool.id, + installedPath: tool.installedPath, + workspaceId: activeWorkspaceId, + // Built-in tools send pre-computed args; a third-party adapter gets + // the raw prompt so the server can apply its promptArgTemplate (#5). + ...(args ? { args } : (sendsRawPrompt ? { prompt } : {})), + ...(watchMode ? { observe: true } : {}), + }); + const promptNote = (args || sendsRawPrompt) ? ' with prompt' : ''; + setLastResult({ + toolId: tool.id, + action, + ok: r.ok, + message: r.ok + ? `Launched ${tool.displayName}${promptNote} (pid ${r.pid})` + : (r.error ?? 'Launch failed'), + }); + // Clear the prompt after a successful launch — avoid sending + // the same text twice by accident. + if (r.ok && (args || sendsRawPrompt)) setPrompt(''); + // Watch mode (⌘K deep-link): auto-open the live output pane. + if (r.ok && watchMode) setOpenPaneToolId(tool.id); } catch (err) { setLastResult({ toolId: tool.id, @@ -507,7 +318,7 @@ const LauncherApp = ({ activeWorkspaceId, workspaces = [], onOpenRoom }: Launche setActiveAction(null); } }, - [activeWorkspaceId, prompt, refresh, watchMode], + [activeWorkspaceId, prompt, watchMode], ); const tools = useMemo(() => detection?.tools ?? [], [detection]); @@ -590,51 +401,22 @@ const LauncherApp = ({ activeWorkspaceId, workspaces = [], onOpenRoom }: Launche return (
- {/* Header — title + A/B segmented toggle + (Variation A only) refresh */} + {/* Header — title + refresh */}
Tool Launcher - {view === 'a' && detection && ( + {detection && ( {detection.platform} )}
- {hooksShown && ( -
- {(['a', 'b'] as LauncherView[]).map((v) => ( - - ))} -
- )} - {view === 'a' && ( - - )} +
- {view === 'b' && hooksShown ? ( - - ) : ( - <> {/* Status bar */} {error && (
@@ -670,25 +452,6 @@ const LauncherApp = ({ activeWorkspaceId, workspaces = [], onOpenRoom }: Launche )}
{lastResult.message}
- {lastResult.details?.length ? ( -
- {lastResult.details.map((detail, index) => ( -
-
- {detail.label} -
-
- {detail.value} -
-
- ))} -
- ) : null}
)} @@ -753,8 +516,6 @@ const LauncherApp = ({ activeWorkspaceId, workspaces = [], onOpenRoom }: Launche )} {tools.map((tool) => { const launchable = toolCanLaunch(tool); - const hooksSupported = hooksShown && HOOKS_COHORT.includes(tool.id); - const launchOnly = hooksShown && launchable && !hooksSupported; const isActive = activeAction?.toolId === tool.id; return (
)} - {hooksShown && tool.hooksInstalled && tool.releaseStatus !== 'roadmap' && ( - - Hooks active - - )} - {launchOnly && ( - - Launch only - - )} {runningTools.has(tool.id) && ( )} - {hooksSupported && !tool.hooksInstalled && ( - - )} - {hooksSupported && ( - - )} - {hooksSupported && tool.hooksInstalled && ( - - )}
- {launchOnly && ( -
- {tool.id === 'hermes-desktop' - ? 'Hook management is not supported for Hermes Desktop.' - : 'Hook management is not supported for this tool yet.'} -
- )} {roomShown && taskToolId === tool.id && toolCanRunCapturedTask(tool) && (
- - )}
); }; -/** - * Variation B · How memory is shared — a pure-UI explainer. No backend, no - * adapter calls, no live data: a fixed flow diagram + three cards + one - * provenance example, mirroring launcher.html lines 147-181. The provenance - * example string is illustrative (a documentation example, not a real recall), - * so it carries an explicit "example" label — no fabricated live data. - */ - -interface FlowNode { - tag: string; - title: string; - detail: React.ReactNode; - hive?: boolean; -} - -const FLOW_NODES: readonly FlowNode[] = [ - { - tag: 'You launch', - title: 'Claude Code', - detail: ( - <> - opened from Waggle with -
- - WAGGLE_WORKSPACE_ID - - - ), - }, - { - tag: '5 lifecycle hooks', - title: 'hive-mind', - detail: <>session · prompt · stop · compact · tool, - }, - { - tag: 'Your workspace', - title: 'The hive', - detail: ( - <> - local SQLite memory -
- shared with Waggle - - ), - hive: true, - }, -]; - -interface ExplainerCard { - icon: typeof ArrowDownToLine; - title: string; - body: string; -} - -const EXPLAINER_CARDS: readonly ExplainerCard[] = [ - { - icon: ArrowDownToLine, - title: 'It recalls on start', - body: 'The agent opens already knowing this workspace: decisions, constraints, and context, pulled from the hive.', - }, - { - icon: ArrowRight, - title: 'It commits as it works', - body: 'Every meaningful step is captured back into the hive, so Waggle and your next session see it too.', - }, - { - icon: ShieldCheckIcon, - title: 'Reversible & local', - body: 'Hooks install and uninstall cleanly. Nothing leaves your machine; you can verify or remove them anytime.', - }, -]; - -const MemorySharingView = () => { - return ( - -
- {/* Heading */} -
-
-
-

- How a launched agent shares the hive -

-

- When you launch from Waggle, the workspace's memory is wired into the external tool. No copy-paste, no - re-explaining. Its work comes back attributed. -

-
- - {/* Flow diagram + cards + provenance example */} -
- {/* Flow row */} -
- {FLOW_NODES.map((node, i) => ( -
-
-
- {node.tag} -
-
{node.title}
-
{node.detail}
-
- {i < FLOW_NODES.length - 1 && ( - - )} -
- ))} -
- - {/* Three explainer cards */} -
- {EXPLAINER_CARDS.map((card) => { - const Icon = card.icon; - return ( -
-
- ); - })} -
- - {/* Provenance example — illustrative, explicitly labelled */} -
-
-
- -
-
-
-
- ); -}; - export default LauncherApp; diff --git a/apps/web/src/components/os/apps/MissionControlApp.tsx b/apps/web/src/components/os/apps/MissionControlApp.tsx index d0f3b40..2a46dd9 100644 --- a/apps/web/src/components/os/apps/MissionControlApp.tsx +++ b/apps/web/src/components/os/apps/MissionControlApp.tsx @@ -10,14 +10,12 @@ interface MissionControlAppProps { /** * AI-OS Phase 4 polish — compact inventory of installed AI tools at - * the top of Mission Control. One line: detected · installed · - * hook-wired counts, with an "Open Launcher" button to jump to the - * dedicated dock app. + * the top of Mission Control. One line: detected · installed counts, + * with an "Open Launcher" button to jump to the dedicated dock app. */ interface ToolInventoryCounts { detected: number; installed: number; - hooked: number; } const MissionControlApp = ({ onSpawnOpen }: MissionControlAppProps) => { @@ -43,7 +41,6 @@ const MissionControlApp = ({ onSpawnOpen }: MissionControlAppProps) => { setToolCounts({ detected: ts.length, installed: ts.filter((t) => t.installed).length, - hooked: ts.filter((t) => t.hooksInstalled).length, }); } if (fleet.status === 'rejected') { @@ -104,8 +101,7 @@ const MissionControlApp = ({ onSpawnOpen }: MissionControlAppProps) => { {toolCounts.detected} tools known ·{' '} - {toolCounts.installed} installed ·{' '} - {toolCounts.hooked} hook-wired + {toolCounts.installed} installed