perf: cap usage worktree canonicalization (#4263)

This commit is contained in:
Neil
2026-05-31 10:11:51 -07:00
committed by GitHub
parent c56f151cb6
commit 0856df806f
4 changed files with 77 additions and 15 deletions
+2 -7
View File
@@ -6,6 +6,7 @@ import { isAbsolute, join, posix, win32 } from 'path'
import type { Repo } from '../../shared/types'
import { areWorktreePathsEqual } from '../ipc/worktree-logic'
import Database from '../sqlite/sync-database'
import { canonicalizeUsageWorktreePaths } from '../usage-worktree-canonicalizer'
import type {
OpenCodeUsageAttributedEvent,
OpenCodeUsageDailyAggregate,
@@ -441,13 +442,7 @@ function isContainingPath(candidatePath: string, targetPath: string): boolean {
async function buildWorktreesWithCanonicalPaths(
worktrees: OpenCodeUsageWorktreeRef[]
): Promise<(OpenCodeUsageWorktreeRef & { canonicalPath: string })[]> {
const canonicalized = await Promise.all(
worktrees.map(async (worktree) => ({
...worktree,
canonicalPath: await canonicalizePath(worktree.path)
}))
)
return canonicalized.sort((left, right) => right.canonicalPath.length - left.canonicalPath.length)
return canonicalizeUsageWorktreePaths(worktrees, canonicalizePath)
}
async function canonicalizePath(pathValue: string): Promise<string> {