@devries-cameron20 / t3code-1 / commits / fad7202f9c
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(web): Cmd+O no longer opens the editor more than once (#18983)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>

Samuel Soeller committed Oct 19, 2026 at 19:31 UTC fad7202f9ca68f69b0acc24f767f29550daf9e18
7 files changed +121 -9
apps/web/src/components/ChatView.tsx
+7
@@ -8451,6 +8451,13 @@ export default function ChatView(props: ChatViewProps) {
8451 keybindings={keybindings}
8452 availableEditors={availableEditors}
8453 showOpenInPicker={showOpenInPicker}
8454 + openInShortcutEnabled={
8455 + !(
8456 + rightPanelOpen &&
8457 + renderedRightPanelSurface?.kind === "file" &&
8458 + renderedRightPanelSurface.attachment === undefined
8459 + )
8460 + }
8461 gitCwd={gitCwd}
8462 isGitRepo={isGitRepo}
8463 envLocked={envLocked}
apps/web/src/components/chat/OpenInPicker.browser.test.tsx
+92 -3
@@ -66,6 +66,7 @@ vi.mock(import("../../remoteOpen"), async (importOriginal) => ({
66 }));
67
68 import { OpenInPicker } from "./OpenInPicker";
69 +import { useOpenFavoriteEditorShortcut } from "./OpenInPickerShortcut";
70
71 const primary = EnvironmentId.make("primary");
72 const selected = EnvironmentId.make("selected");
@@ -133,17 +134,105 @@ async function click(element: HTMLElement) {
134 await act(async () => element.click());
135 }
136
136 -async function pressOpenFavorite() {
137 +async function pressOpenFavorite(mac = false) {
138 const event = new KeyboardEvent("keydown", {
139 key: "o",
139 - ctrlKey: true,
140 + ctrlKey: !mac,
141 + metaKey: mac,
142 bubbles: true,
143 cancelable: true,
144 });
143 - await act(async () => window.dispatchEvent(event));
145 + await act(async () => document.body.dispatchEvent(event));
146 return event;
147 }
148
149 +function FavoriteEditorFallback() {
150 + useOpenFavoriteEditorShortcut({
151 + enabled: true,
152 + environmentId: selected,
153 + keybindings: DEFAULT_RESOLVED_KEYBINDINGS,
154 + availableEditors: editors,
155 + openInCwd: "/work/project",
156 + });
157 + return null;
158 +}
159 +
160 +it.each(["local-exec", "remote-links"] as const)(
161 + "opens exactly one %s target as the file preview and workspace pickers mount and unmount",
162 + async (mode) => {
163 + state.allowed.add(selected);
164 + state.remote =
165 + mode === "local-exec" ? { mode } : { mode, host: { kind: "ssh-alias", host: "test-host" } };
166 + const mac = mode === "remote-links";
167 + vi.spyOn(navigator, "platform", "get").mockReturnValue(mac ? "MacIntel" : "Linux");
168 + const surfaces = ["workspace", "file", "workspace"];
169 + if (mode === "local-exec") surfaces.push("fallback");
170 +
171 + for (const surface of surfaces) {
172 + const previewVisible = surface === "file";
173 + await act(async () => {
174 + root.render(
175 + <>
176 + {/* Mount the fallback first so picker priority cannot rely on listener order. */}
177 + <FavoriteEditorFallback />
178 + {surface !== "fallback" && (
179 + <OpenInPicker
180 + environmentId={selected}
181 + keybindings={DEFAULT_RESOLVED_KEYBINDINGS}
182 + availableEditors={editors}
183 + openInCwd="/work/project"
184 + displayMode="panel"
185 + enableShortcut={!previewVisible}
186 + />
187 + )}
188 + {previewVisible && (
189 + <OpenInPicker
190 + environmentId={selected}
191 + keybindings={DEFAULT_RESOLVED_KEYBINDINGS}
192 + availableEditors={editors}
193 + openInCwd="/work/project/README.md"
194 + compact
195 + />
196 + )}
197 + </>,
198 + );
199 + });
200 + state.run.mockClear();
201 + state.openUrl.mockClear();
202 + const event = await pressOpenFavorite(mac);
203 + const cwd = previewVisible ? "/work/project/README.md" : "/work/project";
204 + expect.soft(event.defaultPrevented, surface).toBe(true);
205 + if (mode === "local-exec") {
206 + expect.soft(state.run, surface).toHaveBeenCalledExactlyOnceWith({
207 + environmentId: selected,
208 + input: { cwd, editor: "vscode" },
209 + });
210 + expect.soft(state.openUrl, surface).not.toHaveBeenCalled();
211 + } else {
212 + expect
213 + .soft(state.openUrl, surface)
214 + .toHaveBeenCalledExactlyOnceWith(`vscode://vscode-remote/ssh-remote+test-host${cwd}`);
215 + expect.soft(state.run, surface).not.toHaveBeenCalled();
216 + }
217 + }
218 + },
219 +);
220 +
221 +it.each(["remote-links", "remote-unavailable"] as const)(
222 + "does not launch an editor from the %s fallback when no picker is mounted",
223 + async (mode) => {
224 + state.allowed.add(selected);
225 + state.remote =
226 + mode === "remote-links" ? { mode, host: { kind: "ssh-alias", host: "test-host" } } : { mode };
227 + await act(async () => root.render(<FavoriteEditorFallback />));
228 +
229 + await pressOpenFavorite();
230 +
231 + expect.soft(state.run).not.toHaveBeenCalled();
232 + expect.soft(state.openUrl).not.toHaveBeenCalled();
233 + },
234 +);
235 +
236 it.each(["local-exec", "remote-links"] as const)(
237 "selects the preferred editor without launching a %s workspace",
238 async (mode) => {
apps/web/src/components/chat/OpenInPicker.tsx
+3 -3
@@ -283,7 +283,7 @@ export const OpenInPicker = memo(function OpenInPicker({
283 useEffect(() => {
284 if (!enableShortcut || !canOpenEditor) return;
285 const handler = (e: globalThis.KeyboardEvent) => {
286 - if (!isOpenFavoriteEditorShortcut(e, keybindings)) return;
286 + if (e.defaultPrevented || !isOpenFavoriteEditorShortcut(e, keybindings)) return;
287 if (!openInCwd) return;
288 if (!preferredEditor) return;
289 if (
@@ -295,8 +295,8 @@ export const OpenInPicker = memo(function OpenInPicker({
295 e.preventDefault();
296 void openInEditor(preferredEditor);
297 };
298 - window.addEventListener("keydown", handler);
299 - return () => window.removeEventListener("keydown", handler);
298 + window.addEventListener("keydown", handler, true);
299 + return () => window.removeEventListener("keydown", handler, true);
300 }, [
301 canOpenEditor,
302 enableShortcut,
apps/web/src/components/chat/OpenInPickerShortcut.ts
+13 -3
@@ -3,6 +3,7 @@ import { useEffect } from "react";
3
4 import { usePreferredEditor } from "../../editorPreferences";
5 import { isOpenFavoriteEditorShortcut } from "../../keybindings";
6 +import { useRemoteOpenState } from "../../remoteOpen";
7 import { shellEnvironment } from "../../state/shell";
8 import { useAtomCommand } from "../../state/use-atom-command";
9
@@ -21,11 +22,12 @@ export function useOpenFavoriteEditorShortcut({
22 }) {
23 const openInEditorMutation = useAtomCommand(shellEnvironment.openInEditor, "open in editor");
24 const [preferredEditor] = usePreferredEditor(availableEditors);
25 + const remote = useRemoteOpenState(environmentId);
26
27 useEffect(() => {
26 - if (!enabled) return;
28 + if (!enabled || remote.mode !== "local-exec") return;
29 const handler = (event: globalThis.KeyboardEvent) => {
28 - if (!isOpenFavoriteEditorShortcut(event, keybindings)) return;
30 + if (event.defaultPrevented || !isOpenFavoriteEditorShortcut(event, keybindings)) return;
31 if (!openInCwd || !preferredEditor) return;
32
33 event.preventDefault();
@@ -39,5 +41,13 @@ export function useOpenFavoriteEditorShortcut({
41 };
42 window.addEventListener("keydown", handler);
43 return () => window.removeEventListener("keydown", handler);
42 - }, [enabled, environmentId, keybindings, openInCwd, openInEditorMutation, preferredEditor]);
44 + }, [
45 + enabled,
46 + environmentId,
47 + keybindings,
48 + openInCwd,
49 + openInEditorMutation,
50 + preferredEditor,
51 + remote.mode,
52 + ]);
53 }
apps/web/src/components/chat/RightPanelSurfaceContent.tsx
+1
@@ -196,6 +196,7 @@ export function RightPanelSurfaceContent(props: {
196 composerDraftTarget={props.composerDraftTarget}
197 keybindings={props.keybindings}
198 availableEditors={files.availableEditors}
199 + openInShortcutEnabled={visible}
200 relativePath={surface.kind === "file" ? surface.relativePath : null}
201 {...(attachment ? { attachment } : {})}
202 revealLine={surface.kind === "file" ? (surface.revealLine ?? null) : null}
apps/web/src/components/chat/ThreadDetailsPanel.tsx
+2
@@ -38,6 +38,7 @@ export interface ThreadDetailsPanelProps extends Pick<
38 keybindings: ResolvedKeybindingsConfig;
39 availableEditors: ReadonlyArray<EditorId>;
40 showOpenInPicker: boolean;
41 + openInShortcutEnabled: boolean;
42 gitCwd: string | null;
43 isGitRepo: boolean;
44 envLocked: boolean;
@@ -126,6 +127,7 @@ export function ThreadDetailsPanel(props: ThreadDetailsPanelProps) {
127 environmentId={props.environmentId}
128 availableEditors={props.availableEditors}
129 openInCwd={props.gitCwd}
130 + enableShortcut={props.openInShortcutEnabled}
131 displayMode="panel"
132 />
133 ) : null}
apps/web/src/components/files/FilePreviewPanel.tsx
+3
@@ -129,6 +129,7 @@ interface FilePreviewPanelProps {
129 composerDraftTarget: ScopedThreadRef | DraftId;
130 keybindings: ResolvedKeybindingsConfig;
131 availableEditors: ReadonlyArray<EditorId>;
132 + openInShortcutEnabled: boolean;
133 revealLine: number | null;
134 revealRequestId: number;
135 onOpenFile: (relativePath: string) => void;
@@ -979,6 +980,7 @@ export default function FilePreviewPanel({
980 composerDraftTarget,
981 keybindings,
982 availableEditors,
983 + openInShortcutEnabled,
984 revealLine,
985 revealRequestId,
986 onOpenFile,
@@ -1239,6 +1241,7 @@ export default function FilePreviewPanel({
1241 environmentId={environmentId}
1242 keybindings={keybindings}
1243 availableEditors={availableEditors}
1244 + enableShortcut={openInShortcutEnabled}
1245 openInCwd={absolutePath}
1246 compact
1247 revealFileManager={revealsInFileManager}