Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
46db063
docs(design): moving a working thread to another computer (Move v2 st…
badcuban Nov 16, 2026
35555f0
feat(contracts): a queued move that waits for a working thread to be …
badcuban Nov 16, 2026
d0fab6d
feat(server): the decider queues a move until its thread is free
badcuban Nov 16, 2026
10b2f4b
feat(server): no session of a moving thread starts, and a stop can be…
badcuban Nov 16, 2026
f681209
feat(contracts): a move target that can't be reached says so
badcuban Nov 16, 2026
ed0b78e
feat(server): queued moves start once their thread is free
badcuban Nov 16, 2026
dfad3a3
feat(server): an agent can move its own thread with thread_move
badcuban Nov 16, 2026
d40501e
docs(guide): agents can explain moving a thread to another computer
badcuban Nov 16, 2026
07ec3fc
docs(guide): agents can explain moving a working thread
badcuban Nov 16, 2026
e626f5b
test(server): queued moves, the session fence and thread_move
badcuban Nov 16, 2026
d628d4a
docs(server): the move decisions say how a queued move ends
badcuban Nov 16, 2026
10a23a6
test(server): the agent-process ledger ends a shell an agent left in …
badcuban Nov 16, 2026
eded41f
feat(codex): a stopped app server, and the shells it started, are pro…
badcuban Nov 16, 2026
fd547ad
feat(acp): a stopped agent, and the shells it put in groups of their …
badcuban Nov 16, 2026
e99be4f
feat(pi, muse): a stopped Pi process or Muse host, and what it starte…
badcuban Nov 16, 2026
6b7d713
feat(claude): a stopped session's Claude Code process, and what it st…
badcuban Nov 16, 2026
3e971cc
feat(opencode): a stopped thread's OpenCode work is confirmed ended b…
badcuban Nov 16, 2026
5d8f78f
test(claude): pass the query factory straight through in the confirme…
badcuban Nov 16, 2026
e325c98
perf(server): the process table is read only for a stop that's for a …
badcuban Nov 16, 2026
9104702
fix(server): an early start the move ends has what its agent started …
badcuban Nov 16, 2026
947cb07
perf(server): a queued move reads only the threads its checks need
badcuban Nov 16, 2026
abb0aac
feat(server): the server says it queues moves
badcuban Nov 16, 2026
3f4596d
feat(server): a queued move picks its agent when it starts
badcuban Nov 16, 2026
4318edf
fix(server): a start or recovery under way can't open a session after…
badcuban Nov 16, 2026
614c9a1
fix(opencode): a restart no longer passes for proof that OpenCode sto…
badcuban Nov 16, 2026
4eefc73
fix(server): a process table that couldn't be read never passes as no…
badcuban Nov 16, 2026
9bf9593
fix(server): a move look begun before a Cancel never stops the user's…
badcuban Nov 16, 2026
d372840
fix(server): a Cancel that the move's start beats still cancels the t…
badcuban Nov 16, 2026
44e646d
fix(server): stop and move now says so when a command runs in the use…
badcuban Nov 16, 2026
7c2bea9
fix(server): a stop that finds its session already gone counts as sto…
badcuban Nov 16, 2026
86037ff
feat(web): move a working thread when it's done, or stop it and move now
badcuban Nov 16, 2026
fe35299
fix(web): a waiting move's notice gives its words the full row on a p…
badcuban Nov 16, 2026
5662930
feat(web): every move goes through the queue where the server queues …
badcuban Nov 16, 2026
ed06cca
fix(web): the move dialog says what the agent is doing, not that the …
badcuban Nov 16, 2026
f8f2051
feat(web): the thread's title in the header opens its menu
badcuban Nov 16, 2026
4bcddd5
fix(web): stop and move now isn't offered while a command runs in the…
badcuban Nov 16, 2026
3b31829
feat(desktop): the window follows the cursor while the page says a dr…
badcuban Nov 16, 2026
a6eb616
feat(web): press and drag on the project name or thread title moves t…
badcuban Nov 16, 2026
5de8610
fix(desktop): no window drag from header buttons under Wayland
badcuban Nov 16, 2026
30dfd28
fix(web): the keyboard opens and leaves submenus in the browser's own…
badcuban Nov 16, 2026
85e673c
fix(web): the title menu offers Move up and Move down in the custom sort
badcuban Nov 16, 2026
bc0344c
Merge remote-tracking branch 'origin/main' into feat/move-working-thr…
badcuban Nov 16, 2026
e7ff724
fix(server): thread_move loads when an agent looks it up, like the ot…
badcuban Nov 16, 2026
9c394bd
fix(contracts): an older app reads a move preview with an offline com…
badcuban Nov 16, 2026
883103d
Merge branch 'main' into feat/move-working-thread
badcuban Nov 16, 2026
a0c72ff
Merge branch 'main' into feat/move-working-thread
badcuban Nov 16, 2026
2321178
Merge remote-tracking branch 'origin/main' into feat/move-working-thr…
badcuban Nov 16, 2026
562b089
Merge remote-tracking branch 'origin/main' into feat/move-working-thr…
badcuban Nov 16, 2026
89b5cc2
Merge branch 'main' into feat/move-working-thread
badcuban Nov 16, 2026
b0cef05
Merge remote-tracking branch 'origin/main' into feat/move-working-thr…
badcuban Nov 16, 2026
35d6598
test(server): the Claude replay recordings list the thread_move tool
badcuban Nov 16, 2026
7014acd
Merge remote-tracking branch 'origin/feat/move-working-thread' into f…
badcuban Nov 16, 2026
86f45a6
Merge branch 'main' into feat/move-working-thread
badcuban Nov 16, 2026
d1deaf5
fix(server): an agent's named computer is found by its exact id first
badcuban Nov 16, 2026
67f45e6
Merge branch 'main' into feat/move-working-thread
badcuban Nov 16, 2026
579bf83
Merge branch 'main' into feat/move-working-thread
badcuban Nov 16, 2026
3ce5322
Merge branch 'main' into feat/move-working-thread
badcuban Nov 16, 2026
44e6559
fix(server): an agent's named computer is picked only when nothing el…
badcuban Nov 16, 2026
ab71f9b
test(server): the ACP stop test hands its helper the pid path as an a…
badcuban Nov 16, 2026
a7b51db
Merge branch 'main' into feat/move-working-thread
badcuban Nov 16, 2026
88bdc31
test(server): the tool-use evals have a canned answer for thread_move
badcuban Nov 16, 2026
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
4 changes: 4 additions & 0 deletions apps/desktop/src/ipc/DesktopIpcHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ import {
setTheme,
getPowerState,
setBackdropActive,
setWindowDragging,
canMoveWindow,
showContextMenu,
} from "./methods/window.ts";
import {
Expand Down Expand Up @@ -92,6 +94,7 @@ export const installDesktopIpcHandlers = Effect.gen(function* () {

yield* ipc.handleSync(getAppBranding);
yield* ipc.handleSync(isMarketingCaptureMode);
yield* ipc.handleSync(canMoveWindow);
yield* ipc.handleSync(getLocalEnvironmentBootstrap);
yield* ipc.handleSync(getPreviousAppVersion);

Expand Down Expand Up @@ -158,6 +161,7 @@ export const installDesktopIpcHandlers = Effect.gen(function* () {
yield* ipc.handle(setTheme);
yield* ipc.handle(getPowerState);
yield* ipc.handle(setBackdropActive);
yield* ipc.handle(setWindowDragging);
yield* ipc.handle(setTaskbarStatus);
yield* ipc.handle(getBackgroundOptions);
yield* ipc.handle(setBackgroundOptions);
Expand Down
2 changes: 2 additions & 0 deletions apps/desktop/src/ipc/channels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export const SET_THEME_CHANNEL = "desktop:set-theme";
export const GET_POWER_STATE_CHANNEL = "desktop:get-power-state";
export const POWER_STATE_CHANNEL = "desktop:power-state";
export const SET_BACKDROP_ACTIVE_CHANNEL = "desktop:set-backdrop-active";
export const SET_WINDOW_DRAGGING_CHANNEL = "desktop:set-window-dragging";
export const CAN_MOVE_WINDOW_CHANNEL = "desktop:can-move-window";
export const BACKDROP_TOO_HEAVY_CHANNEL = "desktop:backdrop-too-heavy";
export const RESET_THEME_CHANNEL = "desktop:reset-theme";
export const SET_TASKBAR_STATUS_CHANNEL = "desktop:set-taskbar-status";
Expand Down
22 changes: 22 additions & 0 deletions apps/desktop/src/ipc/methods/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import * as DesktopStatusIndicator from "../../window/DesktopStatusIndicator.ts"
import * as DesktopBackdropMonitor from "../../window/DesktopBackdropMonitor.ts";
import * as DesktopThemeAppearance from "../../window/DesktopThemeAppearance.ts";
import * as DesktopWindow from "../../window/DesktopWindow.ts";
import * as DesktopWindowDrag from "../../window/DesktopWindowDrag.ts";

const ContextMenuPosition = Schema.Struct({
x: Schema.Number,
Expand Down Expand Up @@ -233,3 +234,24 @@ export const setBackdropActive = makeIpcMethod({
yield* monitor.setBackdropActive(active);
}),
});

/** Whether a drag from the page can move the window here (not under Wayland). */
export const canMoveWindow = makeSyncIpcMethod({
channel: IpcChannels.CAN_MOVE_WINDOW_CHANNEL,
result: Schema.Boolean,
handler: Effect.fn("desktop.ipc.window.canMoveWindow")(function* () {
const windowDrag = yield* DesktopWindowDrag.DesktopWindowDrag;
return windowDrag.canMoveWindow;
}),
});

/** A press on a header control became a drag (true), or ended (false): the window follows the cursor. */
export const setWindowDragging = makeIpcMethod({
channel: IpcChannels.SET_WINDOW_DRAGGING_CHANNEL,
payload: Schema.Boolean,
result: Schema.Void,
handler: Effect.fn("desktop.ipc.window.setWindowDragging")(function* (dragging) {
const windowDrag = yield* DesktopWindowDrag.DesktopWindowDrag;
yield* windowDrag.setDragging(dragging);
}),
});
3 changes: 3 additions & 0 deletions apps/desktop/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ import { runAppImageCommandIfAsked } from "./cliCommand/appImageCommand.ts";
import * as DesktopCliCommand from "./cliCommand/DesktopCliCommand.ts";
import * as DesktopUpdates from "./updates/DesktopUpdates.ts";
import * as DesktopBackdropMonitor from "./window/DesktopBackdropMonitor.ts";
import * as DesktopWindowDrag from "./window/DesktopWindowDrag.ts";
import * as DesktopThemeAppearance from "./window/DesktopThemeAppearance.ts";
import * as DesktopWindow from "./window/DesktopWindow.ts";
import * as DesktopStartupFailurePrompt from "./window/DesktopStartupFailurePrompt.ts";
Expand Down Expand Up @@ -307,6 +308,8 @@ const desktopWindowLayer = DesktopWindow.layer.pipe(
// appearance changes; the art's power and CPU watch sits beside it.
Layer.provideMerge(DesktopThemeAppearance.layer),
Layer.provideMerge(DesktopBackdropMonitor.layer),
// Moving the window from header controls that are also buttons.
Layer.provideMerge(DesktopWindowDrag.layer),
Layer.provideMerge(PreviewSession.layer),
Layer.provideMerge(PreviewAutomation.layer),
// Beneath the window and the automation, which both ask whose a page is.
Expand Down
8 changes: 8 additions & 0 deletions apps/desktop/src/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ ipcRenderer.on(IpcChannels.WINDOW_FOCUS_CHANNEL, (_event, focused: unknown) => {
// moment; telling the main process only once that moment has passed keeps
// those re-runs from costing two messages each.
let menuActionListenerCount = 0;
// Whether a drag from the page can move the window; asked once.
let canMoveWindowAnswer: boolean | null = null;
let menuActionsStopPending = false;

function reportMenuActionsListening(listening: boolean) {
Expand Down Expand Up @@ -335,6 +337,12 @@ contextBridge.exposeInMainWorld("desktopBridge", {
},
setBackdropActive: (active) =>
ipcRenderer.invoke(IpcChannels.SET_BACKDROP_ACTIVE_CHANNEL, active),
canMoveWindow: () => {
canMoveWindowAnswer ??= ipcRenderer.sendSync(IpcChannels.CAN_MOVE_WINDOW_CHANNEL) === true;
return canMoveWindowAnswer;
},
setWindowDragging: (dragging) =>
ipcRenderer.invoke(IpcChannels.SET_WINDOW_DRAGGING_CHANNEL, dragging),
onBackdropTooHeavy: (listener) => {
const wrappedListener = () => listener();
ipcRenderer.on(IpcChannels.BACKDROP_TOO_HEAVY_CHANNEL, wrappedListener);
Expand Down
161 changes: 161 additions & 0 deletions apps/desktop/src/window/DesktopWindowDrag.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
import { assert, describe, it } from "@effect/vitest";

import {
canMoveOwnWindow,
DRAG_FRAME_MS,
DRAG_SAFETY_MS,
makeWindowDragLoop,
type DraggableWindow,
} from "./DesktopWindowDrag.ts";

/** A clock the test moves by hand: intervals and one-shot timers, in ms. */
function makeClock() {
let now = 0;
let nextId = 0;
const timers = new Map<number, { at: number; every: number | null; run: () => void }>();
return {
clock: {
setInterval: (run: () => void, ms: number) => {
nextId += 1;
timers.set(nextId, { at: now + ms, every: ms, run });
return nextId;
},
clearInterval: (handle: unknown) => void timers.delete(handle as number),
setTimeout: (run: () => void, ms: number) => {
nextId += 1;
timers.set(nextId, { at: now + ms, every: null, run });
return nextId;
},
clearTimeout: (handle: unknown) => void timers.delete(handle as number),
},
advance(ms: number) {
const end = now + ms;
for (;;) {
const due = [...timers.entries()]
.filter(([, timer]) => timer.at <= end)
.toSorted(([, left], [, right]) => left.at - right.at)[0];
if (!due) break;
const [id, timer] = due;
now = timer.at;
if (timer.every === null) timers.delete(id);
else timer.at += timer.every;
timer.run();
}
now = end;
},
pending: () => timers.size,
};
}

function makeWindow(input?: { maximized?: boolean; fullScreen?: boolean }) {
let position: [number, number] = [100, 200];
const moves: Array<[number, number]> = [];
const blurListeners = new Set<() => void>();
const window: DraggableWindow = {
getPosition: () => [...position],
setPosition: (x, y) => {
position = [x, y];
moves.push([x, y]);
},
isMaximized: () => input?.maximized ?? false,
isFullScreen: () => input?.fullScreen ?? false,
isDestroyed: () => false,
once: (_event, listener) => blurListeners.add(listener),
removeListener: (_event, listener) => blurListeners.delete(listener),
};
return {
window,
moves,
blur: () => {
for (const listener of blurListeners) listener();
},
};
}

describe("makeWindowDragLoop", () => {
it("moves the window by how far the cursor moved, in whole pixels, only when it changed", () => {
const time = makeClock();
let cursor = { x: 150, y: 210 };
const loop = makeWindowDragLoop({ cursor: () => cursor, clock: time.clock });
const target = makeWindow();

loop.start(target.window);
time.advance(DRAG_FRAME_MS * 3);
assert.deepStrictEqual(target.moves, []);

cursor = { x: 180.4, y: 195.6 };
time.advance(DRAG_FRAME_MS * 3);
assert.deepStrictEqual(target.moves, [[130, 186]]);

loop.stop();
cursor = { x: 400, y: 400 };
time.advance(DRAG_FRAME_MS * 3);
assert.deepStrictEqual(target.moves, [[130, 186]]);
// Nothing runs once it stopped.
assert.strictEqual(time.pending(), 0);
});

it("stops when the window loses focus, or after a while with no stop", () => {
const time = makeClock();
let cursor = { x: 0, y: 0 };
const loop = makeWindowDragLoop({ cursor: () => cursor, clock: time.clock });

const blurred = makeWindow();
loop.start(blurred.window);
blurred.blur();
assert.isFalse(loop.isDragging());
assert.strictEqual(time.pending(), 0);

const forgotten = makeWindow();
loop.start(forgotten.window);
time.advance(DRAG_SAFETY_MS);
assert.isFalse(loop.isDragging());
assert.strictEqual(time.pending(), 0);
cursor = { x: 50, y: 50 };
time.advance(DRAG_FRAME_MS * 3);
assert.deepStrictEqual(forgotten.moves, []);
});

it("leaves a maximized or full-screen window where it is", () => {
const time = makeClock();
let cursor = { x: 0, y: 0 };
const loop = makeWindowDragLoop({ cursor: () => cursor, clock: time.clock });

for (const target of [makeWindow({ maximized: true }), makeWindow({ fullScreen: true })]) {
loop.start(target.window);
assert.isFalse(loop.isDragging());
cursor = { x: cursor.x + 40, y: cursor.y + 40 };
time.advance(DRAG_FRAME_MS * 3);
assert.deepStrictEqual(target.moves, []);
}
assert.strictEqual(time.pending(), 0);
});
});

describe("canMoveOwnWindow", () => {
const linux = (
env: Record<string, string | undefined>,
ozonePlatform = "",
ozonePlatformHint = "",
) => canMoveOwnWindow({ platform: "linux", env, ozonePlatform, ozonePlatformHint });

it("moves the window on macOS, Windows, and Linux under X11", () => {
const wayland = { WAYLAND_DISPLAY: "wayland-0", XDG_SESSION_TYPE: "wayland" };
for (const platform of ["darwin", "win32"] as const) {
assert.isTrue(
canMoveOwnWindow({ platform, env: wayland, ozonePlatform: "", ozonePlatformHint: "" }),
);
}
assert.isTrue(linux({ DISPLAY: ":0", XDG_SESSION_TYPE: "x11" }));
// A Wayland session where the app was told to run on X11 (XWayland).
assert.isTrue(linux(wayland, "x11"));
assert.isTrue(linux(wayland, "", "x11"));
});

it("doesn't offer it under Wayland, where the app can't move its window", () => {
assert.isFalse(linux({ WAYLAND_DISPLAY: "wayland-0" }));
assert.isFalse(linux({ XDG_SESSION_TYPE: "wayland" }));
assert.isFalse(linux({ WAYLAND_DISPLAY: "wayland-0" }, "", "auto"));
assert.isFalse(linux({ DISPLAY: ":0" }, "wayland"));
});
});
Loading
Loading