@devries-cameron20 / t3code-1 / commits / 61b535e919
Fork 0

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

fix(desktop): handle macOS back and forward gestures (#25188)

Co-authored-by: Rodrigo Brechard <18405098+Brechard@users.noreply.github.com>

maria committed Oct 31, 2026 at 08:38 UTC 61b535e919ab1d7181bc5e402456fbd38e19b5e9
2 files changed +46
apps/desktop/src/window/DesktopWindow.test.ts
+40
@@ -78,6 +78,12 @@ function makeFakeBrowserWindow() {
78 zoomLevel = level;
79 }),
80 isLoadingMainFrame: vi.fn(() => false),
81 + navigationHistory: {
82 + canGoBack: vi.fn(() => true),
83 + canGoForward: vi.fn(() => true),
84 + goBack: vi.fn(),
85 + goForward: vi.fn(),
86 + },
87 on: vi.fn((eventName: string, listener: (...args: readonly unknown[]) => void) => {
88 webContentsListeners.set(eventName, listener);
89 }),
@@ -136,6 +142,7 @@ function makeFakeBrowserWindow() {
142 reload: webContents.reload,
143 reloadIgnoringCache: webContents.reloadIgnoringCache,
144 toggleDevTools: webContents.toggleDevTools,
145 + navigationHistory: webContents.navigationHistory,
146 send: webContents.send,
147 setZoomLevel: webContents.setZoomLevel,
148 setWindowButtonPosition: window.setWindowButtonPosition,
@@ -934,6 +941,39 @@ describe("DesktopWindow", () => {
941 }),
942 );
943
944 + it.effect("maps macOS horizontal swipes to available history navigation", () =>
945 + Effect.gen(function* () {
946 + const fakeWindow = makeFakeBrowserWindow();
947 + const createCount = yield* Ref.make(0);
948 + const mainWindow = yield* Ref.make<Option.Option<Electron.BrowserWindow>>(Option.none());
949 + const layer = layerTest({ window: fakeWindow.window, createCount, mainWindow });
950 +
951 + yield* Effect.gen(function* () {
952 + const desktopWindow = yield* DesktopWindow.DesktopWindow;
953 + yield* desktopWindow.handleBackendReady(new URL("http://127.0.0.1:3773"));
954 + const swipe = fakeWindow.windowListeners.get("swipe");
955 + assert.isDefined(swipe);
956 + if (!swipe) return;
957 + const history = fakeWindow.navigationHistory;
958 +
959 + swipe({}, "left");
960 + assert.equal(history.goBack.mock.calls.length, 1);
961 + assert.equal(history.goForward.mock.calls.length, 0);
962 + swipe({}, "right");
963 + assert.equal(history.goForward.mock.calls.length, 1);
964 +
965 + swipe({}, "up");
966 + swipe({}, "down");
967 + history.canGoBack.mockReturnValue(false);
968 + history.canGoForward.mockReturnValue(false);
969 + swipe({}, "left");
970 + swipe({}, "right");
971 + assert.equal(history.goBack.mock.calls.length, 1);
972 + assert.equal(history.goForward.mock.calls.length, 1);
973 + }).pipe(Effect.provide(layer));
974 + }),
975 + );
976 +
977 it.effect("persists the current main window bounds before the window closes", () =>
978 Effect.gen(function* () {
979 const fakeWindow = makeFakeBrowserWindow();
apps/desktop/src/window/DesktopWindow.ts
+6
@@ -685,6 +685,12 @@ export const make = Effect.gen(function* () {
685 });
686
687 if (environment.platform === "darwin") {
688 + // Mouse drivers can deliver Back/Forward as macOS swipe gestures instead of buttons.
689 + window.on("swipe", (_event, direction) => {
690 + const history = window.webContents.navigationHistory;
691 + if (direction === "left" && history.canGoBack()) history.goBack();
692 + else if (direction === "right" && history.canGoForward()) history.goForward();
693 + });
694 window.on("enter-full-screen", () => {
695 window.webContents.send(WINDOW_FULLSCREEN_STATE_CHANNEL, true);
696 });