Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
101 changes: 33 additions & 68 deletions src/browser/components/Settings/sections/GeneralSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import {
SelectValue,
} from "@/browser/components/ui/select";
import { Input } from "@/browser/components/ui/input";
import { Checkbox } from "@/browser/components/ui/checkbox";
import { Tooltip, TooltipTrigger, TooltipContent } from "@/browser/components/ui/tooltip";
import { usePersistedState } from "@/browser/hooks/usePersistedState";
import {
EDITOR_CONFIG_KEY,
Expand Down Expand Up @@ -40,13 +38,6 @@ export function GeneralSection() {
setEditorConfig((prev) => ({ ...prev, customCommand }));
};

const handleRemoteExtensionChange = (useRemoteExtension: boolean) => {
setEditorConfig((prev) => ({ ...prev, useRemoteExtension }));
};

// Remote-SSH is only supported for VS Code and Cursor
const supportsRemote = editorConfig.editor === "vscode" || editorConfig.editor === "cursor";

return (
<div className="space-y-6">
<div>
Expand All @@ -71,67 +62,41 @@ export function GeneralSection() {
</div>
</div>

<div>
<h3 className="text-foreground mb-4 text-sm font-medium">Editor</h3>
<div className="space-y-4">
<div className="flex items-center justify-between">
<div>
<div className="text-foreground text-sm">Default Editor</div>
<div className="text-muted text-xs">Editor to open workspaces in</div>
</div>
<Select value={editorConfig.editor} onValueChange={handleEditorChange}>
<SelectTrigger className="border-border-medium bg-background-secondary hover:bg-hover h-9 w-auto cursor-pointer rounded-md border px-3 text-sm transition-colors">
<SelectValue />
</SelectTrigger>
<SelectContent>
{EDITOR_OPTIONS.map((option) => (
<SelectItem key={option.value} value={option.value}>
{option.label}
</SelectItem>
))}
</SelectContent>
</Select>
</div>

{editorConfig.editor === "custom" && (
<div className="flex items-center justify-between">
<div>
<div className="text-foreground text-sm">Custom Command</div>
<div className="text-muted text-xs">Command to run (path will be appended)</div>
</div>
<Input
value={editorConfig.customCommand ?? ""}
onChange={(e: React.ChangeEvent<HTMLInputElement>) =>
handleCustomCommandChange(e.target.value)
}
placeholder="e.g., nvim"
className="border-border-medium bg-background-secondary h-9 w-40"
/>
</div>
)}

{supportsRemote && (
<div className="flex items-center justify-between">
<div className="flex items-center gap-2">
<div className="text-foreground text-sm">Use Remote-SSH for SSH workspaces</div>
<Tooltip>
<TooltipTrigger asChild>
<span className="text-muted cursor-help text-xs">(?)</span>
</TooltipTrigger>
<TooltipContent side="top" className="max-w-xs">
When enabled, opens SSH workspaces directly in the editor using the Remote-SSH
extension. Requires the Remote-SSH extension to be installed.
</TooltipContent>
</Tooltip>
</div>
<Checkbox
checked={editorConfig.useRemoteExtension}
onCheckedChange={handleRemoteExtensionChange}
/>
</div>
)}
<div className="flex items-center justify-between">
<div>
<div className="text-foreground text-sm">Editor</div>
<div className="text-muted text-xs">Editor to open workspaces in</div>
</div>
<Select value={editorConfig.editor} onValueChange={handleEditorChange}>
<SelectTrigger className="border-border-medium bg-background-secondary hover:bg-hover h-9 w-auto cursor-pointer rounded-md border px-3 text-sm transition-colors">
<SelectValue />
</SelectTrigger>
<SelectContent>
{EDITOR_OPTIONS.map((option) => (
<SelectItem key={option.value} value={option.value}>
{option.label}
</SelectItem>
))}
</SelectContent>
</Select>
</div>

{editorConfig.editor === "custom" && (
<div className="flex items-center justify-between">
<div>
<div className="text-foreground text-sm">Custom Command</div>
<div className="text-muted text-xs">Command to run (path will be appended)</div>
</div>
<Input
value={editorConfig.customCommand ?? ""}
onChange={(e: React.ChangeEvent<HTMLInputElement>) =>
handleCustomCommandChange(e.target.value)
}
placeholder="e.g., nvim"
className="border-border-medium bg-background-secondary h-9 w-40"
/>
</div>
)}
</div>
);
}
12 changes: 2 additions & 10 deletions src/browser/hooks/useOpenInEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ export function useOpenInEditor() {
return { success: false, error: "Please configure a custom editor command in Settings" };
}

// For SSH workspaces, validate the editor supports remote
if (isSSH && editorConfig.useRemoteExtension) {
// For SSH workspaces, validate the editor supports Remote-SSH
if (isSSH) {
if (editorConfig.editor === "zed") {
return { success: false, error: "Zed does not support Remote-SSH for SSH workspaces" };
}
Expand All @@ -57,14 +57,6 @@ export function useOpenInEditor() {
}
}

// For SSH workspaces without remote extension, we can't open
if (isSSH && !editorConfig.useRemoteExtension) {
return {
success: false,
error: "Enable 'Use Remote-SSH' in Settings to open SSH workspaces in editor",
};
}

// Call the backend API
const result = await api?.general.openWorkspaceInEditor({
workspaceId,
Expand Down
2 changes: 0 additions & 2 deletions src/common/constants/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,10 @@ export type EditorType = "vscode" | "cursor" | "zed" | "custom";
export interface EditorConfig {
editor: EditorType;
customCommand?: string; // Only when editor='custom'
useRemoteExtension: boolean; // For SSH workspaces, use Remote-SSH
}

export const DEFAULT_EDITOR_CONFIG: EditorConfig = {
editor: "vscode",
useRemoteExtension: true,
};

/**
Expand Down
3 changes: 1 addition & 2 deletions src/common/orpc/schemas/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,6 @@ const EditorTypeSchema = z.enum(["vscode", "cursor", "zed", "custom"]);
const EditorConfigSchema = z.object({
editor: EditorTypeSchema,
customCommand: z.string().optional(),
useRemoteExtension: z.boolean(),
});

// General
Expand Down Expand Up @@ -491,7 +490,7 @@ export const general = {
},
/**
* Open the workspace in the user's configured editor.
* For SSH workspaces with useRemoteExtension enabled, uses Remote-SSH extension.
* For SSH workspaces, uses Remote-SSH extension (VS Code/Cursor only).
*/
openWorkspaceInEditor: {
input: z.object({
Expand Down
13 changes: 2 additions & 11 deletions src/node/services/editorService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { log } from "@/node/services/log";
export interface EditorConfig {
editor: string;
customCommand?: string;
useRemoteExtension: boolean;
}

/**
Expand All @@ -29,7 +28,7 @@ export class EditorService {

/**
* Open the workspace in the user's configured code editor.
* For SSH workspaces with Remote-SSH extension enabled, opens directly in the editor.
* For SSH workspaces, opens via Remote-SSH extension (VS Code/Cursor only).
*/
async openWorkspaceInEditor(
workspaceId: string,
Expand Down Expand Up @@ -63,15 +62,7 @@ export class EditorService {
}

if (isSSH) {
// SSH workspace handling
if (!editorConfig.useRemoteExtension) {
return {
success: false,
error: "Cannot open SSH workspace without Remote-SSH extension enabled",
};
}

// Only VS Code and Cursor support Remote-SSH
// SSH workspace handling - only VS Code and Cursor support Remote-SSH
if (editorConfig.editor !== "vscode" && editorConfig.editor !== "cursor") {
return {
success: false,
Expand Down
Loading