A desktop coding agent with free access to frontier models.
TypeScript
fix: read the chat when a session opens
ogsamrat901777ca2090
diff --git a/apps/desktop/electron/computer-use.mjs b/apps/desktop/electron/computer-use.mjsindex 16db443b..0b66574c 100644--- a/apps/desktop/electron/computer-use.mjs+++ b/apps/desktop/electron/computer-use.mjs@@ -138,8 +138,11 @@ function hostSettings() {return { enabled: server?.enabled === true, real_screen: setting.real_screen !== false, limits: setting.limits ?? null, deny_apps: setting.deny_apps ?? [], mode: server?.mode ?? "normal", message: setting.message ?? null };}-function hostContext() {+async function hostContext() {const metrics = (() => { try { return app.getAppMetrics().map((m) => m.pid); } catch { return []; } })();+ // The chat now (the one that just called), not the last poll's.+ const fresh = await serverFetch("/computer-use/state").catch(() => null);+ if (fresh) server = fresh;return { ancestors: shared?.ancestors ?? [], self_pids: [process.pid, ...metrics], chat: server?.chat ?? null };}diff --git a/apps/server/src/computer-use/shared/PARITY.sha256 b/apps/server/src/computer-use/shared/PARITY.sha256index 18fbd384..d567ca11 100644--- a/apps/server/src/computer-use/shared/PARITY.sha256+++ b/apps/server/src/computer-use/shared/PARITY.sha256@@ -9,5 +9,5 @@ f11dd35d6db769398222387695262aeeac5dbaf9df16191d62a8811e8613e25d image.d.mts06f9604aa2d36d8cda25098e26088832e8b20cf9b0d756c5d745517c935684c9 media.mjsc12540410a558f4b48960c75b7a09e0660d6de679a6e49e2542427530fd9a3d4 media.d.mts02be6c62de13f3c8a55a0167c751742086c16bfadb201e9ce8e7f1b955d2376d native-worker.mjs-e209a9b5f4c87f035451cb8f0d8a98075c04cc85fcb1bc273a76c84c042a8395 portable-host.mjs-97bff0780540617933f44779ea52d0131190eeb8b4d914cd4abbc59abcd87343 portable-host.d.mts+bceba0caf4293a06096f7d69f820d63b0b5a7bb36c12a72c8b575f3cefa591fb portable-host.mjs+3adf92d8ab9fe7a1a8b595c090f6ba4f99ed10d5146c318cfbdf7b674aec9657 portable-host.d.mtsdiff --git a/apps/server/src/computer-use/shared/portable-host.d.mts b/apps/server/src/computer-use/shared/portable-host.d.mtsindex 1220b679..6bb5546d 100644--- a/apps/server/src/computer-use/shared/portable-host.d.mts+++ b/apps/server/src/computer-use/shared/portable-host.d.mts@@ -86,7 +86,8 @@ export function createPortableHost(options: {native: NativeWorker;spool?: MediaSpool | null;settings: () => HostSettings;- context?: () => HostContext;+ /** May be async (read once per discover / open-session). */+ context?: () => HostContext | Promise<HostContext>;approve: { open(request: OpenRequest): Promise<OpenAnswer> | OpenAnswer; act(request: ActRequest): Promise<{ allow: boolean }> | { allow: boolean } };onEvent?: (event: SessionEvent) => void;onState?: (states: HostSessionState[]) => void;diff --git a/apps/server/src/computer-use/shared/portable-host.mjs b/apps/server/src/computer-use/shared/portable-host.mjsindex 14815059..b3be2786 100644--- a/apps/server/src/computer-use/shared/portable-host.mjs+++ b/apps/server/src/computer-use/shared/portable-host.mjs@@ -129,8 +129,8 @@ function describeAction(a) {* - spool: a media spool (media.mjs createMediaSpool) frames go to, or null* - settings(): { enabled, real_screen, limits, deny_apps, mode } now* (mode: the chat's permission mode careful|normal|auto)- * - context(): { ancestors, self_pids, tty_pids, chat } now (chat: the chat- * using computer use, for "Allow for this chat" and per-chat counts)+ * - context(): { ancestors, self_pids, tty_pids, chat } now, or a promise of it+ * (chat: the chat using computer use, for "Allow for this chat" and per-chat counts)* - approve: { open(request) → { decision: "chat"|"once"|"deny", window_id? },* act(request) → { allow: boolean } }* - onEvent(event): `computer.session` events; onState(states); onFrame(frame)@@ -367,7 +367,7 @@ export async function createPortableHost({ native, spool = null, settings, conte}async function discover() {- const ctx = context() ?? {};+ const ctx = (await context()) ?? {};const config = settings() ?? {};const windows = await native.call("list");const apps = new Map();@@ -383,7 +383,7 @@ export async function createPortableHost({ native, spool = null, settings, conteasync function openSession(connection, args) {const config = settings() ?? {};- const ctx = context() ?? {};+ const ctx = (await context()) ?? {};if (!config.enabled) return mcpResult(failure("disabled", config.message || "Computer use is turned off."));if (config.real_screen === false) return mcpResult(failure("real_screen_unavailable", "Computer use on this screen is turned off."));if (lease) return mcpResult(failure("session_busy", "Another computer use session is open. Close it first."));