Your own team of AI bots in one self-hosted binary: spaces, every account you have, handoffs, approvals and routines. Open-source, self-hosted alternative to Grok Bot, Claude Duet and OpenAI dots. Rust + React.
Rust ai-agentsai-assistantai-botautomationbotbots-teamchatbotclaude-duetgrokgrok-botgrok-bot-alternativeharnessllmmulti-agentopenai-dotsopenbotpersonal-agentrustself-hostedselfhosted-ai
UX PR 2: one Inbox, one bot list, one switcher, one Settings
Pixel (kwant bot)aaf478efaad6
diff --git a/frontend/src/App.tsx b/frontend/src/App.tsxindex 64728f7c..44540a7f 100644--- a/frontend/src/App.tsx+++ b/frontend/src/App.tsx@@ -2,6 +2,8 @@ import React, { Suspense, lazy, useState, useEffect, useRef, useCallback, useMemimport { DecidingMap, applyDecideEvent, decisionsApi, hydrateDeciding } from './decideFirst';import { Sidebar, Kwant, Channel, Team, memberIdsOf } from './components/Sidebar';import { SpaceSettings, SpaceSettingsTab } from './components/SpaceSettings';+import { InboxPage } from './components/InboxPage';+import { InboxTab, SettingsScope, SpaceView, viewSegment } from './nav';import { FirstRunWelcome } from './components/FirstRunWelcome';import { SpaceTile } from './components/Spaces';import { ChatView, ChatMessage, DiscussionState, RoutingState, QueuedState } from './components/ChatView';@@ -118,7 +120,7 @@ const ChannelInstructionsModal = lazy(() =>import('./components/ChannelInstructionsModal').then((m) => ({ default: m.ChannelInstructionsModal })),);const SearchModal = lazy(() => import('./components/SearchModal').then((m) => ({ default: m.SearchModal })));-const RoutinesModal = lazy(() => import('./components/RoutinesModal').then((m) => ({ default: m.RoutinesModal })));+const SettingsModal = lazy(() => import('./components/SettingsModal').then((m) => ({ default: m.SettingsModal })));/** Where to land when a space opens: a channel or a bot's direct chat. */export interface SpaceTarget {@@ -130,18 +132,21 @@ export interface SpaceAppProps {space: Space;spaces: Space[];initialTarget: SpaceTarget | null;- /** Space settings open on this tab when the space mounts (Accounts, right after creating it). */- initialSettingsTab?: SpaceSettingsTab | null;+ /** Where to open instead of a chat when the space mounts: an address like /inbox or+ * /settings/accounts (Accounts, right after creating a space). */+ initialView?: SpaceView | null;+ /** Asks the open space to show a view (the rail's gear, Back and Forward). `seq` makes a repeat count. */+ viewRequest?: { view: SpaceView | null; seq: number } | null;+ /** The view shown changed (null: a chat), for the address bar. */+ onViewChange?: (view: SpaceView | null) => void;onSwitchSpace: (id: string, to?: SpaceTarget | null) => void;onCreateSpace: () => void;onOpenArchived: () => void;- onOpenAppSettings: () => void;/** Re-reads the space list (counts, #general appearing, a rename). */onSpacesChanged: () => void;onSpaceArchived: (space: Space) => void;/** The open chat changed, for the address bar and reopening it later. */onChatChange: (target: SpaceTarget) => void;- onTokensUsed: (n: number) => void;}const PHONE_QUERY = '(max-width: 767px)';@@ -166,15 +171,15 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({space,spaces,initialTarget,- initialSettingsTab = null,+ initialView = null,+ viewRequest = null,+ onViewChange,onSwitchSpace,onCreateSpace,onOpenArchived,- onOpenAppSettings,onSpacesChanged,onSpaceArchived,onChatChange,- onTokensUsed,}) => {const isPhone = useIsPhone();// Phones: the list (one tab of it) or the open chat.@@ -261,8 +266,11 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({};const [tokensUsed, setTokensUsed] = useState(0);- // Space settings: open on one tab, or closed.- const [spaceSettingsTab, setSpaceSettingsTab] = useState<SpaceSettingsTab | null>(initialSettingsTab);+ // Settings: open on This space (one tab) or All spaces, or closed (tab null).+ const [spaceSettingsTab, setSpaceSettingsTab] = useState<SpaceSettingsTab | null>(() =>+ initialView?.kind === 'settings' ? (initialView.scope === 'space' ? initialView.tab : 'general') : null,+ );+ const [settingsScope, setSettingsScope] = useState<SettingsScope>(() => (initialView?.kind === 'settings' ? initialView.scope : 'space'));// Bumped when Space settings closes, so open bot forms read account status again.const [settingsClosedCount, setSettingsClosedCount] = useState(0);// Set when Accounts opens from a "Sign in with Claude" hint, to focus that button.@@ -272,21 +280,21 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({const openSpaceSettings = (tab: SpaceSettingsTab = 'general') => {setClaudeSignInFocus(0);if (tab !== 'routines') setRoutineFocus(null);+ setSettingsScope('space');setSpaceSettingsTab(tab);playSfx('click');};- const openSettings = () => openSpaceSettings('accounts');- const openConnections = () => {- setShowConnections(true);- setShowLoose(false);- setShowParallel(false);- setShowMissions(false);- setShowAway(false);- setPhoneView('chat');+ // Settings › All spaces: what applies to every space and to the app.+ const openAppSettings = () => {+ setSettingsScope('app');+ setSpaceSettingsTab((t) => t ?? 'general');playSfx('click');};+ const openSettings = () => openSpaceSettings('accounts');+ const openConnections = () => openSpaceSettings('connections');const openClaudeSignIn = () => {setClaudeSignInFocus(Date.now());+ setSettingsScope('space');setSpaceSettingsTab('accounts');};// This space's engine checks, shared with the sidebar: the setup banner, the "can't answer"@@ -304,7 +312,6 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({// Connections' "+ Add connection" opens Tools straight on adding a server.const [mcpStartAdding, setMcpStartAdding] = useState(false);const [isSearchOpen, setIsSearchOpen] = useState(false);- const [isRoutinesOpen, setIsRoutinesOpen] = useState(false);const [editingChannelInstructions, setEditingChannelInstructions] = useState<Channel | null>(null);const [highlightMessageId, setHighlightMessageId] = useState<string | null>(null);// Older messages shown instead of the latest (a search hit beyond them). Kept apart from the@@ -312,13 +319,19 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({const [historyWindow, setHistoryWindow] = useState<{ ctx: string; messages: ChatMessage[] } | null>(null);const [profiles, setProfiles] = useState<Profile[]>([]);const [toasts, setToasts] = useState<Toast[]>([]);- // "While you were away": open instead of a chat, and its unseen count for the sidebar badge.- const [showAway, setShowAway] = useState(false);- const [showLoose, setShowLoose] = useState(false);- const [showConnections, setShowConnections] = useState(false);- const [showParallel, setShowParallel] = useState(false);+ // What fills the main pane instead of a chat: the Inbox (New or Loose ends), the Mission board+ // or Parallel Universe. The Inbox's unseen count is the sidebar badge.+ const [page, setPage] = useState<'chat' | 'inbox' | 'board' | 'parallel'>(() =>+ initialView?.kind === 'inbox' || initialView?.kind === 'board' || initialView?.kind === 'parallel' ? initialView.kind : 'chat',+ );+ const [inboxTab, setInboxTab] = useState<InboxTab>(() => (initialView?.kind === 'inbox' ? initialView.tab : 'new'));+ const showPage = (next: 'inbox' | 'board' | 'parallel', tab: InboxTab = 'new') => {+ setPage(next);+ if (next === 'inbox') setInboxTab(tab);+ if (spaceSettingsTab) closeSpaceSettings();+ setPhoneView('chat');+ };// Mission board: shown in the sidebar only when the server has it switched on.- const [showMissions, setShowMissions] = useState(false);const [missionBoard, setMissionBoard] = useState(false);const [awayCount, setAwayCount] = useState(0);const awaySinceRef = useRef<string | null>(null);@@ -346,14 +359,7 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({const openHumanStepRef = useRef<(kwantId: string) => boolean>(() => false);const openTargetRef = useRef<(t: ChatTarget) => boolean>(() => false);// A tier request or a fact dispute is decided on the board's Needs-you list.- const openBoardForTier = () => {- setShowMissions(true);- setShowConnections(false);- setShowLoose(false);- setShowParallel(false);- setShowAway(false);- setPhoneView('chat');- };+ const openBoardForTier = () => showPage('board');const showNotification = (n: NotifyEvent) => {// Another space's news is the shell's to show, with a way to switch there.if (n.space_id && n.space_id !== space.id) return;@@ -369,7 +375,7 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({: n.kind === 'skill_proposed'? { label: 'Review', onClick: () => openSkillsRef.current(n.kwant_id) }: n.kind === 'automation_suggested'- ? { label: 'Review', onClick: () => setIsRoutinesOpen(true) }+ ? { label: 'Review', onClick: () => openSpaceSettings('routines') }: n.kind === 'tier_proposed'? { label: 'Review', onClick: openBoardForTier }: n.kind === 'fact_disputed'@@ -391,7 +397,7 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({const target = { channel_id: n.channel_id, kwant_id: n.kwant_id };if (n.kind === 'skill_proposed') openSkillsRef.current(n.kwant_id);// A suggested routine is decided in Routines, not in the bot's chat- else if (n.kind === 'automation_suggested') setIsRoutinesOpen(true);+ else if (n.kind === 'automation_suggested') openSpaceSettings('routines');else if (n.kind === 'tier_proposed') openBoardForTier();else if (n.kind === 'fact_disputed') openBoardForTier();else if (n.kind === 'human_step' && openHumanStepRef.current(n.kwant_id)) {@@ -1431,11 +1437,7 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({const handleSelectTeam = (team: Team) => {setOpenThreadId(null);- setShowAway(false);- setShowLoose(false);- setShowConnections(false);- setShowParallel(false);- setShowMissions(false);+ setPage('chat');setPhoneView('chat');setSelectedTeamId(team.id);const targetChannel = teamChannelOf(channels, team);@@ -1471,11 +1473,7 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({const handleSelectChannel = (channel: Channel) => {setOpenThreadId(null);- setShowAway(false);- setShowLoose(false);- setShowConnections(false);- setShowParallel(false);- setShowMissions(false);+ setPage('chat');setPhoneView('chat');setSelectedId(channel.id);selectedIdRef.current = channel.id;@@ -1489,11 +1487,7 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({const handleSelectKwant = (kwant: Kwant) => {setOpenThreadId(null);- setShowAway(false);- setShowLoose(false);- setShowConnections(false);- setShowParallel(false);- setShowMissions(false);+ setPage('chat');setPhoneView('chat');setSelectedId(kwant.id);selectedIdRef.current = kwant.id;@@ -1506,11 +1500,7 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({/** Closes the page on top of the chat (board, Loose ends, Away…) and shows the chat pane. */const revealChat = () => {- setShowAway(false);- setShowLoose(false);- setShowConnections(false);- setShowParallel(false);- setShowMissions(false);+ setPage('chat');setPhoneView('chat');};@@ -1568,11 +1558,7 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({return;}knownThreadsRef.current.add(threadId);- setShowAway(false);- setShowLoose(false);- setShowConnections(false);- setShowParallel(false);- setShowMissions(false);+ setPage('chat');if (selectedIdRef.current !== kwant.id || isChannelRef.current) handleSelectKwant(kwant);else playSfx('click');setOpenThreadId(threadId);@@ -1585,11 +1571,7 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({if ('thread' in t) return openThread(t.kwant, t.thread);const ok = 'channel' in t ? openTarget({ channel_id: t.channel, kwant_id: null }) : openTarget({ channel_id: null, kwant_id: t.direct });if (!ok) return pushToast('That chat no longer exists.');- setShowAway(false);- setShowLoose(false);- setShowConnections(false);- setShowParallel(false);- setShowMissions(false);+ setPage('chat');};const openDirectChat = () => {@@ -2523,7 +2505,6 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({};- useEffect(() => onTokensUsed(tokensUsed), [tokensUsed, onTokensUsed]);// The address bar and "reopen where I was" follow the open chat.const chatChangeRef = useRef(onChatChange);@@ -2801,7 +2782,6 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({onOpenSpaceSettings={() => openSpaceSettings('general')}onOpenArchived={onOpenArchived}onOpenSearch={() => setIsSearchOpen(true)}- onOpenRoutines={() => setIsRoutinesOpen(true)}section={section}phone={isPhone}onOpenAccounts={openSettings}@@ -2841,48 +2821,21 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({setIsNewChannelOpen(true);playSfx('click');}}- awayCount={awayCount}- awayActive={showAway}- looseActive={showLoose}- parallelActive={showParallel}+ inboxCount={awayCount}+ inboxActive={page === 'inbox'}+ onOpenInbox={() => {+ showPage('inbox');+ playSfx('click');+ }}+ parallelActive={page === 'parallel'}onOpenParallel={() => {- setShowParallel(true);- setShowMissions(false);- setShowLoose(false);- setShowConnections(false);- setShowAway(false);- setPhoneView('chat');+ showPage('parallel');playSfx('click');}}- connectionsActive={showConnections}- onOpenConnections={openConnections}missionBoard={missionBoard}- missionsActive={showMissions}+ missionsActive={page === 'board'}onOpenMissions={() => {- setShowMissions(true);- setShowConnections(false);- setShowLoose(false);- setShowParallel(false);- setShowAway(false);- setPhoneView('chat');- playSfx('click');- }}- onOpenLooseEnds={() => {- setShowConnections(false);- setShowLoose(true);- setShowParallel(false);- setShowMissions(false);- setShowAway(false);- setPhoneView('chat');- playSfx('click');- }}- onOpenAway={() => {- setShowAway(true);- setShowLoose(false);- setShowConnections(false);- setShowParallel(false);- setShowMissions(false);- setPhoneView('chat');+ showPage('board');playSfx('click');}}/>@@ -2890,17 +2843,17 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({const away = (<AwayPage since={awaySinceRef.current} onSince={(t) => (awaySinceRef.current = t)} onOpen={openAwayItem} onCounts={setAwayCount} onApprovalResolved={dropApproval}- onBack={isPhone ? () => { setShowAway(false); setPhoneView('list'); } : undefined}/>);- const parallel = <ParallelPage onBack={isPhone ? () => { setShowParallel(false); setPhoneView('list'); } : undefined} />;+ const backToList = isPhone ? () => { setPage('chat'); setPhoneView('list'); } : undefined;+ const parallel = <ParallelPage onBack={backToList} />;const connectionsPage = (<ConnectionsPage- onBack={isPhone ? () => { setShowConnections(false); setPhoneView('list'); } : undefined}+ embeddedonOpenTools={() => setIsMcpOpen(true)}onAddTool={() => { setMcpStartAdding(true); setIsMcpOpen(true); }}onOpenAccounts={openSettings}- onOpenLooseEnds={() => { setShowConnections(false); setShowLoose(true); }}+ onOpenLooseEnds={() => showPage('inbox', 'loose')}/>);const missionNames = Object.fromEntries(kwants.map((k) => [k.id, k.name]));@@ -2917,7 +2870,7 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({spaceId={space.id}names={missionNames}avatars={missionAvatars}- onBack={isPhone ? () => { setShowMissions(false); setPhoneView('list'); } : undefined}+ onBack={backToList}onOpenChat={(t, place) => {const c = place ?? sourceChat(t);if (!c) return;@@ -2934,7 +2887,8 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({}}/>);- const loose = <LooseEndsPage onBack={isPhone ? () => { setShowLoose(false); setPhoneView('list'); } : undefined} onOpenChat={openThread} />;+ const loose = <LooseEndsPage onOpenChat={openThread} />;+ const inbox = <InboxPage tab={inboxTab} onTab={setInboxTab} count={awayCount} onBack={backToList} newPage={away} loosePage={loose} />;const chat = (<ChatViewtitle={chatTitle}@@ -3040,7 +2994,40 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({onChangeDecision={handleChangeDecision}/>);- const mainPane = needsSetup ? setupChecklist : showParallel ? parallel : showMissions && missionBoard ? missionsPage : showConnections ? connectionsPage : showLoose ? loose : showAway ? away : !loaded ? (+ // The view on screen, for the address bar; and views asked for from outside (the rail's gear,+ // Back and Forward). The board stays the view while its setting loads; the pane shows a chat if it's off.+ const currentView: SpaceView | null = spaceSettingsTab+ ? settingsScope === 'app'+ ? { kind: 'settings', scope: 'app' }+ : { kind: 'settings', scope: 'space', tab: spaceSettingsTab }+ : page === 'inbox'+ ? { kind: 'inbox', tab: inboxTab }+ : page === 'chat'+ ? null+ : { kind: page };+ const viewKey = currentView ? viewSegment(currentView) : '';+ const viewChangeRef = useRef(onViewChange);+ viewChangeRef.current = onViewChange;+ const currentViewRef = useRef(currentView);+ currentViewRef.current = currentView;+ useEffect(() => {+ viewChangeRef.current?.(currentViewRef.current);+ }, [viewKey]);+ const applyViewRef = useRef<(v: SpaceView | null) => void>(() => undefined);+ applyViewRef.current = (v) => {+ if (!v) {+ if (spaceSettingsTab) closeSpaceSettings();+ setPage('chat');+ return;+ }+ if (v.kind === 'settings') return v.scope === 'app' ? openAppSettings() : openSpaceSettings(v.tab);+ showPage(v.kind, v.kind === 'inbox' ? v.tab : 'new');+ };+ useEffect(() => {+ if (viewRequest) applyViewRef.current(viewRequest.view);+ }, [viewRequest?.seq]);++ const mainPane = needsSetup ? setupChecklist : page === 'parallel' ? parallel : page === 'board' && missionBoard ? missionsPage : page === 'inbox' ? inbox : !loaded ? (<main className="flex-1 flex items-center justify-center text-xs text-zinc-500"><Loader2 size={14} className="mr-2 animate-spin motion-reduce:animate-none" aria-hidden="true" /> Opening {space.name}…</main>@@ -3087,12 +3074,7 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({onClick={() => {playSfx('click');if (t.id === 'inbox') {- setShowAway(true);- setShowLoose(false);- setShowConnections(false);- setShowParallel(false);- setShowMissions(false);- setPhoneView('chat');+ showPage('inbox');return;}if (t.id === 'space') {@@ -3231,7 +3213,21 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({onNewTeam={() => setIsNewTeamOpen(true)}onManageTeam={(t) => setEditingTeam(t)}onOpenTools={() => setIsMcpOpen(true)}- onOpenAppSettings={onOpenAppSettings}+ scope={settingsScope}+ onScope={setSettingsScope}+ onOpenArchived={onOpenArchived}+ connections={connectionsPage}+ appSettings={+ <Suspense+ fallback={+ <p className="flex items-center gap-2 text-xs text-zinc-400">+ <Loader2 size={13} className="animate-spin motion-reduce:animate-none" /> Loading…+ </p>+ }+ >+ <SettingsModal embedded isOpen onClose={closeSpaceSettings} tokensUsed={tokensUsed} onOpenApiKeys={() => openSpaceSettings('accounts')} />+ </Suspense>+ }routineFocus={routineFocus}onApprovalsChanged={refreshRoster}onImported={() => {@@ -3255,17 +3251,10 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({onOpenConnections={() => {setIsMcpOpen(false);setMcpStartAdding(false);- setShowConnections(true);- setShowLoose(false);- setShowParallel(false);- setShowMissions(false);- setShowAway(false);- setPhoneView('chat');- playSfx('click');+ openConnections();}}/>{isSearchOpen && <SearchModal isOpen onClose={() => setIsSearchOpen(false)} kwants={kwants} onJump={handleJump} />}- {isRoutinesOpen && <RoutinesModal isOpen onClose={() => setIsRoutinesOpen(false)} kwants={kwants} channels={channels} onOpenSettings={onOpenAppSettings} />}</Suspense>{editingChannelInstructions && (diff --git a/frontend/src/Shell.tsx b/frontend/src/Shell.tsxindex 6bcfe490..b14c18c4 100644--- a/frontend/src/Shell.tsx+++ b/frontend/src/Shell.tsx@@ -1,10 +1,10 @@-// The app shell: the spaces, the rail, space dialogs and App settings. Everything inside a space+// The app shell: the spaces, the rail and space dialogs. Everything inside a space// lives in <SpaceApp key={space.id}>, so switching remounts it: fresh state, a fresh event stream// for the new space, and nothing from the old space can flash.-import React, { Suspense, lazy, useCallback, useEffect, useRef, useState } from 'react';+import React, { useCallback, useEffect, useRef, useState } from 'react';import { AlertTriangle, Loader2 } from 'lucide-react';import { SpaceApp, SpaceTarget } from './App';-import type { SpaceSettingsTab } from './components/SpaceSettings';+import { SpaceView, sameView } from './nav';import { ArchivedSpacesModal, NewSpaceModal, SpaceRail } from './components/Spaces';import { Toasts, Toast } from './components/Toasts';import { InstallHint } from './components/InstallHint';@@ -26,8 +26,6 @@ import {import { NotifyEvent, TOAST_KINDS, browserNotifyEnabled, notificationPermission, shouldShowOsNotification } from './continuity';import { isNotificationOpen, resyncPushOnLoad, showDeviceNotification, targetFromQuery } from './push';-const SettingsModal = lazy(() => import('./components/SettingsModal').then((m) => ({ default: m.SettingsModal })));-const POLL_MS = 15000;export const App: React.FC = () => {@@ -37,11 +35,17 @@ export const App: React.FC = () => {// Where to land in the space being opened (a link, a notification, the last chat there).const [target, setTarget] = useState<SpaceTarget | null>(null);const [creating, setCreating] = useState<Space[] | null>(null);- // Space settings tab the next space opens on: Accounts right after "Add accounts next".- const [startTab, setStartTab] = useState<SpaceSettingsTab | null>(null);+ // Where the next space opens instead of a chat: its address (/inbox, /settings/accounts…), or+ // Accounts right after "Add accounts next".+ const [startView, setStartView] = useState<SpaceView | null>(null);+ // A view for the open space to show: the rail's gear, Back and Forward.+ const [viewRequest, setViewRequest] = useState<{ view: SpaceView | null; seq: number } | null>(null);+ const requestView = useCallback((view: SpaceView | null) => setViewRequest((r) => ({ view, seq: (r?.seq ?? 0) + 1 })), []);+ // The view the open space shows (null: a chat), as last reported.+ const viewRef = useRef<SpaceView | null>(null);+ // The open chat, the address to return to when the view closes.+ const chatRef = useRef<SpaceTarget | null>(null);const [showArchived, setShowArchived] = useState(false);- const [appSettingsOpen, setAppSettingsOpen] = useState(false);- const [tokensUsed, setTokensUsed] = useState(0);const [toasts, setToasts] = useState<Toast[]>([]);const toastIdRef = useRef(0);const dismissToast = useCallback((id: number) => setToasts((prev) => prev.filter((t) => t.id !== id)), []);@@ -61,14 +65,17 @@ export const App: React.FC = () => {}, []);/** Opens a space: the request scope changes before the new space renders. */- const open = useCallback((id: string, to?: SpaceTarget | null, replace = false) => {+ const open = useCallback((id: string, to?: SpaceTarget | null, replace = false, view: SpaceView | null = null) => {const t = to ?? lastChat(id) ?? null;- setStartTab(null);+ setStartView(view);+ setViewRequest(null);+ viewRef.current = view;+ chatRef.current = t;setCurrentSpace(id);rememberSpace(id);setTarget(t);setCurrentId(id);- const path = spacePath(id, t ?? undefined);+ const path = spacePath(id, t ?? undefined, view ?? undefined);if (window.location.pathname !== path) {if (replace) window.history.replaceState(null, '', path);else window.history.pushState(null, '', path);@@ -84,8 +91,10 @@ export const App: React.FC = () => {const route = q ? { spaceId: q.spaceId, channelId: q.channelId ?? undefined, botId: q.botId ?? undefined } : parseSpacePath(window.location.pathname);const s = pickSpace(list, route.spaceId, lastSpace());if (!s) return;- const fromUrl = route.spaceId === s.id && (route.channelId || route.botId) ? { channelId: route.channelId, botId: route.botId } : null;- open(s.id, fromUrl, true);+ const here = route.spaceId === s.id;+ const fromUrl = here && (route.channelId || route.botId) ? { channelId: route.channelId, botId: route.botId } : null;+ // An old address (/away, /loose-ends, /connections…) opens its new place, rewritten in place.+ open(s.id, fromUrl, true, here && 'view' in route ? route.view ?? null : null);});}, [reload, open]);@@ -93,15 +102,26 @@ export const App: React.FC = () => {useEffect(() => {const onPop = () => {const route = parseSpacePath(window.location.pathname);- if (route.spaceId && route.spaceId !== currentRef.current && spaces?.some((s) => s.id === route.spaceId)) {+ if (!route.spaceId || !spaces?.some((s) => s.id === route.spaceId)) return;+ const view = route.view ?? null;+ if (route.spaceId !== currentRef.current) {setCurrentSpace(route.spaceId);setTarget({ channelId: route.channelId, botId: route.botId });+ setStartView(view);+ setViewRequest(null);+ viewRef.current = view;setCurrentId(route.spaceId);+ return;+ }+ // Same space: Back from the Inbox or Settings goes back to the chat, and Forward again.+ if (!sameView(view, viewRef.current)) {+ viewRef.current = view;+ requestView(view);}};window.addEventListener('popstate', onPop);return () => window.removeEventListener('popstate', onPop);- }, [spaces]);+ }, [spaces, requestView]);// Unread counts for the other spaces.useEffect(() => {@@ -228,17 +248,26 @@ export const App: React.FC = () => {<div className="h-[var(--kwnt-app-height,100dvh)] w-screen flex flex-col bg-zinc-950 text-zinc-100 overflow-hidden font-sans pt-[env(safe-area-inset-top)] pl-[env(safe-area-inset-left)] pr-[env(safe-area-inset-right)]"><AppUpdateBanner /><div className="flex-1 min-h-0 flex">- <SpaceRail spaces={spaces} currentId={current.id} onSwitch={switchTo} onCreate={openCreate} onOpenAppSettings={() => setAppSettingsOpen(true)} />+ <SpaceRail spaces={spaces} currentId={current.id} onSwitch={switchTo} onCreate={openCreate} onOpenAppSettings={() => requestView({ kind: 'settings', scope: 'app' })} /><SpaceAppkey={current.id}space={current}spaces={spaces}initialTarget={target}- initialSettingsTab={startTab}+ initialView={startView}+ viewRequest={viewRequest}+ onViewChange={(v) => {+ const kindChanged = (v?.kind ?? null) !== (viewRef.current?.kind ?? null);+ viewRef.current = v;+ const path = spacePath(current.id, chatRef.current ?? lastChat(current.id) ?? undefined, v ?? undefined);+ if (window.location.pathname === path) return;+ // Opening or leaving the Inbox or Settings is a step Back undoes; moving between their tabs isn't.+ if (kindChanged) window.history.pushState(null, '', path);+ else window.history.replaceState(null, '', path);+ }}onSwitchSpace={switchTo}onCreateSpace={openCreate}onOpenArchived={() => setShowArchived(true)}- onOpenAppSettings={() => setAppSettingsOpen(true)}onSpacesChanged={reload}onSpaceArchived={(s) => {reload().then((list) => {@@ -250,10 +279,12 @@ export const App: React.FC = () => {}}onChatChange={(t) => {rememberChat(current.id, t);+ chatRef.current = t;+ // The Inbox or Settings keeps its own address over the chat underneath.+ if (viewRef.current) return;const path = spacePath(current.id, t);if (window.location.pathname !== path) window.history.replaceState(null, '', path);}}- onTokensUsed={setTokensUsed}/></div>@@ -264,8 +295,7 @@ export const App: React.FC = () => {onCreated={(s, addAccounts) => {setCreating(null);setSpaces((prev) => (prev ? [...prev, s] : [s]));- open(s.id, null);- if (addAccounts) setStartTab('accounts');+ open(s.id, null, false, addAccounts ? { kind: 'settings', scope: 'space', tab: 'accounts' } : null);reload();}}/>@@ -281,9 +311,6 @@ export const App: React.FC = () => {}}/>)}- <Suspense fallback={null}>- <SettingsModal isOpen={appSettingsOpen} onClose={() => setAppSettingsOpen(false)} tokensUsed={tokensUsed} />- </Suspense><Toasts toasts={toasts} onDismiss={dismissToast} position="top" /><InstallHint /></div>diff --git a/frontend/src/automationDiscovery.ts b/frontend/src/automationDiscovery.tsindex a45cb092..68965e07 100644--- a/frontend/src/automationDiscovery.ts+++ b/frontend/src/automationDiscovery.ts@@ -280,7 +280,7 @@ export class AcceptIntent {export const BLOCK_TEXT: Record<DiscoveryBlock, { title: string; fix: string }> = {off: {title: 'Suggestions are off.',- fix: 'Turn on “Suggest routines from repeated tasks” in Settings, under Mission board.',+ fix: 'Turn on “Suggest routines from repeated tasks” in Settings › All spaces, under Mission board.',},board_off: {title: 'Suggestions learn from tasks on the Mission board, and the board is off.',@@ -288,7 +288,7 @@ export const BLOCK_TEXT: Record<DiscoveryBlock, { title: string; fix: string }>},no_timezone: {title: 'Your time zone isn’t set, so there’s no telling what time you usually ask.',- fix: 'Set your time zone in Settings, under Where you are.',+ fix: 'Set your time zone in Settings › All spaces, under Where you are.',},};diff --git a/frontend/src/components/ApiKeysPanel.tsx b/frontend/src/components/ApiKeysPanel.tsxnew file mode 100644index 00000000..5d600c62--- /dev/null+++ b/frontend/src/components/ApiKeysPanel.tsx@@ -0,0 +1,162 @@+// API keys and the Ollama address: one per provider, shared by every space. They live in+// Settings › This space › Accounts, next to the accounts that use them, and are saved on their+// own: only these four fields are sent, so nothing else in App settings changes.+import React, { useEffect, useState } from 'react';+import { AlertTriangle, Check, ChevronDown, ChevronRight, Globe, Key, Loader2 } from 'lucide-react';+import { playSfx } from '../audio/chiptune';++const DEFAULT_OLLAMA = 'http://localhost:11434/v1';++interface Keys {+ anthropic_api_key: string;+ xai_api_key: string;+ openai_api_key: string;+ ollama_url: string;+}++const FIELDS: { key: Exclude<keyof Keys, 'ollama_url'>; label: string; placeholder: string }[] = [+ { key: 'anthropic_api_key', label: 'Anthropic API Key', placeholder: 'sk-ant-api03-...' },+ { key: 'xai_api_key', label: 'xAI Grok API Key', placeholder: 'xai-...' },+ { key: 'openai_api_key', label: 'OpenAI API Key', placeholder: 'sk-...' },+];++const input =+ 'w-full bg-zinc-950 border border-zinc-800 rounded-lg px-3 py-2 text-xs text-zinc-100 placeholder-zinc-600 focus:border-sky-500 focus:outline-none transition-colors';++export const ApiKeysPanel: React.FC<{ onSaved?: () => void; defaultOpen?: boolean }> = ({ onSaved, defaultOpen = false }) => {+ const [open, setOpen] = useState(defaultOpen);+ const [keys, setKeys] = useState<Keys | null>(null);+ const [loadError, setLoadError] = useState<string | null>(null);+ const [saving, setSaving] = useState(false);+ const [saved, setSaved] = useState(false);+ const [saveError, setSaveError] = useState<string | null>(null);++ const load = () => {+ setLoadError(null);+ fetch('/api/settings')+ .then((r) => {+ if (!r.ok) throw new Error(`HTTP ${r.status}`);+ return r.json();+ })+ .then((d: Partial<Keys>) =>+ setKeys({+ anthropic_api_key: d.anthropic_api_key ?? '',+ xai_api_key: d.xai_api_key ?? '',+ openai_api_key: d.openai_api_key ?? '',+ ollama_url: d.ollama_url || DEFAULT_OLLAMA,+ }),+ )+ .catch(() => setLoadError('Couldn’t load your keys.'));+ };+ useEffect(load, []);++ const count = keys ? FIELDS.filter((f) => keys[f.key].trim()).length : 0;++ const save = async (e: React.FormEvent) => {+ e.preventDefault();+ if (!keys || saving) return;+ playSfx('click');+ setSaving(true);+ setSaveError(null);+ try {+ const res = await fetch('/api/settings', {+ method: 'POST',+ headers: { 'Content-Type': 'application/json' },+ body: JSON.stringify(keys),+ });+ if (!res.ok) {+ const data = await res.json().catch(() => null);+ throw new Error(data && typeof data.error === 'string' ? data.error : `Saving failed (HTTP ${res.status}).`);+ }+ playSfx('coin');+ setSaved(true);+ setTimeout(() => setSaved(false), 2500);+ onSaved?.();+ load();+ } catch (err) {+ setSaveError(err instanceof Error ? err.message : 'Could not reach the server.');+ } finally {+ setSaving(false);+ }+ };++ return (+ <div className="rounded-xl border border-zinc-800 bg-zinc-950/60" data-api-keys>+ <button+ type="button"+ aria-expanded={open}+ aria-controls="space-api-keys"+ onClick={() => setOpen((v) => !v)}+ className="w-full flex items-center gap-2 p-3 text-left rounded-xl focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-400"+ >+ <Key size={14} className="text-violet-400" aria-hidden="true" />+ <span className="flex-1">+ <span className="block text-xs font-medium text-zinc-200">API keys and Ollama</span>+ <span className="block text-[11px] text-zinc-500">+ Optional, shared by every space. {count ? `${count} saved. ` : ''}Not needed when bots use a signed-in CLI.+ </span>+ </span>+ {open ? <ChevronDown size={15} className="text-zinc-500" aria-hidden="true" /> : <ChevronRight size={15} className="text-zinc-500" aria-hidden="true" />}+ </button>++ <form id="space-api-keys" hidden={!open} onSubmit={save} className="space-y-3 px-3 pb-3">+ <p className="text-[11px] text-zinc-500">+ One key per provider for the API-key engines. To keep several keys for one provider, add them as accounts above.+ </p>+ {loadError ? (+ <p role="alert" className="flex items-center gap-2 text-xs text-rose-300">+ <AlertTriangle size={13} /> {loadError}+ <button type="button" onClick={load} className="underline hover:text-rose-100">+ Try again+ </button>+ </p>+ ) : !keys ? (+ <p className="flex items-center gap-2 text-xs text-zinc-400">+ <Loader2 size={13} className="animate-spin motion-reduce:animate-none" /> Loading…+ </p>+ ) : (+ <>+ {FIELDS.map((f) => (+ <div key={f.key}>+ <label htmlFor={`key-${f.key}`} className="block text-xs font-medium text-zinc-400 mb-1">+ {f.label}+ </label>+ <input+ id={`key-${f.key}`}+ type="password"+ autoComplete="off"+ value={keys[f.key]}+ onChange={(e) => setKeys({ ...keys, [f.key]: e.target.value })}+ placeholder={f.placeholder}+ className={input}+ />+ </div>+ ))}+ <div>+ <label htmlFor="key-ollama" className="mb-1 flex items-center gap-1.5 text-xs font-medium text-zinc-400">+ <Globe size={13} className="text-zinc-500" />+ <span>Ollama Base URL</span>+ </label>+ <input id="key-ollama" type="text" value={keys.ollama_url} onChange={(e) => setKeys({ ...keys, ollama_url: e.target.value })} placeholder={DEFAULT_OLLAMA} className={input} />+ </div>+ {saveError && (+ <p role="alert" className="flex items-center gap-2 rounded-lg border border-rose-500/20 bg-rose-500/10 px-3 py-2 text-xs text-rose-300">+ <AlertTriangle size={13} /> {saveError}+ </p>+ )}+ <div className="flex items-center justify-end gap-2">+ {saved && (+ <span role="status" className="flex items-center gap-1 text-xs text-emerald-400">+ <Check size={13} /> Saved for every space+ </span>+ )}+ <button type="submit" disabled={saving} className="px-4 py-2 rounded-lg text-xs font-medium text-white bg-sky-600 hover:bg-sky-500 transition-colors disabled:opacity-50">+ {saving ? 'Saving…' : 'Save keys'}+ </button>+ </div>+ </>+ )}+ </form>+ </div>+ );+};diff --git a/frontend/src/components/AwayView.tsx b/frontend/src/components/AwayView.tsxindex 1ee6ed68..8e0dbc12 100644--- a/frontend/src/components/AwayView.tsx+++ b/frontend/src/components/AwayView.tsx@@ -55,7 +55,7 @@ export interface AwayViewProps {const actionBtn ='inline-flex items-center gap-1.5 min-h-[36px] sm:min-h-[30px] px-3 py-1 rounded-lg text-xs font-medium transition-colors disabled:opacity-50 focus-visible:outline focus-visible:outline-2 focus-visible:outline-amber-400';-/** The "While you were away" page: what's waiting on you, what finished and what failed. */+/** The Inbox's New tab (once "While you were away"): what's waiting on you, what finished and what failed. */export const AwayView: React.FC<AwayViewProps> = ({ data, loading, error, notice = null, busy = null, now = Date.now(), onRefresh, onBack, onOpen, onAnswer, onResolve }) => {const renderItem = (item: AwayItem) => {const { label, tone } = itemLabel(item);@@ -131,7 +131,7 @@ export const AwayView: React.FC<AwayViewProps> = ({ data, loading, error, notice</button>)}<div className="min-w-0 flex-1">- <h2 className="text-sm font-semibold text-zinc-100 truncate">While you were away</h2>+ <h2 className="text-sm font-semibold text-zinc-100 truncate">Inbox</h2><p className="text-[11px] text-zinc-400 truncate mt-0.5">{data ? windowLabel(data.since, now) : 'What your bots need, finished and failed'}</p>diff --git a/frontend/src/components/ConnectionsView.tsx b/frontend/src/components/ConnectionsView.tsxindex da37af7c..f21277e5 100644--- a/frontend/src/components/ConnectionsView.tsx+++ b/frontend/src/components/ConnectionsView.tsx@@ -526,6 +526,8 @@ export interface ConnectionsViewProps extends ManageLinks {onUnlockVault?: () => void;onAddComposio: ComposioCardProps['onAdd'];onBack?: () => void;+ /** Inside Settings › This space: the screen has the heading and the scrolling. */+ embedded?: boolean;/** Tests open the Composio form. */composioOpen?: boolean;/** Tests and screenshots open the "+ Add connection" list. */@@ -545,6 +547,7 @@ export const ConnectionsView: React.FC<ConnectionsViewProps> = ({onUnlockVault,onAddComposio,onBack,+ embedded = false,composioOpen = false,addMenuOpen = false,...links@@ -561,8 +564,14 @@ export const ConnectionsView: React.FC<ConnectionsViewProps> = ({sources: links.onOpenLooseEnds ? { key: 'sources', label: 'Loose ends', hint: '', run: links.onOpenLooseEnds } : undefined,};return (- <div className="flex-1 flex flex-col h-full bg-zinc-950 overflow-hidden">- <div className={`h-14 border-b border-zinc-800/80 ${onBack ? 'px-2' : 'px-4'} sm:px-6 flex items-center justify-between gap-3 bg-zinc-900/30 backdrop-blur-sm select-none`}>+ <div className={embedded ? 'space-y-4' : 'flex-1 flex flex-col h-full bg-zinc-950 overflow-hidden'}>+ <div+ className={+ embedded+ ? 'flex items-center justify-between gap-3 select-none'+ : `h-14 border-b border-zinc-800/80 ${onBack ? 'px-2' : 'px-4'} sm:px-6 flex items-center justify-between gap-3 bg-zinc-900/30 backdrop-blur-sm select-none`+ }+ >{onBack && (<buttontype="button"@@ -574,8 +583,8 @@ export const ConnectionsView: React.FC<ConnectionsViewProps> = ({</button>)}<div className="min-w-0 flex-1">- <h2 className="text-sm font-semibold text-zinc-100 truncate">Connections</h2>- <p className="text-[11px] text-zinc-400 truncate mt-0.5">{data ? countsLine(data.connections) : 'Everything your bots reach outside the app'}</p>+ {!embedded && <h2 className="text-sm font-semibold text-zinc-100 truncate">Connections</h2>}+ <p className={`text-[11px] text-zinc-400 truncate ${embedded ? '' : 'mt-0.5'}`}>{data ? countsLine(data.connections) : 'Everything your bots reach outside the app'}</p></div><buttontype="button"@@ -590,8 +599,8 @@ export const ConnectionsView: React.FC<ConnectionsViewProps> = ({<AddConnectionMenu choices={choices} disabled={needsToken} initialOpen={addMenuOpen} /></div>- <div className="flex-1 overflow-y-auto p-4 sm:p-6" aria-busy={loading}>- <div className="max-w-3xl mx-auto space-y-5">+ <div className={embedded ? '' : 'flex-1 overflow-y-auto p-4 sm:p-6'} aria-busy={loading}>+ <div className={embedded ? 'space-y-5' : 'max-w-3xl mx-auto space-y-5'}><p className="text-[11px] text-zinc-400">Tool servers, accounts and logins your bots use. Logins stay in your own vault on this computer unless a row says otherwise. Nothing secret is shown here.</p>{needsToken && (@@ -699,7 +708,7 @@ export const ConnectionsView: React.FC<ConnectionsViewProps> = ({};/** The page: loads the list, checks MCP servers, unlocks the vault and adds Composio. */-export const ConnectionsPage: React.FC<ManageLinks & { onBack?: () => void }> = ({ onBack, ...links }) => {+export const ConnectionsPage: React.FC<ManageLinks & { onBack?: () => void; embedded?: boolean }> = ({ onBack, embedded, ...links }) => {const [data, setData] = useState<ConnectionsList | null>(null);const [loading, setLoading] = useState(true);const [error, setError] = useState<string | null>(null);@@ -778,6 +787,7 @@ export const ConnectionsPage: React.FC<ManageLinks & { onBack?: () => void }> =onUnlockVault={() => setUnlocking(true)}onAddComposio={addComposio}onBack={onBack}+ embedded={embedded}{...links}/>{unlocking && (diff --git a/frontend/src/components/HireCard.tsx b/frontend/src/components/HireCard.tsxindex 20a258e6..5c06776d 100644--- a/frontend/src/components/HireCard.tsx+++ b/frontend/src/components/HireCard.tsx@@ -217,7 +217,7 @@ export const HireCard: React.FC<HireCardProps> = ({ meta, messageId, kwantName,)}{pending && can('always_accept') && (<p className="text-[11px] text-zinc-500">- Always accept hires later proposals in this space at once, up to 3 a day, each with Undo. You can change this in Space settings.+ Always accept hires later proposals in this space at once, up to 3 a day, each with Undo. You can change this in Settings › This space.</p>)}diff --git a/frontend/src/components/ImportDialog.tsx b/frontend/src/components/ImportDialog.tsxindex 7677d488..f658a829 100644--- a/frontend/src/components/ImportDialog.tsx+++ b/frontend/src/components/ImportDialog.tsx@@ -334,7 +334,7 @@ export const DoneView: React.FC<{ applied: Applied; undo: UndoState; onUndo: (fo{extras.length > 0 && <p className="text-[11px] text-zinc-500">Also {extras.join(', ')}.</p>}</div><Notes items={applied.warnings.map((n) => n.message)} tone="warn" label="Worth a look" />- <p className="text-[11px] text-zinc-400">Give them an account and tools in Space settings when you’re ready. Skills and routines are there to review.</p>+ <p className="text-[11px] text-zinc-400">Give them an account and tools in Settings › This space when you’re ready. Skills and routines are there to review.</p><p className="text-[11px] text-zinc-400">Tools you add to this space later will be on for these bots too.</p>{undo.kind === 'confirm_edited' && (<div role="alert" className="rounded-lg border border-amber-500/40 bg-amber-500/10 p-3 space-y-2">diff --git a/frontend/src/components/InboxPage.tsx b/frontend/src/components/InboxPage.tsxnew file mode 100644index 00000000..17c832e1--- /dev/null+++ b/frontend/src/components/InboxPage.tsx@@ -0,0 +1,81 @@+// Inbox: one place for what came in while you were elsewhere. "New" is the old While you were+// away page, unchanged; "Loose ends" is the Loose ends page, unchanged. The tabs sit above them.+import React from 'react';+import { ChevronLeft } from 'lucide-react';+import type { InboxTab } from '../nav';+import { playSfx } from '../audio/chiptune';+import { badgeText } from '../away';++const TABS: { id: InboxTab; label: string }[] = [+ { id: 'new', label: 'New' },+ { id: 'loose', label: 'Loose ends' },+];++export const InboxPage: React.FC<{+ tab: InboxTab;+ onTab: (tab: InboxTab) => void;+ /** Unseen items, shown on the New tab. */+ count?: number;+ /** Phones: back to the list. */+ onBack?: () => void;+ newPage: React.ReactNode;+ loosePage: React.ReactNode;+}> = ({ tab, onTab, count = 0, onBack, newPage, loosePage }) => (+ <div className="flex-1 min-w-0 flex flex-col h-full bg-zinc-950 overflow-hidden" data-inbox>+ <div className={`shrink-0 flex items-center gap-2 border-b border-zinc-800/80 ${onBack ? 'px-2' : 'px-4'} sm:px-6 pt-2 bg-zinc-900/30 select-none`}>+ {onBack && (+ <button+ type="button"+ onClick={onBack}+ aria-label="Back to chats"+ className="shrink-0 mb-1.5 p-2 -ml-0.5 rounded-lg text-zinc-300 hover:text-zinc-100 hover:bg-zinc-800 focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-500"+ >+ <ChevronLeft size={18} />+ </button>+ )}+ <div role="tablist" aria-label="Inbox" className="flex items-end gap-1">+ {TABS.map((t) => {+ const on = t.id === tab;+ return (+ <button+ key={t.id}+ type="button"+ role="tab"+ id={`inbox-tab-${t.id}`}+ aria-selected={on}+ aria-controls="inbox-panel"+ data-inbox-tab={t.id}+ onClick={() => {+ if (on) return;+ playSfx('click');+ onTab(t.id);+ }}+ onKeyDown={(e) => {+ if (e.key !== 'ArrowRight' && e.key !== 'ArrowLeft') return;+ e.preventDefault();+ const next = TABS[(TABS.findIndex((x) => x.id === tab) + 1) % TABS.length].id;+ onTab(next);+ requestAnimationFrame(() => document.getElementById(`inbox-tab-${next}`)?.focus());+ }}+ tabIndex={on ? 0 : -1}+ className={`relative flex items-center gap-1.5 px-3 pb-2 pt-1.5 text-xs font-medium border-b-2 -mb-px transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-500 ${+ on ? 'border-sky-400 text-zinc-100' : 'border-transparent text-zinc-400 hover:text-zinc-200'+ }`}+ >+ {t.label}+ {t.id === 'new' && count > 0 && (+ <span className="min-w-[16px] px-1 rounded-full bg-amber-500 text-zinc-950 text-[9px] font-semibold text-center">+ {badgeText(count)}+ <span className="sr-only"> new</span>+ </span>+ )}+ </button>+ );+ })}+ </div>+ </div>+ <div id="inbox-panel" role="tabpanel" aria-labelledby={`inbox-tab-${tab}`} className="flex-1 min-h-0 flex">+ {tab === 'loose' ? loosePage : newPage}+ </div>+ </div>+);diff --git a/frontend/src/components/InstallAppButton.tsx b/frontend/src/components/InstallAppButton.tsxindex 3aaa216a..da4d6d38 100644--- a/frontend/src/components/InstallAppButton.tsx+++ b/frontend/src/components/InstallAppButton.tsx@@ -1,15 +1,18 @@import React, { useId, useState } from 'react';-import { Download, ExternalLink, Laptop, Share, SquarePlus } from 'lucide-react';+import { Download, ExternalLink, Laptop, Share, SquarePlus, X } from 'lucide-react';import { MAC_DOWNLOAD_URL, desktopInstallKind, isEmbeddedWebView, isIos, isMacSafari, isStandalone, runInstallPrompt } from '../pwa';import { useInstall } from '../useInstall';+import { dismissInstallTip, installTipDismissed } from '../nav';const onMac = () => /Macintosh/.test(navigator.userAgent) && !isIos(navigator);-/** "Install app" in the sidebar, on desktop: Chrome and Edge install in one click; other browsers- * get the steps that work there. Gone once kwant runs installed, or in the Mac app. */-export const InstallAppButton: React.FC<{ className: string }> = ({ className }) => {+/** "Install app", on desktop: Chrome and Edge install in one click; other browsers get the steps+ * that work there. Gone once kwant runs installed, or in the Mac app. Settings › All spaces always+ * has it; the sidebar shows it once as a `tip` until it is dismissed. */+export const InstallAppButton: React.FC<{ className: string; tip?: boolean }> = ({ className, tip = false }) => {const { prompt, installed } = useInstall();const [open, setOpen] = useState(false);+ const [dismissed, setDismissed] = useState(() => tip && installTipDismissed());const panelId = useId();// Server rendering (tests) has no browser to install into.@@ -21,7 +24,9 @@ export const InstallAppButton: React.FC<{ className: string }> = ({ className })macSafari: isMacSafari(navigator),ios: isIos(navigator),});- if (!kind) return null;+ if (!kind || dismissed) return null;+ // A tip that can only say "this can't install here" isn't worth the space.+ if (tip && kind === 'insecure') return null;const onClick = () => {if (kind === 'prompt') void runInstallPrompt();@@ -29,17 +34,33 @@ export const InstallAppButton: React.FC<{ className: string }> = ({ className })};return (- <div className="hidden md:block" data-install-app={kind}>- <button- type="button"- onClick={onClick}- aria-expanded={kind === 'prompt' ? undefined : open}- aria-controls={kind === 'prompt' ? undefined : panelId}- className={className}- >- <Download size={15} className="text-zinc-500" aria-hidden="true" />- <span className="truncate flex-1">Install app</span>- </button>+ <div className={tip ? 'hidden md:block rounded-lg border border-zinc-800 bg-zinc-900/60' : 'hidden md:block'} data-install-app={kind} data-install-tip={tip || undefined}>+ <div className="flex items-center">+ <button+ type="button"+ onClick={onClick}+ aria-expanded={kind === 'prompt' ? undefined : open}+ aria-controls={kind === 'prompt' ? undefined : panelId}+ className={className}+ >+ <Download size={15} className={tip ? 'text-sky-400' : 'text-zinc-500'} aria-hidden="true" />+ <span className="truncate flex-1">{tip ? 'Tip: install this as an app' : 'Install app'}</span>+ </button>+ {tip && (+ <button+ type="button"+ onClick={() => {+ dismissInstallTip();+ setDismissed(true);+ }}+ aria-label="Dismiss the install tip"+ title="Dismiss. Install any time from Settings › All spaces."+ className="shrink-0 mr-1 p-1 rounded text-zinc-500 hover:text-zinc-200 hover:bg-zinc-800 focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-500"+ >+ <X size={12} aria-hidden="true" />+ </button>+ )}+ </div>{open && kind !== 'prompt' && (<div id={panelId} className="mx-2.5 mt-1 mb-1.5 rounded-lg border border-zinc-800 bg-zinc-900/70 p-2.5 text-[11px] leading-relaxed text-zinc-400">{kind === 'safari' ? (diff --git a/frontend/src/components/ModelPicker.tsx b/frontend/src/components/ModelPicker.tsxindex c7b6ba8f..25044738 100644--- a/frontend/src/components/ModelPicker.tsx+++ b/frontend/src/components/ModelPicker.tsx@@ -171,7 +171,7 @@ const SettingsLink: React.FC<{ onOpenSettings?: () => void }> = ({ onOpenSettingOpen Settings <ChevronRight size={11} /></button>) : (- <span>Check Settings → Engines.</span>+ <span>Check Settings › This space › Accounts.</span>);/** "Sign in with Claude", when that's what fixes it. */diff --git a/frontend/src/components/SettingsModal.tsx b/frontend/src/components/SettingsModal.tsxindex 80e44caa..41ab1dce 100644--- a/frontend/src/components/SettingsModal.tsx+++ b/frontend/src/components/SettingsModal.tsx@@ -1,7 +1,7 @@import React, { useState, useEffect, useRef } from 'react';import { AuditorSettings, DAILY_CAPS, SETTING_HINT as AUDITOR_HINT, isAuditorModelError, MODEL_ERROR_TEXT as AUDITOR_MODEL_ERROR, parseAuditorSettings } from '../auditor';import { AuditorModelSetting } from './AuditorModelSetting';-import { Key, Globe, X, Settings, Check, ChevronDown, ChevronRight, LogOut, Bell, AlertTriangle, Layers, Monitor, Volume2, VolumeX, Gauge, MapPin, Vibrate, VibrateOff, Sparkles, KanbanSquare } from 'lucide-react';+import { Key, X, Settings, Check, ChevronRight, LogOut, Bell, AlertTriangle, Layers, Monitor, Volume2, VolumeX, Gauge, MapPin, Vibrate, VibrateOff, Sparkles, KanbanSquare } from 'lucide-react';import { TURN_LIMITS, TurnLimitKey, limitError } from '../threads';import { DailyUsagePanel } from './DailyUsage';import {@@ -27,7 +27,6 @@ import { useAuth } from './AuthGate';import { SignedInDevices } from './DeviceSignIn';import { signedInDevicesVisible } from '../deviceSignIn';import { ComputerModeControl, useComputerMode } from './ComputerModeSwitch';-import { useEngines } from '../useEngines';import { LayaStatusRow } from './LayaStatus';import { AppUpdateAbout, useAppUpdate } from './AppUpdateBanner';import { StarAskSettingsLink } from './StarAsk';@@ -241,6 +240,10 @@ interface SettingsModalProps {onClose: () => void;/** Tokens used in the open chat, shown under Usage. */tokensUsed?: number;+ /** Inside Settings › All spaces: no dialog frame, no close button, Escape is the parent's. */+ embedded?: boolean;+ /** Opens Settings › This space › Accounts, where the API keys and Ollama address live. */+ onOpenApiKeys?: () => void;}/** App settings: shared by every space (keys, Laya, limits, notifications, sounds). Accounts,@@ -287,18 +290,12 @@ const DiscoverySetting: React.FC<{ value: DiscoverySettings; onChange: (v: Disco);};-export const SettingsModal: React.FC<SettingsModalProps> = ({ isOpen, onClose, tokensUsed = 0 }) => {+export const SettingsModal: React.FC<SettingsModalProps> = ({ isOpen, onClose, tokensUsed = 0, embedded = false, onOpenApiKeys }) => {const { authRequired, deviceLogin, signOut } = useAuth();const computer = useComputerMode(isOpen);- const engines = useEngines(isOpen);const [sfxMuted, setSfxMuted] = useState(isSfxMuted);const [vibration, setVibration] = useState(hapticsEnabled);const [settings, setSettings] = useState<SettingsData | null>(null);- const [anthropicKey, setAnthropicKey] = useState('');- const [xaiKey, setXaiKey] = useState('');- const [openaiKey, setOpenaiKey] = useState('');- const [ollamaUrl, setOllamaUrl] = useState('http://localhost:11434/v1');- const [keysOpen, setKeysOpen] = useState(false);const [saving, setSaving] = useState(false);const [saveSuccess, setSaveSuccess] = useState(false);const [saveError, setSaveError] = useState<string | null>(null);@@ -342,7 +339,6 @@ export const SettingsModal: React.FC<SettingsModalProps> = ({ isOpen, onClose, tconst limitErrors = Object.fromEntries(LIMIT_FIELDS.map(({ key }) => [key, limits ? limitError(key, limits[key]) : null]),) as Record<TurnLimitKey, string | null>;- const keysSaved = [anthropicKey, xaiKey, openaiKey].filter((k) => k.trim()).length;const limitsInvalid = Object.values(limitErrors).some(Boolean);const perAgentOverGlobal =!!limits && !limitsInvalid && Number(limits.max_turns_per_agent) > Number(limits.max_turns_global);@@ -350,11 +346,11 @@ export const SettingsModal: React.FC<SettingsModalProps> = ({ isOpen, onClose, tconst closeRef = useRef(onClose);closeRef.current = onClose;useEffect(() => {- if (!isOpen) return;+ if (!isOpen || embedded) return;const onKey = (e: KeyboardEvent) => e.key === 'Escape' && closeRef.current();window.addEventListener('keydown', onKey);return () => window.removeEventListener('keydown', onKey);- }, [isOpen]);+ }, [isOpen, embedded]);useEffect(() => {if (isOpen) {@@ -366,10 +362,6 @@ export const SettingsModal: React.FC<SettingsModalProps> = ({ isOpen, onClose, t.then((r) => r.json()).then((data: SettingsData) => {setSettings(data);- setAnthropicKey(data.anthropic_api_key);- setXaiKey(data.xai_api_key);- setOpenaiKey(data.openai_api_key);- setOllamaUrl(data.ollama_url || 'http://localhost:11434/v1');setWebhookUrl(data.notify_webhook_url ?? '');if (Array.isArray(data.notify_on)) setNotifyOn(data.notify_on);setLimits(@@ -454,10 +446,6 @@ export const SettingsModal: React.FC<SettingsModalProps> = ({ isOpen, onClose, tmethod: 'POST',headers: { 'Content-Type': 'application/json' },body: JSON.stringify({- anthropic_api_key: anthropicKey,- xai_api_key: xaiKey,- openai_api_key: openaiKey,- ollama_url: ollamaUrl,notify_webhook_url: webhookUrl.trim(),notify_on: notifyOnToSave(notifyOn, appUpdates, !!proactive, !!discovery, flightSchool !== null),...(limits@@ -484,9 +472,6 @@ export const SettingsModal: React.FC<SettingsModalProps> = ({ isOpen, onClose, tsetSaveSuccess(true);if (missionBoard !== null) window.dispatchEvent(new CustomEvent(MISSION_BOARD_SETTING_EVENT, { detail: missionBoard }));if (discovery) window.dispatchEvent(new CustomEvent(DISCOVERY_SETTING_EVENT, { detail: discovery }));- // Saving a key or the Ollama URL re-checks engines on the server; show the result.- window.setTimeout(engines.reload, 1500);- window.setTimeout(engines.reload, 6000);if (webhookUrl.trim() && webhookUrl.trim() !== MASK) setWebhookUrl(MASK);playSfx('coin');setTimeout(() => setSaveSuccess(false), 2500);@@ -502,10 +487,24 @@ export const SettingsModal: React.FC<SettingsModalProps> = ({ isOpen, onClose, t}};- return (- <div className="kw-dialog fixed inset-0 z-50 bg-black/70 backdrop-blur-sm flex items-center justify-center p-4 select-none">- <div role="dialog" aria-modal="true" aria-labelledby="settings-title" className="kw-dialog-panel bg-zinc-900 border border-zinc-800 rounded-2xl max-w-lg sm:max-w-2xl w-full max-h-[92vh] overflow-y-auto p-4 sm:p-6 text-zinc-100 shadow-2xl space-y-6">- {/* Header */}+ // A plain call, not a component: a component made here would remount the form on every render.+ const frame = (children: React.ReactNode) =>+ embedded ? (+ <div data-app-settings className="text-zinc-100 space-y-6 select-none">+ {children}+ </div>+ ) : (+ <div className="kw-dialog fixed inset-0 z-50 bg-black/70 backdrop-blur-sm flex items-center justify-center p-4 select-none">+ <div role="dialog" aria-modal="true" aria-labelledby="settings-title" className="kw-dialog-panel bg-zinc-900 border border-zinc-800 rounded-2xl max-w-lg sm:max-w-2xl w-full max-h-[92vh] overflow-y-auto p-4 sm:p-6 text-zinc-100 shadow-2xl space-y-6">+ {children}+ </div>+ </div>+ );++ return frame(+ <>+ {/* Header: the dialog's own; embedded, the Settings screen has the heading and the close button. */}+ {!embedded && (<div className="flex items-center justify-between border-b border-zinc-800 pb-4"><div className="flex items-center gap-2.5"><div className="w-8 h-8 rounded-lg bg-sky-500/10 border border-sky-500/20 flex items-center justify-center text-sky-400">@@ -528,6 +527,7 @@ export const SettingsModal: React.FC<SettingsModalProps> = ({ isOpen, onClose, t<X size={18} /></button></div>+ )}<LayaStatusRow />@@ -601,84 +601,26 @@ export const SettingsModal: React.FC<SettingsModalProps> = ({ isOpen, onClose, t</div>)}- {/* Cloud API Keys Form */}+ {/* App settings form; API keys moved to Settings › This space › Accounts */}<form onSubmit={handleSave} className="space-y-4">- <div className="rounded-xl border border-zinc-800 bg-zinc-950/60">- <button- type="button"- aria-expanded={keysOpen}- aria-controls="settings-api-keys"- onClick={() => setKeysOpen((v) => !v)}- className="w-full flex items-center gap-2 p-3 text-left rounded-xl focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-400"- >- <Key size={14} className="text-violet-400" aria-hidden="true" />- <span className="flex-1">- <span className="block text-xs font-medium text-zinc-200">API keys and Ollama</span>- <span className="block text-[11px] text-zinc-500">- Optional, for every space. {keysSaved ? `${keysSaved} saved. ` : ''}Not needed when a space’s bots use a signed-in CLI.+ {onOpenApiKeys && (+ <button+ type="button"+ onClick={() => {+ playSfx('click');+ onOpenApiKeys();+ }}+ data-api-keys-link+ className="w-full flex items-center gap-2 p-3 text-left rounded-xl border border-zinc-800 bg-zinc-950/60 hover:border-zinc-700 focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-400"+ >+ <Key size={14} className="text-violet-400" aria-hidden="true" />+ <span className="flex-1">+ <span className="block text-xs font-medium text-zinc-200">API keys and Ollama</span>+ <span className="block text-[11px] text-zinc-500">Now in Settings › This space › Accounts, next to the accounts that use them.</span></span>- </span>- {keysOpen ? <ChevronDown size={15} className="text-zinc-500" aria-hidden="true" /> : <ChevronRight size={15} className="text-zinc-500" aria-hidden="true" />}- </button>-- <div id="settings-api-keys" hidden={!keysOpen} className="space-y-3 px-3 pb-3">- <p className="text-[11px] text-zinc-500">- One key per provider for the API-key engines. To keep several keys for one provider, add them as accounts in a space’s settings → Accounts.- </p>- <div>- <label className="block text-xs font-medium text-zinc-400 mb-1">- Anthropic API Key- </label>- <input- type="password"- value={anthropicKey}- onChange={(e) => setAnthropicKey(e.target.value)}- placeholder="sk-ant-api03-..."- className="w-full bg-zinc-950 border border-zinc-800 rounded-lg px-3 py-2 text-xs text-zinc-100 placeholder-zinc-600 focus:border-sky-500 focus:outline-none transition-colors"- />- </div>-- <div>- <label className="block text-xs font-medium text-zinc-400 mb-1">- xAI Grok API Key- </label>- <input- type="password"- value={xaiKey}- onChange={(e) => setXaiKey(e.target.value)}- placeholder="xai-..."- className="w-full bg-zinc-950 border border-zinc-800 rounded-lg px-3 py-2 text-xs text-zinc-100 placeholder-zinc-600 focus:border-sky-500 focus:outline-none transition-colors"- />- </div>-- <div>- <label className="block text-xs font-medium text-zinc-400 mb-1">- OpenAI API Key- </label>- <input- type="password"- value={openaiKey}- onChange={(e) => setOpenaiKey(e.target.value)}- placeholder="sk-..."- className="w-full bg-zinc-950 border border-zinc-800 rounded-lg px-3 py-2 text-xs text-zinc-100 placeholder-zinc-600 focus:border-sky-500 focus:outline-none transition-colors"- />- </div>-- <div>- <label className="block text-xs font-medium text-zinc-400 mb-1 flex items-center gap-1.5">- <Globe size={13} className="text-zinc-500" />- <span>Ollama Base URL</span>- </label>- <input- type="text"- value={ollamaUrl}- onChange={(e) => setOllamaUrl(e.target.value)}- placeholder="http://localhost:11434/v1"- className="w-full bg-zinc-950 border border-zinc-800 rounded-lg px-3 py-2 text-xs text-zinc-100 placeholder-zinc-600 focus:border-sky-500 focus:outline-none transition-colors"- />- </div>- </div>- </div>+ <ChevronRight size={15} className="text-zinc-500" aria-hidden="true" />+ </button>+ )}{place && (<fieldset className="space-y-3 pt-2 border-t border-zinc-800">@@ -1152,7 +1094,6 @@ export const SettingsModal: React.FC<SettingsModalProps> = ({ isOpen, onClose, t</button></div></form>- </div>- </div>+ </>,);};diff --git a/frontend/src/components/Sidebar.tsx b/frontend/src/components/Sidebar.tsxindex 4a089db7..4b2958ab 100644--- a/frontend/src/components/Sidebar.tsx+++ b/frontend/src/components/Sidebar.tsx@@ -1,10 +1,10 @@import React, { useCallback, useEffect, useState } from 'react';-import { Hash, Plus, CheckCircle2, KeyRound, Loader2, Users, ChevronDown, Settings2, X, Crown, UserPlus, Pencil, Inbox, Search, CalendarClock, ShieldOff, ListChecks, Split, Hand, Plug, MoreHorizontal, UserMinus, MessageSquare, KanbanSquare } from 'lucide-react';+import { Hash, Plus, CheckCircle2, KeyRound, Loader2, Users, ChevronDown, Settings, Settings2, X, Crown, UserPlus, Pencil, Inbox, Search, ShieldOff, Split, Hand, MoreHorizontal, UserMinus, MessageSquare, KanbanSquare } from 'lucide-react';import { ModernAvatar } from './ModernAvatar';import { playSfx } from '../audio/chiptune';import { badgeText } from '../away';import { canRunNow, engineTip, isUsable } from '../engines';-import { STATUS_DOT, statusOf, statusText, type BotStatus } from '../botStatus';+import { statusOf, statusText, type BotStatus } from '../botStatus';import { EnginesApi, useEngines } from '../useEngines';import { claudeNeedsSignIn } from '../claudeLogin';import { Space, spaceSummary } from '../spaces';@@ -69,7 +69,6 @@ export interface SidebarProps {onOpenSpaceSettings: () => void;onOpenArchived: () => void;onOpenSearch: () => void;- onOpenRoutines: () => void;/** Phones show one tab at a time, full width. */section?: SidebarSection;phone?: boolean;@@ -96,20 +95,17 @@ export interface SidebarProps {onCreateTeam: () => void;/** Opens the new-channel form. */onCreateChannel?: () => void;- /** "While you were away": unseen count for the badge, whether it's open, and how to open it. */- awayCount?: number;- awayActive?: boolean;- looseActive?: boolean;- connectionsActive?: boolean;- onOpenConnections?: () => void;- onOpenLooseEnds?: () => void;+ /** Inbox: unseen count for the badge, whether it's open, and how to open it. */+ inboxCount?: number;+ inboxActive?: boolean;+ onOpenInbox?: () => void;+ /** Parallel Universe, behind "More". */parallelActive?: boolean;onOpenParallel?: () => void;/** Shows the Mission board row; the server's mission_board setting decides. */missionBoard?: boolean;missionsActive?: boolean;onOpenMissions?: () => void;- onOpenAway?: () => void;/** Opens Space settings → Accounts from the footer. */onOpenAccounts?: () => void;/** Opens Accounts at "Sign in with Claude", when Claude being signed out is why nothing runs. */@@ -132,6 +128,93 @@ export const memberIdsOf = (t: Team): string[] =>? (JSON.parse(t.member_kwants || '[]') as string[]): [];+/**+ * The bot list: one group per team (its members, lead first), then the bots in no team. A bot in+ * two teams shows under each, because that's where you look for it.+ */+export function botGroups(teams: Team[], kwants: Kwant[]): Array<{ team: Team | null; bots: Kwant[] }> {+ const byId = new Map(kwants.map((k) => [k.id, k]));+ const placed = new Set<string>();+ const groups: Array<{ team: Team | null; bots: Kwant[] }> = teams.map((t) => {+ const ids = memberIdsOf(t);+ const ordered = [...ids.filter((id) => id === t.lead_kwant_id), ...ids.filter((id) => id !== t.lead_kwant_id)];+ const bots = ordered.map((id) => byId.get(id)).filter((k): k is Kwant => !!k);+ for (const k of bots) placed.add(k.id);+ return { team: t, bots };+ });+ groups.push({ team: null, bots: kwants.filter((k) => !placed.has(k.id)) });+ return groups;+}++/** "More": the places used less often, in a small menu. */+const MoreMenu: React.FC<{+ className: string;+ active: boolean;+ items: Array<{ label: string; icon: React.ReactNode; active?: boolean; onClick: () => void }>;+}> = ({ className, active, items }) => {+ const [open, setOpen] = useState(false);+ const ref = React.useRef<HTMLDivElement>(null);+ const menuId = React.useId();+ useEffect(() => {+ if (!open) return;+ const onKey = (e: KeyboardEvent) => {+ if (e.key !== 'Escape') return;+ e.stopPropagation();+ setOpen(false);+ ref.current?.querySelector<HTMLElement>('button')?.focus();+ };+ const onDown = (e: MouseEvent) => !ref.current?.contains(e.target as Node) && setOpen(false);+ window.addEventListener('keydown', onKey, true);+ window.addEventListener('mousedown', onDown);+ ref.current?.querySelector<HTMLElement>('[role=menuitem]')?.focus();+ return () => {+ window.removeEventListener('keydown', onKey, true);+ window.removeEventListener('mousedown', onDown);+ };+ }, [open]);+ return (+ <div ref={ref} className="relative" data-more-menu>+ <button+ type="button"+ onClick={() => {+ playSfx('click');+ setOpen((v) => !v);+ }}+ aria-haspopup="menu"+ aria-expanded={open}+ aria-controls={open ? menuId : undefined}+ className={className}+ >+ <MoreHorizontal size={15} className={active ? 'text-sky-400' : 'text-zinc-500'} aria-hidden="true" />+ <span className="truncate flex-1">More</span>+ <ChevronDown size={12} className={`shrink-0 text-zinc-500 transition-transform ${open ? 'rotate-180' : ''}`} aria-hidden="true" />+ </button>+ {open && (+ <div id={menuId} role="menu" aria-label="More" className="absolute left-0 right-0 top-full mt-1 z-30 rounded-lg border border-zinc-700/70 bg-zinc-900 p-1 shadow-xl">+ {items.map((it) => (+ <button+ key={it.label}+ type="button"+ role="menuitem"+ onClick={() => {+ setOpen(false);+ it.onClick();+ }}+ aria-current={it.active ? 'page' : undefined}+ className={`w-full flex items-center gap-2.5 px-2.5 py-1.5 rounded-md text-xs font-medium text-left focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-500 ${+ it.active ? 'bg-zinc-800 text-zinc-100' : 'text-zinc-300 hover:bg-zinc-800 hover:text-zinc-100'+ }`}+ >+ <span className={it.active ? 'text-sky-400' : 'text-zinc-500'}>{it.icon}</span>+ {it.label}+ </button>+ ))}+ </div>+ )}+ </div>+ );+};+export const Sidebar: React.FC<SidebarProps> = ({space,spaces,@@ -140,7 +223,6 @@ export const Sidebar: React.FC<SidebarProps> = ({onOpenSpaceSettings,onOpenArchived,onOpenSearch,- onOpenRoutines,section = 'all',phone = false,kwants,@@ -161,18 +243,14 @@ export const Sidebar: React.FC<SidebarProps> = ({onSummonKwant,onCreateTeam,onCreateChannel,- awayCount = 0,- awayActive = false,- looseActive = false,- connectionsActive = false,- onOpenConnections,+ inboxCount = 0,+ inboxActive = false,+ onOpenInbox,parallelActive = false,onOpenParallel,missionBoard = false,missionsActive = false,onOpenMissions,- onOpenLooseEnds,- onOpenAway,onOpenAccounts,onSignInClaude,enginesRefreshKey = 0,@@ -190,7 +268,6 @@ export const Sidebar: React.FC<SidebarProps> = ({// Nothing can run and Claude only needs signing in: the footer goes straight to that.const offerClaude = readyCount === 0 && !!onSignInClaude && claudeNeedsSignIn(engines.engines);const canRun = canRunNow(engines.engines);- const [teamsOpen, setTeamsOpen] = useState(true);const [collapsedTeams, setCollapsedTeams] = useState<Set<string>>(new Set());const [addingTo, setAddingTo] = useState<string | null>(null);const [switcherOpen, setSwitcherOpen] = useState(false);@@ -249,43 +326,323 @@ export const Sidebar: React.FC<SidebarProps> = ({</button>);- return (- <aside- aria-label={`${space.name} chats and kwant bots`}- className={`${phone ? 'w-full flex-1 min-h-0' : 'w-64 h-full border-r border-zinc-800/80'} bg-zinc-900/40 flex flex-col select-none flex-shrink-0`}- >- {/* The open space: tap to switch, create or open its settings */}- <div className="relative p-2 border-b border-zinc-800/60">+ // One row per bot: avatar with its status dot, name, what it is doing, and its actions. In a+ // team the lead is marked and others can be removed; on phones those sit in a sheet.+ const botRow = (k: Kwant, team?: Team) => {+ const active = !isChannel && selectedId === k.id;+ const status = statusOf(k.id, botStatus, canRun);+ const isLead = !!team && k.id === team.lead_kwant_id;+ const memberIds = team ? memberIdsOf(team) : [];+ return (+ <div+ key={`${team?.id ?? 'none'}:${k.id}`}+ role="button"+ tabIndex={0}+ onClick={() => onSelectKwant(k)}+ onKeyDown={(e) => e.key === 'Enter' && onSelectKwant(k)}+ data-bot-row={k.id}+ className={`group/fleet w-full flex items-center gap-2.5 px-2 py-1.5 rounded-xl text-left cursor-pointer transition-all ${+ active ? 'bg-zinc-800/90 text-zinc-100 shadow-sm border border-zinc-700/60' : 'text-zinc-400 hover:text-zinc-200 hover:bg-zinc-800/40 border border-transparent'+ }`}+ >+ <span className="shrink-0" title={status === 'cant_run' ? "Can't run yet: no account works here" : statusText(k.name, status)}>+ <ModernAvatar role={k.avatar_sprite} name={k.name} size={28} status={status} kwantId={k.id} />+ </span>+ <div className="flex-1 min-w-0">+ <div className="flex items-center gap-1">+ {/* The full name; what it runs on is in the tooltip */}+ <span className="text-xs font-semibold text-zinc-200 truncate" title={`${k.name} · ${engineTip(k.preferred_model)}`}>+ {k.name}+ </span>+ {isLead && (+ <span className="shrink-0 flex items-center gap-0.5 text-[9px] uppercase tracking-wide text-amber-300/90" title={`Leads @${team!.name}`}>+ <Crown size={10} aria-hidden="true" />+ lead+ </span>+ )}+ {needsYou[k.id] > 0 && (+ <span+ className="shrink-0 inline-flex items-center gap-1 px-1.5 py-px rounded-full text-[10px] font-medium bg-amber-400/15 text-amber-200 border border-amber-400/30"+ title={`${k.name} needs you in the browser`}+ >+ <Hand size={10} aria-hidden="true" />+ Needs you{needsYou[k.id] > 1 ? ` · ${needsYou[k.id]}` : ''}+ </span>+ )}+ {approvalsOff(k) && <ApprovalsOffBadge compact title={`${k.name} acts without asking. Payments still ask you.`} />}+ {!phone && (+ <span className="ml-auto flex items-center gap-0.5">+ {onEditKwant && (+ <button+ type="button"+ onClick={(e) => {+ e.stopPropagation();+ onEditKwant(k);+ }}+ className="opacity-0 group-hover/fleet:opacity-100 focus-visible:opacity-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-400 p-0.5 rounded text-zinc-500 hover:text-sky-300 hover:bg-sky-500/10 transition-all"+ title={`Edit or delete ${k.name}`}+ aria-label={`Edit or delete ${k.name}`}+ >+ <Pencil size={11} />+ </button>+ )}+ {team && !isLead && onUpdateTeamMembers && (+ <button+ type="button"+ onClick={(e) => {+ e.stopPropagation();+ onUpdateTeamMembers(team, memberIds.filter((id) => id !== k.id));+ }}+ className="opacity-0 group-hover/fleet:opacity-100 focus-visible:opacity-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-400 p-0.5 rounded text-zinc-500 hover:text-rose-300 hover:bg-rose-500/10 transition-all"+ title={`Remove ${k.name} from @${team.name}`}+ aria-label={`Remove ${k.name} from @${team.name}`}+ >+ <X size={11} />+ </button>+ )}+ </span>+ )}+ </div>+ {busyKwants[k.id] ? (+ <p className="text-[11px] text-sky-300 truncate" title={busyKwants[k.id]}>+ {busyKwants[k.id]}+ </p>+ ) : (+ <p className="text-[11px] text-zinc-500 truncate">{k.title}</p>+ )}+ </div>+ {/* Phones: one button at the row's end; in a team it opens the member's actions */}+ {phone && team && (onEditKwant || (onUpdateTeamMembers && !isLead)) && (+ <button+ type="button"+ onClick={(e) => {+ e.stopPropagation();+ playSfx('click');+ setMemberMenu({ team, kwant: k });+ }}+ aria-haspopup="dialog"+ aria-label={`More for ${k.name}`}+ className="-mr-1 shrink-0 rounded-lg text-zinc-500 hover:text-zinc-200 hover:bg-zinc-800 active:bg-zinc-800 transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-400"+ >+ <MoreHorizontal size={16} />+ </button>+ )}+ {phone && !team && onEditKwant && (+ <button+ type="button"+ onClick={(e) => {+ e.stopPropagation();+ onEditKwant(k);+ }}+ className="shrink-0 -my-1 rounded-lg text-zinc-400 hover:text-sky-300 hover:bg-sky-500/10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-400"+ title={`Edit or delete ${k.name}`}+ aria-label={`Edit or delete ${k.name}`}+ >+ <Pencil size={16} />+ </button>+ )}+ </div>+ );+ };++ // A team's chat row: opens the team chat; collapses its members, opens its settings.+ const teamRow = (t: Team, withMembers: boolean) => {+ const active = isTeamActive(t);+ const count = memberIdsOf(t).length;+ const expanded = withMembers && !collapsedTeams.has(t.id);+ return (+ <div+ role="button"+ tabIndex={0}+ onClick={() => onSelectTeam(t)}+ onKeyDown={(e) => e.key === 'Enter' && onSelectTeam(t)}+ data-team-row={t.id}+ title={`Open the @${t.name} team chat`}+ className={`w-full flex items-center justify-between px-1.5 py-1.5 rounded-lg text-xs font-medium transition-all text-left group cursor-pointer ${+ active ? 'bg-zinc-800 text-zinc-100 shadow-sm border border-zinc-700/50' : 'text-zinc-300 hover:text-zinc-100 hover:bg-zinc-800/50 border border-transparent'+ }`}+ >+ <div className="flex items-center gap-1.5 min-w-0">+ {withMembers && (+ <button+ type="button"+ onClick={(e) => {+ e.stopPropagation();+ toggleTeam(t.id);+ }}+ aria-expanded={expanded}+ aria-label={expanded ? `Hide @${t.name} members` : `Show @${t.name} members`}+ className="p-0.5 rounded text-zinc-500 hover:text-zinc-200 hover:bg-zinc-700/60"+ >+ <ChevronDown size={12} className={`transition-transform duration-150 ${expanded ? '' : '-rotate-90'}`} />+ </button>+ )}+ <Users size={14} className={active ? 'text-sky-400' : 'text-zinc-500 group-hover:text-zinc-400'} aria-hidden="true" />+ <span className="truncate">@{t.name}</span>+ </div>+ <div className="flex items-center gap-1 flex-shrink-0">+ {(!expanded || !withMembers) && (+ <span className="text-[10px] px-1.5 py-0.5 rounded-full tabular-nums bg-zinc-800/80 text-zinc-400 border border-zinc-800" title={`${count} ${count === 1 ? 'member' : 'members'}`}>+ {count}+ </span>+ )}+ {onManageTeam && (+ <button+ type="button"+ onClick={(e) => {+ e.stopPropagation();+ playSfx('click');+ onManageTeam(t);+ }}+ className="opacity-0 group-hover:opacity-100 focus-visible:opacity-100 max-md:opacity-100 p-1 hover:text-zinc-100 hover:bg-zinc-700/60 rounded transition-all text-zinc-400"+ title={`Team settings for @${t.name}`}+ aria-label={`Team settings for @${t.name}`}+ >+ <Settings2 size={12} />+ </button>+ )}+ </div>+ </div>+ );+ };++ const addMember = (t: Team) => {+ const memberIds = memberIdsOf(t);+ const candidates = kwants.filter((k) => !memberIds.includes(k.id));+ if (!onUpdateTeamMembers) return null;+ if (addingTo !== t.id) {+ return (<buttontype="button"onClick={() => {+ setAddingTo(t.id);playSfx('click');- setSwitcherOpen((v) => !v);}}- data-space-toggle- aria-haspopup="menu"- aria-expanded={switcherOpen}- className="w-full flex items-center gap-2.5 px-1.5 py-1.5 rounded-lg text-left hover:bg-zinc-800/60 transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-500"+ className="w-full flex items-center gap-2 px-2 py-1 rounded-md text-[11px] text-sky-400/90 hover:text-sky-300 hover:bg-sky-500/10 transition-colors">- <SpaceTile space={space} size={32} />- <span className="flex-1 min-w-0">- <span className="block text-sm font-semibold text-zinc-100 truncate">{space.name}</span>- <span className="block text-[11px] text-zinc-500 truncate">{spaceSummary(space.counts)}</span>+ <span className="w-[18px] h-[18px] flex items-center justify-center rounded border border-dashed border-sky-500/40">+ <Plus size={11} /></span>- <ChevronDown size={14} className={`shrink-0 text-zinc-500 transition-transform ${switcherOpen ? 'rotate-180' : ''}`} aria-hidden="true" />+ <span>Add member</span></button>+ );+ }+ return (+ <div className="rounded-lg border border-zinc-700/60 bg-zinc-900/90 p-1 space-y-0.5">+ <div className="flex items-center justify-between px-1.5 pt-0.5 pb-1 text-[10px] uppercase tracking-wider text-zinc-500">+ <span>Add to @{t.name}</span>+ <button type="button" onClick={() => setAddingTo(null)} className="p-0.5 rounded hover:text-zinc-200 hover:bg-zinc-700/60" title="Cancel" aria-label="Cancel">+ <X size={11} />+ </button>+ </div>+ {candidates.map((k) => (+ <button+ key={k.id}+ type="button"+ onClick={() => {+ onUpdateTeamMembers(t, [...memberIds, k.id]);+ setAddingTo(null);+ }}+ className="w-full flex items-center gap-2 px-1.5 py-1 rounded-md text-[11px] text-zinc-300 hover:bg-sky-500/10 hover:text-zinc-100 text-left"+ >+ <ModernAvatar role={k.avatar_sprite} name={k.name} size={18} kwantId={k.id} />+ <span className="truncate flex-1">{k.name}</span>+ <span className="text-[10px] text-zinc-500 truncate max-w-[80px]">{k.title}</span>+ </button>+ ))}+ {candidates.length === 0 && <div className="px-1.5 py-1 text-[11px] text-zinc-500">Every bot is already in this team.</div>}+ <button+ type="button"+ onClick={() => {+ setAddingTo(null);+ onSummonKwant(t);+ }}+ className="w-full flex items-center gap-2 px-1.5 py-1 rounded-md text-[11px] text-sky-400 hover:bg-sky-500/10 border-t border-zinc-800 mt-0.5 pt-1.5"+ >+ <UserPlus size={13} />+ <span>Create a new bot…</span>+ </button>+ </div>+ );+ };++ const groups = botGroups(teams, kwants);+ const headButton = (label: string, title: string, onClick: () => void) =>+ phone ? (+ phoneAdd(title, onClick)+ ) : (+ <button+ type="button"+ onClick={onClick}+ className="flex items-center gap-1 text-[10px] font-medium text-sky-400 hover:text-sky-300 hover:bg-sky-500/10 px-1.5 py-0.5 rounded border border-sky-500/20 transition-all normal-case tracking-normal focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-500"+ title={title}+ >+ <Plus size={11} />+ <span>{label}</span>+ </button>+ );++ return (+ <aside+ aria-label={`${space.name} chats and kwant bots`}+ className={`${phone ? 'w-full flex-1 min-h-0' : 'w-64 h-full border-r border-zinc-800/80'} bg-zinc-900/40 flex flex-col select-none flex-shrink-0`}+ >+ {/* The open space. Desktop switches spaces on the rail, so this is its name and settings;+ phones have no rail, so here it is their one switcher. */}+ <div className="relative p-2 border-b border-zinc-800/60">+ {phone ? (+ <button+ type="button"+ onClick={() => {+ playSfx('click');+ setSwitcherOpen((v) => !v);+ }}+ data-space-toggle+ aria-haspopup="menu"+ aria-expanded={switcherOpen}+ className="w-full flex items-center gap-2.5 px-1.5 py-1.5 rounded-lg text-left hover:bg-zinc-800/60 transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-500"+ >+ <SpaceTile space={space} size={32} />+ <span className="flex-1 min-w-0">+ <span className="block text-sm font-semibold text-zinc-100 truncate">{space.name}</span>+ <span className="block text-[11px] text-zinc-500 truncate">{spaceSummary(space.counts)}</span>+ </span>+ <ChevronDown size={14} className={`shrink-0 text-zinc-500 transition-transform ${switcherOpen ? 'rotate-180' : ''}`} aria-hidden="true" />+ </button>+ ) : (+ <div className="flex items-center gap-2.5 px-1.5 py-1.5" data-space-header>+ <SpaceTile space={space} size={32} />+ <span className="flex-1 min-w-0">+ <h1 className="text-sm font-semibold text-zinc-100 truncate">{space.name}</h1>+ <span className="block text-[11px] text-zinc-500 truncate">{spaceSummary(space.counts)}</span>+ </span>+ <button+ type="button"+ onClick={() => {+ playSfx('click');+ onOpenSpaceSettings();+ }}+ data-space-settings-open+ aria-label={`Settings for ${space.name}`}+ title={`Settings for ${space.name}`}+ className="shrink-0 p-1.5 rounded-lg text-zinc-400 hover:text-zinc-100 hover:bg-zinc-800 transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-500"+ >+ <Settings size={15} aria-hidden="true" />+ </button>+ </div>+ )}{offLine && (<buttontype="button"onClick={onOpenSpaceSettings}- title="Bots here act without asking, including deletions, publishing and sign-ins. Payments still ask you. Change it in Space settings."+ title="Bots here act without asking, including deletions, publishing and sign-ins. Payments still ask you. Change it in Settings › This space."className="mt-1 w-full flex items-center gap-1.5 px-2 py-1 rounded-md border border-amber-500/30 bg-amber-500/10 text-[11px] font-medium text-amber-200 hover:bg-amber-500/20 focus-visible:outline focus-visible:outline-2 focus-visible:outline-amber-400"><ShieldOff size={12} aria-hidden="true" className="shrink-0" /><span className="truncate">{offLine}</span></button>)}- {switcherOpen && (+ {phone && switcherOpen && (<SpaceSwitcherspaces={spaces}currentId={space.id}@@ -301,24 +658,25 @@ export const Sidebar: React.FC<SidebarProps> = ({<div className="flex-1 overflow-y-auto p-2 space-y-4">{showChats && (- <div className="space-y-0.5">+ <div className="space-y-0.5" data-utility-rows><button type="button" onClick={onOpenSearch} className={navRow(false)}><Search size={15} className="text-zinc-500" aria-hidden="true" /><span className="truncate flex-1">Search {space.name}</span>{!phone && <kbd className="shrink-0 text-[10px] font-sans text-zinc-500">{isMac ? '⌘K' : 'Ctrl K'}</kbd>}</button>- {onOpenAway && !phone && (+ {/* Phones have Inbox as a tab */}+ {onOpenInbox && !phone && (<buttontype="button"- onClick={onOpenAway}- aria-current={awayActive ? 'page' : undefined}- className={navRow(awayActive)}+ onClick={onOpenInbox}+ aria-current={inboxActive ? 'page' : undefined}+ className={navRow(inboxActive)}>- <Inbox size={15} className={awayActive ? 'text-sky-400' : 'text-zinc-500'} aria-hidden="true" />- <span className="truncate flex-1">While you were away</span>- {awayCount > 0 && (+ <Inbox size={15} className={inboxActive ? 'text-sky-400' : 'text-zinc-500'} aria-hidden="true" />+ <span className="truncate flex-1">Inbox</span>+ {inboxCount > 0 && (<span className="shrink-0 min-w-[18px] px-1.5 py-px rounded-full bg-amber-500 text-zinc-950 text-[10px] font-semibold text-center">- {badgeText(awayCount)}+ {badgeText(inboxCount)}<span className="sr-only"> new</span></span>)}@@ -330,29 +688,13 @@ export const Sidebar: React.FC<SidebarProps> = ({<span className="truncate flex-1">Mission board</span></button>)}- {onOpenLooseEnds && (- <button type="button" onClick={onOpenLooseEnds} aria-current={looseActive ? 'page' : undefined} className={navRow(looseActive)}>- <ListChecks size={15} className={looseActive ? 'text-sky-400' : 'text-zinc-500'} aria-hidden="true" />- <span className="truncate flex-1">Loose ends</span>- </button>- )}{onOpenParallel && (- <button type="button" onClick={onOpenParallel} aria-current={parallelActive ? 'page' : undefined} className={navRow(parallelActive)}>- <Split size={15} className={parallelActive ? 'text-sky-400' : 'text-zinc-500'} aria-hidden="true" />- <span className="truncate flex-1">Parallel Universe</span>- </button>+ <MoreMenu+ className={navRow(parallelActive)}+ active={parallelActive}+ items={[{ label: 'Parallel Universe', icon: <Split size={15} aria-hidden="true" />, active: parallelActive, onClick: onOpenParallel }]}+ />)}- {onOpenConnections && (- <button type="button" onClick={onOpenConnections} aria-current={connectionsActive ? 'page' : undefined} className={navRow(connectionsActive)}>- <Plug size={15} className={connectionsActive ? 'text-sky-400' : 'text-zinc-500'} aria-hidden="true" />- <span className="truncate flex-1">Connections</span>- </button>- )}- <button type="button" onClick={onOpenRoutines} className={navRow(false)}>- <CalendarClock size={15} className="text-zinc-500" aria-hidden="true" />- <span className="truncate flex-1">Routines</span>- </button>- <InstallAppButton className={navRow(false)} /></div>)}@@ -361,17 +703,7 @@ export const Sidebar: React.FC<SidebarProps> = ({<div><div className={sectionHead}><span>Channels</span>- {onCreateChannel && kwants.length > 0 && (phone ? phoneAdd(`New channel in ${space.name}`, onCreateChannel) :- <button- type="button"- onClick={onCreateChannel}- className="flex items-center gap-1 text-[10px] font-medium text-sky-400 hover:text-sky-300 hover:bg-sky-500/10 px-1.5 py-0.5 rounded border border-sky-500/20 transition-all normal-case tracking-normal focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-500"- title={`New channel in ${space.name}`}- >- <Plus size={11} />- <span>New channel</span>- </button>- )}+ {onCreateChannel && kwants.length > 0 && headButton('New channel', `New channel in ${space.name}`, onCreateChannel)}</div><div className="mt-1 space-y-0.5">{displayChannels.map((c) => {@@ -400,377 +732,62 @@ export const Sidebar: React.FC<SidebarProps> = ({</div>)}- {/* Teams Section */}- {showChats && (+ {/* Phones' Chats tab: team chats are chats too; their members live on the Bots tab */}+ {section === 'chats' && teams.length > 0 && (<div><div className={sectionHead}>- <button- type="button"- onClick={() => setTeamsOpen(!teamsOpen)}- className="flex items-center gap-1 hover:text-zinc-300 transition-colors"- >- <ChevronDown- size={12}- className={`transition-transform duration-150 ${teamsOpen ? '' : '-rotate-90'}`}- />- <span>Teams ({teams.length})</span>- </button>- {phone ? phoneAdd(`New team in ${space.name}`, onCreateTeam) : (- <button- type="button"- onClick={onCreateTeam}- className="flex items-center gap-1 text-[10px] font-medium text-sky-400 hover:text-sky-300 hover:bg-sky-500/10 px-1.5 py-0.5 rounded border border-sky-500/20 transition-all normal-case tracking-normal"- title={`New team in ${space.name}`}- >- <Plus size={11} />- <span>New team</span>- </button>- )}+ <span>Team chats</span>+ </div>+ <div className="mt-1 space-y-0.5">+ {teams.map((t) => (+ <React.Fragment key={t.id}>{teamRow(t, false)}</React.Fragment>+ ))}</div>-- {teamsOpen && (- <div className="mt-1 space-y-0.5">- {teams.map((t) => {- const active = isTeamActive(t);- const memberIds = memberIdsOf(t);- const members = memberIds- .map((id) => kwants.find((k) => k.id === id))- .filter((k): k is Kwant => !!k);- const candidates = kwants.filter((k) => !memberIds.includes(k.id));- const expanded = !collapsedTeams.has(t.id);- const picking = addingTo === t.id;-- return (- <div key={t.id}>- <div- role="button"- tabIndex={0}- onClick={() => onSelectTeam(t)}- onKeyDown={(e) => e.key === 'Enter' && onSelectTeam(t)}- className={`w-full flex items-center justify-between px-1.5 py-1.5 rounded-lg text-xs font-medium transition-all text-left group cursor-pointer ${- active- ? 'bg-zinc-800 text-zinc-100 shadow-sm border border-zinc-700/50'- : 'text-zinc-400 hover:text-zinc-200 hover:bg-zinc-800/50 border border-transparent'- }`}- >- <div className="flex items-center gap-1.5 min-w-0">- <button- type="button"- onClick={(e) => {- e.stopPropagation();- toggleTeam(t.id);- }}- className="p-0.5 rounded text-zinc-500 hover:text-zinc-200 hover:bg-zinc-700/60"- title={expanded ? 'Hide members' : 'Show members'}- >- <ChevronDown- size={12}- className={`transition-transform duration-150 ${expanded ? '' : '-rotate-90'}`}- />- </button>- <Users size={14} className={active ? 'text-sky-400' : 'text-zinc-500 group-hover:text-zinc-400'} />- <span className="truncate">@{t.name}</span>- </div>- <div className="flex items-center gap-1 flex-shrink-0">- {!expanded && (- <span className="text-[10px] px-1.5 py-0.5 rounded-full tabular-nums bg-zinc-800/80 text-zinc-400 border border-zinc-800">- {memberIds.length}- </span>- )}- {onManageTeam && (- <button- type="button"- onClick={(e) => {- e.stopPropagation();- playSfx('click');- onManageTeam(t);- }}- className="opacity-0 group-hover:opacity-100 max-md:opacity-100 p-1 hover:text-zinc-100 hover:bg-zinc-700/60 rounded transition-all text-zinc-400"- title={`Team settings for @${t.name}`}- >- <Settings2 size={12} />- </button>- )}- </div>- </div>-- {expanded && (- <div className="ml-[18px] pl-2 border-l border-zinc-800 mt-0.5 mb-1.5 space-y-0.5">- {members.map((k) => {- const isLead = k.id === t.lead_kwant_id;- const memberActive = !isChannel && selectedId === k.id;- return (- <div- key={k.id}- role="button"- tabIndex={0}- onClick={() => onSelectKwant(k)}- onKeyDown={(e) => e.key === 'Enter' && onSelectKwant(k)}- className={`group/member flex items-center gap-2 px-1.5 ${phone ? 'py-0' : 'py-1'} rounded-md cursor-pointer text-[11px] transition-colors ${- memberActive ? 'bg-zinc-800 text-zinc-100' : 'text-zinc-400 hover:bg-zinc-800/50 hover:text-zinc-200'- }`}- title={busyKwants[k.id] ? `Chat with ${k.name} · ${busyKwants[k.id]}` : `Chat with ${k.name}`}- >- <ModernAvatar role={k.avatar_sprite} name={k.name} size={18} kwantId={k.id} />- <span className="truncate flex-1">- {k.name}- {busyKwants[k.id] && <span className="sr-only"> ({busyKwants[k.id]})</span>}- </span>- {needsYou[k.id] > 0 && (- <span className="shrink-0 inline-flex text-amber-300" role="img" aria-label="Needs you in the browser" title="Needs you in the browser">- <Hand size={11} />- </span>- )}- {botStatus[k.id] && (- <span className={`w-1.5 h-1.5 shrink-0 rounded-full ${STATUS_DOT[botStatus[k.id]].replace('border-2', 'border')}`} title={statusText(k.name, botStatus[k.id])} aria-hidden="true" />- )}- {phone ? (- <>- {isLead && (- <span className="shrink-0 flex items-center gap-0.5 text-[9px] uppercase tracking-wide text-amber-300/90" title="Team lead">- <Crown size={10} aria-hidden="true" />- lead- </span>- )}- {(onEditKwant || (onUpdateTeamMembers && !isLead)) && (- <button- type="button"- onClick={(e) => {- e.stopPropagation();- playSfx('click');- setMemberMenu({ team: t, kwant: k });- }}- aria-haspopup="dialog"- aria-label={`More for ${k.name}`}- className="-mr-1 shrink-0 rounded-lg text-zinc-500 hover:text-zinc-200 hover:bg-zinc-800 active:bg-zinc-800 transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-400"- >- <MoreHorizontal size={16} />- </button>- )}- </>- ) : (- <>- {onEditKwant && (- <button- type="button"- onClick={(e) => {- e.stopPropagation();- onEditKwant(k);- }}- className="opacity-0 group-hover/member:opacity-100 max-sm:opacity-100 focus-visible:opacity-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-400 p-0.5 rounded text-zinc-500 hover:text-sky-300 hover:bg-sky-500/10 transition-all"- title={`Edit or delete ${k.name}`}- aria-label={`Edit or delete ${k.name}`}- >- <Pencil size={11} />- </button>- )}- {isLead ? (- <span className="flex items-center gap-0.5 text-[9px] uppercase tracking-wide text-amber-300/90" title="Team lead">- <Crown size={10} />- lead- </span>- ) : (- onUpdateTeamMembers && (- <button- type="button"- onClick={(e) => {- e.stopPropagation();- onUpdateTeamMembers(t, memberIds.filter((id) => id !== k.id));- }}- className="opacity-0 group-hover/member:opacity-100 max-sm:opacity-100 focus-visible:opacity-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-400 p-0.5 rounded text-zinc-500 hover:text-rose-300 hover:bg-rose-500/10 transition-all"- title={`Remove ${k.name} from @${t.name}`}- >- <X size={11} />- </button>- )- )}- </>- )}- </div>- );- })}-- {onUpdateTeamMembers && !picking && (- <button- type="button"- onClick={() => {- setAddingTo(t.id);- playSfx('click');- }}- className="w-full flex items-center gap-2 px-1.5 py-1 rounded-md text-[11px] text-sky-400/90 hover:text-sky-300 hover:bg-sky-500/10 transition-colors"- >- <span className="w-[18px] h-[18px] flex items-center justify-center rounded border border-dashed border-sky-500/40">- <Plus size={11} />- </span>- <span>Add member</span>- </button>- )}-- {onUpdateTeamMembers && picking && (- <div className="rounded-lg border border-zinc-700/60 bg-zinc-900/90 p-1 space-y-0.5">- <div className="flex items-center justify-between px-1.5 pt-0.5 pb-1 text-[10px] uppercase tracking-wider text-zinc-500">- <span>Add to @{t.name}</span>- <button- type="button"- onClick={() => setAddingTo(null)}- className="p-0.5 rounded hover:text-zinc-200 hover:bg-zinc-700/60"- title="Cancel"- >- <X size={11} />- </button>- </div>- {candidates.map((k) => (- <button- key={k.id}- type="button"- onClick={() => {- onUpdateTeamMembers(t, [...memberIds, k.id]);- setAddingTo(null);- }}- className="w-full flex items-center gap-2 px-1.5 py-1 rounded-md text-[11px] text-zinc-300 hover:bg-sky-500/10 hover:text-zinc-100 text-left"- >- <ModernAvatar role={k.avatar_sprite} name={k.name} size={18} kwantId={k.id} />- <span className="truncate flex-1">{k.name}</span>- <span className="text-[10px] text-zinc-500 truncate max-w-[80px]">{k.title}</span>- </button>- ))}- {candidates.length === 0 && (- <div className="px-1.5 py-1 text-[11px] text-zinc-500">Every bot is already in this team.</div>- )}- <button- type="button"- onClick={() => {- setAddingTo(null);- onSummonKwant(t);- }}- className="w-full flex items-center gap-2 px-1.5 py-1 rounded-md text-[11px] text-sky-400 hover:bg-sky-500/10 border-t border-zinc-800 mt-0.5 pt-1.5"- >- <UserPlus size={13} />- <span>Create a new bot…</span>- </button>- </div>- )}- </div>- )}- </div>- );- })}- {teams.length === 0 && (- <div className="px-2.5 py-1.5 text-[11px] text-zinc-500 italic">- No teams in {space.name} yet.- </div>- )}- </div>- )}</div>-)}- {/* Every bot in this space */}+ {/* Every bot once, grouped by team; bots in no team last */}{showBots && (- <div>+ <div data-bot-list><div className={sectionHead}>- <h2>Kwant bots ({kwants.length})</h2>- {phone ? phoneAdd(`New bot in ${space.name}`, () => onSummonKwant()) : (- <button- type="button"- onClick={() => onSummonKwant()}- className="flex items-center gap-1 text-[10px] font-medium text-sky-400 hover:text-sky-300 hover:bg-sky-500/10 px-1.5 py-0.5 rounded border border-sky-500/20 transition-all normal-case tracking-normal"- title={`New bot in ${space.name}`}- >- <Plus size={11} />- <span>New bot</span>- </button>- )}+ <h2>Bots ({kwants.length})</h2>+ <span className="flex items-center gap-1">+ {headButton('New team', `New team in ${space.name}`, onCreateTeam)}+ {headButton('New bot', `New bot in ${space.name}`, () => onSummonKwant())}+ </span></div>- <div className="mt-1 space-y-1">- {kwants.length === 0 && (+ <div className="mt-1 space-y-2">+ {kwants.length === 0 && teams.length === 0 && (<div className="px-2.5 py-1.5 text-[11px] text-zinc-500">No bots in {space.name} yet.</div>)}- {kwants.map((k) => {- const active = !isChannel && selectedId === k.id;- return (- <div- key={k.id}- role="button"- tabIndex={0}- onClick={() => onSelectKwant(k)}- onKeyDown={(e) => e.key === 'Enter' && onSelectKwant(k)}- className={`group/fleet w-full flex items-center gap-3 p-2 rounded-xl text-left cursor-pointer transition-all ${- active- ? 'bg-zinc-800/90 text-zinc-100 shadow-sm border border-zinc-700/60'- : 'text-zinc-400 hover:text-zinc-200 hover:bg-zinc-800/40'- }`}- >- <span className="shrink-0" title={statusOf(k.id, botStatus, canRun) === 'cant_run' ? "Can't run yet: no account works here" : undefined}>- <ModernAvatar- role={k.avatar_sprite}- name={k.name}- size={32}- status={statusOf(k.id, botStatus, canRun)}- kwantId={k.id}- />- </span>- <div className="flex-1 min-w-0">- <div className="flex items-center justify-between gap-1">- {/* The full name; what it runs on is in the tooltip */}- <span className="text-xs font-semibold text-zinc-200 truncate" title={`${k.name} · ${engineTip(k.preferred_model)}`}>- {k.name}- </span>- {needsYou[k.id] > 0 && (- <span- className="shrink-0 inline-flex items-center gap-1 px-1.5 py-px rounded-full text-[10px] font-medium bg-amber-400/15 text-amber-200 border border-amber-400/30"- title={`${k.name} needs you in the browser`}- >- <Hand size={10} aria-hidden="true" />- Needs you{needsYou[k.id] > 1 ? ` · ${needsYou[k.id]}` : ''}- </span>- )}- {approvalsOff(k) && <ApprovalsOffBadge compact title={`${k.name} acts without asking. Payments still ask you.`} />}- {onEditKwant && !phone && (- <button- type="button"- onClick={(e) => {- e.stopPropagation();- onEditKwant(k);- }}- className="ml-auto opacity-0 group-hover/fleet:opacity-100 max-sm:opacity-100 focus-visible:opacity-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-400 p-0.5 rounded text-zinc-500 hover:text-sky-300 hover:bg-sky-500/10 transition-all"- title={`Edit or delete ${k.name}`}- aria-label={`Edit or delete ${k.name}`}- >- <Pencil size={11} />- </button>- )}+ {groups.map((g) =>+ g.team ? (+ <div key={g.team.id} data-team-group={g.team.id}>+ {teamRow(g.team, true)}+ {!collapsedTeams.has(g.team.id) && (+ <div className="ml-[13px] pl-1.5 border-l border-zinc-800 mt-0.5 space-y-0.5">+ {g.bots.map((k) => botRow(k, g.team!))}+ {addMember(g.team)}</div>- {busyKwants[k.id] ? (- <p className="text-[11px] text-sky-300 truncate mt-0.5" title={busyKwants[k.id]}>- {busyKwants[k.id]}- </p>- ) : (- <p className="text-[11px] text-zinc-400 truncate mt-0.5">{k.title}</p>- )}- </div>- {/* Phones: the edit button sits at the row's end so it doesn't stretch the name line */}- {onEditKwant && phone && (- <button- type="button"- onClick={(e) => {- e.stopPropagation();- onEditKwant(k);- }}- className="shrink-0 -my-1 rounded-lg text-zinc-400 hover:text-sky-300 hover:bg-sky-500/10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-400"- title={`Edit or delete ${k.name}`}- aria-label={`Edit or delete ${k.name}`}- >- <Pencil size={16} />- </button>)}</div>- );- })}+ ) : (+ g.bots.length > 0 && (+ <div key="no-team" data-team-group="none">+ {teams.length > 0 && (+ <div className="px-2 pt-1 pb-0.5 text-[10px] font-semibold uppercase tracking-wider text-zinc-500">No team</div>+ )}+ <div className="space-y-0.5">{g.bots.map((k) => botRow(k))}</div>+ </div>+ )+ ),+ )}</div></div>)}++ {/* Desktop: a one-time tip; Settings › All spaces keeps "Install app" for later */}+ {section === 'all' && <InstallAppButton tip className={navRow(false)} />}</div>{/* Footer: what this space's bots run on, from the real checks */}diff --git a/frontend/src/components/SpaceSettings.tsx b/frontend/src/components/SpaceSettings.tsxindex a84c4fee..43505239 100644--- a/frontend/src/components/SpaceSettings.tsx+++ b/frontend/src/components/SpaceSettings.tsx@@ -8,12 +8,13 @@ import {Check,Download,FileUp,+ Globe,KeyRound,+ Link2,Loader2,Pencil,Plug,Plus,- Settings,Settings2,Sparkles,Users,@@ -25,6 +26,7 @@ import { useEngines } from '../useEngines';import { useProfiles } from '../useProfiles';import type { Profile } from '../profiles';import { EnginesPanel } from './EnginesPanel';+import { ApiKeysPanel } from './ApiKeysPanel';import { RoutinesPanel, type RoutineFocus } from './RoutinesPanel';import { HirePolicyPanel } from './HirePolicyPanel';import { ModernAvatar } from './ModernAvatar';@@ -34,13 +36,17 @@ import { ImportError, ImportRecord, downloadExport, importApi, importErrorText }import { memberIdsOf, type Channel, type Kwant, type Team } from './Sidebar';import { SpaceApprovalsSetting } from './ApprovalsSetting';-export type SpaceSettingsTab = 'general' | 'accounts' | 'bots' | 'teams' | 'tools' | 'skills' | 'routines' | 'import';+import type { SettingsScope, SpaceSettingsTab } from '../nav';+import { InstallAppButton } from './InstallAppButton';++export type { SettingsScope, SpaceSettingsTab };const TABS: Array<{ id: SpaceSettingsTab; label: string; icon: React.ReactNode }> = [{ id: 'general', label: 'General', icon: <Settings2 size={15} /> },{ id: 'accounts', label: 'Accounts', icon: <KeyRound size={15} /> },{ id: 'bots', label: 'Kwant bots', icon: <Bot size={15} /> },{ id: 'teams', label: 'Teams', icon: <Users size={15} /> },+ { id: 'connections', label: 'Connections', icon: <Link2 size={15} /> },{ id: 'tools', label: 'Tools', icon: <Plug size={15} /> },{ id: 'skills', label: 'Skills', icon: <Sparkles size={15} /> },{ id: 'routines', label: 'Routines', icon: <CalendarClock size={15} /> },@@ -51,9 +57,17 @@ interface Props {space: Space;/** Every space, for taken names. */spaces: Space[];+ /** This space, or All spaces (app-wide settings). */+ scope: SettingsScope;+ onScope: (scope: SettingsScope) => void;tab: SpaceSettingsTab;onTab: (tab: SpaceSettingsTab) => void;onClose: () => void;+ /** This space › Connections: the space's connected apps and tools. */+ connections: React.ReactNode;+ /** All spaces: the app-wide settings. */+ appSettings: React.ReactNode;+ onOpenArchived: () => void;kwants: Kwant[];channels: Channel[];teams: Team[];@@ -69,7 +83,6 @@ interface Props {onNewTeam: () => void;onManageTeam: (t: Team) => void;onOpenTools: () => void;- onOpenAppSettings: () => void;/** Set by a routine card's Edit or Pause: opens that routine in Routines. */routineFocus?: RoutineFocus | null;/** After an import or its undo: load bots, teams and chats again. */@@ -87,9 +100,13 @@ const rowBtn =const primaryBtn ='flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium text-white bg-sky-600 hover:bg-sky-500 transition-colors disabled:opacity-50';-/** Space settings: everything here belongs to the open space only. */+/** Settings, in one place: "This space" (only the open space) and "All spaces" (the app). */export const SpaceSettings: React.FC<Props> = (p) => {- const { space, tab, onTab, onClose } = p;+ const { space, tab, onTab, onClose, scope, onScope } = p;+ const toApp = () => {+ playSfx('click');+ onScope('app');+ };const [importOpen, setImportOpen] = useState(false);// Bumped after the dialog imports or undoes, so the Import tab's list loads again.const [importsSeq, setImportsSeq] = useState(0);@@ -115,73 +132,110 @@ export const SpaceSettings: React.FC<Props> = (p) => {>{/* Tab list: a column on desktop, scrolling chips on phones */}<div className="md:w-60 shrink-0 border-b md:border-b-0 md:border-r border-zinc-800/80 bg-zinc-900/40 flex flex-col">- <div className="flex items-center gap-2.5 p-3 md:p-4">+ <div className="flex items-center gap-2.5 p-3 md:p-4 pb-2 md:pb-3"><button type="button" onClick={onClose} aria-label="Back to chats" className="p-1.5 -ml-1 rounded-lg text-zinc-400 hover:text-zinc-100 hover:bg-zinc-800"><ArrowLeft size={17} /></button>- <SpaceTile space={space} size={28} />- <div className="min-w-0">- <h2 id="space-settings-title" className="text-sm font-semibold truncate">{space.name} settings</h2>- <p className="text-[11px] text-zinc-500">Only affects this space</p>- </div>+ <h2 id="space-settings-title" className="text-sm font-semibold truncate">Settings</h2></div>- <nav aria-label="Space settings" className="flex md:flex-col gap-1 px-3 pb-3 md:px-2 overflow-x-auto md:overflow-visible">- {TABS.map((t) => (+ {/* Which settings: this space's, or the ones every space shares */}+ <div role="tablist" aria-label="Settings scope" className="mx-3 md:mx-2 mb-3 grid grid-cols-2 gap-1 rounded-lg bg-zinc-900 border border-zinc-800 p-0.5">+ {(+ [+ { id: 'space', label: 'This space', icon: <SpaceTile space={space} size={16} /> },+ { id: 'app', label: 'All spaces', icon: <Globe size={13} aria-hidden="true" /> },+ ] as const+ ).map((s) => (<button- key={t.id}+ key={s.id}type="button"- aria-current={tab === t.id ? 'page' : undefined}+ role="tab"+ aria-selected={scope === s.id}+ data-settings-scope={s.id}onClick={() => {+ if (scope === s.id) return;playSfx('click');- onTab(t.id);+ onScope(s.id);}}- className={`shrink-0 flex items-center gap-2 px-3 py-1.5 md:py-2 rounded-full md:rounded-lg text-xs font-medium transition-colors ${- tab === t.id ? 'bg-zinc-800 text-zinc-100 border border-zinc-700/60' : 'text-zinc-400 hover:text-zinc-200 hover:bg-zinc-800/50 border border-transparent'+ className={`flex items-center justify-center gap-1.5 min-w-0 px-2 py-1.5 rounded-md text-xs font-medium transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-500 ${+ scope === s.id ? 'bg-zinc-800 text-zinc-100 shadow-sm' : 'text-zinc-400 hover:text-zinc-200'}`}>- <span className={tab === t.id ? 'text-sky-400' : 'text-zinc-500'} aria-hidden="true">{t.icon}</span>- {t.label}+ <span className="shrink-0 flex">{s.icon}</span>+ <span className="truncate">{s.label}</span></button>))}- </nav>- <div className="hidden md:block mt-auto p-3 border-t border-zinc-800/60">- <button type="button" onClick={p.onOpenAppSettings} className="flex items-center gap-2 text-xs text-zinc-400 hover:text-zinc-100">- <Settings size={14} /> App settings (every space)- </button></div>+ {scope === 'space' && (+ <nav aria-label={`${space.name} settings`} className="flex md:flex-col gap-1 px-3 pb-3 md:px-2 overflow-x-auto md:overflow-visible">+ {TABS.map((t) => (+ <button+ key={t.id}+ type="button"+ aria-current={tab === t.id ? 'page' : undefined}+ onClick={() => {+ playSfx('click');+ onTab(t.id);+ }}+ className={`shrink-0 flex items-center gap-2 px-3 py-1.5 md:py-2 rounded-full md:rounded-lg text-xs font-medium transition-colors ${+ tab === t.id ? 'bg-zinc-800 text-zinc-100 border border-zinc-700/60' : 'text-zinc-400 hover:text-zinc-200 hover:bg-zinc-800/50 border border-transparent'+ }`}+ >+ <span className={tab === t.id ? 'text-sky-400' : 'text-zinc-500'} aria-hidden="true">{t.icon}</span>+ {t.label}+ </button>+ ))}+ </nav>+ )}</div><div className="flex-1 min-w-0 overflow-y-auto"><div className="max-w-2xl mx-auto p-4 sm:p-6 space-y-5"><div className="flex items-center justify-between gap-3"><div>- <h3 className="text-base font-semibold">{TABS.find((t) => t.id === tab)?.label}</h3>- <p className="text-[11px] text-zinc-500">Only affects this space ({space.name})</p>+ <h3 className="text-base font-semibold">{scope === 'app' ? 'All spaces' : TABS.find((t) => t.id === tab)?.label}</h3>+ <p className="text-[11px] text-zinc-500">+ {scope === 'app' ? 'Applies to every space and to this app' : `Only affects this space (${space.name})`}+ </p></div>- <button type="button" onClick={onClose} aria-label="Close space settings" className="hidden md:block p-1.5 rounded-lg text-zinc-400 hover:text-zinc-100 hover:bg-zinc-800">+ <button type="button" onClick={onClose} aria-label="Close settings" className="hidden md:block p-1.5 rounded-lg text-zinc-400 hover:text-zinc-100 hover:bg-zinc-800"><X size={18} /></button></div>- {tab === 'general' && <GeneralTab {...p} />}- {tab === 'accounts' && <AccountsTab {...p} />}- {tab === 'bots' && <BotsTab {...tp} />}- {tab === 'teams' && <TeamsTab {...p} />}- {tab === 'tools' && (- <div className={`${card} p-4 space-y-3`}>- <p className="text-xs text-zinc-300">Tool servers (MCP) give the bots in {space.name} abilities like files, web pages or GitHub.</p>- <button type="button" onClick={p.onOpenTools} className={primaryBtn}>- <Plug size={13} /> Manage tools- </button>- </div>+ {scope === 'app' ? (+ <>+ <div className={`${card} p-4 space-y-3`} data-all-spaces-spaces>+ <p className="text-xs font-medium text-zinc-200">Spaces</p>+ <p className="text-[11px] text-zinc-500">Switch spaces on the left rail (Ctrl or ⌘ with 1–9). Archived spaces keep their bots and chats until you restore them.</p>+ <div className="flex flex-wrap gap-2">+ <button type="button" onClick={p.onOpenArchived} className={rowBtn}>+ <Archive size={13} /> Archived spaces+ </button>+ <InstallAppButton className={rowBtn} />+ </div>+ </div>+ {p.appSettings}+ </>+ ) : (+ <>+ {tab === 'general' && <GeneralTab {...p} />}+ {tab === 'accounts' && <AccountsTab {...p} />}+ {tab === 'bots' && <BotsTab {...tp} />}+ {tab === 'teams' && <TeamsTab {...p} />}+ {tab === 'connections' && <div data-settings-connections>{p.connections}</div>}+ {tab === 'tools' && (+ <div className={`${card} p-4 space-y-3`}>+ <p className="text-xs text-zinc-300">Tool servers (MCP) give the bots in {space.name} abilities like files, web pages or GitHub.</p>+ <button type="button" onClick={p.onOpenTools} className={primaryBtn}>+ <Plug size={13} /> Manage tools+ </button>+ </div>+ )}+ {tab === 'skills' && <SkillsTab {...p} />}+ {tab === 'routines' && <RoutinesPanel kwants={p.kwants} channels={p.channels} focus={p.routineFocus} onOpenSettings={toApp} />}+ {tab === 'import' && <ImportTab {...tp} />}+ </>)}- {tab === 'skills' && <SkillsTab {...p} />}- {tab === 'routines' && <RoutinesPanel kwants={p.kwants} channels={p.channels} focus={p.routineFocus} onOpenSettings={p.onOpenAppSettings} />}- {tab === 'import' && <ImportTab {...tp} />}- <div className="md:hidden pt-2">- <button type="button" onClick={p.onOpenAppSettings} className="flex items-center gap-2 text-xs text-zinc-400 hover:text-zinc-100">- <Settings size={14} /> App settings (every space)- </button>- </div></div></div>{importOpen && (@@ -467,6 +521,13 @@ const AccountsTab: React.FC<Props> = ({ space, focusClaudeSignIn, onProfilesChan<div className="space-y-3"><p className="text-xs text-zinc-400">What runs your kwant bots in {space.name}: the accounts here, and This machine when it’s on.</p><EnginesPanel api={engines} accounts={accounts} focusClaudeSignIn={focusClaudeSignIn} />+ <ApiKeysPanel+ onSaved={() => {+ // Saving a key or the Ollama address re-checks engines on the server; show the result.+ window.setTimeout(engines.reload, 1500);+ window.setTimeout(engines.reload, 6000);+ }}+ /></div>);};diff --git a/frontend/src/components/Spaces.tsx b/frontend/src/components/Spaces.tsxindex be974dab..50f699da 100644--- a/frontend/src/components/Spaces.tsx+++ b/frontend/src/components/Spaces.tsx@@ -86,8 +86,8 @@ export const SpaceRail: React.FC<RailProps> = ({ spaces, currentId, onSwitch, on<buttontype="button"onClick={onOpenAppSettings}- aria-label="App settings"- title="App settings"+ aria-label="Settings (all spaces)"+ title="Settings (all spaces)"className="w-10 h-10 rounded-xl text-zinc-400 hover:text-zinc-100 hover:bg-zinc-800 flex items-center justify-center transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-400"><Settings size={18} />diff --git a/frontend/src/nav.ts b/frontend/src/nav.tsnew file mode 100644index 00000000..6f0cf0da--- /dev/null+++ b/frontend/src/nav.ts@@ -0,0 +1,98 @@+// Where you are inside a space besides a chat: Inbox, Mission board, Parallel Universe or+// Settings. Each has its own address under /s/<space>/, so a reload, a bookmark or a link+// lands on the same place. Older names (While you were away, Loose ends, Connections,+// Routines) still resolve and are rewritten to the new address.++export type InboxTab = 'new' | 'loose';++/** Settings › This space tabs. Kept here, not in the component, so routing stays pure. */+export const SPACE_SETTINGS_TABS = ['general', 'accounts', 'bots', 'teams', 'connections', 'tools', 'skills', 'routines', 'import'] as const;+export type SpaceSettingsTab = (typeof SPACE_SETTINGS_TABS)[number];++export type SettingsScope = 'space' | 'app';++export type SpaceView =+ | { kind: 'inbox'; tab: InboxTab }+ | { kind: 'board' }+ | { kind: 'parallel' }+ | { kind: 'settings'; scope: 'space'; tab: SpaceSettingsTab }+ | { kind: 'settings'; scope: 'app' };++/** The address segment after /s/<space>/ for a view. */+export function viewSegment(v: SpaceView): string {+ switch (v.kind) {+ case 'inbox':+ return v.tab === 'loose' ? 'inbox/loose-ends' : 'inbox';+ case 'board':+ return 'board';+ case 'parallel':+ return 'parallel';+ case 'settings':+ return v.scope === 'app' ? 'settings/app' : `settings/${v.tab}`;+ }+}++/** Old names that still open the right place. */+const LEGACY: Record<string, SpaceView> = {+ away: { kind: 'inbox', tab: 'new' },+ 'while-you-were-away': { kind: 'inbox', tab: 'new' },+ 'loose-ends': { kind: 'inbox', tab: 'loose' },+ connections: { kind: 'settings', scope: 'space', tab: 'connections' },+ routines: { kind: 'settings', scope: 'space', tab: 'routines' },+ 'mission-board': { kind: 'board' },+ missions: { kind: 'board' },+ 'parallel-universe': { kind: 'parallel' },+ 'app-settings': { kind: 'settings', scope: 'app' },+};++/**+ * The view an address segment names, or null when it names none. `legacy` is true when the+ * segment is an old name, so the caller rewrites the address to `viewSegment(view)`.+ */+export function parseView(segment: string): { view: SpaceView; legacy: boolean } | null {+ const s = segment.replace(/^\/+|\/+$/g, '').toLowerCase();+ if (!s) return null;+ if (LEGACY[s]) return { view: LEGACY[s], legacy: true };+ const [head, sub, ...rest] = s.split('/');+ if (rest.length) return null;+ if (head === 'inbox') {+ if (!sub || sub === 'new') return { view: { kind: 'inbox', tab: 'new' }, legacy: !!sub };+ if (sub === 'loose-ends' || sub === 'loose') return { view: { kind: 'inbox', tab: 'loose' }, legacy: sub !== 'loose-ends' };+ return null;+ }+ if (head === 'board' && !sub) return { view: { kind: 'board' }, legacy: false };+ if (head === 'parallel' && !sub) return { view: { kind: 'parallel' }, legacy: false };+ if (head === 'settings') {+ if (!sub) return { view: { kind: 'settings', scope: 'space', tab: 'general' }, legacy: true };+ if (sub === 'app' || sub === 'all') return { view: { kind: 'settings', scope: 'app' }, legacy: sub !== 'app' };+ if ((SPACE_SETTINGS_TABS as readonly string[]).includes(sub)) {+ return { view: { kind: 'settings', scope: 'space', tab: sub as SpaceSettingsTab }, legacy: false };+ }+ return null;+ }+ return null;+}++/** Whether two views are the same place. */+export function sameView(a: SpaceView | null | undefined, b: SpaceView | null | undefined): boolean {+ if (!a || !b) return !a && !b;+ return viewSegment(a) === viewSegment(b);+}++const INSTALL_TIP_KEY = 'kwnt.installTip.dismissed';++/** The desktop "Install app" tip shows until it is dismissed or the app is installed. */+export function installTipDismissed(): boolean {+ try {+ return localStorage.getItem(INSTALL_TIP_KEY) === '1';+ } catch {+ return false;+ }+}+export function dismissInstallTip() {+ try {+ localStorage.setItem(INSTALL_TIP_KEY, '1');+ } catch {+ // private mode: it comes back next load+ }+}diff --git a/frontend/src/spaces.ts b/frontend/src/spaces.tsindex 38301e2b..fbbaf82f 100644--- a/frontend/src/spaces.ts+++ b/frontend/src/spaces.ts@@ -1,6 +1,7 @@// Spaces: separate sets of bots, teams, channels and accounts. The open space rides on every// `/api` call as `?space=` (added by the fetch wrapper in auth.ts) and on the event stream.+import { parseView, viewSegment, type SpaceView } from './nav';import { serverReason } from './routeReason';export interface SpaceCounts {@@ -151,25 +152,39 @@ export function withSpace(url: string, origin: string, spaceId: string | null):/** The event stream for one space. */export const eventsUrl = (spaceId: string | null) => (spaceId ? `/api/events?space=${encodeURIComponent(spaceId)}` : '/api/events');-// ---- Addresses: /s/<space>/c/<channel>, /s/<space>/b/<bot> ----+// ---- Addresses: /s/<space>/c/<channel>, /s/<space>/b/<bot>, /s/<space>/<view> ----export interface SpaceRoute {spaceId: string | null;channelId?: string;botId?: string;+ /** Inbox, Mission board, Parallel Universe or Settings (see nav.ts). */+ view?: SpaceView;+ /** The address used an old name for the view; rewrite it to `spacePath(...)`. */+ legacy?: boolean;}export function parseSpacePath(path: string): SpaceRoute {- const m = path.match(/^\/s\/([^/]+)(?:\/(c|b)\/([^/]+))?\/?$/);+ const m = path.match(/^\/s\/([^/]+)(?:\/(.*?))?\/?$/);if (!m) return { spaceId: null };const spaceId = decodeURIComponent(m[1]);- if (m[2] === 'c') return { spaceId, channelId: decodeURIComponent(m[3]) };- if (m[2] === 'b') return { spaceId, botId: decodeURIComponent(m[3]) };- return { spaceId };+ const rest = m[2] ?? '';+ const chat = rest.match(/^(c|b)\/([^/]+)$/);+ if (chat?.[1] === 'c') return { spaceId, channelId: decodeURIComponent(chat[2]) };+ if (chat?.[1] === 'b') return { spaceId, botId: decodeURIComponent(chat[2]) };+ const v = rest ? parseView(rest) : null;+ if (v) return v.legacy ? { spaceId, view: v.view, legacy: true } : { spaceId, view: v.view };+ // An address this version doesn't know still opens the space, and is rewritten.+ return rest ? { spaceId, legacy: true } : { spaceId };}-export function spacePath(spaceId: string, target?: { channelId?: string | null; botId?: string | null }): string {+export function spacePath(+ spaceId: string,+ target?: { channelId?: string | null; botId?: string | null } | null,+ view?: SpaceView | null,+): string {const base = `/s/${encodeURIComponent(spaceId)}`;+ if (view) return `${base}/${viewSegment(view)}`;if (target?.channelId) return `${base}/c/${encodeURIComponent(target.channelId)}`;if (target?.botId) return `${base}/b/${encodeURIComponent(target.botId)}`;return base;diff --git a/frontend/tests/automationDiscovery.test.mjs b/frontend/tests/automationDiscovery.test.mjsindex 3faee9de..0acfecdd 100644--- a/frontend/tests/automationDiscovery.test.mjs+++ b/frontend/tests/automationDiscovery.test.mjs@@ -260,7 +260,7 @@ test('the automation_suggested notification: a toggle where the server has it, aassert.ok(m.TOAST_KINDS.includes('automation_suggested'));assert.equal(m.shouldShowOsNotification({ enabled: true, permission: 'granted', hidden: true, kind: 'automation_suggested' }), true);const app = readFileSync(new URL('../src/App.tsx', import.meta.url), 'utf8');- assert.match(app, /n\.kind === 'automation_suggested'\) setIsRoutinesOpen\(true\)/, 'a tapped notification opens Routines');+ assert.match(app, /n\.kind === 'automation_suggested'\) openSpaceSettings\('routines'\)/, 'a tapped notification opens Settings › This space › Routines');assert.doesNotMatch(readFileSync(new URL('../src/missions.ts', import.meta.url), 'utf8'), /automation_suggested/, 'not on the Needs-you list');const settings = readFileSync(new URL('../src/components/SettingsModal.tsx', import.meta.url), 'utf8');assert.match(settings, /notifyKindsFor\(appUpdates, !!proactive, !!discovery[,)]/);@@ -404,7 +404,7 @@ test('blocked: off is one quiet line; board off and no time zone each show theirbox = v.host.querySelector('[data-testid="discovery-blocked"]');assert.equal(box.getAttribute('role'), 'status');assert.match(box.textContent, /the board is off\..*Turn on “Show the Mission board” in Settings/);- assert.match(box.textContent, /time zone isn’t set.*Set your time zone in Settings, under Where you are/);+ assert.match(box.textContent, /time zone isn’t set.*Set your time zone in Settings › All spaces, under Where you are/);assert.ok(v.button('Check again'));v.done();});diff --git a/frontend/tests/away.test.mjs b/frontend/tests/away.test.mjsindex 9d7a5742..c47bd8f6 100644--- a/frontend/tests/away.test.mjs+++ b/frontend/tests/away.test.mjs@@ -152,12 +152,13 @@ test('sidebar entry shows the unseen badge only when there is something new', ()const space = { id: 'spc_default', name: 'Default', icon: '💼', color: '#f59e0b', sort: 0, is_default: true, archived_at: null,created_at: '', general_channel_id: null, counts: { bots: 0, ready_accounts: 0, unread: 0 } };const base = { space, spaces: [space], onSwitchSpace: noop, onCreateSpace: noop, onOpenSpaceSettings: noop, onOpenArchived: noop,- onOpenSearch: noop, onOpenRoutines: noop,+ onOpenSearch: noop,kwants: [], channels: [], teams: [], selectedId: '', isChannel: true, onSelectKwant: noop, onSelectChannel: noop,- onSelectTeam: noop, onSummonKwant: noop, onCreateTeam: noop, onOpenAway: noop };- const withNew = ui.sidebar({ ...base, awayCount: 7 });- assert.match(withNew, /While you were away/);+ onSelectTeam: noop, onSummonKwant: noop, onCreateTeam: noop, onOpenInbox: noop };+ const withNew = ui.sidebar({ ...base, inboxCount: 7 });+ assert.match(withNew, />Inbox</);+ assert.doesNotMatch(withNew, /While you were away/);assert.match(withNew, />7<span class="sr-only"> new<\/span>/);- assert.doesNotMatch(ui.sidebar({ ...base, awayCount: 0 }), /sr-only"> new/);- assert.match(ui.sidebar({ ...base, awayCount: 3, awayActive: true }), /aria-current="page"/);+ assert.doesNotMatch(ui.sidebar({ ...base, inboxCount: 0 }), /sr-only"> new/);+ assert.match(ui.sidebar({ ...base, inboxCount: 3, inboxActive: true }), /aria-current="page"/);});diff --git a/frontend/tests/chatTarget.test.mjs b/frontend/tests/chatTarget.test.mjsindex 8c295c14..b4fc94f9 100644--- a/frontend/tests/chatTarget.test.mjs+++ b/frontend/tests/chatTarget.test.mjs@@ -31,11 +31,11 @@ test('a chat that no longer exists is gone', () => {assert.equal(planOpenTarget({ channel_id: null, kwant_id: null }, shown(), exists), 'gone');});-test("App's openTarget closes the board and Loose ends when the chat is already selected", () => {+test("App's openTarget closes the board and Inbox when the chat is already selected", () => {const app = readFileSync(new URL('../src/App.tsx', import.meta.url), 'utf8');const reveal = app.match(/const revealChat = \(\) => \{([\s\S]*?)\n \};/);assert.ok(reveal, 'revealChat exists');- for (const call of ['setShowMissions(false)', 'setShowLoose(false)', 'setShowAway(false)', "setPhoneView('chat')"]) {+ for (const call of ["setPage('chat')", "setPhoneView('chat')"]) {assert.ok(reveal[1].includes(call), `revealChat calls ${call}`);}const open = app.match(/const openTarget = \(t: ChatTarget\): boolean => \{([\s\S]*?)\n \};/);diff --git a/frontend/tests/ia.test.mjs b/frontend/tests/ia.test.mjsnew file mode 100644index 00000000..143521ba--- /dev/null+++ b/frontend/tests/ia.test.mjs@@ -0,0 +1,238 @@+// PR 2 of the UX review: one Inbox, one bot list, one switcher, one Settings. Every old way in+// still lands somewhere, and old addresses are rewritten to the new ones.+import assert from 'node:assert/strict';+import test from 'node:test';+import { readFileSync } from 'node:fs';+import { loadBundled } from './bundle.mjs';++const store = new Map();+globalThis.localStorage ??= { getItem: (k) => (store.has(k) ? store.get(k) : null), setItem: (k, v) => store.set(k, String(v)) };++const nav = await loadBundled(`export * from './src/nav'; export { parseSpacePath, spacePath } from './src/spaces';`);+const ui = await loadBundled(`+ import React from 'react';+ import { renderToStaticMarkup } from 'react-dom/server.browser';+ import { Sidebar, botGroups } from './src/components/Sidebar';+ import { SpaceSettings } from './src/components/SpaceSettings';+ import { InboxPage } from './src/components/InboxPage';+ import { ApiKeysPanel } from './src/components/ApiKeysPanel';+ export { botGroups };+ const r = (C) => (props) => renderToStaticMarkup(React.createElement(C, props));+ export const sidebar = r(Sidebar);+ export const settings = r(SpaceSettings);+ export const inbox = r(InboxPage);+ export const apiKeys = r(ApiKeysPanel);+`);+const src = (f) => readFileSync(new URL(`../src/${f}`, import.meta.url), 'utf8');+const noop = () => {};++// ---------------------------------------------------------------------------+// Addresses++test('every canonical address round-trips', () => {+ const views = [+ { kind: 'inbox', tab: 'new' },+ { kind: 'inbox', tab: 'loose' },+ { kind: 'board' },+ { kind: 'parallel' },+ { kind: 'settings', scope: 'app' },+ ...nav.SPACE_SETTINGS_TABS.map((tab) => ({ kind: 'settings', scope: 'space', tab })),+ ];+ for (const v of views) {+ const seg = nav.viewSegment(v);+ const back = nav.parseView(seg);+ assert.ok(back, seg);+ assert.equal(back.legacy, false, `${seg} is canonical`);+ assert.ok(nav.sameView(back.view, v), seg);+ }+ assert.equal(nav.viewSegment({ kind: 'inbox', tab: 'loose' }), 'inbox/loose-ends');+ assert.equal(nav.viewSegment({ kind: 'settings', scope: 'space', tab: 'accounts' }), 'settings/accounts');+});++test('old addresses resolve to the new place and are flagged for rewriting', () => {+ const cases = {+ away: 'inbox',+ 'while-you-were-away': 'inbox',+ 'loose-ends': 'inbox/loose-ends',+ connections: 'settings/connections',+ routines: 'settings/routines',+ 'mission-board': 'board',+ missions: 'board',+ 'parallel-universe': 'parallel',+ 'app-settings': 'settings/app',+ 'inbox/new': 'inbox',+ 'inbox/loose': 'inbox/loose-ends',+ settings: 'settings/general',+ 'settings/all': 'settings/app',+ };+ for (const [old, now] of Object.entries(cases)) {+ const p = nav.parseView(old);+ assert.ok(p, old);+ assert.equal(p.legacy, true, `${old} is legacy`);+ assert.equal(nav.viewSegment(p.view), now, old);+ }+ for (const bad of ['', 'nope', 'settings/nope', 'inbox/nope', 'board/x', 'settings/app/x']) assert.equal(nav.parseView(bad), null, bad);+});++test('space paths carry the view, and a view wins over a chat', () => {+ const r = nav.parseSpacePath('/s/spc_a/away');+ assert.equal(r.spaceId, 'spc_a');+ assert.equal(nav.viewSegment(r.view), 'inbox');+ assert.equal(r.legacy, true);+ const s = nav.parseSpacePath('/s/spc_a/settings/accounts');+ assert.equal(nav.viewSegment(s.view), 'settings/accounts');+ assert.ok(!s.legacy);+ assert.equal(nav.spacePath('spc_a', null, { kind: 'inbox', tab: 'loose' }), '/s/spc_a/inbox/loose-ends');+ assert.equal(nav.spacePath('spc_a', { channelId: 'c1' }, { kind: 'board' }), '/s/spc_a/board');+ assert.ok(!nav.spacePath('spc_a', { channelId: 'c1' }).includes('board'));+});++test('the shell rewrites a legacy address in place and keeps Back working', () => {+ const shell = src('Shell.tsx');+ assert.match(shell, /route\.view/, 'the first load opens the view in the address');+ assert.match(shell, /replaceState/);+ assert.match(shell, /pushState/);+ assert.match(shell, /popstate/);+});++// ---------------------------------------------------------------------------+// Item 8: the sidebar's top rows++const space = { id: 'spc_default', name: 'Default', icon: '💼', color: '#f59e0b', sort: 0, is_default: true, archived_at: null,+ created_at: '', general_channel_id: null, counts: { bots: 0, ready_accounts: 0, unread: 0 } };+const bot = (id, name) => ({ id, name, title: 'Role', persona_prompt: '', avatar_sprite: 'mouse', driver_type: 'claude', preferred_model: '' });+const kwants = [bot('k1', 'Ada Lead'), bot('k2', 'Lin Backend'), bot('k3', 'Loner')];+const teams = [{ id: 't1', name: 'Ship', icon: '🚢', lead_kwant_id: 'k1', member_kwants: ['k2', 'k1'] }];+const base = {+ space, spaces: [space], onSwitchSpace: noop, onCreateSpace: noop, onOpenSpaceSettings: noop, onOpenArchived: noop, onOpenSearch: noop,+ kwants, channels: [], teams, selectedId: '', isChannel: true, onSelectKwant: noop, onSelectChannel: noop, onSelectTeam: noop,+ onSummonKwant: noop, onCreateTeam: noop, onOpenInbox: noop, onOpenParallel: noop, onOpenMissions: noop, missionBoard: true,+};++test('the top rows are Search, Inbox, Mission board and More, nothing else', () => {+ const html = ui.sidebar(base);+ const rows = html.match(/data-utility-rows[\s\S]*?<\/nav>|data-utility-rows[\s\S]*$/)[0];+ for (const t of ['Search', 'Inbox', 'Mission board', 'More']) assert.match(rows, new RegExp(t), t);+ for (const gone of ['While you were away', 'Loose ends', 'Connections', 'Routines']) assert.doesNotMatch(html, new RegExp(gone), `${gone} is not a sidebar row`);+ assert.doesNotMatch(html, /Parallel Universe/, 'Parallel Universe sits behind More, closed by default');+});++test('the Inbox row keeps the unseen badge and marks the open page', () => {+ assert.match(ui.sidebar({ ...base, inboxCount: 4 }), />4<span class="sr-only"> new<\/span>/);+ assert.doesNotMatch(ui.sidebar({ ...base, inboxCount: 0 }), /sr-only"> new/);+ assert.match(ui.sidebar({ ...base, inboxActive: true }), /aria-current="page"[^>]*>(?:(?!<\/button>)[\s\S])*>Inbox</);+});++test('Install is a tip that can be dismissed, and stays in Settings › All spaces', () => {+ const tip = src('components/InstallAppButton.tsx');+ assert.match(tip, /dismissInstallTip\(\)/);+ assert.match(tip, /Install any time from Settings › All spaces/);+ assert.match(src('components/SpaceSettings.tsx'), /<InstallAppButton/);+ assert.equal(nav.installTipDismissed(), false);+ nav.dismissInstallTip();+ assert.equal(nav.installTipDismissed(), true);+});++// ---------------------------------------------------------------------------+// Item 9: one bot list, grouped by team++test('bots are grouped by team, lead first, unassigned last', () => {+ const g = ui.botGroups(teams, kwants);+ assert.deepEqual(g.map((x) => x.team?.id ?? null), ['t1', null]);+ assert.deepEqual(g[0].bots.map((k) => k.id), ['k1', 'k2']);+ assert.deepEqual(g[1].bots.map((k) => k.id), ['k3']);+});++test('the sidebar lists each bot once, in its team group', () => {+ const html = ui.sidebar(base);+ assert.equal((html.match(/data-bot-list/g) || []).length, 1, 'one bot list');+ assert.equal((html.match(/data-team-group/g) || []).length, 2, 'Ship and the unassigned group');+ for (const k of kwants) assert.equal((html.match(new RegExp(`data-bot-row="${k.id}"`, 'g')) || []).length, 1, `${k.name} once`);+ assert.ok(html.indexOf('Loner') > html.indexOf('Lin Backend'), 'unassigned bots come last');+});++test('the phone Bots tab uses the same grouped list', () => {+ const html = ui.sidebar({ ...base, phone: true, section: 'bots' });+ assert.match(html, /data-bot-list/);+ assert.equal((html.match(/data-team-group/g) || []).length, 2);+});++// ---------------------------------------------------------------------------+// Item 10: the header is the space name and its settings++test('desktop header: the space name and a settings entry, no switcher dropdown', () => {+ const html = ui.sidebar(base);+ assert.match(html, /data-space-header/);+ assert.match(html, /data-space-settings-open[^>]*aria-label="Settings for Default"|aria-label="Settings for Default"[^>]*data-space-settings-open/);+ assert.doesNotMatch(html, /data-space-toggle/);+});++test('phones keep exactly one switcher', () => {+ const html = ui.sidebar({ ...base, phone: true, section: 'chats' });+ assert.equal((html.match(/data-space-toggle/g) || []).length, 1);+});++// ---------------------------------------------------------------------------+// Item 11: one Settings++const settingsProps = (over = {}) => ({+ space, scope: 'space', onScope: noop, tab: 'connections', onTab: noop, onClose: noop,+ connections: 'CONNECTIONS-HERE', appSettings: 'APP-SETTINGS-HERE', onOpenArchived: noop, kwants, channels: [], teams,+ onSpaceSaved: noop, onArchived: noop, onNewBot: noop, onEditBot: noop, onOpenSkills: noop, onNewTeam: noop, onManageTeam: noop, onOpenTools: noop,+ ...over,+});++test('Settings has This space and All spaces, and Connections is a section of This space', () => {+ const html = ui.settings(settingsProps());+ assert.match(html, /data-settings-scope="space"[^>]*>|aria-selected="true"[^>]*data-settings-scope="space"/);+ assert.match(html, /This space/);+ assert.match(html, /All spaces/);+ assert.match(html, /data-settings-connections[^>]*>CONNECTIONS-HERE/);+ for (const t of ['General', 'Accounts', 'Connections', 'Routines']) assert.match(html, new RegExp(`>${t}<`), t);+ assert.doesNotMatch(html, /APP-SETTINGS-HERE/);+});++test('All spaces shows the app settings, archived spaces and install, not the space tabs', () => {+ const html = ui.settings(settingsProps({ scope: 'app' }));+ assert.match(html, /APP-SETTINGS-HERE/);+ assert.match(html, /Archived spaces/);+ assert.doesNotMatch(html, /CONNECTIONS-HERE/);+ assert.doesNotMatch(html, /aria-label="Default settings"/);+});++test('API keys live only in This space › Accounts; App settings links there', () => {+ const keys = ui.apiKeys({ defaultOpen: false });+ assert.match(keys, /API keys and Ollama/);+ assert.match(keys, /data-api-keys/);+ assert.match(src('components/SpaceSettings.tsx'), /<ApiKeysPanel/);+ const app = src('components/SettingsModal.tsx');+ assert.match(app, /data-api-keys-link/);+ assert.match(app, /onClick=\{onOpenApiKeys\}|onOpenApiKeys\(\)/);+ assert.match(app, /Settings › This space › Accounts/);+ assert.doesNotMatch(app, /Anthropic API Key|placeholder="sk-ant/, 'no key fields left in App settings');+ assert.match(src('App.tsx'), /onOpenApiKeys=\{\(\) => openSpaceSettings\('accounts'\)\}/);+});++test('the rail gear opens Settings › All spaces and the header entry opens This space', () => {+ assert.match(src('Shell.tsx'), /requestView\(\{ kind: 'settings', scope: 'app' \}\)/);+ assert.match(src('components/Spaces.tsx'), /Settings \(all spaces\)/);+ assert.match(src('App.tsx'), /onOpenSpaceSettings=\{\(\) => openSpaceSettings\(/);+});++// ---------------------------------------------------------------------------+// Inbox++test('Inbox has New and Loose ends tabs, with the badge on New', () => {+ const html = ui.inbox({ tab: 'new', onTab: noop, count: 3, newPage: 'NEW-PAGE', loosePage: 'LOOSE-PAGE' });+ assert.match(html, /role="tablist" aria-label="Inbox"/);+ assert.match(html, /data-inbox-tab="new"/);+ assert.match(html, /data-inbox-tab="loose"/);+ assert.match(html, />3<span class="sr-only"> new<\/span>/);+ assert.match(html, /NEW-PAGE/);+ assert.doesNotMatch(html, /LOOSE-PAGE/);+ const loose = ui.inbox({ tab: 'loose', onTab: noop, newPage: 'NEW-PAGE', loosePage: 'LOOSE-PAGE' });+ assert.match(loose, /LOOSE-PAGE/);+ assert.match(loose, /aria-selected="true"[^>]*data-inbox-tab="loose"|data-inbox-tab="loose"[^>]*aria-selected="true"|id="inbox-tab-loose" aria-selected="true"/);+ assert.doesNotMatch(loose, /Back to chats/, 'no back button on desktop');+ assert.match(ui.inbox({ tab: 'new', onTab: noop, onBack: noop, newPage: '', loosePage: '' }), /Back to chats/);+});