Skip to content

Open the focused file surface in a terminal editor - #10039

Closed
v-raykov wants to merge 1 commit into
manaflow-ai:mainfrom
v-raykov:feat/preview-open-in-terminal-editor
Closed

Open the focused file surface in a terminal editor#10039
v-raykov wants to merge 1 commit into
manaflow-ai:mainfrom
v-raykov:feat/preview-open-in-terminal-editor

Conversation

@v-raykov

@v-raykov v-raykov commented Aug 12, 2026

Copy link
Copy Markdown

File preview and markdown surfaces get an "Open in Terminal Editor" header button and a Cmd+Ctrl+E shortcut that hands the file to $VISUAL/$EDITOR (falling back to vi) in a cmux terminal surface, so a TUI editor gets the PTY it needs. A GUI app process has none of the user's shell configuration, so the editor is resolved by an interactive shell once in the background and cached; opens then launch the absolute path with no shell in between, carrying the shell's PATH so the editor still finds the tools it spawns.

The editor surface opens beside the file surface and closes when the editor exits, which needs a new command-exit policy: startup commands otherwise hold the PTY open so a failed remote command stays readable. That default is unchanged and pinned by a test. The file surface stays open, both so quitting the editor returns to it and because a child exit on a workspace's last panel collapses the workspace.

Placement is configurable through fileEditor.terminalEditorPlacement. Dock-hosted previews hide the action, since the Dock owns no terminal-capable surface tree.

Summary

  • What changed?
  • Why?

Testing

  • How did you test this change?
  • What did you verify manually?

Demo Video

For UI or behavior changes, include a short demo video (GitHub upload, Loom, or other direct link).

  • Video URL or attachment:

Review Trigger (Copy/Paste as PR comment)

@codex review
@coderabbitai review
@greptile-apps review
@cubic-dev-ai review

Checklist

  • I tested the change locally
  • I added or updated tests for behavior changes
  • I updated docs/changelog if needed
  • I requested bot reviews after my latest commit (copy/paste block above or equivalent)
  • All code review bot comments are resolved
  • All human review comments are resolved

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Summary by cubic

Add “Open in Terminal Editor” for file preview and markdown surfaces. Press Cmd+Ctrl+E or click the header button to open the file in $VISUAL/$EDITOR (fallback vi) in a terminal; the editor tab closes on exit and the file tab stays open.

  • New Features
    • Header button and Cmd+Ctrl+E on file preview and markdown surfaces.
    • Editor is resolved once via an interactive login shell and cached as ResolvedTerminalEditor; subsequent opens launch the absolute path and carry the shell’s PATH (no shell startup).
    • New TerminalSurfaceCommandExitPolicy with closeOnExit used for the editor; the default “wait after command” behavior for other startup commands is unchanged.
    • Placement is configurable via fileEditor.terminalEditorPlacement (afterSource default, or endOfTabStrip). Dock-hosted previews hide the action.

Written for commit 82e0bd1. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • New Features
    • Open files and Markdown documents in your preferred terminal editor from preview panels.
    • Added the Ctrl+Cmd+E shortcut and Dock shortcut support.
    • Automatically detects $VISUAL or $EDITOR, with vi as a fallback.
    • Choose whether opened terminal editors appear after the source or at the end of the tab strip.
  • Bug Fixes
    • Added save confirmation before opening unsaved files.
    • Improved startup-command exit behavior to preserve configured terminal settings.

File preview and markdown surfaces get an "Open in Terminal Editor"
header button and a Cmd+Ctrl+E shortcut that hands the file to
$VISUAL/$EDITOR (falling back to vi) in a cmux terminal surface, so a
TUI editor gets the PTY it needs. A GUI app process has none of the
user's shell configuration, so the editor is resolved by an interactive
shell once in the background and cached; opens then launch the absolute
path with no shell in between, carrying the shell's PATH so the editor
still finds the tools it spawns.

The editor surface opens beside the file surface and closes when the
editor exits, which needs a new command-exit policy: startup commands
otherwise hold the PTY open so a failed remote command stays readable.
That default is unchanged and pinned by a test. The file surface stays
open, both so quitting the editor returns to it and because a child exit
on a workspace's last panel collapses the workspace.

Placement is configurable through fileEditor.terminalEditorPlacement.
Dock-hosted previews hide the action, since the Dock owns no
terminal-capable surface tree.

Co-authored-by: Cursor <cursoragent@cursor.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@v-raykov v-raykov closed this Aug 12, 2026
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: efb23b3d-085e-4bd7-b320-0f44b041c42d

📥 Commits

Reviewing files that changed from the base of the PR and between b17c260 and 82e0bd1.

