Skip to content

Commit cb6dcca

Browse files
authored
Miscellaneous cleanup (#6453)
1 parent b8dc315 commit cb6dcca

File tree

11 files changed

+74
-52
lines changed

11 files changed

+74
-52
lines changed

.roo/rules/rules.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
- Before attempting completion, always make sure that any code changes have test coverage
66
- Ensure all tests pass before submitting changes
7-
- The vitest framework is used for testing; the `describe`, `test`, `it`, etc functions are defined by default in `tsconfig.json` and therefore don't need to be imported
7+
- The vitest framework is used for testing; the `vi`, `describe`, `test`, `it`, etc functions are defined by default in `tsconfig.json` and therefore don't need to be imported from `vitest`
88
- Tests must be run from the same directory as the `package.json` file that specifies `vitest` in `devDependencies`
99
- Run tests with: `npx vitest run <relative-path-from-workspace-root>`
1010
- Do NOT run tests from project root - this causes "vitest: command not found" error
@@ -18,6 +18,7 @@
1818
- Never disable any lint rules without explicit user approval
1919

2020
3. Styling Guidelines:
21+
2122
- Use Tailwind CSS classes instead of inline style objects for new markup
2223
- VSCode CSS variables must be added to webview-ui/src/index.css before using them in Tailwind classes
2324
- Example: `<div className="text-md text-vscode-descriptionForeground mb-2" />` instead of style objects

README.vscode.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

apps/web-evals/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"format": "prettier --write src",
1010
"build": "next build",
1111
"start": "next start",
12-
"clean": "rimraf .next .turbo"
12+
"clean": "rimraf tsconfig.tsbuildinfo .next .turbo"
1313
},
1414
"dependencies": {
1515
"@hookform/resolvers": "^5.1.1",

apps/web-roo-code/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"check-types": "tsc --noEmit",
88
"dev": "next dev",
99
"build": "next build",
10-
"start": "next start"
10+
"start": "next start",
11+
"clean": "rimraf .next .turbo"
1112
},
1213
"dependencies": {
1314
"@radix-ui/react-dialog": "^1.1.14",

packages/cloud/src/CloudService.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export class CloudService {
4848

4949
try {
5050
const cloudToken = process.env.ROO_CODE_CLOUD_TOKEN
51+
5152
if (cloudToken && cloudToken.length > 0) {
5253
this.authService = new StaticTokenAuthService(this.context, cloudToken, this.log)
5354
} else {
@@ -62,8 +63,9 @@ export class CloudService {
6263
this.authService.on("logged-out", this.authListener)
6364
this.authService.on("user-info", this.authListener)
6465

65-
// Check for static settings environment variable
66+
// Check for static settings environment variable.
6667
const staticOrgSettings = process.env.ROO_CODE_CLOUD_ORG_SETTINGS
68+
6769
if (staticOrgSettings && staticOrgSettings.length > 0) {
6870
this.settingsService = new StaticSettingsService(staticOrgSettings, this.log)
6971
} else {
@@ -73,12 +75,12 @@ export class CloudService {
7375
() => this.callbacks.stateChanged?.(),
7476
this.log,
7577
)
78+
7679
cloudSettingsService.initialize()
7780
this.settingsService = cloudSettingsService
7881
}
7982

8083
this.telemetryClient = new TelemetryClient(this.authService, this.settingsService)
81-
8284
this.shareService = new ShareService(this.authService, this.settingsService, this.log)
8385

8486
try {

src/core/task/Task.ts

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,9 @@ import { getMessagesSinceLastSummary, summarizeConversation } from "../condense"
9393
import { maybeRemoveImageBlocks } from "../../api/transform/image-cleaning"
9494
import { restoreTodoListForTask } from "../tools/updateTodoListTool"
9595

96-
// Constants
9796
const MAX_EXPONENTIAL_BACKOFF_SECONDS = 600 // 10 minutes
9897

99-
export type ClineEvents = {
98+
export type TaskEvents = {
10099
message: [{ action: "created" | "updated"; message: ClineMessage }]
101100
taskStarted: []
102101
taskModeSwitched: [taskId: string, mode: string]
@@ -110,6 +109,10 @@ export type ClineEvents = {
110109
taskToolFailed: [taskId: string, tool: ToolName, error: string]
111110
}
112111

112+
export type TaskEventHandlers = {
113+
[K in keyof TaskEvents]: (...args: TaskEvents[K]) => void | Promise<void>
114+
}
115+
113116
export type TaskOptions = {
114117
provider: ClineProvider
115118
apiConfiguration: ProviderSettings
@@ -125,10 +128,10 @@ export type TaskOptions = {
125128
rootTask?: Task
126129
parentTask?: Task
127130
taskNumber?: number
128-
onCreated?: (cline: Task) => void
131+
onCreated?: (task: Task) => void
129132
}
130133

131-
export class Task extends EventEmitter<ClineEvents> {
134+
export class Task extends EventEmitter<TaskEvents> {
132135
todoList?: TodoItem[]
133136
readonly taskId: string
134137
readonly instanceId: string
@@ -137,6 +140,7 @@ export class Task extends EventEmitter<ClineEvents> {
137140
readonly parentTask: Task | undefined = undefined
138141
readonly taskNumber: number
139142
readonly workspacePath: string
143+
140144
/**
141145
* The mode associated with this task. Persisted across sessions
142146
* to maintain user context when reopening tasks from history.
@@ -279,10 +283,12 @@ export class Task extends EventEmitter<ClineEvents> {
279283
}
280284

281285
this.taskId = historyItem ? historyItem.id : crypto.randomUUID()
282-
// normal use-case is usually retry similar history task with new workspace
286+
287+
// Normal use-case is usually retry similar history task with new workspace.
283288
this.workspacePath = parentTask
284289
? parentTask.workspacePath
285290
: getWorkspacePath(path.join(os.homedir(), "Desktop"))
291+
286292
this.instanceId = crypto.randomUUID().slice(0, 8)
287293
this.taskNumber = -1
288294

@@ -311,25 +317,26 @@ export class Task extends EventEmitter<ClineEvents> {
311317
this.parentTask = parentTask
312318
this.taskNumber = taskNumber
313319

314-
// Store the task's mode when it's created
315-
// For history items, use the stored mode; for new tasks, we'll set it after getting state
320+
// Store the task's mode when it's created.
321+
// For history items, use the stored mode; for new tasks, we'll set it
322+
// after getting state.
316323
if (historyItem) {
317324
this._taskMode = historyItem.mode || defaultModeSlug
318325
this.taskModeReady = Promise.resolve()
319326
TelemetryService.instance.captureTaskRestarted(this.taskId)
320327
} else {
321-
// For new tasks, don't set the mode yet - wait for async initialization
328+
// For new tasks, don't set the mode yet - wait for async initialization.
322329
this._taskMode = undefined
323330
this.taskModeReady = this.initializeTaskMode(provider)
324331
TelemetryService.instance.captureTaskCreated(this.taskId)
325332
}
326333

327-
// Only set up diff strategy if diff is enabled
334+
// Only set up diff strategy if diff is enabled.
328335
if (this.diffEnabled) {
329-
// Default to old strategy, will be updated if experiment is enabled
336+
// Default to old strategy, will be updated if experiment is enabled.
330337
this.diffStrategy = new MultiSearchReplaceDiffStrategy(this.fuzzyMatchThreshold)
331338

332-
// Check experiment asynchronously and update strategy if needed
339+
// Check experiment asynchronously and update strategy if needed.
333340
provider.getState().then((state) => {
334341
const isMultiFileApplyDiffEnabled = experiments.isEnabled(
335342
state.experiments ?? {},
@@ -1230,7 +1237,7 @@ export class Task extends EventEmitter<ClineEvents> {
12301237
}
12311238
} catch (error) {
12321239
console.error("Error disposing RooIgnoreController:", error)
1233-
// This is the critical one for the leak fix
1240+
// This is the critical one for the leak fix.
12341241
}
12351242

12361243
try {
@@ -1240,7 +1247,7 @@ export class Task extends EventEmitter<ClineEvents> {
12401247
}
12411248

12421249
try {
1243-
// If we're not streaming then `abortStream` won't be called
1250+
// If we're not streaming then `abortStream` won't be called.
12441251
if (this.isStreaming && this.diffViewProvider.isEditing) {
12451252
this.diffViewProvider.revertChanges().catch(console.error)
12461253
}
@@ -1847,6 +1854,7 @@ export class Task extends EventEmitter<ClineEvents> {
18471854

18481855
public async *attemptApiRequest(retryAttempt: number = 0): ApiStream {
18491856
const state = await this.providerRef.deref()?.getState()
1857+
18501858
const {
18511859
apiConfiguration,
18521860
autoApprovalEnabled,
@@ -1858,21 +1866,24 @@ export class Task extends EventEmitter<ClineEvents> {
18581866
profileThresholds = {},
18591867
} = state ?? {}
18601868

1861-
// Get condensing configuration for automatic triggers
1869+
// Get condensing configuration for automatic triggers.
18621870
const customCondensingPrompt = state?.customCondensingPrompt
18631871
const condensingApiConfigId = state?.condensingApiConfigId
18641872
const listApiConfigMeta = state?.listApiConfigMeta
18651873

1866-
// Determine API handler to use for condensing
1874+
// Determine API handler to use for condensing.
18671875
let condensingApiHandler: ApiHandler | undefined
1876+
18681877
if (condensingApiConfigId && listApiConfigMeta && Array.isArray(listApiConfigMeta)) {
1869-
// Using type assertion for the id property to avoid implicit any
1878+
// Using type assertion for the id property to avoid implicit any.
18701879
const matchingConfig = listApiConfigMeta.find((config: any) => config.id === condensingApiConfigId)
1880+
18711881
if (matchingConfig) {
18721882
const profile = await this.providerRef.deref()?.providerSettingsManager.getProfile({
18731883
id: condensingApiConfigId,
18741884
})
1875-
// Ensure profile and apiProvider exist before trying to build handler
1885+
1886+
// Ensure profile and apiProvider exist before trying to build handler.
18761887
if (profile && profile.apiProvider) {
18771888
condensingApiHandler = buildApiHandler(profile)
18781889
}

src/core/webview/ClineProvider.ts

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ import {
2323
type TerminalActionPromptType,
2424
type HistoryItem,
2525
type CloudUserInfo,
26-
type MarketplaceItem,
2726
requestyDefaultModelId,
2827
openRouterDefaultModelId,
2928
glamaDefaultModelId,
3029
ORGANIZATION_ALLOW_ALL,
3130
DEFAULT_TERMINAL_OUTPUT_CHARACTER_LIMIT,
31+
DEFAULT_WRITE_DELAY_MS,
3232
} from "@roo-code/types"
3333
import { TelemetryService } from "@roo-code/telemetry"
3434
import { CloudService, getRooCodeApiUrl } from "@roo-code/cloud"
@@ -41,9 +41,8 @@ import { supportPrompt } from "../../shared/support-prompt"
4141
import { GlobalFileNames } from "../../shared/globalFileNames"
4242
import { ExtensionMessage, MarketplaceInstalledMetadata } from "../../shared/ExtensionMessage"
4343
import { Mode, defaultModeSlug, getModeBySlug } from "../../shared/modes"
44-
import { experimentDefault, experiments, EXPERIMENT_IDS } from "../../shared/experiments"
44+
import { experimentDefault } from "../../shared/experiments"
4545
import { formatLanguage } from "../../shared/language"
46-
import { DEFAULT_WRITE_DELAY_MS } from "@roo-code/types"
4746
import { Terminal } from "../../integrations/terminal/Terminal"
4847
import { downloadTask } from "../../integrations/misc/export-markdown"
4948
import { getTheme } from "../../integrations/theme/getTheme"
@@ -78,13 +77,7 @@ import { getWorkspaceGitInfo } from "../../utils/git"
7877
*/
7978

8079
export type ClineProviderEvents = {
81-
clineCreated: [cline: Task]
82-
}
83-
84-
class OrganizationAllowListViolationError extends Error {
85-
constructor(message: string) {
86-
super(message)
87-
}
80+
taskCreated: [task: Task]
8881
}
8982

9083
export class ClineProvider
@@ -380,6 +373,7 @@ export class ClineProvider
380373
// Errors from terminal commands seem to get swallowed / ignored.
381374
vscode.window.showErrorMessage(error.message)
382375
}
376+
383377
throw error
384378
}
385379
}
@@ -526,7 +520,7 @@ export class ClineProvider
526520
// of tasks, each one being a sub task of the previous one until the main
527521
// task is finished.
528522
public async initClineWithTask(
529-
task?: string,
523+
text?: string,
530524
images?: string[],
531525
parentTask?: Task,
532526
options: Partial<
@@ -549,30 +543,30 @@ export class ClineProvider
549543
throw new OrganizationAllowListViolationError(t("common:errors.violated_organization_allowlist"))
550544
}
551545

552-
const cline = new Task({
546+
const task = new Task({
553547
provider: this,
554548
apiConfiguration,
555549
enableDiff,
556550
enableCheckpoints,
557551
fuzzyMatchThreshold,
558552
consecutiveMistakeLimit: apiConfiguration.consecutiveMistakeLimit,
559-
task,
553+
task: text,
560554
images,
561555
experiments,
562556
rootTask: this.clineStack.length > 0 ? this.clineStack[0] : undefined,
563557
parentTask,
564558
taskNumber: this.clineStack.length + 1,
565-
onCreated: (cline) => this.emit("clineCreated", cline),
559+
onCreated: (instance) => this.emit("taskCreated", instance),
566560
...options,
567561
})
568562

569-
await this.addClineToStack(cline)
563+
await this.addClineToStack(task)
570564

571565
this.log(
572-
`[subtasks] ${cline.parentTask ? "child" : "parent"} task ${cline.taskId}.${cline.instanceId} instantiated`,
566+
`[subtasks] ${task.parentTask ? "child" : "parent"} task ${task.taskId}.${task.instanceId} instantiated`,
573567
)
574568

575-
return cline
569+
return task
576570
}
577571

578572
public async initClineWithHistoryItem(historyItem: HistoryItem & { rootTask?: Task; parentTask?: Task }) {
@@ -629,7 +623,7 @@ export class ClineProvider
629623
experiments,
630624
} = await this.getState()
631625

632-
const cline = new Task({
626+
const task = new Task({
633627
provider: this,
634628
apiConfiguration,
635629
enableDiff,
@@ -641,14 +635,16 @@ export class ClineProvider
641635
rootTask: historyItem.rootTask,
642636
parentTask: historyItem.parentTask,
643637
taskNumber: historyItem.number,
644-
onCreated: (cline) => this.emit("clineCreated", cline),
638+
onCreated: (instance) => this.emit("taskCreated", instance),
645639
})
646640

647-
await this.addClineToStack(cline)
641+
await this.addClineToStack(task)
642+
648643
this.log(
649-
`[subtasks] ${cline.parentTask ? "child" : "parent"} task ${cline.taskId}.${cline.instanceId} instantiated`,
644+
`[subtasks] ${task.parentTask ? "child" : "parent"} task ${task.taskId}.${task.instanceId} instantiated`,
650645
)
651-
return cline
646+
647+
return task
652648
}
653649

654650
public async postMessageToWebview(message: ExtensionMessage) {
@@ -1999,3 +1995,9 @@ export class ClineProvider
19991995
}
20001996
}
20011997
}
1998+
1999+
class OrganizationAllowListViolationError extends Error {
2000+
constructor(message: string) {
2001+
super(message)
2002+
}
2003+
}

src/extension/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ export class API extends EventEmitter<RooCodeEvents> implements RooCodeAPI {
214214
}
215215

216216
private registerListeners(provider: ClineProvider) {
217-
provider.on("clineCreated", (cline) => {
217+
provider.on("taskCreated", (cline) => {
218218
cline.on("taskStarted", async () => {
219219
this.emit(RooCodeEventName.TaskStarted, cline.taskId)
220220
this.taskMap.set(cline.taskId, provider)

src/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@
407407
"publish:marketplace": "vsce publish --no-dependencies && ovsx publish --no-dependencies",
408408
"watch:bundle": "pnpm bundle --watch",
409409
"watch:tsc": "cd .. && tsc --noEmit --watch --project src/tsconfig.json",
410-
"clean": "rimraf README.md CHANGELOG.md LICENSE dist mock .turbo"
410+
"clean": "rimraf README.md CHANGELOG.md LICENSE dist logs mock .turbo"
411411
},
412412
"dependencies": {
413413
"@anthropic-ai/bedrock-sdk": "^0.10.2",

0 commit comments

Comments
 (0)