From f3daebf49fd0f75a2ceec92446407d8e90c6d438 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Thu, 27 Nov 2025 16:07:24 +0530 Subject: [PATCH 1/4] chore: retry cli tests on macos --- extensions/cli/vitest.config.ts | 1 + extensions/cli/vitest.e2e.config.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/extensions/cli/vitest.config.ts b/extensions/cli/vitest.config.ts index 81b6c4b7f..5f8f22c11 100644 --- a/extensions/cli/vitest.config.ts +++ b/extensions/cli/vitest.config.ts @@ -20,6 +20,7 @@ export default defineConfig({ }, testTimeout: 30000, hookTimeout: 30000, + retry: process.env.CI && process.platform === "darwin" ? 2 : 0, }, resolve: { extensions: [".js", ".ts", ".tsx", ".json"], diff --git a/extensions/cli/vitest.e2e.config.ts b/extensions/cli/vitest.e2e.config.ts index 53d6d8210..520a88bb5 100644 --- a/extensions/cli/vitest.e2e.config.ts +++ b/extensions/cli/vitest.e2e.config.ts @@ -8,6 +8,7 @@ export default defineConfig({ include: ["src/e2e/**/*.test.ts"], testTimeout: 30000, hookTimeout: 30000, + retry: process.env.CI && process.platform === "darwin" ? 2 : 0, }, resolve: { extensions: [".js", ".ts", ".tsx", ".json"], From 12040b609f8eae0f78643809b716958952478d28 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Tue, 2 Dec 2025 19:15:49 +0530 Subject: [PATCH 3/4] fix(cli): wait for tui to update in test --- .../ui/__tests__/TUIChat.editMessage.test.tsx | 29 ++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/extensions/cli/src/ui/__tests__/TUIChat.editMessage.test.tsx b/extensions/cli/src/ui/__tests__/TUIChat.editMessage.test.tsx index 9e6a92874..73af37d50 100644 --- a/extensions/cli/src/ui/__tests__/TUIChat.editMessage.test.tsx +++ b/extensions/cli/src/ui/__tests__/TUIChat.editMessage.test.tsx @@ -1,4 +1,18 @@ -import { testBothModes, renderInMode } from "./TUIChat.dualModeHelper.js"; +import { renderInMode, testBothModes } from "./TUIChat.dualModeHelper.js"; + +async function waitForCondition( + conditionFn: () => boolean, + timeoutMs = 2000, + intervalMs = 50, +): Promise { + const startTime = Date.now(); + while (Date.now() - startTime < timeoutMs) { + if (conditionFn()) { + return; + } + await new Promise((resolve) => setTimeout(resolve, intervalMs)); + } +} /** * Integration tests for the message edit feature in TUIChat @@ -10,7 +24,6 @@ import { testBothModes, renderInMode } from "./TUIChat.dualModeHelper.js"; * 4. History is rewound and new message is submitted * 5. Chat updates correctly */ - describe("TUIChat - Message Edit Feature", () => { testBothModes("double Esc should open edit selector", async (mode) => { const { lastFrame, stdin } = renderInMode(mode); @@ -119,7 +132,11 @@ describe("TUIChat - Message Edit Feature", () => { // Perform various operations stdin.write("\u001b"); stdin.write("\u001b"); // Open edit with separate Esc presses - await new Promise((resolve) => setTimeout(resolve, 100)); + + // Wait for selector to open (poll instead of fixed timeout) + await waitForCondition( + () => lastFrame()?.includes("No user messages to edit") ?? false, + ); // Verify selector opened let frame = lastFrame(); @@ -130,7 +147,11 @@ describe("TUIChat - Message Edit Feature", () => { await new Promise((resolve) => setTimeout(resolve, 50)); stdin.write("\u001b"); // Close - await new Promise((resolve) => setTimeout(resolve, 100)); + + // Wait for selector to close (poll instead of fixed timeout) + await waitForCondition( + () => !(lastFrame()?.includes("No user messages to edit") ?? true), + ); frame = lastFrame(); From 163b004ce0c51a346cc0ceb47d67c7c5d4235c7d Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Tue, 2 Dec 2025 19:16:02 +0530 Subject: [PATCH 4/4] Revert "chore: retry cli tests on macos" This reverts commit f3daebf49fd0f75a2ceec92446407d8e90c6d438. --- extensions/cli/vitest.config.ts | 1 - extensions/cli/vitest.e2e.config.ts | 1 - 2 files changed, 2 deletions(-) diff --git a/extensions/cli/vitest.config.ts b/extensions/cli/vitest.config.ts index 5f8f22c11..81b6c4b7f 100644 --- a/extensions/cli/vitest.config.ts +++ b/extensions/cli/vitest.config.ts @@ -20,7 +20,6 @@ export default defineConfig({ }, testTimeout: 30000, hookTimeout: 30000, - retry: process.env.CI && process.platform === "darwin" ? 2 : 0, }, resolve: { extensions: [".js", ".ts", ".tsx", ".json"], diff --git a/extensions/cli/vitest.e2e.config.ts b/extensions/cli/vitest.e2e.config.ts index 520a88bb5..53d6d8210 100644 --- a/extensions/cli/vitest.e2e.config.ts +++ b/extensions/cli/vitest.e2e.config.ts @@ -8,7 +8,6 @@ export default defineConfig({ include: ["src/e2e/**/*.test.ts"], testTimeout: 30000, hookTimeout: 30000, - retry: process.env.CI && process.platform === "darwin" ? 2 : 0, }, resolve: { extensions: [".js", ".ts", ".tsx", ".json"],