Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

feat(palette): Files section with fuzzy file search + open (editor/OS)

enes07efc7194a3e
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsx
index 918f4ef8e..3f70183b7 100644
--- a/src/renderer/canvas/Canvas.tsx
+++ b/src/renderer/canvas/Canvas.tsx
@@ -57,6 +57,8 @@ import { ExplorerPanel } from '../components/ExplorerPanel'
import { UsageIndicator } from '../components/UsageIndicator'
import { RemoteSessionView } from './RemoteSessionView'
import { transport } from '../terminal/local-transport'
+import { prepareQuickOpenFiles, type QuickOpenIndexedFile } from '../lib/quickOpenSearch'
+import { opensInEditor } from '../lib/openTarget'
import { useProjects } from '../state/projects'
import { useAgentStatus } from '../state/agentStatus'
import { useAgentNodes } from '../state/agentNodes'
@@ -113,6 +115,7 @@ export function Canvas() {
const [zoomPct, setZoomPct] = useState(100)
const [menu, setMenu] = useState<{ x: number; y: number; items: MenuItem[] } | null>(null)
const [paletteOpen, setPaletteOpen] = useState(false)
+ const [fileIndex, setFileIndex] = useState<QuickOpenIndexedFile[]>([])
// Cached visible-buffer text per terminal, for command-palette content search.
const [bufferCache, setBufferCache] = useState<Record<string, string>>({})
const captureTsRef = useRef<Record<string, number>>({})
@@ -722,6 +725,36 @@ export function Canvas() {
[setNodes, markDirty, viewCenter]
)
+ // Load the quick-open file index when the palette opens.
+ useEffect(() => {
+ if (!paletteOpen) return
+ const cwd = useProjects.getState().getProject(activeProjectId ?? '')?.cwd
+ if (!cwd) {
+ setFileIndex([])
+ return
+ }
+ let cancelled = false
+ void window.nodeTerminal.files.quickOpen(cwd).then((files) => {
+ if (!cancelled) setFileIndex(prepareQuickOpenFiles(files))
+ })
+ return () => {
+ cancelled = true
+ }
+ }, [paletteOpen, activeProjectId])
+
+ /** Open a quick-open file result by root-relative path: editor node for text/images,
+ * OS default app for binaries (e.g. .dmg). */
+ const openProjectFile = useCallback(
+ (relPath: string) => {
+ const cwd = useProjects.getState().getProject(activeProjectId ?? '')?.cwd
+ if (!cwd) return
+ const abs = `${cwd.replace(/\/$/, '')}/${relPath}`
+ if (opensInEditor(relPath)) openFile(abs)
+ else window.nodeTerminal.shell.openPath(abs)
+ },
+ [activeProjectId, openFile]
+ )
+
/** Open a git diff editor node for a changed file (from Source Control). */
const openDiff = useCallback(
(relPath: string, staged: boolean) => {
@@ -1794,7 +1827,12 @@ export function Canvas() {
)}
{paletteOpen && (
- <CommandPalette commands={buildCommands()} onClose={() => setPaletteOpen(false)} />
+ <CommandPalette
+ commands={buildCommands()}
+ fileIndex={fileIndex}
+ onOpenFile={openProjectFile}
+ onClose={() => setPaletteOpen(false)}
+ />
)}
{settingsOpen && <SettingsPage onClose={() => setSettingsOpen(false)} />}
diff --git a/src/renderer/components/CommandPalette.tsx b/src/renderer/components/CommandPalette.tsx
index ff133b01c..0d6da9da8 100644
--- a/src/renderer/components/CommandPalette.tsx
+++ b/src/renderer/components/CommandPalette.tsx
@@ -1,5 +1,7 @@
import { useMemo, useState, type ReactNode } from 'react'
import { createPortal } from 'react-dom'
+import { rankQuickOpenFiles, type QuickOpenIndexedFile } from '../lib/quickOpenSearch'
+import { IconEditor } from './icons'
export interface Command {
id: string
@@ -10,11 +12,21 @@ export interface Command {
/** Searchable body text (e.g. a terminal's visible output) — matched by substring. */
content?: string
run: () => void
+ /** Optional secondary action shown as a right-aligned button (e.g. "Reveal in Explorer"). */
+ onSecondary?: () => void
+ /** Label for the secondary-action button (defaults to "Reveal"). */
+ secondaryLabel?: string
}
interface CommandPaletteProps {
commands: Command[]
onClose: () => void
+ /** Prepared file index for the active project (⌘K file search). */
+ fileIndex?: QuickOpenIndexedFile[]
+ /** Open a file result by its root-relative path. */
+ onOpenFile?: (relPath: string) => void
+ /** Reveal a file result in the Explorer by its root-relative path. */
+ onRevealFile?: (relPath: string) => void
}
/** Case-insensitive subsequence match — "ntr" matches "New TeRminal". */
@@ -31,7 +43,13 @@ function matches(label: string, q: string): boolean {
}
/** Cmd/Ctrl+K command palette: fuzzy-filter actions and jump targets, Enter to run. */
-export function CommandPalette({ commands, onClose }: CommandPaletteProps) {
+export function CommandPalette({
+ commands,
+ onClose,
+ fileIndex,
+ onOpenFile,
+ onRevealFile
+}: CommandPaletteProps) {
const [query, setQuery] = useState('')
const [active, setActive] = useState(0)
@@ -45,6 +63,26 @@ export function CommandPalette({ commands, onClose }: CommandPaletteProps) {
[commands, query]
)
+ const fileCommands = useMemo<Command[]>(() => {
+ if (!fileIndex || !onOpenFile || query.trim().length < 1) return []
+ return rankQuickOpenFiles(query, fileIndex, 20).map((r) => {
+ const base = r.path.split('/').pop() ?? r.path
+ const dir = r.path.slice(0, r.path.length - base.length).replace(/\/$/, '')
+ return {
+ id: `file:${r.path}`,
+ label: base,
+ hint: dir,
+ section: 'Files',
+ icon: <IconEditor />,
+ run: () => onOpenFile(r.path),
+ onSecondary: onRevealFile ? () => onRevealFile(r.path) : undefined,
+ secondaryLabel: 'Reveal in Explorer'
+ }
+ })
+ }, [fileIndex, onOpenFile, onRevealFile, query])
+
+ const items = useMemo(() => [...filtered, ...fileCommands], [filtered, fileCommands])
+
const run = (cmd?: Command) => {
if (!cmd) return
cmd.run()
@@ -67,35 +105,59 @@ export function CommandPalette({ commands, onClose }: CommandPaletteProps) {
onKeyDown={(e) => {
if (e.key === 'ArrowDown') {
e.preventDefault()
- setActive((a) => Math.min(a + 1, filtered.length - 1))
+ setActive((a) => Math.min(a + 1, items.length - 1))
} else if (e.key === 'ArrowUp') {
e.preventDefault()
setActive((a) => Math.max(a - 1, 0))
+ } else if (e.key === 'Enter' && (e.metaKey || e.ctrlKey)) {
+ e.preventDefault()
+ const c = items[active]
+ if (c?.onSecondary) {
+ c.onSecondary()
+ onClose()
+ }
} else if (e.key === 'Enter') {
e.preventDefault()
- run(filtered[active])
+ run(items[active])
} else if (e.key === 'Escape') {
onClose()
}
}}
/>
<div className="palette__list">
- {filtered.length === 0 && <div className="palette__empty">No matches</div>}
- {filtered.map((c, i) => (
- <button
- key={c.id}
- className={`palette__item${i === active ? ' active' : ''}`}
- onMouseEnter={() => setActive(i)}
- onClick={() => run(c)}
- >
- <span className="palette__icon">{c.icon}</span>
- <span className="palette__label">{c.label}</span>
- {!labelHit(c) && contentHit(c) ? (
- <span className="palette__hint">found in output</span>
- ) : (
- c.hint && <span className="palette__hint">{c.hint}</span>
+ {items.length === 0 && <div className="palette__empty">No matches</div>}
+ {items.map((c, i) => (
+ <div key={c.id} className="palette__row">
+ {c.section && c.section !== items[i - 1]?.section && (
+ <div className="palette__section">{c.section}</div>
)}
- </button>
+ <button
+ className={`palette__item${i === active ? ' active' : ''}`}
+ onMouseEnter={() => setActive(i)}
+ onClick={() => run(c)}
+ >
+ <span className="palette__icon">{c.icon}</span>
+ <span className="palette__label">{c.label}</span>
+ {!labelHit(c) && contentHit(c) ? (
+ <span className="palette__hint">found in output</span>
+ ) : (
+ c.hint && <span className="palette__hint">{c.hint}</span>
+ )}
+ {c.onSecondary && (
+ <span
+ className="palette__secondary"
+ title={c.secondaryLabel}
+ onClick={(e) => {
+ e.stopPropagation()
+ c.onSecondary?.()
+ onClose()
+ }}
+ >
+ ⤷
+ </span>
+ )}
+ </button>
+ </div>
))}
</div>
</div>
diff --git a/src/renderer/lib/openTarget.test.ts b/src/renderer/lib/openTarget.test.ts
new file mode 100644
index 000000000..71c040435
--- /dev/null
+++ b/src/renderer/lib/openTarget.test.ts
@@ -0,0 +1,15 @@
+import { describe, it, expect } from 'vitest'
+import { opensInEditor } from './openTarget'
+
+describe('opensInEditor', () => {
+ it('text and image files open in an editor node', () => {
+ for (const p of ['src/a.ts', 'README.md', 'a/b.json', 'icon.png', 'photo.JPG', 'notes']) {
+ expect(opensInEditor(p)).toBe(true)
+ }
+ })
+ it('binary/app artifacts open with the OS instead', () => {
+ for (const p of ['dist/app.dmg', 'x.zip', 'y.pkg', 'App.app/Contents/Info', 'a.tar.gz']) {
+ expect(opensInEditor(p)).toBe(false)
+ }
+ })
+})
diff --git a/src/renderer/lib/openTarget.ts b/src/renderer/lib/openTarget.ts
new file mode 100644
index 000000000..a1db67079
--- /dev/null
+++ b/src/renderer/lib/openTarget.ts
@@ -0,0 +1,29 @@
+/** Decides whether a quick-open file should open as an editor node (text/image, handled by
+ * EditorNode) or be handed to the OS default app (binaries/installers like .dmg). */
+
+// Extensions the OS should handle — EditorNode (Monaco) can't render these. Anything NOT in
+// this set opens in an editor node (text, code, images, or extensionless config files).
+const OS_OPEN_EXTENSIONS = new Set([
+ 'dmg', 'pkg', 'app', 'zip', 'gz', 'tar', 'tgz', 'rar', '7z',
+ 'exe', 'msi', 'deb', 'rpm', 'iso',
+ 'mp4', 'mov', 'avi', 'mkv', 'mp3', 'wav', 'flac',
+ 'sqlite', 'db', 'bin', 'dat', 'wasm'
+])
+
+/** Returns the lowercase extension of a single path segment, or '' if it has none. */
+function extensionOf(segment: string): string {
+ const dot = segment.lastIndexOf('.')
+ if (dot <= 0) return ''
+ return segment.slice(dot + 1).toLowerCase()
+}
+
+export function opensInEditor(path: string): boolean {
+ const segments = path.replace(/\\/g, '/').split('/').filter(Boolean)
+ if (segments.length === 0) return true
+ // A file living inside an OS bundle/archive (e.g. "App.app/Contents/Info") must go to the OS,
+ // so inspect every segment — not just the basename.
+ for (const segment of segments) {
+ if (OS_OPEN_EXTENSIONS.has(extensionOf(segment))) return false
+ }
+ return true
+}
diff --git a/src/renderer/styles.css b/src/renderer/styles.css
index aa2145f2e..439124f56 100644
--- a/src/renderer/styles.css
+++ b/src/renderer/styles.css
@@ -2872,6 +2872,27 @@ body,
font-size: 11px;
}
+.palette__secondary {
+ margin-left: 8px;
+ padding: 1px 6px;
+ border-radius: 4px;
+ color: var(--muted);
+ flex-shrink: 0;
+}
+.palette__secondary:hover {
+ background: rgba(10, 132, 255, 0.18);
+ color: #6cb0ff;
+}
+
+.palette__section {
+ padding: 8px 12px 2px;
+ color: var(--muted-2);
+ font-size: 11px;
+ font-weight: 600;
+ text-transform: uppercase;
+ letter-spacing: 0.04em;
+}
+
.palette__empty {
padding: 16px;
color: var(--muted);