Skip to content

A desktop coding agent with free access to frontier models.

TypeScript

fix: match undo and status wording

Samrat Talukdarbe2affa88b9b
diff --git a/apps/app/src/react-app/domains/session/commands/context-usage.ts b/apps/app/src/react-app/domains/session/commands/context-usage.ts
index 7de0fa9f..834b0e55 100644
--- a/apps/app/src/react-app/domains/session/commands/context-usage.ts
+++ b/apps/app/src/react-app/domains/session/commands/context-usage.ts
@@ -48,9 +48,25 @@ export function contextUse(
};
}
-/** The Uploads row: "nothing waiting" or "N waiting" (sessions and project archives still queued). */
-export function uploadsLine(pending: { uploads?: number; archives?: number } | null | undefined): string | null {
+/** The Uploads row, in the CLI's words: "nothing waiting", "N waiting to be sent", or paused while signed out. */
+export function uploadsLine(pending: { uploads?: number; archives?: number } | null | undefined, { signedOut = false } = {}): string | null {
if (!pending) return null;
const waiting = num(pending.uploads) + num(pending.archives);
- return waiting === 0 ? "nothing waiting" : `${waiting} waiting`;
+ if (signedOut) return waiting ? `${waiting} waiting · sign in to send` : "paused · sign in to send";
+ return waiting === 0 ? "nothing waiting" : `${waiting} waiting to be sent`;
+}
+
+type SandboxBox = {
+ on: boolean;
+ state?: string | null;
+ backend?: { id?: string | null } | null;
+ runtime?: { ok?: boolean; name?: string | null } | null;
+};
+
+/** The Sandbox row, in the CLI's words: "off", "on · docker", "off (fell back to this machine)". */
+export function sandboxLabel(box: SandboxBox | null | undefined): string {
+ if (!box?.on) return "off";
+ if (box.state === "unavailable" || box.state === "failed") return "off (fell back to this machine)";
+ const backend = box.backend?.id || (box.runtime?.ok ? box.runtime.name : null) || null;
+ return backend ? `on · ${backend}` : "on";
}
diff --git a/apps/app/src/react-app/domains/session/commands/session-command-controls.tsx b/apps/app/src/react-app/domains/session/commands/session-command-controls.tsx
index a03d14ce..d7ae9a11 100644
--- a/apps/app/src/react-app/domains/session/commands/session-command-controls.tsx
+++ b/apps/app/src/react-app/domains/session/commands/session-command-controls.tsx
@@ -17,7 +17,7 @@ import { linuxSandboxView, useLinuxSandbox } from "@/react-app/domains/settings/
import { useSessionModelSelection } from "@/react-app/domains/session/surface/session-model-store";
import type { ProviderCatalog } from "@/react-app/domains/session/surface/use-model-behavior";
import { ChangesPanel } from "./changes-panel";
-import { contextUse, uploadsLine } from "./context-usage";
+import { contextUse, sandboxLabel, uploadsLine } from "./context-usage";
import { useSessionCommandsStore } from "./session-commands-store";
import { chatUndoKey } from "./undo-key";
import { useCachedQueryData, useUndoRedo, visibleMessages, type SessionCommandTarget } from "./use-session-commands";
@@ -254,7 +254,7 @@ function StatusRows(props: SessionCommandControlsProps) {
<StatusRow
row={{
label: "Uploads",
- value: pending ? uploadsLine(pending) ?? "unknown" : pendingFailed ? "unknown" : "checking…",
+ value: pending ? uploadsLine(pending, { signedOut: account?.connected === false }) ?? "unknown" : pendingFailed ? "unknown" : "checking…",
}}
/>
</div>
@@ -267,7 +267,6 @@ function SandboxRow(props: { client: OmniRushServerClient | null; workspaceId: s
if (!props.client) return null;
if (!box) return <StatusRow row={{ label: "Sandbox", value: sandbox.problem ? "unknown" : "checking…" }} />;
const view = linuxSandboxView(box, sandbox.pending);
- const backend = box.backend?.label ?? box.backend?.id ?? box.runtime?.name ?? null;
- const value = box.on ? `on${backend ? ` · ${backend}` : ""} · ${view.title.toLowerCase()}` : "off";
+ const value = sandboxLabel(box);
return <StatusRow row={{ label: "Sandbox", value, detail: view.detail }} />;
}
diff --git a/apps/app/src/react-app/domains/session/commands/undo-notice.ts b/apps/app/src/react-app/domains/session/commands/undo-notice.ts
index 4b0dd96c..ede8c597 100644
--- a/apps/app/src/react-app/domains/session/commands/undo-notice.ts
+++ b/apps/app/src/react-app/domains/session/commands/undo-notice.ts
@@ -6,6 +6,7 @@ export type RevertOutcome = {
restored?: readonly string[] | null;
merged?: readonly string[] | null;
kept?: readonly string[] | null;
+ outside?: readonly string[] | null;
};
export type UndoNotice = {
@@ -33,18 +34,20 @@ export function undoNotice(revert: RevertOutcome | null | undefined, tracked: bo
const restored = strings(revert?.restored);
const merged = strings(revert?.merged);
const kept = strings(revert?.kept);
+ const outside = strings(revert?.outside);
const lines: string[] = [];
const changed = restored.length + merged.length;
if (changed) lines.push(`Restored ${plural(changed, "file")}: ${list([...restored, ...merged])}.`);
if (merged.length) lines.push(`Your own edits in ${list(merged)} were kept.`);
if (kept.length) {
lines.push(
- `Left ${plural(kept.length, "file")} as ${kept.length === 1 ? "it is" : "they are"}: ${list(kept)} (changed by you or another program too).`,
+ `Left ${plural(kept.length, "file")} as ${kept.length === 1 ? "it is" : "they are"}: ${list(kept)} (edited after the turn, and the turn's change could not be taken out cleanly).`,
);
}
+ if (outside.length) lines.push(`Not touched: ${list(outside)} (changed during the turn, but not by the agent).`);
if (!lines.length) lines.push("The last turn changed no files.");
lines.push("Redo puts it back.");
- return { title: "Undid the last turn", message: lines.join(" "), variant: kept.length ? "warning" : "success" };
+ return { title: "Undid the last turn", message: lines.join(" "), variant: kept.length || outside.length ? "warning" : "success" };
}
export const REDO_NOTICE = "Redid the last turn";
diff --git a/apps/app/tests/session-commands.test.ts b/apps/app/tests/session-commands.test.ts
index 165016ef..36fea4c9 100644
--- a/apps/app/tests/session-commands.test.ts
+++ b/apps/app/tests/session-commands.test.ts
@@ -2,7 +2,7 @@ import { describe, expect, test } from "bun:test";
import { NOT_TRACKED_MESSAGE, projectTracksFiles, undoNotice } from "../src/react-app/domains/session/commands/undo-notice";
import { commandTemplateLabel, parseReviewReply } from "../src/react-app/domains/session/commands/review-message";
-import { contextUse, uploadsLine } from "../src/react-app/domains/session/commands/context-usage";
+import { contextUse, sandboxLabel, uploadsLine } from "../src/react-app/domains/session/commands/context-usage";
import { changeTotals, normalizeChanges, patchLines } from "../src/react-app/domains/session/commands/changes";
import { chatUndoKey } from "../src/react-app/domains/session/commands/undo-key";
@@ -15,11 +15,16 @@ describe("undoNotice", () => {
});
expect(undoNotice({ restored: ["a.ts"], merged: ["c.ts"], kept: ["d.ts"] }, true)).toEqual({
title: "Undid the last turn",
- message: "Restored 2 files: a.ts, c.ts. Your own edits in c.ts were kept. Left 1 file as it is: d.ts (changed by you or another program too). Redo puts it back.",
+ message: "Restored 2 files: a.ts, c.ts. Your own edits in c.ts were kept. Left 1 file as it is: d.ts (edited after the turn, and the turn's change could not be taken out cleanly). Redo puts it back.",
variant: "warning",
});
expect(undoNotice({ restored: ["1", "2", "3", "4", "5"] }, true).message).toBe("Restored 5 files: 1, 2, 3 and 2 more. Redo puts it back.");
- expect(undoNotice({ kept: ["x", "y"] }, true).message).toBe("Left 2 files as they are: x, y (changed by you or another program too). Redo puts it back.");
+ expect(undoNotice({ kept: ["x", "y"] }, true).message).toBe("Left 2 files as they are: x, y (edited after the turn, and the turn's change could not be taken out cleanly). Redo puts it back.");
+ expect(undoNotice({ restored: ["a"], outside: ["log.txt"] }, true)).toEqual({
+ title: "Undid the last turn",
+ message: "Restored 1 file: a. Not touched: log.txt (changed during the turn, but not by the agent). Redo puts it back.",
+ variant: "warning",
+ });
});
test("a turn that changed nothing, and a folder that is not a git repository", () => {
@@ -106,10 +111,18 @@ describe("contextUse", () => {
expect(contextUse([{ role: "user" }], limit)).toBeNull();
});
- test("uploads line", () => {
+ test("uploads and sandbox lines, in the CLI's words", () => {
expect(uploadsLine({ uploads: 0, archives: 0 })).toBe("nothing waiting");
- expect(uploadsLine({ uploads: 2, archives: 1 })).toBe("3 waiting");
+ expect(uploadsLine({ uploads: 2, archives: 1 })).toBe("3 waiting to be sent");
+ expect(uploadsLine({ uploads: 0, archives: 0 }, { signedOut: true })).toBe("paused · sign in to send");
+ expect(uploadsLine({ uploads: 2, archives: 0 }, { signedOut: true })).toBe("2 waiting · sign in to send");
expect(uploadsLine(null)).toBeNull();
+ expect(sandboxLabel(null)).toBe("off");
+ expect(sandboxLabel({ on: false })).toBe("off");
+ expect(sandboxLabel({ on: true, state: "ready", backend: { id: "docker" } })).toBe("on · docker");
+ expect(sandboxLabel({ on: true, state: "ready", backend: null, runtime: { ok: true, name: "podman" } })).toBe("on · podman");
+ expect(sandboxLabel({ on: true, state: "unavailable", backend: { id: "docker" } })).toBe("off (fell back to this machine)");
+ expect(sandboxLabel({ on: true, state: "starting" })).toBe("on");
});
});
diff --git a/apps/server/src/command-events.test.ts b/apps/server/src/command-events.test.ts
index 4d12feaf..f4ace4e4 100644
--- a/apps/server/src/command-events.test.ts
+++ b/apps/server/src/command-events.test.ts
@@ -40,7 +40,7 @@ describe("commandEvent", () => {
describe("revertEvent", () => {
const session = {
id: "ses_1",
- revert: { messageID: "msg_4", restored: ["src/a.ts", "b.md"], merged: ["c.ts"], kept: ["d.ts"], snapshot: "x" },
+ revert: { messageID: "msg_4", restored: ["src/a.ts", "b.md"], merged: ["c.ts"], kept: ["d.ts"], outside: ["log.txt"], snapshot: "x" },
};
test("an undo counts what happened to each file", () => {
@@ -52,14 +52,15 @@ describe("revertEvent", () => {
restored: 2,
merged: 1,
kept: 1,
- files: { restored: ["src/a.ts", "b.md"], merged: ["c.ts"], kept: ["d.ts"] },
+ outside: 1,
+ files: { restored: ["src/a.ts", "b.md"], merged: ["c.ts"], kept: ["d.ts"], outside: ["log.txt"] },
},
});
expect(revertEvent("revert", session, "msg_9")?.data.repeat).toBe(true);
});
test("an engine without the file lists records empty ones", () => {
- expect(revertEvent("revert", { revert: { messageID: "msg_1" } })?.data).toMatchObject({ restored: 0, merged: 0, kept: 0, files: { restored: [], merged: [], kept: [] } });
+ expect(revertEvent("revert", { revert: { messageID: "msg_1" } })?.data).toMatchObject({ restored: 0, merged: 0, kept: 0, outside: 0, files: { restored: [], merged: [], kept: [], outside: [] } });
});
test("a redo names the revert point before it", () => {
@@ -122,7 +123,7 @@ describe("SessionUploader.recordCommand", () => {
const pick = (type: string) => events.filter((event) => event.type === type);
expect(pick("turn.undone")).toHaveLength(1);
const data = pick("turn.undone")[0]!.data!;
- expect(data).toMatchObject({ schema: 1, message_id: "msg_2", repeat: false, restored: 1, merged: 0, kept: 1 });
+ expect(data).toMatchObject({ schema: 1, message_id: "msg_2", repeat: false, restored: 1, merged: 0, kept: 1, outside: 0 });
const files = data.files as { restored: string[]; kept: string[] };
expect(files.restored).toEqual(["src/app.ts"]);
// Paths take the same upload pass as every other path (an e-mail address in a name is not sent as is).
diff --git a/apps/server/src/command-events.ts b/apps/server/src/command-events.ts
index b2108d0f..59f4a421 100644
--- a/apps/server/src/command-events.ts
+++ b/apps/server/src/command-events.ts
@@ -3,7 +3,7 @@
* additive schema-1 events (SessionUploader.recordCommand). PARITY: the same
* names, fields and rules as omnirush-cli's src/command-events.js.
*
- * turn.undone {schema, message_id, repeat, restored, merged, kept, files: {restored, merged, kept}}
+ * turn.undone {schema, message_id, repeat, restored, merged, kept, outside, files: {restored, merged, kept, outside}}
* turn.redone {schema, message_id}
* review.run {schema, target, has_arguments}
* review.fix {schema, issues}
@@ -63,7 +63,7 @@ export function revertEvent(kind: "revert" | "unrevert", session: unknown, previ
const revert = (session as { revert?: unknown }).revert;
if (!revert || typeof revert !== "object") return null;
const record = revert as Record<string, unknown>;
- const files = { restored: list(record.restored), merged: list(record.merged), kept: list(record.kept) };
+ const files = { restored: list(record.restored), merged: list(record.merged), kept: list(record.kept), outside: list(record.outside) };
return {
type: "turn.undone",
data: {
@@ -72,6 +72,7 @@ export function revertEvent(kind: "revert" | "unrevert", session: unknown, previ
restored: files.restored.length,
merged: files.merged.length,
kept: files.kept.length,
+ outside: files.outside.length,
files,
},
};