@@ -126,6 +126,29 @@ function resolvePluginDoctorSessionRouteStateOwners(params: {
126126 return listPluginDoctorSessionRouteStateOwners ( { env : params . env } ) ;
127127}
128128
129+ function entryMayContainPluginSessionRouteState ( entry : SessionEntry ) : boolean {
130+ const record = entry as unknown as Record < string , unknown > ;
131+ return (
132+ normalizeString ( record . providerOverride ) !== undefined ||
133+ normalizeString ( record . modelOverride ) !== undefined ||
134+ normalizeString ( record . modelOverrideSource ) !== undefined ||
135+ record . liveModelSwitchPending !== undefined ||
136+ normalizeString ( record . modelProvider ) !== undefined ||
137+ normalizeString ( record . model ) !== undefined ||
138+ normalizeString ( record . agentHarnessId ) !== undefined ||
139+ record . cliSessionBindings !== undefined ||
140+ record . cliSessionIds !== undefined ||
141+ normalizeString ( record . authProfileOverride ) !== undefined ||
142+ normalizeString ( record . authProfileOverrideSource ) !== undefined
143+ ) ;
144+ }
145+
146+ export function storeMayContainPluginSessionRouteState (
147+ store : Record < string , SessionEntry > ,
148+ ) : boolean {
149+ return Object . values ( store ) . some ( ( entry ) => entryMayContainPluginSessionRouteState ( entry ) ) ;
150+ }
151+
129152export type DoctorSessionRouteState = {
130153 defaultProvider : string ;
131154 configuredModelRefs : string [ ] ;
@@ -434,6 +457,9 @@ export async function runPluginSessionStateDoctorRepairs(params: {
434457 warnings : string [ ] ;
435458 changes : string [ ] ;
436459} ) : Promise < void > {
460+ if ( ! storeMayContainPluginSessionRouteState ( params . store ) ) {
461+ return ;
462+ }
437463 const owners = resolvePluginDoctorSessionRouteStateOwners ( { env : params . env } ) ;
438464 if ( owners . length === 0 ) {
439465 return ;
0 commit comments