Skip to content

Commit e70bb39

Browse files
committed
More cleanup
1 parent 779f117 commit e70bb39

File tree

3 files changed

+33
-19
lines changed

3 files changed

+33
-19
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

src/core/task/Task.ts

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ 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

9998
export type TaskEvents = {
@@ -110,6 +109,10 @@ export type TaskEvents = {
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
@@ -280,10 +283,12 @@ export class Task extends EventEmitter<TaskEvents> {
280283
}
281284

282285
this.taskId = historyItem ? historyItem.id : crypto.randomUUID()
283-
// 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.
284288
this.workspacePath = parentTask
285289
? parentTask.workspacePath
286290
: getWorkspacePath(path.join(os.homedir(), "Desktop"))
291+
287292
this.instanceId = crypto.randomUUID().slice(0, 8)
288293
this.taskNumber = -1
289294

@@ -312,25 +317,26 @@ export class Task extends EventEmitter<TaskEvents> {
312317
this.parentTask = parentTask
313318
this.taskNumber = taskNumber
314319

315-
// Store the task's mode when it's created
316-
// 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.
317323
if (historyItem) {
318324
this._taskMode = historyItem.mode || defaultModeSlug
319325
this.taskModeReady = Promise.resolve()
320326
TelemetryService.instance.captureTaskRestarted(this.taskId)
321327
} else {
322-
// 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.
323329
this._taskMode = undefined
324330
this.taskModeReady = this.initializeTaskMode(provider)
325331
TelemetryService.instance.captureTaskCreated(this.taskId)
326332
}
327333

328-
// Only set up diff strategy if diff is enabled
334+
// Only set up diff strategy if diff is enabled.
329335
if (this.diffEnabled) {
330-
// Default to old strategy, will be updated if experiment is enabled
336+
// Default to old strategy, will be updated if experiment is enabled.
331337
this.diffStrategy = new MultiSearchReplaceDiffStrategy(this.fuzzyMatchThreshold)
332338

333-
// Check experiment asynchronously and update strategy if needed
339+
// Check experiment asynchronously and update strategy if needed.
334340
provider.getState().then((state) => {
335341
const isMultiFileApplyDiffEnabled = experiments.isEnabled(
336342
state.experiments ?? {},
@@ -1231,7 +1237,7 @@ export class Task extends EventEmitter<TaskEvents> {
12311237
}
12321238
} catch (error) {
12331239
console.error("Error disposing RooIgnoreController:", error)
1234-
// This is the critical one for the leak fix
1240+
// This is the critical one for the leak fix.
12351241
}
12361242

12371243
try {
@@ -1241,7 +1247,7 @@ export class Task extends EventEmitter<TaskEvents> {
12411247
}
12421248

12431249
try {
1244-
// If we're not streaming then `abortStream` won't be called
1250+
// If we're not streaming then `abortStream` won't be called.
12451251
if (this.isStreaming && this.diffViewProvider.isEditing) {
12461252
this.diffViewProvider.revertChanges().catch(console.error)
12471253
}
@@ -1848,6 +1854,7 @@ export class Task extends EventEmitter<TaskEvents> {
18481854

18491855
public async *attemptApiRequest(retryAttempt: number = 0): ApiStream {
18501856
const state = await this.providerRef.deref()?.getState()
1857+
18511858
const {
18521859
apiConfiguration,
18531860
autoApprovalEnabled,
@@ -1859,21 +1866,24 @@ export class Task extends EventEmitter<TaskEvents> {
18591866
profileThresholds = {},
18601867
} = state ?? {}
18611868

1862-
// Get condensing configuration for automatic triggers
1869+
// Get condensing configuration for automatic triggers.
18631870
const customCondensingPrompt = state?.customCondensingPrompt
18641871
const condensingApiConfigId = state?.condensingApiConfigId
18651872
const listApiConfigMeta = state?.listApiConfigMeta
18661873

1867-
// Determine API handler to use for condensing
1874+
// Determine API handler to use for condensing.
18681875
let condensingApiHandler: ApiHandler | undefined
1876+
18691877
if (condensingApiConfigId && listApiConfigMeta && Array.isArray(listApiConfigMeta)) {
1870-
// Using type assertion for the id property to avoid implicit any
1878+
// Using type assertion for the id property to avoid implicit any.
18711879
const matchingConfig = listApiConfigMeta.find((config: any) => config.id === condensingApiConfigId)
1880+
18721881
if (matchingConfig) {
18731882
const profile = await this.providerRef.deref()?.providerSettingsManager.getProfile({
18741883
id: condensingApiConfigId,
18751884
})
1876-
// Ensure profile and apiProvider exist before trying to build handler
1885+
1886+
// Ensure profile and apiProvider exist before trying to build handler.
18771887
if (profile && profile.apiProvider) {
18781888
condensingApiHandler = buildApiHandler(profile)
18791889
}

src/core/webview/ClineProvider.ts

Lines changed: 7 additions & 4 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"
@@ -1977,4 +1976,8 @@ export class ClineProvider
19771976
}
19781977
}
19791978

1980-
class OrganizationAllowListViolationError extends Error {}
1979+
class OrganizationAllowListViolationError extends Error {
1980+
constructor(message: string) {
1981+
super(message)
1982+
}
1983+
}

0 commit comments

Comments
 (0)