Skip to content

Commit 878b382

Browse files
authored
Settings tweaks: add terminal & language sections, fix whell scroll in editor tab (#1763)
1 parent 6301e90 commit 878b382

39 files changed

+653
-396
lines changed

.vscode/extensions.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
// for the documentation about the extensions.json format
44
"recommendations": [
55
"dbaeumer.vscode-eslint",
6-
"connor4312.esbuild-problem-matchers",
7-
"ms-vscode.extension-test-runner",
6+
"esbenp.prettier-vscode",
87
"csstools.postcss",
98
"bradlc.vscode-tailwindcss",
10-
"tobermory.es6-string-html"
9+
"connor4312.esbuild-problem-matchers"
1110
]
1211
}

package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/activate/registerCommands.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,11 @@ const getCommandsMap = ({ context, outputChannel, provider }: RegisterCommandOpt
8989
}
9090

9191
const openClineInNewTab = async ({ context, outputChannel }: Omit<RegisterCommandOptions, "provider">) => {
92-
outputChannel.appendLine("Opening Roo Code in new tab")
93-
9492
// (This example uses webviewProvider activation event which is necessary to
9593
// deserialize cached webview, but since we use retainContextWhenHidden, we
9694
// don't need to use that event).
9795
// https://github.com/microsoft/vscode-extension-samples/blob/main/webview-sample/src/extension.ts
98-
const tabProvider = new ClineProvider(context, outputChannel)
99-
// const column = vscode.window.activeTextEditor ? vscode.window.activeTextEditor.viewColumn : undefined
96+
const tabProvider = new ClineProvider(context, outputChannel, "editor")
10097
const lastCol = Math.max(...vscode.window.visibleTextEditors.map((editor) => editor.viewColumn || 0))
10198

10299
// Check if there are any visible text editors, otherwise open a new group
@@ -115,10 +112,10 @@ const openClineInNewTab = async ({ context, outputChannel }: Omit<RegisterComman
115112
localResourceRoots: [context.extensionUri],
116113
})
117114

118-
// Save as tab type panel
115+
// Save as tab type panel.
119116
setPanel(newPanel, "tab")
120117

