@kontsedal/olas-devtools 0.0.1-rc.0 → 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/store.ts CHANGED
@@ -134,6 +134,10 @@ export class DevtoolsStore {
134
134
  return
135
135
  case 'controller:disposed':
136
136
  this.tree$.set(setNodeState(this.tree$.peek(), event.path, 'disposed'))
137
+ // A controller that disposed mid-mutation (before `success`/`error`
138
+ // ever fired) would otherwise leave its `mutation:run` start entry
139
+ // in `mutationStarts` forever. Drop any starts under this path.
140
+ this.dropStartsForPath(event.path)
137
141
  return
138
142
  case 'cache:subscribed':
139
143
  this.pushCache({
@@ -212,6 +216,10 @@ export class DevtoolsStore {
212
216
  this.cache$.set([])
213
217
  this.mutations$.set([])
214
218
  this.fields$.set([])
219
+ // Drop pending mutation-start timing records too — `clearLogs()` is the
220
+ // user's "start fresh" gesture; any subsequent `success`/`error` for a
221
+ // pre-clear `run` would have produced a duration anchored to noise.
222
+ this.mutationStarts.clear()
215
223
  }
216
224
 
217
225
  // -----------------------------------------------------------------------
@@ -240,6 +248,23 @@ export class DevtoolsStore {
240
248
  this.mutationStarts.delete(key)
241
249
  return this.now() - startedAt
242
250
  }
251
+
252
+ /**
253
+ * Drop every pending mutation-start record under `path` (and its
254
+ * descendants). Called on `controller:disposed` so a dispose mid-mutation
255
+ * doesn't leave a permanent entry in `mutationStarts`.
256
+ */
257
+ private dropStartsForPath(path: readonly string[]): void {
258
+ if (this.mutationStarts.size === 0) return
259
+ const prefix = `${path.join('>')}>`
260
+ const exact = path.join('>')
261
+ for (const key of this.mutationStarts.keys()) {
262
+ const beforeHash = key.split('#')[0] ?? ''
263
+ if (beforeHash === exact || beforeHash.startsWith(prefix)) {
264
+ this.mutationStarts.delete(key)
265
+ }
266
+ }
267
+ }
243
268
  }
244
269
 
245
270
  function mutationKey(path: readonly string[], name: string | undefined): string {