Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
fix(webui): use consistent chat names for scheduled tasks
Xubin Ren9a5542bc1509
diff --git a/docs/automations.md b/docs/automations.mdindex 62ea3c7fa..d052385a1 100644--- a/docs/automations.md+++ b/docs/automations.md@@ -143,7 +143,11 @@ message. Copy the `nanobot trigger ...` command from the WebUI and replace### Change the Chat for a Scheduled TaskOpen a scheduled task in **Automations**. **Run and reply in** shows its saved chat,-with the channel logo and name. To change it:+with the channel logo and name. WebUI chats use the same display names as the+sidebar. A renamed chat keeps its identity and task binding. Chats with the same+name show an `@handle` to help you tell them apart.++To change the chat:1. Select another chat from **Run and reply in**.2. Review the task instructions. Remove recipients you no longer want, but keepdiff --git a/webui/src/App.tsx b/webui/src/App.tsxindex 9cc58c3ae..ab0ec0059 100644--- a/webui/src/App.tsx+++ b/webui/src/App.tsx@@ -3094,6 +3094,7 @@ function Shell({skills={skills}onStartAutomationChat={onStartAutomationChat}titleOverrides={sidebarState.title_overrides}+ sessions={topicSessions}onSectionChange={onSettingsSectionChange}onLogout={onLogout}onRestart={onRestart}diff --git a/webui/src/components/settings/SettingsPage.tsx b/webui/src/components/settings/SettingsPage.tsxindex 5cd18f63b..bafdb76ab 100644--- a/webui/src/components/settings/SettingsPage.tsx+++ b/webui/src/components/settings/SettingsPage.tsx@@ -41,7 +41,7 @@ import { RuntimeConfigSettings } from "@/components/settings/system/RuntimeConfiimport { RuntimeSettings } from "@/components/settings/system/RuntimeSettings";import type { SettingsController } from "@/components/settings/useSettingsController";import type { SendAttachment, SendOptions } from "@/hooks/useNanobotStream";-import type { SessionAutomationJob, SkillSummary } from "@/lib/types";+import type { ChatSummary, SessionAutomationJob, SkillSummary } from "@/lib/types";import { cn } from "@/lib/utils";interface SettingsPageProps {@@ -60,6 +60,7 @@ interface SettingsPageProps {modelPreset?: string | null,) => boolean | void | Promise<boolean | void>;titleOverrides?: Record<string, string>;+ sessions?: ChatSummary[];onLogout?: () => void;isRestarting: boolean;hostChromeInset: boolean;@@ -76,6 +77,7 @@ export function SettingsPage({skills,onStartAutomationChat,titleOverrides,+ sessions,onLogout,isRestarting,hostChromeInset,@@ -584,6 +586,7 @@ export function SettingsPage({token={token}payload={automations}titleOverrides={titleOverrides}+ sessions={sessions}settingsSnapshot={controller.settings}onStartChat={onStartAutomationChat}loading={automationsLoading}diff --git a/webui/src/components/settings/SettingsView.tsx b/webui/src/components/settings/SettingsView.tsxindex 662552793..675df6181 100644--- a/webui/src/components/settings/SettingsView.tsx+++ b/webui/src/components/settings/SettingsView.tsx@@ -2,7 +2,7 @@ import { SettingsPage } from "@/components/settings/SettingsPage";import type { SettingsExitGuard, SettingsSectionKey } from "@/components/settings/contracts";import { useSettingsController } from "@/components/settings/useSettingsController";import type { SendAttachment, SendOptions } from "@/hooks/useNanobotStream";-import type { SettingsPayload, SkillSummary } from "@/lib/types";+import type { ChatSummary, SettingsPayload, SkillSummary } from "@/lib/types";export type { SettingsSectionKey } from "@/components/settings/contracts";@@ -25,6 +25,7 @@ interface SettingsViewProps {modelPreset?: string | null,) => boolean | void | Promise<boolean | void>;titleOverrides?: Record<string, string>;+ sessions?: ChatSummary[];onSectionChange?: (section: SettingsSectionKey) => void;onLogout?: () => void;onRestart?: () => void;@@ -47,6 +48,7 @@ export function SettingsView({skills = [],onStartAutomationChat,titleOverrides,+ sessions,onSectionChange,onLogout,onRestart,@@ -76,6 +78,7 @@ export function SettingsView({skills={skills}onStartAutomationChat={onStartAutomationChat}titleOverrides={titleOverrides}+ sessions={sessions}onLogout={onLogout}isRestarting={isRestarting}hostChromeInset={hostChromeInset}diff --git a/webui/src/components/settings/system/AutomationChatBinding.tsx b/webui/src/components/settings/system/AutomationChatBinding.tsxindex af57febbd..72d52fc95 100644--- a/webui/src/components/settings/system/AutomationChatBinding.tsx+++ b/webui/src/components/settings/system/AutomationChatBinding.tsx@@ -12,8 +12,9 @@ import { readLocalPreferences } from "@/lib/local-preferences";import type { AutomationChat, AutomationChatsPayload, AutomationChatUpdate, NanobotFeatureInfo, SessionAutomationJob } from "@/lib/types";export type ChangeAutomationChat = (job: SessionAutomationJob, values: AutomationChatUpdate) => Promise<void>;+export type AutomationChatNames = ReadonlyMap<string, { title: string; handle: string }>;-function ChatIdentity({ chat }: { chat: AutomationChat }) {+function ChatIdentity({ chat, title }: { chat: AutomationChat; title: string }) {const { t } = useTranslation();const owner = channelUiOwner(chat.channel);const presentation = channelUiPresentation(chat.channel);@@ -29,13 +30,14 @@ function ChatIdentity({ chat }: { chat: AutomationChat }) {: <span className="absolute left-0 top-0 origin-top-left scale-75"><ChannelLogo feature={feature} showBrandLogos={readLocalPreferences().brandLogos} /></span>}</span><span className="flex min-w-0 flex-wrap items-baseline gap-x-2 text-[13px] leading-5">- <span className="min-w-0 break-words">{chat.title}</span><span className="text-[12px] text-muted-foreground">{platform}</span>+ <span className="min-w-0 break-words">{title}</span><span className="text-[12px] text-muted-foreground">{platform}</span></span></span>;}-export function AutomationChatBinding({ job, token, onSave, children }: {+export function AutomationChatBinding({ job, token, chatNames, onSave, children }: {job: SessionAutomationJob; token: string; onSave: ChangeAutomationChat;+ chatNames?: AutomationChatNames;children: (picker: ReactNode) => ReactNode;}) {const { t } = useTranslation();@@ -72,6 +74,18 @@ export function AutomationChatBinding({ job, token, onSave, children }: {const back = () => { returning.current = true; setDraft(null); };const current = data?.current;const fallback: AutomationChat = { id: "current", title: job.origin?.title || tx("current"), channel: job.origin?.channel || "websocket" };+ const baseTitle = (chat: AutomationChat) => chatNames?.get(chat.id)?.title ?? chat.title;+ const counts = new Map<string, number>();+ for (const chat of data?.chats ?? []) {+ const title = baseTitle(chat);+ counts.set(title, (counts.get(title) ?? 0) + 1);+ }+ const chatTitle = (chat: AutomationChat) => {+ const title = baseTitle(chat);+ const name = chatNames?.get(chat.id);+ return name && (counts.get(title) ?? 0) > 1 ? `${title} · @${name.handle}` : title;+ };+ const identity = (chat: AutomationChat) => <ChatIdentity chat={chat} title={chatTitle(chat)} />;const targetUnavailable = Boolean(draft && data && !data.chats.some(chat => chat.id === draft.target.id && !chat.unavailable));const picker = (review: boolean) => <Select value={review ? draft?.target.id : current?.id ?? "current"}disabled={pickerDisabled} onValueChange={id => {@@ -85,13 +99,13 @@ export function AutomationChatBinding({ job, token, onSave, children }: {}}><SelectTrigger ref={review ? undefined : trigger} aria-label={tx(review ? "new" : "label")}className="h-auto min-h-11 w-full py-2 [&>span:first-child]:min-w-0 [&>span:first-child]:flex-1 [&>span:first-child]:text-start">- <SelectValue><ChatIdentity chat={(review ? draft?.target : current) ?? fallback} /></SelectValue>+ <SelectValue>{identity((review ? draft?.target : current) ?? fallback)}</SelectValue></SelectTrigger><SelectContent>- {!current ? <SelectItem value="current" disabled><ChatIdentity chat={fallback} /></SelectItem> : null}- {data?.chats.map(chat => <SelectItem key={chat.id} value={chat.id} textValue={`${chat.title} ${chat.channel}`}+ {!current ? <SelectItem value="current" disabled>{identity(fallback)}</SelectItem> : null}+ {data?.chats.map(chat => <SelectItem key={chat.id} value={chat.id} textValue={`${chatTitle(chat)} ${chat.channel}`}disabled={chat.unavailable || (review && chat.id === current?.id)}- className="h-auto min-h-11 py-2 [&>span:first-child]:min-w-0 [&>span:first-child]:max-w-[calc(100vw-5rem)] [&>span:first-child]:w-full"><ChatIdentity chat={chat} /></SelectItem>)}+ className="h-auto min-h-11 py-2 [&>span:first-child]:min-w-0 [&>span:first-child]:max-w-[calc(100vw-5rem)] [&>span:first-child]:w-full">{identity(chat)}</SelectItem>)}</SelectContent></Select>;const save = async () => {@@ -113,14 +127,14 @@ export function AutomationChatBinding({ job, token, onSave, children }: {<p className="text-[13px] font-medium">{tx("label")}</p>{picker(false)}<p role={saved ? "status" : undefined} className="text-[12px] leading-5 text-muted-foreground">- {job.state.pending ? tx("busy") : saved ? tx("saved", { chat: saved.target.title }) : tx("hint")}+ {job.state.pending ? tx("busy") : saved ? tx("saved", { chat: chatTitle(saved.target) }) : tx("hint")}</p>{saved && current?.id === saved.target.id && data?.chats.some(chat => chat.id === saved.previous.id && !chat.unavailable) ? (<Button variant="link" size="sm" className="h-11 justify-start whitespace-normal p-0 text-start text-[12px] sm:h-auto" disabled={pickerDisabled}onClick={() => {setError("");setDraft({ target: saved.previous, previous: current, revision: data.revision, message: job.payload.message });- }}>{tx("changeBack", { chat: saved.previous.title })}</Button>+ }}>{tx("changeBack", { chat: chatTitle(saved.previous) })}</Button>) : null}{loadError ? <Button variant="link" size="sm" onClick={() => setReload(value => value + 1)}>{tx("retry")}</Button> : null}{data && data.chats.length <= (current ? 1 : 0) ? <p className="text-[12px] leading-5 text-muted-foreground">{tx("available")}</p> : null}@@ -133,7 +147,7 @@ export function AutomationChatBinding({ job, token, onSave, children }: {<div className="space-y-2"><div role="group" aria-label={tx("previous")} className="flex min-w-0 items-start gap-3 pb-1 text-muted-foreground"><span className="shrink-0 text-[12px] leading-6">{tx("previous")}</span>- <ChatIdentity chat={draft.previous} />+ {identity(draft.previous)}</div><p className="text-[13px] font-medium">{tx("new")}</p>{picker(true)}diff --git a/webui/src/components/settings/system/AutomationsSettings.tsx b/webui/src/components/settings/system/AutomationsSettings.tsxindex fa8fa1869..daf94c9f1 100644--- a/webui/src/components/settings/system/AutomationsSettings.tsx+++ b/webui/src/components/settings/system/AutomationsSettings.tsx@@ -15,7 +15,7 @@ import { useTranslation } from "react-i18next";import { channelTranslator } from "@/channel-plugins/i18n";import { channelUiOwner, channelUiPresentation } from "@/channel-plugins/registry";import { AutomationCalendar } from "@/components/settings/system/AutomationCalendar";-import { AutomationChatBinding, type ChangeAutomationChat } from "@/components/settings/system/AutomationChatBinding";+import { AutomationChatBinding, type AutomationChatNames, type ChangeAutomationChat } from "@/components/settings/system/AutomationChatBinding";import { AutomationRunAtPicker, parseAutomationRunAt } from "@/components/settings/system/AutomationRunAtPicker";import {modelPresetOptionsFromSettings,@@ -46,6 +46,7 @@ import type { SendAttachment, SendOptions } from "@/hooks/useNanobotStream";import type {AutomationsPayload,AutomationUpdatePayload,+ ChatSummary,SessionAutomationJob,SettingsPayload,} from "@/lib/types";@@ -55,11 +56,13 @@ export type AutomationFilter = "all" | "active" | "paused" | "failed" | "system"export type AutomationAction = "enable" | "disable" | "delete" | "run";const EMPTY_TITLE_OVERRIDES: Record<string, string> = {};+const EMPTY_SESSIONS: ChatSummary[] = [];export function AutomationsSettings({token = "",payload, loading, filter, actionKey, error,titleOverrides = EMPTY_TITLE_OVERRIDES,+ sessions = EMPTY_SESSIONS,settingsSnapshot = null,onFilterChange, onAction,onRequestEdit, onRequestDelete, onStartChat, onManageModels,@@ -69,6 +72,7 @@ export function AutomationsSettings({token?: string;payload: AutomationsPayload | null;titleOverrides?: Record<string, string>;+ sessions?: ChatSummary[];settingsSnapshot?: SettingsPayload | null;loading: boolean;filter: AutomationFilter;@@ -92,6 +96,13 @@ export function AutomationsSettings({const { t, i18n } = useTranslation();const tx = (key: string, fallback: string, values?: Record<string, unknown>) =>t(key, { defaultValue: fallback, ...(values ?? {}) });+ // Join display names by the server-owned handle ID, never by a mutable title.+ const chatNames: AutomationChatNames = useMemo(() => new Map(sessions.flatMap(session => (+ session.handle ? [[session.handle.id, {+ title: displayTitle(session, titleOverrides, t("chat.newChat")),+ handle: session.handle.name,+ }] as const] : []+ ))), [sessions, titleOverrides, t]);const jobs = useMemo(() => (payload?.jobs ?? []).map((job) => {const origin = job.origin;if (origin?.channel !== "websocket") return job;@@ -367,6 +378,7 @@ export function AutomationsSettings({<AutomationDetailDialogtoken={token}+ chatNames={chatNames}onChangeChat={onChangeChat}job={selectedJob}open={detailOpen}@@ -395,6 +407,7 @@ export function AutomationsSettings({export function AutomationDetailDialog({token = "",+ chatNames,onChangeChat,job,open,@@ -408,6 +421,7 @@ export function AutomationDetailDialog({onCloseAutoFocus,}: {token?: string;+ chatNames?: AutomationChatNames;onChangeChat?: ChangeAutomationChat;job: SessionAutomationJob | null;open: boolean;@@ -438,7 +452,7 @@ export function AutomationDetailDialog({onCloseAutoFocus={onCloseAutoFocus}>{job.chat_binding_revision && onChangeChat ? (- <AutomationChatBinding key={job.id} job={job} token={token} onSave={onChangeChat}>{panel}</AutomationChatBinding>+ <AutomationChatBinding key={job.id} job={job} token={token} chatNames={chatNames} onSave={onChangeChat}>{panel}</AutomationChatBinding>) : panel()}</DialogContent>) : null}diff --git a/webui/src/i18n/locales/en/common.json b/webui/src/i18n/locales/en/common.jsonindex 582d74dd1..618dcc8e6 100644--- a/webui/src/i18n/locales/en/common.json+++ b/webui/src/i18n/locales/en/common.json@@ -1724,7 +1724,7 @@"unpin": "Unpin","rename": "Rename","renameTitle": "Rename topic",- "renameDescription": "Choose a local sidebar name for this topic.",+ "renameDescription": "Choose a display name for this topic in WebUI.","renamePlaceholder": "Topic name","renameProjectTitle": "Rename project","renameProjectDescription": "Choose a local sidebar name for this project.",diff --git a/webui/src/i18n/locales/es/common.json b/webui/src/i18n/locales/es/common.jsonindex f45c165ca..fc6cbdc58 100644--- a/webui/src/i18n/locales/es/common.json+++ b/webui/src/i18n/locales/es/common.json@@ -1525,7 +1525,7 @@"unpin": "Desfijar","rename": "Renombrar","renameTitle": "Renombrar tema",- "renameDescription": "Elige un nombre local de la barra lateral para este tema.",+ "renameDescription": "Elige el nombre que se mostrará para este tema en WebUI.","renamePlaceholder": "Nombre del tema","renameProjectTitle": "Renombrar proyecto","renameProjectDescription": "Elige un nombre local para este proyecto en la barra lateral.",diff --git a/webui/src/i18n/locales/fr/common.json b/webui/src/i18n/locales/fr/common.jsonindex bafda39da..ec5034c65 100644--- a/webui/src/i18n/locales/fr/common.json+++ b/webui/src/i18n/locales/fr/common.json@@ -1524,7 +1524,7 @@"unpin": "Désépingler","rename": "Renommer","renameTitle": "Renommer le sujet",- "renameDescription": "Choisissez un nom local dans la barre latérale pour ce sujet.",+ "renameDescription": "Choisissez le nom affiché pour ce sujet dans WebUI.","renamePlaceholder": "Nom du sujet","renameProjectTitle": "Renommer le projet","renameProjectDescription": "Choisissez un nom local dans la barre latérale pour ce projet.",diff --git a/webui/src/i18n/locales/id/common.json b/webui/src/i18n/locales/id/common.jsonindex 959946c8a..bd2d49fed 100644--- a/webui/src/i18n/locales/id/common.json+++ b/webui/src/i18n/locales/id/common.json@@ -1524,7 +1524,7 @@"unpin": "Lepas sematan","rename": "Ganti nama","renameTitle": "Ganti nama topik",- "renameDescription": "Pilih nama lokal di bilah sisi untuk topik ini.",+ "renameDescription": "Pilih nama tampilan untuk topik ini di WebUI.","renamePlaceholder": "Nama topik","renameProjectTitle": "Ganti nama proyek","renameProjectDescription": "Pilih nama lokal untuk proyek ini di bilah sisi.",diff --git a/webui/src/i18n/locales/ja/common.json b/webui/src/i18n/locales/ja/common.jsonindex 7c311465b..b51ffe749 100644--- a/webui/src/i18n/locales/ja/common.json+++ b/webui/src/i18n/locales/ja/common.json@@ -1524,7 +1524,7 @@"unpin": "ピン留めを解除","rename": "名前を変更","renameTitle": "トピック名を変更",- "renameDescription": "このトピックのサイドバー表示名を選択します。",+ "renameDescription": "このトピックの WebUI での表示名を設定します。","renamePlaceholder": "トピック名","renameProjectTitle": "プロジェクト名を変更","renameProjectDescription": "このプロジェクトのサイドバー表示名を選択します。",diff --git a/webui/src/i18n/locales/ko/common.json b/webui/src/i18n/locales/ko/common.jsonindex 9cb023cf8..c63689a08 100644--- a/webui/src/i18n/locales/ko/common.json+++ b/webui/src/i18n/locales/ko/common.json@@ -1524,7 +1524,7 @@"unpin": "고정 해제","rename": "이름 변경","renameTitle": "주제 이름 변경",- "renameDescription": "이 주제에 사용할 사이드바 이름을 선택하세요.",+ "renameDescription": "WebUI에서 이 주제에 표시할 이름을 선택하세요.","renamePlaceholder": "주제 이름","renameProjectTitle": "프로젝트 이름 변경","renameProjectDescription": "이 프로젝트에 사용할 사이드바 이름을 선택하세요.",diff --git a/webui/src/i18n/locales/pt-BR/common.json b/webui/src/i18n/locales/pt-BR/common.jsonindex bf8bc31ae..799792d76 100644--- a/webui/src/i18n/locales/pt-BR/common.json+++ b/webui/src/i18n/locales/pt-BR/common.json@@ -1538,7 +1538,7 @@"unpin": "Desafixar","rename": "Renomear","renameTitle": "Renomear tópico",- "renameDescription": "Escolha um nome local da barra lateral para este tópico.",+ "renameDescription": "Escolha um nome de exibição para este tópico na WebUI.","renamePlaceholder": "Nome do tópico","renameProjectTitle": "Renomear projeto","renameProjectDescription": "Escolha um nome local da barra lateral para este projeto.",diff --git a/webui/src/i18n/locales/vi/common.json b/webui/src/i18n/locales/vi/common.jsonindex 2e5d441dd..84a1efa5f 100644--- a/webui/src/i18n/locales/vi/common.json+++ b/webui/src/i18n/locales/vi/common.json@@ -1524,7 +1524,7 @@"unpin": "Bỏ ghim","rename": "Đổi tên","renameTitle": "Đổi tên chủ đề",- "renameDescription": "Chọn tên hiển thị trong thanh bên cho chủ đề này.",+ "renameDescription": "Chọn tên hiển thị cho chủ đề này trong WebUI.","renamePlaceholder": "Tên chủ đề","renameProjectTitle": "Đổi tên dự án","renameProjectDescription": "Chọn tên hiển thị cục bộ cho dự án này trên thanh bên.",diff --git a/webui/src/i18n/locales/zh-CN/common.json b/webui/src/i18n/locales/zh-CN/common.jsonindex 52ddb2006..6bcd0825c 100644--- a/webui/src/i18n/locales/zh-CN/common.json+++ b/webui/src/i18n/locales/zh-CN/common.json@@ -1724,7 +1724,7 @@"unpin": "取消置顶","rename": "重命名","renameTitle": "重命名话题",- "renameDescription": "为这个话题设置一个仅用于 WebUI 侧边栏的名称。",+ "renameDescription": "设置这个话题在 WebUI 中显示的名称。","renamePlaceholder": "话题名称","renameProjectTitle": "重命名项目","renameProjectDescription": "为这个项目设置一个仅用于 WebUI 侧边栏的名称。",diff --git a/webui/src/i18n/locales/zh-TW/common.json b/webui/src/i18n/locales/zh-TW/common.jsonindex de75fc4a3..02b9fb7a6 100644--- a/webui/src/i18n/locales/zh-TW/common.json+++ b/webui/src/i18n/locales/zh-TW/common.json@@ -1524,7 +1524,7 @@"unpin": "取消置頂","rename": "重新命名","renameTitle": "重新命名話題",- "renameDescription": "為這個話題選擇僅顯示於本機側邊欄的名稱。",+ "renameDescription": "設定這個話題在 WebUI 中顯示的名稱。","renamePlaceholder": "話題名稱","renameProjectTitle": "重新命名專案","renameProjectDescription": "為這個專案選擇僅顯示於本機側邊欄的名稱。",diff --git a/webui/src/tests/automation-chat-binding.test.tsx b/webui/src/tests/automation-chat-binding.test.tsxindex fda25a9b3..cb3ed66b0 100644--- a/webui/src/tests/automation-chat-binding.test.tsx+++ b/webui/src/tests/automation-chat-binding.test.tsx@@ -1,10 +1,10 @@import { act, cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";import userEvent from "@testing-library/user-event";import { afterEach, beforeEach, expect, it, vi } from "vitest";-import { AutomationDetailDialog } from "@/components/settings/system/AutomationsSettings";+import { AutomationDetailDialog, AutomationsSettings } from "@/components/settings/system/AutomationsSettings";import { fetchAutomationChats } from "@/lib/api";import { setAppLanguage } from "@/i18n";-import type { AutomationChatsPayload, SessionAutomationJob } from "@/lib/types";+import type { AutomationChatsPayload, ChatSummary, SessionAutomationJob } from "@/lib/types";vi.mock("@/lib/api", () => ({ fetchAutomationChats: vi.fn() }));const source = { id: "source", title: "My planning", channel: "websocket" };@@ -158,3 +158,75 @@ it("keeps the current chat visible when discovery fails and permits a retry", asawait waitFor(() => expect(screen.getByRole("combobox", { name: "Run and reply in" })).toBeEnabled());expect(fetchAutomationChats).toHaveBeenCalledTimes(2);});++const webTarget = { ...target, channel: "websocket" };+const namedSessions: ChatSummary[] = [source, webTarget].map((chat) => ({+ key: `websocket:${chat.id}`, channel: "websocket", chatId: chat.id,+ title: chat.title, preview: "", createdAt: null, updatedAt: null,+ handle: { id: chat.id, name: chat.id === source.id ? "nime" : "jeno" },+}));++function NamedChats({ titles, onSave, task = job }: {+ titles: Record<string, string>;+ onSave: React.ComponentProps<typeof AutomationsSettings>["onChangeChat"];+ task?: SessionAutomationJob;+}) {+ return <AutomationsSettings payload={{ jobs: [task] }} sessions={namedSessions} titleOverrides={titles}+ loading={false} filter="all" actionKey={null} error={null} returnToDetailJob={task}+ onFilterChange={vi.fn()} onAction={vi.fn()} onRequestEdit={vi.fn()} onRequestDelete={vi.fn()}+ onChangeChat={onSave} />;+}++it("uses live sidebar names through loading, review, save and change-back without changing identity", async () => {+ const user = userEvent.setup();+ const save = vi.fn().mockResolvedValue(undefined);+ let resolve!: (value: AutomationChatsPayload) => void;+ vi.mocked(fetchAutomationChats).mockImplementationOnce(() => new Promise(done => { resolve = done; }));+ const titles = { "websocket:source": "推特大战场", "websocket:target": "产品讨论" };+ const { rerender } = render(<NamedChats titles={titles} onSave={save} />);+ expect(await screen.findByRole("combobox", { name: "Run and reply in" })).toHaveTextContent("推特大战场");+ await act(async () => resolve({ ...choices, chats: [source, webTarget] }));+ const control = screen.getByRole("combobox", { name: "Run and reply in" });+ expect(control).toHaveTextContent("推特大战场");+ fireEvent.keyDown(control, { key: "ArrowDown" });+ expect(await screen.findByRole("option", { name: /推特大战场/ })).toBeInTheDocument();+ await user.click(screen.getByRole("option", { name: /产品讨论/ }));+ expect(screen.getByRole("group", { name: "Now" })).toHaveTextContent("推特大战场");+ const renamed = { "websocket:source": "工作笔记", "websocket:target": "研发讨论" };+ rerender(<NamedChats titles={renamed} onSave={save} />);+ expect(screen.getByRole("group", { name: "Now" })).toHaveTextContent("工作笔记");+ expect(screen.getByRole("combobox", { name: "Change to" })).toHaveTextContent("研发讨论");+ expect(save).not.toHaveBeenCalled();+ expect(fetchAutomationChats).toHaveBeenCalledTimes(1);+ vi.mocked(fetchAutomationChats).mockResolvedValue({ ...choices, current: webTarget, chats: [source, webTarget] });+ await user.click(screen.getByRole("button", { name: "Confirm change" }));+ expect(save).toHaveBeenCalledWith(expect.objectContaining({ id: job.id }), {+ target_id: "target", revision: "rev-1", message: job.payload.message,+ });+ expect(await screen.findByRole("status")).toHaveTextContent("研发讨论");+ await user.click(await screen.findByRole("button", { name: "Change back to “工作笔记”" }));+ expect(screen.getByRole("group", { name: "Now" })).toHaveTextContent("研发讨论");+ expect(screen.getByRole("combobox", { name: "Change to" })).toHaveTextContent("工作笔记");+ await user.click(screen.getByRole("button", { name: "Cancel" }));+ expect(save).toHaveBeenCalledTimes(1);+ expect(job.origin?.session_key).toBe("websocket:source");+ expect(choices.current?.title).toBe("My planning");+});++it("distinguishes identical renamed chats by handle and uses the original title when the override is removed", async () => {+ const user = userEvent.setup();+ const save = vi.fn();+ vi.mocked(fetchAutomationChats).mockResolvedValue({ ...choices, chats: [source, webTarget] });+ const { rerender } = render(<NamedChats titles={{ "websocket:source": "日报", "websocket:target": "日报" }} onSave={save} />);+ const control = await screen.findByRole("combobox", { name: "Run and reply in" });+ await waitFor(() => expect(control).toBeEnabled());+ expect(control).toHaveTextContent("日报 · @nime");+ fireEvent.keyDown(control, { key: "ArrowDown" });+ expect(await screen.findByRole("option", { name: /日报 · @nime/ })).toBeInTheDocument();+ await user.click(screen.getByRole("option", { name: /日报 · @jeno/ }));+ expect(screen.getByRole("combobox", { name: "Change to" })).toHaveTextContent("日报 · @jeno");+ await user.click(screen.getByRole("button", { name: "Cancel" }));+ rerender(<NamedChats titles={{}} onSave={save} />);+ expect(screen.getByRole("combobox", { name: "Run and reply in" })).toHaveTextContent("My planning");+ expect(save).not.toHaveBeenCalled();+});