Compare commits

...
Author SHA1 Message Date
Julius MarmingeandClaude Opus 4.6 36314bb3bb Merge origin/main and resolve conflicts
Keep open-in-editor dropdown, accept main's removal of status indicator
from header.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
2026-02-08 23:24:04 -08:00
Cursor AgentandJulius Marminge 84b71e0a01 fix: add error handling and address review feedback
- Validate cwd is non-empty in shell:open-in-editor IPC handler
- Check shell.openPath() return value and throw on error
- Attach spawn error listener to prevent crashes from missing CLI
- Validate localStorage lastEditor against known EDITORS list
- Only call preventDefault() for Cmd+O when action will run

Co-authored-by: Julius Marminge <[email protected]>
2026-02-09 05:23:09 +00:00
Julius MarmingeandClaude Opus 4.6 c8f33b89c6 Fix biome formatting issues
Co-Authored-By: Claude Opus 4.6 <[email protected]>
2026-02-08 21:17:09 -08:00
Julius MarmingeandClaude Opus 4.6 6204eaf5e1 Move editor definitions to contracts for strict IPC typing
EDITORS config and EditorId type now live in @acme/contracts so the
shell.openInEditor IPC channel is strictly typed end-to-end. The main
process uses the contract's command field (null = file manager via
shell.openPath).

Co-Authored-By: Claude Opus 4.6 <[email protected]>
2026-02-08 21:15:13 -08:00
Julius MarmingeandClaude Haiku 4.5 3303d9a7fa Add open-in-editor feature with Cmd+O shortcut
Add dropdown in header to open workspace in Cursor or system file manager (Finder/Explorer/Files). Include Cmd+O/Ctrl+O global keyboard shortcut to open in last-used editor, persisted to localStorage.

Co-Authored-By: Claude Haiku 4.5 <[email protected]>
2026-02-08 20:49:16 -08:00
4 changed files with 135 additions and 1 deletions

No files matched your search

