Skip to content

feat: add File Explorer for context folder in admin settings#491

Draft
Bl3f wants to merge 11 commits intomainfrom
cursor/context-folder-explorer-32b4
Draft

feat: add File Explorer for context folder in admin settings#491
Bl3f wants to merge 11 commits intomainfrom
cursor/context-folder-explorer-32b4

Conversation

@Bl3f
Copy link
Contributor

@Bl3f Bl3f commented Mar 20, 2026

Summary

Adds a read-only File Explorer page in the Admin settings that lets admins browse and view files from the project's context folder, similar to an editor's file explorer.

Changes

Backend

  • context-explorer.service.ts — New service with two functions:
    • getFileTree() — Recursively reads the context folder and returns a tree structure, respecting .naoignore patterns and excluded directories
    • readFileContent() — Reads a file's content (with 1 MB size limit and path validation)
  • context-explorer.routes.ts — Two admin-protected tRPC endpoints:
    • contextExplorer.getFileTree — Returns the full file tree
    • contextExplorer.readFile — Returns a single file's content
  • router.ts — Registered the new contextExplorer routes

Frontend

  • file-tree.tsx — Tree view component with:
    • Expandable directories with chevron + colored folder icons
    • Extension-based colored file icons (FileCode for .ts/.js/.py/.sql, FileJson for .json, FileText for .md/.txt, FileSpreadsheet for .csv, etc.)
    • File search input at the top for filtering the tree
    • Cursor pointer on hover, proper hover padding
  • file-viewer.tsx — Monaco editor wrapper in read-only mode with:
    • Automatic language detection based on file extension
    • Light/dark theme support via useEditorTheme hook
    • Custom nao-light / nao-dark Monaco themes with subtle line highlight background (no border), similar to Cursor's style
  • use-editor-theme.ts — Hook that resolves the Monaco theme (vs / vs-dark) from the app's light/dark/system theme setting, including reacting to system preference changes
  • _sidebar-layout.settings.context-explorer.tsx — Route page with:
    • Header with title and refresh button
    • Resizable left panel: file tree with search (react-resizable-panels v4 API)
    • Resizable right panel: file viewer with Monaco editor
  • sidebar-settings-nav.tsx — Added "File Explorer" entry (admin-only) to settings navigation
  • routeTree.gen.ts — Updated with the new route registration

How it works

  1. Admin navigates to Settings → File Explorer
  2. The file tree loads showing all files/directories in the context folder
  3. Clicking a directory expands/collapses it
  4. Clicking a file loads its content in the Monaco editor (read-only)
  5. The sidebar is resizable by dragging the separator
  6. The search input filters files across the entire tree
  7. Monaco editor theme automatically matches the app's light/dark mode
Open in Web Open in Cursor 

- Add backend service (context-explorer.service.ts) with recursive file
  tree listing and file content reading, respecting .naoignore patterns
- Add tRPC routes (context-explorer.routes.ts) with getFileTree and
  readFile endpoints, both admin-protected
- Add frontend FileTree component with expandable directory nodes
- Add frontend FileViewer component using Monaco editor (read-only)
  with language detection by file extension
- Add context-explorer route page with tree sidebar and file viewer
- Add 'File Explorer' entry to admin settings sidebar navigation
- Update routeTree.gen.ts with new route registration
@github-actions
Copy link
Contributor

github-actions bot commented Mar 20, 2026

🚀 Preview Deployment

URL https://pr-491-254d910.preview.getnao.io
Commit 254d910

⚠️ No LLM API keys configured - you'll see the API key setup flow when trying to chat.


Preview will be automatically removed when this PR is closed.

- Add cursor pointer on tree item hover
- Use colored file icons based on extension (FileCode, FileJson, etc.)
- Color folder icons amber for better visual distinction
- Respect light/dark theme in Monaco editor via useEditorTheme hook
- Fix tree hover padding (separate pr/pl for proper indent)
- Make tree sidebar resizable using ResizablePanelGroup
- Add file search input at the top of the file tree with filtering
Use defaultLayout on PanelGroup with fractional sizes (1:3 ratio)
and pixel-based minSize on panels instead of the old percentage-based
defaultSize/minSize/maxSize API which caused the sidebar to be stuck
at ~49px.
Define custom nao-light and nao-dark Monaco themes that use a soft
background tint for the current line highlight instead of the default
harsh border, similar to Cursor's style.
Replace exact substring matching with fuzzy character-sequence
matching. Also include folder names in search results — when a
folder name matches, all its children are shown.
The ResizableSeparator already renders a 1px border line. Remove
the extra border-r on the tree panel that was doubling it up.
Monaco intercepts all keyboard shortcuts when focused. Override the
Cmd/Ctrl+K binding to dispatch the event to window so the global
command menu listener picks it up.
Match the query against entry.path instead of entry.name so queries
like 'orderscolumn' match paths like '/databases/orders/columns.md'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants