fix(usage): keep deleted worktrees' sessions in the Orca usage totals (#41218)

Usage attribution only knew live worktrees, so deleting one moved its
sessions out of the Orca scope on the next scan and Stats & Usage totals
went down. Remember every worktree Orca has had in a small usage-owned
history and attribute against live plus remembered worktrees, with live
rows claiming reused paths first. The history loads off the main thread,
scans wait for it, and an unreadable or newer file is never overwritten.
This commit is contained in:
Kelvin Amoaba
2026-11-11 19:07:05 +00:00
committed by GitHub
parent d5f6fe17bf
commit d46cf4b295
15 changed files with 303 additions and 30 deletions
+2 -2
View File
@@ -11,7 +11,7 @@ import type {
OpenCodeUsageSnapshot,
OpenCodeUsageSummary
} from '../../shared/opencode-usage-types'
import type { Store } from '../persistence/loading-store/store'
import type { UsageWorktreeSource } from '../usage/worktree-attribution/usage-worktree-metadata'
import type {
OpenCodeUsageDailyAggregate,
OpenCodeUsagePersistedState,
@@ -50,7 +50,7 @@ export class OpenCodeUsageStore extends UsageProviderStoreLifecycle<
OpenCodeUsagePersistedState,
'hasAnyOpenCodeData'
> {
constructor(store: Pick<Store, 'getRepos' | 'getAllWorktreeMeta'>) {
constructor(store: UsageWorktreeSource) {
super(store, {
tokenUsage: {
provider: 'opencode',