Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
e168cbd
Throttle calls to calculate task folder size
cte Apr 22, 2025
e72208f
feat: allow variable interpolation into the custom system prompt (#2863)
daniel-lxs Apr 23, 2025
6f26cb5
fix: allow opening files without workspace root (#1054)
hannesrudolph Apr 23, 2025
92171fe
Fix: Preserve editor state and prevent tab unpinning during diffs (#2…
seedlord Apr 23, 2025
40d1708
Bugfix/fix vscodellm model information (#2832)
QuinsZouls Apr 23, 2025
4563b53
Fix: focusInput open roo code panel (#2626) (#2817)
hongzio Apr 23, 2025
5059636
fix(mention): conditionally remove aftercursor content (#2732)
elianiva Apr 23, 2025
d3d96bc
feat: add `injectEnv` util, support env ref in mcp config (#2679)
NamesMT Apr 23, 2025
fd0fa0a
Update contributors list (#2867)
github-actions[bot] Apr 23, 2025
1ddc426
FakeAI "controller" object must not be copied (#2463)
wkordalski Apr 23, 2025
0570154
Remove unnecessary cost calculation from vscode-lm.ts (#2875)
d-oit Apr 23, 2025
0477226
Allow Amazon Bedrock Marketplace ARNs (#2874)
mlopezr Apr 23, 2025
558925a
OpenRouter Gemini caching (#2847)
cte Apr 23, 2025
95bed9a
v13.3.3 (#2876)
mrubens Apr 23, 2025
2689dbd
fix(chat): better loading feedback (#2750)
elianiva Apr 23, 2025
418e290
feat: add other useful variables to the custom system prompt (#2879)
daniel-lxs Apr 23, 2025
466328e
Use formatLargeNumber on token counts in task header (#2883)
cte Apr 23, 2025
3131a21
Package material icons in vsix (#2882)
cte Apr 23, 2025
9991f42
Gemini prompt caching (#2827)
cte Apr 23, 2025
2028dc7
PR feedback
cte Apr 23, 2025
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
33 changes: 23 additions & 10 deletions src/core/Cline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,11 @@ export class Cline extends EventEmitter<ClineEvents> {
}

private async addToApiConversationHistory(message: Anthropic.MessageParam) {
const messageWithTs = { ...message, ts: Date.now() }
const ts = Date.now()
const messageWithTs = { ...message, ts }
this.apiConversationHistory.push(messageWithTs)
await this.saveApiConversationHistory()
console.log(`addToApiConversationHistory: ${Date.now() - ts}ms`)
}

async overwriteApiConversationHistory(newHistory: Anthropic.MessageParam[]) {
Expand Down Expand Up @@ -362,7 +364,13 @@ export class Cline extends EventEmitter<ClineEvents> {
this.emit("message", { action: "updated", message: partialMessage })
}

private taskDirSize = 0
private taskDirSizeCheckedAt = 0
private readonly taskDirSizeCheckInterval = 30_000

private async saveClineMessages() {
const ts = Date.now()

try {
const taskDir = await this.ensureTaskDirectoryExists()
const filePath = path.join(taskDir, GlobalFileNames.uiMessages)
Expand All @@ -381,14 +389,15 @@ export class Cline extends EventEmitter<ClineEvents> {
)
]

let taskDirSize = 0

try {
taskDirSize = await getFolderSize.loose(taskDir)
} catch (err) {
console.error(
`[saveClineMessages] failed to get task directory size (${taskDir}): ${err instanceof Error ? err.message : String(err)}`,
)
if (Date.now() - this.taskDirSizeCheckedAt > this.taskDirSizeCheckInterval) {
try {
this.taskDirSize = await getFolderSize.loose(taskDir)
this.taskDirSizeCheckedAt = Date.now()
} catch (err) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When throttling the folder size calculation, if getFolderSize.loose(taskDir) fails (lines 392-400), the catch block logs the error but does not update taskDirSizeCheckedAt. This may result in repeated calls if the error persists. Consider updating taskDirSizeCheckedAt in a finally block (or even on error) to avoid continuous retries.

This comment was generated because it violated a code review rule: mrule_OR1S8PRRHcvbdFib.

console.error(
`[saveClineMessages] failed to get task directory size (${taskDir}): ${err instanceof Error ? err.message : String(err)}`,
)
}
}

await this.providerRef.deref()?.updateTaskHistory({
Expand All @@ -401,12 +410,14 @@ export class Cline extends EventEmitter<ClineEvents> {
cacheWrites: tokenUsage.totalCacheWrites,
cacheReads: tokenUsage.totalCacheReads,
totalCost: tokenUsage.totalCost,
size: taskDirSize,
size: this.taskDirSize,
workspace: this.cwd,
})
} catch (error) {
console.error("Failed to save cline messages:", error)
}

console.log(`saveClineMessages: ${Date.now() - ts}ms`)
}

// Communicate with webview
Expand Down Expand Up @@ -1885,11 +1896,13 @@ export class Cline extends EventEmitter<ClineEvents> {
// now add to apiconversationhistory
// need to save assistant responses to file before proceeding to tool use since user can exit at any moment and we wouldn't be able to save the assistant's response
let didEndLoop = false

if (assistantMessage.length > 0) {
await this.addToApiConversationHistory({
role: "assistant",
content: [{ type: "text", text: assistantMessage }],
})

telemetryService.captureConversationMessage(this.taskId, "assistant")

// NOTE: this comment is here for future reference - this was a workaround for userMessageContent not getting set to true. It was due to it not recursively calling for partial blocks when didRejectTool, so it would get stuck waiting for a partial block to complete before it could continue.
Expand Down