From 20dcc41de0cf2be427454a76a1ffa9ed9eb06176 Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Tue, 2 Sep 2025 09:36:41 -0700 Subject: [PATCH] fix: formatting --- extensions/cli/src/e2e/resume-flag.test.ts | 6 +- .../vscode/e2e/actions/Global.actions.ts | 99 +++++++++---------- .../gui/ToolCallDiv/SimpleToolCallUI.tsx | 11 ++- gui/src/redux/thunks/streamNormalInput.ts | 34 ++++--- 4 files changed, 80 insertions(+), 70 deletions(-) diff --git a/extensions/cli/src/e2e/resume-flag.test.ts b/extensions/cli/src/e2e/resume-flag.test.ts index a6d29da27..c1fa8344b 100644 --- a/extensions/cli/src/e2e/resume-flag.test.ts +++ b/extensions/cli/src/e2e/resume-flag.test.ts @@ -46,7 +46,7 @@ describe("E2E: Resume Flag", () => { // Verify that a session file was created const sessionDir = path.join(context.testDir, ".continue", "sessions"); const sessionFiles = (await fs.readdir(sessionDir)).filter( - f => f.endsWith('.json') && f !== 'sessions.json' + (f) => f.endsWith(".json") && f !== "sessions.json", ); expect(sessionFiles).toHaveLength(1); @@ -139,7 +139,7 @@ describe("E2E: Resume Flag", () => { // Verify the first session was saved correctly const sessionDir = path.join(context.testDir, ".continue", "sessions"); let sessionFiles = (await fs.readdir(sessionDir)).filter( - f => f.endsWith('.json') && f !== 'sessions.json' + (f) => f.endsWith(".json") && f !== "sessions.json", ); expect(sessionFiles).toHaveLength(1); @@ -172,7 +172,7 @@ describe("E2E: Resume Flag", () => { // Check that the session file contains both messages sessionFiles = (await fs.readdir(sessionDir)).filter( - f => f.endsWith('.json') && f !== 'sessions.json' + (f) => f.endsWith(".json") && f !== "sessions.json", ); sessionFile = sessionFiles[0]; sessionPath = path.join(sessionDir, sessionFile); diff --git a/extensions/vscode/e2e/actions/Global.actions.ts b/extensions/vscode/e2e/actions/Global.actions.ts index e6f8a3bee..d77ac69e1 100644 --- a/extensions/vscode/e2e/actions/Global.actions.ts +++ b/extensions/vscode/e2e/actions/Global.actions.ts @@ -4,7 +4,7 @@ import { InputBox, TextEditor, VSBrowser, - Workbench + Workbench, } from "vscode-extension-tester"; import { DEFAULT_TIMEOUT } from "../constants"; @@ -86,76 +86,69 @@ export class GlobalActions { static async setNextEditEnabled(enabled: boolean) { const workbench = new Workbench(); - - await workbench.openCommandPrompt(); - process.env.CONTINUE_E2E_NON_NEXT_EDIT_TEST = 'true'; - + await workbench.openCommandPrompt(); + process.env.CONTINUE_E2E_NON_NEXT_EDIT_TEST = "true"; + // Initial wait and clear await TestUtils.waitForTimeout(1000); await GlobalActions.clearAllNotifications(); - + const statusBar = await workbench.getStatusBar(); - + // Robust element finding with text validation - const continueItem = await TestUtils.waitForSuccess( - async () => { - // Clear any new notifications - try { - await GlobalActions.clearAllNotifications(); - } catch (e) { - // Ignore + const continueItem = await TestUtils.waitForSuccess(async () => { + // Clear any new notifications + try { + await GlobalActions.clearAllNotifications(); + } catch (e) { + // Ignore + } + + const element = await statusBar.findElement( + By.xpath("//*[contains(text(), 'Continue')]"), + ); + + // Validate we can get text + const text = await element.getText(); + if (!text || text.trim() === "") { + // Try alternative methods + const textContent = await element.getAttribute("textContent"); + if (!textContent || textContent.trim() === "") { + throw new Error("Text not yet available"); } - - const element = await statusBar.findElement( - By.xpath("//*[contains(text(), 'Continue')]") - ); - - // Validate we can get text - const text = await element.getText(); - if (!text || text.trim() === '') { - // Try alternative methods - const textContent = await element.getAttribute('textContent'); - if (!textContent || textContent.trim() === '') { - throw new Error('Text not yet available'); - } - } - - return element; - }, - DEFAULT_TIMEOUT.MD - ); + } + + return element; + }, DEFAULT_TIMEOUT.MD); // Get text with retry - const text = await TestUtils.waitForSuccess( - async () => { - const itemText = await continueItem.getText(); - if (!itemText || itemText.trim() === '') { - // Fallback to textContent - const textContent = await continueItem.getAttribute('textContent'); - if (textContent && textContent.trim() !== '') { - return textContent; - } - throw new Error('Text content not yet available'); + const text = await TestUtils.waitForSuccess(async () => { + const itemText = await continueItem.getText(); + if (!itemText || itemText.trim() === "") { + // Fallback to textContent + const textContent = await continueItem.getAttribute("textContent"); + if (textContent && textContent.trim() !== "") { + return textContent; } - return itemText; - }, - DEFAULT_TIMEOUT.MD - ); - + throw new Error("Text content not yet available"); + } + return itemText; + }, DEFAULT_TIMEOUT.MD); + console.log("Final text:", text); - - const hasNE = text.includes('(NE)'); + + const hasNE = text.includes("(NE)"); console.log("hasNE:", hasNE); - + if (hasNE !== enabled) { - await workbench.executeCommand('Continue: Toggle Next Edit'); + await workbench.executeCommand("Continue: Toggle Next Edit"); // Clear any resulting notifications await TestUtils.waitForTimeout(500); await GlobalActions.clearAllNotifications(); } } - + static async disableNextEdit() { await this.setNextEditEnabled(false); } diff --git a/gui/src/pages/gui/ToolCallDiv/SimpleToolCallUI.tsx b/gui/src/pages/gui/ToolCallDiv/SimpleToolCallUI.tsx index 578a24faf..bbed5b444 100644 --- a/gui/src/pages/gui/ToolCallDiv/SimpleToolCallUI.tsx +++ b/gui/src/pages/gui/ToolCallDiv/SimpleToolCallUI.tsx @@ -1,5 +1,12 @@ import { Tool, ToolCallState } from "core"; -import { ComponentType, useContext, useEffect, useMemo, useRef, useState } from "react"; +import { + ComponentType, + useContext, + useEffect, + useMemo, + useRef, + useState, +} from "react"; import { ContextItemsPeekItem, openContextItem, @@ -42,7 +49,7 @@ export function SimpleToolCallUI({ !hasAutoOpenedError.current ) { hasAutoOpenedError.current = true; - + // For single error items, open directly if (shownContextItems.length === 1) { openContextItem(shownContextItems[0], ideMessenger); diff --git a/gui/src/redux/thunks/streamNormalInput.ts b/gui/src/redux/thunks/streamNormalInput.ts index ea4bd47ad..d332aae50 100644 --- a/gui/src/redux/thunks/streamNormalInput.ts +++ b/gui/src/redux/thunks/streamNormalInput.ts @@ -1,5 +1,11 @@ import { createAsyncThunk, unwrapResult } from "@reduxjs/toolkit"; -import { ContextItem, LLMFullCompletionOptions, Tool, ToolCallState, ToolPolicy } from "core"; +import { + ContextItem, + LLMFullCompletionOptions, + Tool, + ToolCallState, + ToolPolicy, +} from "core"; import { getRuleId } from "core/llm/rules/getSystemMessageWithRules"; import { ToCoreProtocol } from "core/protocol"; import { selectActiveTools } from "../selectors/selectActiveTools"; @@ -60,7 +66,7 @@ async function evaluateToolPolicy( args: parsedArgs, }); } catch (error) { - // If request fails, return disabled + // If request fails, return disabled return "disabled"; } @@ -77,7 +83,10 @@ async function evaluateToolPolicy( if (basePolicy === "disabled") { return "disabled"; // Cannot override disabled } - if (basePolicy === "allowedWithPermission" && dynamicPolicy === "allowedWithoutPermission") { + if ( + basePolicy === "allowedWithPermission" && + dynamicPolicy === "allowedWithoutPermission" + ) { return "allowedWithPermission"; // Cannot make more lenient } @@ -93,7 +102,8 @@ async function handleToolCallExecution( getState: () => RootState, activeTools: Tool[], ideMessenger: IIdeMessenger, -): Promise { // Return whether all tools were auto-approved +): Promise { + // Return whether all tools were auto-approved const newState = getState(); const toolSettings = newState.ui.toolSettings; const allToolCallStates = selectCurrentToolCalls(newState); @@ -105,7 +115,7 @@ async function handleToolCallExecution( // If no generating tool calls, nothing to process if (toolCallStates.length === 0) { - return false; // No tools to process, need to set inactive + return false; // No tools to process, need to set inactive } // Check if ALL tool calls are auto-approved using dynamic evaluation @@ -113,16 +123,16 @@ async function handleToolCallExecution( evaluateToolPolicy(toolCallState, toolSettings, activeTools, ideMessenger), ); const policies = await Promise.all(policyPromises); - + // Handle disabled tool calls and set others as generated const allAutoApproved = await Promise.all( toolCallStates.map(async (toolCallState, index) => { const policy = policies[index]; - + if (policy === "disabled") { // Mark as errored instead of generated dispatch(errorToolCall({ toolCallId: toolCallState.toolCallId })); - + // Get the actual command from parsed arguments if it's runTerminalCommand const parsedArgs = toolCallState.parsedArgs || {}; let command = toolCallState.toolCall.function.name; @@ -132,7 +142,7 @@ async function handleToolCallExecution( ) { command = parsedArgs.command; } - + // Add error message explaining why it's disabled dispatch( updateToolCallOutput({ @@ -167,7 +177,7 @@ async function handleToolCallExecution( const nonDisabledToolCalls = toolCallStates.filter( (_, index) => policies[index] !== "disabled", ); - + const toolCallPromises = nonDisabledToolCalls.map(async (toolCallState) => { const response = await dispatch( callToolById({ toolCallId: toolCallState.toolCallId }), @@ -177,7 +187,7 @@ async function handleToolCallExecution( await Promise.all(toolCallPromises); } - + return allAutoApproved; } @@ -369,7 +379,7 @@ export const streamNormalInput = createAsyncThunk< activeTools, extra.ideMessenger, ); - + // Only set inactive if not all tools were auto-approved // This prevents UI flashing for auto-approved tools if (!allAutoApproved) {