Skip to content

Commit 4fb72c4

Browse files
authored
Merge pull request #462 from RooVetGit/fix_language_selector
Fix language selector
2 parents 5dcb967 + 8bbb64d commit 4fb72c4

File tree

4 files changed

+40
-2
lines changed

4 files changed

+40
-2
lines changed

.changeset/cyan-camels-explode.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"roo-cline": patch
3+
---
4+
5+
Fix bug where language selector wasn't working

src/core/Cline.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,8 @@ export class Cline {
809809
})
810810
}
811811

812-
const { browserViewportSize, mode, customPrompts } = (await this.providerRef.deref()?.getState()) ?? {}
812+
const { browserViewportSize, mode, customPrompts, preferredLanguage } =
813+
(await this.providerRef.deref()?.getState()) ?? {}
813814
const { customModes } = (await this.providerRef.deref()?.getState()) ?? {}
814815
const systemPrompt = await (async () => {
815816
const provider = this.providerRef.deref()
@@ -826,6 +827,7 @@ export class Cline {
826827
mode,
827828
customPrompts,
828829
customModes,
830+
preferredLanguage,
829831
)
830832
})()
831833

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { addCustomInstructions } from "../sections/custom-instructions"
2+
3+
describe("addCustomInstructions", () => {
4+
test("adds preferred language to custom instructions", async () => {
5+
const result = await addCustomInstructions(
6+
"mode instructions",
7+
"global instructions",
8+
"/test/path",
9+
"test-mode",
10+
{ preferredLanguage: "French" },
11+
)
12+
13+
expect(result).toContain("Language Preference:")
14+
expect(result).toContain("You should always speak and think in the French language")
15+
})
16+
17+
test("works without preferred language", async () => {
18+
const result = await addCustomInstructions(
19+
"mode instructions",
20+
"global instructions",
21+
"/test/path",
22+
"test-mode",
23+
)
24+
25+
expect(result).not.toContain("Language Preference:")
26+
expect(result).not.toContain("You should always speak and think in")
27+
})
28+
})

src/core/prompts/system.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ async function generatePrompt(
3737
promptComponent?: PromptComponent,
3838
customModeConfigs?: ModeConfig[],
3939
globalCustomInstructions?: string,
40+
preferredLanguage?: string,
4041
): Promise<string> {
4142
if (!context) {
4243
throw new Error("Extension context is required for generating system prompt")
@@ -79,7 +80,7 @@ ${getSystemInfoSection(cwd, mode, customModeConfigs)}
7980
8081
${getObjectiveSection()}
8182
82-
${await addCustomInstructions(modeConfig.customInstructions || "", globalCustomInstructions || "", cwd, mode, {})}`
83+
${await addCustomInstructions(modeConfig.customInstructions || "", globalCustomInstructions || "", cwd, mode, { preferredLanguage })}`
8384

8485
return basePrompt
8586
}
@@ -95,6 +96,7 @@ export const SYSTEM_PROMPT = async (
9596
customPrompts?: CustomPrompts,
9697
customModes?: ModeConfig[],
9798
globalCustomInstructions?: string,
99+
preferredLanguage?: string,
98100
): Promise<string> => {
99101
if (!context) {
100102
throw new Error("Extension context is required for generating system prompt")
@@ -123,5 +125,6 @@ export const SYSTEM_PROMPT = async (
123125
promptComponent,
124126
customModes,
125127
globalCustomInstructions,
128+
preferredLanguage,
126129
)
127130
}

0 commit comments

Comments
 (0)