Skip to content

Commit d75b11d

Browse files
committed
fix: sending roo code when we're in creator mode
1 parent eb384f6 commit d75b11d

4 files changed

Lines changed: 52 additions & 8 deletions

File tree

src/core/Cline.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ export type ClineOptions = {
115115
rootTask?: Cline
116116
parentTask?: Cline
117117
taskNumber?: number
118+
creatorMode?: boolean
118119
}
119120

120121
export class Cline extends EventEmitter<ClineEvents> {
@@ -131,6 +132,7 @@ export class Cline extends EventEmitter<ClineEvents> {
131132
private pausedModeSlug: string = defaultModeSlug
132133
private pauseInterval: NodeJS.Timeout | undefined
133134

135+
public creatorMode: boolean
134136
readonly apiConfiguration: ApiConfiguration
135137
api: ApiHandler
136138
private urlContentFetcher: UrlContentFetcher
@@ -192,6 +194,7 @@ export class Cline extends EventEmitter<ClineEvents> {
192194
rootTask,
193195
parentTask,
194196
taskNumber,
197+
creatorMode,
195198
}: ClineOptions) {
196199
super()
197200

@@ -219,6 +222,8 @@ export class Cline extends EventEmitter<ClineEvents> {
219222
this.enableCheckpoints = enableCheckpoints
220223
this.checkpointStorage = checkpointStorage
221224

225+
this.creatorMode = creatorMode ?? false
226+
222227
this.rootTask = rootTask
223228
this.parentTask = parentTask
224229
this.taskNumber = taskNumber ?? -1

src/core/webview/ClineProvider.ts

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,15 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
501501
experiments,
502502
} = await this.getState()
503503

504+
// Update API configuration with creator mode
505+
await this.updateApiConfiguration({
506+
...apiConfiguration,
507+
creatorMode,
508+
})
509+
510+
// Post updated state to webview immediately
511+
await this.postStateToWebview()
512+
504513
const modePrompt = customModePrompts?.[mode] as PromptComponent
505514
const effectiveInstructions = [globalInstructions, modePrompt?.customInstructions].filter(Boolean).join("\n\n")
506515

@@ -524,6 +533,7 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
524533
rootTask: this.clineStack.length > 0 ? this.clineStack[0] : undefined,
525534
parentTask,
526535
taskNumber: this.clineStack.length + 1,
536+
creatorMode,
527537
})
528538

529539
await this.addClineToStack(cline)
@@ -2175,6 +2185,13 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
21752185
private async updateApiConfiguration(apiConfiguration: ApiConfiguration) {
21762186
// Update mode's default config.
21772187
const { mode } = await this.getState()
2188+
const currentCline = this.getCurrentCline()
2189+
2190+
// Preserve creator mode when updating configuration
2191+
const updatedConfig = {
2192+
...apiConfiguration,
2193+
creatorMode: currentCline?.creatorMode,
2194+
}
21782195

21792196
if (mode) {
21802197
const currentApiConfigName = await this.getGlobalState("currentApiConfigName")
@@ -2186,7 +2203,7 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
21862203
}
21872204
}
21882205

2189-
await this.contextProxy.setApiConfiguration(apiConfiguration)
2206+
await this.contextProxy.setApiConfiguration(updatedConfig)
21902207

21912208
if (this.getCurrentCline()) {
21922209
this.getCurrentCline()!.api = buildApiHandler(apiConfiguration)
@@ -2511,8 +2528,10 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
25112528
}
25122529

25132530
async getStateToPostToWebview() {
2531+
const currentCline = this.getCurrentCline()
2532+
// Get base state
25142533
const {
2515-
apiConfiguration,
2534+
apiConfiguration: baseApiConfiguration,
25162535
lastShownAnnouncementId,
25172536
customInstructions,
25182537
alwaysAllowReadOnly,
@@ -2560,6 +2579,12 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
25602579
maxReadFileLine,
25612580
} = await this.getState()
25622581

2582+
// Construct API configuration with creator mode
2583+
const apiConfiguration = {
2584+
...baseApiConfiguration,
2585+
creatorMode: currentCline?.creatorMode,
2586+
}
2587+
25632588
const telemetryKey = process.env.POSTHOG_API_KEY
25642589
const machineId = vscode.env.machineId
25652590
const allowedCommands = vscode.workspace.getConfiguration("roo-cline").get<string[]>("allowedCommands") || []

src/shared/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,12 @@ export interface ApiHandlerOptions {
8585
pearaiAgentModels?: PearAIAgentModelsConfig
8686
modelMaxThinkingTokens?: number
8787
fakeAi?: unknown
88+
creatorMode?: boolean
8889
}
8990

9091
export type ApiConfiguration = ApiHandlerOptions & {
9192
apiProvider?: ApiProvider
9293
id?: string // stable unique identifier
93-
creatorMode?: boolean
9494
}
9595

9696
// Import GlobalStateKey type from globalState.ts

webview-ui/src/components/settings/ApiOptions.tsx

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1607,8 +1607,8 @@ export function normalizeApiConfiguration(
16071607
if (modelId === "pearai-model" && models[modelId].underlyingModelUpdated) {
16081608
let modelInfo = models[modelId].underlyingModelUpdated
16091609
selectedModelInfo = {
1610-
contextWindow: modelInfo.contextWindow || 4096, // provide default or actual value
1611-
supportsPromptCache: modelInfo.supportsPromptCaching || false, // provide default or actual value
1610+
contextWindow: modelInfo.contextWindow || 4096,
1611+
supportsPromptCache: modelInfo.supportsPromptCaching || false,
16121612
...modelInfo,
16131613
}
16141614
} else {
@@ -1619,7 +1619,13 @@ export function normalizeApiConfiguration(
16191619
selectedModelInfo = models[defaultId]
16201620
}
16211621

1622-
return { selectedProvider: provider, selectedModelId, selectedModelInfo }
1622+
// Preserve all original configuration fields while updating model-specific ones
1623+
return {
1624+
selectedProvider: provider,
1625+
selectedModelId,
1626+
selectedModelInfo,
1627+
...apiConfiguration,
1628+
}
16231629
}
16241630

16251631
switch (provider) {
@@ -1705,8 +1711,16 @@ export function normalizeApiConfiguration(
17051711
}
17061712
case "pearai": {
17071713
// Always use the models from the hook which are fetched when provider is selected
1708-
let query = pearAiModelsQuery
1709-
return getProviderData(pearAiModelsQuery || {}, pearAiDefaultModelId)
1714+
const { selectedProvider, selectedModelId, selectedModelInfo } = getProviderData(
1715+
pearAiModelsQuery || {},
1716+
pearAiDefaultModelId,
1717+
)
1718+
return {
1719+
selectedProvider,
1720+
selectedModelId,
1721+
selectedModelInfo,
1722+
creatorMode: apiConfiguration?.creatorMode,
1723+
}
17101724
}
17111725
default:
17121726
return getProviderData(anthropicModels, anthropicDefaultModelId)

0 commit comments

Comments
 (0)