fix: refresh model target after reconnect

This commit is contained in:
Yichen Jiang
2026-07-27 15:45:06 +08:00
parent 181ac52f8e
commit 7da7b182c9
6 changed files with 43 additions and 5 deletions
@@ -116,6 +116,24 @@ export class ModelDirectory {
this.store.update((s) => { s.effort = effort })
}
/**
* Drop the previous Host generation's projection and repull it. Clearing
* first prevents an unconsumed process-local selection from being displayed
* while the restarted Host has restored the last logged request target.
*/
resetConnected(): void {
if (this.disposed) return
++this.generation
this.store.update((s) => {
s.current = null
s.groups = []
s.failures = []
s.status = 'idle'
s.error = null
})
void this.load().catch(() => { /* the next menu open remains the explicit retry surface */ })
}
/** Scope teardown: late settlements lose write access to the store. */
dispose(): void {
this.disposed = true
@@ -41,6 +41,9 @@ export class ModelService extends Service {
*/
constructor(ctx: Context) {
super(ctx, 'models')
ctx.on('connection/reset', () => {
for (const directory of this.live.directories.values()) directory.resetConnected()
})
}
/**