+25 -1
View File
@@ -3,9 +3,10 @@ fixPath();
import { spawn } from "node:child_process";
import path from "node:path";
import { BrowserWindow, app, dialog, ipcMain, session } from "electron";
import { BrowserWindow, app, dialog, ipcMain, session, shell } from "electron";
import {
EDITORS,
IPC_CHANNELS,
type TerminalCommandInput,
type TerminalCommandResult,
@@ -125,6 +126,29 @@ function registerIpcHandlers(): void {
}),
);
// Shell handlers
ipcMain.handle(
IPC_CHANNELS.shellOpenInEditor,
async (_event, cwd: string, editor: string) => {
if (!cwd) throw new Error("cwd is required");
const editorDef = EDITORS.find((e) => e.id === editor);
if (!editorDef) throw new Error(`Unknown editor: ${editor}`);
if (!editorDef.command) {
const error = await shell.openPath(cwd);
if (error) throw new Error(error);
return;
}
const child = spawn(editorDef.command, [cwd], {
detached: true,
stdio: "ignore",
});
child.on("error", () => {
/* ignore spawn failures for detached editors */
});
child.unref();
},
);
// Agent handlers
ipcMain.handle(
IPC_CHANNELS.agentSpawn,
+4
View File
@@ -52,6 +52,10 @@ const nativeApi: NativeApi = {
ipcRenderer.removeListener(IPC_CHANNELS.providerEvent, listener);
},
},
shell: {
openInEditor: (cwd: string, editor: string) =>
ipcRenderer.invoke(IPC_CHANNELS.shellOpenInEditor, cwd, editor),
},
};
contextBridge.exposeInMainWorld("nativeApi", nativeApi);
+95
View File
@@ -8,6 +8,7 @@ import {
useState,
} from "react";
import { EDITORS, type EditorId } from "@acme/contracts";
import {
DEFAULT_MODEL,
DEFAULT_REASONING,
@@ -32,6 +33,18 @@ function formatMessageMeta(createdAt: string, duration: string | null): string {
return `${formatTimestamp(createdAt)} • ${duration}`;
}
const FILE_MANAGER_LABEL = navigator.platform.includes("Mac")
? "Finder"
: navigator.platform.includes("Win")
? "Explorer"
: "Files";
function editorLabel(editor: (typeof EDITORS)[number]): string {
return editor.command ? editor.label : FILE_MANAGER_LABEL;
}
const LAST_EDITOR_KEY = "codething:last-editor";
function workToneClass(tone: "thinking" | "tool" | "info" | "error"): string {
if (tone === "error") return "text-rose-300/50";
if (tone === "tool") return "text-[#8a8a8a]";
@@ -46,12 +59,20 @@ export default function ChatView() {
const [isSending, setIsSending] = useState(false);
const [isConnecting, setIsConnecting] = useState(false);
const [isModelMenuOpen, setIsModelMenuOpen] = useState(false);
const [isEditorMenuOpen, setIsEditorMenuOpen] = useState(false);
const [lastEditor, setLastEditor] = useState<EditorId>(() => {
const stored = localStorage.getItem(LAST_EDITOR_KEY);
return EDITORS.some((e) => e.id === stored)
? (stored as EditorId)
: EDITORS[0].id;
});
const [selectedEffort, setSelectedEffort] =
useState<string>(DEFAULT_REASONING);
const [nowTick, setNowTick] = useState(() => Date.now());
const messagesEndRef = useRef<HTMLDivElement>(null);
const textareaRef = useRef<HTMLTextAreaElement>(null);
const modelMenuRef = useRef<HTMLDivElement>(null);
const editorMenuRef = useRef<HTMLDivElement>(null);
const activeThread = state.threads.find((t) => t.id === state.activeThreadId);
const activeProject = state.projects.find(
@@ -179,6 +200,47 @@ export default function ChatView() {
};
}, [isModelMenuOpen]);
useEffect(() => {
if (!isEditorMenuOpen) return;
const handleClickOutside = (event: MouseEvent) => {
if (!editorMenuRef.current) return;
if (
event.target instanceof Node &&
!editorMenuRef.current.contains(event.target)
) {
setIsEditorMenuOpen(false);
}
};
window.addEventListener("mousedown", handleClickOutside);
return () => {
window.removeEventListener("mousedown", handleClickOutside);
};
}, [isEditorMenuOpen]);
// Cmd+O / Ctrl+O to open in last-used editor
useEffect(() => {
const handler = (e: globalThis.KeyboardEvent) => {
if (e.key === "o" && (e.metaKey || e.ctrlKey) && !e.shiftKey) {
if (api && activeProject) {
e.preventDefault();
void api.shell.openInEditor(activeProject.cwd, lastEditor);
}
}
};
window.addEventListener("keydown", handler);
return () => window.removeEventListener("keydown", handler);
}, [api, activeProject, lastEditor]);
const openInEditor = (editorId: EditorId) => {
if (!api || !activeProject) return;
void api.shell.openInEditor(activeProject.cwd, editorId);
setLastEditor(editorId);
localStorage.setItem(LAST_EDITOR_KEY, editorId);
setIsEditorMenuOpen(false);
};
const ensureSession = async (): Promise<string | null> => {
if (!api || !activeThread || !activeProject) return null;
if (activeThread.session && activeThread.session.status !== "closed") {
@@ -313,6 +375,39 @@ export default function ChatView() {
</h2>
</div>
<div className="flex items-center gap-3">
{/* Open in editor */}
{activeProject && (
<div className="relative" ref={editorMenuRef}>
<button
type="button"
className="rounded-md px-2 py-1 text-[10px] text-[#a0a0a0]/40 transition-colors duration-150 hover:text-[#a0a0a0]/60"
onClick={() => setIsEditorMenuOpen((v) => !v)}
>
Open in&hellip;
</button>
{isEditorMenuOpen && (
<div className="absolute right-0 top-full z-50 mt-1 min-w-[120px] rounded-md border border-white/[0.08] bg-[#1b1b1d] py-1 shadow-xl">
{EDITORS.map((editor) => (
<button
key={editor.id}
type="button"
className="flex w-full items-center gap-2 px-3 py-1.5 text-left text-[11px] text-[#e0e0e0] hover:bg-white/[0.06]"
onClick={() => openInEditor(editor.id)}
>
{editorLabel(editor)}
{editor.id === lastEditor && (
<kbd className="ml-auto text-[9px] text-[#a0a0a0]/40">
{navigator.platform.includes("Mac")
? "\u2318O"
: "Ctrl+O"}
</kbd>
)}
</button>
))}
</div>
)}
</div>
)}
{/* Diff toggle */}
<button
type="button"
+11
View File
@@ -11,6 +11,13 @@ import type {
import type { TerminalCommandInput, TerminalCommandResult } from "./terminal";
import type { NewTodoInput, Todo } from "./todo";
export const EDITORS = [
{ id: "cursor", label: "Cursor", command: "cursor" },
{ id: "file-manager", label: "File Manager", command: null },
] as const;
export type EditorId = (typeof EDITORS)[number]["id"];
export const IPC_CHANNELS = {
todosList: "todos:list",
todosAdd: "todos:add",
@@ -29,6 +36,7 @@ export const IPC_CHANNELS = {
providerSessionStop: "provider:session:stop",
providerSessionList: "provider:session:list",
providerEvent: "provider:event",
shellOpenInEditor: "shell:open-in-editor",
} as const;
export interface NativeApi {
@@ -63,4 +71,7 @@ export interface NativeApi {
listSessions: () => Promise<ProviderSession[]>;
onEvent: (callback: (event: ProviderEvent) => void) => () => void;
};
shell: {
openInEditor: (cwd: string, editor: EditorId) => Promise<void>;
};
}