test(coding-agent): align ctx fixtures with settled-component cache and todo commit-on-execute

- Added transcriptMessageComponents to every InteractiveMode ctx test literal; #6033's reuse cache made the field required and addMessageToChat populates it unconditionally.
- Wired setTodoPhases into the eager-todo ToolSession fixture to mirror sdk.ts; the test relied on the stale message_end todo replay #6148 removed.
This commit is contained in:
can1357
2026-07-22 21:32:12 +02:00
parent dd80dcd035
commit 58a2acd330
25 changed files with 28 additions and 0 deletions
@@ -129,6 +129,8 @@ describe("AgentSession eager todo enforcement", () => {
getSessionFile: () => sessionManager.getSessionFile() ?? null,
getSessionSpawns: () => "*",
settings,
// Mirrors sdk.ts wiring: TodoTool commits phases during execute (#6148 removed the message_end replay).
setTodoPhases: phases => session?.setTodoPhases(phases),
};
const todoTool = new TodoTool(toolSession);
const mockBashTool: AgentTool = {
@@ -103,6 +103,7 @@ function makeFailingGuestContext(failure: Error): InteractiveModeContext {
compactionQueuedMessages: [],
streamingComponent: undefined,
streamingMessage: undefined,
transcriptMessageComponents: new WeakMap(),
pendingTools: new Map(),
loadingAnimation: undefined,
statusLine: {
@@ -68,6 +68,7 @@ function makeGuestContext(counts: number[]): InteractiveModeContext {
compactionQueuedMessages: [],
streamingComponent: undefined,
streamingMessage: undefined,
transcriptMessageComponents: new WeakMap(),
pendingTools: new Map(),
loadingAnimation: undefined,
statusLine: {
@@ -211,6 +211,7 @@ async function makeHarness(opts?: { readOnly?: boolean }): Promise<GuestUiHarnes
compactionQueuedMessages: [],
streamingComponent: undefined,
streamingMessage: undefined,
transcriptMessageComponents: new WeakMap(),
pendingTools: new Map(),
loadingAnimation: undefined,
statusLine: {
@@ -65,6 +65,7 @@ function createFixture(opts: {
updateEditorTopBorder: vi.fn(),
streamingComponent,
streamingMessage: opts.streamingMessage,
transcriptMessageComponents: new WeakMap(),
pendingTools: new Map(),
noteDisplayableThinkingContent: vi.fn(() => false),
};
@@ -110,6 +110,7 @@ function createFixture(streamingMessage?: AssistantMessage) {
streamingMessage,
chatContainer,
proseOnlyThinking: true,
transcriptMessageComponents: new WeakMap(),
pendingTools: new Map(),
flushCompactionQueue: vi.fn(async () => {}),
showPinnedError,
@@ -69,6 +69,7 @@ function createFixture() {
ui,
settings,
chatContainer,
transcriptMessageComponents: new WeakMap(),
pendingTools,
toolOutputExpanded: false,
effectiveHideThinkingBlock: false,
@@ -14,6 +14,7 @@ function createContext() {
isInitialized: true,
init: vi.fn(async () => {}),
ui: { requestRender: vi.fn() },
transcriptMessageComponents: new WeakMap(),
pendingTools: new Map(),
statusLine: { invalidate: vi.fn(), markActivityStart: vi.fn() },
updateEditorTopBorder: vi.fn(),
@@ -775,6 +775,7 @@ function createEventControllerFixture() {
updateEditorTopBorder: vi.fn(),
addMessageToChat,
updatePendingMessagesDisplay,
transcriptMessageComponents: new WeakMap(),
pendingTools: new Map(),
session: {},
get viewSession() {
@@ -24,6 +24,7 @@ function createInitialRenderHarness(): { ctx: InteractiveModeContext; helpers: U
pendingMessagesContainer: new Container(),
pendingBashComponents: [],
pendingPythonComponents: [],
transcriptMessageComponents: new WeakMap(),
pendingTools: new Map(),
ui: { requestRender: vi.fn() },
present: (content: Component | readonly Component[]) => {
@@ -136,6 +137,7 @@ describe("InteractiveMode.showStatus", () => {
test("preserves optimistic user signatures when rebuilding transcript state", () => {
const ctx = {
chatContainer: new Container(),
transcriptMessageComponents: new WeakMap(),
pendingTools: new Map(),
ui: { requestRender: vi.fn() },
viewSession: { isStreaming: false },
@@ -59,6 +59,7 @@ function makeRenderCtx(transcript: SessionContext): { ctx: InteractiveModeContex
pendingMessagesContainer: new Container(),
pendingBashComponents: [],
pendingPythonComponents: [],
transcriptMessageComponents: new WeakMap(),
pendingTools: new Map(),
statusLine: { invalidate: vi.fn() },
updateEditorBorderColor: vi.fn(),
@@ -413,6 +413,7 @@ describe("UiHelpers.renderSessionContext collapses repeated todo snapshots", ()
let helpers!: UiHelpers;
const ctx = {
chatContainer,
transcriptMessageComponents: new WeakMap(),
pendingTools: new Map(),
ui: { requestRender: vi.fn() },
statusLine: { invalidate: vi.fn() },
@@ -489,6 +490,7 @@ describe("UiHelpers.renderSessionContext collapses repeated todo snapshots", ()
let helpers!: UiHelpers;
const ctx = {
chatContainer,
transcriptMessageComponents: new WeakMap(),
pendingTools: new Map(),
ui: { requestRender: vi.fn() },
statusLine: { invalidate: vi.fn() },
@@ -57,6 +57,7 @@ function createFixture(opts: { isStreaming: boolean }) {
isInitialized: true,
init: vi.fn(async () => {}),
chatContainer,
transcriptMessageComponents: new WeakMap(),
pendingTools: new Map(),
ui: { requestRender: vi.fn() },
statusLine: { invalidate: vi.fn() },
@@ -51,6 +51,7 @@ function createFixture(streamingMessage: AssistantMessage) {
updateEditorTopBorder: vi.fn(),
streamingComponent: { updateContent: vi.fn(), markTranscriptBlockFinalized: vi.fn() },
streamingMessage,
transcriptMessageComponents: new WeakMap(),
pendingTools,
noteDisplayableThinkingContent: vi.fn(() => false),
chatContainer: { addChild: vi.fn() },
@@ -70,6 +70,7 @@ function createContext(
loadingAnimation: undefined,
streamingComponent: undefined,
streamingMessage: undefined,
transcriptMessageComponents: new WeakMap(),
pendingTools: new Map<string, unknown>(),
flushPendingModelSwitch: async () => {},
flushPendingCommandOutput: () => {},
@@ -18,6 +18,7 @@ function createContext() {
settings: { get: () => false },
statusLine: { invalidate: vi.fn(), markActivityStart: vi.fn(), markActivityEnd: vi.fn() },
updateEditorTopBorder: vi.fn(),
transcriptMessageComponents: new WeakMap(),
pendingTools,
hideThinkingBlock: false,
setWorkingMessage,
@@ -53,6 +53,7 @@ function createContext(options: { terminalProgress?: boolean } = {}) {
statusLine: { invalidate: vi.fn(), markActivityStart: vi.fn(), markActivityEnd: vi.fn() },
updateEditorTopBorder: vi.fn(),
flushPendingCommandOutput: vi.fn(),
transcriptMessageComponents: new WeakMap(),
pendingTools: new Map<string, unknown>(),
hideThinkingBlock: false,
setWorkingMessage: vi.fn(),
@@ -61,6 +61,7 @@ function createContext(options: {
locallySubmittedUserSignatures: new Set<string>(options.locallySubmittedSignatures ?? []),
clearOptimisticUserMessage,
replaceOptimisticUserMessage,
transcriptMessageComponents: new WeakMap(),
pendingTools: new Map(),
viewSession: { isStreaming: false },
} as unknown as InteractiveModeContext;
@@ -80,6 +80,7 @@ function createFixture() {
updateEditorTopBorder: vi.fn(),
ui: { requestRender: vi.fn(), imageBudget: undefined },
chatContainer,
transcriptMessageComponents: new WeakMap(),
pendingTools: new Map(),
noteDisplayableThinkingContent: vi.fn(() => false),
settings: { get: () => false },
@@ -20,6 +20,7 @@ function createContext() {
statusLine: { invalidate: vi.fn(), markActivityStart: vi.fn(), markActivityEnd: vi.fn() },
updateEditorTopBorder: vi.fn(),
flushPendingCommandOutput: vi.fn(),
transcriptMessageComponents: new WeakMap(),
pendingTools: new Map<string, unknown>(),
hideThinkingBlock: false,
setWorkingMessage: vi.fn(),
@@ -65,6 +65,7 @@ describe("EventController async update finalization", () => {
statusLine: { invalidate: vi.fn() },
updateEditorTopBorder: vi.fn(),
toolOutputExpanded: false,
transcriptMessageComponents: new WeakMap(),
pendingTools,
chatContainer,
session: { getToolByName: () => undefined, isStreaming: true },
@@ -58,6 +58,7 @@ function createFixture(streamingMessage: AssistantMessage) {
updateEditorTopBorder: vi.fn(),
streamingComponent,
streamingMessage,
transcriptMessageComponents: new WeakMap(),
pendingTools: new Map(),
noteDisplayableThinkingContent: vi.fn(() => false),
chatContainer: { addChild: vi.fn((child: { seal?(): void }) => mountedComponents.push(child)) },
@@ -147,6 +147,7 @@ function makeRenderCtx(
pendingMessagesContainer: new Container(),
pendingBashComponents: [],
pendingPythonComponents: [],
transcriptMessageComponents: new WeakMap(),
pendingTools: new Map(),
statusLine: { invalidate: vi.fn() },
updateEditorBorderColor: vi.fn(),
@@ -109,6 +109,7 @@ function createHarness(): Harness {
pendingMessagesContainer: new Container(),
pendingBashComponents: [],
pendingPythonComponents: [],
transcriptMessageComponents: new WeakMap(),
pendingTools: new Map(),
ui: { requestRender: vi.fn() },
isBackgrounded: false,
@@ -58,6 +58,7 @@ function makeHarness(showTokenUsage: boolean): { ctx: InteractiveModeContext; he
let helpers: UiHelpers;
const ctx = {
chatContainer: new Container(),
transcriptMessageComponents: new WeakMap(),
pendingTools: new Map(),
ui: { requestRender: vi.fn() },
statusLine: { invalidate: vi.fn() },