feat: add truncate file URIs opt-in setting

- Add new global setting `truncateFileUris` to control URI truncation
- Add checkbox UI in Context Management settings section
- Handle setting updates through webview message handler
- Add English translations for the new setting

This allows users to opt into truncating long file paths in the context
display to save tokens while showing full paths on hover.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
hannesrudolph 2025-06-16 12:21:26 -06:00
parent 8fba4467f5
commit 9409490cf7
6 changed files with 31 additions and 0 deletions

View file

@ -68,6 +68,7 @@ export const globalSettingsSchema = z.object({
maxWorkspaceFiles: z.number().optional(),
showRooIgnoredFiles: z.boolean().optional(),
maxReadFileLine: z.number().optional(),
truncateFileUris: z.boolean().optional(),
terminalOutputLineLimit: z.number().optional(),
terminalShellIntegrationTimeout: z.number().optional(),
@ -154,6 +155,7 @@ export const GLOBAL_SETTINGS_KEYS = keysOf<GlobalSettings>()([
"maxWorkspaceFiles",
"showRooIgnoredFiles",
"maxReadFileLine",
"truncateFileUris",
"terminalOutputLineLimit",
"terminalShellIntegrationTimeout",

View file

@ -1001,6 +1001,10 @@ export const webviewMessageHandler = async (
await updateGlobalState("maxReadFileLine", message.value)
await provider.postStateToWebview()
break
case "truncateFileUris":
await updateGlobalState("truncateFileUris", message.bool ?? false)
await provider.postStateToWebview()
break
case "maxConcurrentFileReads":
const valueToSave = message.value // Capture the value intended for saving
await updateGlobalState("maxConcurrentFileReads", valueToSave)

View file

@ -137,6 +137,7 @@ export interface WebviewMessage {
| "remoteBrowserEnabled"
| "language"
| "maxReadFileLine"
| "truncateFileUris"
| "maxConcurrentFileReads"
| "searchFiles"
| "toggleApiConfigPin"

View file

@ -61,6 +61,7 @@ type ContextManagementSettingsProps = HTMLAttributes<HTMLDivElement> & {
maxWorkspaceFiles: number
showRooIgnoredFiles?: boolean
maxReadFileLine?: number
truncateFileUris?: boolean
setCachedStateField: SetCachedStateField<
| "autoCondenseContext"
| "autoCondenseContextPercent"
@ -70,6 +71,7 @@ type ContextManagementSettingsProps = HTMLAttributes<HTMLDivElement> & {
| "maxWorkspaceFiles"
| "showRooIgnoredFiles"
| "maxReadFileLine"
| "truncateFileUris"
>
}
@ -84,6 +86,7 @@ export const ContextManagementSettings = ({
showRooIgnoredFiles,
setCachedStateField,
maxReadFileLine,
truncateFileUris,
className,
...props
}: ContextManagementSettingsProps) => {
@ -185,6 +188,20 @@ export const ContextManagementSettings = ({
{t("settings:contextManagement.maxReadFile.description")}
</div>
</div>
<div>
<VSCodeCheckbox
checked={truncateFileUris}
onChange={(e: any) => setCachedStateField("truncateFileUris", e.target.checked)}
data-testid="truncate-file-uris-checkbox">
<label className="block font-medium mb-1">
{t("settings:contextManagement.truncateFileUris.label")}
</label>
</VSCodeCheckbox>
<div className="text-vscode-descriptionForeground text-sm mt-1">
{t("settings:contextManagement.truncateFileUris.description")}
</div>
</div>
</Section>
<Section>

View file

@ -164,6 +164,7 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone, t
showRooIgnoredFiles,
remoteBrowserEnabled,
maxReadFileLine,
truncateFileUris,
terminalCompressProgressBar,
maxConcurrentFileReads,
condensingApiConfigId,
@ -290,6 +291,7 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone, t
vscode.postMessage({ type: "maxWorkspaceFiles", value: maxWorkspaceFiles ?? 200 })
vscode.postMessage({ type: "showRooIgnoredFiles", bool: showRooIgnoredFiles })
vscode.postMessage({ type: "maxReadFileLine", value: maxReadFileLine ?? -1 })
vscode.postMessage({ type: "truncateFileUris", bool: truncateFileUris })
vscode.postMessage({ type: "maxConcurrentFileReads", value: cachedState.maxConcurrentFileReads ?? 15 })
vscode.postMessage({ type: "currentApiConfigName", text: currentApiConfigName })
vscode.postMessage({ type: "updateExperimental", values: experiments })
@ -627,6 +629,7 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone, t
maxWorkspaceFiles={maxWorkspaceFiles ?? 200}
showRooIgnoredFiles={showRooIgnoredFiles}
maxReadFileLine={maxReadFileLine}
truncateFileUris={truncateFileUris}
setCachedStateField={setCachedStateField}
/>
)}

View file

@ -389,6 +389,10 @@
"description": "Roo reads this number of lines when the model omits start/end values. If this number is less than the file's total, Roo generates a line number index of code definitions. Special cases: -1 instructs Roo to read the entire file (without indexing), and 0 instructs it to read no lines and provides line indexes only for minimal context. Lower values minimize initial context usage, enabling precise subsequent line-range reads. Explicit start/end requests are not limited by this setting.",
"lines": "lines",
"always_full_read": "Always read entire file"
},
"truncateFileUris": {
"label": "Truncate long file URIs",
"description": "When enabled, long file paths in the context window will be truncated to save tokens. The full path is shown on hover."
}
},
"terminal": {