merge PR #4613: fix(coding-agent): refresh advisor on model role changes
This commit is contained in:
@@ -181,7 +181,12 @@ import { MODEL_ROLE_IDS, MODEL_ROLES } from "../config/model-roles";
|
||||
import { expandPromptTemplate, type PromptTemplate } from "../config/prompt-templates";
|
||||
import { buildServiceTierByFamily, serviceTierForAllFamilies, serviceTierSettingToTier } from "../config/service-tier";
|
||||
import type { Settings, SkillsSettings } from "../config/settings";
|
||||
import { getDefault, onAppendOnlyModeChanged, validateProviderMaxInFlightRequests } from "../config/settings";
|
||||
import {
|
||||
getDefault,
|
||||
onAppendOnlyModeChanged,
|
||||
onModelRolesChanged,
|
||||
validateProviderMaxInFlightRequests,
|
||||
} from "../config/settings";
|
||||
import { RawSseDebugBuffer } from "../debug/raw-sse-buffer";
|
||||
import { loadCapability } from "../discovery";
|
||||
import { expandApplyPatchToEntries, normalizeDiff, normalizeToLF, ParseError, previewPatch, stripBom } from "../edit";
|
||||
@@ -1562,6 +1567,7 @@ export class AgentSession {
|
||||
#cancelExitRecorder?: () => void;
|
||||
#exitRecorded = false;
|
||||
#unsubscribeAppendOnly?: () => void;
|
||||
#unsubscribeModelRoles?: () => void;
|
||||
/** Last (enable, providerId) tuple resolved by `#syncAppendOnlyContext` — used to skip no-op invalidations. */
|
||||
#lastAppendOnlyResolution?: { enable: boolean; providerId: string | undefined };
|
||||
#eventListeners: AgentSessionEventListener[] = [];
|
||||
@@ -2270,6 +2276,11 @@ export class AgentSession {
|
||||
this.#unsubscribeAgent = this.agent.subscribe(this.#handleAgentEvent);
|
||||
// Re-evaluate append-only context mode when the setting changes at runtime.
|
||||
this.#unsubscribeAppendOnly = onAppendOnlyModeChanged(_value => this.#syncAppendOnlyContext(this.model));
|
||||
this.#unsubscribeModelRoles = onModelRolesChanged(() => {
|
||||
if (!this.#advisorEnabled || this.#isDisposed) return;
|
||||
if (this.#advisors.length > 0 && !this.#advisorRuntimeMatchesCurrentConfig()) this.#stopAdvisorRuntime();
|
||||
this.#buildAdvisorRuntime(true);
|
||||
});
|
||||
}
|
||||
// -------------------------------------------------------------------------
|
||||
// Advisor runtime lifecycle
|
||||
@@ -5781,6 +5792,10 @@ export class AgentSession {
|
||||
this.#unsubscribeAppendOnly();
|
||||
this.#unsubscribeAppendOnly = undefined;
|
||||
}
|
||||
if (this.#unsubscribeModelRoles) {
|
||||
this.#unsubscribeModelRoles();
|
||||
this.#unsubscribeModelRoles = undefined;
|
||||
}
|
||||
this.#eventListeners = [];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user