121-
// TODO: use better svg icon with light and dark variants (see
118+
// TODO: Use better svg icon with light and dark variants (see
122119
// https://stackoverflow.com/questions/58365687/vscode-extension-iconpath).
123120
newPanel.iconPath = {
124121
light: vscode.Uri.joinPath(context.extensionUri, "assets", "icons", "rocket.png"),
@@ -127,12 +124,12 @@ const openClineInNewTab = async ({ context, outputChannel }: Omit<RegisterComman
127124

128125
await tabProvider.resolveWebviewView(newPanel)
129126

130-
// Handle panel closing events
127+
// Handle panel closing events.
131128
newPanel.onDidDispose(() => {
132129
setPanel(undefined, "tab")
133130
})
134131

135-
// Lock the editor group so clicking on files doesn't open them over the panel
132+
// Lock the editor group so clicking on files doesn't open them over the panel.
136133
await delay(100)
137134
await vscode.commands.executeCommand("workbench.action.lockEditorGroup")
138135
}

src/core/prompts/__tests__/__snapshots__/system.test.ts.snap

Lines changed: 15 additions & 15 deletions
Large diffs are not rendered by default.

src/core/prompts/sections/rules.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
import { DiffStrategy } from "../../diff/DiffStrategy"
2-
import { modes, ModeConfig } from "../../../shared/modes"
3-
import * as vscode from "vscode"
4-
import * as path from "path"
52

63
function getEditingInstructions(diffStrategy?: DiffStrategy, experiments?: Record<string, boolean>): string {
74
const instructions: string[] = []
@@ -65,7 +62,7 @@ export function getRulesSection(
6562
RULES
6663
6764
- The project base directory is: ${cwd.toPosix()}
68-
- All all file paths must be relative to this directory. However, commands may change directories in terminals, so respect working directory specified by the response to <execute_command>.
65+
- All file paths must be relative to this directory. However, commands may change directories in terminals, so respect working directory specified by the response to <execute_command>.
6966
- You cannot \`cd\` into a different directory to complete a task. You are stuck operating from '${cwd.toPosix()}', so be sure to pass in the correct 'path' parameter when using tools that require a path.
7067
- Do not use the ~ character or $HOME to refer to the home directory.
7168
- Before using the execute_command tool, you must first think about the SYSTEM INFORMATION context provided to understand the user's environment and tailor your commands to ensure they are compatible with their system. You must also consider if the command you need to run should be executed in a specific directory outside of the current working directory '${cwd.toPosix()}', and if so prepend with \`cd\`'ing into that directory && then executing the command (as one command since you are stuck operating from '${cwd.toPosix()}'). For example, if you needed to run \`npm install\` in a project outside of '${cwd.toPosix()}', you would need to prepend with a \`cd\` i.e. pseudocode for this would be \`cd (path to project) && (command, in this case npm install)\`.

src/core/webview/ClineProvider.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import fs from "fs/promises"
66
import os from "os"
77
import pWaitFor from "p-wait-for"
88
import * as path from "path"
9-
import { Terminal } from "../../integrations/terminal/Terminal"
109
import * as vscode from "vscode"
1110

1211
import { setPanel } from "../../activate/registerCommands"
@@ -28,6 +27,7 @@ import { Mode, PromptComponent, defaultModeSlug, ModeConfig } from "../../shared
2827
import { checkExistKey } from "../../shared/checkExistApiConfig"
2928
import { EXPERIMENT_IDS, experiments as Experiments, experimentDefault, ExperimentId } from "../../shared/experiments"
3029
import { formatLanguage } from "../../shared/language"
30+
import { Terminal, TERMINAL_SHELL_INTEGRATION_TIMEOUT } from "../../integrations/terminal/Terminal"
3131
import { downloadTask } from "../../integrations/misc/export-markdown"
3232
import { openFile, openImage } from "../../integrations/misc/open-file"
3333
import { selectImages } from "../../integrations/misc/process-images"
@@ -95,6 +95,7 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
9595
constructor(
9696
readonly context: vscode.ExtensionContext,
9797
private readonly outputChannel: vscode.OutputChannel,
98+
private readonly renderContext: "sidebar" | "editor" = "sidebar",
9899
) {
99100
super()
100101

@@ -359,7 +360,7 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
359360
// Initialize out-of-scope variables that need to recieve persistent global state values
360361
this.getState().then(({ soundEnabled, terminalShellIntegrationTimeout }) => {
361362
setSoundEnabled(soundEnabled ?? false)
362-
Terminal.setShellIntegrationTimeout(terminalShellIntegrationTimeout ?? 4000)
363+
Terminal.setShellIntegrationTimeout(terminalShellIntegrationTimeout ?? TERMINAL_SHELL_INTEGRATION_TIMEOUT)
363364
})
364365

365366
// Initialize tts enabled state
@@ -2400,11 +2401,10 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
24002401
showRooIgnoredFiles,
24012402
language,
24022403
} = await this.getState()
2404+
24032405
const telemetryKey = process.env.POSTHOG_API_KEY
24042406
const machineId = vscode.env.machineId
2405-
24062407
const allowedCommands = vscode.workspace.getConfiguration("roo-cline").get<string[]>("allowedCommands") || []
2407-
24082408
const cwd = this.cwd
24092409

24102410
return {
@@ -2442,7 +2442,7 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
24422442
remoteBrowserEnabled: remoteBrowserEnabled ?? false,
24432443
writeDelayMs: writeDelayMs ?? 1000,
24442444
terminalOutputLineLimit: terminalOutputLineLimit ?? 500,
2445-
terminalShellIntegrationTimeout: terminalShellIntegrationTimeout ?? 4000,
2445+
terminalShellIntegrationTimeout: terminalShellIntegrationTimeout ?? TERMINAL_SHELL_INTEGRATION_TIMEOUT,
24462446
fuzzyMatchThreshold: fuzzyMatchThreshold ?? 1.0,
24472447
mcpEnabled: mcpEnabled ?? true,
24482448
enableMcpServerCreation: enableMcpServerCreation ?? true,
@@ -2468,6 +2468,7 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
24682468
machineId,
24692469
showRooIgnoredFiles: showRooIgnoredFiles ?? true,
24702470
language,
2471+
renderContext: this.renderContext,
24712472
}
24722473
}
24732474

@@ -2602,7 +2603,8 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
26022603
fuzzyMatchThreshold: stateValues.fuzzyMatchThreshold ?? 1.0,
26032604
writeDelayMs: stateValues.writeDelayMs ?? 1000,
26042605
terminalOutputLineLimit: stateValues.terminalOutputLineLimit ?? 500,
2605-
terminalShellIntegrationTimeout: stateValues.terminalShellIntegrationTimeout ?? 4000,
2606+
terminalShellIntegrationTimeout:
2607+
stateValues.terminalShellIntegrationTimeout ?? TERMINAL_SHELL_INTEGRATION_TIMEOUT,
26062608
mode: stateValues.mode ?? defaultModeSlug,
26072609
language: stateValues.language ?? formatLanguage(vscode.env.language),
26082610
mcpEnabled: stateValues.mcpEnabled ?? true,

src/core/webview/__tests__/ClineProvider.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,7 @@ describe("ClineProvider", () => {
531531
browserToolEnabled: true,
532532
telemetrySetting: "unset",
533533
showRooIgnoredFiles: true,
534+
renderContext: "sidebar",
534535
}
535536

536537
const message: ExtensionMessage = {

src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export function activate(context: vscode.ExtensionContext) {
5656
context.globalState.update("allowedCommands", defaultCommands)
5757
}
5858

59-
const provider = new ClineProvider(context, outputChannel)
59+
const provider = new ClineProvider(context, outputChannel, "sidebar")
6060
telemetryService.setProvider(provider)
6161

6262
// Validate task history on extension activation

src/integrations/terminal/Terminal.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ import pWaitFor from "p-wait-for"
33
import { ExitCodeDetails, mergePromise, TerminalProcess, TerminalProcessResultPromise } from "./TerminalProcess"
44
import { truncateOutput, applyRunLengthEncoding } from "../misc/extract-text"
55

6+
export const TERMINAL_SHELL_INTEGRATION_TIMEOUT = 5000
7+
68
export class Terminal {
7-
private static shellIntegrationTimeout: number = 4000
9+
private static shellIntegrationTimeout: number = TERMINAL_SHELL_INTEGRATION_TIMEOUT
810

911
public terminal: vscode.Terminal
1012
public busy: boolean

src/shared/ExtensionMessage.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ export interface ExtensionState {
156156
telemetryKey?: string
157157
machineId?: string
158158
showRooIgnoredFiles: boolean // Whether to show .rooignore'd files in listings
159+
renderContext: "sidebar" | "editor"
159160
}
160161

161162
export type { ClineMessage, ClineAsk, ClineSay }

0 commit comments

Comments
 (0)