
























@@ -45,7 +45,7 @@ import { isSessionRunActive } from "./session-run-state.ts";
4545import { normalizeLowercaseStringOrEmpty, normalizeOptionalString } from "./string-coerce.ts";
4646import type { ChatModelOverride, ModelCatalogEntry } from "./types.ts";
4747import type { SessionsListResult } from "./types.ts";
48-import type { ChatAttachment, ChatQueueItem } from "./ui-types.ts";
48+import type { ChatAttachment, ChatQueueItem, ChatSessionRefreshTarget } from "./ui-types.ts";
4949import { generateUUID } from "./uuid.ts";
5050import { isRenderableControlUiAvatarUrl } from "./views/agents-utils.ts";
5151@@ -77,7 +77,7 @@ export type ChatHost = ChatInputHistoryState & {
7777sessionsShowArchived?: boolean;
7878updateComplete?: Promise<unknown>;
7979requestUpdate?: () => void;
80-refreshSessionsAfterChat: Set<string>;
80+refreshSessionsAfterChat: Map<string, ChatSessionRefreshTarget>;
8181pendingAbort?: { runId?: string | null; sessionKey: string; agentId?: string } | null;
8282chatSubmitGuards?: Map<string, Promise<void>>;
8383assistantAgentId?: string | null;
@@ -250,6 +250,12 @@ function resolveSelectedGlobalAgentId(
250250return agentId ? normalizeAgentId(agentId) : undefined;
251251}
252252253+function resolveDefaultAgentIdForList(host: Pick<ChatHost, "agentsList" | "hello">): string {
254+return normalizeAgentId(
255+host.agentsList?.defaultId ?? readHelloDefaultAgentId(host) ?? DEFAULT_AGENT_ID,
256+);
257+}
258+253259function scopedAgentIdForSession(host: ChatHost, sessionKey: string | undefined | null) {
254260return isGlobalSessionKey(sessionKey)
255261 ? resolveSelectedGlobalAgentId(host)
@@ -291,6 +297,32 @@ export function scopedAgentParamsForSession(
291297return agentId ? { agentId } : {};
292298}
293299300+export function scopedAgentListParamsForSession(
301+host: Pick<ChatHost, "assistantAgentId" | "agentsList" | "hello">,
302+sessionKey: string,
303+) {
304+const parsed = parseAgentSessionKey(sessionKey);
305+const normalizedSessionKey = normalizeLowercaseStringOrEmpty(sessionKey);
306+const agentId =
307+parsed?.agentId ??
308+(normalizedSessionKey === "global"
309+ ? resolveSelectedGlobalAgentId(host)
310+ : normalizedSessionKey === "unknown"
311+ ? undefined
312+ : resolveDefaultAgentIdForList(host));
313+return agentId ? { agentId: normalizeAgentId(agentId) } : {};
314+}
315+316+export function scopedAgentListParamsForRefreshTarget(
317+host: Pick<ChatHost, "assistantAgentId" | "agentsList" | "hello">,
318+target: ChatSessionRefreshTarget,
319+) {
320+const agentId =
321+normalizeOptionalString(target.agentId) ??
322+scopedAgentListParamsForSession(host, target.sessionKey).agentId;
323+return agentId ? { agentId: normalizeAgentId(agentId) } : {};
324+}
325+294326export async function handleAbortChat(host: ChatHost, opts?: ChatAbortOptions) {
295327const activeRunId = host.chatRunId;
296328const clearDraft = () => {
@@ -593,12 +625,17 @@ async function sendQueuedChatMessage(
593625}
594626}
595627if (prepared.refreshSessions) {
628+const refreshTarget = {
629+ sessionKey,
630+agentId: prepared.agentId,
631+};
596632if (ack.status === "ok") {
597633void loadSessions(host as unknown as SessionsState, {
598634 ...createChatSessionsLoadOverrides(host),
635+ ...scopedAgentListParamsForRefreshTarget(host, refreshTarget),
599636});
600637} else {
601-host.refreshSessionsAfterChat.add(ack.runId);
638+host.refreshSessionsAfterChat.set(ack.runId, refreshTarget);
602639}
603640}
604641discardChatAttachmentDataUrls(excludeComposerAttachments(host, attachments));
@@ -1299,7 +1336,7 @@ export async function refreshChat(
12991336const secondaryRefresh = Promise.allSettled([
13001337loadSessions(host as unknown as SessionsState, {
13011338 ...createChatSessionsLoadOverrides(host),
1302- ...scopedAgentParamsForSession(host, host.sessionKey),
1339+ ...scopedAgentListParamsForSession(host, host.sessionKey),
13031340}),
13041341refreshChatAvatar(host),
13051342refreshChatModels(host),
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。