📒 Files selected for processing (27)
  • Packages/macOS/CmuxSettings/Sources/CmuxSettings/Values/ShortcutAction+Defaults.swift
  • Packages/macOS/CmuxSettings/Sources/CmuxSettings/Values/ShortcutAction+DisplayName.swift
  • Packages/macOS/CmuxSettings/Sources/CmuxSettings/Values/ShortcutAction+Group.swift
  • Packages/macOS/CmuxSettings/Sources/CmuxSettings/Values/ShortcutAction.swift
  • Packages/macOS/CmuxTerminalCore/Sources/CmuxTerminalCore/SurfaceValues/TerminalSurfaceCommandExitPolicy.swift
  • Packages/macOS/CmuxTerminalCore/Tests/CmuxTerminalCoreTests/TerminalSurfaceCommandExitPolicyTests.swift
  • Packages/macOS/CmuxWorkspaces/Sources/CmuxWorkspaces/FileOpen/ResolvedTerminalEditor.swift
  • Packages/macOS/CmuxWorkspaces/Sources/CmuxWorkspaces/FileOpen/TerminalEditorCommand.swift
  • Packages/macOS/CmuxWorkspaces/Tests/CmuxWorkspacesTests/FileOpen/TerminalEditorCommandTests.swift
  • Packages/macOS/CmuxWorkspaces/Tests/CmuxWorkspacesTests/FileOpen/TerminalEditorProbeTests.swift
  • Sources/AppDelegate+DockShortcutRouting.swift
  • Sources/AppDelegate.swift
  • Sources/CmuxSettingsJSONPathSupport.swift
  • Sources/KeyboardShortcutContext.swift
  • Sources/KeyboardShortcutSettings.swift
  • Sources/KeyboardShortcutSettingsFileStore+SectionParsers.swift
  • Sources/KeyboardShortcutSettingsFileStore+Template.swift
  • Sources/Panels/FilePreviewPanel.swift
  • Sources/Panels/FilePreviewTabMetadata.swift
  • Sources/Panels/FilePreviewWorkspaceOpenSupport.swift
  • Sources/Panels/MarkdownPanel.swift
  • Sources/Panels/MarkdownPanelView.swift
  • Sources/Workspace.swift
  • Sources/WorkspaceInitialCommandLoginShell.swift
  • cmuxTests/WorkspaceSplitStartupCommandTests.swift
  • web/data/cmux.schema.json
  • web/messages/en.json

📝 Walkthrough

Walkthrough

The pull request adds terminal-editor support for file-preview and Markdown panels. It resolves shell editors, launches terminal surfaces with configurable placement and exit behavior, adds save-before-open handling, and wires the feature to toolbar buttons and Ctrl+Cmd+E.

Changes

Terminal editor integration

Layer / File(s) Summary
Editor resolution and command construction
Packages/macOS/CmuxWorkspaces/Sources/CmuxWorkspaces/FileOpen/*, Packages/macOS/CmuxWorkspaces/Tests/CmuxWorkspacesTests/FileOpen/*, Sources/WorkspaceInitialCommandLoginShell.swift
Resolves $VISUAL or $EDITOR, validates executable data, supports Fish and POSIX shells, quotes paths, and provides a vi fallback.
Surface launch and placement
Packages/macOS/CmuxTerminalCore/..., Sources/Panels/FilePreviewWorkspaceOpenSupport.swift, Sources/Workspace.swift, Sources/KeyboardShortcutSettingsFileStore+*
Creates terminal surfaces with configurable exit policies, preserves shell environment, caches editor resolution, and supports afterSource or endOfTabStrip placement.
Panel handoff and save flow
Sources/Panels/FilePreview*, Sources/Panels/Markdown*, Sources/Workspace.swift, cmuxTests/WorkspaceSplitStartupCommandTests.swift
Adds terminal-editor hosts and toolbar actions. Dirty files require confirmation and asynchronous saving before opening.
Shortcut routing and configuration
Packages/macOS/CmuxSettings/..., Sources/AppDelegate*, Sources/KeyboardShortcut*, web/data/cmux.schema.json, web/messages/en.json
Adds the terminal-editor shortcut with default Ctrl+Cmd+E, Dock routing, event-panel resolution, startup refresh, and placement configuration support.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Panel
  participant TerminalEditorResolutionStore
  participant Workspace
  participant TerminalPanel
  Panel->>TerminalEditorResolutionStore: Resolve terminal editor
  Panel->>Workspace: Open selected file
  Workspace->>TerminalPanel: Create terminal surface
  Workspace->>TerminalPanel: Run editor command with PATH
Loading

Possibly related PRs

Suggested reviewers: azooz2003-bit, austinywang

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Warning

⚠️ This pull request shows signs of AI-generated slop (ai_padded_prose). It has been flagged by CodeRabbit slop detection and should be reviewed carefully.

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.

1 participant