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 snapshotSequence: number
} }
// Disabled: file checkpointing causes unbounded memory growth (100 snapshots × full file backups). // Throttled: file checkpointing remains enabled (gated by fileHistoryEnabled())
// See heap snapshot analysis — re-enable only after switching to incremental diffs. // 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 const MAX_SNAPSHOTS = 20
export type DiffStats = export type DiffStats =
| { | {

View File

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