272
return;
273
}
275
>
const customizations = await agent.getSessionCustomizations(URI.parse(session));
276
>
277
>
// Skip the dispatch when the resolved customizations match what the
278
>
// session state already holds. A single edit under a shared `~/.claude`
279
>
// tree fans out to every open session (and, via the agent-level
280
>
// `onDidCustomizationsChange`, is republished once per session), so
281
>
// without this guard a single change emitted O(N^2) identical
282
>
// `SessionCustomizationsChanged` envelopes. Comparing against the
283
>
// authoritative session state (rather than a side cache) keeps this
284
>
// correct across idle-eviction + restore: a restored session's state
285
>
// starts without customizations, so the first successful refresh always
286
>
// dispatches even if the resolved set matches the prior incarnation.
287
>
// It also needs no cleanup on session teardown. `undefined` (never
288
>
// published) never equals a resolved array, so the initial publish
289
>
// always goes through.
290
>
const current = this._stateManager.getSessionState(session)?.customizations;
291
if (current && equals(current, customizations)) {
292
return;
293
}
295
>
this._stateManager.dispatchServerAction(session, {
296
>
type: ActionType.SessionCustomizationsChanged,
297
>
customizations: [...customizations],
298
>
});
299
}
300