Spaces:
Runtime error
Runtime error
Nyk commited on
Commit ·
0ae06ef
1
Parent(s): 3c99311
fix: add documents navigation and panel
Browse files
src/app/[[...panel]]/page.tsx
CHANGED
|
@@ -32,6 +32,7 @@ import { MultiGatewayPanel } from '@/components/panels/multi-gateway-panel'
|
|
| 32 |
import { SuperAdminPanel } from '@/components/panels/super-admin-panel'
|
| 33 |
import { OfficePanel } from '@/components/panels/office-panel'
|
| 34 |
import { GitHubSyncPanel } from '@/components/panels/github-sync-panel'
|
|
|
|
| 35 |
import { ChatPanel } from '@/components/chat/chat-panel'
|
| 36 |
import { ErrorBoundary } from '@/components/ErrorBoundary'
|
| 37 |
import { LocalModeBanner } from '@/components/layout/local-mode-banner'
|
|
@@ -266,6 +267,8 @@ function ContentRouter({ tab }: { tab: string }) {
|
|
| 266 |
return <GitHubSyncPanel />
|
| 267 |
case 'office':
|
| 268 |
return <OfficePanel />
|
|
|
|
|
|
|
| 269 |
case 'super-admin':
|
| 270 |
return <SuperAdminPanel />
|
| 271 |
case 'workspaces':
|
|
|
|
| 32 |
import { SuperAdminPanel } from '@/components/panels/super-admin-panel'
|
| 33 |
import { OfficePanel } from '@/components/panels/office-panel'
|
| 34 |
import { GitHubSyncPanel } from '@/components/panels/github-sync-panel'
|
| 35 |
+
import { DocumentsPanel } from '@/components/panels/documents-panel'
|
| 36 |
import { ChatPanel } from '@/components/chat/chat-panel'
|
| 37 |
import { ErrorBoundary } from '@/components/ErrorBoundary'
|
| 38 |
import { LocalModeBanner } from '@/components/layout/local-mode-banner'
|
|
|
|
| 267 |
return <GitHubSyncPanel />
|
| 268 |
case 'office':
|
| 269 |
return <OfficePanel />
|
| 270 |
+
case 'documents':
|
| 271 |
+
return <DocumentsPanel />
|
| 272 |
case 'super-admin':
|
| 273 |
return <SuperAdminPanel />
|
| 274 |
case 'workspaces':
|
src/components/layout/header-bar.tsx
CHANGED
|
@@ -29,6 +29,7 @@ export function HeaderBar() {
|
|
| 29 |
agents: 'Agent Squad',
|
| 30 |
tasks: 'Task Board',
|
| 31 |
sessions: 'Sessions',
|
|
|
|
| 32 |
activity: 'Activity Feed',
|
| 33 |
notifications: 'Notifications',
|
| 34 |
standup: 'Daily Standup',
|
|
|
|
| 29 |
agents: 'Agent Squad',
|
| 30 |
tasks: 'Task Board',
|
| 31 |
sessions: 'Sessions',
|
| 32 |
+
documents: 'Documents',
|
| 33 |
activity: 'Activity Feed',
|
| 34 |
notifications: 'Notifications',
|
| 35 |
standup: 'Daily Standup',
|
src/components/layout/nav-rail.tsx
CHANGED
|
@@ -27,6 +27,7 @@ const navGroups: NavGroup[] = [
|
|
| 27 |
{ id: 'tasks', label: 'Tasks', icon: <TasksIcon />, priority: true },
|
| 28 |
{ id: 'sessions', label: 'Sessions', icon: <SessionsIcon />, priority: false },
|
| 29 |
{ id: 'office', label: 'Office', icon: <OfficeIcon />, priority: false },
|
|
|
|
| 30 |
],
|
| 31 |
},
|
| 32 |
{
|
|
@@ -637,3 +638,13 @@ function OfficeIcon() {
|
|
| 637 |
</svg>
|
| 638 |
)
|
| 639 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
{ id: 'tasks', label: 'Tasks', icon: <TasksIcon />, priority: true },
|
| 28 |
{ id: 'sessions', label: 'Sessions', icon: <SessionsIcon />, priority: false },
|
| 29 |
{ id: 'office', label: 'Office', icon: <OfficeIcon />, priority: false },
|
| 30 |
+
{ id: 'documents', label: 'Documents', icon: <DocumentsIcon />, priority: false },
|
| 31 |
],
|
| 32 |
},
|
| 33 |
{
|
|
|
|
| 638 |
</svg>
|
| 639 |
)
|
| 640 |
}
|
| 641 |
+
|
| 642 |
+
function DocumentsIcon() {
|
| 643 |
+
return (
|
| 644 |
+
<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
|
| 645 |
+
<path d="M3 1.5h7l3 3V14a1 1 0 01-1 1H3a1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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use client'
|
| 2 |
+
|
| 3 |
+
import { useCallback, useEffect, useMemo, useState } from 'react'
|
| 4 |
+
import { MarkdownRenderer } from '@/components/markdown-renderer'
|
| 5 |
+
|
| 6 |
+
interface DocsTreeNode {
|
| 7 |
+
path: string
|
| 8 |
+
name: string
|
| 9 |
+
type: 'file' | 'directory'
|
| 10 |
+
size?: number
|
| 11 |
+
modified?: number
|
| 12 |
+
children?: DocsTreeNode[]
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
interface DocsTreeResponse {
|
| 16 |
+
roots: string[]
|
| 17 |
+
tree: DocsTreeNode[]
|
| 18 |
+
error?: string
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
interface DocsContentResponse {
|
| 22 |
+
path: string
|
| 23 |
+
content: string
|
| 24 |
+
size: number
|
| 25 |
+
modified: number
|
| 26 |
+
error?: string
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
interface DocsSearchResult {
|
| 30 |
+
path: string
|
| 31 |
+
name: string
|
| 32 |
+
matches: number
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
interface DocsSearchResponse {
|
| 36 |
+
results: DocsSearchResult[]
|
| 37 |
+
error?: string
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
function collectFilePaths(nodes: DocsTreeNode[]): string[] {
|
| 41 |
+
const filePaths: string[] = []
|
| 42 |
+
for (const node of nodes) {
|
| 43 |
+
if (node.type === 'file') {
|
| 44 |
+
filePaths.push(node.path)
|
| 45 |
+
continue
|
| 46 |
+
}
|
| 47 |
+
if (node.children && node.children.length > 0) {
|
| 48 |
+
filePaths.push(...collectFilePaths(node.children))
|
| 49 |
+
}
|
| 50 |
+
}
|
| 51 |
+
return filePaths
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
function formatBytes(value: number): string {
|
| 55 |
+
if (value < 1024) return `${value} B`
|
| 56 |
+
if (value < 1024 * 1024) return `${(value / 1024).toFixed(1)} KB`
|
| 57 |
+
return `${(value / (1024 * 1024)).toFixed(1)} MB`
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
function formatTime(value: number): string {
|
| 61 |
+
return new Date(value).toLocaleString()
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
export function DocumentsPanel() {
|
| 65 |
+
const [tree, setTree] = useState<DocsTreeNode[]>([])
|
| 66 |
+
const [roots, setRoots] = useState<string[]>([])
|
| 67 |
+
const [loadingTree, setLoadingTree] = useState(true)
|
| 68 |
+
const [treeError, setTreeError] = useState<string | null>(null)
|
| 69 |
+
const [selectedPath, setSelectedPath] = useState<string | null>(null)
|
| 70 |
+
const [docContent, setDocContent] = useState<string>('')
|
| 71 |
+
const [docMeta, setDocMeta] = useState<{ size: number; modified: number } | null>(null)
|
| 72 |
+
const [loadingDoc, setLoadingDoc] = useState(false)
|
| 73 |
+
const [docError, setDocError] = useState<string | null>(null)
|
| 74 |
+
const [searchQuery, setSearchQuery] = useState('')
|
| 75 |
+
const [searchResults, setSearchResults] = useState<DocsSearchResult[]>([])
|
| 76 |
+
const [searching, setSearching] = useState(false)
|
| 77 |
+
const [searchError, setSearchError] = useState<string | null>(null)
|
| 78 |
+
const [expandedDirs, setExpandedDirs] = useState<Set<string>>(new Set())
|
| 79 |
+
|
| 80 |
+
const loadTree = useCallback(async () => {
|
| 81 |
+
setLoadingTree(true)
|
| 82 |
+
setTreeError(null)
|
| 83 |
+
try {
|
| 84 |
+
const res = await fetch('/api/docs/tree')
|
| 85 |
+
const data = (await res.json()) as DocsTreeResponse
|
| 86 |
+
if (!res.ok) throw new Error(data.error || 'Failed to load documents')
|
| 87 |
+
|
| 88 |
+
setTree(data.tree || [])
|
| 89 |
+
setRoots(data.roots || [])
|
| 90 |
+
const defaultExpanded = new Set<string>((data.roots || []).filter(Boolean))
|
| 91 |
+
setExpandedDirs(defaultExpanded)
|
| 92 |
+
} catch (error) {
|
| 93 |
+
setTree([])
|
| 94 |
+
setRoots([])
|
| 95 |
+
setTreeError((error as Error).message || 'Failed to load documents')
|
| 96 |
+
} finally {
|
| 97 |
+
setLoadingTree(false)
|
| 98 |
+
}
|
| 99 |
+
}, [])
|
| 100 |
+
|
| 101 |
+
const loadDoc = useCallback(async (path: string) => {
|
| 102 |
+
setLoadingDoc(true)
|
| 103 |
+
setDocError(null)
|
| 104 |
+
setSelectedPath(path)
|
| 105 |
+
try {
|
| 106 |
+
const res = await fetch(`/api/docs/content?path=${encodeURIComponent(path)}`)
|
| 107 |
+
const data = (await res.json()) as DocsContentResponse
|
| 108 |
+
if (!res.ok) throw new Error(data.error || 'Failed to load document')
|
| 109 |
+
setDocContent(data.content || '')
|
| 110 |
+
setDocMeta({ size: data.size, modified: data.modified })
|
| 111 |
+
} catch (error) {
|
| 112 |
+
setDocContent('')
|
| 113 |
+
setDocMeta(null)
|
| 114 |
+
setDocError((error as Error).message || 'Failed to load document')
|
| 115 |
+
} finally {
|
| 116 |
+
setLoadingDoc(false)
|
| 117 |
+
}
|
| 118 |
+
}, [])
|
| 119 |
+
|
| 120 |
+
useEffect(() => {
|
| 121 |
+
void loadTree()
|
| 122 |
+
}, [loadTree])
|
| 123 |
+
|
| 124 |
+
const filePaths = useMemo(() => collectFilePaths(tree), [tree])
|
| 125 |
+
|
| 126 |
+
useEffect(() => {
|
| 127 |
+
if (selectedPath) return
|
| 128 |
+
if (filePaths.length === 0) return
|
| 129 |
+
void loadDoc(filePaths[0])
|
| 130 |
+
}, [filePaths, loadDoc, selectedPath])
|
| 131 |
+
|
| 132 |
+
useEffect(() => {
|
| 133 |
+
const query = searchQuery.trim()
|
| 134 |
+
if (query.length < 2) {
|
| 135 |
+
setSearchResults([])
|
| 136 |
+
setSearchError(null)
|
| 137 |
+
setSearching(false)
|
| 138 |
+
return
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
const handle = setTimeout(async () => {
|
| 142 |
+
setSearching(true)
|
| 143 |
+
setSearchError(null)
|
| 144 |
+
try {
|
| 145 |
+
const res = await fetch(`/api/docs/search?q=${encodeURIComponent(query)}&limit=100`)
|
| 146 |
+
const data = (await res.json()) as DocsSearchResponse
|
| 147 |
+
if (!res.ok) throw new Error(data.error || 'Failed to search docs')
|
| 148 |
+
setSearchResults(data.results || [])
|
| 149 |
+
} catch (error) {
|
| 150 |
+
setSearchResults([])
|
| 151 |
+
setSearchError((error as Error).message || 'Failed to search docs')
|
| 152 |
+
} finally {
|
| 153 |
+
setSearching(false)
|
| 154 |
+
}
|
| 155 |
+
}, 250)
|
| 156 |
+
|
| 157 |
+
return () => clearTimeout(handle)
|
| 158 |
+
}, [searchQuery])
|
| 159 |
+
|
| 160 |
+
const isShowingSearch = searchQuery.trim().length >= 2
|
| 161 |
+
|
| 162 |
+
const toggleDir = (path: string) => {
|
| 163 |
+
setExpandedDirs((prev) => {
|
| 164 |
+
const next = new Set(prev)
|
| 165 |
+
if (next.has(path)) next.delete(path)
|
| 166 |
+
else next.add(path)
|
| 167 |
+
return next
|
| 168 |
+
})
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
const renderNode = (node: DocsTreeNode, depth = 0) => {
|
| 172 |
+
if (node.type === 'directory') {
|
| 173 |
+
const isOpen = expandedDirs.has(node.path)
|
| 174 |
+
return (
|
| 175 |
+
<div key={node.path}>
|
| 176 |
+
<button
|
| 177 |
+
onClick={() => toggleDir(node.path)}
|
| 178 |
+
className="w-full flex items-center gap-2 py-1.5 px-2 rounded-md hover:bg-secondary text-left"
|
| 179 |
+
style={{ paddingLeft: `${depth * 16 + 8}px` }}
|
| 180 |
+
>
|
| 181 |
+
<span className="text-xs text-muted-foreground">{isOpen ? '▾' : '▸'}</span>
|
| 182 |
+
<span className="text-sm text-foreground">{node.name}</span>
|
| 183 |
+
</button>
|
| 184 |
+
{isOpen && node.children && (
|
| 185 |
+
<div>
|
| 186 |
+
{node.children.map((child) => renderNode(child, depth + 1))}
|
| 187 |
+
</div>
|
| 188 |
+
)}
|
| 189 |
+
</div>
|
| 190 |
+
)
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
+
const active = selectedPath === node.path
|
| 194 |
+
return (
|
| 195 |
+
<button
|
| 196 |
+
key={node.path}
|
| 197 |
+
onClick={() => void loadDoc(node.path)}
|
| 198 |
+
className={`w-full text-left py-1.5 px-2 rounded-md text-sm ${
|
| 199 |
+
active ? 'bg-primary/15 text-primary' : 'text-foreground hover:bg-secondary'
|
| 200 |
+
}`}
|
| 201 |
+
style={{ paddingLeft: `${depth * 16 + 26}px` }}
|
| 202 |
+
>
|
| 203 |
+
{node.name}
|
| 204 |
+
</button>
|
| 205 |
+
)
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
return (
|
| 209 |
+
<div className="h-full p-4 md:p-6">
|
| 210 |
+
<div className="h-full min-h-[600px] rounded-xl border border-border bg-card overflow-hidden grid grid-cols-1 lg:grid-cols-[340px_1fr]">
|
| 211 |
+
<aside className="border-r border-border p-4 space-y-3 overflow-y-auto">
|
| 212 |
+
<div className="flex items-center justify-between">
|
| 213 |
+
<h2 className="text-sm font-semibold text-foreground">Documents</h2>
|
| 214 |
+
<button
|
| 215 |
+
onClick={() => void loadTree()}
|
| 216 |
+
className="text-xs px-2 py-1 rounded-md border border-border text-muted-foreground hover:text-foreground hover:bg-secondary"
|
| 217 |
+
>
|
| 218 |
+
Refresh
|
| 219 |
+
</button>
|
| 220 |
+
</div>
|
| 221 |
+
|
| 222 |
+
<div className="space-y-1">
|
| 223 |
+
<label htmlFor="docs-search" className="text-xs text-muted-foreground">Search docs</label>
|
| 224 |
+
<input
|
| 225 |
+
id="docs-search"
|
| 226 |
+
value={searchQuery}
|
| 227 |
+
onChange={(event) => setSearchQuery(event.target.value)}
|
| 228 |
+
placeholder="Type at least 2 characters..."
|
| 229 |
+
className="w-full h-9 px-3 rounded-md bg-background border border-border text-sm text-foreground focus:outline-none focus:ring-1 focus:ring-primary/50"
|
| 230 |
+
/>
|
| 231 |
+
</div>
|
| 232 |
+
|
| 233 |
+
{roots.length > 0 && (
|
| 234 |
+
<div className="text-xs text-muted-foreground">
|
| 235 |
+
Roots: {roots.join(', ')}
|
| 236 |
+
</div>
|
| 237 |
+
)}
|
| 238 |
+
|
| 239 |
+
{loadingTree && (
|
| 240 |
+
<div className="text-sm text-muted-foreground">Loading documents...</div>
|
| 241 |
+
)}
|
| 242 |
+
|
| 243 |
+
{treeError && (
|
| 244 |
+
<div className="text-sm text-red-400">{treeError}</div>
|
| 245 |
+
)}
|
| 246 |
+
|
| 247 |
+
{!loadingTree && !treeError && isShowingSearch && (
|
| 248 |
+
<div className="space-y-1">
|
| 249 |
+
{searching && <div className="text-sm text-muted-foreground">Searching...</div>}
|
| 250 |
+
{searchError && <div className="text-sm text-red-400">{searchError}</div>}
|
| 251 |
+
{!searching && !searchError && searchResults.length === 0 && (
|
| 252 |
+
<div className="text-sm text-muted-foreground">No matches.</div>
|
| 253 |
+
)}
|
| 254 |
+
{!searching && !searchError && searchResults.map((result) => (
|
| 255 |
+
<button
|
| 256 |
+
key={result.path}
|
| 257 |
+
onClick={() => void loadDoc(result.path)}
|
| 258 |
+
className={`w-full text-left p-2 rounded-md border ${
|
| 259 |
+
selectedPath === result.path
|
| 260 |
+
? 'border-primary/40 bg-primary/10'
|
| 261 |
+
: 'border-border hover:bg-secondary'
|
| 262 |
+
}`}
|
| 263 |
+
>
|
| 264 |
+
<div className="text-sm text-foreground truncate">{result.name}</div>
|
| 265 |
+
<div className="text-xs text-muted-foreground truncate">{result.path}</div>
|
| 266 |
+
<div className="text-2xs text-muted-foreground mt-0.5">{result.matches} matches</div>
|
| 267 |
+
</button>
|
| 268 |
+
))}
|
| 269 |
+
</div>
|
| 270 |
+
)}
|
| 271 |
+
|
| 272 |
+
{!loadingTree && !treeError && !isShowingSearch && (
|
| 273 |
+
<div className="space-y-1">
|
| 274 |
+
{tree.length === 0 && (
|
| 275 |
+
<div className="text-sm text-muted-foreground">
|
| 276 |
+
No supported docs roots found. Add one of: <code className="font-mono">docs</code>, <code className="font-mono">knowledge-base</code>, <code className="font-mono">knowledge</code>, <code className="font-mono">memory</code>.
|
| 277 |
+
</div>
|
| 278 |
+
)}
|
| 279 |
+
{tree.map((node) => renderNode(node))}
|
| 280 |
+
</div>
|
| 281 |
+
)}
|
| 282 |
+
</aside>
|
| 283 |
+
|
| 284 |
+
<section className="p-4 md:p-6 overflow-y-auto">
|
| 285 |
+
<div className="mb-4">
|
| 286 |
+
<h3 className="text-base md:text-lg font-semibold text-foreground">Document Viewer</h3>
|
| 287 |
+
<p className="text-xs text-muted-foreground mt-1">
|
| 288 |
+
Browse and inspect workspace docs from allowed roots.
|
| 289 |
+
</p>
|
| 290 |
+
</div>
|
| 291 |
+
|
| 292 |
+
{!selectedPath && (
|
| 293 |
+
<div className="text-sm text-muted-foreground">Select a file to view its contents.</div>
|
| 294 |
+
)}
|
| 295 |
+
|
| 296 |
+
{selectedPath && (
|
| 297 |
+
<div className="space-y-3">
|
| 298 |
+
<div className="rounded-md border border-border bg-secondary/30 px-3 py-2">
|
| 299 |
+
<div className="text-sm text-foreground font-medium break-all">{selectedPath}</div>
|
| 300 |
+
{docMeta && (
|
| 301 |
+
<div className="mt-1 text-xs text-muted-foreground">
|
| 302 |
+
{formatBytes(docMeta.size)} • Updated {formatTime(docMeta.modified)}
|
| 303 |
+
</div>
|
| 304 |
+
)}
|
| 305 |
+
</div>
|
| 306 |
+
|
| 307 |
+
{loadingDoc && <div className="text-sm text-muted-foreground">Loading document...</div>}
|
| 308 |
+
{docError && <div className="text-sm text-red-400">{docError}</div>}
|
| 309 |
+
|
| 310 |
+
{!loadingDoc && !docError && (
|
| 311 |
+
<div className="rounded-md border border-border bg-background p-4">
|
| 312 |
+
<MarkdownRenderer content={docContent} />
|
| 313 |
+
</div>
|
| 314 |
+
)}
|
| 315 |
+
</div>
|
| 316 |
+
)}
|
| 317 |
+
</section>
|
| 318 |
+
</div>
|
| 319 |
+
</div>
|
| 320 |
+
)
|
| 321 |
+
}
|