Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
9803bfd
feat(explorer): add optional host filesystem navigation
Chihen-Tai Sep 29, 2026
f612e99
test(explorer): toggle Host mode through state so tree remounts are o…
Chihen-Tai Sep 29, 2026
ebede3e
fix(explorer): keep Host-mode tabs out of persisted tab chrome
Chihen-Tai Sep 29, 2026
f7441cf
docs(explorer): note the patch trigger Host-tab filtering relies on
Chihen-Tai Sep 29, 2026
305b86c
perf(explorer): make Host/Project switching shift-free and cheap
Chihen-Tai Sep 29, 2026
d1cad27
fix(explorer): keep covered Project search inert and leave Host mode …
Chihen-Tai Sep 29, 2026
b90c711
fix(explorer): trust canonical ownership for Host opens and gate SSH …
Chihen-Tai Sep 29, 2026
1f63af9
fix(explorer): virtualize Host listings, block tree shortcuts under H…
Chihen-Tai Sep 29, 2026
27454a3
fix(explorer): start a new Host folder or filter at the top
Chihen-Tai Sep 29, 2026
34a7259
Merge stablyai/orca main into feat/explorer-host-mode
Chihen-Tai Sep 30, 2026
62c980d
refactor(explorer): trim Host mode to local and SSH, end it when leav…
Chihen-Tai Sep 30, 2026
e72c331
test(explorer): lock fresh Host sessions per entry and filter reset o…
Chihen-Tai Sep 30, 2026
9d48c37
test(explorer): type the recorded visit keys without an assertion
Chihen-Tai Sep 30, 2026
95990d2
fix(explorer): end Host mode when the host becomes unavailable
Chihen-Tai Sep 30, 2026
ab170a1
refactor(explorer): conservative cleanup before merge and end Host vi…
Chihen-Tai Sep 30, 2026
7cd6d66
Merge stablyai/orca main into feat/explorer-host-mode
Chihen-Tai Sep 30, 2026
976e0e2
refactor(explorer): trim Host mode code and tests
Chihen-Tai Sep 30, 2026
0230ee9
Merge origin/main into feat/explorer-host-mode
Chihen-Tai Oct 3, 2026
b2bfb20
fix(explorer): hold the Host mode loading spinner for a minimum time
Chihen-Tai Oct 4, 2026
a154f12
Merge origin/main into feat/explorer-host-mode
Chihen-Tai Oct 5, 2026
3794745
Merge origin/main into feat/explorer-host-mode
Chihen-Tai Oct 8, 2026
4d9e126
Merge origin/main into feat/explorer-host-mode
Chihen-Tai Oct 18, 2026
b52448c
Merge remote-tracking branch 'origin/main' into feat/explorer-host-mode
Chihen-Tai Oct 28, 2026
908204f
test(explorer): await async isPathAllowed after main merge
Chihen-Tai Oct 28, 2026
c53f2d2
fix(explorer): refuse SSH host-mode file opens until an SSH stat RPC …
Chihen-Tai Oct 28, 2026
fc08bdd
Merge remote-tracking branch 'origin/main' into feat/explorer-host-mode
Chihen-Tai Oct 30, 2026
7aa6a08
Merge origin/main (4ec21a86df) into feat/explorer-host-mode
Chihen-Tai Nov 8, 2026
5367583
test(file-explorer): toggle Host mode through the toolbar in the over…
Chihen-Tai Nov 8, 2026
4ed03c1
fix(file-explorer): keep Host mode React Compiler compatible
Chihen-Tai Nov 8, 2026
f8580a1
fix(remote-file-browser): keep breadcrumb memoization at the main bas…
Chihen-Tai Nov 8, 2026
c6d3903
fix(file-explorer): return to Project when Contents is chosen in Host…
Chihen-Tai Nov 8, 2026
a6181dd
test(file-explorer): drive the Host overlay key guard through the hook
Chihen-Tai Nov 8, 2026
a734247
test(file-explorer): drop Host checks that cannot fail
Chihen-Tai Nov 8, 2026
c36a8b2
test(host-browse): keep a workspace symlink that leaves the workspace…
Chihen-Tai Nov 8, 2026
83b1d8b
Merge origin/main (98b618b17b) into feat/explorer-host-mode
Chihen-Tai Nov 20, 2026
d7a49de
feat(explorer): browse runtime-owned hosts in Host mode
Chihen-Tai Nov 20, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main/ipc/filesystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { registerFilesystemGitRemoteHandlers } from './filesystem/filesystem-git
import { registerFilesystemGitDiffHandlers } from './filesystem/filesystem-git-diff-handlers'
import { registerFilesystemGitIndexHandlers } from './filesystem/filesystem-git-index-handlers'
import { registerFilesystemGitUrlHandlers } from './filesystem/filesystem-git-url-handlers'
import { registerFilesystemHostBrowseHandlers } from './filesystem/filesystem-host-browse-handlers'

