Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .roomodes
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"slug": "translate",
"name": "Translate",
"roleDefinition": "You are Roo, a linguistic specialist focused on translating and managing localization files. Your responsibility is to help maintain and update translation files for the application, ensuring consistency and accuracy across all language resources.",
"customInstructions": "When internationalizing and translating content:\n\n# Translation Style and Tone\n- Maintain a direct and concise style that mirrors the tone of the original text\n- Carefully account for colloquialisms and idiomatic expressions in both source and target languages\n- Aim for culturally relevant and meaningful translations rather than literal translations\n- Adapt the formality level to match the original content (whether formal or informal)\n- Preserve the personality and voice of the original content\n- Use natural-sounding language that feels native to speakers of the target language\n- Don't translate the word \"token\" as it means something specific in English that all languages will understand\n\n# Technical Implementation\n- Use namespaces to organize translations logically\n- Handle pluralization using i18next's built-in capabilities\n- Implement proper interpolation for variables using {{variable}} syntax\n- Don't include defaultValue. The `en` translations are the fallback.\n- Always use apply_diff instead of write_to_file when editing existing translation files as it's much faster and more reliable\n- When using apply_diff, make sure to carefully identify the exact JSON structure to edit to avoid syntax errors\n- Always use the Trans component for text with embedded components\n\n# Quality Assurance\n- Maintain consistent terminology across all translations\n- Respect the JSON structure of translation files\n- Watch for placeholders and preserve them in translations\n- Be mindful of text length in UI elements when translating to languages that might require more characters\n- Use context-aware translations when the same string has different meanings\n- Always validate your translation work by running the missing translations script:\n ```\n node scripts/find-missing-translations.js\n ```\n- Before completing any translation task, ensure there are no missing translations by running the script with the target locale(s):\n ```\n node scripts/find-missing-translations.js --locale=<locale-code>\n ```\n- Address any missing translations identified by the script to ensure complete coverage across all locales\n\n# Supported Languages\n- Localize all strings into the following locale files: ca, de, en, es, fr, hi, it, ja, ko, pl, pt-BR, tr, vi, zh-CN, zh-TW\n- The translation files are under webview-ui/src/i18n/locales/",
"customInstructions": "When internationalizing and translating content:\n\n# Translation Style and Tone\n- Maintain a direct and concise style that mirrors the tone of the original text\n- Carefully account for colloquialisms and idiomatic expressions in both source and target languages\n- Aim for culturally relevant and meaningful translations rather than literal translations\n- Adapt the formality level to match the original content (whether formal or informal)\n- Preserve the personality and voice of the original content\n- Use natural-sounding language that feels native to speakers of the target language\n- Don't translate the word \"token\" as it means something specific in English that all languages will understand\n\n# Technical Implementation\n- Use namespaces to organize translations logically\n- Handle pluralization using i18next's built-in capabilities\n- Implement proper interpolation for variables using {{variable}} syntax\n- Don't include defaultValue. The `en` translations are the fallback.\n- Always use apply_diff instead of write_to_file when editing existing translation files as it's much faster and more reliable\n- When using apply_diff, make sure to carefully identify the exact JSON structure to edit to avoid syntax errors\n- Always use the Trans component for text with embedded components\n- Internationalize and add English strings first, and then ask the user to confirm the approach before translating into all other languages\n\n# Quality Assurance\n- Maintain consistent terminology across all translations\n- Respect the JSON structure of translation files\n- Watch for placeholders and preserve them in translations\n- Be mindful of text length in UI elements when translating to languages that might require more characters\n- Use context-aware translations when the same string has different meanings\n- Always validate your translation work by running the missing translations script:\n ```\n node scripts/find-missing-translations.js\n ```\n- Before completing any translation task, ensure there are no missing translations by running the script with the target locale(s):\n ```\n node scripts/find-missing-translations.js --locale=<locale-code>\n ```\n- Address any missing translations identified by the script to ensure complete coverage across all locales\n\n# Supported Languages\n- Localize all strings into the following locale files: ca, de, en, es, fr, hi, it, ja, ko, pl, pt-BR, tr, vi, zh-CN, zh-TW\n- The translation files are under webview-ui/src/i18n/locales/",
"groups": [
"read",
"command",
Expand Down
Empty file modified scripts/find-missing-translations.js
100644 → 100755
Empty file.
3 changes: 2 additions & 1 deletion src/core/Cline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3692,12 +3692,13 @@ export class Cline extends EventEmitter<ClineEvents> {
customModePrompts,
experiments = {} as Record<ExperimentId, boolean>,
customInstructions: globalCustomInstructions,
language,
} = (await this.providerRef.deref()?.getState()) ?? {}
const currentMode = mode ?? defaultModeSlug
const modeDetails = await getFullModeDetails(currentMode, customModes, customModePrompts, {
cwd,
globalCustomInstructions,
language: formatLanguage(vscode.env.language),
language: language ?? formatLanguage(vscode.env.language),
})
details += `\n\n# Current Mode\n`
details += `<slug>${currentMode}</slug>\n`
Expand Down
7 changes: 5 additions & 2 deletions src/core/prompts/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ async function generatePrompt(
diffEnabled?: boolean,
experiments?: Record<string, boolean>,
enableMcpServerCreation?: boolean,
language?: string,
rooIgnoreInstructions?: string,
): Promise<string> {
if (!context) {
Expand Down Expand Up @@ -90,7 +91,7 @@ ${getSystemInfoSection(cwd, mode, customModeConfigs)}

${getObjectiveSection()}

${await addCustomInstructions(promptComponent?.customInstructions || modeConfig.customInstructions || "", globalCustomInstructions || "", cwd, mode, { language: formatLanguage(vscode.env.language), rooIgnoreInstructions })}`
${await addCustomInstructions(promptComponent?.customInstructions || modeConfig.customInstructions || "", globalCustomInstructions || "", cwd, mode, { language: language ?? formatLanguage(vscode.env.language), rooIgnoreInstructions })}`

return basePrompt
}
Expand All @@ -109,6 +110,7 @@ export const SYSTEM_PROMPT = async (
diffEnabled?: boolean,
experiments?: Record<string, boolean>,
enableMcpServerCreation?: boolean,
language?: string,
rooIgnoreInstructions?: string,
): Promise<string> => {
if (!context) {
Expand Down Expand Up @@ -139,7 +141,7 @@ export const SYSTEM_PROMPT = async (
globalCustomInstructions || "",
cwd,
mode,
{ language: formatLanguage(vscode.env.language), rooIgnoreInstructions },
{ language: language ?? formatLanguage(vscode.env.language), rooIgnoreInstructions },
)
// For file-based prompts, don't include the tool sections
return `${roleDefinition}
Expand All @@ -166,6 +168,7 @@ ${customInstructions}`
diffEnabled,
experiments,
enableMcpServerCreation,
language,
rooIgnoreInstructions,
)
}
2 changes: 1 addition & 1 deletion src/core/webview/ClineProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2545,7 +2545,7 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
writeDelayMs: stateValues.writeDelayMs ?? 1000,
terminalOutputLineLimit: stateValues.terminalOutputLineLimit ?? 500,
mode: stateValues.mode ?? defaultModeSlug,
language: stateValues.language || formatLanguage(vscode.env.language),
language: stateValues.language ?? formatLanguage(vscode.env.language),
mcpEnabled: stateValues.mcpEnabled ?? true,
enableMcpServerCreation: stateValues.enableMcpServerCreation ?? true,
alwaysApproveResubmit: stateValues.alwaysApproveResubmit ?? false,
Expand Down
27 changes: 15 additions & 12 deletions webview-ui/src/__tests__/ContextWindowProgress.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ describe("ContextWindowProgress", () => {
})

// Check for basic elements
expect(screen.getByText("Context Window:")).toBeInTheDocument()
expect(screen.getByText("1000")).toBeInTheDocument() // contextTokens
expect(screen.getByTestId("context-window-label")).toBeInTheDocument()
expect(screen.getByTestId("context-tokens-count")).toHaveTextContent("1000") // contextTokens
// The actual context window might be different than what we pass in
// due to the mock returning a default value from the API config
expect(screen.getByText(/(4000|128000)/)).toBeInTheDocument() // contextWindow
expect(screen.getByTestId("context-window-size")).toHaveTextContent(/(4000|128000)/) // contextWindow
})

