Accept task settings in init task (#6342)
* v3.28.5 Release Notes * changeset version bump * Updating CHANGELOG.md format * Update changelog for patch release --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: Kevin Bond <kevin@Kevins-MacBook-Pro.local> * Add task-specific settings caching to StateManager (#6171) * Add task-specific settings caching to StateManager Implement per-task settings storage with automatic loading/clearing: - Add taskStateCache for isolated task settings - Load task settings on task creation and reinitialize - Clear task settings cache when tasks end - Prioritize task cache over global state in getters * update error wording for taskSettings read failure * add missing return statement in promise.all * fix: persist pending task settings before clearing cache Changed clearTaskSettings to be async and ensure any pending task state changes are persisted to storage before clearing the in-memory cache. This prevents potential data loss when a task ends with unpersisted settings still in the pending state queue. - Made clearTaskSettings async and added optional taskId parameter - Added logic to persist pending task state batch before clearing - Updated controller to await clearTaskSettings and pass taskId * add ability to set task setting overrides in newtask rpc * spread proto object keys that don't need to be transformed and filter undefined values * use most Settings fields in TaskSettings proto and convert fields that do not directly map to the application typescripts type of Settings * accept taskSettings in newTask RPC and save them to task state * remove test taskSettings in useMessageHandlers --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: Kevin Bond <kevin@Kevins-MacBook-Pro.local>
This commit is contained in:
7 files changed
+275
-29
No files matched your search
@@ -1,14 +1,75 @@
|
||||
import { Empty } from "@shared/proto/cline/common"
|
||||
import { PlanActMode, OpenaiReasoningEffort as ProtoOpenaiReasoningEffort } from "@shared/proto/cline/state"
|
||||
import { NewTaskRequest } from "@shared/proto/cline/task"
|
||||
import { Settings } from "@/core/storage/state-keys"
|
||||
import { convertProtoToApiProvider } from "@/shared/proto-conversions/models/api-configuration-conversion"
|
||||
import { DEFAULT_BROWSER_SETTINGS } from "../../../shared/BrowserSettings"
|
||||
import { convertProtoToAutoApprovalSettings } from "../../../shared/proto-conversions/models/auto-approval-settings-conversion"
|
||||
import { Controller } from ".."
|
||||
|
||||
/**
|
||||
* Creates a new task with the given text and optional images
|
||||
* @param controller The controller instance
|
||||
* @param request The new task request containing text and optional images
|
||||
* @param request The new task request containing text and optional images, and optional task settings
|
||||
* @returns Empty response
|
||||
*/
|
||||
export async function newTask(controller: Controller, request: NewTaskRequest): Promise<Empty> {
|
||||
await controller.initTask(request.text, request.images, request.files)
|
||||
const convertOpenaiReasoningEffort = (effort: ProtoOpenaiReasoningEffort): string => {
|
||||
switch (effort) {
|
||||
case ProtoOpenaiReasoningEffort.LOW:
|
||||
return "low"
|
||||
case ProtoOpenaiReasoningEffort.MEDIUM:
|
||||
return "medium"
|
||||
case ProtoOpenaiReasoningEffort.HIGH:
|
||||
return "high"
|
||||
case ProtoOpenaiReasoningEffort.MINIMAL:
|
||||
return "minimal"
|
||||
default:
|
||||
return "medium"
|
||||
}
|
||||
}
|
||||
|
||||
const convertPlanActMode = (mode: PlanActMode): string => {
|
||||
return mode === PlanActMode.PLAN ? "plan" : "act"
|
||||
}
|
||||
|
||||
const filteredTaskSettings: Partial<Settings> = Object.fromEntries(
|
||||
Object.entries({
|
||||
...request.taskSettings,
|
||||
...(request.taskSettings?.autoApprovalSettings && {
|
||||
autoApprovalSettings: convertProtoToAutoApprovalSettings({
|
||||
...request.taskSettings.autoApprovalSettings,
|
||||
metadata: {},
|
||||
}),
|
||||
}),
|
||||
...(request.taskSettings?.browserSettings && {
|
||||
browserSettings: {
|
||||
viewport: request.taskSettings.browserSettings.viewport || DEFAULT_BROWSER_SETTINGS.viewport,
|
||||
remoteBrowserHost: request.taskSettings.browserSettings.remoteBrowserHost,
|
||||
remoteBrowserEnabled: request.taskSettings.browserSettings.remoteBrowserEnabled,
|
||||
chromeExecutablePath: request.taskSettings.browserSettings.chromeExecutablePath,
|
||||
disableToolUse: request.taskSettings.browserSettings.disableToolUse,
|
||||
customArgs: request.taskSettings.browserSettings.customArgs,
|
||||
},
|
||||
}),
|
||||
...(request.taskSettings?.openaiReasoningEffort !== undefined && {
|
||||
openaiReasoningEffort: convertOpenaiReasoningEffort(request.taskSettings.openaiReasoningEffort),
|
||||
}),
|
||||
...(request.taskSettings?.mode !== undefined && {
|
||||
mode: convertPlanActMode(request.taskSettings.mode),
|
||||
}),
|
||||
...(request.taskSettings?.customPrompt === "compact" && {
|
||||
customPrompt: "compact",
|
||||
}),
|
||||
...(request.taskSettings?.planModeApiProvider !== undefined && {
|
||||
planModeApiProvider: convertProtoToApiProvider(request.taskSettings.planModeApiProvider),
|
||||
}),
|
||||
...(request.taskSettings?.actModeApiProvider !== undefined && {
|
||||
actModeApiProvider: convertProtoToApiProvider(request.taskSettings.actModeApiProvider),
|
||||
}),
|
||||
}).filter(([_, value]) => value !== undefined),
|
||||
)
|
||||
|
||||
await controller.initTask(request.text, request.images, request.files, undefined, filteredTaskSettings)
|
||||
return Empty.create()
|
||||
}
|
||||
Reference in new issue
Block a user