MCPcopy
hub / github.com/coder/mux / collectFullHistory

Method collectFullHistory

src/node/services/sessionUsageService.ts:103–113  ·  view source on GitHub ↗

* Collect all messages from iterateFullHistory into an array. * Usage rebuild needs every epoch for accurate totals.

(workspaceId: string)

Source from the content-addressed store, hash-verified

101 * Usage rebuild needs every epoch for accurate totals.
102 */
103 private async collectFullHistory(workspaceId: string): Promise<MuxMessage[]> {
104 const messages: MuxMessage[] = [];
105 const result = await this.historyService.iterateFullHistory(workspaceId, "forward", (chunk) => {
106 messages.push(...chunk);
107 });
108 if (!result.success) {
109 log.warn(`Failed to iterate history for ${workspaceId}: ${result.error}`);
110 return [];
111 }
112 return messages;
113 }
114
115 private getFilePath(workspaceId: string): string {
116 return path.join(this.config.getSessionDir(workspaceId), this.SESSION_USAGE_FILE);

Callers 3

setTokenStatsCacheMethod · 0.95
rollUpUsageIntoParentMethod · 0.95
getSessionUsageMethod · 0.95

Calls 2

iterateFullHistoryMethod · 0.80
pushMethod · 0.65

Tested by

no test coverage detected