fix: tighten as any usage in performanceShim and clarify fileHistory cap

- performanceShim: replace 'as any' on the onresourcetimingbufferfull
  getter/setter and the globalThis install guard with typed intersection
  casts, per the project's TS guideline.
- fileHistory: clarify the MAX_SNAPSHOTS comment so it reflects that
  checkpointing is throttled (cap reduced from 100 to 20), not disabled.
This commit is contained in:
claude-code-best
2026-05-05 13:25:35 +00:00
parent a5ca2c1a97
commit 056893ebb0
2 changed files with 12 additions and 7 deletions

View File

@@ -51,8 +51,9 @@ export type FileHistoryState = {
snapshotSequence: number
}
// Disabled: file checkpointing causes unbounded memory growth (100 snapshots × full file backups).
// See heap snapshot analysis — re-enable only after switching to incremental diffs.
// Throttled: file checkpointing remains enabled (gated by fileHistoryEnabled())
// but capped to mitigate unbounded memory growth (full file backups x N snapshots).
// See heap snapshot analysis; only raise this cap after switching to incremental diffs.
const MAX_SNAPSHOTS = 20
export type DiffStats =
| {

View File

@@ -145,10 +145,11 @@ const shim = {
return original.timeOrigin
},
get onresourcetimingbufferfull() {
return (original as any).onresourcetimingbufferfull
return (original as Performance & { onresourcetimingbufferfull?: unknown })
.onresourcetimingbufferfull
},
set onresourcetimingbufferfull(_v: any) {
// no-op prevent accumulation
set onresourcetimingbufferfull(_v: unknown) {
// no-op to prevent accumulation
},
toJSON() {
return original.toJSON()
@@ -161,8 +162,11 @@ const shim = {
* native Performance reference.
*/
export function installPerformanceShim(): void {
if ((globalThis as any).__performanceShimInstalled) return
;(globalThis as any).__performanceShimInstalled = true
const g = globalThis as typeof globalThis & {
__performanceShimInstalled?: boolean
}
if (g.__performanceShimInstalled) return
g.__performanceShimInstalled = true
globalThis.performance = shim
}