fix(webui): refresh pairing prompts on gateway changes (#6401)
This commit is contained in:
1 parent
9e9e22d331
commit
8af6313c56
26 files changed
+630
-82
No files matched your search
@@ -87,6 +87,7 @@ type SessionUpdateHandler = (
|
||||
workspaceScope?: WorkspaceScopePayload,
|
||||
) => void;
|
||||
type SidebarStateUpdateHandler = (state: SidebarStatePayload) => void;
|
||||
type PairingChangeHandler = () => void;
|
||||
type RunStatusHandler = (chatId: string, state: RunState) => void;
|
||||
|
||||
/** Structured errors surfaced to the UI.
|
||||
@@ -238,6 +239,8 @@ export class NanobotClient {
|
||||
private runCompletionHandlers = new Set<RunCompletionHandler>();
|
||||
private errorHandlers = new Set<ErrorHandler>();
|
||||
private taskNoticeHandlers = new Set<(notice: TaskNotice) => void>();
|
||||
private pairingChangeHandlers = new Set<PairingChangeHandler>();
|
||||
private readyHandlers = new Set<() => void>();
|
||||
private chatHandlers = new Map<string, Set<EventHandler>>();
|
||||
private transcriptHandlers = new Map<string, { handler: EventHandler }>();
|
||||
/** Inbound frames received while the transcript owner is absent, regardless of observers. */
|
||||
@@ -317,6 +320,16 @@ export class NanobotClient {
|
||||
};
|
||||
}
|
||||
|
||||
onPairingChange(handler: PairingChangeHandler): Unsubscribe {
|
||||
this.pairingChangeHandlers.add(handler);
|
||||
return () => { this.pairingChangeHandlers.delete(handler); };
|
||||
}
|
||||
|
||||
onReady(handler: () => void): Unsubscribe {
|
||||
this.readyHandlers.add(handler);
|
||||
return () => { this.readyHandlers.delete(handler); };
|
||||
}
|
||||
|
||||
onSidebarStateUpdate(handler: SidebarStateUpdateHandler): Unsubscribe {
|
||||
this.sidebarStateUpdateHandlers.add(handler);
|
||||
return () => {
|
||||
@@ -966,6 +979,9 @@ export class NanobotClient {
|
||||
this.upload = uploadCapability(parsed.upload);
|
||||
this.readyChatId = parsed.chat_id;
|
||||
this.knownChats.add(parsed.chat_id);
|
||||
for (const handler of this.readyHandlers) {
|
||||
try { handler(); } catch { /* One listener must not block another ready consumer. */ }
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -987,6 +1003,13 @@ export class NanobotClient {
|
||||
return;
|
||||
}
|
||||
|
||||
if (parsed.event === "pairing_changed") {
|
||||
for (const handler of this.pairingChangeHandlers) {
|
||||
try { handler(); } catch { /* One listener must not block another pairing refresh. */ }
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (parsed.event === "runtime_model_updated") {
|
||||
this.emitRuntimeModelUpdate(parsed.model_name || null, parsed.model_preset ?? null);
|
||||
return;
|
||||
|
||||
@@ -1572,6 +1572,7 @@ export type InboundEvent =
|
||||
/** Legacy persisted transcripts may carry the final reasoning text here. */
|
||||
text?: string;
|
||||
} & InboundTurnMetadata)
|
||||
| { event: "pairing_changed" }
|
||||
| {
|
||||
event: "runtime_model_updated";
|
||||
model_name: string;
|
||||
|
||||
Reference in new issue
Block a user