@@ -131,13 +131,13 @@ export class ProviderInstanceRegistry extends Context.Service<
131131
132132/**
133133 * Live registry entry: the materialized `ProviderInstance` + the fresh
134- * child scope its `create` effect ran in + the original `entry` envelope
135- * so `reconcile` can cheaply detect "no-op" updates.
134+ * child scope its `create` effect ran in + the latest `entry` envelope so
135+ * `reconcile` can compare subsequent runtime and presentation updates.
136136 */
137137interface LiveEntry {
138138 readonly instance : ProviderInstance ;
139139 readonly scope : Scope . Closeable ;
140- readonly entry : ProviderInstanceConfig ;
140+ entry : ProviderInstanceConfig ;
141141}
142142
143143/**
@@ -151,14 +151,18 @@ interface RegistryState {
151151}
152152
153153/**
154- * Structural equality on `ProviderInstanceConfig` envelopes. Used by
155- * `reconcile` to skip rebuilds when settings arrive unchanged. Config
156- * payloads are opaque `unknown` at the envelope layer; `Equal.equals`
157- * falls back to structural equality for plain records, which matches how
158- * the schema decode output is constructed.
154+ * Runtime identity equality on `ProviderInstanceConfig` envelopes. Changes
155+ * to display metadata are applied to the retained instance; driver, enable,
156+ * environment, and decoded config changes rebuild it. Config payloads are
157+ * opaque `unknown` at the envelope layer; `Equal.equals` falls back to
158+ * structural equality for plain records, which matches how the schema decode
159+ * output is constructed.
159160 */
160- const entryEqual = ( a : ProviderInstanceConfig , b : ProviderInstanceConfig ) : boolean =>
161- Equal . equals ( a , b ) ;
161+ const runtimeEntryEqual = ( a : ProviderInstanceConfig , b : ProviderInstanceConfig ) : boolean =>
162+ a . driver === b . driver &&
163+ a . enabled === b . enabled &&
164+ Equal . equals ( a . environment ?? [ ] , b . environment ?? [ ] ) &&
165+ Equal . equals ( a . config , b . config ) ;
162166
163167/**
164168 * Resolve an entry's enabled state. An explicit false on either the
@@ -269,13 +273,51 @@ const buildEntry = <R>(input: {
269273 } ;
270274 }
271275
276+ const baseInstance = createResult . success ;
277+ let live ! : LiveEntry ;
278+ const withPresentation = < T extends ServerProvider > ( snapshot : T ) : T => {
279+ const {
280+ displayName : _displayName ,
281+ accentColor : _accentColor ,
282+ ...snapshotWithoutPresentation
283+ } = snapshot ;
284+ return {
285+ ...snapshotWithoutPresentation ,
286+ ...( live . entry . displayName === undefined ? { } : { displayName : live . entry . displayName } ) ,
287+ ...( live . entry . accentColor === undefined ? { } : { accentColor : live . entry . accentColor } ) ,
288+ } as T ;
289+ } ;
290+ const snapshot = {
291+ ...baseInstance . snapshot ,
292+ getSnapshot : baseInstance . snapshot . getSnapshot . pipe ( Effect . map ( withPresentation ) ) ,
293+ refresh : baseInstance . snapshot . refresh . pipe ( Effect . map ( withPresentation ) ) ,
294+ streamChanges : baseInstance . snapshot . streamChanges . pipe ( Stream . map ( withPresentation ) ) ,
295+ } ;
296+ const baseSnapshotForCwd = baseInstance . snapshotForCwd ;
297+ const instance : ProviderInstance = {
298+ ...baseInstance ,
299+ get displayName ( ) {
300+ return live . entry . displayName ;
301+ } ,
302+ get accentColor ( ) {
303+ return live . entry . accentColor ;
304+ } ,
305+ snapshot,
306+ ...( baseSnapshotForCwd
307+ ? {
308+ snapshotForCwd : ( cwd : string ) =>
309+ baseSnapshotForCwd ( cwd ) . pipe ( Effect . map ( withPresentation ) ) ,
310+ }
311+ : { } ) ,
312+ } ;
313+ live = {
314+ instance,
315+ scope : childScope ,
316+ entry,
317+ } ;
272318 return {
273319 kind : "live" as const ,
274- live : {
275- instance : createResult . success ,
276- scope : childScope ,
277- entry,
278- } ,
320+ live,
279321 } ;
280322 } ) ;
281323
@@ -298,18 +340,19 @@ const makeReconcile = <R>(input: {
298340 nextRaw . map ( ( [ raw ] ) => ProviderInstanceId . make ( raw ) ) ,
299341 ) ;
300342
301- // 1. Close scopes for instances that disappeared or whose config
302- // changed. Do this BEFORE creating replacements so ids map 1-to-1
303- // to live scopes at all times.
343+ // 1. Close scopes for instances that disappeared or whose runtime
344+ // config changed. Do this BEFORE creating replacements so ids map
345+ // 1-to-1 to live scopes at all times.
304346 const removedIds : Array < ProviderInstanceId > = [ ] ;
305347 const replacedIds = new Set < ProviderInstanceId > ( ) ;
348+ let presentationChanged = false ;
306349 for ( const [ instanceId , live ] of previousEntries ) {
307350 if ( ! nextKeys . has ( instanceId ) ) {
308351 removedIds . push ( instanceId ) ;
309352 continue ;
310353 }
311354 const nextEntry = configMap [ instanceId ] ;
312- if ( nextEntry !== undefined && ! entryEqual ( live . entry , nextEntry ) ) {
355+ if ( nextEntry !== undefined && ! runtimeEntryEqual ( live . entry , nextEntry ) ) {
313356 replacedIds . add ( instanceId ) ;
314357 }
315358 }
@@ -334,7 +377,10 @@ const makeReconcile = <R>(input: {
334377
335378 const existing = previousEntries . get ( instanceId ) ;
336379 if ( existing !== undefined && ! replacedIds . has ( instanceId ) ) {
337- // No-op update: keep the existing live entry and scope.
380+ // Presentation-only update: keep the live instance and scope while
381+ // letting its presentation-aware snapshots read the new entry.
382+ presentationChanged ||= ! Equal . equals ( existing . entry , entry ) ;
383+ existing . entry = entry ;
338384 builtEntries . set ( instanceId , existing ) ;
339385 continue ;
340386 }
@@ -368,6 +414,7 @@ const makeReconcile = <R>(input: {
368414 orderChanged ||
369415 removedIds . length > 0 ||
370416 replacedIds . size > 0 ||
417+ presentationChanged ||
371418 builtEntries . size !== previousEntries . size ;
372419 const unavailableChanged =
373420 builtUnavailable . size !== previousUnavailable . size ||
0 commit comments