Skip to content

Your lightweight open-source personal agent.

fix(webui): offer restart in installed channel rows (NAN-334) (#6392)

chengyongru169062be110e
diff --git a/docs/webui.md b/docs/webui.md
index 6e261e734..566a62303 100644
--- a/docs/webui.md
+++ b/docs/webui.md
@@ -189,7 +189,7 @@ For image generation, configure an image provider first and then use the WebUI i
## Channels
-**Channels** provides credential or QR-based setup, connection validation, and restart guidance. Missing channel support can be installed from a local WebUI.
+**Channels** provides credential or QR-based setup, connection validation, and restart guidance. Missing channel support can be installed from a local WebUI. When newly installed support needs a restart, select the restart icon in that channel's row before continuing setup.
The platform itself may still require you to create a bot, enable event permissions, copy a token, or configure a webhook. Use [`chat-apps.md`](./chat-apps.md) for those platform-side prerequisites and for manual JSON/reference options.
diff --git a/nanobot/channels/websocket/tests/test_websocket_http_routes.py b/nanobot/channels/websocket/tests/test_websocket_http_routes.py
index 1376f7732..e4c3554a3 100644
--- a/nanobot/channels/websocket/tests/test_websocket_http_routes.py
+++ b/nanobot/channels/websocket/tests/test_websocket_http_routes.py
@@ -1408,13 +1408,34 @@ async def test_nanobot_feature_channel_action_can_apply_without_restart(
@pytest.mark.asyncio
-async def test_nanobot_feature_install_only_does_not_start_channel(
[email protected]("installed_now", [True, False])
+async def test_nanobot_feature_install_only_tracks_pending_restart_without_starting_channel(
bus: MagicMock,
tmp_path: Path,
monkeypatch: pytest.MonkeyPatch,
+ installed_now: bool,
) -> None:
runtime_calls: list[tuple[str, str, str | None]] = []
+ def features_payload(**_kwargs: Any) -> dict[str, Any]:
+ return {
+ "features": [{
+ "name": name,
+ "type": "channel",
+ "enabled": False,
+ "installed": True,
+ "ready": False,
+ "status": "not_enabled",
+ "requires_restart": True,
+ } for name in ("whatsapp", "email")],
+ "enabled_count": 0,
+ }
+
+ monkeypatch.setattr(
+ "nanobot.webui.settings_routes.nanobot_features_payload",
+ features_payload,
+ )
+
def feature_action(
action: str,
query: dict[str, list[str]],
@@ -1425,18 +1446,7 @@ async def test_nanobot_feature_install_only_does_not_start_channel(
assert action == "enable"
assert query == {"name": ["whatsapp"], "install_only": ["true"]}
assert allow_install is True
- return {
- "features": [{
- "name": "whatsapp",
- "type": "channel",
- "enabled": False,
- "installed": True,
- "ready": False,
- "status": "not_enabled",
- }],
- "enabled_count": 0,
- "requires_restart": False,
- }
+ return {**features_payload(), "requires_restart": installed_now}
async def channel_feature_action(
action: str,
@@ -1465,7 +1475,28 @@ async def test_nanobot_feature_install_only_does_not_start_channel(
assert response.status_code == 200
assert runtime_calls == []
- assert response.json()["features"][0]["enabled"] is False
+ features = response.json()["features"]
+ assert features[0]["enabled"] is False
+ assert [feature["restart_pending"] for feature in features] == [installed_now, False]
+
+ # Refreshing the catalog keeps the pending installation tied to its channel.
+ refreshed = await _http_get(
+ f"http://127.0.0.1:{channel.config.port}/api/settings/nanobot-features",
+ headers={"Authorization": f"Bearer {channel.gateway.tokens.issue_api_token(300)}"},
+ )
+ assert refreshed.status_code == 200
+ assert [feature["restart_pending"] for feature in refreshed.json()["features"]] == [
+ installed_now, False,
+ ]
+
+ # A new gateway owns a fresh runtime; installed support is ready to configure.
+ restarted = _ch(bus, session_manager=SessionManager(tmp_path), port=_free_port())
+ after_restart = await _http_get(
+ f"http://127.0.0.1:{restarted.config.port}/api/settings/nanobot-features",
+ headers={"Authorization": f"Bearer {restarted.gateway.tokens.issue_api_token(300)}"},
+ )
+ assert after_restart.status_code == 200
+ assert all(not feature["restart_pending"] for feature in after_restart.json()["features"])
@pytest.mark.asyncio
diff --git a/nanobot/webui/settings_system.py b/nanobot/webui/settings_system.py
index f5c4eee90..ad373da07 100644
--- a/nanobot/webui/settings_system.py
+++ b/nanobot/webui/settings_system.py
@@ -454,6 +454,7 @@ class SystemSettingsHandler:
self.logger = logger
self._admission = admission
self._channel_connectors: dict[str, ChannelConnector] = {}
+ self._pending_channel_restarts: set[str] = set()
self._remove_pending_work: Callable[[], None] | None = None
self._closing_connectors = False
self._update_jobs = UpdateJobService()
@@ -793,6 +794,8 @@ class SystemSettingsHandler:
action,
)
return SettingsRouteResult.failure(status, message)
+ if install_only and payload.get("requires_restart"):
+ self._pending_channel_restarts.add((query_first(request.query, "name") or "").strip())
if not install_only:
payload = await self._apply_feature_runtime_change(
action,
@@ -812,16 +815,22 @@ class SystemSettingsHandler:
payload: dict[str, Any],
operations: SystemSettingsOperations,
) -> dict[str, Any]:
- if operations.channel_runtime_status is None:
- return payload
- try:
- return with_channel_runtime_status(
- payload,
- operations.channel_runtime_status(),
- )
- except Exception:
- self.logger.exception("failed to load channel runtime status")
- return payload
+ if operations.channel_runtime_status is not None:
+ try:
+ payload = with_channel_runtime_status(
+ payload,
+ operations.channel_runtime_status(),
+ )
+ except Exception:
+ self.logger.exception("failed to load channel runtime status")
+ return {
+ **payload,
+ "features": [
+ {**feature, "restart_pending": feature["name"] in self._pending_channel_restarts}
+ if feature["type"] == "channel" else feature
+ for feature in payload["features"]
+ ],
+ }
async def _apply_feature_runtime_change(
self,
diff --git a/webui/src/components/settings/channels/ChannelCatalogRow.tsx b/webui/src/components/settings/channels/ChannelCatalogRow.tsx
index 55cbb5e64..859065ce0 100644
--- a/webui/src/components/settings/channels/ChannelCatalogRow.tsx
+++ b/webui/src/components/settings/channels/ChannelCatalogRow.tsx
@@ -1,9 +1,10 @@
import { useEffect, useRef, useState } from "react";
-import { Download, Loader2 } from "lucide-react";
+import { Download, Loader2, RotateCcw } from "lucide-react";
import { useTranslation } from "react-i18next";
import type { ChannelFeatureAction } from "@/channel-plugins/types";
import { ToggleButton } from "@/components/ui/toggle-button";
+import { HoverHint } from "@/components/ui/hover-hint";
import {
ChannelLogo,
ChannelStatusBadge,
@@ -20,15 +21,19 @@ export function ChannelCatalogRow({
showBrandLogos,
onSelect,
actionKey,
- actionsDisabled = false,
+ restartRequired = false,
onAction,
+ onRestart,
+ isRestarting = false,
}: {
feature: NanobotFeatureInfo;
showBrandLogos: boolean;
onSelect: (connect?: boolean) => void;
actionKey: string | null;
- actionsDisabled?: boolean;
+ restartRequired?: boolean;
onAction: ChannelFeatureAction;
+ onRestart?: () => void;
+ isRestarting?: boolean;
}) {
const { t } = useTranslation();
const tx = (key: string, fallback: string) => t(key, { defaultValue: fallback });
@@ -39,6 +44,8 @@ export function ChannelCatalogRow({
const ownActionBusy = pendingChecked !== null || actionKey === `install:${feature.name}`;
const checked = alwaysEnabled || (pendingChecked ?? channelToggleChecked(feature));
const anyActionBusy = Boolean(actionKey);
+ const actionsDisabled = restartRequired || isRestarting;
+ const showInstallRestartHint = feature.install_supported && actionsDisabled;
const installButtonRef = useRef<HTMLButtonElement | null>(null);
const [installHint, setInstallHint] = useState(false);
@@ -96,22 +103,43 @@ export function ChannelCatalogRow({
) : null}
<div className="flex w-16 shrink-0 items-center justify-center">
{!feature.installed ? (
- <Button ref={installButtonRef} type="button" variant="outline" size="icon"
- className={cn(
- "h-[22px] w-[38px] min-w-0 shrink-0 rounded-full border-border/70 bg-background p-0",
- installHint && "border-[#2997FF]/60 bg-[#2997FF]/10 text-[#087FE7] ring-2 ring-[#2997FF]/25 ring-offset-2",
- )}
- disabled={actionsDisabled || anyActionBusy || !feature.install_supported}
- aria-label={t("settings.channels.installChannel", { name: displayName })}
- onClick={() => {
- setInstallHint(false);
- onAction("enable", feature.name, { installOnly: true, confirmed: true });
- }}>
- {ownActionBusy
- ? <Loader2 className="h-3.5 w-3.5 animate-spin" aria-hidden />
- : <Download className="h-3.5 w-3.5" aria-hidden />}
- <span className="sr-only">{tx("settings.channels.install", "Install")}</span>
- </Button>
+ <HoverHint enabled={showInstallRestartHint}
+ content={t(isRestarting ? "app.system.restarting" : "settings.channels.restartBeforeInstall")}>
+ <span role={showInstallRestartHint ? "group" : undefined}
+ tabIndex={showInstallRestartHint ? 0 : undefined}
+ aria-label={showInstallRestartHint ? t("settings.channels.installChannel", { name: displayName }) : undefined}
+ className="inline-flex rounded-full outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2">
+ <Button ref={installButtonRef} type="button" variant="outline" size="icon"
+ className={cn(
+ "h-[22px] w-[38px] min-w-0 shrink-0 rounded-full border-border/70 bg-background p-0",
+ installHint && "border-[#2997FF]/60 bg-[#2997FF]/10 text-[#087FE7] ring-2 ring-[#2997FF]/25 ring-offset-2",
+ )}
+ disabled={actionsDisabled || anyActionBusy || !feature.install_supported}
+ aria-label={t("settings.channels.installChannel", { name: displayName })}
+ onClick={() => {
+ setInstallHint(false);
+ onAction("enable", feature.name, { installOnly: true, confirmed: true });
+ }}>
+ {ownActionBusy
+ ? <Loader2 className="h-3.5 w-3.5 animate-spin" aria-hidden />
+ : <Download className="h-3.5 w-3.5" aria-hidden />}
+ <span className="sr-only">{tx("settings.channels.install", "Install")}</span>
+ </Button>
+ </span>
+ </HoverHint>
+ ) : feature.restart_pending ? (
+ <HoverHint content={t("settings.channels.restartRequired")}>
+ <Button type="button" variant="outline" size="icon"
+ className="h-[22px] w-[38px] min-w-0 shrink-0 rounded-full border-border/70 bg-background p-0"
+ aria-label={t("app.system.restart")}
+ aria-busy={isRestarting}
+ disabled={isRestarting || anyActionBusy || !onRestart}
+ onClick={onRestart}>
+ {isRestarting
+ ? <Loader2 className="h-3.5 w-3.5 animate-spin" aria-hidden />
+ : <RotateCcw className="h-3.5 w-3.5" aria-hidden />}
+ </Button>
+ </HoverHint>
) : (
<ToggleButton checked={checked}
label={checked ? tx("settings.values.on", "On") : tx("settings.values.off", "Off")}
diff --git a/webui/src/components/settings/system/ChannelsSettings.tsx b/webui/src/components/settings/system/ChannelsSettings.tsx
index d252680ff..c8742da83 100644
--- a/webui/src/components/settings/system/ChannelsSettings.tsx
+++ b/webui/src/components/settings/system/ChannelsSettings.tsx
@@ -55,6 +55,7 @@ export function ChannelsSettings({
const hasEnabledConfigurableChannels = channels.some((feature) =>
feature.enabled && !feature.capabilities?.includes("always_enabled"));
const restartRequired = requiresRestartPending || Boolean(nanobotFeatures?.requires_restart);
+ const hasPendingChannelRestart = channels.some((feature) => feature.restart_pending);
useLayoutEffect(() => {
if (!nanobotFeatures || filterInitializedRef.current) return;
filterInitializedRef.current = true;
@@ -120,7 +121,7 @@ export function ChannelsSettings({
]} />
</div>
{error && !selectedChannel ? <DismissibleStatusMessage message={error} isError onDismiss={onDismissStatus} /> : null}
- {restartRequired ? (
+ {restartRequired && !hasPendingChannelRestart ? (
<RestartRequiredNotice message={t("settings.channels.restartRequired")}
onRestart={onRestart} isRestarting={isRestarting} />
) : null}
@@ -143,7 +144,8 @@ export function ChannelsSettings({
<div className="grid grid-cols-1 gap-x-4 gap-y-1 min-[640px]:grid-cols-2">
{group.channels.map((feature) => (
<ChannelCatalogRow key={feature.name} feature={feature} showBrandLogos={showBrandLogos}
- actionKey={actionKey} actionsDisabled={restartRequired || Boolean(isRestarting)} onAction={onAction}
+ actionKey={actionKey} restartRequired={restartRequired} onAction={onAction}
+ onRestart={onRestart} isRestarting={isRestarting}
onSelect={(connect = false) => {
triggerRef.current = document.activeElement instanceof HTMLElement ? document.activeElement : null;
beforeCloseRef.current = null;
diff --git a/webui/src/i18n/locales/en/common.json b/webui/src/i18n/locales/en/common.json
index 6ca24e4d6..828fa749e 100644
--- a/webui/src/i18n/locales/en/common.json
+++ b/webui/src/i18n/locales/en/common.json
@@ -1467,6 +1467,7 @@
"loading": "Loading channels…",
"empty": "No channels match this filter.",
"restartRequired": "Restart nanobot to apply updated channel support.",
+ "restartBeforeInstall": "Restart nanobot before installing another channel.",
"requires": "Requires: {{requirements}}",
"setUp": "Set up",
"setupGuide": "Setup guide",
diff --git a/webui/src/i18n/locales/es/common.json b/webui/src/i18n/locales/es/common.json
index 69a06bc4c..48441ba8e 100644
--- a/webui/src/i18n/locales/es/common.json
+++ b/webui/src/i18n/locales/es/common.json
@@ -1263,6 +1263,7 @@
"loading": "Cargando canales...",
"empty": "Ningún canal coincide con este filtro.",
"restartRequired": "Reinicia nanobot para aplicar el soporte de canales actualizado.",
+ "restartBeforeInstall": "Reinicia nanobot antes de instalar otro canal.",
"requires": "Requiere: {{requirements}}",
"setUp": "Configurar",
"setupGuide": "Guía de configuración",
diff --git a/webui/src/i18n/locales/fr/common.json b/webui/src/i18n/locales/fr/common.json
index 162f12ebc..7f227fd40 100644
--- a/webui/src/i18n/locales/fr/common.json
+++ b/webui/src/i18n/locales/fr/common.json
@@ -1262,6 +1262,7 @@
"loading": "Chargement des canaux...",
"empty": "Aucun canal ne correspond à ce filtre.",
"restartRequired": "Redémarrez nanobot pour appliquer le support de canal mis à jour.",
+ "restartBeforeInstall": "Redémarrez nanobot avant d’installer un autre canal.",
"requires": "Requiert : {{requirements}}",
"setUp": "Configurer",
"setupGuide": "Guide de configuration",
diff --git a/webui/src/i18n/locales/id/common.json b/webui/src/i18n/locales/id/common.json
index 06e684d08..8a31e8ded 100644
--- a/webui/src/i18n/locales/id/common.json
+++ b/webui/src/i18n/locales/id/common.json
@@ -1262,6 +1262,7 @@
"loading": "Memuat kanal...",
"empty": "Tidak ada kanal yang cocok dengan filter ini.",
"restartRequired": "Mulai ulang nanobot untuk menerapkan dukungan kanal yang diperbarui.",
+ "restartBeforeInstall": "Mulai ulang nanobot sebelum memasang kanal lain.",
"requires": "Memerlukan: {{requirements}}",
"setUp": "Siapkan",
"setupGuide": "Panduan penyiapan",
diff --git a/webui/src/i18n/locales/ja/common.json b/webui/src/i18n/locales/ja/common.json
index 188852eae..5a08308f7 100644
--- a/webui/src/i18n/locales/ja/common.json
+++ b/webui/src/i18n/locales/ja/common.json
@@ -1262,6 +1262,7 @@
"loading": "チャンネルを読み込み中...",
"empty": "一致するチャンネルはありません。",
"restartRequired": "更新したチャンネルサポートを反映するには nanobot を再起動してください。",
+ "restartBeforeInstall": "別のチャンネルをインストールするには、nanobot を再起動してください。",
"requires": "必要: {{requirements}}",
"setUp": "設定",
"setupGuide": "設定ガイド",
diff --git a/webui/src/i18n/locales/ko/common.json b/webui/src/i18n/locales/ko/common.json
index 86cfa63bc..ec5959d03 100644
--- a/webui/src/i18n/locales/ko/common.json
+++ b/webui/src/i18n/locales/ko/common.json
@@ -1262,6 +1262,7 @@
"loading": "채널을 불러오는 중...",
"empty": "일치하는 채널이 없습니다.",
"restartRequired": "업데이트된 채널 지원을 적용하려면 nanobot을 다시 시작하세요.",
+ "restartBeforeInstall": "다른 채널을 설치하려면 nanobot을 다시 시작하세요.",
"requires": "필요: {{requirements}}",
"setUp": "설정",
"setupGuide": "설정 가이드",
diff --git a/webui/src/i18n/locales/pt-BR/common.json b/webui/src/i18n/locales/pt-BR/common.json
index d8f9496d5..0ee9d5817 100644
--- a/webui/src/i18n/locales/pt-BR/common.json
+++ b/webui/src/i18n/locales/pt-BR/common.json
@@ -1276,6 +1276,7 @@
"loading": "Carregando canais...",
"empty": "Nenhum canal corresponde a este filtro.",
"restartRequired": "Reinicie o nanobot para aplicar o suporte de canais atualizado.",
+ "restartBeforeInstall": "Reinicie o nanobot antes de instalar outro canal.",
"requires": "Requer: {{requirements}}",
"setUp": "Configurar",
"setupGuide": "Guia de configuração",
diff --git a/webui/src/i18n/locales/vi/common.json b/webui/src/i18n/locales/vi/common.json
index 47875eea5..64ac5520f 100644
--- a/webui/src/i18n/locales/vi/common.json
+++ b/webui/src/i18n/locales/vi/common.json
@@ -1262,6 +1262,7 @@
"loading": "Đang tải kênh...",
"empty": "Không có kênh nào phù hợp.",
"restartRequired": "Khởi động lại nanobot để áp dụng hỗ trợ kênh đã cập nhật.",
+ "restartBeforeInstall": "Khởi động lại nanobot trước khi cài đặt kênh khác.",
"requires": "Yêu cầu: {{requirements}}",
"setUp": "Thiết lập",
"setupGuide": "Hướng dẫn thiết lập",
diff --git a/webui/src/i18n/locales/zh-CN/common.json b/webui/src/i18n/locales/zh-CN/common.json
index 44faa044a..db4e03c39 100644
--- a/webui/src/i18n/locales/zh-CN/common.json
+++ b/webui/src/i18n/locales/zh-CN/common.json
@@ -1467,6 +1467,7 @@
"loading": "正在加载聊天平台...",
"empty": "没有匹配的聊天平台。",
"restartRequired": "重启 nanobot 以应用更新后的聊天平台支持。",
+ "restartBeforeInstall": "重启 nanobot 后可继续安装。",
"requires": "需要:{{requirements}}",
"setUp": "设置",
"setupGuide": "配置指南",
diff --git a/webui/src/i18n/locales/zh-TW/common.json b/webui/src/i18n/locales/zh-TW/common.json
index 22b3348c2..1688e642f 100644
--- a/webui/src/i18n/locales/zh-TW/common.json
+++ b/webui/src/i18n/locales/zh-TW/common.json
@@ -1261,6 +1261,7 @@
"loading": "正在載入通訊管道…",
"empty": "沒有符合條件的通訊管道。",
"restartRequired": "重新啟動 nanobot 以套用更新後的通訊管道支援。",
+ "restartBeforeInstall": "重新啟動 nanobot 後即可繼續安裝。",
"requires": "需要:{{requirements}}",
"setUp": "設定",
"setupGuide": "設定指南",
diff --git a/webui/src/lib/types.ts b/webui/src/lib/types.ts
index cd58f1b79..2f7099218 100644
--- a/webui/src/lib/types.ts
+++ b/webui/src/lib/types.ts
@@ -1115,6 +1115,7 @@ export interface NanobotFeatureInfo {
status: "enabled" | "missing_dependency" | "not_enabled" | string;
install_supported: boolean;
requires_restart: boolean;
+ restart_pending?: boolean;
}
export interface ChannelSetupContractField {
diff --git a/webui/src/tests/settings-channels.test.tsx b/webui/src/tests/settings-channels.test.tsx
index 984409ad6..279a1f779 100644
--- a/webui/src/tests/settings-channels.test.tsx
+++ b/webui/src/tests/settings-channels.test.tsx
@@ -456,7 +456,8 @@ describe("Settings channels", () => {
expect(screen.getByRole("button", { name: "All" })).toHaveAttribute("aria-pressed", "true");
});
- it("requires a restart before enabling newly installed channel support", async () => {
+ it("replaces the installed channel switch with an in-row restart action", async () => {
+ const restart = vi.fn();
const whatsappFeature = {
name: "whatsapp",
display_name: "WhatsApp",
@@ -490,7 +491,7 @@ describe("Settings channels", () => {
finishInstall = resolve;
}));
const installedPayload = {
- features: [{ ...whatsappFeature, installed: true }, weixinFeature],
+ features: [{ ...whatsappFeature, installed: true, restart_pending: true }, weixinFeature],
enabled_count: 0,
requires_restart: true,
last_action: {
@@ -500,7 +501,7 @@ describe("Settings channels", () => {
},
};
- renderSettingsView({ initialSection: "channels" });
+ renderSettingsView({ initialSection: "channels", onRestart: restart });
requestMutationMock.mockResolvedValueOnce({ status: "pending", session_id: "test-link" });
expect(screen.queryByRole("switch", { name: "WhatsApp channel" })).not.toBeInTheDocument();
@@ -520,13 +521,56 @@ describe("Settings channels", () => {
);
finishInstall(installedPayload);
expect(requestMutationMock).not.toHaveBeenCalledWith("settings.channel.connect.start", expect.anything(), expect.anything());
- expect(await screen.findByText("Restart nanobot to apply updated channel support.")).toBeInTheDocument();
- const installedGroup = await screen.findByRole("region", { name: "Requires dependencies" });
- expect(within(installedGroup).getByRole("switch", { name: "WhatsApp channel" })).toBeDisabled();
+ const restartButton = await within(installationGroup).findByRole("button", { name: "Restart nanobot" });
+ const blockedInstallHint = within(installationGroup).getByRole("group", { name: "Install WeChat" });
+ expect(secondInstall).toBeDisabled();
+ await act(async () => { blockedInstallHint.focus(); });
+ expect(await screen.findByRole("tooltip")).toHaveTextContent("Restart nanobot before installing another channel.");
+ await userEvent.setup().keyboard("{Enter}");
+ fireEvent.click(secondInstall);
+ expect(requestMutationMock).toHaveBeenCalledTimes(1);
+ expect(restartButton).toBeEnabled();
+ await act(async () => { restartButton.focus(); });
+ expect(await screen.findByRole("tooltip")).toHaveTextContent("Restart nanobot to apply updated channel support.");
+ expect(screen.queryByRole("switch", { name: "WhatsApp channel" })).not.toBeInTheDocument();
+ expect(restart).not.toHaveBeenCalled();
+ fireEvent.click(restartButton);
+ expect(restart).toHaveBeenCalledTimes(1);
expect(requestMutationMock.mock.calls.map(([action]) => action)).toEqual([
"settings.feature.enable",
]);
+ });
+ it("keeps a refreshed pending restart on its channel and restores switches after restart", async () => {
+ let restartPending = true;
+ const installed = { ...uninstalledConnectFeature("whatsapp"), installed: true };
+ const other = { ...catalogFeature("Existing", false), requires_restart: true };
+ vi.stubGlobal("fetch", vi.fn(async (input: RequestInfo | URL) => {
+ const url = String(input);
+ if (url === "/api/settings") {
+ return jsonResponse({ ...settingsPayload(), requires_restart: restartPending });
+ }
+ if (url === "/api/settings/nanobot-features") {
+ return jsonResponse({
+ features: [{ ...installed, restart_pending: restartPending }, other, uninstalledConnectFeature("weixin")],
+ enabled_count: 0,
+ requires_restart: restartPending,
+ });
+ }
+ return jsonResponse({});
+ }));
+ renderSettingsView({ initialSection: "channels" });
+
+ const installationGroup = await screen.findByRole("region", { name: "Requires dependencies" });
+ expect(await within(installationGroup).findByRole("button", { name: "Restart nanobot" })).toBeEnabled();
+ expect(screen.getByRole("switch", { name: "Existing channel" })).toBeDisabled();
+
+ restartPending = false;
+ await act(async () => { fireEvent(window, new Event("focus")); });
+ expect(await screen.findByRole("switch", { name: "WhatsApp channel" })).toBeEnabled();
+ expect(screen.getByRole("switch", { name: "WhatsApp channel" })).toHaveAttribute("aria-checked", "false");
+ expect(screen.getByRole("switch", { name: "Existing channel" })).toBeEnabled();
+ expect(screen.getByRole("button", { name: "Install WeChat" })).toBeEnabled();
});
it.each([
@@ -699,6 +743,7 @@ describe("Settings channels", () => {
fireEvent.click(await screen.findByRole("button", { name: "Install WhatsApp" }));
expect(await screen.findByRole("alert")).toHaveTextContent("Package install failed");
+ expect(screen.getByRole("button", { name: "Install WhatsApp" })).toBeEnabled();
expect(consoleError).toHaveBeenCalledWith(
"nanobot feature action failed",
expect.objectContaining({