A desktop coding agent with free access to frontier models.
TypeScript
fix: undo restores the typed command
Samrat Talukdar713b52eda2d6
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.tsxindex 74004ee6..a03d14ce 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@@ -61,10 +61,12 @@ export function SessionCommandControls(props: SessionCommandControlsProps) {if (action === "undo" && !canUndo) return;if (action === "redo" && !canRedo) return;event.preventDefault();+ event.stopPropagation();void (action === "undo" ? undo() : redo());};- window.addEventListener("keydown", onKey);- return () => window.removeEventListener("keydown", onKey);+ // Capture phase: the composer's editor keeps its own undo for text, so an empty composer must be seen first.+ window.addEventListener("keydown", onKey, true);+ return () => window.removeEventListener("keydown", onKey, true);}, [canRedo, canUndo, redo, undo]);const mod = isMac() ? "⌘" : "Ctrl+";diff --git a/apps/app/src/react-app/domains/session/commands/use-session-commands.ts b/apps/app/src/react-app/domains/session/commands/use-session-commands.tsindex 2fd36268..e39e68ac 100644--- a/apps/app/src/react-app/domains/session/commands/use-session-commands.ts+++ b/apps/app/src/react-app/domains/session/commands/use-session-commands.ts@@ -16,6 +16,7 @@ import {} from "@/react-app/domains/session/sync/session-sync";import { getComposerDraft, useComposerStateStore } from "@/react-app/domains/session/surface/composer-state-store";import { REDO_NOTICE, projectTracksFiles, undoNotice } from "./undo-notice";+import { commandTemplateLabel } from "./review-message";export type SessionCommandTarget = {workspaceId: string;@@ -171,7 +172,9 @@ export function useUndoRedo(target: SessionCommandTarget) {const reverted = await revertSession(client, target.sessionId, message.info.id);applySessionRevert(target.workspaceId, reverted);// The turn's prompt goes back into an empty composer (a draft being written is left alone).- const text = userMessageText(message);+ // A review or fix turn goes back as the command it was typed as, not its expanded prompt.+ const sent = userMessageText(message);+ const text = commandTemplateLabel(sent) ?? sent;const draft = getComposerDraft(useComposerStateStore.getState(), target.sessionId);if (text && !draft.trim()) {useComposerStateStore.getState().replaceDraft(target.sessionId, text);diff --git a/apps/app/src/react-app/domains/session/surface/session-surface.tsx b/apps/app/src/react-app/domains/session/surface/session-surface.tsxindex f00b3b01..a22b354c 100644--- a/apps/app/src/react-app/domains/session/surface/session-surface.tsx+++ b/apps/app/src/react-app/domains/session/surface/session-surface.tsx@@ -1594,6 +1594,10 @@ export function SessionSurface(props: SessionSurfaceProps) {});const revertMessageId = snapshot?.session.revert?.messageID ?? null;const revertedMessageCount = snapshot && revertMessageId ? hiddenMessageCount(snapshot, revertMessageId) : 0;+ // An undo rewinds the transcript below the last send's baseline: nothing is being waited for any more.+ useEffect(() => {+ if (revertMessageId) setAwaitingAssistantBaseline(null);+ }, [revertMessageId]);const liveStatus = statusState ?? snapshot?.status ?? IDLE_STATUS;const preparingCloudTools = props.cloudMcpSubmissionState.status === "checking" ||props.cloudMcpSubmissionState.status === "repairing";