mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 08:00:42 +00:00
fix(control-ui): keep agent main session visible
This commit is contained in:
@@ -547,6 +547,10 @@ describe("resolveSessionOptionGroups", () => {
|
||||
).toContain("subagent:4f2146de-887b-4176-9abe-91140082959b");
|
||||
});
|
||||
|
||||
it("keeps the active agent main session visible when no row exists yet", () => {
|
||||
expect(labelsForSessionOptions({ sessionKey: "agent:main:main" })).toEqual(["main"]);
|
||||
});
|
||||
|
||||
it("disambiguates duplicate grouped labels with scoped suffixes", () => {
|
||||
const labels = labelsForSessionOptions({
|
||||
sessionKey: "agent:main:subagent:4f2146de-887b-4176-9abe-91140082959b",
|
||||
|
||||
@@ -549,6 +549,10 @@ function isSessionKeyTiedToAgent(key: string, agentId: string, defaultAgentId: s
|
||||
return agentId === defaultAgentId;
|
||||
}
|
||||
|
||||
function isAgentMainSessionKey(key: string): boolean {
|
||||
return parseAgentSessionKey(key)?.rest === "main";
|
||||
}
|
||||
|
||||
function resolvePreferredSessionForAgent(state: AppViewState, agentId: string): string {
|
||||
const normalizedAgentId = normalizeAgentId(agentId);
|
||||
const defaultAgentId = normalizeAgentId(state.agentsList?.defaultId ?? "main");
|
||||
@@ -663,6 +667,8 @@ export function resolveSessionOptionGroups(
|
||||
}
|
||||
if (byKey.has(sessionKey)) {
|
||||
addOption(sessionKey);
|
||||
} else if (isAgentMainSessionKey(sessionKey)) {
|
||||
addOption(sessionKey);
|
||||
}
|
||||
|
||||
for (const group of groups.values()) {
|
||||
|
||||
@@ -873,6 +873,35 @@ describe("chat session controls", () => {
|
||||
expect(onSwitchSession).toHaveBeenCalledWith(state, "agent:beta:main");
|
||||
});
|
||||
|
||||
it("shows the active agent main session instead of a blank select when no row exists yet", () => {
|
||||
const { state } = createChatHeaderState();
|
||||
state.sessionKey = "agent:main:main";
|
||||
state.settings.sessionKey = "agent:main:main";
|
||||
state.agentsList = {
|
||||
defaultId: "main",
|
||||
mainKey: "agent:main:main",
|
||||
scope: "all",
|
||||
agents: [{ id: "main", name: "MB Black" }],
|
||||
};
|
||||
state.sessionsResult = {
|
||||
ts: 0,
|
||||
path: "",
|
||||
count: 0,
|
||||
defaults: { modelProvider: "openai", model: "gpt-5", contextTokens: null },
|
||||
sessions: [],
|
||||
};
|
||||
const container = document.createElement("div");
|
||||
render(renderChatSessionSelect(state), container);
|
||||
|
||||
const sessionSelect = container.querySelector<HTMLSelectElement>(
|
||||
'select[data-chat-session-select="true"]',
|
||||
);
|
||||
|
||||
expect(sessionSelect?.value).toBe("agent:main:main");
|
||||
expect([...sessionSelect!.options].map((option) => option.value)).toEqual(["agent:main:main"]);
|
||||
expect(sessionSelect?.selectedOptions[0]?.textContent?.trim()).toBe("main");
|
||||
});
|
||||
|
||||
it("patches the current session model and refreshes active tool visibility", async () => {
|
||||
const { state, request } = createChatHeaderState();
|
||||
state.agentsPanel = "tools";
|
||||
|
||||
Reference in New Issue
Block a user