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
replace the Shell page's hardcoded AI CLI buttons with a launch menu built from enabled TUI providers
[._.]/ Adam Eivyf24396325b59
diff --git a/client/src/components/providers/ProviderCard.jsx b/client/src/components/providers/ProviderCard.jsxindex 2771100b74..f343035200 100644--- a/client/src/components/providers/ProviderCard.jsx+++ b/client/src/components/providers/ProviderCard.jsx@@ -23,6 +23,7 @@ import {isProcessProvider,isRunnerAllowedCommand,isTuiProvider,+ isLaunchableTuiProvider,providerTypeClass,supportsModelRefresh,} from '../../utils/providers';@@ -188,7 +189,7 @@ export default function ProviderCard({are secret, so they can't ride a URL anyway. `tuiCommandLine` isthe display half of the same resolution: it shows what will run,and an older server that omits it simply renders no button. */}- {isTuiProvider(provider) && provider.tuiCommandLine && (+ {isLaunchableTuiProvider(provider) && (<Linkto={`/shell?provider=${encodeURIComponent(provider.id)}`}className="flex items-center gap-1.5 px-3 py-1.5 text-sm bg-port-accent/20 text-port-accent hover:bg-port-accent/30 rounded transition-colors"diff --git a/client/src/components/shell/ShellProviderLauncher.jsx b/client/src/components/shell/ShellProviderLauncher.jsxnew file mode 100644index 0000000000..a266af3631--- /dev/null+++ b/client/src/components/shell/ShellProviderLauncher.jsx@@ -0,0 +1,187 @@+import { useRef, useState } from 'react';+import { createPortal } from 'react-dom';+import { Bot, ChevronDown, Search, Terminal, AlertTriangle } from 'lucide-react';+import usePopoverPosition, { VIEWPORT_PADDING } from '../../hooks/usePopoverPosition.js';+import useClickOutside from '../../hooks/useClickOutside';+import useEscapeKey from '../../hooks/useEscapeKey';+import { tokenizeQuery, matchHaystack } from '../../lib/mediaSearch.js';+import { isLaunchableTuiProvider } from '../../utils/providers';++const PANEL_WIDTH = 384;++// How many entries the list needs before the filter box earns its row. A short+// list is faster to scan than to type into — and on a phone the box would cost+// a chunk of the panel plus an unwanted keyboard.+const FILTER_THRESHOLD = 6;++/**+ * The launchable set: enabled providers `isLaunchableTuiProvider` accepts,+ * sorted by name so the list is stable as providers are toggled on and off.+ * Each carries a prebuilt lowercase haystack so keystroke filtering is a plain+ * `includes` rather than a re-join per provider per keypress.+ */+export function launchableProviders(providers) {+ return (providers || [])+ .filter((p) => p?.enabled && isLaunchableTuiProvider(p))+ .sort((a, b) => (a.name || a.id).localeCompare(b.name || b.id))+ // Match on everything the row shows — name, id, and the command line — so+ // typing `ollama`, `opencode`, or `agy` all find their providers.+ .map((p) => ({ ...p, haystack: `${p.name || ''} ${p.id} ${p.tuiCommandLine}`.toLowerCase() }));+}++/**+ * Dynamic "launch an AI CLI" menu for the Shell page.+ *+ * Replaces the hardcoded per-tool buttons (claude / codex / agy / grok …) that+ * couldn't scale past a handful and duplicated provider config in the client.+ * Every enabled TUI provider shows up here automatically, and picking one goes+ * through `shell:start { providerId }` — the server re-resolves the command AND+ * pairs it with the provider's `envVars`, so an Ollama-, MTPLX- or+ * Bedrock-backed provider reaches the backend it is configured for. Typing the+ * command line into the current shell instead would leave that env behind (and+ * those values are secret, so they can't cross the wire anyway).+ *+ * The panel is PORTALED and fixed-positioned via `usePopoverPosition` for the+ * same two reasons `ShellImageDrop` is: both host bars are `overflow-x-auto`+ * (which clips an in-flow absolute panel) and both scroll horizontally, so a+ * hardcoded offset would detach from the button. The hook also clamps and flips+ * into the viewport, which is what keeps a 14-row menu on screen when the+ * trigger sits near the bottom of a phone.+ *+ * @param {Object} props+ * @param {Array} props.providers - `GET /api/providers` records; may be empty+ * until `onOpen` has loaded them.+ * @param {(providerId: string) => void} props.onLaunch+ * @param {() => void} [props.onOpen] - fired on each open so the host can load+ * providers lazily; a Shell visit that never opens this menu pays nothing.+ * @param {boolean} [props.loading] - providers are in flight (first open).+ * @param {'below'|'above'} [props.placement] - preferred side; flips if there's no room+ */+export default function ShellProviderLauncher({ providers, onLaunch, onOpen, loading = false, placement = 'below' }) {+ const [open, setOpen] = useState(false);+ const [query, setQuery] = useState('');+ const containerRef = useRef(null);++ const launchable = launchableProviders(providers);+ const tokens = tokenizeQuery(query);+ const visible = tokens.length === 0+ ? launchable+ : launchable.filter((p) => matchHaystack(p.haystack, tokens));++ const { triggerRef, popoverRef, style } = usePopoverPosition({+ open,+ width: PANEL_WIDTH,+ position: placement === 'above' ? 'above' : 'below',+ // The panel's height changes as the list loads and as the filter narrows it,+ // and that height is what decides whether the preferred side still fits.+ contentDeps: [visible.length, loading],+ });++ const close = () => { setOpen(false); setQuery(''); };+ // The panel is portaled to <body>, so it is not a descendant of the trigger+ // container — a single-ref containment check would read every click inside+ // the panel (including typing in the filter) as an outside click.+ useClickOutside([containerRef, popoverRef], open, close);+ useEscapeKey(open, close);++ const toggle = () => {+ if (open) { close(); return; }+ setOpen(true);+ onOpen?.();+ };++ const handlePick = (providerId) => {+ close();+ onLaunch(providerId);+ };++ return (+ <div className="relative shrink-0" ref={containerRef}>+ <button+ ref={triggerRef}+ onClick={toggle}+ className="flex items-center gap-1.5 px-2.5 py-1.5 bg-port-card hover:bg-port-border text-gray-300 hover:text-white rounded text-xs transition-colors border border-port-border min-h-[40px] shrink-0"+ title="Launch an AI CLI from your enabled providers"+ aria-label="Launch an AI CLI"+ aria-expanded={open}+ aria-haspopup="menu"+ >+ <Bot size={14} />+ <span className="hidden sm:inline">Launch AI</span>+ <ChevronDown size={12} className={`transition-transform ${open ? 'rotate-180' : ''}`} />+ </button>++ {open && createPortal(+ <div+ ref={popoverRef}+ className="fixed max-w-[calc(100vw-1rem)] max-h-[70vh] overflow-y-auto overscroll-contain z-[100] bg-port-card border border-port-border rounded-lg shadow-xl"+ style={{+ left: style?.left ?? `${VIEWPORT_PADDING}px`,+ top: style?.top ?? `${VIEWPORT_PADDING}px`,+ width: style?.width ?? `${PANEL_WIDTH}px`,+ // Hidden until measured so the panel never flashes at the corner.+ visibility: style ? 'visible' : 'hidden',+ }}+ >+ {launchable.length >= FILTER_THRESHOLD && (+ // Sticky so the filter stays reachable while scrolling a long list.+ // Deliberately not autofocused — on a phone that pops the keyboard+ // over the very list the user opened the menu to look at.+ <div className="sticky top-0 flex items-center gap-2 px-3 py-2 bg-port-card border-b border-port-border">+ <Search size={14} className="text-gray-500 shrink-0" />+ <input+ type="text"+ value={query}+ onChange={(e) => setQuery(e.target.value)}+ placeholder="Filter providers…"+ aria-label="Filter providers"+ className="w-full bg-transparent text-sm text-white placeholder-gray-500 focus:outline-none"+ />+ </div>+ )}++ {/* The `menu` role wraps only the items — an `<input>` is not a valid+ child of a menu, so the filter row stays outside it. */}+ <div role="menu" aria-label="Enabled AI providers">+ {visible.map((provider) => (+ <button+ key={provider.id}+ role="menuitem"+ onClick={() => handlePick(provider.id)}+ className="w-full text-left px-3 py-2 min-h-[44px] hover:bg-port-border transition-colors border-b border-port-border/50 last:border-b-0"+ title={provider.tuiCommandLine}+ >+ <div className="flex items-center gap-2">+ <Terminal size={12} className="text-port-accent shrink-0" />+ <span className="text-sm text-gray-200 truncate">{provider.name || provider.id}</span>+ {/* The server already told us this provider can't run here (a+ missing binary, an unset key). Still launchable — the user+ may be fixing it in another tab — but flagged, so a shell+ that instantly prints `command not found` isn't a surprise. */}+ {provider.prerequisitesMet === false && (+ <span className="flex items-center gap-1 text-[10px] text-port-warning shrink-0" title="Needs setup — see AI Providers">+ <AlertTriangle size={10} />+ setup+ </span>+ )}+ </div>+ <div className="text-[11px] font-mono text-gray-500 truncate">{provider.tuiCommandLine}</div>+ </button>+ ))}+ </div>++ {visible.length === 0 && (+ <div className="px-3 py-3 text-xs text-gray-500">+ {loading+ ? 'Loading providers…'+ : launchable.length === 0+ ? 'No enabled TUI providers. Enable one on the AI Providers page.'+ : 'No providers match that filter.'}+ </div>+ )}+ </div>,+ document.body+ )}+ </div>+ );+}diff --git a/client/src/components/shell/ShellProviderLauncher.test.jsx b/client/src/components/shell/ShellProviderLauncher.test.jsxnew file mode 100644index 0000000000..123e235934--- /dev/null+++ b/client/src/components/shell/ShellProviderLauncher.test.jsx@@ -0,0 +1,137 @@+import { describe, it, expect, vi } from 'vitest';+import { render, screen, fireEvent } from '@testing-library/react';+import ShellProviderLauncher, { launchableProviders } from './ShellProviderLauncher';++const tui = (overrides = {}) => ({+ id: 'claude-code-tui',+ name: 'Claude Code TUI',+ type: 'tui',+ enabled: true,+ tuiCommandLine: 'claude --dangerously-skip-permissions',+ ...overrides,+});++const open = (props = {}) => {+ const onLaunch = vi.fn();+ render(<ShellProviderLauncher providers={[tui()]} onLaunch={onLaunch} {...props} />);+ fireEvent.click(screen.getByLabelText('Launch an AI CLI'));+ return onLaunch;+};++describe('launchableProviders', () => {+ it('keeps only enabled TUI providers the server resolved a command line for', () => {+ const ids = launchableProviders([+ tui({ id: 'a' }),+ tui({ id: 'disabled', enabled: false }),+ // A CLI provider's args are headless (`--print`) — it has no interactive+ // form, and the server gives it no tuiCommandLine.+ { id: 'claude-code', name: 'Claude Code CLI', type: 'cli', enabled: true },+ { id: 'ollama', name: 'Ollama', type: 'api', enabled: true },+ // A TUI whose command the server could not resolve is not launchable.+ tui({ id: 'unresolved', tuiCommandLine: undefined }),+ ]).map((p) => p.id);+ expect(ids).toEqual(['a']);+ });++ it('sorts by display name so the list is stable as providers toggle', () => {+ const ids = launchableProviders([+ tui({ id: 'z', name: 'Zed TUI' }),+ tui({ id: 'a', name: 'Antigravity TUI' }),+ tui({ id: 'm', name: 'MTPLX TUI' }),+ ]).map((p) => p.id);+ expect(ids).toEqual(['a', 'm', 'z']);+ });++ it('tolerates a missing provider list', () => {+ expect(launchableProviders(undefined)).toEqual([]);+ });+});++describe('ShellProviderLauncher', () => {+ it('launches by provider ID, never by typing the command line', () => {+ const onLaunch = open();+ fireEvent.click(screen.getByText('Claude Code TUI'));+ // The ID is the whole point: the server pairs it with the provider's env.+ expect(onLaunch).toHaveBeenCalledWith('claude-code-tui');+ });++ it('shows the resolved command line so the user sees what will run', () => {+ open();+ expect(screen.getByText('claude --dangerously-skip-permissions')).toBeTruthy();+ });++ it('closes the menu after a launch', () => {+ open();+ fireEvent.click(screen.getByText('Claude Code TUI'));+ expect(screen.queryByText('Claude Code TUI')).toBeNull();+ });++ it('points at the Providers page when nothing is enabled', () => {+ render(<ShellProviderLauncher providers={[tui({ enabled: false })]} onLaunch={vi.fn()} />);+ fireEvent.click(screen.getByLabelText('Launch an AI CLI'));+ expect(screen.getByText(/No enabled TUI providers/)).toBeTruthy();+ });++ it('flags a provider the server says cannot run here, but still offers it', () => {+ const onLaunch = open({ providers: [tui({ prerequisitesMet: false })] });+ expect(screen.getByText('setup')).toBeTruthy();+ fireEvent.click(screen.getByText('Claude Code TUI'));+ expect(onLaunch).toHaveBeenCalledWith('claude-code-tui');+ });++ it('offers no filter box for a short list', () => {+ open();+ expect(screen.queryByLabelText('Filter providers')).toBeNull();+ });++ // The host loads /api/providers lazily — a Shell visit that never opens this+ // menu must not pay for the biggest payload on the page.+ it('asks the host to load providers on open, not on mount', () => {+ const onOpen = vi.fn();+ render(<ShellProviderLauncher providers={[]} onLaunch={vi.fn()} onOpen={onOpen} loading />);+ expect(onOpen).not.toHaveBeenCalled();+ fireEvent.click(screen.getByLabelText('Launch an AI CLI'));+ expect(onOpen).toHaveBeenCalled();+ // An in-flight load reads as loading, not as "you have no providers".+ expect(screen.getByText(/Loading providers/)).toBeTruthy();+ expect(screen.queryByText(/No enabled TUI providers/)).toBeNull();+ });++ it('filters a long list on name, id, or command line', () => {+ const many = [+ tui({ id: 'opencode-ollama-tui', name: 'OpenCode Ollama TUI', tuiCommandLine: 'opencode' }),+ tui({ id: 'codex-tui', name: 'Codex TUI', tuiCommandLine: 'codex --dangerously-bypass-approvals-and-sandbox' }),+ tui({ id: 'antigravity-tui', name: 'Antigravity TUI', tuiCommandLine: 'agy --dangerously-skip-permissions' }),+ tui({ id: 'grok-tui', name: 'Grok Build TUI', tuiCommandLine: 'grok' }),+ tui({ id: 'kimi-tui', name: 'Kimi Code TUI', tuiCommandLine: 'kimi --yolo' }),+ tui({ id: 'cursor-tui', name: 'Cursor Agent TUI', tuiCommandLine: 'cursor-agent --force' }),+ ];+ open({ providers: many });+ const filter = screen.getByLabelText('Filter providers');++ fireEvent.change(filter, { target: { value: 'ollama' } });+ expect(screen.getByText('OpenCode Ollama TUI')).toBeTruthy();+ expect(screen.queryByText('Codex TUI')).toBeNull();++ // Matches the command line, not just the display name — `agy` is how the+ // user knows Antigravity.+ fireEvent.change(filter, { target: { value: 'agy' } });+ expect(screen.getByText('Antigravity TUI')).toBeTruthy();+ expect(screen.queryByText('OpenCode Ollama TUI')).toBeNull();++ // Multi-word, any-order — the shared matcher, so this box behaves like+ // every other filter in the app.+ fireEvent.change(filter, { target: { value: 'tui opencode' } });+ expect(screen.getByText('OpenCode Ollama TUI')).toBeTruthy();+ expect(screen.queryByText('Codex TUI')).toBeNull();++ fireEvent.change(filter, { target: { value: 'nothing-matches' } });+ expect(screen.getByText(/No providers match/)).toBeTruthy();+ });++ it('closes on Escape', () => {+ open();+ fireEvent.keyDown(window, { key: 'Escape' });+ expect(screen.queryByText('Claude Code TUI')).toBeNull();+ });+});diff --git a/client/src/hooks/useShellSession.js b/client/src/hooks/useShellSession.jsindex 33c1ac8362..844bcd0408 100644--- a/client/src/hooks/useShellSession.js+++ b/client/src/hooks/useShellSession.js@@ -429,7 +429,12 @@ export function useShellSession({ isFullscreen } = {}) {// intent: 'push' arms the next activateSession to push a history entry. Only set AFTER the// socket-connected guard so a disconnected call doesn't leak the intent into a later auto-activation.- const startSession = useCallback(({ intent } = {}) => {+ //+ // `launch` ({ cwd?, cmd?, provider? }) is the in-page caller's version of what+ // initialOptsRef carries for a `?cwd=/?cmd=/?provider=` deep link. Passing it+ // as an argument rather than parking it in the ref is what keeps a start that+ // never fires from arming the NEXT one with someone else's provider.+ const startSession = useCallback(({ intent, launch } = {}) => {if (!socket?.connected) return;if (intent === 'push') pendingNavIntentRef.current = 'push';setPendingAttach('new');@@ -445,7 +450,7 @@ export function useShellSession({ isFullscreen } = {}) {termInstanceRef.current.reset();termInstanceRef.current.writeln('\x1b[36mStarting shell session...\x1b[0m');}- const opts = initialOptsRef.current || {};+ const opts = launch || initialOptsRef.current || {};const startOpts = {};if (opts.cwd) startOpts.cwd = opts.cwd;if (opts.cmd) startOpts.initialCommand = opts.cmd;@@ -567,6 +572,18 @@ export function useShellSession({ isFullscreen } = {}) {startSession({ intent: 'push' });}, [startSession]);+ // Launch a configured TUI provider from the Shell page's provider menu — the+ // in-page twin of the AI Providers page's `?provider=` deep link. Always a NEW+ // session, and always by ID rather than by command line; the reason is in+ // `components/shell/ShellProviderLauncher.jsx`. The displayed session's cwd+ // rides along so a launch lands in the folder the user already cd'd to rather+ // than back at $HOME.+ const launchProvider = useCallback((providerId) => {+ if (!providerId) return;+ const cwd = sessionsRef.current.find(s => s.sessionId === sessionIdRef.current)?.cwd;+ startSession({ intent: 'push', launch: { provider: providerId, cwd } });+ }, [startSession]);+// Handle socket connection and shell session eventsuseEffect(() => {if (!socket) return;@@ -904,6 +921,7 @@ export function useShellSession({ isFullscreen } = {}) {restartSession,stopSession,startNewSession,+ launchProvider,switchToSession,killOtherSession,};diff --git a/client/src/hooks/useShellSession.test.jsx b/client/src/hooks/useShellSession.test.jsxindex 07e90e3017..73c6a3fc1e 100644--- a/client/src/hooks/useShellSession.test.jsx+++ b/client/src/hooks/useShellSession.test.jsx@@ -232,6 +232,36 @@ describe('useShellSession', () => {});});+ // The Shell page's provider launch menu. The ID is what crosses the wire —+ // the server pairs it with the provider's own env, which a typed command line+ // would leave behind (and which is secret, so it can't cross at all).+ describe('launchProvider', () => {+ it('starts a new session by provider ID, inheriting the displayed cwd', () => {+ const { result } = attachedTo('s1', [session('s1', { cwd: '/repos/example-app' })]);+ act(() => { result.current.launchProvider('claude-code-tui'); });+ expect(lastEmit('shell:start')).toEqual([+ 'shell:start', { cwd: '/repos/example-app', providerId: 'claude-code-tui' },+ ]);+ });++ it('omits cwd when the displayed session reports none', () => {+ const { result } = attachedTo('s1', [session('s1')]);+ act(() => { result.current.launchProvider('codex-tui'); });+ expect(lastEmit('shell:start')).toEqual(['shell:start', { providerId: 'codex-tui' }]);+ });++ it('never emits — and never arms a stale launch — without a provider id', () => {+ const { result } = attachedTo('s1', [session('s1')]);+ const before = emitted.length;+ act(() => { result.current.launchProvider(''); });+ expect(emitted.length).toBe(before);+ // The id must not have been parked in the pending-opts slot either: a+ // later plain "New" would otherwise spawn the provider instead of a shell.+ act(() => { result.current.startNewSession(); });+ expect(lastEmit('shell:start')).toEqual(['shell:start', undefined]);+ });+ });+// Restart asks for a *replacement* shell, so it must not run the survivor// adoption path even when another shell is free.describe('restartSession', () => {diff --git a/client/src/pages/Shell.jsx b/client/src/pages/Shell.jsxindex e986dea61a..baa8c058b0 100644--- a/client/src/pages/Shell.jsx+++ b/client/src/pages/Shell.jsx@@ -2,16 +2,24 @@ import { useEffect, useRef, useState, useCallback } from 'react';import { RefreshCw, Power, PowerOff, FolderOpen, ChevronDown, Bot, Maximize2, Minimize2 } from 'lucide-react';import * as api from '../services/api';import { readClipboard } from '../lib/clipboard';+import useClickOutside from '../hooks/useClickOutside';+import useEscapeKey from '../hooks/useEscapeKey';import { useShellSession, MAX_SESSIONS } from '../hooks/useShellSession';import TerminalHotKeys from '../components/shell/TerminalHotKeys';import ShellSessionTabs from '../components/shell/ShellSessionTabs';+import ShellProviderLauncher from '../components/shell/ShellProviderLauncher';import InfoTooltip from '../components/ui/InfoTooltip';+// Typed-into-the-current-session shortcuts only. The AI CLIs that used to sit+// here as hardcoded buttons (claude / codex / agy / grok) now come from the+// enabled TUI providers via ShellProviderLauncher — a dynamic list that scales+// past a row of buttons and, unlike a typed command line, carries each+// provider's own backend env.+//+// `openclaw` is the one holdout, because PortOS ships no provider record for it.+// A new AI CLI belongs in `providers.sample.json` as a TUI provider, where the+// launcher picks it up for free — do not grow this list back.const QUICK_COMMANDS = [- { label: 'claude', command: 'claude --dangerously-skip-permissions' },- { label: 'codex', command: 'codex --dangerously-bypass-approvals-and-sandbox' },- { label: 'agy', command: 'agy' },- { label: 'grok', command: 'grok' },{ label: 'openclaw', command: 'openclaw tui' },// Claude Code slash-command shortcuts — typed + submitted into an interactive// `claude` session. The flags are double-dash (`--`); keep them verbatim.@@ -25,6 +33,8 @@ export default function Shell() {// where the header/tabs/quick-commands otherwise eat most of the screen.const [isFullscreen, setIsFullscreen] = useState(false);const [appFolders, setAppFolders] = useState([]);+ const [providers, setProviders] = useState({ list: [], loading: false });+ const providersRequestedRef = useRef(false);const [folderDropdownOpen, setFolderDropdownOpen] = useState(false);const [showPasteInput, setShowPasteInput] = useState(false);const pasteInputRef = useRef(null);@@ -50,6 +60,7 @@ export default function Shell() {restartSession,stopSession,startNewSession,+ launchProvider,switchToSession,killOtherSession,} = useShellSession({ isFullscreen });@@ -66,17 +77,32 @@ export default function Shell() {.catch(err => console.warn('fetch app folders:', err?.message ?? String(err)));}, []);- // Close dropdown on outside click- useEffect(() => {- const handleClickOutside = (e) => {- if (dropdownRef.current && !dropdownRef.current.contains(e.target)) {- setFolderDropdownOpen(false);- }- };- document.addEventListener('mousedown', handleClickOutside);- return () => document.removeEventListener('mousedown', handleClickOutside);+ // The launch menu's source of truth, loaded on the first open rather than at+ // mount: `/api/providers` is the biggest payload this page could pull and most+ // Shell visits are plain terminal work that never opens the menu. State lives+ // on the page, not in the launcher, because the launcher unmounts on every+ // fullscreen toggle and would otherwise refetch each time.+ //+ // `silent` — the page is usable without it; the menu just says there's nothing+ // to launch, and a toast would land on top of the terminal.+ const loadProviders = useCallback(() => {+ if (providersRequestedRef.current) return;+ providersRequestedRef.current = true;+ setProviders(prev => ({ ...prev, loading: true }));+ api.getProviders({ silent: true })+ .then(res => setProviders({ list: res?.providers || [], loading: false }))+ .catch(err => {+ console.warn('fetch providers:', err?.message ?? String(err));+ // Re-armed, so the next open retries rather than showing an empty menu forever.+ providersRequestedRef.current = false;+ setProviders({ list: [], loading: false });+ });}, []);+ const closeFolderDropdown = useCallback(() => setFolderDropdownOpen(false), []);+ useClickOutside(dropdownRef, folderDropdownOpen, closeFolderDropdown);+ useEscapeKey(folderDropdownOpen, closeFolderDropdown);+const handlePaste = useCallback(async () => {const text = await readClipboard();if (text == null) { setShowPasteInput(true); return; }@@ -94,6 +120,14 @@ export default function Shell() {if (showPasteInput) pasteInputRef.current?.focus();}, [showPasteInput]);+ // The two toolbars render the same hot-key strip with the same ten props and+ // differ only in which way its popover opens; spread one object so a new prop+ // reaches both.+ const hotKeyProps = {+ sendCtrlB, sendCtrlC, handlePaste, sendNavKey, scrollPage,+ showPasteInput, setShowPasteInput, pasteInputRef, handlePasteInputEvent, sendImage,+ };+const statusLabel = connected ? 'Connected' : 'Disconnected';return (@@ -201,23 +235,19 @@ export default function Shell() {{/* Quick commands toolbar — one horizontally-scrollable row rather than awrapping grid, so it costs a fixed ~40px of vertical space no matter howmany quick commands there are. The folder dropdown sits OUTSIDE the- scroller: an absolutely-positioned menu is clipped by `overflow-x-auto`. */}+ scroller: an absolutely-positioned menu is clipped by `overflow-x-auto`.+ The provider launcher portals its panel, so it rides inside. */}{!isFullscreen && connected && (<div className="flex items-center gap-2"><div className="flex items-center gap-2 flex-1 min-w-0 overflow-x-auto scrollbar-hide touch-pan-x">- <TerminalHotKeys- sendCtrlB={sendCtrlB}- sendCtrlC={sendCtrlC}- handlePaste={handlePaste}- sendNavKey={sendNavKey}- scrollPage={scrollPage}- showPasteInput={showPasteInput}- setShowPasteInput={setShowPasteInput}- pasteInputRef={pasteInputRef}- handlePasteInputEvent={handlePasteInputEvent}- sendImage={sendImage}- />+ <TerminalHotKeys {...hotKeyProps} /><div className="w-px h-6 bg-port-border shrink-0" />+ <ShellProviderLauncher+ providers={providers.list}+ loading={providers.loading}+ onOpen={loadProviders}+ onLaunch={launchProvider}+ />{QUICK_COMMANDS.map(({ label, command }) => (<buttonkey={label}@@ -237,6 +267,8 @@ export default function Shell() {className="flex items-center gap-1.5 px-2.5 py-1.5 bg-port-card hover:bg-port-border text-gray-300 hover:text-white rounded text-xs transition-colors border border-port-border min-h-[40px]"title="cd to app folder"aria-label="cd to app folder"+ aria-expanded={folderDropdownOpen}+ aria-haspopup="menu"><FolderOpen size={14} /><span className="hidden sm:inline">cd to app</span>@@ -277,7 +309,7 @@ export default function Shell() {{/* Fullscreen control bar — compact, single-row, horizontally scrollable sothe TUI-driving keys stay reachable by thumb without the stacked toolbars. */}{isFullscreen && (- <div className="flex items-center gap-1.5 mt-2 overflow-x-auto pb-1">+ <div className="flex items-center gap-1.5 mt-2 overflow-x-auto scrollbar-hide touch-pan-x pb-1"><buttononClick={() => setIsFullscreen(false)}className="flex items-center gap-1.5 px-3 py-1.5 bg-port-card hover:bg-port-border text-gray-300 hover:text-white rounded text-xs transition-colors border border-port-border min-h-[40px] shrink-0"@@ -289,20 +321,18 @@ export default function Shell() {</button><div className="w-px h-6 bg-port-border shrink-0" />{connected && (- <TerminalHotKeys- sendCtrlB={sendCtrlB}- sendCtrlC={sendCtrlC}- handlePaste={handlePaste}- sendNavKey={sendNavKey}- scrollPage={scrollPage}- showPasteInput={showPasteInput}- setShowPasteInput={setShowPasteInput}- pasteInputRef={pasteInputRef}- handlePasteInputEvent={handlePasteInputEvent}- sendImage={sendImage}- /* Opens upward — this bar is pinned to the bottom of the viewport. */- popoverPlacement="above"- />+ <>+ {/* Both popovers open upward — this bar is pinned to the bottom of+ the viewport — and both portal out, so this scroller can't clip them. */}+ <TerminalHotKeys {...hotKeyProps} popoverPlacement="above" />+ <ShellProviderLauncher+ providers={providers.list}+ loading={providers.loading}+ onOpen={loadProviders}+ onLaunch={launchProvider}+ placement="above"+ />+ </>)}</div>)}diff --git a/client/src/utils/README.md b/client/src/utils/README.mdindex f04d347a1a..9f3ad5ed58 100644--- a/client/src/utils/README.md+++ b/client/src/utils/README.md@@ -41,7 +41,7 @@ grep -i "what you want to do" client/src/utils/README.md| `urlNormalize` | `isUrl` detection, `normalizeUrl` (optional git/`requireDot` modes), `isHttpUrl` (explicit http(s) only — safe-href check), and `tiktokVideoId` / `tiktokEmbedSrc` (host-anchored TikTok video-id extraction + its Embed Player URL, so a reference embeds without loading TikTok's embed.js). || `platform` | `isMac` detection and `modKey` (⌘/Ctrl) for keyboard-shortcut display. || `navWorkingSet` | Recent/pinned nav persistence (`recordVisit`, `togglePin`, `isPinned`) plus `resolveRecentNavEntries` for mapping stored deep links back to their longest matching nav-manifest entry. Also `migrateLegacyNavPath(path, commands)` — maps a stored path onto the CURRENT path of the page that used to answer to it, driven by each command's own `previousPaths` (declared in `server/lib/navManifest.js` beside the page that moved, shipped whole in the palette manifest). A pin is a stored route path, so without it a moved page's pin stops matching the manifest and the sidebar row silently vanishes on update. |-| `providers` | AI-provider type predicates and helpers (`isCliProvider`, `isApiProvider`, `isCodexProvider`, `isAntigravityProvider`, `PROVIDER_GATEWAYS` / `gatewayForProvider` / `isGatewayBackedProvider` (an OpenCode wrapper front-ending a hosted OpenAI-compatible gateway — `orcarouter`, `openrouter` — which inherits its API key at spawn time from the sibling API provider whose id equals the gateway id; reads the generic `gatewayBacked` marker and, forever, the legacy per-gateway boolean. MIRROR of `server/lib/providerGateways.js`, which the browser cannot import; keep the three copies in lockstep), `filterSelectableModels`, `resolveCliEffort` (mirror — what a stored effort actually runs as, so the picker can name a clamped level), `configuredDefaultIn` — the sentinel a provider's catalog carries, so a picker can render an option matching a sentinel-valued tier instead of a blank select — `getProviderTimeout`, `resolveEffectiveProvider` — the provider a record actually runs on (its pin, else the active provider) plus whether it fell back, so a "Default" option can name what it resolves to — `resolveSeriesRunLlm` (mirror of server `seriesLlmOverride.js`: which provider/model a Pipeline **series** run resolves to — per-run override → `series.llm` → active provider) and `providerModelLabel` (the one "Provider / model" phrasing), configured-default sentinels, and the claude/codex/agy thinking-effort levels — `effortLevelsForProvider`, mirror of server `providerModels.js`). Also `isRunnerAllowedCommand(command, allowedCommands)` — would the CoS Agent Runner (`/spawn`, `/spawn-tui`) accept this command? Mirrors only the *normalization* in `server/cos-runner/allowedCommands.js` (the list itself arrives as `runnerAllowedCommands` on `GET /api/providers`, because the allowlist is an exec boundary and stays hand-curated server-side); returns `null` for "list not fetched / field blank" so a failed fetch never renders a warning. Pinned by `server/cos-runner/allowedCommands.parity.test.js`. `isPrivateNetworkEndpoint(endpoint)` — loopback, RFC1918/tailnet address, or a `.local`/`.ts.net`/single-label host, i.e. somewhere an unauthenticated OpenAI-compatible server is a normal setup rather than a missing API key. `isLocalInstanceProvider(provider)` — the narrower question, mirroring server `localProviderRuntime.js#isLocalInstanceEndpoint`: does this provider talk to a daemon on THIS machine (loopback, or no endpoint at all)? Gate anything that explains a provider by inspecting the host PortOS runs on — install state, "start it from Settings → Local LLM" — since `localBackendForProvider` matches by NAME and would otherwise claim a peer's LM Studio. And `credentialSource(provider)` plus `providerCardState(provider, { runtime, status, keySetFor, envVarSet })` + `PROVIDER_CARD_STATE` — is a provider ready to run, benched, blocked on a missing prerequisite (CLI not installed / API key absent / empty credential environment variable), or simply switched off? Reads the SERVER's `missingPrerequisites` (published per provider on `GET /api/providers` from `server/lib/providerPrerequisites.js`, and the same computation `getFallbackProvider` routes on) and adds the local-app runtime shape plus tri-state checks for stored, inherited, and process environment credentials. Unknown lookup values mean "not probed", never "missing". Drives the AI Providers page card colors and grouping — distinct from `ProviderReadiness`/`GET /api/providers/readiness`, which probes the local daemon behind a provider. `resolvesOutsidePortosPath(provider)` — does this provider resolve its binary somewhere the runtime probe never looked (an explicit path in `command`, or its own `PATH` in `envVars`)? Mirror of the same two guards in the server's `providerRuntimeKey`, and what keeps the card's badge from accusing a working provider the router happily routes. And `providerRuntimeKey(provider)` — the key a provider's runtime is published under by `GET /api/providers/runtimes`, so a card can show its CLI install status (bare binary name for a cli/tui provider, provider id for an API provider fronted by a local app); the runtime table itself stays server-side. |+| `providers` | AI-provider type predicates and helpers (`isCliProvider`, `isApiProvider`, `isCodexProvider`, `isAntigravityProvider`, `isLaunchableTuiProvider` — a TUI provider carrying the server-resolved `tuiCommandLine`, i.e. one a human can start at a shell prompt; shared by the Providers card's "Launch in Shell" button and the Shell page's launch menu so the two can't disagree — `PROVIDER_GATEWAYS` / `gatewayForProvider` / `isGatewayBackedProvider` (an OpenCode wrapper front-ending a hosted OpenAI-compatible gateway — `orcarouter`, `openrouter` — which inherits its API key at spawn time from the sibling API provider whose id equals the gateway id; reads the generic `gatewayBacked` marker and, forever, the legacy per-gateway boolean. MIRROR of `server/lib/providerGateways.js`, which the browser cannot import; keep the three copies in lockstep), `filterSelectableModels`, `resolveCliEffort` (mirror — what a stored effort actually runs as, so the picker can name a clamped level), `configuredDefaultIn` — the sentinel a provider's catalog carries, so a picker can render an option matching a sentinel-valued tier instead of a blank select — `getProviderTimeout`, `resolveEffectiveProvider` — the provider a record actually runs on (its pin, else the active provider) plus whether it fell back, so a "Default" option can name what it resolves to — `resolveSeriesRunLlm` (mirror of server `seriesLlmOverride.js`: which provider/model a Pipeline **series** run resolves to — per-run override → `series.llm` → active provider) and `providerModelLabel` (the one "Provider / model" phrasing), configured-default sentinels, and the claude/codex/agy thinking-effort levels — `effortLevelsForProvider`, mirror of server `providerModels.js`). Also `isRunnerAllowedCommand(command, allowedCommands)` — would the CoS Agent Runner (`/spawn`, `/spawn-tui`) accept this command? Mirrors only the *normalization* in `server/cos-runner/allowedCommands.js` (the list itself arrives as `runnerAllowedCommands` on `GET /api/providers`, because the allowlist is an exec boundary and stays hand-curated server-side); returns `null` for "list not fetched / field blank" so a failed fetch never renders a warning. Pinned by `server/cos-runner/allowedCommands.parity.test.js`. `isPrivateNetworkEndpoint(endpoint)` — loopback, RFC1918/tailnet address, or a `.local`/`.ts.net`/single-label host, i.e. somewhere an unauthenticated OpenAI-compatible server is a normal setup rather than a missing API key. `isLocalInstanceProvider(provider)` — the narrower question, mirroring server `localProviderRuntime.js#isLocalInstanceEndpoint`: does this provider talk to a daemon on THIS machine (loopback, or no endpoint at all)? Gate anything that explains a provider by inspecting the host PortOS runs on — install state, "start it from Settings → Local LLM" — since `localBackendForProvider` matches by NAME and would otherwise claim a peer's LM Studio. And `credentialSource(provider)` plus `providerCardState(provider, { runtime, status, keySetFor, envVarSet })` + `PROVIDER_CARD_STATE` — is a provider ready to run, benched, blocked on a missing prerequisite (CLI not installed / API key absent / empty credential environment variable), or simply switched off? Reads the SERVER's `missingPrerequisites` (published per provider on `GET /api/providers` from `server/lib/providerPrerequisites.js`, and the same computation `getFallbackProvider` routes on) and adds the local-app runtime shape plus tri-state checks for stored, inherited, and process environment credentials. Unknown lookup values mean "not probed", never "missing". Drives the AI Providers page card colors and grouping — distinct from `ProviderReadiness`/`GET /api/providers/readiness`, which probes the local daemon behind a provider. `resolvesOutsidePortosPath(provider)` — does this provider resolve its binary somewhere the runtime probe never looked (an explicit path in `command`, or its own `PATH` in `envVars`)? Mirror of the same two guards in the server's `providerRuntimeKey`, and what keeps the card's badge from accusing a working provider the router happily routes. And `providerRuntimeKey(provider)` — the key a provider's runtime is published under by `GET /api/providers/runtimes`, so a card can show its CLI install status (bare binary name for a cli/tui provider, provider id for an API provider fronted by a local app); the runtime table itself stays server-side. || `layeredIntelligenceReasons` | Canonical gloss for the Layered Intelligence loop's run-outcome reason tokens, shared by the on-demand toast and the durable "Last run" line (`formatLiReason`, `liReasonTone`, `LI_NEUTRAL_REASONS`). |## Module loading / resiliencediff --git a/client/src/utils/providers.js b/client/src/utils/providers.jsindex 484ce9b1d4..2dab0961af 100644--- a/client/src/utils/providers.js+++ b/client/src/utils/providers.js@@ -854,6 +854,21 @@ export const modelOptionLabel = (id, ctxById) => {*/export const isTuiProvider = (provider) => provider?.type === PROVIDER_TYPES.TUI;+/**+ * Can a human launch this provider at a shell prompt?+ *+ * TUI is the only type that has an interactive form — a `cli` provider's args+ * are headless (`--print`), and an `api` provider has no local binary at all.+ * `tuiCommandLine` is the server's own resolution of what the launch will run+ * (`server/lib/tuiShellLaunch.js`, published by `GET /api/providers`), so a+ * provider it could not resolve a command for is not offered, and an older+ * server that omits the field simply offers nothing.+ *+ * Shared so the AI Providers card's "Launch in Shell" button and the Shell+ * page's launch menu can't disagree about which providers are launchable.+ */+export const isLaunchableTuiProvider = (provider) => isTuiProvider(provider) && Boolean(provider?.tuiCommandLine);+/*** Check if a provider is a one-shot CLI agent provider.*/diff --git a/client/src/utils/providers.test.js b/client/src/utils/providers.test.jsindex 8eba7bc330..0347927168 100644--- a/client/src/utils/providers.test.js+++ b/client/src/utils/providers.test.js@@ -29,6 +29,7 @@ import {mergeModelLists,modelOptionLabel,isTuiProvider,+ isLaunchableTuiProvider,isCliProvider,isApiProvider,isProcessProvider,@@ -464,6 +465,18 @@ describe('provider type predicates', () => {expect(isTuiProvider(api)).toBe(false);});+ // Shared by the Providers card's "Launch in Shell" button and the Shell page's+ // launch menu, so the two can't disagree about what is launchable.+ it('isLaunchableTuiProvider needs a TUI AND a server-resolved command line', () => {+ expect(isLaunchableTuiProvider({ ...tui, tuiCommandLine: 'claude --dangerously-skip-permissions' })).toBe(true);+ // A TUI the server resolved no command for, or an older server that omits+ // the field entirely, is not offered.+ expect(isLaunchableTuiProvider(tui)).toBe(false);+ expect(isLaunchableTuiProvider({ ...cli, tuiCommandLine: 'claude' })).toBe(false);+ expect(isLaunchableTuiProvider({ ...api, tuiCommandLine: 'x' })).toBe(false);+ expect(isLaunchableTuiProvider(null)).toBe(false);+ });+it('isCliProvider matches only cli providers', () => {expect(isCliProvider(cli)).toBe(true);expect(isCliProvider(tui)).toBe(false);