diff --git a/packages/types/src/task.ts b/packages/types/src/task.ts index 792298350f..348ebe8ac7 100644 --- a/packages/types/src/task.ts +++ b/packages/types/src/task.ts @@ -14,7 +14,7 @@ export interface TaskProviderState { } export interface InitTaskOptions { - mode_slug?: string + modeSlug?: string enableDiff?: boolean enableCheckpoints?: boolean fuzzyMatchThreshold?: number @@ -95,7 +95,7 @@ export interface TaskLike { off(event: K, listener: (...args: TaskEvents[K]) => void | Promise): this setMessageResponse(text: string, images?: string[]): void - submitUserMessage(text: string, images?: string[], mode_slug?: string): void + submitUserMessage(text: string, images?: string[], modeSlug?: string): void } export type TaskEvents = { diff --git a/src/core/task/Task.ts b/src/core/task/Task.ts index f2e39f3f86..3d79f82797 100644 --- a/src/core/task/Task.ts +++ b/src/core/task/Task.ts @@ -768,7 +768,7 @@ export class Task extends EventEmitter implements TaskLike { this.askResponseImages = images } - public submitUserMessage(text: string, images?: string[], mode_slug?: string): void { + public submitUserMessage(text: string, images?: string[], modeSlug?: string): void { try { const trimmed = (text ?? "").trim() const imgs = images ?? [] @@ -783,20 +783,20 @@ export class Task extends EventEmitter implements TaskLike { void (async () => { // If a mode slug is provided, handle the mode switch first (same behavior as initClineWithTask) try { - const modeSlugValue = (mode_slug ?? "").trim() + const modeSlugValue = (modeSlug ?? "").trim() if (modeSlugValue.length > 0) { const customModes = await provider.customModesManager.getCustomModes() const targetMode = getModeBySlug(modeSlugValue, customModes) if (targetMode) { await provider.handleModeSwitch(targetMode.slug) - provider.log(`[Task#submitUserMessage] Applied mode from mode_slug: '${targetMode.slug}'`) + provider.log(`[Task#submitUserMessage] Applied mode from modeSlug: '${targetMode.slug}'`) } else { - provider.log(`[Task#submitUserMessage] Ignoring invalid mode_slug: '${modeSlugValue}'.`) + provider.log(`[Task#submitUserMessage] Ignoring invalid modeSlug: '${modeSlugValue}'.`) } } } catch (err) { provider.log( - `[Task#submitUserMessage] Failed to apply mode_slug: ${ + `[Task#submitUserMessage] Failed to apply modeSlug: ${ err instanceof Error ? err.message : String(err) }`, ) @@ -2554,10 +2554,6 @@ export class Task extends EventEmitter implements TaskLike { // Getters public get cwd() { - if (!this.workspacePath) { - // Return a fallback to prevent crashes - return path.join(os.homedir(), "Desktop") - } return this.workspacePath } } diff --git a/src/core/webview/ClineProvider.ts b/src/core/webview/ClineProvider.ts index 3965d9428e..0e5667515f 100644 --- a/src/core/webview/ClineProvider.ts +++ b/src/core/webview/ClineProvider.ts @@ -708,10 +708,10 @@ export class ClineProvider throw new OrganizationAllowListViolationError(t("common:errors.violated_organization_allowlist")) } - // Bridge: If a mode_slug is provided by the cloud extension bridge, honor it before creating the task + // Bridge: If a modeSlug is provided by the cloud extension bridge, honor it before creating the task // This ensures the task initializes with the correct mode and associated provider profile try { - const modeSlugFromBridge: string | undefined = (options as any)?.mode_slug + const modeSlugFromBridge: string | undefined = (options as any)?.modeSlug if (typeof modeSlugFromBridge === "string" && modeSlugFromBridge.trim().length > 0) { const customModes = await this.customModesManager.getCustomModes() const targetMode = getModeBySlug(modeSlugFromBridge, customModes) @@ -721,13 +721,13 @@ export class ClineProvider this.log(`[initClineWithTask] Applied mode from bridge: '${targetMode.slug}'`) } else { this.log( - `[initClineWithTask] Ignoring invalid mode_slug from bridge: '${modeSlugFromBridge}'. Falling back to current mode.`, + `[initClineWithTask] Ignoring invalid modeSlug from bridge: '${modeSlugFromBridge}'. Falling back to current mode.`, ) } } } catch (err) { this.log( - `[initClineWithTask] Failed to apply mode_slug from bridge: ${ + `[initClineWithTask] Failed to apply modeSlug from bridge: ${ err instanceof Error ? err.message : String(err) }`, ) diff --git a/src/core/webview/__tests__/ClineProvider.spec.ts b/src/core/webview/__tests__/ClineProvider.spec.ts index dbe0c346fc..a48b9110cc 100644 --- a/src/core/webview/__tests__/ClineProvider.spec.ts +++ b/src/core/webview/__tests__/ClineProvider.spec.ts @@ -2208,7 +2208,7 @@ describe("ClineProvider", () => { }) }) }) -describe("Bridge mode_slug handling", () => { +describe("Bridge modeSlug handling", () => { let provider: ClineProvider let mockContext: vscode.ExtensionContext let mockOutputChannel: vscode.OutputChannel @@ -2262,7 +2262,7 @@ describe("Bridge mode_slug handling", () => { provider = new ClineProvider(mockContext, mockOutputChannel, "sidebar", new ContextProxy(mockContext)) }) - it("applies mode_slug from bridge options when starting task", async () => { + it("applies modeSlug from bridge options when starting task", async () => { await provider.resolveWebviewView(mockWebviewView) // Spy on handleModeSwitch to ensure it's invoked with the bridge-provided mode @@ -2277,10 +2277,10 @@ describe("Bridge mode_slug handling", () => { groups: ["read", "edit"] as any, } as any) - // Pass mode_slug through the options object (as provided by the bridge package) + // Pass modeSlug through the options object (as provided by the bridge package) await provider.initClineWithTask("Started from bridge", undefined, undefined, { experiments: {}, - mode_slug: "architect", + modeSlug: "architect", } as any) expect(handleModeSwitchSpy).toHaveBeenCalledWith("architect") diff --git a/src/extension/api.ts b/src/extension/api.ts index 324f2fc476..cd4b2457f0 100644 --- a/src/extension/api.ts +++ b/src/extension/api.ts @@ -97,13 +97,13 @@ export class API extends EventEmitter implements RooCodeAPI { text, images, newTab, - mode_slug, + modeSlug, }: { configuration: RooCodeSettings text?: string images?: string[] newTab?: boolean - mode_slug?: string + modeSlug?: string }) { let provider: ClineProvider @@ -152,7 +152,7 @@ export class API extends EventEmitter implements RooCodeAPI { const cline = await provider.initClineWithTask(text, images, undefined, { consecutiveMistakeLimit: Number.MAX_SAFE_INTEGER, - mode_slug, + modeSlug, }) if (!cline) {