From 388a9f96ea3e26e6ed71488ca38be3f3256eaed6 Mon Sep 17 00:00:00 2001 From: Akarshan Date: Thu, 30 Oct 2025 12:46:54 +0530 Subject: [PATCH] refactor: reorder postMessageProcessing parameters for clarity Rearrange the `postMessageProcessing` signature so that `isProactiveMode` now precedes the internal `currentStepCount`. This change improves the logical flow of the API: the proactive flag is a public flag that callers should set, whereas the step counter is an internal bookkeeping value. The updated order also aligns the JSDoc comment with the implementation. All related tests were updated to reflect the new parameter order, and comments were adjusted to describe the internal counter in the correct place. No functional behavior changes occur; the change simply makes the API easier to read and maintain. --- web-app/src/lib/__tests__/completion.test.ts | 3 --- web-app/src/lib/completion.ts | 8 ++++---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/web-app/src/lib/__tests__/completion.test.ts b/web-app/src/lib/__tests__/completion.test.ts index e8bd84b86..f0524347f 100644 --- a/web-app/src/lib/__tests__/completion.test.ts +++ b/web-app/src/lib/__tests__/completion.test.ts @@ -673,7 +673,6 @@ describe('completion.ts', () => { [], // tools undefined, // updateStreamingUI undefined, // maxToolSteps - undefined, // currentStepCount true // isProactiveMode - Correctly set to true ) @@ -733,7 +732,6 @@ describe('completion.ts', () => { [], // tools undefined, // updateStreamingUI undefined, // maxToolSteps - undefined, // currentStepCount false // isProactiveMode - Correctly set to false ) @@ -788,7 +786,6 @@ describe('completion.ts', () => { [], // tools undefined, // updateStreamingUI undefined, // maxToolSteps - undefined, // currentStepCount true // isProactiveMode - Still set to true, but the non-browser tool should skip the proactive step ) diff --git a/web-app/src/lib/completion.ts b/web-app/src/lib/completion.ts index 9e6be6776..8a8eb9cd9 100644 --- a/web-app/src/lib/completion.ts +++ b/web-app/src/lib/completion.ts @@ -534,8 +534,8 @@ const filterOldProactiveScreenshots = (builder: CompletionMessagesBuilder) => { * @param tools * @param updateStreamingUI * @param maxToolSteps - * @param currentStepCount - Internal counter for recursive calls (do not set manually) * @param isProactiveMode + * @param currentStepCount - Internal counter for recursive calls (do not set manually) */ export const postMessageProcessing = async ( calls: ChatCompletionMessageToolCall[], @@ -554,8 +554,8 @@ export const postMessageProcessing = async ( tools: MCPTool[] = [], updateStreamingUI?: (content: ThreadMessage) => void, maxToolSteps: number = 20, - currentStepCount: number = 0, - isProactiveMode: boolean = false + isProactiveMode: boolean = false, + currentStepCount: number = 0 ): Promise => { // Initialize/get the current total thinking time from metadata // This value is passed from sendMessage (initial completion time) or previous recursive call @@ -877,8 +877,8 @@ export const postMessageProcessing = async ( tools, updateStreamingUI, maxToolSteps, + isProactiveMode, nextStepCount, // Pass the incremented step count - isProactiveMode ) } }