From 9331b95eee79003e8b4b0fbee2c7a30238af2feb Mon Sep 17 00:00:00 2001 From: lycaon Date: Thu, 16 Jul 2026 04:49:05 -0600 Subject: [PATCH] style(session): satisfy xdev rewind checks --- .../coding-agent/src/session/agent-session.ts | 22 +++++-------------- ...t-session-checkpoint-rewind-branch.test.ts | 14 +++++------- 2 files changed, 11 insertions(+), 25 deletions(-) diff --git a/packages/coding-agent/src/session/agent-session.ts b/packages/coding-agent/src/session/agent-session.ts index 5bbdf5b79..f731b4089 100644 --- a/packages/coding-agent/src/session/agent-session.ts +++ b/packages/coding-agent/src/session/agent-session.ts @@ -545,16 +545,11 @@ type SemanticToolResult = { */ function semanticToolResult(toolName: string | undefined, result: unknown): SemanticToolResult | undefined { if (toolName === "checkpoint" || toolName === "rewind") { - const details = - result && typeof result === "object" && "details" in result ? result.details : undefined; + const details = result && typeof result === "object" && "details" in result ? result.details : undefined; return { toolName, details }; } const dispatch = writeDeviceDispatch(toolName ?? "", result); - if ( - !dispatch || - dispatch.mode !== "execute" || - (dispatch.tool !== "checkpoint" && dispatch.tool !== "rewind") - ) { + if (dispatch?.mode !== "execute" || (dispatch.tool !== "checkpoint" && dispatch.tool !== "rewind")) { return undefined; } return { toolName: dispatch.tool, details: dispatch.inner }; @@ -4410,13 +4405,7 @@ export class AgentSession { this.#invalidateFileCacheForPath(editedPath); } const phases = details?.phases; - if ( - toolName === "todo" && - !isError && - details && - Array.isArray(phases) && - phases.every(isTodoPhase) - ) { + if (toolName === "todo" && !isError && details && Array.isArray(phases) && phases.every(isTodoPhase)) { this.setTodoPhases(phases); if (this.#isTodoInitResult(details, toolCallId)) { this.#scheduleReplanTitleRefresh(); @@ -4447,14 +4436,13 @@ export class AgentSession { checkpointMessageCount: this.agent.state.messages.length, checkpointEntryId, startedAt: - (semanticDetails && stringProperty(semanticDetails, "startedAt")) ?? - new Date().toISOString(), + (semanticDetails && stringProperty(semanticDetails, "startedAt")) ?? new Date().toISOString(), }; this.#pendingRewindReport = undefined; this.#lastCompletedRewind = undefined; } if (semanticResult?.toolName === "rewind" && !isError && this.#checkpointState) { - const detailReport = semanticDetails ? stringProperty(semanticDetails, "report")?.trim() ?? "" : ""; + const detailReport = semanticDetails ? (stringProperty(semanticDetails, "report")?.trim() ?? "") : ""; const textReport = content?.find(part => part.type === "text")?.text?.trim() ?? ""; const report = detailReport || textReport; if (report.length > 0) { diff --git a/packages/coding-agent/test/agent-session-checkpoint-rewind-branch.test.ts b/packages/coding-agent/test/agent-session-checkpoint-rewind-branch.test.ts index bfe4f9b2f..7e3098614 100644 --- a/packages/coding-agent/test/agent-session-checkpoint-rewind-branch.test.ts +++ b/packages/coding-agent/test/agent-session-checkpoint-rewind-branch.test.ts @@ -35,10 +35,7 @@ const xdevWriteTool: AgentTool = { const args = parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {}; const goal = "goal" in args && typeof args.goal === "string" ? args.goal : undefined; const report = "report" in args && typeof args.report === "string" ? args.report : undefined; - const inner = - tool === "checkpoint" - ? { goal, startedAt: "2026-01-01T00:00:00.000Z" } - : { report, rewound: true }; + const inner = tool === "checkpoint" ? { goal, startedAt: "2026-01-01T00:00:00.000Z" } : { report, rewound: true }; return { content: [{ type: "text" as const, text: `${tool} via xdev` }], details: { @@ -624,9 +621,10 @@ describe("AgentSession checkpoint rewind branch context", () => { startedAt: "2026-01-01T00:00:00.000Z", }); expect(reloadedSession.getLastCompletedRewind()).toBeUndefined(); - await expect(rewindToolForSession(reloadedSession).execute("call_rewind_after_xdev_resume", { - report: "post-resume findings", - })).resolves.toMatchObject({ details: { report: "post-resume findings", rewound: true } }); + await expect( + rewindToolForSession(reloadedSession).execute("call_rewind_after_xdev_resume", { + report: "post-resume findings", + }), + ).resolves.toMatchObject({ details: { report: "post-resume findings", rewound: true } }); }); - });