Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(voice-input): 将词典提示收紧为自适应单行浮窗 (#4195)

Dashfd4c1d03348d
diff --git a/apps/desktop/src/main/voice-input/global.ts b/apps/desktop/src/main/voice-input/global.ts
index b5084b3b21..4d0cc5251c 100644
--- a/apps/desktop/src/main/voice-input/global.ts
+++ b/apps/desktop/src/main/voice-input/global.ts
@@ -296,8 +296,9 @@ const OVERLAY_SNAP_THRESHOLD_X = 48;
// 也不让浮窗出现明显延迟;答案迟到时不再挪窗,避免可见的跨屏跳动。
const OVERLAY_FOCUSED_DISPLAY_DEADLINE_MS = 90;
const DICTIONARY_TOAST_QUERY = 'view=voice-input-dictionary-toast';
-const DICTIONARY_TOAST_CARD_WIDTH = 360;
-const DICTIONARY_TOAST_CARD_ESTIMATED_HEIGHT = 68;
+// Reserve the maximum card width; the renderer shrink-wraps shorter terms.
+const DICTIONARY_TOAST_CARD_WIDTH = 400;
+const DICTIONARY_TOAST_CARD_ESTIMATED_HEIGHT = 44;
const DICTIONARY_TOAST_SHADOW_PADDING = 34;
const DICTIONARY_TOAST_WIDTH = DICTIONARY_TOAST_CARD_WIDTH + DICTIONARY_TOAST_SHADOW_PADDING * 2;
const DICTIONARY_TOAST_HEIGHT = DICTIONARY_TOAST_CARD_ESTIMATED_HEIGHT + DICTIONARY_TOAST_SHADOW_PADDING * 2;
diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.json
index dd9d321c07..80b9d9956c 100644
--- a/apps/desktop/src/renderer/i18n/locales/en/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json
@@ -1294,7 +1294,6 @@
},
"toast": {
"title": "Added to dictionary",
- "titleMultiple": "Added {{count}} terms",
"termsSummary": "{{terms}} and {{count}} terms total",
"automaticAdded": "Auto-added to dictionary: {{term}}",
"automaticAddedMultiple": "Auto-added {{count}} terms, including {{term}}",
diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.json
index 5552490974..687e46603c 100644
--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json
@@ -1293,8 +1293,7 @@
"manual": "手動"
},
"toast": {
- "title": "辞書に自動追加しました",
- "titleMultiple": "{{count}} 件を辞書に自動追加しました",
+ "title": "辞書に追加しました",
"termsSummary": "{{terms}} ほか合計 {{count}} 件",
"automaticAdded": "辞書に自動追加しました:{{term}}",
"automaticAddedMultiple": "辞書に自動追加しました:{{term}} ほか {{count}} 件",
diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.json
index 2552f52dcd..b9ec452ed0 100644
--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json
@@ -1293,8 +1293,7 @@
"manual": "수동"
},
"toast": {
- "title": "사전에 자동 추가됨",
- "titleMultiple": "{{count}}개 단어가 사전에 자동 추가됨",
+ "title": "사전에 추가됨",
"termsSummary": "{{terms}} 외 총 {{count}}개",
"automaticAdded": "사전에 자동 추가됨: {{term}}",
"automaticAddedMultiple": "사전에 자동 추가됨: {{term}} 외 {{count}}개",
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
index 1872981367..ad9ce580e0 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
@@ -1293,8 +1293,7 @@
"manual": "手动"
},
"toast": {
- "title": "已自动加入词典",
- "titleMultiple": "已自动加入 {{count}} 个词",
+ "title": "已加入词典",
"termsSummary": "{{terms}} 等 {{count}} 个词",
"automaticAdded": "已自动加入词典:{{term}}",
"automaticAddedMultiple": "已自动加入词典:{{term}} 等 {{count}} 个词",
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
index 5b4c125fe3..7d086dcf9e 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
@@ -1293,8 +1293,7 @@
"manual": "手動"
},
"toast": {
- "title": "已自動加入詞典",
- "titleMultiple": "已自動加入 {{count}} 個詞",
+ "title": "已加入詞典",
"termsSummary": "{{terms}} 等 {{count}} 個詞",
"automaticAdded": "已自動加入詞典:{{term}}",
"automaticAddedMultiple": "已自動加入詞典:{{term}} 等 {{count}} 個詞",
diff --git a/apps/desktop/src/renderer/voice-input/VoiceInputDictionaryToast.tsx b/apps/desktop/src/renderer/voice-input/VoiceInputDictionaryToast.tsx
index 88e4b33623..6feb6aa652 100644
--- a/apps/desktop/src/renderer/voice-input/VoiceInputDictionaryToast.tsx
+++ b/apps/desktop/src/renderer/voice-input/VoiceInputDictionaryToast.tsx
@@ -3,6 +3,7 @@ import { useTranslation } from 'react-i18next';
import { Sparkles, Trash2 } from 'lucide-react';
import { cn } from '@/lib/utils';
+import { Tip } from '@/components/ui/tooltip';
import { deleteVoiceInputDictionaryEntries } from '@/hooks/useVoiceInputSettings';
type DictionaryToastEntry = {
@@ -50,9 +51,7 @@ export function VoiceInputDictionaryToast() {
count: terms.length,
});
}, [t, terms]);
- const title = entries.length > 1
- ? t('settings.voiceInput.refinement.dictionary.toast.titleMultiple', { count: entries.length })
- : t('settings.voiceInput.refinement.dictionary.toast.title');
+ const title = t('settings.voiceInput.refinement.dictionary.toast.title');
const close = useCallback(() => {
void window.electronAPI.voiceInput.closeDictionaryToast();
@@ -67,32 +66,35 @@ export function VoiceInputDictionaryToast() {
<div className="flex h-screen w-screen select-none items-center justify-center bg-transparent p-[34px] text-[var(--cmd-palette-item-text)]">
<div
className={cn(
- 'flex h-[68px] w-[360px] items-center gap-3 rounded-[22px] border px-4',
+ 'flex h-11 w-max max-w-full shrink-0 items-center gap-2 rounded-xl border px-2.5',
'border-[var(--cmd-palette-border)] shadow-[var(--shadow-menu)] backdrop-blur-xl',
)}
style={{ backgroundColor: 'color-mix(in srgb, var(--cmd-palette-bg) 95%, transparent)' }}
>
- <div className="grid h-8 w-8 shrink-0 place-items-center rounded-full bg-[var(--send-btn-bg)] text-[var(--send-btn-icon)]">
+ <div className="grid h-6 w-5 shrink-0 place-items-center text-[var(--cmd-palette-item-meta)]">
<Sparkles aria-hidden className="h-4 w-4" strokeWidth={2.2} />
</div>
- <div className="min-w-0 flex-1">
- <div className="text-13 font-medium leading-4 text-[var(--cmd-palette-item-meta)]">
+ <div className="flex min-w-0 shrink items-center gap-2">
+ <div className="shrink-0 whitespace-nowrap text-12 font-medium leading-5 text-[var(--cmd-palette-item-meta)]">
{title}
</div>
- <div className="truncate text-15 font-semibold leading-5 text-[var(--cmd-palette-item-text)]">
+ <div className="min-w-0 truncate text-14 font-semibold leading-5 text-[var(--cmd-palette-item-text)]">
{termText}
</div>
</div>
- <button
- type="button"
- className="grid h-8 w-8 shrink-0 place-items-center rounded-full text-[var(--cmd-palette-item-meta)] transition hover:bg-[var(--cmd-palette-item-hover)] hover:text-[var(--cmd-palette-item-text)] active:scale-95"
- aria-label={t('settings.voiceInput.refinement.dictionary.toast.deleteAriaLabel', { term: termText })}
- title={t('settings.voiceInput.refinement.dictionary.toast.delete')}
- onMouseDown={(event) => event.preventDefault()}
- onClick={deleteEntry}
- >
- <Trash2 aria-hidden className="h-4 w-4" strokeWidth={2} />
- </button>
+ <Tip text={t('settings.voiceInput.refinement.dictionary.toast.delete')}>
+ <button
+ type="button"
+ className="grid h-7 w-7 shrink-0 place-items-center rounded-full text-[var(--cmd-palette-item-meta)] transition hover:bg-[var(--cmd-palette-item-hover)] hover:text-[var(--cmd-palette-item-text)] active:scale-95"
+ aria-label={t('settings.voiceInput.refinement.dictionary.toast.deleteAriaLabel', {
+ term: termText,
+ })}
+ onMouseDown={(event) => event.preventDefault()}
+ onClick={deleteEntry}
+ >
+ <Trash2 aria-hidden className="h-4 w-4" strokeWidth={2} />
+ </button>
+ </Tip>
</div>
</div>
);
diff --git a/docs/design-rules/design-inventory.md b/docs/design-rules/design-inventory.md
index f6c73ca713..7ddce3fa92 100644
--- a/docs/design-rules/design-inventory.md
+++ b/docs/design-rules/design-inventory.md
@@ -48,7 +48,7 @@
| `desktop.window.review-artifact-confirm` | desktop | Review 成果确认窗 | main/reviewer/reviewArtifactConfirmWindow.ts 内联 HTML/CSS(不走 renderer 路由) | reviewArtifactConfirmWindow | apps/desktop/src/main/reviewer/reviewArtifactConfirmWindow.ts | 8 | 18 | 2 |
| `desktop.window.session-drag-preview` | desktop | 会话拖拽预览 | main/session-drag-preview.ts 透明预览窗 | session-drag-preview | apps/desktop/src/main/session-drag-preview.ts | 0 | 1 | 0 |
| `desktop.window.sidebar` | desktop | 右侧栏独立窗口 | `?sidebarWindow=1` → renderer/sidebar-window-entry.tsx;hash `/sidebar-window` | RightSidebar, RightSidebarShell, SidebarWindowLayout | apps/desktop/src/main/right-sidebar-window/controller.ts, apps/desktop/src/main/right-sidebar-window/ipc.ts, apps/desktop/src/main/right-sidebar-window/registry.ts, apps/desktop/src/main/right-sidebar-window/resolveHostContext.ts, apps/desktop/src/main/right-sidebar-window/settings-store.ts, apps/desktop/src/main/right-sidebar-window/window.ts, apps/desktop/src/renderer/components/layout/SidebarWindowLayout.tsx, apps/desktop/src/renderer/features/right-sidebar/AddTabDropdown.tsx, apps/desktop/src/renderer/features/right-sidebar/EmptyState.tsx, apps/desktop/src/renderer/features/right-sidebar/RightSidebarShell.tsx, apps/desktop/src/renderer/features/right-sidebar/TabBar.tsx, apps/desktop/src/renderer/features/right-sidebar/TabBodyErrorBoundary.tsx, apps/desktop/src/renderer/features/right-sidebar/hooks/useBrowserWebview.ts, apps/desktop/src/renderer/features/right-sidebar/hooks/useNativePopupSurface.ts, apps/desktop/src/renderer/features/right-sidebar/iosSimulatorPluginAvailability.ts, apps/desktop/src/renderer/features/right-sidebar/lib/browserPartition.ts, apps/desktop/src/renderer/features/right-sidebar/lib/browserWebviewPool.ts, apps/desktop/src/renderer/features/right-sidebar/lib/detachedSidebarRouting.ts, apps/desktop/src/renderer/features/right-sidebar/lib/executeSidebarCommand.ts, apps/desktop/src/renderer/features/right-sidebar/lib/iosSimulatorFocusBridge.ts, apps/desktop/src/renderer/features/right-sidebar/lib/lastTurnChangedFiles.ts, apps/desktop/src/renderer/features/right-sidebar/lib/nativePopupTabs.ts, apps/desktop/src/renderer/features/right-sidebar/lib/openBackgroundTasksTab.ts, apps/desktop/src/renderer/features/right-sidebar/lib/openInSidebarBrowser.ts, apps/desktop/src/renderer/features/right-sidebar/lib/openInSidebarFileBrowser.ts, apps/desktop/src/renderer/features/right-sidebar/lib/openRoutinesTab.ts, apps/desktop/src/renderer/features/right-sidebar/lib/openSubagentsTab.ts, apps/desktop/src/renderer/features/right-sidebar/lib/openTerminalShortcut.ts, apps/desktop/src/renderer/features/right-sidebar/lib/openTurnReview.ts, apps/desktop/src/renderer/features/right-sidebar/lib/popupRouter.ts, apps/desktop/src/renderer/features/right-sidebar/lib/popupTabs.ts, apps/desktop/src/renderer/features/right-sidebar/lib/rsbBrowserBridge.ts, apps/desktop/src/renderer/features/right-sidebar/lib/sidebarCommands.ts, apps/desktop/src/renderer/features/right-sidebar/lib/sidebarHostSession.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/BackgroundTasksBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/WorkflowAgentStrip.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/WorkflowProgressTree.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/chatTaskFocusIntent.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/listSessionTasks.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/workflowProgressModel.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/file-browser/FileBrowserBody.css, apps/desktop/src/renderer/features/right-sidebar/plugins/file-browser/FileBrowserBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/file-browser/dropExternalFile.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/file-browser/fileTreeImagePreview.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/file-browser/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/file-browser/useSessionScopedTreeWidth.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/index.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/ios-simulator/IOSSimulatorInstanceGrid.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/ios-simulator/IOSSimulatorTabBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/ios-simulator/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/ios-simulator/iosSimulatorH264Decoder.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/orca-workers/OrcaWorkersAttentionIcon.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/orca-workers/OrcaWorkersTabBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/orca-workers/actions.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/orca-workers/closeDecision.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/orca-workers/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/resource-usage/ResourceUsageBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/resource-usage/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/resource-usage/resource-usage.css, apps/desktop/src/renderer/features/right-sidebar/plugins/resource-usage/subscription.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/DiffViewer/ImageDiffPreview.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/review/DiffViewer/MarkdownDiffPreview.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/review/DiffViewer/PlainUnifiedDiff.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/review/DiffViewer/diffRows.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/DiffViewer/highlight.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/DiffViewer/inlineDiff.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/DiffViewer/useDiffHighlights.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/ReviewTabBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/review/diffExpansionPreference.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/fileTree.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/gitApplyCommand.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/review/markdownPreview.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/useLastTurnFilter.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/useReviewGitState.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/useReviewSource.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/routines/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/ConversationStream.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/DetailView.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/RunList.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/SubagentChrome.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/SubagentToolCard.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/SubagentsBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/subagentChangeFence.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/subagentConversation.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/subagentFormat.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/terminal/TerminalTabBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/terminal/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/terminal/lib/xtermPool.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/BrowserChrome.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/BrowserCommentPopover.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/BrowserTabBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/browserCommentEditorDraft.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/lib/parseOmnibox.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/useBrowserComment.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/useLocalHtmlAutoReload.ts, apps/desktop/src/renderer/features/right-sidebar/registry.ts, apps/desktop/src/renderer/features/right-sidebar/store.ts, apps/desktop/src/renderer/features/right-sidebar/types.ts, apps/desktop/src/renderer/sidebar-window-entry.tsx, apps/desktop/src/renderer/styles/globals.css | 100 | 71 | 197 |
-| `desktop.window.voice-dictionary-toast` | desktop | 语音词典 Toast 窗 | `?view=voice-input-dictionary-toast` → main-entry.tsx → VoiceInputDictionaryToast | VoiceInputDictionaryToast | apps/desktop/src/renderer/voice-input/VoiceInputDictionaryToast.tsx | 8 | 0 | 3 |
+| `desktop.window.voice-dictionary-toast` | desktop | 语音词典 Toast 窗 | `?view=voice-input-dictionary-toast` → main-entry.tsx → VoiceInputDictionaryToast | VoiceInputDictionaryToast | apps/desktop/src/renderer/voice-input/VoiceInputDictionaryToast.tsx | 6 | 0 | 2 |
| `desktop.window.voice-overlay` | desktop | 语音输入浮窗 | `?view=voice-input-overlay` → main-entry.tsx → VoiceInputOverlay | VoiceInputOverlay, VoiceInputStatusNotice | apps/desktop/src/main/voice-input/global.ts, apps/desktop/src/renderer/styles/globals.css, apps/desktop/src/renderer/voice-input/VoiceInputOverlay.tsx, apps/desktop/src/renderer/voice-input/VoiceInputStatusNotice.tsx | 67 | 64 | 25 |
### 生产路由覆盖