export function registerFilesystemHandlers(
store: Store,
Expand All @@ -44,5 +45,6 @@ export function registerFilesystemHandlers(
registerFilesystemGitDiffHandlers(context)
registerFilesystemGitIndexHandlers(context)
registerFilesystemGitUrlHandlers(context)
registerFilesystemHostBrowseHandlers()
registerLocalLogTailHandlers(store)
}
162 changes: 162 additions & 0 deletions src/main/ipc/filesystem/filesystem-host-browse-handlers.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
import { mkdir, mkdtemp, realpath, rm, symlink, writeFile } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import type { Store } from '../../persistence'
import { isPathAllowed, resolveAuthorizedPath } from '../filesystem-auth'
import { browseHostDirectory, resolveHostBrowseEntry } from './filesystem-host-browse-handlers'

const { requireSshFilesystemProviderMock } = vi.hoisted(() => ({
requireSshFilesystemProviderMock: vi.fn()
}))

vi.mock('../../providers/ssh-filesystem-dispatch', () => ({
requireSshFilesystemProvider: requireSshFilesystemProviderMock
}))

// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: allowed-root lookups read only these four accessors.
const store = {
getRepos: () => [],
getProjectGroups: () => [],
getFolderWorkspaces: () => [],
getSettings: () => ({})
} as unknown as Store

describe('host browse handlers', () => {
let root: string

beforeEach(async () => {
root = await realpath(await mkdtemp(join(tmpdir(), 'orca-host-browse-')))
await mkdir(join(root, 'outside', 'nested'), { recursive: true })
await writeFile(join(root, 'outside', 'notes.txt'), 'hi')
requireSshFilesystemProviderMock.mockReset()
})

afterEach(async () => {
await rm(root, { recursive: true, force: true })
})

it('lists a directory outside allowed roots without granting access to it', async () => {
const outside = join(root, 'outside')
const listing = await browseHostDirectory(outside)

expect(listing.resolvedPath).toBe(outside)
expect(listing.entries.map((entry) => entry.name).sort()).toEqual(['nested', 'notes.txt'])
expect(isPathAllowed(outside, store)).toBe(false)
expect(isPathAllowed(join(outside, 'nested', 'x'), store)).toBe(false)
await expect(resolveAuthorizedPath(join(outside, 'nested'), store)).rejects.toThrow(
/Access denied/
)
})

it('grants a regular file only, never its parent directory', async () => {
const file = join(root, 'outside', 'notes.txt')
const resolution = await resolveHostBrowseEntry(file)

expect(resolution).toEqual({ kind: 'file', realPath: file, workspaceRelativePath: null })
expect(isPathAllowed(file, store)).toBe(true)
expect(isPathAllowed(join(root, 'outside'), store)).toBe(false)
expect(isPathAllowed(join(root, 'outside', 'nested'), store)).toBe(false)
})

it('classifies a symlink to a directory as a directory and grants nothing', async () => {
const target = join(root, 'outside', 'nested')
const link = join(root, 'dir-link')
await symlink(target, link, 'dir')

const resolution = await resolveHostBrowseEntry(link)

expect(resolution).toEqual({ kind: 'directory', realPath: target, workspaceRelativePath: null })
expect(isPathAllowed(join(target, 'anything'), store)).toBe(false)
expect(isPathAllowed(join(link, 'anything'), store)).toBe(false)
})

it('reports the canonical path of a symlinked file for worktree ownership checks', async () => {
const target = join(root, 'outside', 'notes.txt')
const link = join(root, 'file-link')
await symlink(target, link, 'file')

await expect(resolveHostBrowseEntry(link)).resolves.toEqual({
kind: 'file',
realPath: target,
workspaceRelativePath: null
})
})

it('rejects relative and null-byte paths', async () => {
await expect(resolveHostBrowseEntry('outside/notes.txt')).rejects.toThrow(/absolute/)
await expect(resolveHostBrowseEntry(`${root}\0x`)).rejects.toThrow(/null bytes/)
})

it('classifies SSH entries through the provider realpath without local grants', async () => {
const provider = {
realpath: vi.fn(async (path: string) =>
path === '/home/allen/link' ? '/home/allen/codes/repo/src' : path
),
stat: vi.fn().mockResolvedValue({ type: 'directory', size: 0, mtime: 0 })
}
requireSshFilesystemProviderMock.mockReturnValue(provider)

await expect(
resolveHostBrowseEntry('/home/allen/link', 'ssh-1', '/home/allen/codes/repo')
).resolves.toEqual({
kind: 'directory',
realPath: '/home/allen/codes/repo/src',
workspaceRelativePath: 'src'
})
expect(requireSshFilesystemProviderMock).toHaveBeenCalledWith('ssh-1')
expect(provider.stat).toHaveBeenCalledWith('/home/allen/codes/repo/src')
expect(provider.realpath).toHaveBeenCalledWith('/home/allen/codes/repo')
expect(isPathAllowed('/home/allen/link', store)).toBe(false)
})

it('maps SSH file stats to file and anything else to unsupported', async () => {
const provider = {
realpath: vi.fn().mockImplementation(async (path: string) => path),
stat: vi
.fn()
.mockResolvedValueOnce({ type: 'file', size: 1, mtime: 0 })
.mockResolvedValueOnce({ type: 'symlink', size: 1, mtime: 0 })
}
requireSshFilesystemProviderMock.mockReturnValue(provider)

await expect(resolveHostBrowseEntry('/etc/hosts', 'ssh-1')).resolves.toEqual({
kind: 'file',
realPath: '/etc/hosts',
workspaceRelativePath: null
})
await expect(resolveHostBrowseEntry('/dev/weird', 'ssh-1')).resolves.toEqual({
kind: 'unsupported',
realPath: '/dev/weird',
workspaceRelativePath: null
})
})

it('resolves workspace ownership against the canonical workspace root', async () => {
const realWorkspace = join(root, 'real-workspace')
await mkdir(join(realWorkspace, 'src'), { recursive: true })
await writeFile(join(realWorkspace, 'src', 'a.ts'), 'x')
const workspaceAlias = join(root, 'workspace-alias')
await symlink(realWorkspace, workspaceAlias, 'dir')
const outsideLink = join(root, 'outside', 'a-link.ts')
await symlink(join(realWorkspace, 'src', 'a.ts'), outsideLink, 'file')

const resolution = await resolveHostBrowseEntry(outsideLink, undefined, workspaceAlias)

expect(resolution).toEqual({
kind: 'file',
realPath: join(realWorkspace, 'src', 'a.ts'),
workspaceRelativePath: 'src/a.ts'
})
// Why: workspace files are reached through allowed roots; no external grant is added.
expect(isPathAllowed(outsideLink, store)).toBe(false)
})

it('rejects null-byte SSH paths before they reach the relay', async () => {
const provider = { realpath: vi.fn(), stat: vi.fn() }
requireSshFilesystemProviderMock.mockReturnValue(provider)

await expect(resolveHostBrowseEntry('/home/allen\0x', 'ssh-1')).rejects.toThrow(/null bytes/)
expect(provider.realpath).not.toHaveBeenCalled()
})
})
91 changes: 91 additions & 0 deletions src/main/ipc/filesystem/filesystem-host-browse-handlers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import { ipcMain } from 'electron'
import { realpath, stat } from 'node:fs/promises'
import { isAbsolute } from 'node:path'
import { relativePathInsideRoot } from '../../../shared/cross-platform-path'
import type {
HostBrowseEntryResolution,
HostDirectoryListing
} from '../../../shared/filesystem-entry-types'
import { browseServerDirectory } from '../../runtime/runtime-server-environment-commands'
import { requireSshFilesystemProvider } from '../../providers/ssh-filesystem-dispatch'
import { authorizeExternalPath } from '../filesystem-auth'

// Why: names-only listing never touches the external-path allowlist, so browsing
// outside the workspace grants nothing to later read/write/delete handlers.
export function browseHostDirectory(dirPath: string): Promise<HostDirectoryListing> {
return browseServerDirectory(dirPath)
}

async function canonicalRelativePath(
realPath: string,
workspaceRoot: string | undefined,
canonicalize: (path: string) => Promise<string>
): Promise<string | null> {
if (!workspaceRoot) {
return null
}
try {
return relativePathInsideRoot(await canonicalize(workspaceRoot), realPath)
} catch {
return null
}
}

export async function resolveHostBrowseEntry(
targetPath: string,
connectionId?: string,
workspaceRoot?: string
): Promise<HostBrowseEntryResolution> {
if (targetPath.includes('\0')) {
throw new Error('Path cannot contain null bytes')
}
if (connectionId) {
// Why: the relay has no FS allowlist (relay/context.ts), so SSH only classifies.
const provider = requireSshFilesystemProvider(connectionId)
const realPath = await provider.realpath(targetPath)
const target = await provider.stat(realPath)
return {
kind:
target.type === 'directory' ? 'directory' : target.type === 'file' ? 'file' : 'unsupported',
realPath,
workspaceRelativePath: await canonicalRelativePath(realPath, workspaceRoot, (path) =>
provider.realpath(path)
)
}
}
if (!isAbsolute(targetPath)) {
throw new Error('Host browse path must be absolute')
}
const realPath = await realpath(targetPath)
const target = await stat(realPath)
const workspaceRelativePath = await canonicalRelativePath(realPath, workspaceRoot, realpath)
if (target.isDirectory()) {
return { kind: 'directory', realPath, workspaceRelativePath }
}
if (!target.isFile()) {
return { kind: 'unsupported', realPath, workspaceRelativePath }
}
// Why: workspace files are already allowed; granting them would only crowd the LRU.
if (workspaceRelativePath === null) {
// Why: a rename between stat and grant is accepted; winning it needs local write
// access that the grant would not add.
authorizeExternalPath(targetPath)
}
return { kind: 'file', realPath, workspaceRelativePath }
}

export function registerFilesystemHostBrowseHandlers(): void {
ipcMain.handle(
'fs:browseHostDir',
(_event, args: { dirPath: string }): Promise<HostDirectoryListing> =>
browseHostDirectory(args.dirPath)
)
ipcMain.handle(
'fs:resolveHostBrowseEntry',
(
_event,
args: { targetPath: string; connectionId?: string; workspaceRoot?: string }
): Promise<HostBrowseEntryResolution> =>
resolveHostBrowseEntry(args.targetPath, args.connectionId, args.workspaceRoot)
)
}
56 changes: 28 additions & 28 deletions src/main/runtime/runtime-server-environment-commands.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { readdir, stat } from 'node:fs/promises'
import { homedir } from 'node:os'
import { isAbsolute, resolve } from 'node:path'
import type { DirEntry, FilesystemPathFlavor } from '../../shared/filesystem-entry-types'
import type { HostDirectoryListing } from '../../shared/filesystem-entry-types'
import { sortDirEntries } from '../../shared/file-name-sort'
import { probeGitAvailability } from '../git/git-availability'
import { gitExecFileAsync } from '../git/runner'
Expand All @@ -24,34 +24,34 @@ function resolveServerBrowsePath(pathValue: string): string {
return resolve(homedir(), trimmed)
}

export async function browseServerDirectory(pathValue: string): Promise<HostDirectoryListing> {
if (isServerDriveListRequest(pathValue)) {
return listWindowsDrives()
}
const dirPath = resolveServerBrowsePath(pathValue)
const dirStat = await stat(dirPath)
if (!dirStat.isDirectory()) {
throw new Error(`${dirPath} is not a directory`)
}
const entries = await readdir(dirPath, { withFileTypes: true })
const mapped = entries
.filter((entry) => entry.name !== '.' && entry.name !== '..')
.map((entry) => ({
name: entry.name,
isDirectory: entry.isDirectory(),
isSymlink: entry.isSymbolicLink()
}))
sortDirEntries(mapped)
return {
resolvedPath: dirPath,
entries: mapped,
pathFlavor: process.platform === 'win32' ? 'win32' : 'posix'
}
}

export class RuntimeServerEnvironmentCommands {
async browseDirectory(pathValue: string): Promise<{
resolvedPath: string
entries: DirEntry[]
pathFlavor: FilesystemPathFlavor
}> {
if (isServerDriveListRequest(pathValue)) {
return listWindowsDrives()
}
const dirPath = resolveServerBrowsePath(pathValue)
const dirStat = await stat(dirPath)
if (!dirStat.isDirectory()) {
throw new Error(`${dirPath} is not a directory`)
}
const entries = await readdir(dirPath, { withFileTypes: true })
const mapped = entries
.filter((entry) => entry.name !== '.' && entry.name !== '..')
.map((entry) => ({
name: entry.name,
isDirectory: entry.isDirectory(),
isSymlink: entry.isSymbolicLink()
}))
sortDirEntries(mapped)
return {
resolvedPath: dirPath,
entries: mapped,
pathFlavor: process.platform === 'win32' ? 'win32' : 'posix'
}
async browseDirectory(pathValue: string): Promise<HostDirectoryListing> {
return browseServerDirectory(pathValue)
}

async isGitAvailable(): Promise<boolean> {
Expand Down
10 changes: 10 additions & 0 deletions src/preload/api/filesystem-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import type { SearchOptions, SearchResult } from '../../shared/code-search-types
import type {
DirEntry,
FsChangedPayload,
HostBrowseEntryResolution,
HostDirectoryListing,
MarkdownDocument
} from '../../shared/filesystem-entry-types'
import type {
Expand Down Expand Up @@ -121,6 +123,14 @@ export type FilesystemApi = {
} & SshMutationExpectation
) => Promise<void>
authorizeExternalPath: (args: { targetPath: string }) => Promise<void>
/** Desktop-only names listing for the Explorer's Host mode; never widens path grants. */
browseHostDir?: (args: { dirPath: string }) => Promise<HostDirectoryListing>
/** Desktop-only; grants a local read only when the target resolves to a regular file. */
resolveHostBrowseEntry?: (args: {
targetPath: string
connectionId?: string
workspaceRoot?: string
}) => Promise<HostBrowseEntryResolution>
stat: (args: {
filePath: string
connectionId?: string
Expand Down
13 changes: 12 additions & 1 deletion src/preload/api/fs-bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import { ipcRenderer } from 'electron'
import type { SshMutationExpectation } from '../../shared/ssh-types'
import type { RuntimeUploadFileStreamRequest } from '../../shared/runtime-upload-staging-contract'
import type { SearchResult } from '../../shared/code-search-types'
import type { FsChangedPayload } from '../../shared/filesystem-entry-types'
import type {
FsChangedPayload,
HostBrowseEntryResolution,
HostDirectoryListing
} from '../../shared/filesystem-entry-types'
import type {
ImportItemResult,
ResolveDroppedPathsResult,
Expand Down Expand Up @@ -118,6 +122,13 @@ export const fsApi = {
): Promise<void> => ipcRenderer.invoke('fs:deletePath', args),
authorizeExternalPath: (args: { targetPath: string }): Promise<void> =>
ipcRenderer.invoke('fs:authorizeExternalPath', args),
browseHostDir: (args: { dirPath: string }): Promise<HostDirectoryListing> =>
ipcRenderer.invoke('fs:browseHostDir', args),
resolveHostBrowseEntry: (args: {
targetPath: string
connectionId?: string
workspaceRoot?: string
}): Promise<HostBrowseEntryResolution> => ipcRenderer.invoke('fs:resolveHostBrowseEntry', args),
stat: (args: {
filePath: string
connectionId?: string
Expand Down
Loading