Repository navigation
[codex] Add file explorer open in terminal - #7029
Conversation
|
Ready to review this PR? Stage has broken it down into 6 individual chapters for you: Chapters generated by Stage for commit 9827b2c on Jul 1, 2026 5:39pm UTC. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (12)
💤 Files with no reviewable changes (6)
🚧 Files skipped from review as they are similar to previous changes (5)
📝 WalkthroughWalkthroughThis change adds optional 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
5976da9 to
08df405
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/renderer/src/runtime/web-runtime-session.ts (1)
74-91: 🔒 Security & Privacy | 🟡 Minor | ⚡ Quick winClamp
cwdto the selected worktree before launching the terminal.CreateTerminalTab.cwdis forwarded unchanged all the way topty.spawn, so a paired client can start the shell outside the target worktree.
🧹 Nitpick comments (2)
src/shared/workspace-session-schema.ts (1)
81-81: 🗄️ Data Integrity & Integration | 🔵 Trivial | 💤 Low valueConsider matching the
.min(1)constraint used forcwdat the RPC layer.
startupCwdhere accepts empty strings, whilesession-tabs-schemas.ts'scwdfield requires non-empty. Store writes always omit empty values, but this leaves the persisted-schema layer more permissive than necessary for consistency.♻️ Proposed fix
- startupCwd: z.string().optional(), + startupCwd: z.string().min(1).optional(),src/main/runtime/orca-runtime.ts (1)
3831-3834: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winPositional-argument fragility in
createHeadlessMobileSessionTerminal.The new
cwdparameter was inserted mid-signature (position 5 of 11), and all three call sites use long lists of positionalundefinedplaceholders to reach later params (identity,launchAgent,targetGroupId,launchConfig). This diff appears correctly threaded at all three call sites, but this pattern makes any future parameter insertion/reorder a silent-miscount risk (a wrong argument count wouldn't always be caught by TypeScript if adjacent optional params share compatible types).Consider converting this private method's trailing optional params into a single options object so future additions can't silently shift positions.
♻️ Suggested direction
- private async createHeadlessMobileSessionTerminal( - worktreeId: string, - activate: boolean, - afterTabId?: string, - command?: string, - cwd?: string, - env?: Record<string, string>, - startupCommandDelivery?: WorktreeStartupLaunch['startupCommandDelivery'], - identity?: { tabId: string; leafId: string; sessionId?: string }, - launchAgent?: TuiAgent, - targetGroupId?: string, - launchConfig?: SleepingAgentLaunchConfig - ): Promise<RuntimeMobileSessionCreateTerminalResult> { + private async createHeadlessMobileSessionTerminal( + worktreeId: string, + activate: boolean, + afterTabId: string | undefined, + opts: { + command?: string + cwd?: string + env?: Record<string, string> + startupCommandDelivery?: WorktreeStartupLaunch['startupCommandDelivery'] + identity?: { tabId: string; leafId: string; sessionId?: string } + launchAgent?: TuiAgent + targetGroupId?: string + launchConfig?: SleepingAgentLaunchConfig + } = {} + ): Promise<RuntimeMobileSessionCreateTerminalResult> {Also applies to: 15693-15716
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 193a8e9b-15d3-4ad0-81c8-59b36768365c
📥 Commits
Reviewing files that changed from the base of the PR and between 021cfc4 and 08df4053c08206c616ecab10b21e0b9fa3343197.
📒 Files selected for processing (33)
src/main/runtime/orca-runtime.tssrc/main/runtime/rpc/methods/session-tabs-schemas.tssrc/main/runtime/rpc/methods/session-tabs.test.tssrc/main/runtime/rpc/methods/session-tabs.tssrc/main/window/attach-main-window-services.tssrc/preload/api-types.tssrc/preload/index.tssrc/renderer/src/components/Terminal.tsxsrc/renderer/src/components/right-sidebar/FileExplorer.test.tsxsrc/renderer/src/components/right-sidebar/FileExplorer.tsxsrc/renderer/src/components/right-sidebar/FileExplorerRow.tsxsrc/renderer/src/components/right-sidebar/FileExplorerVirtualRows.tsxsrc/renderer/src/components/right-sidebar/FileExplorerVirtualRowsAddProject.test.tsxsrc/renderer/src/components/right-sidebar/file-explorer-drag-scroll-marker.test.tsxsrc/renderer/src/components/tab-group/useTabGroupWorkspaceModel.tssrc/renderer/src/components/terminal-pane/TerminalPaneOverlayLayer.tsxsrc/renderer/src/components/terminal/terminal-tab-actions.test.tssrc/renderer/src/components/terminal/terminal-tab-actions.tssrc/renderer/src/hooks/useIpcEvents.test.tssrc/renderer/src/hooks/useIpcEvents.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/renderer/src/runtime/web-runtime-session.test.tssrc/renderer/src/runtime/web-runtime-session.tssrc/renderer/src/store/slices/store-cascades.test.tssrc/renderer/src/store/slices/terminals.tssrc/shared/runtime-types.tssrc/shared/types.tssrc/shared/workspace-session-schema.tssrc/shared/workspace-session-terminal-schema.test.ts
08df405 to
9827b2c
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 27861500-95f5-4143-8e04-ae94e3c0a558
📥 Commits
Reviewing files that changed from the base of the PR and between 08df4053c08206c616ecab10b21e0b9fa3343197 and 9827b2c.
📒 Files selected for processing (36)
src/main/runtime/orca-runtime-terminal-cwd.test.tssrc/main/runtime/orca-runtime.tssrc/main/runtime/rpc/methods/session-tabs-schemas.tssrc/main/runtime/rpc/methods/session-tabs.test.tssrc/main/runtime/rpc/methods/session-tabs.tssrc/main/window/attach-main-window-services.tssrc/preload/api-types.tssrc/preload/index.tssrc/renderer/src/components/Terminal.tsxsrc/renderer/src/components/right-sidebar/FileExplorer.test.tsxsrc/renderer/src/components/right-sidebar/FileExplorer.tsxsrc/renderer/src/components/right-sidebar/FileExplorerRow.tsxsrc/renderer/src/components/right-sidebar/FileExplorerVirtualRows.tsxsrc/renderer/src/components/right-sidebar/FileExplorerVirtualRowsAddProject.test.tsxsrc/renderer/src/components/right-sidebar/file-explorer-drag-scroll-marker.test.tsxsrc/renderer/src/components/tab-group/useTabGroupWorkspaceModel.tssrc/renderer/src/components/terminal-pane/TerminalPaneOverlayLayer.tsxsrc/renderer/src/components/terminal/terminal-tab-actions.test.tssrc/renderer/src/components/terminal/terminal-tab-actions.tssrc/renderer/src/hooks/useIpcEvents.test.tssrc/renderer/src/hooks/useIpcEvents.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/renderer/src/runtime/web-runtime-session.test.tssrc/renderer/src/runtime/web-runtime-session.tssrc/renderer/src/store/slices/store-cascades.test.tssrc/renderer/src/store/slices/terminals.tssrc/shared/runtime-types.tssrc/shared/terminal-startup-cwd.test.tssrc/shared/terminal-startup-cwd.tssrc/shared/types.tssrc/shared/workspace-session-schema.tssrc/shared/workspace-session-terminal-schema.test.ts
✅ Files skipped from review due to trivial changes (7)
- src/main/runtime/rpc/methods/session-tabs.ts
- src/renderer/src/runtime/web-runtime-session.test.ts
- src/renderer/src/components/right-sidebar/file-explorer-drag-scroll-marker.test.tsx
- src/renderer/src/i18n/locales/ko.json
- src/renderer/src/i18n/locales/en.json
- src/main/runtime/rpc/methods/session-tabs.test.ts
- src/renderer/src/i18n/locales/zh.json
🚧 Files skipped from review as they are similar to previous changes (26)
- src/main/runtime/rpc/methods/session-tabs-schemas.ts
- src/shared/runtime-types.ts
- src/shared/types.ts
- src/renderer/src/components/Terminal.tsx
- src/preload/index.ts
- src/renderer/src/components/right-sidebar/FileExplorerVirtualRowsAddProject.test.tsx
- src/renderer/src/components/right-sidebar/FileExplorerVirtualRows.tsx
- src/shared/workspace-session-terminal-schema.test.ts
- src/renderer/src/components/tab-group/useTabGroupWorkspaceModel.ts
- src/renderer/src/i18n/locales/ja.json
- src/shared/workspace-session-schema.ts
- src/renderer/src/runtime/web-runtime-session.ts
- src/renderer/src/components/terminal/terminal-tab-actions.test.ts
- src/renderer/src/components/terminal/terminal-tab-actions.ts
- src/renderer/src/i18n/locales/es.json
- src/renderer/src/components/right-sidebar/FileExplorer.test.tsx
- src/renderer/src/components/terminal-pane/TerminalPaneOverlayLayer.tsx
- src/renderer/src/components/right-sidebar/FileExplorer.tsx
- src/preload/api-types.ts
- src/renderer/src/hooks/useIpcEvents.test.ts
- src/renderer/src/hooks/useIpcEvents.ts
- src/main/window/attach-main-window-services.ts
- src/renderer/src/components/right-sidebar/FileExplorerRow.tsx
- src/renderer/src/store/slices/terminals.ts
- src/renderer/src/store/slices/store-cascades.test.ts
- src/main/runtime/orca-runtime.ts
| if (!requestedCwd || requestedCwd.trim().length === 0) { | ||
| return undefined | ||
| } | ||
| const resolvedCwd = resolveRuntimePath(worktreePath, requestedCwd) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Untrimmed requestedCwd passed to resolveRuntimePath.
requestedCwd.trim() is only used for the emptiness check; the raw (potentially whitespace-padded) value is then passed to resolveRuntimePath. A value like "packages/web " would resolve to a cwd with trailing whitespace, likely causing an ENOENT at pty spawn time instead of being sanitized upfront.
🩹 Proposed fix
if (!requestedCwd || requestedCwd.trim().length === 0) {
return undefined
}
- const resolvedCwd = resolveRuntimePath(worktreePath, requestedCwd)
+ const resolvedCwd = resolveRuntimePath(worktreePath, requestedCwd.trim())📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if (!requestedCwd || requestedCwd.trim().length === 0) { | |
| return undefined | |
| } | |
| const resolvedCwd = resolveRuntimePath(worktreePath, requestedCwd) | |
| if (!requestedCwd || requestedCwd.trim().length === 0) { | |
| return undefined | |
| } | |
| const resolvedCwd = resolveRuntimePath(worktreePath, requestedCwd.trim()) |
| if (!isPathInsideOrEqual(worktreePath, resolvedCwd)) { | ||
| // Why: remote/session clients can request terminal cwd; never let that | ||
| // become a shell outside the selected workspace. | ||
| throw new Error('Terminal cwd must be inside the selected worktree.') | ||
| } |
There was a problem hiding this comment.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check whether cross-platform-path.ts performs any realpath/symlink resolution
rg -n -A5 -B5 'realpath|lstat|fs\.' src/shared/cross-platform-path.tsRepository: stablyai/orca
Length of output: 151
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n== Files ==\n'
git ls-files 'src/shared/*path*' 'src/shared/terminal-startup-cwd.ts'
printf '\n== Outline: src/shared/cross-platform-path.ts ==\n'
ast-grep outline src/shared/cross-platform-path.ts --view expanded || true
printf '\n== Outline: src/shared/terminal-startup-cwd.ts ==\n'
ast-grep outline src/shared/terminal-startup-cwd.ts --view expanded || true
printf '\n== Read relevant sections ==\n'
sed -n '1,220p' src/shared/cross-platform-path.ts
printf '\n---\n'
sed -n '1,120p' src/shared/terminal-startup-cwd.tsRepository: stablyai/orca
Length of output: 7260
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n== Usages of resolveTerminalStartupCwd ==\n'
rg -n "resolveTerminalStartupCwd\(" src
printf '\n== Usages of isPathInsideOrEqual / resolveRuntimePath ==\n'
rg -n "isPathInsideOrEqual\(|resolveRuntimePath\(" src
printf '\n== Worktree path origin candidates ==\n'
rg -n "worktreePath|selected worktree|selected workspace|realpath|canonical" src/shared src | head -n 200Repository: stablyai/orca
Length of output: 28665
Resolve symlink targets before the containment check. resolveRuntimePath/isPathInsideOrEqual only normalize separators and ..; they do not canonicalize symlinks, so a symlink inside the worktree can still point outside it and bypass this boundary.
Co-authored-by: Orca <[email protected]>
Jinwoo-H
left a comment
There was a problem hiding this comment.
Thanks! I made a few review fixes before landing:
- localized the new file-explorer context-menu label
- preserved and validated terminal startup cwd through main/runtime restore paths
- covered crash-safe PTY persistence and web-session mirroring edge cases
- verified the directory context-menu flow in Electron with screenshots
Validated with focused tests, typecheck, lint, and Electron UI/PTY cwd checks.
…erminal # Conflicts: # src/main/ipc/pty.ts
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/main/persistence.ts (1)
5513-5529: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
persistPtyBindingdropsstartupCwdwhen the tab record already exists.The new
elsebranch (tab doesn't exist yet) persistsstartupCwdviacreateMinimalPersistedTerminalTab, but theif (tab)branch only patchestab.ptyIdand never appliesargs.startupCwdto the existing tab. Given this function exists specifically to win the race against the renderer's debounced session writer, an existing-but-not-yet-fully-synced tab record could permanently lose the requested startup cwd if a crash happens before the debounced writer's next flush — undermining the commit's stated goal of preserving startup cwd "across restore paths."🛠️ Proposed fix
const tabs = session.tabsByWorktree?.[args.worktreeId] const tab = tabs?.find((t) => t.id === args.tabId) if (tab) { tab.ptyId = args.ptyId + if (args.startupCwd && !tab.startupCwd) { + tab.startupCwd = args.startupCwd + } } else {
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: f55e60a0-4506-4b17-811c-6ccae2d6fcf0
📒 Files selected for processing (16)
src/main/ipc/pty.test.tssrc/main/ipc/pty.tssrc/main/persistence.tssrc/main/runtime/orca-runtime-terminal-cwd.test.tssrc/main/runtime/orca-runtime.tssrc/main/window/attach-main-window-services.test.tssrc/main/window/attach-main-window-services.tssrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/renderer/src/runtime/web-session-tabs-sync.test.tssrc/renderer/src/runtime/web-session-tabs-sync.tssrc/shared/runtime-types.tssrc/shared/terminal-startup-cwd.test.tssrc/shared/terminal-startup-cwd.ts
✅ Files skipped from review due to trivial changes (3)
- src/renderer/src/i18n/locales/ko.json
- src/renderer/src/i18n/locales/ja.json
- src/renderer/src/i18n/locales/es.json
🚧 Files skipped from review as they are similar to previous changes (3)
- src/main/window/attach-main-window-services.ts
- src/renderer/src/i18n/locales/zh.json
- src/main/runtime/orca-runtime.ts
| if (!workspacePath) { | ||
| return args.requestedCwd | ||
| } |
There was a problem hiding this comment.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
Fallback silently bypasses the worktree containment check.
When workspacePath can't be resolved (e.g. workspaceId is undefined, or resolveFolderWorkspacePath returns nothing), the function returns the raw, unchecked args.requestedCwd. This defeats the entire purpose of this module — enforcing that the terminal cwd stays inside the selected worktree — for any caller where the workspace can't be resolved (e.g. pty.ts's resolveGuardedPtySpawnCwd is called with a possibly-undefined worktreeId).
🔒 Proposed fix: fail closed instead of trusting an unvalidated path
if (!workspacePath) {
- return args.requestedCwd
+ // Why: without a resolvable workspace root we cannot enforce the
+ // in-worktree containment check, so refuse the requested cwd rather
+ // than trusting an unvalidated path.
+ return undefined
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if (!workspacePath) { | |
| return args.requestedCwd | |
| } | |
| if (!workspacePath) { | |
| // Why: without a resolvable workspace root we cannot enforce the | |
| // in-worktree containment check, so refuse the requested cwd rather | |
| // than trusting an unvalidated path. | |
| return undefined | |
| } |
Summary
Open in Terminalcontext-menu action for directories in the file explorer.Closes #6271.
Demo
open-directory-terminal-dark-redacted.mp4
Validation
pnpm lintpnpm test(2054files passed,20812tests passed)pnpm buildterminal-cwd-test, selectedOpen in Terminal, and confirmed the new terminal opened in that directoryAI Code Review Summary
Notes