diff --git a/ui/src/ui/app-render.helpers.browser.test.ts b/ui/src/ui/app-render.helpers.browser.test.ts index bbb2aec7062..fdb83310b53 100644 --- a/ui/src/ui/app-render.helpers.browser.test.ts +++ b/ui/src/ui/app-render.helpers.browser.test.ts @@ -15,6 +15,9 @@ function createState(overrides: Partial = {}) { return { connected: true, chatLoading: false, + chatRunId: null, + chatSending: false, + chatStream: null, onboarding: false, sessionKey: "main", sessionsHideCron: true, @@ -49,6 +52,17 @@ function createState(overrides: Partial = {}) { } as unknown as AppViewState; } +function renderRefreshButton(overrides: Partial = {}) { + const container = document.createElement("div"); + render(renderChatControls(createState(overrides)), container); + + const button = container.querySelector( + `.chat-controls .btn--icon[data-tooltip="${t("chat.refreshTitle")}"]`, + ); + expect(button).not.toBeNull(); + return button!; +} + describe("chat header controls (browser)", () => { it("renders explicit hover tooltip metadata for the top-right action buttons", async () => { const container = document.createElement("div"); @@ -76,6 +90,19 @@ describe("chat header controls (browser)", () => { } }); + it.each([ + ["connected and idle", {}, false], + ["chat history loading", { chatLoading: true }, true], + ["chat send in flight", { chatSending: true }, true], + ["active run", { chatRunId: "run-123" }, true], + ["active stream", { chatStream: "streaming" }, true], + ["disconnected", { connected: false }, true], + ] as const)("sets refresh disabled state while %s", (_name, overrides, disabled) => { + const button = renderRefreshButton(overrides); + + expect(button.disabled).toBe(disabled); + }); + it("renders the cron session filter in the mobile dropdown controls", async () => { const state = createState({ sessionsResult: { diff --git a/ui/src/ui/app-render.helpers.ts b/ui/src/ui/app-render.helpers.ts index 4f7c6b9ea47..8faa31b053b 100644 --- a/ui/src/ui/app-render.helpers.ts +++ b/ui/src/ui/app-render.helpers.ts @@ -222,6 +222,12 @@ export function renderChatControls(state: AppViewState) { ? t("chat.showCronSessionsHidden", { count: String(hiddenCronCount) }) : t("chat.showCronSessions") : t("chat.hideCronSessions"); + const refreshDisabled = + !state.connected || + state.chatLoading || + state.chatSending || + Boolean(state.chatRunId) || + state.chatStream !== null; const toolCallsIcon = html`