MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / saveClineMessages

Method saveClineMessages

src/core/task/Task.ts:1098–1136  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1096 }
1097
1098 private async saveClineMessages(): Promise<boolean> {
1099 try {
1100 await saveTaskMessages({
1101 messages: structuredClone(this.clineMessages),
1102 taskId: this.taskId,
1103 globalStoragePath: this.globalStoragePath,
1104 })
1105
1106 if (this._taskApiConfigName === undefined) {
1107 await this.taskApiConfigReady
1108 }
1109
1110 const { historyItem, tokenUsage } = await taskMetadata({
1111 taskId: this.taskId,
1112 rootTaskId: this.rootTaskId,
1113 parentTaskId: this.parentTaskId,
1114 taskNumber: this.taskNumber,
1115 messages: this.clineMessages,
1116 globalStoragePath: this.globalStoragePath,
1117 workspace: this.cwd,
1118 mode: this._taskMode || defaultModeSlug, // Use the task's own mode, not the current provider mode.
1119 apiConfigName: this._taskApiConfigName, // Use the task's own provider profile, not the current provider profile.
1120 initialStatus: this.initialStatus,
1121 })
1122
1123 // Emit token/tool usage updates using debounced function
1124 // The debounce with maxWait ensures:
1125 // - Immediate first emit (leading: true)
1126 // - At most one emit per interval during rapid updates (maxWait)
1127 // - Final state is emitted when updates stop (trailing: true)
1128 this.debouncedEmitTokenUsage(tokenUsage, this.toolUsage)
1129
1130 await this.providerRef.deref()?.updateTaskHistory(historyItem)
1131 return true
1132 } catch (error) {
1133 console.error("Failed to save Roo messages:", error)
1134 return false
1135 }
1136 }
1137
1138 private findMessageByTimestamp(ts: number): ClineMessage | undefined {
1139 for (let i = this.clineMessages.length - 1; i >= 0; i--) {

Callers 11

addToClineMessagesMethod · 0.95
askMethod · 0.95
sayMethod · 0.95
abortTaskMethod · 0.95
abortStreamMethod · 0.95
captureUsageDataMethod · 0.95

Calls 4

saveTaskMessagesFunction · 0.90
taskMetadataFunction · 0.90
updateTaskHistoryMethod · 0.80
errorMethod · 0.65

Tested by

no test coverage detected