Spaces:
Runtime error
Runtime error
nyk commited on
feat: sync side panel navigation with URL routes (#76) (#87)
Browse filesMove page.tsx to [[...panel]] optional catch-all route so each panel
gets its own URL (e.g. /tasks, /agents, /settings). URL is the source
of truth — synced into Zustand via usePathname on every navigation.
Enables bookmarking, refresh persistence, deep-linking, and browser
back/forward.
- src/app/{page.tsx → [[...panel]]/page.tsx} +10 -1
- src/components/dashboard/dashboard.tsx +21 -20
- src/components/dashboard/sidebar.tsx +4 -2
- src/components/layout/header-bar.tsx +5 -6
- src/components/layout/local-mode-banner.tsx +4 -2
- src/components/layout/nav-rail.tsx +12 -10
- src/lib/navigation.ts +15 -0
src/app/{page.tsx → [[...panel]]/page.tsx}
RENAMED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
'use client'
|
| 2 |
|
| 3 |
import { useEffect, useState } from 'react'
|
|
|
|
| 4 |
import { NavRail } from '@/components/layout/nav-rail'
|
| 5 |
import { HeaderBar } from '@/components/layout/header-bar'
|
| 6 |
import { LiveFeed } from '@/components/layout/live-feed'
|
|
@@ -39,7 +40,15 @@ import { useMissionControl } from '@/store'
|
|
| 39 |
|
| 40 |
export default function Home() {
|
| 41 |
const { connect } = useWebSocket()
|
| 42 |
-
const { activeTab, setCurrentUser, setDashboardMode, setGatewayAvailable, setSubscription, liveFeedOpen, toggleLiveFeed } = useMissionControl()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
// Connect to SSE for real-time local DB events (tasks, agents, chat, etc.)
|
| 45 |
useServerEvents()
|
|
|
|
| 1 |
'use client'
|
| 2 |
|
| 3 |
import { useEffect, useState } from 'react'
|
| 4 |
+
import { usePathname } from 'next/navigation'
|
| 5 |
import { NavRail } from '@/components/layout/nav-rail'
|
| 6 |
import { HeaderBar } from '@/components/layout/header-bar'
|
| 7 |
import { LiveFeed } from '@/components/layout/live-feed'
|
|
|
|
| 40 |
|
| 41 |
export default function Home() {
|
| 42 |
const { connect } = useWebSocket()
|
| 43 |
+
const { activeTab, setActiveTab, setCurrentUser, setDashboardMode, setGatewayAvailable, setSubscription, liveFeedOpen, toggleLiveFeed } = useMissionControl()
|
| 44 |
+
|
| 45 |
+
// Sync URL → Zustand activeTab
|
| 46 |
+
const pathname = usePathname()
|
| 47 |
+
const panelFromUrl = pathname === '/' ? 'overview' : pathname.slice(1)
|
| 48 |
+
|
| 49 |
+
useEffect(() => {
|
| 50 |
+
setActiveTab(panelFromUrl)
|
| 51 |
+
}, [panelFromUrl, setActiveTab])
|
| 52 |
|
| 53 |
// Connect to SSE for real-time local DB events (tasks, agents, chat, etc.)
|
| 54 |
useServerEvents()
|
src/components/dashboard/dashboard.tsx
CHANGED
|
@@ -2,6 +2,7 @@
|
|
| 2 |
|
| 3 |
import { useState, useCallback } from 'react'
|
| 4 |
import { useMissionControl } from '@/store'
|
|
|
|
| 5 |
import { useSmartPoll } from '@/lib/use-smart-poll'
|
| 6 |
|
| 7 |
interface DbStats {
|
|
@@ -35,8 +36,8 @@ export function Dashboard() {
|
|
| 35 |
logs,
|
| 36 |
agents,
|
| 37 |
tasks,
|
| 38 |
-
setActiveTab,
|
| 39 |
} = useMissionControl()
|
|
|
|
| 40 |
const isLocal = dashboardMode === 'local'
|
| 41 |
const subscriptionLabel = subscription?.type
|
| 42 |
? subscription.type.charAt(0).toUpperCase() + subscription.type.slice(1)
|
|
@@ -124,7 +125,7 @@ export function Dashboard() {
|
|
| 124 |
<div className="grid grid-cols-2 lg:grid-cols-4 gap-3">
|
| 125 |
{isLocal ? (
|
| 126 |
<>
|
| 127 |
-
<div className="cursor-pointer" onClick={() =>
|
| 128 |
<MetricCard
|
| 129 |
label="Active Sessions"
|
| 130 |
value={claudeStats?.active_sessions ?? activeSessions}
|
|
@@ -133,7 +134,7 @@ export function Dashboard() {
|
|
| 133 |
color="blue"
|
| 134 |
/>
|
| 135 |
</div>
|
| 136 |
-
<div className="cursor-pointer" onClick={() =>
|
| 137 |
<MetricCard
|
| 138 |
label="Projects"
|
| 139 |
value={claudeStats?.unique_projects ?? 0}
|
|
@@ -141,7 +142,7 @@ export function Dashboard() {
|
|
| 141 |
color="green"
|
| 142 |
/>
|
| 143 |
</div>
|
| 144 |
-
<div className="cursor-pointer" onClick={() =>
|
| 145 |
<MetricCard
|
| 146 |
label="Tokens Used"
|
| 147 |
value={formatTokensShort((claudeStats?.total_input_tokens ?? 0) + (claudeStats?.total_output_tokens ?? 0))}
|
|
@@ -150,7 +151,7 @@ export function Dashboard() {
|
|
| 150 |
color="purple"
|
| 151 |
/>
|
| 152 |
</div>
|
| 153 |
-
<div className="cursor-pointer" onClick={() =>
|
| 154 |
<MetricCard
|
| 155 |
label="Est. Cost"
|
| 156 |
value={subscriptionLabel ? `Included` : `$${(claudeStats?.total_estimated_cost ?? 0).toFixed(2)}`}
|
|
@@ -162,7 +163,7 @@ export function Dashboard() {
|
|
| 162 |
</>
|
| 163 |
) : (
|
| 164 |
<>
|
| 165 |
-
<div className="cursor-pointer" onClick={() =>
|
| 166 |
<MetricCard
|
| 167 |
label="Active Sessions"
|
| 168 |
value={activeSessions}
|
|
@@ -171,7 +172,7 @@ export function Dashboard() {
|
|
| 171 |
color="blue"
|
| 172 |
/>
|
| 173 |
</div>
|
| 174 |
-
<div className="cursor-pointer" onClick={() =>
|
| 175 |
<MetricCard
|
| 176 |
label="Agents Online"
|
| 177 |
value={onlineAgents}
|
|
@@ -180,7 +181,7 @@ export function Dashboard() {
|
|
| 180 |
color="green"
|
| 181 |
/>
|
| 182 |
</div>
|
| 183 |
-
<div className="cursor-pointer" onClick={() =>
|
| 184 |
<MetricCard
|
| 185 |
label="Tasks Running"
|
| 186 |
value={runningTasks}
|
|
@@ -189,7 +190,7 @@ export function Dashboard() {
|
|
| 189 |
color="purple"
|
| 190 |
/>
|
| 191 |
</div>
|
| 192 |
-
<div className="cursor-pointer" onClick={() =>
|
| 193 |
<MetricCard
|
| 194 |
label="Errors (24h)"
|
| 195 |
value={errorCount}
|
|
@@ -261,7 +262,7 @@ export function Dashboard() {
|
|
| 261 |
|
| 262 |
{/* Middle panel: Claude Stats (local) or Security & Audit (full) */}
|
| 263 |
{isLocal ? (
|
| 264 |
-
<div className="panel cursor-pointer hover:border-primary/30 transition-smooth" onClick={() =>
|
| 265 |
<div className="panel-header">
|
| 266 |
<h3 className="text-sm font-semibold text-foreground">Claude Code Stats</h3>
|
| 267 |
<span className="inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-2xs font-medium bg-purple-500/10 text-purple-400 border border-purple-500/20">
|
|
@@ -305,7 +306,7 @@ export function Dashboard() {
|
|
| 305 |
</div>
|
| 306 |
</div>
|
| 307 |
) : (
|
| 308 |
-
<div className="panel cursor-pointer hover:border-primary/30 transition-smooth" onClick={() =>
|
| 309 |
<div className="panel-header">
|
| 310 |
<h3 className="text-sm font-semibold text-foreground">Security & Audit</h3>
|
| 311 |
{dbStats && dbStats.audit.loginFailures > 0 && (
|
|
@@ -513,15 +514,15 @@ export function Dashboard() {
|
|
| 513 |
{/* Quick Actions */}
|
| 514 |
<div className="grid grid-cols-2 lg:grid-cols-5 gap-2">
|
| 515 |
{!isLocal && (
|
| 516 |
-
<QuickAction label="Spawn Agent" desc="Launch sub-agent" tab="spawn" icon={<SpawnActionIcon />}
|
| 517 |
)}
|
| 518 |
-
<QuickAction label="View Logs" desc="Real-time viewer" tab="logs" icon={<LogActionIcon />}
|
| 519 |
-
<QuickAction label="Task Board" desc="Kanban view" tab="tasks" icon={<TaskActionIcon />}
|
| 520 |
-
<QuickAction label="Memory" desc="Knowledge base" tab="memory" icon={<MemoryActionIcon />}
|
| 521 |
{isLocal ? (
|
| 522 |
-
<QuickAction label="Sessions" desc="Claude Code sessions" tab="sessions" icon={<SessionIcon />}
|
| 523 |
) : (
|
| 524 |
-
<QuickAction label="Orchestration" desc="Workflows & pipelines" tab="orchestration" icon={<PipelineActionIcon />}
|
| 525 |
)}
|
| 526 |
</div>
|
| 527 |
</div>
|
|
@@ -616,13 +617,13 @@ function StatusBadge({ connected }: { connected: boolean }) {
|
|
| 616 |
)
|
| 617 |
}
|
| 618 |
|
| 619 |
-
function QuickAction({ label, desc, tab, icon,
|
| 620 |
label: string; desc: string; tab: string; icon: React.ReactNode
|
| 621 |
-
|
| 622 |
}) {
|
| 623 |
return (
|
| 624 |
<button
|
| 625 |
-
onClick={() =>
|
| 626 |
className="flex items-center gap-3 p-3 rounded-lg border border-border hover:border-primary/30 hover:bg-primary/5 transition-smooth text-left group"
|
| 627 |
>
|
| 628 |
<div className="w-8 h-8 rounded-md bg-secondary flex items-center justify-center shrink-0 group-hover:bg-primary/10 transition-smooth">
|
|
|
|
| 2 |
|
| 3 |
import { useState, useCallback } from 'react'
|
| 4 |
import { useMissionControl } from '@/store'
|
| 5 |
+
import { useNavigateToPanel } from '@/lib/navigation'
|
| 6 |
import { useSmartPoll } from '@/lib/use-smart-poll'
|
| 7 |
|
| 8 |
interface DbStats {
|
|
|
|
| 36 |
logs,
|
| 37 |
agents,
|
| 38 |
tasks,
|
|
|
|
| 39 |
} = useMissionControl()
|
| 40 |
+
const navigateToPanel = useNavigateToPanel()
|
| 41 |
const isLocal = dashboardMode === 'local'
|
| 42 |
const subscriptionLabel = subscription?.type
|
| 43 |
? subscription.type.charAt(0).toUpperCase() + subscription.type.slice(1)
|
|
|
|
| 125 |
<div className="grid grid-cols-2 lg:grid-cols-4 gap-3">
|
| 126 |
{isLocal ? (
|
| 127 |
<>
|
| 128 |
+
<div className="cursor-pointer" onClick={() => navigateToPanel('sessions')}>
|
| 129 |
<MetricCard
|
| 130 |
label="Active Sessions"
|
| 131 |
value={claudeStats?.active_sessions ?? activeSessions}
|
|
|
|
| 134 |
color="blue"
|
| 135 |
/>
|
| 136 |
</div>
|
| 137 |
+
<div className="cursor-pointer" onClick={() => navigateToPanel('sessions')}>
|
| 138 |
<MetricCard
|
| 139 |
label="Projects"
|
| 140 |
value={claudeStats?.unique_projects ?? 0}
|
|
|
|
| 142 |
color="green"
|
| 143 |
/>
|
| 144 |
</div>
|
| 145 |
+
<div className="cursor-pointer" onClick={() => navigateToPanel('tokens')}>
|
| 146 |
<MetricCard
|
| 147 |
label="Tokens Used"
|
| 148 |
value={formatTokensShort((claudeStats?.total_input_tokens ?? 0) + (claudeStats?.total_output_tokens ?? 0))}
|
|
|
|
| 151 |
color="purple"
|
| 152 |
/>
|
| 153 |
</div>
|
| 154 |
+
<div className="cursor-pointer" onClick={() => navigateToPanel('tokens')}>
|
| 155 |
<MetricCard
|
| 156 |
label="Est. Cost"
|
| 157 |
value={subscriptionLabel ? `Included` : `$${(claudeStats?.total_estimated_cost ?? 0).toFixed(2)}`}
|
|
|
|
| 163 |
</>
|
| 164 |
) : (
|
| 165 |
<>
|
| 166 |
+
<div className="cursor-pointer" onClick={() => navigateToPanel('history')}>
|
| 167 |
<MetricCard
|
| 168 |
label="Active Sessions"
|
| 169 |
value={activeSessions}
|
|
|
|
| 172 |
color="blue"
|
| 173 |
/>
|
| 174 |
</div>
|
| 175 |
+
<div className="cursor-pointer" onClick={() => navigateToPanel('agents')}>
|
| 176 |
<MetricCard
|
| 177 |
label="Agents Online"
|
| 178 |
value={onlineAgents}
|
|
|
|
| 181 |
color="green"
|
| 182 |
/>
|
| 183 |
</div>
|
| 184 |
+
<div className="cursor-pointer" onClick={() => navigateToPanel('tasks')}>
|
| 185 |
<MetricCard
|
| 186 |
label="Tasks Running"
|
| 187 |
value={runningTasks}
|
|
|
|
| 190 |
color="purple"
|
| 191 |
/>
|
| 192 |
</div>
|
| 193 |
+
<div className="cursor-pointer" onClick={() => navigateToPanel('logs')}>
|
| 194 |
<MetricCard
|
| 195 |
label="Errors (24h)"
|
| 196 |
value={errorCount}
|
|
|
|
| 262 |
|
| 263 |
{/* Middle panel: Claude Stats (local) or Security & Audit (full) */}
|
| 264 |
{isLocal ? (
|
| 265 |
+
<div className="panel cursor-pointer hover:border-primary/30 transition-smooth" onClick={() => navigateToPanel('sessions')}>
|
| 266 |
<div className="panel-header">
|
| 267 |
<h3 className="text-sm font-semibold text-foreground">Claude Code Stats</h3>
|
| 268 |
<span className="inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-2xs font-medium bg-purple-500/10 text-purple-400 border border-purple-500/20">
|
|
|
|
| 306 |
</div>
|
| 307 |
</div>
|
| 308 |
) : (
|
| 309 |
+
<div className="panel cursor-pointer hover:border-primary/30 transition-smooth" onClick={() => navigateToPanel('audit')}>
|
| 310 |
<div className="panel-header">
|
| 311 |
<h3 className="text-sm font-semibold text-foreground">Security & Audit</h3>
|
| 312 |
{dbStats && dbStats.audit.loginFailures > 0 && (
|
|
|
|
| 514 |
{/* Quick Actions */}
|
| 515 |
<div className="grid grid-cols-2 lg:grid-cols-5 gap-2">
|
| 516 |
{!isLocal && (
|
| 517 |
+
<QuickAction label="Spawn Agent" desc="Launch sub-agent" tab="spawn" icon={<SpawnActionIcon />} onNavigate={navigateToPanel} />
|
| 518 |
)}
|
| 519 |
+
<QuickAction label="View Logs" desc="Real-time viewer" tab="logs" icon={<LogActionIcon />} onNavigate={navigateToPanel} />
|
| 520 |
+
<QuickAction label="Task Board" desc="Kanban view" tab="tasks" icon={<TaskActionIcon />} onNavigate={navigateToPanel} />
|
| 521 |
+
<QuickAction label="Memory" desc="Knowledge base" tab="memory" icon={<MemoryActionIcon />} onNavigate={navigateToPanel} />
|
| 522 |
{isLocal ? (
|
| 523 |
+
<QuickAction label="Sessions" desc="Claude Code sessions" tab="sessions" icon={<SessionIcon />} onNavigate={navigateToPanel} />
|
| 524 |
) : (
|
| 525 |
+
<QuickAction label="Orchestration" desc="Workflows & pipelines" tab="orchestration" icon={<PipelineActionIcon />} onNavigate={navigateToPanel} />
|
| 526 |
)}
|
| 527 |
</div>
|
| 528 |
</div>
|
|
|
|
| 617 |
)
|
| 618 |
}
|
| 619 |
|
| 620 |
+
function QuickAction({ label, desc, tab, icon, onNavigate }: {
|
| 621 |
label: string; desc: string; tab: string; icon: React.ReactNode
|
| 622 |
+
onNavigate: (tab: string) => void
|
| 623 |
}) {
|
| 624 |
return (
|
| 625 |
<button
|
| 626 |
+
onClick={() => onNavigate(tab)}
|
| 627 |
className="flex items-center gap-3 p-3 rounded-lg border border-border hover:border-primary/30 hover:bg-primary/5 transition-smooth text-left group"
|
| 628 |
>
|
| 629 |
<div className="w-8 h-8 rounded-md bg-secondary flex items-center justify-center shrink-0 group-hover:bg-primary/10 transition-smooth">
|
src/components/dashboard/sidebar.tsx
CHANGED
|
@@ -2,6 +2,7 @@
|
|
| 2 |
|
| 3 |
import { useEffect, useState } from 'react'
|
| 4 |
import { useMissionControl } from '@/store'
|
|
|
|
| 5 |
|
| 6 |
interface MenuItem {
|
| 7 |
id: string
|
|
@@ -26,7 +27,8 @@ const menuItems: MenuItem[] = [
|
|
| 26 |
]
|
| 27 |
|
| 28 |
export function Sidebar() {
|
| 29 |
-
const { activeTab,
|
|
|
|
| 30 |
const [systemStats, setSystemStats] = useState<any>(null)
|
| 31 |
|
| 32 |
useEffect(() => {
|
|
@@ -61,7 +63,7 @@ export function Sidebar() {
|
|
| 61 |
{menuItems.map((item) => (
|
| 62 |
<li key={item.id}>
|
| 63 |
<button
|
| 64 |
-
onClick={() =>
|
| 65 |
className={`w-full flex items-start space-x-3 px-3 py-3 rounded-lg text-left transition-colors group ${
|
| 66 |
activeTab === item.id
|
| 67 |
? 'bg-primary text-primary-foreground shadow-sm'
|
|
|
|
| 2 |
|
| 3 |
import { useEffect, useState } from 'react'
|
| 4 |
import { useMissionControl } from '@/store'
|
| 5 |
+
import { useNavigateToPanel } from '@/lib/navigation'
|
| 6 |
|
| 7 |
interface MenuItem {
|
| 8 |
id: string
|
|
|
|
| 27 |
]
|
| 28 |
|
| 29 |
export function Sidebar() {
|
| 30 |
+
const { activeTab, connection, sessions } = useMissionControl()
|
| 31 |
+
const navigateToPanel = useNavigateToPanel()
|
| 32 |
const [systemStats, setSystemStats] = useState<any>(null)
|
| 33 |
|
| 34 |
useEffect(() => {
|
|
|
|
| 63 |
{menuItems.map((item) => (
|
| 64 |
<li key={item.id}>
|
| 65 |
<button
|
| 66 |
+
onClick={() => navigateToPanel(item.id)}
|
| 67 |
className={`w-full flex items-start space-x-3 px-3 py-3 rounded-lg text-left transition-colors group ${
|
| 68 |
activeTab === item.id
|
| 69 |
? 'bg-primary text-primary-foreground shadow-sm'
|
src/components/layout/header-bar.tsx
CHANGED
|
@@ -4,6 +4,7 @@ import { useState, useRef, useEffect, useCallback } from 'react'
|
|
| 4 |
import { useRouter } from 'next/navigation'
|
| 5 |
import { useMissionControl } from '@/store'
|
| 6 |
import { useWebSocket } from '@/lib/websocket'
|
|
|
|
| 7 |
import { ThemeToggle } from '@/components/ui/theme-toggle'
|
| 8 |
import { DigitalClock } from '@/components/ui/digital-clock'
|
| 9 |
|
|
@@ -17,8 +18,9 @@ interface SearchResult {
|
|
| 17 |
}
|
| 18 |
|
| 19 |
export function HeaderBar() {
|
| 20 |
-
const { activeTab,
|
| 21 |
const { isConnected, reconnect } = useWebSocket()
|
|
|
|
| 22 |
|
| 23 |
const activeSessions = sessions.filter(s => s.active).length
|
| 24 |
const tabLabels: Record<string, string> = {
|
|
@@ -105,7 +107,7 @@ export function HeaderBar() {
|
|
| 105 |
audit: 'audit', message: 'agents', notification: 'notifications',
|
| 106 |
webhook: 'webhooks', pipeline: 'agents', alert_rule: 'alerts',
|
| 107 |
}
|
| 108 |
-
|
| 109 |
setSearchOpen(false)
|
| 110 |
setSearchQuery('')
|
| 111 |
setSearchResults([])
|
|
@@ -187,10 +189,7 @@ export function HeaderBar() {
|
|
| 187 |
|
| 188 |
{/* Notifications */}
|
| 189 |
<button
|
| 190 |
-
onClick={() =>
|
| 191 |
-
const { setActiveTab } = useMissionControl.getState()
|
| 192 |
-
setActiveTab('notifications')
|
| 193 |
-
}}
|
| 194 |
className="h-8 w-8 rounded-md text-muted-foreground hover:text-foreground hover:bg-secondary transition-smooth flex items-center justify-center relative"
|
| 195 |
>
|
| 196 |
<BellIcon />
|
|
|
|
| 4 |
import { useRouter } from 'next/navigation'
|
| 5 |
import { useMissionControl } from '@/store'
|
| 6 |
import { useWebSocket } from '@/lib/websocket'
|
| 7 |
+
import { useNavigateToPanel } from '@/lib/navigation'
|
| 8 |
import { ThemeToggle } from '@/components/ui/theme-toggle'
|
| 9 |
import { DigitalClock } from '@/components/ui/digital-clock'
|
| 10 |
|
|
|
|
| 18 |
}
|
| 19 |
|
| 20 |
export function HeaderBar() {
|
| 21 |
+
const { activeTab, connection, sessions, chatPanelOpen, setChatPanelOpen, notifications, unreadNotificationCount, currentUser, setCurrentUser } = useMissionControl()
|
| 22 |
const { isConnected, reconnect } = useWebSocket()
|
| 23 |
+
const navigateToPanel = useNavigateToPanel()
|
| 24 |
|
| 25 |
const activeSessions = sessions.filter(s => s.active).length
|
| 26 |
const tabLabels: Record<string, string> = {
|
|
|
|
| 107 |
audit: 'audit', message: 'agents', notification: 'notifications',
|
| 108 |
webhook: 'webhooks', pipeline: 'agents', alert_rule: 'alerts',
|
| 109 |
}
|
| 110 |
+
navigateToPanel(typeToTab[result.type] || 'overview')
|
| 111 |
setSearchOpen(false)
|
| 112 |
setSearchQuery('')
|
| 113 |
setSearchResults([])
|
|
|
|
| 189 |
|
| 190 |
{/* Notifications */}
|
| 191 |
<button
|
| 192 |
+
onClick={() => navigateToPanel('notifications')}
|
|
|
|
|
|
|
|
|
|
| 193 |
className="h-8 w-8 rounded-md text-muted-foreground hover:text-foreground hover:bg-secondary transition-smooth flex items-center justify-center relative"
|
| 194 |
>
|
| 195 |
<BellIcon />
|
src/components/layout/local-mode-banner.tsx
CHANGED
|
@@ -1,9 +1,11 @@
|
|
| 1 |
'use client'
|
| 2 |
|
| 3 |
import { useMissionControl } from '@/store'
|
|
|
|
| 4 |
|
| 5 |
export function LocalModeBanner() {
|
| 6 |
-
const { dashboardMode, bannerDismissed, dismissBanner
|
|
|
|
| 7 |
|
| 8 |
if (dashboardMode === 'full' || bannerDismissed) return null
|
| 9 |
|
|
@@ -15,7 +17,7 @@ export function LocalModeBanner() {
|
|
| 15 |
{' — running in Local Mode. Monitoring Claude Code sessions, tasks, and local data.'}
|
| 16 |
</p>
|
| 17 |
<button
|
| 18 |
-
onClick={() =>
|
| 19 |
className="shrink-0 text-2xs font-medium text-blue-400 hover:text-blue-300 px-2 py-1 rounded border border-blue-500/20 hover:border-blue-500/40 transition-colors"
|
| 20 |
>
|
| 21 |
Configure Gateway
|
|
|
|
| 1 |
'use client'
|
| 2 |
|
| 3 |
import { useMissionControl } from '@/store'
|
| 4 |
+
import { useNavigateToPanel } from '@/lib/navigation'
|
| 5 |
|
| 6 |
export function LocalModeBanner() {
|
| 7 |
+
const { dashboardMode, bannerDismissed, dismissBanner } = useMissionControl()
|
| 8 |
+
const navigateToPanel = useNavigateToPanel()
|
| 9 |
|
| 10 |
if (dashboardMode === 'full' || bannerDismissed) return null
|
| 11 |
|
|
|
|
| 17 |
{' — running in Local Mode. Monitoring Claude Code sessions, tasks, and local data.'}
|
| 18 |
</p>
|
| 19 |
<button
|
| 20 |
+
onClick={() => navigateToPanel('gateways')}
|
| 21 |
className="shrink-0 text-2xs font-medium text-blue-400 hover:text-blue-300 px-2 py-1 rounded border border-blue-500/20 hover:border-blue-500/40 transition-colors"
|
| 22 |
>
|
| 23 |
Configure Gateway
|
src/components/layout/nav-rail.tsx
CHANGED
|
@@ -2,6 +2,7 @@
|
|
| 2 |
|
| 3 |
import { useState, useEffect } from 'react'
|
| 4 |
import { useMissionControl } from '@/store'
|
|
|
|
| 5 |
|
| 6 |
interface NavItem {
|
| 7 |
id: string
|
|
@@ -69,7 +70,8 @@ const navGroups: NavGroup[] = [
|
|
| 69 |
const allNavItems = navGroups.flatMap(g => g.items)
|
| 70 |
|
| 71 |
export function NavRail() {
|
| 72 |
-
const { activeTab,
|
|
|
|
| 73 |
const isLocal = dashboardMode === 'local'
|
| 74 |
|
| 75 |
// Keyboard shortcut: [ to toggle sidebar
|
|
@@ -167,7 +169,7 @@ export function NavRail() {
|
|
| 167 |
active={activeTab === item.id}
|
| 168 |
expanded={sidebarExpanded}
|
| 169 |
disabled={disabled}
|
| 170 |
-
onClick={() => { if (!disabled)
|
| 171 |
/>
|
| 172 |
)
|
| 173 |
})}
|
|
@@ -196,7 +198,7 @@ export function NavRail() {
|
|
| 196 |
</nav>
|
| 197 |
|
| 198 |
{/* Mobile: Bottom tab bar */}
|
| 199 |
-
<MobileBottomBar activeTab={activeTab}
|
| 200 |
</>
|
| 201 |
)
|
| 202 |
}
|
|
@@ -257,9 +259,9 @@ function NavButton({ item, active, expanded, disabled, onClick }: {
|
|
| 257 |
)
|
| 258 |
}
|
| 259 |
|
| 260 |
-
function MobileBottomBar({ activeTab,
|
| 261 |
activeTab: string
|
| 262 |
-
|
| 263 |
}) {
|
| 264 |
const [sheetOpen, setSheetOpen] = useState(false)
|
| 265 |
const priorityItems = allNavItems.filter(i => i.priority)
|
|
@@ -273,7 +275,7 @@ function MobileBottomBar({ activeTab, setActiveTab }: {
|
|
| 273 |
{priorityItems.map((item) => (
|
| 274 |
<button
|
| 275 |
key={item.id}
|
| 276 |
-
onClick={() =>
|
| 277 |
className={`flex flex-col items-center justify-center gap-0.5 px-2 py-2 rounded-lg transition-smooth min-w-[48px] min-h-[48px] ${
|
| 278 |
activeTab === item.id
|
| 279 |
? 'text-primary'
|
|
@@ -311,17 +313,17 @@ function MobileBottomBar({ activeTab, setActiveTab }: {
|
|
| 311 |
open={sheetOpen}
|
| 312 |
onClose={() => setSheetOpen(false)}
|
| 313 |
activeTab={activeTab}
|
| 314 |
-
|
| 315 |
/>
|
| 316 |
</>
|
| 317 |
)
|
| 318 |
}
|
| 319 |
|
| 320 |
-
function MobileBottomSheet({ open, onClose, activeTab,
|
| 321 |
open: boolean
|
| 322 |
onClose: () => void
|
| 323 |
activeTab: string
|
| 324 |
-
|
| 325 |
}) {
|
| 326 |
// Track mount state for animation
|
| 327 |
const [visible, setVisible] = useState(false)
|
|
@@ -385,7 +387,7 @@ function MobileBottomSheet({ open, onClose, activeTab, setActiveTab }: {
|
|
| 385 |
<button
|
| 386 |
key={item.id}
|
| 387 |
onClick={() => {
|
| 388 |
-
|
| 389 |
handleClose()
|
| 390 |
}}
|
| 391 |
className={`flex items-center gap-2.5 px-3 min-h-[48px] rounded-xl transition-smooth ${
|
|
|
|
| 2 |
|
| 3 |
import { useState, useEffect } from 'react'
|
| 4 |
import { useMissionControl } from '@/store'
|
| 5 |
+
import { useNavigateToPanel } from '@/lib/navigation'
|
| 6 |
|
| 7 |
interface NavItem {
|
| 8 |
id: string
|
|
|
|
| 70 |
const allNavItems = navGroups.flatMap(g => g.items)
|
| 71 |
|
| 72 |
export function NavRail() {
|
| 73 |
+
const { activeTab, connection, dashboardMode, sidebarExpanded, collapsedGroups, toggleSidebar, toggleGroup } = useMissionControl()
|
| 74 |
+
const navigateToPanel = useNavigateToPanel()
|
| 75 |
const isLocal = dashboardMode === 'local'
|
| 76 |
|
| 77 |
// Keyboard shortcut: [ to toggle sidebar
|
|
|
|
| 169 |
active={activeTab === item.id}
|
| 170 |
expanded={sidebarExpanded}
|
| 171 |
disabled={disabled}
|
| 172 |
+
onClick={() => { if (!disabled) navigateToPanel(item.id) }}
|
| 173 |
/>
|
| 174 |
)
|
| 175 |
})}
|
|
|
|
| 198 |
</nav>
|
| 199 |
|
| 200 |
{/* Mobile: Bottom tab bar */}
|
| 201 |
+
<MobileBottomBar activeTab={activeTab} navigateToPanel={navigateToPanel} />
|
| 202 |
</>
|
| 203 |
)
|
| 204 |
}
|
|
|
|
| 259 |
)
|
| 260 |
}
|
| 261 |
|
| 262 |
+
function MobileBottomBar({ activeTab, navigateToPanel }: {
|
| 263 |
activeTab: string
|
| 264 |
+
navigateToPanel: (tab: string) => void
|
| 265 |
}) {
|
| 266 |
const [sheetOpen, setSheetOpen] = useState(false)
|
| 267 |
const priorityItems = allNavItems.filter(i => i.priority)
|
|
|
|
| 275 |
{priorityItems.map((item) => (
|
| 276 |
<button
|
| 277 |
key={item.id}
|
| 278 |
+
onClick={() => navigateToPanel(item.id)}
|
| 279 |
className={`flex flex-col items-center justify-center gap-0.5 px-2 py-2 rounded-lg transition-smooth min-w-[48px] min-h-[48px] ${
|
| 280 |
activeTab === item.id
|
| 281 |
? 'text-primary'
|
|
|
|
| 313 |
open={sheetOpen}
|
| 314 |
onClose={() => setSheetOpen(false)}
|
| 315 |
activeTab={activeTab}
|
| 316 |
+
navigateToPanel={navigateToPanel}
|
| 317 |
/>
|
| 318 |
</>
|
| 319 |
)
|
| 320 |
}
|
| 321 |
|
| 322 |
+
function MobileBottomSheet({ open, onClose, activeTab, navigateToPanel }: {
|
| 323 |
open: boolean
|
| 324 |
onClose: () => void
|
| 325 |
activeTab: string
|
| 326 |
+
navigateToPanel: (tab: string) => void
|
| 327 |
}) {
|
| 328 |
// Track mount state for animation
|
| 329 |
const [visible, setVisible] = useState(false)
|
|
|
|
| 387 |
<button
|
| 388 |
key={item.id}
|
| 389 |
onClick={() => {
|
| 390 |
+
navigateToPanel(item.id)
|
| 391 |
handleClose()
|
| 392 |
}}
|
| 393 |
className={`flex items-center gap-2.5 px-3 min-h-[48px] rounded-xl transition-smooth ${
|
src/lib/navigation.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use client'
|
| 2 |
+
|
| 3 |
+
import { useRouter } from 'next/navigation'
|
| 4 |
+
import { useCallback } from 'react'
|
| 5 |
+
|
| 6 |
+
export function panelHref(panel: string): string {
|
| 7 |
+
return panel === 'overview' ? '/' : `/${panel}`
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
export function useNavigateToPanel() {
|
| 11 |
+
const router = useRouter()
|
| 12 |
+
return useCallback((panel: string) => {
|
| 13 |
+
router.push(panelHref(panel))
|
| 14 |
+
}, [router])
|
| 15 |
+
}
|