JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.
Python
fix(dialogs): enhance delete dialog with improved structure and localization
zhengkailan18756aa58e83
diff --git a/jiuwenswarm/channels/web/frontend/src/components/ChatPanel/ChatPanel.css b/jiuwenswarm/channels/web/frontend/src/components/ChatPanel/ChatPanel.cssindex 13a6723dbc..bd1481057f 100644--- a/jiuwenswarm/channels/web/frontend/src/components/ChatPanel/ChatPanel.css+++ b/jiuwenswarm/channels/web/frontend/src/components/ChatPanel/ChatPanel.css@@ -1556,7 +1556,9 @@ overflow: hidden;}.chat-work-select__menu--projects {+ display: flex;width: 160px;+ flex-direction: column;}.chat-work-select__submenu {@@ -1607,6 +1609,12 @@ overflow: hidden;color: var(--color-text-secondary);}+.chat-work-select__options {+ min-height: 0;+ flex: 1 1 auto;+ overflow-y: auto;+}+.chat-work-select__option {display: flex;width: 100%;diff --git a/jiuwenswarm/channels/web/frontend/src/components/ChatPanel/InputArea.tsx b/jiuwenswarm/channels/web/frontend/src/components/ChatPanel/InputArea.tsxindex 9e9ef9384b..2a25ed5c18 100644--- a/jiuwenswarm/channels/web/frontend/src/components/ChatPanel/InputArea.tsx+++ b/jiuwenswarm/channels/web/frontend/src/components/ChatPanel/InputArea.tsx@@ -1726,30 +1726,32 @@ export function InputArea({placeholder={t('multiSession.project.searchProject')}/></label>- {inputProjectOptions.map((project) => {- const active = selectedProject?.project_id === project.project_id;- return (- <button- type="button"- key={project.project_id}- className={clsx('chat-work-select__option', active && 'is-active')}- onClick={() => {- setSelectedProject(project);- setWorkMenuOpen(null);- }}- role="menuitemradio"- aria-checked={active}- title={project.project_dir}- >- <WorkIcon name="folder" />- <span>{project.name}</span>- {active ? <WorkIcon name="check" className="chat-work-select__check" /> : null}- </button>- );- })}- {inputProjectOptions.length === 0 ? (- <div className="chat-work-select__empty">{t('multiSession.project.noProjectMatches')}</div>- ) : null}+ <div className="chat-work-select__options">+ {inputProjectOptions.map((project) => {+ const active = selectedProject?.project_id === project.project_id;+ return (+ <button+ type="button"+ key={project.project_id}+ className={clsx('chat-work-select__option', active && 'is-active')}+ onClick={() => {+ setSelectedProject(project);+ setWorkMenuOpen(null);+ }}+ role="menuitemradio"+ aria-checked={active}+ title={project.project_dir}+ >+ <WorkIcon name="folder" />+ <span>{project.name}</span>+ {active ? <WorkIcon name="check" className="chat-work-select__check" /> : null}+ </button>+ );+ })}+ {inputProjectOptions.length === 0 ? (+ <div className="chat-work-select__empty">{t('multiSession.project.noProjectMatches')}</div>+ ) : null}+ </div><ProjectAddSubmenuonCreate={(mode) => {void openProjectCreateDialog(mode);diff --git a/jiuwenswarm/channels/web/frontend/src/i18n/locales/en.json b/jiuwenswarm/channels/web/frontend/src/i18n/locales/en.jsonindex 872da3a152..10096f17ac 100644--- a/jiuwenswarm/channels/web/frontend/src/i18n/locales/en.json+++ b/jiuwenswarm/channels/web/frontend/src/i18n/locales/en.json@@ -2110,7 +2110,7 @@"rename": "Rename","renamePlaceholder": "Enter a new name","deleteProject": "Delete project",- "deleteProjectDescription": "Remove “{{projectName}}”? Unpinned conversations in this project will temporarily move to the default project.",+ "deleteProjectDescription": "Remove “<name>{{projectName}}</name>”? Unpinned conversations in this project will temporarily move to the default project.","defaultProjectName": "Default Project","absolutePathError": "Enter an absolute path, for example /Users/name/work/project","errors": {@@ -2121,7 +2121,7 @@"confirm": "Confirm"},"runtime": { "processing": "Processing" },- "deleteDialog": { "title": "Delete", "description": "Delete “{{title}}”? This action cannot be undone." },+ "deleteDialog": { "title": "Delete", "description": "Delete “<name>{{title}}</name>”? This action cannot be undone." },"notFound": { "title": "Conversation not found or deleted", "newConversation": "New conversation" },"errors": { "delete": "Failed to delete conversation", "create": "Failed to create conversation", "send": "Failed to send message" }},diff --git a/jiuwenswarm/channels/web/frontend/src/i18n/locales/zh.json b/jiuwenswarm/channels/web/frontend/src/i18n/locales/zh.jsonindex f49623d2ba..cacb3cc152 100644--- a/jiuwenswarm/channels/web/frontend/src/i18n/locales/zh.json+++ b/jiuwenswarm/channels/web/frontend/src/i18n/locales/zh.json@@ -2114,7 +2114,7 @@"rename": "重命名","renamePlaceholder": "输入新名称","deleteProject": "删除项目",- "deleteProjectDescription": "确定要移除“{{projectName}}”吗?项目下未置顶会话会临时归入默认项目。",+ "deleteProjectDescription": "确定要移除“<name>{{projectName}}</name>”吗?项目下未置顶会话会临时归入默认项目。","defaultProjectName": "默认项目","absolutePathError": "请输入绝对路径,例如 /Users/name/work/project","errors": {@@ -2125,7 +2125,7 @@"confirm": "确定"},"runtime": { "processing": "处理中" },- "deleteDialog": { "title": "删除", "description": "确定删除“{{title}}”吗?此操作不可撤销。" },+ "deleteDialog": { "title": "删除", "description": "确定删除“<name>{{title}}</name>”吗?此操作不可撤销。" },"notFound": { "title": "对话不存在或已删除", "newConversation": "新建对话" },"errors": { "delete": "删除对话失败", "create": "创建对话失败", "send": "发送消息失败" }},diff --git a/jiuwenswarm/channels/web/frontend/src/multi-session/dialogs/Dialogs.tsx b/jiuwenswarm/channels/web/frontend/src/multi-session/dialogs/Dialogs.tsxindex a07f14c486..2a6f93c684 100644--- a/jiuwenswarm/channels/web/frontend/src/multi-session/dialogs/Dialogs.tsx+++ b/jiuwenswarm/channels/web/frontend/src/multi-session/dialogs/Dialogs.tsx@@ -1,10 +1,19 @@import { type ReactNode } from 'react';import { X } from 'lucide-react';-import { useTranslation } from 'react-i18next';+import { Trans, useTranslation } from 'react-i18next';import './dialogs.css';interface DialogShellProps { title: string; children: ReactNode; onCancel: () => void }-interface DeleteDialogProps { title: string; deleting: boolean; error: string | null; onCancel: () => void; onDelete: () => void }+interface DeleteDialogProps {+ title: string;+ dialogTitle?: string;+ descriptionKey?: string;+ descriptionValues?: Record<string, string>;+ deleting: boolean;+ error: string | null;+ onCancel: () => void;+ onDelete: () => void;+}function DialogShell({ title, children, onCancel }: DialogShellProps) {const { t } = useTranslation();@@ -32,11 +41,28 @@ function DialogActions({ busy, danger = false, confirmLabel, onCancel, onConfirm);}-export function DeleteDialog({ title, deleting, error, onCancel, onDelete }: DeleteDialogProps) {+export function DeleteDialog({+ title,+ dialogTitle,+ descriptionKey = 'multiSession.deleteDialog.description',+ descriptionValues = { title },+ deleting,+ error,+ onCancel,+ onDelete,+}: DeleteDialogProps) {const { t } = useTranslation();return (- <DialogShell title={t('multiSession.deleteDialog.title')} onCancel={onCancel}>- <p>{t('multiSession.deleteDialog.description', { title })}</p>+ <DialogShell title={dialogTitle ?? t('multiSession.deleteDialog.title')} onCancel={onCancel}>+ <p>+ <Trans+ i18nKey={descriptionKey}+ values={descriptionValues}+ components={{+ name: <span className="conversation-dialog__subject" title={title} />,+ }}+ />+ </p>{error && <div className="conversation-dialog__error">{error}</div>}<DialogActions busy={deleting} danger confirmLabel={t('multiSession.delete')} onCancel={onCancel} onConfirm={onDelete} /></DialogShell>diff --git a/jiuwenswarm/channels/web/frontend/src/multi-session/dialogs/dialogs.css b/jiuwenswarm/channels/web/frontend/src/multi-session/dialogs/dialogs.cssindex b22aae2b94..87096e6fe3 100644--- a/jiuwenswarm/channels/web/frontend/src/multi-session/dialogs/dialogs.css+++ b/jiuwenswarm/channels/web/frontend/src/multi-session/dialogs/dialogs.css@@ -1 +1 @@-.conversation-dialog{position:fixed;inset:0;z-index:100;display:flex;align-items:center;justify-content:center;padding:20px}.conversation-dialog__backdrop{position:absolute;inset:0;border:0;background:var(--color-backdrop)}.conversation-dialog__panel{position:relative;width:min(420px,100%);padding:22px;border:1px solid var(--color-border-default);border-radius:18px;background:var(--color-surface-card);box-shadow:var(--effect-shadow-xl)}.conversation-dialog__panel h2{margin:0;color:var(--color-text-primary);font-size:20px}.conversation-dialog__panel p{margin:6px 0 16px;color:var(--color-text-secondary);font-size:13px}.conversation-dialog__panel input{width:100%;height:40px;padding:0 12px;border:1px solid var(--color-border-default);border-radius:10px;background:var(--color-surface-card);color:var(--color-text-primary)}.conversation-dialog__close{position:absolute;top:16px;right:16px;border:0;background:transparent;color:var(--color-text-secondary);cursor:pointer}.conversation-dialog__actions{display:flex;justify-content:flex-end;gap:10px;margin-top:16px}.conversation-dialog__actions button{height:34px;padding:0 14px;border:1px solid var(--color-border-default);border-radius:9px;background:var(--color-surface-card);color:var(--color-text-primary);cursor:pointer}.conversation-dialog__actions .is-primary{background:var(--color-text-primary);color:var(--color-surface-card)}.conversation-dialog__actions .is-danger{border-color:var(--color-feedback-danger);background:var(--color-feedback-danger);color:var(--color-text-inverse)}.conversation-dialog__actions button:disabled{opacity:.5;cursor:not-allowed}.conversation-dialog__error{margin-top:10px;color:var(--color-feedback-danger);font-size:12px}+.conversation-dialog{position:fixed;inset:0;z-index:100;display:flex;align-items:center;justify-content:center;padding:20px}.conversation-dialog__backdrop{position:absolute;inset:0;border:0;background:var(--color-backdrop)}.conversation-dialog__panel{position:relative;width:min(420px,100%);padding:22px;border:1px solid var(--color-border-default);border-radius:18px;background:var(--color-surface-card);box-shadow:var(--effect-shadow-xl)}.conversation-dialog__panel h2{margin:0;color:var(--color-text-primary);font-size:20px}.conversation-dialog__panel p{margin:6px 0 16px;color:var(--color-text-secondary);font-size:13px}.conversation-dialog__subject{display:inline-block;max-width:70%;vertical-align:bottom;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.conversation-dialog__panel input{width:100%;height:40px;padding:0 12px;border:1px solid var(--color-border-default);border-radius:10px;background:var(--color-surface-card);color:var(--color-text-primary)}.conversation-dialog__close{position:absolute;top:16px;right:16px;border:0;background:transparent;color:var(--color-text-secondary);cursor:pointer}.conversation-dialog__actions{display:flex;justify-content:flex-end;gap:10px;margin-top:16px}.conversation-dialog__actions button{height:34px;padding:0 14px;border:1px solid var(--color-border-default);border-radius:9px;background:var(--color-surface-card);color:var(--color-text-primary);cursor:pointer}.conversation-dialog__actions .is-primary{background:var(--color-text-primary);color:var(--color-surface-card)}.conversation-dialog__actions .is-danger{border-color:var(--color-feedback-danger);background:var(--color-feedback-danger);color:var(--color-text-inverse)}.conversation-dialog__actions button:disabled{opacity:.5;cursor:not-allowed}.conversation-dialog__error{margin-top:10px;color:var(--color-feedback-danger);font-size:12px}diff --git a/jiuwenswarm/channels/web/frontend/src/multi-session/sidebar/ConversationSidebar.tsx b/jiuwenswarm/channels/web/frontend/src/multi-session/sidebar/ConversationSidebar.tsxindex e02ca14c38..9a4b442b69 100644--- a/jiuwenswarm/channels/web/frontend/src/multi-session/sidebar/ConversationSidebar.tsx+++ b/jiuwenswarm/channels/web/frontend/src/multi-session/sidebar/ConversationSidebar.tsx@@ -3,6 +3,7 @@ import { CircleAlert, LoaderCircle } from 'lucide-react';import { useTranslation } from 'react-i18next';import { useChatStore, type ChatRuntime } from '../../stores/chatStore';import { webClient } from '../../services/webClient';+import { DeleteDialog } from '../dialogs/Dialogs';import {PROJECT_SESSION_PAGE_SIZE,useWorkspaceStore,@@ -567,19 +568,16 @@ function ProjectDeleteDialog({}) {const { t } = useTranslation();return (- <div className="conversation-path-dialog-backdrop" role="presentation">- <div className="conversation-path-dialog" role="dialog" aria-modal="true" aria-labelledby="project-delete-title">- <div id="project-delete-title" className="conversation-path-dialog__title">{t('multiSession.project.deleteProject')}</div>- <div className="conversation-path-dialog__message">- {t('multiSession.project.deleteProjectDescription', { projectName: project.name })}- </div>- {error ? <div className="conversation-path-dialog__error">{error}</div> : null}- <div className="conversation-path-dialog__actions">- <button type="button" onClick={onCancel} disabled={deleting}>{t('multiSession.project.cancel')}</button>- <button type="button" onClick={onDelete} disabled={deleting}>{t('multiSession.delete')}</button>- </div>- </div>- </div>+ <DeleteDialog+ title={project.name}+ dialogTitle={t('multiSession.project.deleteProject')}+ descriptionKey="multiSession.project.deleteProjectDescription"+ descriptionValues={{ projectName: project.name }}+ deleting={deleting}+ error={error ?? null}+ onCancel={onCancel}+ onDelete={onDelete}+ />);}