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
@@ -2,9 +2,33 @@ syntax = "proto3";
|
||||
|
||||
package cline;
|
||||
import "cline/common.proto";
|
||||
import "cline/state.proto";
|
||||
import "cline/models.proto";
|
||||
import "cline/browser.proto";
|
||||
option java_package = "bot.cline.proto";
|
||||
option java_multiple_files = true;
|
||||
|
||||
message AutoApprovalActions {
|
||||
bool read_files = 1;
|
||||
bool read_files_externally = 2;
|
||||
bool edit_files = 3;
|
||||
bool edit_files_externally = 4;
|
||||
bool execute_safe_commands = 5;
|
||||
bool execute_all_commands = 6;
|
||||
bool use_browser = 7;
|
||||
bool use_mcp = 8;
|
||||
}
|
||||
|
||||
// Auto approval settings for task execution
|
||||
message AutoApprovalSettings {
|
||||
int32 version = 1;
|
||||
bool enabled = 2;
|
||||
AutoApprovalActions actions = 3;
|
||||
int32 max_requests = 4;
|
||||
bool enable_notifications = 5;
|
||||
repeated string favorites = 6;
|
||||
}
|
||||
|
||||
service TaskService {
|
||||
// Cancels the currently running task
|
||||
rpc cancelTask(EmptyRequest) returns (Empty);
|
||||
@@ -36,12 +60,138 @@ service TaskService {
|
||||
rpc deleteAllTaskHistory(EmptyRequest) returns (DeleteAllTaskHistoryCount);
|
||||
}
|
||||
|
||||
// Task-specific settings
|
||||
message TaskSettings {
|
||||
string aws_region = 1;
|
||||
bool aws_use_cross_region_inference = 2;
|
||||
bool aws_bedrock_use_prompt_cache = 3;
|
||||
string aws_bedrock_endpoint = 4;
|
||||
string aws_profile = 5;
|
||||
string aws_authentication = 6;
|
||||
bool aws_use_profile = 7;
|
||||
string vertex_project_id = 8;
|
||||
string vertex_region = 9;
|
||||
string requesty_base_url = 10;
|
||||
string open_ai_base_url = 11;
|
||||
map<string, string> open_ai_headers = 12;
|
||||
string ollama_base_url = 13;
|
||||
string ollama_api_options_ctx_num = 14;
|
||||
string lm_studio_base_url = 15;
|
||||
string lm_studio_max_tokens = 16;
|
||||
string anthropic_base_url = 17;
|
||||
string gemini_base_url = 18;
|
||||
string azure_api_version = 19;
|
||||
string open_router_provider_sorting = 20;
|
||||
AutoApprovalSettings auto_approval_settings = 21;
|
||||
BrowserSettings browser_settings = 24;
|
||||
string lite_llm_base_url = 25;
|
||||
bool lite_llm_use_prompt_cache = 26;
|
||||
int32 fireworks_model_max_completion_tokens = 27;
|
||||
int32 fireworks_model_max_tokens = 28;
|
||||
string qwen_api_line = 29;
|
||||
string moonshot_api_line = 30;
|
||||
string zai_api_line = 31;
|
||||
string telemetry_setting = 32;
|
||||
string asksage_api_url = 33;
|
||||
bool plan_act_separate_models_setting = 34;
|
||||
bool enable_checkpoints_setting = 35;
|
||||
int32 request_timeout_ms = 36;
|
||||
int32 shell_integration_timeout = 37;
|
||||
string default_terminal_profile = 38;
|
||||
int32 terminal_output_line_limit = 39;
|
||||
string sap_ai_core_token_url = 40;
|
||||
string sap_ai_core_base_url = 41;
|
||||
string sap_ai_resource_group = 42;
|
||||
bool sap_ai_core_use_orchestration_mode = 43;
|
||||
string claude_code_path = 44;
|
||||
string qwen_code_oauth_path = 45;
|
||||
bool strict_plan_mode_enabled = 46;
|
||||
bool yolo_mode_toggled = 47;
|
||||
bool use_auto_condense = 48;
|
||||
string preferred_language = 49;
|
||||
OpenaiReasoningEffort openai_reasoning_effort = 50;
|
||||
PlanActMode mode = 51;
|
||||
DictationSettings dictation_settings = 52;
|
||||
FocusChainSettings focus_chain_settings = 53;
|
||||
string custom_prompt = 54;
|
||||
string dify_base_url = 55;
|
||||
double auto_condense_threshold = 56;
|
||||
string oca_base_url = 57;
|
||||
ApiProvider plan_mode_api_provider = 58;
|
||||
string plan_mode_api_model_id = 59;
|
||||
int64 plan_mode_thinking_budget_tokens = 60;
|
||||
string plan_mode_reasoning_effort = 61;
|
||||
LanguageModelChatSelector plan_mode_vs_code_lm_model_selector = 62;
|
||||
bool plan_mode_aws_bedrock_custom_selected = 63;
|
||||
string plan_mode_aws_bedrock_custom_model_base_id = 64;
|
||||
string plan_mode_open_router_model_id = 65;
|
||||
OpenRouterModelInfo plan_mode_open_router_model_info = 66;
|
||||
string plan_mode_open_ai_model_id = 67;
|
||||
OpenAiCompatibleModelInfo plan_mode_open_ai_model_info = 68;
|
||||
string plan_mode_ollama_model_id = 69;
|
||||
string plan_mode_lm_studio_model_id = 70;
|
||||
string plan_mode_lite_llm_model_id = 71;
|
||||
LiteLLMModelInfo plan_mode_lite_llm_model_info = 72;
|
||||
string plan_mode_requesty_model_id = 73;
|
||||
OpenRouterModelInfo plan_mode_requesty_model_info = 74;
|
||||
string plan_mode_together_model_id = 75;
|
||||
string plan_mode_fireworks_model_id = 76;
|
||||
string plan_mode_sap_ai_core_model_id = 77;
|
||||
string plan_mode_sap_ai_core_deployment_id = 78;
|
||||
string plan_mode_groq_model_id = 79;
|
||||
OpenRouterModelInfo plan_mode_groq_model_info = 80;
|
||||
string plan_mode_baseten_model_id = 81;
|
||||
OpenRouterModelInfo plan_mode_baseten_model_info = 82;
|
||||
string plan_mode_hugging_face_model_id = 83;
|
||||
OpenRouterModelInfo plan_mode_hugging_face_model_info = 84;
|
||||
string plan_mode_huawei_cloud_maas_model_id = 85;
|
||||
OpenRouterModelInfo plan_mode_huawei_cloud_maas_model_info = 86;
|
||||
string plan_mode_oca_model_id = 87;
|
||||
OcaModelInfo plan_mode_oca_model_info = 88;
|
||||
ApiProvider act_mode_api_provider = 89;
|
||||
string act_mode_api_model_id = 90;
|
||||
int64 act_mode_thinking_budget_tokens = 91;
|
||||
string act_mode_reasoning_effort = 92;
|
||||
LanguageModelChatSelector act_mode_vs_code_lm_model_selector = 93;
|
||||
bool act_mode_aws_bedrock_custom_selected = 94;
|
||||
string act_mode_aws_bedrock_custom_model_base_id = 95;
|
||||
string act_mode_open_router_model_id = 96;
|
||||
OpenRouterModelInfo act_mode_open_router_model_info = 97;
|
||||
string act_mode_open_ai_model_id = 98;
|
||||
OpenAiCompatibleModelInfo act_mode_open_ai_model_info = 99;
|
||||
string act_mode_ollama_model_id = 100;
|
||||
string act_mode_lm_studio_model_id = 101;
|
||||
string act_mode_lite_llm_model_id = 102;
|
||||
LiteLLMModelInfo act_mode_lite_llm_model_info = 103;
|
||||
string act_mode_requesty_model_id = 104;
|
||||
OpenRouterModelInfo act_mode_requesty_model_info = 105;
|
||||
string act_mode_together_model_id = 106;
|
||||
string act_mode_fireworks_model_id = 107;
|
||||
string act_mode_sap_ai_core_model_id = 108;
|
||||
string act_mode_sap_ai_core_deployment_id = 109;
|
||||
string act_mode_groq_model_id = 110;
|
||||
OpenRouterModelInfo act_mode_groq_model_info = 111;
|
||||
string act_mode_baseten_model_id = 112;
|
||||
OpenRouterModelInfo act_mode_baseten_model_info = 113;
|
||||
string act_mode_hugging_face_model_id = 114;
|
||||
OpenRouterModelInfo act_mode_hugging_face_model_info = 115;
|
||||
string act_mode_huawei_cloud_maas_model_id = 116;
|
||||
OpenRouterModelInfo act_mode_huawei_cloud_maas_model_info = 117;
|
||||
string plan_mode_vercel_ai_gateway_model_id = 118;
|
||||
OpenRouterModelInfo plan_mode_vercel_ai_gateway_model_info = 119;
|
||||
string act_mode_vercel_ai_gateway_model_id = 120;
|
||||
OpenRouterModelInfo act_mode_vercel_ai_gateway_model_info = 121;
|
||||
string act_mode_oca_model_id = 122;
|
||||
OcaModelInfo act_mode_oca_model_info = 123;
|
||||
}
|
||||
|
||||
// Request message for creating a new task
|
||||
message NewTaskRequest {
|
||||
Metadata metadata = 1;
|
||||
string text = 2;
|
||||
repeated string images = 3;
|
||||
repeated string files = 4;
|
||||
optional TaskSettings task_settings = 5;
|
||||
}
|
||||
|
||||
// Request message for toggling task favorite status
|
||||
|
||||
@@ -40,6 +40,7 @@ import {
|
||||
GlobalFileNames,
|
||||
} from "../storage/disk"
|
||||
import { PersistenceErrorEvent, StateManager } from "../storage/StateManager"
|
||||
import { Settings } from "../storage/state-keys"
|
||||
import { Task } from "../task"
|
||||
import { sendMcpMarketplaceCatalogEvent } from "./mcp/subscribeToMcpMarketplaceCatalog"
|
||||
import { appendClineStealthModels } from "./models/refreshOpenRouterModels"
|
||||
@@ -187,7 +188,13 @@ export class Controller {
|
||||
this.stateManager.setGlobalState("userInfo", info)
|
||||
}
|
||||
|
||||
async initTask(task?: string, images?: string[], files?: string[], historyItem?: HistoryItem) {
|
||||
async initTask(
|
||||
task?: string,
|
||||
images?: string[],
|
||||
files?: string[],
|
||||
historyItem?: HistoryItem,
|
||||
taskSettings?: Partial<Settings>,
|
||||
) {
|
||||
await this.clearTask() // ensures that an existing task doesn't exist before starting a new one, although this shouldn't be possible since user must clear task before starting a new one
|
||||
|
||||
const autoApprovalSettings = this.stateManager.getGlobalSettingsKey("autoApprovalSettings")
|
||||
@@ -222,6 +229,13 @@ export class Controller {
|
||||
|
||||
const cwd = this.workspaceManager?.getPrimaryRoot()?.path || (await getCwd(getDesktopDir()))
|
||||
|
||||
const taskId = historyItem?.id || Date.now().toString()
|
||||
|
||||
await this.stateManager.loadTaskSettings(taskId)
|
||||
if (taskSettings) {
|
||||
this.stateManager.setTaskSettingsBatch(taskId, taskSettings)
|
||||
}
|
||||
|
||||
this.task = new Task({
|
||||
controller: this,
|
||||
mcpHub: this.mcpHub,
|
||||
@@ -240,12 +254,8 @@ export class Controller {
|
||||
images,
|
||||
files,
|
||||
historyItem,
|
||||
taskId,
|
||||
})
|
||||
|
||||
// Load task settings after task creation
|
||||
if (this.task.taskId) {
|
||||
await this.stateManager.loadTaskSettings(this.task.taskId)
|
||||
}
|
||||
}
|
||||
|
||||
async reinitExistingTaskFromId(taskId: string) {
|
||||
@@ -803,7 +813,7 @@ export class Controller {
|
||||
async clearTask() {
|
||||
if (this.task) {
|
||||
// Clear task settings cache when task ends
|
||||
await this.stateManager.clearTaskSettings(this.task.taskId)
|
||||
await this.stateManager.clearTaskSettings()
|
||||
}
|
||||
await this.task?.abortTask()
|
||||
this.task = undefined // removes reference to it, so once promises end it will be garbage collected
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
@@ -42,7 +42,7 @@ export class StateManager {
|
||||
|
||||
// Debounced persistence state
|
||||
private pendingGlobalState = new Set<GlobalStateAndSettingsKey>()
|
||||
private pendingTaskState = new Set<SettingsKey>()
|
||||
private pendingTaskState = new Map<string, Set<SettingsKey>>()
|
||||
private pendingSecrets = new Set<SecretKey>()
|
||||
private pendingWorkspaceState = new Set<LocalStateKey>()
|
||||
private persistenceTimeout: NodeJS.Timeout | null = null
|
||||
@@ -132,8 +132,11 @@ export class StateManager {
|
||||
this.taskStateCache[key] = value
|
||||
|
||||
// Add to pending persistence set and schedule debounced write
|
||||
this.pendingTaskState.add(key)
|
||||
this.scheduleDebouncedPersistence(taskId)
|
||||
if (!this.pendingTaskState.has(taskId)) {
|
||||
this.pendingTaskState.set(taskId, new Set())
|
||||
}
|
||||
this.pendingTaskState.get(taskId)!.add(key)
|
||||
this.scheduleDebouncedPersistence()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -148,12 +151,15 @@ export class StateManager {
|
||||
Object.assign(this.taskStateCache, updates)
|
||||
|
||||
// Then track the keys for persistence
|
||||
if (!this.pendingTaskState.has(taskId)) {
|
||||
this.pendingTaskState.set(taskId, new Set())
|
||||
}
|
||||
Object.keys(updates).forEach((key) => {
|
||||
this.pendingTaskState.add(key as SettingsKey)
|
||||
this.pendingTaskState.get(taskId)!.add(key as SettingsKey)
|
||||
})
|
||||
|
||||
// Schedule debounced persistence
|
||||
this.scheduleDebouncedPersistence(taskId)
|
||||
this.scheduleDebouncedPersistence()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -182,12 +188,12 @@ export class StateManager {
|
||||
/**
|
||||
* Clear task settings cache - ensures pending changes are persisted first
|
||||
*/
|
||||
async clearTaskSettings(taskId?: string): Promise<void> {
|
||||
async clearTaskSettings(): Promise<void> {
|
||||
// If there are pending task settings, persist them first
|
||||
if (this.pendingTaskState.size > 0 && taskId) {
|
||||
if (this.pendingTaskState.size > 0) {
|
||||
try {
|
||||
// Persist pending task state immediately
|
||||
await this.persistTaskStateBatch(this.pendingTaskState, taskId)
|
||||
await this.persistTaskStateBatch(this.pendingTaskState)
|
||||
// Clear pending set after successful persistence
|
||||
this.pendingTaskState.clear()
|
||||
} catch (error) {
|
||||
@@ -723,7 +729,7 @@ export class StateManager {
|
||||
/**
|
||||
* Schedule debounced persistence - simple timeout-based persistence
|
||||
*/
|
||||
private scheduleDebouncedPersistence(taskId?: string): void {
|
||||
private scheduleDebouncedPersistence(): void {
|
||||
// Clear existing timeout if one is pending
|
||||
if (this.persistenceTimeout) {
|
||||
clearTimeout(this.persistenceTimeout)
|
||||
@@ -736,7 +742,7 @@ export class StateManager {
|
||||
this.persistGlobalStateBatch(this.pendingGlobalState),
|
||||
this.persistSecretsBatch(this.pendingSecrets),
|
||||
this.persistWorkspaceStateBatch(this.pendingWorkspaceState),
|
||||
this.persistTaskStateBatch(this.pendingTaskState, taskId),
|
||||
this.persistTaskStateBatch(this.pendingTaskState),
|
||||
])
|
||||
|
||||
// Clear pending sets on successful persistence
|
||||
@@ -776,16 +782,27 @@ export class StateManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Private method to batch persist task state keys with Promise.all
|
||||
* Private method to batch persist task state keys with a single write operation
|
||||
*/
|
||||
private async persistTaskStateBatch(keys: Set<SettingsKey>, taskId: string | undefined): Promise<void> {
|
||||
if (!taskId) {
|
||||
private async persistTaskStateBatch(pendingTaskStates: Map<string, Set<SettingsKey>>): Promise<void> {
|
||||
if (pendingTaskStates.size === 0) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
// Persist each task's settings
|
||||
await Promise.all(
|
||||
Array.from(keys).map((key) => {
|
||||
return writeTaskSettingsToStorage(taskId, { [key]: this.taskStateCache[key] })
|
||||
Array.from(pendingTaskStates.entries()).map(([taskId, keys]) => {
|
||||
if (keys.size === 0) {
|
||||
return Promise.resolve()
|
||||
}
|
||||
const settingsToWrite: Record<string, any> = {}
|
||||
for (const key of keys) {
|
||||
const value = this.taskStateCache[key]
|
||||
if (value !== undefined) {
|
||||
settingsToWrite[key] = value
|
||||
}
|
||||
}
|
||||
return writeTaskSettingsToStorage(taskId, settingsToWrite)
|
||||
}),
|
||||
)
|
||||
} catch (error) {
|
||||
|
||||
@@ -8,7 +8,7 @@ import fs from "fs/promises"
|
||||
import os from "os"
|
||||
import * as path from "path"
|
||||
import { HostProvider } from "@/hosts/host-provider"
|
||||
import { GlobalState } from "./state-keys"
|
||||
import { GlobalState, Settings } from "./state-keys"
|
||||
|
||||
export const GlobalFileNames = {
|
||||
apiConversationHistory: "api_conversation_history.json",
|
||||
@@ -242,7 +242,7 @@ export async function readTaskSettingsFromStorage(taskId: string): Promise<Parti
|
||||
}
|
||||
}
|
||||
|
||||
export async function writeTaskSettingsToStorage(taskId: string, settings: Partial<GlobalState>) {
|
||||
export async function writeTaskSettingsToStorage(taskId: string, settings: Partial<Settings>) {
|
||||
try {
|
||||
const taskDirectoryFilePath = await ensureTaskDirectoryExists(taskId)
|
||||
const settingsFilePath = path.join(taskDirectoryFilePath, "settings.json")
|
||||
|
||||
@@ -103,6 +103,7 @@ type TaskParams = {
|
||||
images?: string[]
|
||||
files?: string[]
|
||||
historyItem?: HistoryItem
|
||||
taskId: string
|
||||
}
|
||||
|
||||
export class Task {
|
||||
@@ -171,6 +172,7 @@ export class Task {
|
||||
images,
|
||||
files,
|
||||
historyItem,
|
||||
taskId,
|
||||
} = params
|
||||
|
||||
this.taskInitializationStartTime = performance.now()
|
||||
@@ -214,9 +216,10 @@ export class Task {
|
||||
await this.say("mcp_notification", `[${serverName}] ${message}`)
|
||||
})
|
||||
|
||||
this.taskId = taskId
|
||||
|
||||
// Initialize taskId first
|
||||
if (historyItem) {
|
||||
this.taskId = historyItem.id
|
||||
this.ulid = historyItem.ulid ?? ulid()
|
||||
this.taskIsFavorited = historyItem.isFavorited
|
||||
this.taskState.conversationHistoryDeletedRange = historyItem.conversationHistoryDeletedRange
|
||||
@@ -224,7 +227,6 @@ export class Task {
|
||||
this.taskState.checkpointManagerErrorMessage = historyItem.checkpointManagerErrorMessage
|
||||
}
|
||||
} else if (task || images || files) {
|
||||
this.taskId = Date.now().toString()
|
||||
this.ulid = ulid()
|
||||
} else {
|
||||
throw new Error("Either historyItem or task/images must be provided")
|
||||
|
||||
@@ -40,7 +40,13 @@ export function useMessageHandlers(messages: ClineMessage[], chatState: ChatStat
|
||||
if (hasContent) {
|
||||
console.log("[ChatView] handleSendMessage - Sending message:", messageToSend)
|
||||
if (messages.length === 0) {
|
||||
await TaskServiceClient.newTask(NewTaskRequest.create({ text: messageToSend, images, files }))
|
||||
await TaskServiceClient.newTask(
|
||||
NewTaskRequest.create({
|
||||
text: messageToSend,
|
||||
images,
|
||||
files,
|
||||
}),
|
||||
)
|
||||
} else if (clineAsk) {
|
||||
switch (clineAsk) {
|
||||
case "followup":
|
||||
|
||||
Reference in new issue
Block a user