test("handles zero context window gracefully", () => {
Expand All @@ -83,8 +83,8 @@ describe("ContextWindowProgress", () => {

// In the current implementation, the component is still displayed with zero values
// rather than being hidden completely
expect(screen.getByText("Context Window:")).toBeInTheDocument()
expect(screen.getByText("0")).toBeInTheDocument()
expect(screen.getByTestId("context-window-label")).toBeInTheDocument()
expect(screen.getByTestId("context-tokens-count")).toHaveTextContent("0")
})

test("handles edge cases with negative values", () => {
Expand All @@ -94,9 +94,9 @@ describe("ContextWindowProgress", () => {
})

// Should show 0 instead of -100
expect(screen.getByText("0")).toBeInTheDocument()
expect(screen.getByTestId("context-tokens-count")).toHaveTextContent("0")
// The actual context window might be different than what we pass in
expect(screen.getByText(/(4000|128000)/)).toBeInTheDocument()
expect(screen.getByTestId("context-window-size")).toHaveTextContent(/(4000|128000)/)
})

test("calculates percentages correctly", () => {
Expand All @@ -107,15 +107,18 @@ describe("ContextWindowProgress", () => {
contextTokens,
contextWindow,
})

// Instead of checking the exact style, verify the title attribute
// which contains information about the percentage of tokens used
const tokenUsageDiv = screen.getByTitle(/Tokens used:/, { exact: false })
// Instead of checking the title attribute, verify the data-test-id
// which identifies the element containing info about the percentage of tokens used
const tokenUsageDiv = screen.getByTestId("context-tokens-used")
expect(tokenUsageDiv).toBeInTheDocument()

// Just verify that the element has a title attribute (the actual text is translated and may vary)
expect(tokenUsageDiv).toHaveAttribute("title")

// We can't reliably test computed styles in JSDOM, so we'll just check
// that the component appears to be working correctly by checking for expected elements
expect(screen.getByText("Context Window:")).toBeInTheDocument()
expect(screen.getByTestId("context-window-label")).toBeInTheDocument()
expect(screen.getByTestId("context-tokens-count")).toHaveTextContent("1000")
expect(screen.getByText("1000")).toBeInTheDocument()
})
})
Loading