fix(whatsapp_agent): clarify privacy and align current channel setup
This commit is contained in:
1 parent
5a0f2c2dc3
commit
86f16ff493
22 files changed
+76
-20
No files matched your search
@@ -15,6 +15,7 @@ export type ChannelPresentation = {
|
||||
|
||||
export type ChannelSetupPresentation = {
|
||||
mode?: "webui" | "credentials" | "connect";
|
||||
privacyNotice?: string;
|
||||
primaryActionLabel?: string;
|
||||
command?: string;
|
||||
docsUrl?: string;
|
||||
|
||||
@@ -9,6 +9,7 @@ type ChannelFieldMessages = {
|
||||
export type ChannelMessages = {
|
||||
displayName?: string;
|
||||
setup: {
|
||||
privacyNotice?: string;
|
||||
primaryAction?: string;
|
||||
docsLabel?: string;
|
||||
officialLabel?: string;
|
||||
|
||||
@@ -50,6 +50,7 @@ export function channelSetup(
|
||||
});
|
||||
const presentation: ChannelSetupPresentation = {
|
||||
...definition,
|
||||
privacyNotice: setupMessages?.privacyNotice,
|
||||
primaryActionLabel: setupMessages?.primaryAction,
|
||||
docsLabel: setupMessages?.docsLabel,
|
||||
officialLabel: setupMessages?.officialLabel,
|
||||
|
||||
@@ -136,6 +136,11 @@ export function ChannelSetupSurfaceView({
|
||||
</div>
|
||||
</div>
|
||||
<ChannelRuntimeError message={feature.runtime_error} />
|
||||
{setup.privacyNotice ? (
|
||||
<p className="text-pretty text-sm leading-relaxed text-muted-foreground">
|
||||
{setup.privacyNotice}
|
||||
</p>
|
||||
) : null}
|
||||
<div className="flex flex-wrap items-center gap-4">
|
||||
<section className={cn("min-w-0", inlineActions ? "flex-[1_1_20rem]" : "w-full")}>
|
||||
<div className="flex flex-wrap items-center justify-between gap-2">
|
||||
|
||||
@@ -20,4 +20,5 @@ export const channelFeatures: Record<string, NanobotFeatureInfo> = {
|
||||
"wecom": {"name": "wecom","display_name": "WeCom","webui": "webui/index.ts","type": "channel","enabled": false,"installed": true,"configured": false,"ready": false,"status": "not_enabled","install_supported": true,"requires_restart": false,"runtime_status": "stopped","config_values": {},"configured_fields": [],"setup": {"fields": [{"key": "channels.wecom.botId","field": "botId","kind": "string","choices": [],"required": true},{"key": "channels.wecom.secret","field": "secret","kind": "secret","choices": [],"required": true},{"key": "channels.wecom.allowFrom","field": "allowFrom","kind": "list","choices": [],"required": false},{"key": "channels.wecom.welcomeMessage","field": "welcomeMessage","kind": "string","choices": [],"required": false}],"requirements": [{"alternatives": [["channels.wecom.botId"]]},{"alternatives": [["channels.wecom.secret"]]}],"official_url": "https://developer.work.weixin.qq.com/"}},
|
||||
"weixin": {"name": "weixin","display_name": "WeChat","webui": "webui/index.tsx","type": "channel","enabled": false,"installed": true,"configured": false,"ready": false,"status": "not_enabled","install_supported": true,"requires_restart": false,"runtime_status": "stopped","config_values": {},"configured_fields": [],"setup": {"fields": [{"key": "channels.weixin.allowFrom","field": "allowFrom","kind": "list","choices": [],"required": false},{"key": "channels.weixin.baseUrl","field": "baseUrl","kind": "string","choices": [],"required": false,"default_value": "https://ilinkai.weixin.qq.com"},{"key": "channels.weixin.cdnBaseUrl","field": "cdnBaseUrl","kind": "string","choices": [],"required": false,"default_value": "https://novac2c.cdn.weixin.qq.com/c2c"},{"key": "channels.weixin.routeTag","field": "routeTag","kind": "string","choices": [],"required": false},{"key": "channels.weixin.stateDir","field": "stateDir","kind": "string","choices": [],"required": false},{"key": "channels.weixin.pollTimeout","field": "pollTimeout","kind": "int","choices": [],"required": false,"default_value": "35"},{"key": "channels.weixin.sendProgress","field": "sendProgress","kind": "bool","choices": [],"required": false,"default_value": "false"},{"key": "channels.weixin.sendToolHints","field": "sendToolHints","kind": "bool","choices": [],"required": false,"default_value": "false"},{"key": "channels.weixin.replyProgressMessages","field": "replyProgressMessages","kind": "bool","choices": [],"required": false,"default_value": "false"},{"key": "channels.weixin.replyProgressMaxMessages","field": "replyProgressMaxMessages","kind": "int","choices": [],"required": false,"default_value": "2"},{"key": "channels.weixin.contextMessageBudget","field": "contextMessageBudget","kind": "int","choices": [],"required": false,"default_value": "8"},{"key": "channels.weixin.streaming","field": "streaming","kind": "bool","choices": [],"required": false,"default_value": "true"},{"key": "channels.weixin.blockStreaming","field": "blockStreaming","kind": "bool","choices": [],"required": false,"default_value": "false"},{"key": "channels.weixin.blockStreamingMinChars","field": "blockStreamingMinChars","kind": "int","choices": [],"required": false,"default_value": "1200"},{"key": "channels.weixin.blockStreamingMaxMessages","field": "blockStreamingMaxMessages","kind": "int","choices": [],"required": false,"default_value": "3"}],"requirements": [{"alternatives": [["channels.weixin.token"]]}],"official_url": "https://weixin.qq.com/"}},
|
||||
"whatsapp": {"name": "whatsapp","display_name": "WhatsApp","webui": "webui/index.tsx","type": "channel","enabled": false,"installed": true,"configured": false,"ready": false,"status": "not_enabled","install_supported": true,"requires_restart": false,"runtime_status": "stopped","config_values": {},"configured_fields": [],"setup": {"fields": [{"key": "channels.whatsapp.proxy","field": "proxy","kind": "string","choices": [],"required": false},{"key": "channels.whatsapp.allowFrom","field": "allowFrom","kind": "list","choices": [],"required": false},{"key": "channels.whatsapp.groupPolicy","field": "groupPolicy","kind": "enum","choices": ["mention","open"],"required": false,"default_value": "open"}],"requirements": [],"official_url": "https://faq.whatsapp.com/"}},
|
||||
"whatsapp_agent": {"name": "whatsapp_agent","display_name": "WhatsApp Agent Platform","webui": "webui/index.ts","type": "channel","enabled": false,"installed": true,"configured": false,"ready": false,"status": "not_enabled","install_supported": true,"requires_restart": false,"runtime_status": "stopped","config_values": {},"configured_fields": [],"setup": {"fields": [{"key": "channels.whatsapp_agent.token","field": "token","kind": "secret","choices": [],"required": true},{"key": "channels.whatsapp_agent.allowFrom","field": "allowFrom","kind": "list","choices": [],"required": false},{"key": "channels.whatsapp_agent.stateDir","field": "stateDir","kind": "string","choices": [],"required": false},{"key": "channels.whatsapp_agent.pollTimeout","field": "pollTimeout","kind": "int","choices": [],"required": false,"default_value": "25"},{"key": "channels.whatsapp_agent.markRead","field": "markRead","kind": "bool","choices": [],"required": false,"default_value": "true"},{"key": "channels.whatsapp_agent.typingIndicator","field": "typingIndicator","kind": "bool","choices": [],"required": false,"default_value": "true"},{"key": "channels.whatsapp_agent.downloadMedia","field": "downloadMedia","kind": "bool","choices": [],"required": false,"default_value": "true"},{"key": "channels.whatsapp_agent.deleteMediaAfterDownload","field": "deleteMediaAfterDownload","kind": "bool","choices": [],"required": false,"default_value": "false"},{"key": "channels.whatsapp_agent.maxMediaMb","field": "maxMediaMb","kind": "int","choices": [],"required": false,"default_value": "16"},{"key": "channels.whatsapp_agent.retryAmbiguousSends","field": "retryAmbiguousSends","kind": "bool","choices": [],"required": false,"default_value": "false"},{"key": "channels.whatsapp_agent.sendProgress","field": "sendProgress","kind": "bool","choices": [],"required": false,"default_value": "false"},{"key": "channels.whatsapp_agent.sendToolHints","field": "sendToolHints","kind": "bool","choices": [],"required": false,"default_value": "false"}],"requirements": [{"alternatives": [["channels.whatsapp_agent.token"]]}],"official_url": "https://faq.whatsapp.com/1050934623978152","verifies_connection": true}},
|
||||
};
|
||||
@@ -214,6 +214,39 @@ function catalogFeature(
|
||||
describe("Settings channels", () => {
|
||||
installSettingsViewTestHooks();
|
||||
|
||||
it("shows agent chat privacy before entering credentials or enabling the channel", async () => {
|
||||
vi.stubGlobal("fetch", vi.fn(async (input: RequestInfo | URL) => {
|
||||
const url = String(input);
|
||||
if (url === "/api/settings") return jsonResponse(settingsPayload());
|
||||
if (url === "/api/settings/nanobot-features") return jsonResponse({
|
||||
features: [{
|
||||
...catalogFeature("whatsapp_agent", false),
|
||||
display_name: "WhatsApp Agent Platform",
|
||||
webui: "webui/index.ts",
|
||||
setup: {
|
||||
verifies_connection: true,
|
||||
fields: [channelSetupField("whatsapp_agent", "token", "secret", { required: true })],
|
||||
requirements: [{ alternatives: [["channels.whatsapp_agent.token"]] }],
|
||||
},
|
||||
}],
|
||||
enabled_count: 0,
|
||||
});
|
||||
return jsonResponse({});
|
||||
}));
|
||||
|
||||
renderSettingsView({ initialSection: "channels" });
|
||||
fireEvent.click(await screen.findByRole("button", { name: "View WhatsApp Agent Platform settings" }));
|
||||
|
||||
const privacy = screen.getByText(/Agent chats are not end-to-end encrypted/);
|
||||
expect(privacy).toBeVisible();
|
||||
expect(privacy).toHaveTextContent("nanobot and your configured model provider");
|
||||
const token = screen.getByLabelText("API token");
|
||||
expect(token).toHaveValue("");
|
||||
expect(privacy.compareDocumentPosition(token) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
|
||||
expect(screen.getByRole("switch", { name: "Enable channel" })).not.toBeChecked();
|
||||
expect(requestMutationMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it.each([
|
||||
{
|
||||
name: "telegram",
|
||||
|
||||
Reference in new issue
Block a user