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(desktop): 统一图标按钮提示 (#2926)

Dash917a5fc56ee5
diff --git a/apps/desktop/src/renderer/__tests__/automationGeneratedSessions.test.ts b/apps/desktop/src/renderer/__tests__/automationGeneratedSessions.test.ts
index 96980c1530..49749745cf 100644
--- a/apps/desktop/src/renderer/__tests__/automationGeneratedSessions.test.ts
+++ b/apps/desktop/src/renderer/__tests__/automationGeneratedSessions.test.ts
@@ -791,9 +791,7 @@ describe('automation-generated sessions', () => {
expect(source).not.toContain('<Pause');
// text 沿用 vendor → Timer → 标题的 6px 节奏;list 把 Timer 排到标题后,
// 标题与普通列表任务落在同一列。
- expect(source).toContain(
- 'className="flex min-w-0 items-center gap-1.5 text-left disabled:cursor-default"',
- );
+ expect(source).toContain('className="min-w-0 truncate text-left disabled:cursor-default"');
expect(source).toContain('className="flex min-w-0 items-center gap-1.5"');
expect(source).toContain("sessionVariant === 'list' && 'order-2'");
expect(source).toContain('runningSessionIds,');
diff --git a/apps/desktop/src/renderer/__tests__/conversationSearchBox.test.ts b/apps/desktop/src/renderer/__tests__/conversationSearchBox.test.ts
index fd87fc807e..c10eabcca4 100644
--- a/apps/desktop/src/renderer/__tests__/conversationSearchBox.test.ts
+++ b/apps/desktop/src/renderer/__tests__/conversationSearchBox.test.ts
@@ -35,14 +35,6 @@ vi.mock('@/lib/orcaSessionIdentity', () => ({
resolveSessionRoute: vi.fn(),
}));
-vi.mock('@/components/ui/tooltip', async () => {
- const React = await import('react');
-
- return {
- Tip: ({ children }: { children: ReactNode }) => React.createElement(React.Fragment, null, children),
- };
-});
-
vi.mock('@/components/ui/popover', async () => {
const React = await import('react');
const PopoverContext = React.createContext<{
diff --git a/apps/desktop/src/renderer/__tests__/iconButtonTooltips.test.ts b/apps/desktop/src/renderer/__tests__/iconButtonTooltips.test.ts
new file mode 100644
index 0000000000..9b47774ff0
--- /dev/null
+++ b/apps/desktop/src/renderer/__tests__/iconButtonTooltips.test.ts
@@ -0,0 +1,416 @@
+import { readFileSync, readdirSync } from 'node:fs';
+import { relative, resolve } from 'node:path';
+
+import ts from 'typescript';
+import { describe, expect, it } from 'vitest';
+
+const RENDERER_ROOT = resolve(__dirname, '..');
+const GUARDED_TOOLTIP_ROOTS = [
+ 'components/layout',
+ 'components/sidebar',
+ 'components/title-bar',
+ 'features/cc-agent/sidebar',
+ 'features/right-sidebar',
+] as const;
+const WINDOWS_SYSTEM_CONTROL_PATH = 'components/title-bar/WindowControls.tsx';
+const WINDOWS_SYSTEM_CONTROL_TOOLTIP_EXEMPTION = 'windows-system-control';
+
+function normalizeRendererPath(path: string): string {
+ return path.replaceAll('\\', '/');
+}
+
+function rendererSource(path: string): string {
+ return readFileSync(resolve(RENDERER_ROOT, path), 'utf8');
+}
+
+function rendererComponentFiles(directory: string): string[] {
+ return readdirSync(directory, { withFileTypes: true })
+ .flatMap((entry) => {
+ const path = resolve(directory, entry.name);
+ if (entry.isDirectory()) {
+ return entry.name === '__tests__' ? [] : rendererComponentFiles(path);
+ }
+ return /\.[jt]sx$/.test(entry.name) && !/\.(?:test|spec)\.[jt]sx$/.test(entry.name)
+ ? [path]
+ : [];
+ })
+ .sort();
+}
+
+type JsxOpeningLikeElement = ts.JsxOpeningElement | ts.JsxSelfClosingElement;
+
+function jsxAttribute(
+ node: JsxOpeningLikeElement,
+ name: string,
+ sourceFile: ts.SourceFile,
+): ts.JsxAttribute | undefined {
+ return node.attributes.properties
+ .filter(ts.isJsxAttribute)
+ .find((attribute) => attribute.name.getText(sourceFile) === name);
+}
+
+function staticAttributeValue(attribute: ts.JsxAttribute | undefined): string | true | undefined {
+ if (!attribute) return undefined;
+ if (!attribute.initializer) return true;
+ return ts.isStringLiteral(attribute.initializer) ? attribute.initializer.text : undefined;
+}
+
+function jsxTagName(node: JsxOpeningLikeElement, sourceFile: ts.SourceFile): string {
+ return node.tagName.getText(sourceFile);
+}
+
+function jsxElementForOpening(
+ node: JsxOpeningLikeElement,
+): ts.JsxElement | ts.JsxSelfClosingElement {
+ return ts.isJsxOpeningElement(node) ? node.parent : node;
+}
+
+function expressionContainsButtonRole(expression: ts.Expression): boolean {
+ if (ts.isStringLiteral(expression) || ts.isNoSubstitutionTemplateLiteral(expression)) {
+ return expression.text === 'button';
+ }
+ return expression
+ .getChildren()
+ .some((child) => (ts.isExpression(child) ? expressionContainsButtonRole(child) : false));
+}
+
+function hasButtonRole(node: JsxOpeningLikeElement, sourceFile: ts.SourceFile): boolean {
+ const role = jsxAttribute(node, 'role', sourceFile);
+ if (!role?.initializer) return false;
+ if (ts.isStringLiteral(role.initializer)) return role.initializer.text === 'button';
+ return (
+ ts.isJsxExpression(role.initializer) &&
+ role.initializer.expression !== undefined &&
+ expressionContainsButtonRole(role.initializer.expression)
+ );
+}
+
+function isInteractiveControl(node: JsxOpeningLikeElement, sourceFile: ts.SourceFile): boolean {
+ return jsxTagName(node, sourceFile) === 'button' || hasButtonRole(node, sourceFile);
+}
+
+function expressionHasPersistentText(expression: ts.Expression): boolean {
+ if (
+ ts.isStringLiteral(expression) ||
+ ts.isNoSubstitutionTemplateLiteral(expression) ||
+ ts.isNumericLiteral(expression)
+ ) {
+ return expression.text.length > 0;
+ }
+ if (ts.isParenthesizedExpression(expression)) {
+ return expressionHasPersistentText(expression.expression);
+ }
+ if (ts.isConditionalExpression(expression)) {
+ return (
+ expressionHasPersistentText(expression.whenTrue) ||
+ expressionHasPersistentText(expression.whenFalse)
+ );
+ }
+ if (
+ ts.isBinaryExpression(expression) &&
+ [
+ ts.SyntaxKind.AmpersandAmpersandToken,
+ ts.SyntaxKind.BarBarToken,
+ ts.SyntaxKind.QuestionQuestionToken,
+ ].includes(expression.operatorToken.kind)
+ ) {
+ return (
+ expressionHasPersistentText(expression.left) || expressionHasPersistentText(expression.right)
+ );
+ }
+ if (ts.isJsxElement(expression) || ts.isJsxFragment(expression)) {
+ return jsxChildrenHavePersistentText(expression.children);
+ }
+ if (ts.isJsxSelfClosingElement(expression)) return false;
+
+ // A dynamic value rendered as a child is persistent visible content (for example
+ // `{label}`). Icon components instead arrive as JSX elements and take the branches above.
+ return true;
+}
+
+function jsxChildrenHavePersistentText(children: ts.NodeArray<ts.JsxChild>): boolean {
+ return children.some((child) => {
+ if (ts.isJsxText(child)) return child.text.trim().length > 0;
+ if (ts.isJsxExpression(child)) {
+ return child.expression ? expressionHasPersistentText(child.expression) : false;
+ }
+ if (ts.isJsxElement(child) || ts.isJsxFragment(child)) {
+ return jsxChildrenHavePersistentText(child.children);
+ }
+ return false;
+ });
+}
+
+function isIconOnlyControl(node: JsxOpeningLikeElement): boolean {
+ return ts.isJsxSelfClosingElement(node) || !jsxChildrenHavePersistentText(node.parent.children);
+}
+
+function isDirectTooltipTrigger(node: ts.Node, sourceFile: ts.SourceFile): boolean {
+ let current: ts.Node | undefined = node;
+
+ while (current?.parent) {
+ const parent: ts.Node = current.parent;
+ if (ts.isJsxElement(parent)) {
+ const tagName = jsxTagName(parent.openingElement, sourceFile);
+ if (tagName === 'Tip' || tagName === 'Tooltip.Trigger') return true;
+ return false;
+ }
+ if (ts.isJsxSelfClosingElement(parent)) return false;
+ current = parent;
+ }
+ return false;
+}
+
+function variableDeclarationForControl(
+ node: JsxOpeningLikeElement,
+): ts.VariableDeclaration | undefined {
+ let current: ts.Node | undefined = jsxElementForOpening(node);
+
+ while (current?.parent) {
+ const parent: ts.Node = current.parent;
+ if (ts.isJsxElement(parent) || ts.isJsxSelfClosingElement(parent)) return undefined;
+ if (ts.isVariableDeclaration(parent) && parent.initializer) return parent;
+ current = parent;
+ }
+ return undefined;
+}
+
+function hasManagedTip(node: JsxOpeningLikeElement, sourceFile: ts.SourceFile): boolean {
+ if (isDirectTooltipTrigger(jsxElementForOpening(node), sourceFile)) return true;
+
+ const declaration = variableDeclarationForControl(node);
+ if (!declaration || !ts.isIdentifier(declaration.name)) return false;
+
+ const declarationName = declaration.name;
+ const bindingName = declarationName.text;
+ const scope = declaration.parent.parent.parent;
+ let covered = false;
+
+ function visit(candidate: ts.Node): void {
+ if (
+ !covered &&
+ ts.isIdentifier(candidate) &&
+ candidate.text === bindingName &&
+ candidate !== declarationName &&
+ isDirectTooltipTrigger(candidate, sourceFile)
+ ) {
+ covered = true;
+ return;
+ }
+ ts.forEachChild(candidate, visit);
+ }
+
+ visit(scope);
+ return covered;
+}
+
+function tooltipContractViolations(): string[] {
+ const violations: string[] = [];
+
+ for (const root of GUARDED_TOOLTIP_ROOTS) {
+ for (const file of rendererComponentFiles(resolve(RENDERER_ROOT, root))) {
+ const source = readFileSync(file, 'utf8');
+ const rendererRelativePath = normalizeRendererPath(relative(RENDERER_ROOT, file));
+ const sourceFile = ts.createSourceFile(
+ file,
+ source,
+ ts.ScriptTarget.Latest,
+ true,
+ file.endsWith('.tsx') ? ts.ScriptKind.TSX : ts.ScriptKind.JSX,
+ );
+
+ function visit(node: ts.Node): void {
+ if (ts.isJsxOpeningElement(node) || ts.isJsxSelfClosingElement(node)) {
+ const nativeTitle = jsxAttribute(node, 'title', sourceFile);
+ const nativeTitleMarker = jsxAttribute(node, 'data-native-title', sourceFile);
+ const isTruncatedTextException =
+ staticAttributeValue(nativeTitleMarker) === 'truncated-text';
+ const ariaHidden = jsxAttribute(node, 'aria-hidden', sourceFile);
+ const isHiddenFromAccessibilityTree = staticAttributeValue(ariaHidden) === 'true';
+ const tooltipExemption = jsxAttribute(node, 'data-tooltip-exempt', sourceFile);
+ const isWindowsSystemControlException =
+ rendererRelativePath === WINDOWS_SYSTEM_CONTROL_PATH &&
+ staticAttributeValue(tooltipExemption) ===
+ WINDOWS_SYSTEM_CONTROL_TOOLTIP_EXEMPTION;
+ const isIconControl =
+ isInteractiveControl(node, sourceFile) &&
+ !isHiddenFromAccessibilityTree &&
+ isIconOnlyControl(node);
+
+ if (
+ (nativeTitle && isInteractiveControl(node, sourceFile) && !isTruncatedTextException) ||
+ (isIconControl &&
+ !isWindowsSystemControlException &&
+ !hasManagedTip(node, sourceFile))
+ ) {
+ const { line } = sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile));
+ violations.push(`${rendererRelativePath}:${line + 1}`);
+ }
+ }
+ ts.forEachChild(node, visit);
+ }
+
+ visit(sourceFile);
+ }
+ }
+
+ return violations;
+}
+
+describe('icon-only button tooltip coverage', () => {
+ it('centralizes visible tips in shared chrome and sidebar button primitives', () => {
+ const chromeButton = rendererSource('components/title-bar/ChromeIconButton.tsx');
+ const sidebarButton = rendererSource('components/sidebar/SidebarIconButton.tsx');
+
+ expect(chromeButton).toContain("import { Tip, type TipProps } from '@/components/ui/tooltip';");
+ expect(chromeButton).toContain('<Tip text={tooltipText}');
+ expect(chromeButton).toContain('role="button"');
+ expect(chromeButton).toContain('aria-disabled="true"');
+ expect(chromeButton).toContain('tabIndex={0}');
+ expect(chromeButton).toContain('aria-hidden={rest.disabled ? true : undefined}');
+ expect(chromeButton).not.toContain('<button type="button" title=');
+ expect(sidebarButton).toContain("import { Tip } from '@/components/ui/tooltip';");
+ expect(sidebarButton).toContain('<Tip text={title ?? label} side="right">');
+ expect(sidebarButton).toContain('role="button"');
+ expect(sidebarButton).toContain('aria-disabled="true"');
+ expect(sidebarButton).toContain('tabIndex={0}');
+ expect(sidebarButton).toContain('aria-hidden={disabled ? true : undefined}');
+ expect(sidebarButton).not.toContain('title={label}');
+ });
+
+ it('gives the left title-bar sidebar toggle and app menu visible tips', () => {
+ const chromeActions = rendererSource('components/layout/ChromeActions.tsx');
+ const menuButton = rendererSource('components/title-bar/MenuButton.tsx');
+
+ expect(chromeActions).toContain("import { Tip } from '@/components/ui/tooltip';");
+ expect(chromeActions).toContain("'contentHeader.expandSidebar'");
+ expect(chromeActions).toContain("'contentHeader.collapseSidebar'");
+ expect(chromeActions).toContain('<Tip text={sidebarToggleLabel} side="bottom">');
+ expect(chromeActions).toContain('aria-label={sidebarToggleLabel}');
+ expect(menuButton).toContain("import { Tip } from '@/components/ui/tooltip';");
+ expect(menuButton).toContain("text={t('titleBar.menu')}");
+ });
+
+ it('keeps Windows system window controls accessible without visible tips', () => {
+ const windowControls = rendererSource(WINDOWS_SYSTEM_CONTROL_PATH);
+
+ expect(normalizeRendererPath('components\\title-bar\\WindowControls.tsx')).toBe(
+ WINDOWS_SYSTEM_CONTROL_PATH,
+ );
+ expect(windowControls).not.toContain("import { Tip } from '@/components/ui/tooltip';");
+ expect(windowControls).not.toContain('<Tip');
+ expect(
+ windowControls.match(/data-tooltip-exempt="windows-system-control"/g),
+ ).toHaveLength(4);
+ expect(windowControls).toContain("aria-label={t('titleBar.minimize')}");
+ expect(windowControls).toContain("aria-label={t('titleBar.maximizeOrRestore')}");
+ expect(windowControls).toContain("aria-label={t('titleBar.close')}");
+ expect(windowControls).toContain("aria-label={t('titleBar.closing.title')}");
+ });
+
+ it('gives both sidebar footer icon actions visible, state-aware tips', () => {
+ const source = rendererSource('components/sidebar/UserInfoSection.tsx');
+
+ expect(source).toContain("import { Tip } from '@/components/ui/tooltip';");
+ expect(source).toContain('<Tip text={settingsLinkLabel} side="right">');
+ expect(source).toContain("text={t('sidebar.user.downloadMobile')}");
+ expect(source).toMatch(
+ /text=\{\s*isFlameReopen\s*\? t\('sidebar\.user\.reopenUpdateBanner'\)\s*: t\('sidebar\.user\.viewReleaseNotes'\)\s*\}/,
+ );
+ });
+
+ it('does not exempt session-row icon actions from visible tips', () => {
+ const sessionItem = rendererSource('features/cc-agent/sidebar/SessionItem.tsx');
+ const sessionCard = rendererSource('features/cc-agent/sidebar/SessionCard.tsx');
+ const actionStart = sessionItem.indexOf('function SessionAction(');
+ const cardActionStart = sessionCard.indexOf('function CardAction(');
+
+ expect(actionStart).toBeGreaterThanOrEqual(0);
+ expect(cardActionStart).toBeGreaterThanOrEqual(0);
+ expect(sessionItem.slice(actionStart)).toContain('<Tip text={label}');
+ expect(sessionCard.slice(cardActionStart)).toContain('<Tip text={label}');
+ expect(sessionItem).toContain("<Tip text={t('ccAgent.sidebar.scheduleBinding.viewTask')}");
+ expect(sessionCard).toContain("<Tip text={t('ccAgent.sidebar.scheduleBinding.viewTask')}");
+ expect(sessionItem).not.toContain("<Tip text={t('ccAgent.sidebar.automationGenerated')}");
+ expect(sessionCard).not.toContain("<Tip text={t('ccAgent.sidebar.automationGenerated')}");
+ expect(sessionItem).not.toContain('故意不挂 Tip 浮层');
+ });
+
+ it('covers the high-frequency custom sidebar and panel triggers', () => {
+ const automation = rendererSource('features/cc-agent/sidebar/AutomationSessionGroupItem.tsx');
+ const pinned = rendererSource('features/cc-agent/sidebar/sections/PinnedSection.tsx');
+ const search = rendererSource('features/cc-agent/sidebar/ConversationSearchBox.tsx');
+ const rail = rendererSource('features/cc-agent/sidebar/RailNav.tsx');
+ const sessionHeader = rendererSource('features/cc-agent/SessionContentHeader.tsx');
+ const tabBar = rendererSource('features/right-sidebar/TabBar.tsx');
+
+ expect(automation).toContain("text={t('ccAgent.sidebar.automationGroup.menu.more')}");
+ expect(pinned).toContain("text={t('ccAgent.sidebar.viewStyle')}");
+ expect(search).toContain("text={t('ccAgent.search.open')}");
+ expect(rail).toContain('text={t(`ccAgent.sidebar.railNav.${key}`)}');
+ expect(sessionHeader).toContain("text={t('ccAgent.sessionHeader.moreActions')}");
+ expect(tabBar).toContain("text={t('rightSidebar.tabs.addAria')}");
+ expect(tabBar).toContain('<Tip text={closeAriaLabel}>');
+ });
+
+ it('keeps modal tips visible and row details separate from inline action tips', () => {
+ const mobileDownload = rendererSource('components/sidebar/MobileDownloadDialog.tsx');
+ const sessionExport = rendererSource('features/cc-agent/sidebar/SessionShareExportDialog.tsx');
+ const automation = rendererSource('features/cc-agent/sidebar/AutomationSessionGroupItem.tsx');
+ const sessionItem = rendererSource('features/cc-agent/sidebar/SessionItem.tsx');
+
+ expect(mobileDownload).toMatch(
+ /text=\{t\('sidebar\.mobileDownload\.close'\)\}[\s\S]*?contentClassName="z-\[10001\]"/,
+ );
+ expect(sessionExport).toMatch(
+ /sessionShare\.export\.(?:hide|show)Password[\s\S]*?contentClassName="z-\[10001\]"/,
+ );
+ expect(automation).toContain('controlledOpen={rowTooltipOpen}');
+ expect(automation).toContain('setRowTooltipOpen(!isAutomationGroupInlineAction(event.target))');
+ expect(automation).toContain('onPointerLeave={() => setRowTooltipOpen(false)}');
+ expect(automation).toContain('onFocusCapture={(event) => {');
+ expect(automation).toContain('onBlurCapture={(event) => {');
+ expect(automation.match(/^\s+data-automation-group-inline-action="true"/gm)).toHaveLength(4);
+ expect(sessionItem).toContain('const [rowTooltipOpen, setRowTooltipOpen] = useState(false)');
+ expect(sessionItem).toContain(
+ 'setRowTooltipOpen(!isNestedSessionRowAction(event.target, event.currentTarget))',
+ );
+ expect(sessionItem).toContain('onPointerLeave={() => setRowTooltipOpen(false)}');
+ expect(sessionItem).toContain('controlledOpen={rowTooltipOpen}');
+ });
+
+ it('keeps disabled icon actions hoverable and keyboard discoverable', () => {
+ const sidebar = rendererSource('features/cc-agent/CCAgentSidebarUpper.tsx');
+ const backgroundTasks = rendererSource(
+ 'features/right-sidebar/plugins/background-tasks/BackgroundTasksBody.tsx',
+ );
+
+ expect(sidebar).toContain("t('ccAgent.sidebar.bulkSelection.actionInProgress')");
+ expect(sidebar).toContain("t('ccAgent.sidebar.bulkSelection.archiveNone')");
+ expect(sidebar).toContain('`${bulkArchiveActionLabel} — ${bulkActionInProgressLabel}`');
+ expect(sidebar).toContain('`${bulkDeleteActionLabel} — ${bulkActionInProgressLabel}`');
+ expect(sidebar).toContain('`${bulkClearActionLabel} — ${bulkActionInProgressLabel}`');
+ expect(sidebar).toContain('<Tip text={bulkArchiveLabel} side="bottom">');
+ expect(sidebar).toContain("role={bulkArchiveDisabled ? 'button' : undefined}");
+ expect(sidebar).toContain('tabIndex={bulkArchiveDisabled ? 0 : undefined}');
+ expect(sidebar).toContain('aria-hidden={bulkArchiveDisabled ? true : undefined}');
+ expect(sidebar).toContain("role={disabled ? 'button' : undefined}");
+ expect(sidebar).toContain('tabIndex={disabled ? 0 : undefined}');
+ expect(sidebar).toContain(
+ 'disabled && disabledReason ? `${actionLabel} — ${disabledReason}` : actionLabel',
+ );
+ expect(sidebar).toContain("t('ccAgent.sidebar.newDialogue')");
+ expect(sidebar).toContain("t('ccAgent.sidebar.creationInProgress')");
+ expect(sidebar).toContain("t('ccAgent.sidebar.projectAction.newInDirectory')");
+ expect(sidebar).toContain("t('ccAgent.remoteSession.actionsUnavailable')");
+ expect(backgroundTasks).toContain(
+ "`${actionLabel} — ${t('rightSidebar.backgroundTasks.stopping')}`",
+ );
+ const rail = rendererSource('features/cc-agent/sidebar/RailNav.tsx');
+ expect(rail).toContain('controlledOpen={panelState.openSection === key ? false : undefined}');
+ });
+
+ it('discovers native titles and icon controls without a managed Tip in guarded roots', () => {
+ expect(tooltipContractViolations()).toEqual([]);
+ });
+});
diff --git a/apps/desktop/src/renderer/__tests__/userInfoSectionHover.test.ts b/apps/desktop/src/renderer/__tests__/userInfoSectionHover.test.ts
index 4a08b95277..dd91d53cc8 100644
--- a/apps/desktop/src/renderer/__tests__/userInfoSectionHover.test.ts
+++ b/apps/desktop/src/renderer/__tests__/userInfoSectionHover.test.ts
@@ -94,6 +94,18 @@ describe('UserInfoSection — Canary avatar badge', () => {
expect(source).not.toContain("user.role === 'admin'");
expect(locale.sidebar.user.canaryBadge).toBe('灰度用户');
});
+
+ it('keeps the collapsed settings Tip from overlapping the Canary native title', () => {
+ expect(
+ source.match(/title=\{isCanary \? t\('sidebar\.user\.canaryBadge'\) : undefined\}/g),
+ ).toHaveLength(1);
+ expect(source).toMatch(
+ /className="relative h-\[27px\] w-\[27px\] shrink-0"\s+title=\{isCanary \? t\('sidebar\.user\.canaryBadge'\) : undefined\}/,
+ );
+ expect(source).not.toMatch(
+ /className="relative h-9 w-9 shrink-0"\s+title=\{isCanary \? t\('sidebar\.user\.canaryBadge'\) : undefined\}/,
+ );
+ });
});
describe('UserInfoSection — 未登录态头像兜底', () => {
@@ -176,7 +188,10 @@ describe('UserInfoSection — inner main button no longer owns hover background'
it('main button preserves onClick / role="link" / aria-label (跳转和无障碍不破)', () => {
expect(source).toContain('onClick={handleClick}');
expect(source).toContain('role="link"');
- expect(source).toContain("aria-label={t('sidebar.user.settingsLink', { name: displayName })}");
+ expect(source).toContain(
+ "const settingsLinkLabel = t('sidebar.user.settingsLink', { name: displayName });",
+ );
+ expect(source).toContain('aria-label={settingsLinkLabel}');
expect(locale.sidebar.user.settingsLink).toBe('设置,当前用户:{{name}}');
});
});
diff --git a/apps/desktop/src/renderer/components/layout/ChromeActions.tsx b/apps/desktop/src/renderer/components/layout/ChromeActions.tsx
index 6291d1fc35..13576614a1 100644
--- a/apps/desktop/src/renderer/components/layout/ChromeActions.tsx
+++ b/apps/desktop/src/renderer/components/layout/ChromeActions.tsx
@@ -36,6 +36,7 @@ import { PanelLeft } from 'lucide-react';
import { useTranslation } from 'react-i18next';
import { MenuButton } from '@/components/title-bar/MenuButton';
+import { Tip } from '@/components/ui/tooltip';
import { useMacFullscreen } from '@/hooks/useMacFullscreen';
import { cn } from '@/lib/utils';
@@ -65,6 +66,9 @@ export function ChromeActions({
isMac && !isFullscreen
? CHROME_ACTIONS_GEOMETRY.macTrafficLightLeft
: CHROME_ACTIONS_GEOMETRY.defaultLeft;
+ const sidebarToggleLabel = t(
+ isSidebarCollapsed ? 'contentHeader.expandSidebar' : 'contentHeader.collapseSidebar',
+ );
return (
<div
@@ -78,21 +82,23 @@ export function ChromeActions({
} as React.CSSProperties
}
>
- <button
- {...peekTriggerProps}
- className={cn(
- 'flex items-center justify-center',
- 'h-7 w-7 rounded-md',
- 'text-titlebar-icon',
- 'transition-colors',
- 'hover:bg-titlebar-button-hover',
- )}
- onClick={onToggleSidebar}
- aria-label={t('contentHeader.toggleSidebar')}
- aria-expanded={!isSidebarCollapsed}
- >
- <PanelLeft size={15} />
- </button>
+ <Tip text={sidebarToggleLabel} side="bottom">
+ <button
+ {...peekTriggerProps}
+ className={cn(
+ 'flex items-center justify-center',
+ 'h-7 w-7 rounded-md',
+ 'text-titlebar-icon',
+ 'transition-colors',
+ 'hover:bg-titlebar-button-hover',
+ )}
+ onClick={onToggleSidebar}
+ aria-label={sidebarToggleLabel}
+ aria-expanded={!isSidebarCollapsed}
+ >
+ <PanelLeft size={15} />
+ </button>
+ </Tip>
<MenuButton />
</div>
);
diff --git a/apps/desktop/src/renderer/components/layout/GhostPanelWindowLayout.tsx b/apps/desktop/src/renderer/components/layout/GhostPanelWindowLayout.tsx
index 6ee94dc942..1fc5ac2c6e 100644
--- a/apps/desktop/src/renderer/components/layout/GhostPanelWindowLayout.tsx
+++ b/apps/desktop/src/renderer/components/layout/GhostPanelWindowLayout.tsx
@@ -176,7 +176,6 @@ export function GhostPanelWindowLayout() {
{/* 合并回主窗口:关偏�?+ 关本�?面板原位回停�?*/}
<ChromeIconButton
onClick={mergeBack}
- title={t('rightSidebar.window.mergeBack')}
aria-label={t('rightSidebar.window.mergeBack')}
>
<PictureInPicture2 size={14} />
diff --git a/apps/desktop/src/renderer/components/layout/RightSidebarDetach.tsx b/apps/desktop/src/renderer/components/layout/RightSidebarDetach.tsx
index acbe7b6262..02fcec1601 100644
--- a/apps/desktop/src/renderer/components/layout/RightSidebarDetach.tsx
+++ b/apps/desktop/src/renderer/components/layout/RightSidebarDetach.tsx
@@ -11,6 +11,7 @@
import { PictureInPicture2 } from 'lucide-react';
import { useTranslation } from 'react-i18next';
+import { Tip } from '@/components/ui/tooltip';
import { cn } from '@/lib/utils';
interface RightSidebarDetachProps {
@@ -22,23 +23,25 @@ interface RightSidebarDetachProps {
export function RightSidebarDetach({ onDetach, size = 'toolbar' }: RightSidebarDetachProps) {
const { t } = useTranslation();
const isToolbar = size === 'toolbar';
+ const label = t('rightSidebar.tabs.controls.detachAria');
return (
- <button
- type="button"
- // toolbar(mac 浮层)与左簇 28px 规格族对齐(rounded-md);chip(Win TabBar)保持圆形。
- className={cn(
- 'pointer-events-auto flex h-7 w-7 items-center justify-center',
- isToolbar ? 'rounded-md' : 'rounded-full',
- 'text-titlebar-icon',
- 'transition-colors',
- 'hover:bg-titlebar-button-hover',
- )}
- onClick={onDetach}
- aria-label={t('rightSidebar.tabs.controls.detachAria')}
- title={t('rightSidebar.tabs.controls.detachAria')}
- >
- <PictureInPicture2 size={14} />
- </button>
+ <Tip text={label} side="bottom">
+ <button
+ type="button"
+ // toolbar(mac 浮层)与左簇 28px 规格族对齐(rounded-md);chip(Win TabBar)保持圆形。
+ className={cn(
+ 'pointer-events-auto flex h-7 w-7 items-center justify-center',
+ isToolbar ? 'rounded-md' : 'rounded-full',
+ 'text-titlebar-icon',
+ 'transition-colors',
+ 'hover:bg-titlebar-button-hover',
+ )}
+ onClick={onDetach}
+ aria-label={label}
+ >
+ <PictureInPicture2 size={14} />
+ </button>
+ </Tip>
);
}
diff --git a/apps/desktop/src/renderer/components/layout/RightSidebarMaximize.tsx b/apps/desktop/src/renderer/components/layout/RightSidebarMaximize.tsx
index 7fd509e253..4803198fb0 100644
--- a/apps/desktop/src/renderer/components/layout/RightSidebarMaximize.tsx
+++ b/apps/desktop/src/renderer/components/layout/RightSidebarMaximize.tsx
@@ -13,6 +13,7 @@
import { Maximize2, Minimize2 } from 'lucide-react';
import { useTranslation } from 'react-i18next';
+import { Tip } from '@/components/ui/tooltip';
import { cn } from '@/lib/utils';
interface RightSidebarMaximizeProps {
@@ -32,25 +33,28 @@ export function RightSidebarMaximize({
const { t } = useTranslation();
const isToolbar = size === 'toolbar';
const Icon = isMaximized ? Minimize2 : Maximize2;
+ const label = t(
+ isMaximized
+ ? 'rightSidebar.tabs.controls.restoreAria'
+ : 'rightSidebar.tabs.controls.maximizeAria',
+ );
return (
- <button
- type="button"
- className={cn(
- 'pointer-events-auto flex h-7 w-7 items-center justify-center',
- isToolbar ? 'rounded-md' : 'rounded-full',
- 'text-titlebar-icon',
- 'transition-colors',
- 'hover:bg-titlebar-button-hover',
- )}
- onClick={onMaximize}
- aria-label={t(
- isMaximized
- ? 'rightSidebar.tabs.controls.restoreAria'
- : 'rightSidebar.tabs.controls.maximizeAria',
- )}
- >
- <Icon size={14} />
- </button>
+ <Tip text={label} side="bottom">
+ <button
+ type="button"
+ className={cn(
+ 'pointer-events-auto flex h-7 w-7 items-center justify-center',
+ isToolbar ? 'rounded-md' : 'rounded-full',
+ 'text-titlebar-icon',
+ 'transition-colors',
+ 'hover:bg-titlebar-button-hover',
+ )}
+ onClick={onMaximize}
+ aria-label={label}
+ >
+ <Icon size={14} />
+ </button>
+ </Tip>
);
}
diff --git a/apps/desktop/src/renderer/components/layout/RightSidebarToggle.tsx b/apps/desktop/src/renderer/components/layout/RightSidebarToggle.tsx
index 0814f18762..ddb2569e06 100644
--- a/apps/desktop/src/renderer/components/layout/RightSidebarToggle.tsx
+++ b/apps/desktop/src/renderer/components/layout/RightSidebarToggle.tsx
@@ -22,6 +22,7 @@
import { PanelLeft, PanelRight } from 'lucide-react';
import { useTranslation } from 'react-i18next';
+import { Tip } from '@/components/ui/tooltip';
import { cn } from '@/lib/utils';
interface RightSidebarToggleProps {
@@ -50,37 +51,33 @@ export function RightSidebarToggle({
const { t } = useTranslation();
const isToolbar = size === 'toolbar';
const Icon = side === 'left' ? PanelLeft : PanelRight;
+ // B2c:文案只说动作(折叠/展开),不提"右栏"等方位名词 —— 按钮按位置寻址,
+ // 管的是"贴这条缘的面板",绑定方位词会在面板换侧后说谎。
+ const label = t(
+ action === 'show'
+ ? 'rightSidebar.tabs.controls.showAria'
+ : collapsed
+ ? 'contentHeader.expandPanel'
+ : 'contentHeader.collapsePanel',
+ );
return (
- <button
- type="button"
- className={cn(
- 'pointer-events-auto flex h-7 w-7 items-center justify-center',
- isToolbar ? 'rounded-md' : 'rounded-full',
- 'text-titlebar-icon',
- 'transition-colors',
- 'hover:bg-titlebar-button-hover',
- )}
- onClick={onToggle}
- // B2c:文案只说动作(折叠/展开),不提"右栏"等方位名词 —— 按钮按位置寻址,
- // 管的是"贴这条缘的面板",绑定方位词会在面板换侧后说谎。
- aria-label={t(
- action === 'show'
- ? 'rightSidebar.tabs.controls.showAria'
- : collapsed
- ? 'contentHeader.expandPanel'
- : 'contentHeader.collapsePanel',
- )}
- title={t(
- action === 'show'
- ? 'rightSidebar.tabs.controls.showAria'
- : collapsed
- ? 'contentHeader.expandPanel'
- : 'contentHeader.collapsePanel',
- )}
- aria-expanded={!collapsed}
- >
- <Icon size={15} />
- </button>
+ <Tip text={label} side="bottom">
+ <button
+ type="button"
+ className={cn(
+ 'pointer-events-auto flex h-7 w-7 items-center justify-center',
+ isToolbar ? 'rounded-md' : 'rounded-full',
+ 'text-titlebar-icon',
+ 'transition-colors',
+ 'hover:bg-titlebar-button-hover',
+ )}
+ onClick={onToggle}
+ aria-label={label}
+ aria-expanded={!collapsed}
+ >
+ <Icon size={15} />
+ </button>
+ </Tip>
);
}
diff --git a/apps/desktop/src/renderer/components/layout/SidebarWindowLayout.tsx b/apps/desktop/src/renderer/components/layout/SidebarWindowLayout.tsx
index 0e0db3c119..091ec1e6d6 100644
--- a/apps/desktop/src/renderer/components/layout/SidebarWindowLayout.tsx
+++ b/apps/desktop/src/renderer/components/layout/SidebarWindowLayout.tsx
@@ -294,7 +294,6 @@ export function SidebarWindowLayout() {
log.warn('merge back failed', err);
});
}}
- title={t('rightSidebar.window.mergeBack')}
aria-label={t('rightSidebar.window.mergeBack')}
>
<PanelRight size={14} />
diff --git a/apps/desktop/src/renderer/components/layout/__tests__/ReusableWindowChrome.test.tsx b/apps/desktop/src/renderer/components/layout/__tests__/ReusableWindowChrome.test.tsx
index 3b81c97093..c92fcd5644 100644
--- a/apps/desktop/src/renderer/components/layout/__tests__/ReusableWindowChrome.test.tsx
+++ b/apps/desktop/src/renderer/components/layout/__tests__/ReusableWindowChrome.test.tsx
@@ -273,7 +273,7 @@ describe('reusable auxiliary window chrome', () => {
render(<GhostPanelWindowLayout />);
const mergeBack = screen.getByRole('button', { name: 'rightSidebar.window.mergeBack' });
- expect(mergeBack.getAttribute('title')).toBe('rightSidebar.window.mergeBack');
+ expect(mergeBack.getAttribute('title')).toBeNull();
expect(mergeBack.textContent).not.toContain('rightSidebar.window.mergeBack');
fireEvent.click(mergeBack);
diff --git a/apps/desktop/src/renderer/components/layout/__tests__/RightSidebarToggle.test.tsx b/apps/desktop/src/renderer/components/layout/__tests__/RightSidebarToggle.test.tsx
index 24b2b80e2f..a9620569d8 100644
--- a/apps/desktop/src/renderer/components/layout/__tests__/RightSidebarToggle.test.tsx
+++ b/apps/desktop/src/renderer/components/layout/__tests__/RightSidebarToggle.test.tsx
@@ -25,7 +25,7 @@ describe('RightSidebarToggle', () => {
const button = screen.getByRole('button', {
name: 'rightSidebar.tabs.controls.showAria',
});
- expect(button.getAttribute('title')).toBe('rightSidebar.tabs.controls.showAria');
+ expect(button.getAttribute('title')).toBeNull();
fireEvent.click(button);
expect(onToggle).toHaveBeenCalledOnce();
},
diff --git a/apps/desktop/src/renderer/components/sidebar/MobileDownloadDialog.tsx b/apps/desktop/src/renderer/components/sidebar/MobileDownloadDialog.tsx
index d059087db1..9f01c43b85 100644
--- a/apps/desktop/src/renderer/components/sidebar/MobileDownloadDialog.tsx
+++ b/apps/desktop/src/renderer/components/sidebar/MobileDownloadDialog.tsx
@@ -6,6 +6,7 @@ import * as QRCode from 'qrcode';
import cindyIconUrl from '@/../../resources/icon.png?url';
import { Spinner } from '@/components/ui/spinner';
+import { Tip } from '@/components/ui/tooltip';
import { compareDevicesByName } from '@/features/device-link/deviceSort';
import { toast } from '@/lib/toast';
import { cn } from '@/lib/utils';
@@ -382,20 +383,26 @@ export function MobileDownloadDialog({
}}
>
<Dialog.Close asChild>
- <button
- ref={closeActionRef}
- type="button"
- aria-label={t('sidebar.mobileDownload.close')}
- className={cn(
- 'absolute right-3 top-3 z-10 flex h-8 w-8 items-center justify-center rounded-full',
- 'text-[var(--confirm-desc)] transition-colors',
- 'hover:bg-[var(--surface-hover)] hover:text-[var(--confirm-title)]',
- 'active:scale-[0.98]',
- 'focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]',
- )}
+ <Tip
+ text={t('sidebar.mobileDownload.close')}
+ side="bottom"
+ contentClassName="z-[10001]"
>
- <X className="h-4 w-4" aria-hidden="true" />
- </button>
+ <button
+ ref={closeActionRef}
+ type="button"
+ aria-label={t('sidebar.mobileDownload.close')}
+ className={cn(
+ 'absolute right-3 top-3 z-10 flex h-8 w-8 items-center justify-center rounded-full',
+ 'text-[var(--confirm-desc)] transition-colors',
+ 'hover:bg-[var(--surface-hover)] hover:text-[var(--confirm-title)]',
+ 'active:scale-[0.98]',
+ 'focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]',
+ )}
+ >
+ <X className="h-4 w-4" aria-hidden="true" />
+ </button>
+ </Tip>
</Dialog.Close>
<div className="flex flex-col items-center text-center">
diff --git a/apps/desktop/src/renderer/components/sidebar/SidebarIconButton.tsx b/apps/desktop/src/renderer/components/sidebar/SidebarIconButton.tsx
index 76f7124624..343ad8fd77 100644
--- a/apps/desktop/src/renderer/components/sidebar/SidebarIconButton.tsx
+++ b/apps/desktop/src/renderer/components/sidebar/SidebarIconButton.tsx
@@ -22,6 +22,7 @@
import type { ButtonHTMLAttributes } from 'react';
import type { LucideIcon } from 'lucide-react';
+import { Tip } from '@/components/ui/tooltip';
import { cn } from '@/lib/utils';
import { AttentionDot, type DotTone } from './AttentionDot';
@@ -53,7 +54,7 @@ export const SIDEBAR_RAIL_ICON_BUTTON_CLASS = cn(
export interface SidebarIconButtonProps
extends ButtonHTMLAttributes<HTMLButtonElement> {
icon: LucideIcon;
- /** aria-label 与原生 title(可被传入的 title 覆盖)。 */
+ /** aria-label 与可见 tooltip 文案。 */
label: string;
variant?: 'grid' | 'rail';
active?: boolean;
@@ -71,13 +72,15 @@ export function SidebarIconButton({
showDot = false,
dotTone = 'done',
className,
+ disabled,
+ title,
...rest
}: SidebarIconButtonProps) {
- return (
+ const button = (
<button
type="button"
aria-label={label}
- title={label}
+ disabled={disabled}
className={cn(
BTN_BASE,
variant === 'grid' ? GRID_GEOMETRY : RAIL_GEOMETRY,
@@ -85,9 +88,31 @@ export function SidebarIconButton({
className,
)}
{...rest}
+ aria-hidden={disabled ? true : undefined}
>
<Icon size={18} />
{showDot && <AttentionDot size={6} tone={dotTone} className="absolute right-1.5 top-1.5" />}
</button>
);
+
+ return (
+ <Tip text={title ?? label} side="right">
+ {disabled ? (
+ <span
+ role="button"
+ aria-disabled="true"
+ aria-label={title ?? label}
+ tabIndex={0}
+ className={cn(
+ 'inline-flex focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]',
+ variant === 'grid' ? 'rounded-[6px]' : 'rounded-full',
+ )}
+ >
+ {button}
+ </span>
+ ) : (
+ button
+ )}
+ </Tip>
+ );
}
diff --git a/apps/desktop/src/renderer/components/sidebar/UserInfoSection.tsx b/apps/desktop/src/renderer/components/sidebar/UserInfoSection.tsx
index 1e07e012aa..79f51c887b 100644
--- a/apps/desktop/src/renderer/components/sidebar/UserInfoSection.tsx
+++ b/apps/desktop/src/renderer/components/sidebar/UserInfoSection.tsx
@@ -7,6 +7,7 @@ import { cn } from '@/lib/utils';
import { useAuth } from '@/contexts/AuthContext';
import { useUpdateStatus } from '@/hooks/useUpdateStatus';
import { useUpdateBannerDismiss } from '@/hooks/useUpdateBannerDismiss';
+import { Tip } from '@/components/ui/tooltip';
import { CURRENT_CINDY_REGION } from '../../../shared/brandRegion';
import { shouldLabelRegion } from '../../../shared/regionCode';
import { MobileDownloadDialog } from './MobileDownloadDialog';
@@ -38,6 +39,7 @@ export function UserInfoSection({ isCollapsed, onOpenUpdateNotice }: UserInfoSec
// 让新地址有机会渲染,而不是永远停在首字母兜底。
const isLocal = mode === 'local';
const displayName = user?.name ?? (isLocal ? t('settings.userProfile.local.name') : '');
+ const settingsLinkLabel = t('sidebar.user.settingsLink', { name: displayName });
const avatarUrl = user?.avatar ?? null;
useEffect(() => {
setAvatarError(false);
@@ -88,73 +90,74 @@ export function UserInfoSection({ isCollapsed, onOpenUpdateNotice }: UserInfoSec
};
const mobileDownloadEntry = (
- <button
- ref={mobileDownloadButtonRef}
- type="button"
- onClick={() => setMobileDownloadOpen(true)}
- aria-label={t('sidebar.user.downloadMobile')}
- className={cn(
- 'mobile-download-btn',
- 'flex h-[22px] w-[22px] shrink-0 items-center justify-center rounded-full',
- !isCollapsed && 'mr-1',
- 'border border-[var(--sidebar-user-card-border)] bg-[var(--sidebar-user-card-bg)]',
- 'text-[var(--sidebar-user-card-text)] transition-colors hover:bg-sidebar-item-hover',
- 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]',
- )}
- >
- <Smartphone className="h-3 w-3" aria-hidden="true" />
- </button>
+ <Tip text={t('sidebar.user.downloadMobile')} side="right">
+ <button
+ ref={mobileDownloadButtonRef}
+ type="button"
+ onClick={() => setMobileDownloadOpen(true)}
+ aria-label={t('sidebar.user.downloadMobile')}
+ className={cn(
+ 'mobile-download-btn',
+ 'flex h-[22px] w-[22px] shrink-0 items-center justify-center rounded-full',
+ !isCollapsed && 'mr-1',
+ 'border border-[var(--sidebar-user-card-border)] bg-[var(--sidebar-user-card-bg)]',
+ 'text-[var(--sidebar-user-card-text)] transition-colors hover:bg-sidebar-item-hover',
+ 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]',
+ )}
+ >
+ <Smartphone className="h-3 w-3" aria-hidden="true" />
+ </button>
+ </Tip>
);
if (isCollapsed) {
return (
<>
<div className="mt-auto flex h-[66px] flex-col items-center justify-center gap-1 px-3">
- <button
- onClick={handleClick}
- role="link"
- aria-label={t('sidebar.user.settingsLink', { name: displayName })}
- className="flex min-w-0 items-center justify-center text-left"
- >
- <div
- className="relative h-9 w-9 shrink-0"
- title={isCanary ? t('sidebar.user.canaryBadge') : undefined}
+ <Tip text={settingsLinkLabel} side="right">
+ <button
+ onClick={handleClick}
+ role="link"
+ aria-label={settingsLinkLabel}
+ className="flex min-w-0 items-center justify-center text-left"
>
- {user?.avatar && !avatarError ? (
- <img
- src={user.avatar}
- alt={displayName}
- className="h-9 w-9 rounded-full object-cover"
- onError={() => setAvatarError(true)}
- />
- ) : (
- <div
- className={cn(
- 'flex h-9 w-9 items-center justify-center rounded-full',
- 'border border-sidebar-border bg-sidebar-item-hover text-base font-medium text-foreground',
- )}
- >
- {showNotSignedInGlyph ? (
- <UserRound aria-hidden="true" size={18} strokeWidth={1.75} />
- ) : (
- initial
- )}
- </div>
- )}
- {isCanary && (
- <span
- aria-label={t('sidebar.user.canaryBadge')}
- className={cn(
- 'absolute -bottom-0.5 -right-0.5',
- 'flex h-3 w-3 items-center justify-center rounded-full',
- 'bg-foreground text-background ring-2 ring-sidebar',
- )}
- >
- <Shield size={8} strokeWidth={2.5} />
- </span>
- )}
- </div>
- </button>
+ <div className="relative h-9 w-9 shrink-0">
+ {user?.avatar && !avatarError ? (
+ <img
+ src={user.avatar}
+ alt={displayName}
+ className="h-9 w-9 rounded-full object-cover"
+ onError={() => setAvatarError(true)}
+ />
+ ) : (
+ <div
+ className={cn(
+ 'flex h-9 w-9 items-center justify-center rounded-full',
+ 'border border-sidebar-border bg-sidebar-item-hover text-base font-medium text-foreground',
+ )}
+ >
+ {showNotSignedInGlyph ? (
+ <UserRound aria-hidden="true" size={18} strokeWidth={1.75} />
+ ) : (
+ initial
+ )}
+ </div>
+ )}
+ {isCanary && (
+ <span
+ aria-label={t('sidebar.user.canaryBadge')}
+ className={cn(
+ 'absolute -bottom-0.5 -right-0.5',
+ 'flex h-3 w-3 items-center justify-center rounded-full',
+ 'bg-foreground text-background ring-2 ring-sidebar',
+ )}
+ >
+ <Shield size={8} strokeWidth={2.5} />
+ </span>
+ )}
+ </div>
+ </button>
+ </Tip>
{mobileDownloadEntry}
</div>
<MobileDownloadDialog
@@ -184,7 +187,7 @@ export function UserInfoSection({ isCollapsed, onOpenUpdateNotice }: UserInfoSec
<button
onClick={handleClick}
role="link"
- aria-label={t('sidebar.user.settingsLink', { name: displayName })}
+ aria-label={settingsLinkLabel}
className={cn('flex min-w-0 flex-1 items-center gap-[10px]', 'text-left')}
>
{/* Avatar — admin 用户加 1.5px 反色描边 + 右下角盾牌角标 */}
@@ -257,38 +260,47 @@ export function UserInfoSection({ isCollapsed, onOpenUpdateNotice }: UserInfoSec
update 时切换为「唤回 banner」入口,视觉涂黑(fill 实心 + foreground 主色)
告诉用户还有更新等待确认。 */}
{(onOpenUpdateNotice || isFlameReopen) && (
- <button
- onClick={(e) => {
- e.stopPropagation();
- if (isFlameReopen) {
- restore();
- } else {
- onOpenUpdateNotice?.();
- }
- }}
- aria-label={
+ <Tip
+ text={
isFlameReopen
? t('sidebar.user.reopenUpdateBanner')
: t('sidebar.user.viewReleaseNotes')
}
- className={cn(
- 'flame-btn',
- 'flex h-[22px] w-[22px] shrink-0 items-center justify-center rounded-full',
- 'border border-[var(--sidebar-user-card-border)] bg-[var(--sidebar-user-card-bg)]',
- 'transition-colors hover:bg-sidebar-item-hover',
- 'transition-opacity duration-200 ease-in-out',
- 'opacity-100',
- )}
+ side="right"
>
- <Flame
- className={cn(
- 'h-3 w-3',
+ <button
+ onClick={(e) => {
+ e.stopPropagation();
+ if (isFlameReopen) {
+ restore();
+ } else {
+ onOpenUpdateNotice?.();
+ }
+ }}
+ aria-label={
isFlameReopen
- ? 'fill-current text-[var(--sidebar-user-card-text)]'
- : 'text-[var(--sidebar-user-card-text)]',
+ ? t('sidebar.user.reopenUpdateBanner')
+ : t('sidebar.user.viewReleaseNotes')
+ }
+ className={cn(
+ 'flame-btn',
+ 'flex h-[22px] w-[22px] shrink-0 items-center justify-center rounded-full',
+ 'border border-[var(--sidebar-user-card-border)] bg-[var(--sidebar-user-card-bg)]',
+ 'transition-colors hover:bg-sidebar-item-hover',
+ 'transition-opacity duration-200 ease-in-out',
+ 'opacity-100',
)}
- />
- </button>
+ >
+ <Flame
+ className={cn(
+ 'h-3 w-3',
+ isFlameReopen
+ ? 'fill-current text-[var(--sidebar-user-card-text)]'
+ : 'text-[var(--sidebar-user-card-text)]',
+ )}
+ />
+ </button>
+ </Tip>
)}
</div>
diff --git a/apps/desktop/src/renderer/components/title-bar/ChromeIconButton.tsx b/apps/desktop/src/renderer/components/title-bar/ChromeIconButton.tsx
index e432e546b2..11876751dd 100644
--- a/apps/desktop/src/renderer/components/title-bar/ChromeIconButton.tsx
+++ b/apps/desktop/src/renderer/components/title-bar/ChromeIconButton.tsx
@@ -1,5 +1,7 @@
import type { ButtonHTMLAttributes, ReactNode } from 'react';
+import { Tip, type TipProps } from '@/components/ui/tooltip';
+
/**
* ChromeIconButton —— 标题栏 28px 圆形图标按钮基元。
*
@@ -17,11 +19,52 @@ const CHROME_ICON_BUTTON_CLASS =
export function ChromeIconButton({
children,
className,
+ tooltip,
+ tooltipSide,
+ tooltipDelay,
+ title,
...rest
-}: ButtonHTMLAttributes<HTMLButtonElement> & { children?: ReactNode }) {
- return (
- <button type="button" className={[CHROME_ICON_BUTTON_CLASS, className].filter(Boolean).join(' ')} {...rest}>
+}: ButtonHTMLAttributes<HTMLButtonElement> & {
+ children?: ReactNode;
+ tooltip?: ReactNode;
+ tooltipSide?: TipProps['side'];
+ tooltipDelay?: number;
+}) {
+ const accessibleLabel = rest['aria-label'];
+ const tooltipText =
+ tooltip ?? title ?? (typeof accessibleLabel === 'string' ? accessibleLabel : undefined);
+ const disabledLabel =
+ typeof tooltipText === 'string'
+ ? tooltipText
+ : typeof accessibleLabel === 'string'
+ ? accessibleLabel
+ : undefined;
+ const button = (
+ <button
+ type="button"
+ className={[CHROME_ICON_BUTTON_CLASS, className].filter(Boolean).join(' ')}
+ {...rest}
+ aria-hidden={rest.disabled ? true : undefined}
+ >
{children}
</button>
);
+
+ return (
+ <Tip text={tooltipText} side={tooltipSide} delay={tooltipDelay}>
+ {rest.disabled ? (
+ <span
+ role="button"
+ aria-disabled="true"
+ aria-label={disabledLabel}
+ tabIndex={0}
+ className="inline-flex rounded-full focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]"
+ >
+ {button}
+ </span>
+ ) : (
+ button
+ )}
+ </Tip>
+ );
}
diff --git a/apps/desktop/src/renderer/components/title-bar/MenuButton.tsx b/apps/desktop/src/renderer/components/title-bar/MenuButton.tsx
index 0100709cde..5c720184af 100644
--- a/apps/desktop/src/renderer/components/title-bar/MenuButton.tsx
+++ b/apps/desktop/src/renderer/components/title-bar/MenuButton.tsx
@@ -13,6 +13,7 @@ import {
DropdownMenuItem,
DropdownMenuTrigger,
} from '@/components/ui/dropdown-menu';
+import { Tip } from '@/components/ui/tooltip';
export function MenuButton() {
const { t } = useTranslation();
@@ -21,21 +22,23 @@ export function MenuButton() {
return (
<DropdownMenu>
<DropdownMenuTrigger asChild>
- {/* 尺寸与 ChromeActions 的折叠按钮同规格(h-7 / 图标 15 / rounded-md),
- 与折叠态标题行图标(「…」h-7 / 15)视觉重量一致。 */}
- <button
- className={cn(
- 'flex items-center justify-center',
- 'h-7 w-7 rounded-md',
- 'text-titlebar-icon',
- 'transition-colors',
- 'hover:bg-titlebar-button-hover',
- 'focus-visible:outline-none',
- )}
- aria-label={t('titleBar.menu')}
- >
- <Menu size={15} />
- </button>
+ <Tip text={t('titleBar.menu')} side="bottom">
+ {/* 尺寸与 ChromeActions 的折叠按钮同规格(h-7 / 图标 15 / rounded-md),
+ 与折叠态标题行图标(「…」h-7 / 15)视觉重量一致。 */}
+ <button
+ className={cn(
+ 'flex items-center justify-center',
+ 'h-7 w-7 rounded-md',
+ 'text-titlebar-icon',
+ 'transition-colors',
+ 'hover:bg-titlebar-button-hover',
+ 'focus-visible:outline-none',
+ )}
+ aria-label={t('titleBar.menu')}
+ >
+ <Menu size={15} />
+ </button>
+ </Tip>
</DropdownMenuTrigger>
<DropdownMenuContent
align="start"
diff --git a/apps/desktop/src/renderer/components/title-bar/WindowControls.tsx b/apps/desktop/src/renderer/components/title-bar/WindowControls.tsx
index 5f2abaedfd..c3b3770f96 100644
--- a/apps/desktop/src/renderer/components/title-bar/WindowControls.tsx
+++ b/apps/desktop/src/renderer/components/title-bar/WindowControls.tsx
@@ -119,9 +119,7 @@ export function WindowControls({
}
};
- const selectWindowsCloseBehavior = async (
- behavior: WindowsCloseBehavior,
- ): Promise<void> => {
+ const selectWindowsCloseBehavior = async (behavior: WindowsCloseBehavior): Promise<void> => {
if (savingWindowsCloseBehaviorRef.current) return;
savingWindowsCloseBehaviorRef.current = true;
setSavingWindowsCloseBehavior(true);
@@ -188,6 +186,7 @@ export function WindowControls({
className={cn(controlBase, 'hover:bg-titlebar-control-hover')}
onClick={handleMinimizeClick}
aria-label={t('titleBar.minimize')}
+ data-tooltip-exempt="windows-system-control"
>
<Minus size={14} />
</button>
@@ -195,18 +194,38 @@ export function WindowControls({
<button
className={cn(controlBase, 'hover:bg-titlebar-control-hover')}
onClick={() => window.electronAPI.windowMaximize()}
- aria-label={t('titleBar.maximize')}
+ aria-label={t('titleBar.maximizeOrRestore')}
+ data-tooltip-exempt="windows-system-control"
>
<Square size={14} />
</button>
- <button
- className={cn(controlBase, 'hover:bg-[#E81123] hover:text-white')}
- onClick={() => void handleCloseClick()}
- aria-label={t('titleBar.close')}
- disabled={closing}
- >
- <X size={14} />
- </button>
+ {closing ? (
+ <span
+ role="button"
+ aria-disabled="true"
+ aria-label={t('titleBar.closing.title')}
+ tabIndex={0}
+ data-tooltip-exempt="windows-system-control"
+ className="inline-flex focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]"
+ >
+ <button
+ className={cn(controlBase, 'hover:bg-[#E81123] hover:text-white')}
+ aria-hidden="true"
+ disabled
+ >
+ <X size={14} />
+ </button>
+ </span>
+ ) : (
+ <button
+ className={cn(controlBase, 'hover:bg-[#E81123] hover:text-white')}
+ onClick={() => void handleCloseClick()}
+ aria-label={t('titleBar.close')}
+ data-tooltip-exempt="windows-system-control"
+ >
+ <X size={14} />
+ </button>
+ )}
</div>
<ConfirmDialog
open={showWindowsCloseBehaviorDialog}
@@ -277,9 +296,7 @@ function ClosingOverlay({ visible }: { visible: boolean }) {
style={{ background: 'var(--surface-elevated)' }}
>
<Spinner size={16} className="text-[var(--text-primary)]" />
- <span className="text-sm text-[var(--text-primary)]">
- {t('titleBar.closing.title')}
- </span>
+ <span className="text-sm text-[var(--text-primary)]">{t('titleBar.closing.title')}</span>
</div>
</div>,
document.body,
diff --git a/apps/desktop/src/renderer/features/cc-agent/CCAgentSidebarUpper.tsx b/apps/desktop/src/renderer/features/cc-agent/CCAgentSidebarUpper.tsx
index 9dae743dc8..58da5ee3e0 100644
--- a/apps/desktop/src/renderer/features/cc-agent/CCAgentSidebarUpper.tsx
+++ b/apps/desktop/src/renderer/features/cc-agent/CCAgentSidebarUpper.tsx
@@ -81,7 +81,7 @@ import {
DropdownMenuSeparator,
DropdownMenuTrigger,
} from '@/components/ui/dropdown-menu';
-import { Tooltip } from '@/components/ui/tooltip';
+import { Tip, Tooltip } from '@/components/ui/tooltip';
import * as sessionService from '@/lib/sessionService';
import { makerChatStore } from '@/lib/makerChatStore';
import { discardDraft as discardComposerDraft } from '@/lib/composerDraftStore';
@@ -3278,6 +3278,26 @@ function ExpandedView({
t,
],
);
+ const bulkActionInProgressLabel = t('ccAgent.sidebar.bulkSelection.actionInProgress');
+ const bulkArchiveActionLabel = t('ccAgent.sidebar.bulkSelection.archive');
+ const bulkDeleteActionLabel = t('ccAgent.sidebar.bulkSelection.delete');
+ const bulkClearActionLabel = t('ccAgent.sidebar.bulkSelection.clear');
+ const bulkArchiveLabel =
+ bulkActionPending !== null
+ ? `${bulkArchiveActionLabel} — ${bulkActionInProgressLabel}`
+ : selectedActiveSessionCount === 0
+ ? t('ccAgent.sidebar.bulkSelection.archiveNone')
+ : bulkArchiveActionLabel;
+ const bulkDeleteLabel =
+ bulkActionPending !== null
+ ? `${bulkDeleteActionLabel} — ${bulkActionInProgressLabel}`
+ : bulkDeleteActionLabel;
+ const bulkClearLabel =
+ bulkActionPending !== null
+ ? `${bulkClearActionLabel} — ${bulkActionInProgressLabel}`
+ : bulkClearActionLabel;
+ const bulkArchiveDisabled = bulkActionPending !== null || selectedActiveSessionCount === 0;
+ const bulkActionDisabled = bulkActionPending !== null;
return (
<>
@@ -3295,51 +3315,81 @@ function ExpandedView({
<span className="min-w-0 flex-1 truncate text-xs font-medium">
{t('ccAgent.sidebar.bulkSelection.selected', { count: selectedSessionIds.size })}
</span>
- <button
- type="button"
- onClick={() => void handleBulkArchive()}
- disabled={bulkActionPending !== null || selectedActiveSessionCount === 0}
- aria-label={t('ccAgent.sidebar.bulkSelection.archive')}
- title={t('ccAgent.sidebar.bulkSelection.archive')}
- className={cn(
- 'flex size-6 shrink-0 items-center justify-center rounded-full',
- 'text-[var(--cmd-palette-item-meta)] hover:bg-[var(--cmd-palette-item-hover)] hover:text-[var(--msg-assistant-text)]',
- 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring-soft)]',
- 'disabled:cursor-default disabled:opacity-40 disabled:hover:bg-transparent disabled:hover:text-[var(--cmd-palette-item-meta)]',
- )}
- >
- <Archive size={13} strokeWidth={2} />
- </button>
- <button
- type="button"
- onClick={() => void handleBulkDelete()}
- disabled={bulkActionPending !== null}
- aria-label={t('ccAgent.sidebar.bulkSelection.delete')}
- title={t('ccAgent.sidebar.bulkSelection.delete')}
- className={cn(
- 'flex size-6 shrink-0 items-center justify-center rounded-full',
- 'text-[var(--cmd-palette-item-meta)] hover:bg-[var(--cmd-palette-item-hover)] hover:text-[var(--msg-assistant-text)]',
- 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring-soft)]',
- 'disabled:cursor-default disabled:opacity-40 disabled:hover:bg-transparent disabled:hover:text-[var(--cmd-palette-item-meta)]',
- )}
- >
- <Trash2 size={13} strokeWidth={2} />
- </button>
- <button
- type="button"
- onClick={handleClearSelection}
- disabled={bulkActionPending !== null}
- aria-label={t('ccAgent.sidebar.bulkSelection.clear')}
- title={t('ccAgent.sidebar.bulkSelection.clear')}
- className={cn(
- 'flex size-6 shrink-0 items-center justify-center rounded-full',
- 'text-[var(--cmd-palette-item-meta)] hover:bg-[var(--cmd-palette-item-hover)] hover:text-[var(--msg-assistant-text)]',
- 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring-soft)]',
- 'disabled:cursor-default disabled:opacity-40 disabled:hover:bg-transparent disabled:hover:text-[var(--cmd-palette-item-meta)]',
- )}
- >
- <X size={13} strokeWidth={2} />
- </button>
+ <Tip text={bulkArchiveLabel} side="bottom">
+ <span
+ role={bulkArchiveDisabled ? 'button' : undefined}
+ aria-disabled={bulkArchiveDisabled ? true : undefined}
+ aria-label={bulkArchiveDisabled ? bulkArchiveLabel : undefined}
+ tabIndex={bulkArchiveDisabled ? 0 : undefined}
+ className="inline-flex rounded-full focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring-soft)]"
+ >
+ <button
+ type="button"
+ onClick={() => void handleBulkArchive()}
+ disabled={bulkArchiveDisabled}
+ aria-label={bulkArchiveLabel}
+ aria-hidden={bulkArchiveDisabled ? true : undefined}
+ className={cn(
+ 'flex size-6 shrink-0 items-center justify-center rounded-full',
+ 'text-[var(--cmd-palette-item-meta)] hover:bg-[var(--cmd-palette-item-hover)] hover:text-[var(--msg-assistant-text)]',
+ 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring-soft)]',
+ 'disabled:cursor-default disabled:opacity-40 disabled:hover:bg-transparent disabled:hover:text-[var(--cmd-palette-item-meta)]',
+ )}
+ >
+ <Archive size={13} strokeWidth={2} />
+ </button>
+ </span>
+ </Tip>
+ <Tip text={bulkDeleteLabel} side="bottom">
+ <span
+ role={bulkActionDisabled ? 'button' : undefined}
+ aria-disabled={bulkActionDisabled ? true : undefined}
+ aria-label={bulkActionDisabled ? bulkDeleteLabel : undefined}
+ tabIndex={bulkActionDisabled ? 0 : undefined}
+ className="inline-flex rounded-full focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring-soft)]"
+ >
+ <button
+ type="button"
+ onClick={() => void handleBulkDelete()}
+ disabled={bulkActionDisabled}
+ aria-label={bulkDeleteLabel}
+ aria-hidden={bulkActionDisabled ? true : undefined}
+ className={cn(
+ 'flex size-6 shrink-0 items-center justify-center rounded-full',
+ 'text-[var(--cmd-palette-item-meta)] hover:bg-[var(--cmd-palette-item-hover)] hover:text-[var(--msg-assistant-text)]',
+ 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring-soft)]',
+ 'disabled:cursor-default disabled:opacity-40 disabled:hover:bg-transparent disabled:hover:text-[var(--cmd-palette-item-meta)]',
+ )}
+ >
+ <Trash2 size={13} strokeWidth={2} />
+ </button>
+ </span>
+ </Tip>
+ <Tip text={bulkClearLabel} side="bottom">
+ <span
+ role={bulkActionDisabled ? 'button' : undefined}
+ aria-disabled={bulkActionDisabled ? true : undefined}
+ aria-label={bulkActionDisabled ? bulkClearLabel : undefined}
+ tabIndex={bulkActionDisabled ? 0 : undefined}
+ className="inline-flex rounded-full focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring-soft)]"
+ >
+ <button
+ type="button"
+ onClick={handleClearSelection}
+ disabled={bulkActionDisabled}
+ aria-label={bulkClearLabel}
+ aria-hidden={bulkActionDisabled ? true : undefined}
+ className={cn(
+ 'flex size-6 shrink-0 items-center justify-center rounded-full',
+ 'text-[var(--cmd-palette-item-meta)] hover:bg-[var(--cmd-palette-item-hover)] hover:text-[var(--msg-assistant-text)]',
+ 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring-soft)]',
+ 'disabled:cursor-default disabled:opacity-40 disabled:hover:bg-transparent disabled:hover:text-[var(--cmd-palette-item-meta)]',
+ )}
+ >
+ <X size={13} strokeWidth={2} />
+ </button>
+ </span>
+ </Tip>
</div>
</div>
)}
@@ -4286,28 +4336,48 @@ function RailPanels({
/** 面板头部的新建按钮(展开态段头 SquarePen 同款配色);创建动作导航去
* 新建页,面板随之收起。disabled = 远程写保护(与展开态 ProjectAction
* 同语义置灰,不收面板不丢上下文,codex review)。 */
- const panelHeadCreateButton = (label: string, onCreate: () => void, disabled = false) => (
- <button
- type="button"
- aria-label={label}
- title={label}
- disabled={disabled}
- onClick={() => {
- railPanelStore.closeAll();
- onCreate();
- }}
- className={cn(
- 'flex h-6 w-6 shrink-0 items-center justify-center self-center rounded-md -my-1',
- 'text-[var(--text-tertiary)] transition-colors hover:text-[var(--text-secondary)]',
- // globals.css 移除了 Chromium 默认 outline,键盘可达按钮必须自带
- // token 化 focus 环(DESIGN.md §10;codex review)。
- 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]',
- 'disabled:opacity-40 disabled:hover:text-[var(--text-tertiary)]',
- )}
- >
- <SquarePen size={14} strokeWidth={2} />
- </button>
- );
+ const panelHeadCreateButton = (
+ actionLabel: string,
+ onCreate: () => void,
+ disabled = false,
+ disabledReason?: string,
+ ) => {
+ const label =
+ disabled && disabledReason ? `${actionLabel} — ${disabledReason}` : actionLabel;
+
+ return (
+ <Tip text={label} side="bottom">
+ <span
+ role={disabled ? 'button' : undefined}
+ aria-disabled={disabled ? true : undefined}
+ aria-label={disabled ? label : undefined}
+ tabIndex={disabled ? 0 : undefined}
+ className="inline-flex self-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]"
+ >
+ <button
+ type="button"
+ aria-label={actionLabel}
+ aria-hidden={disabled ? true : undefined}
+ disabled={disabled}
+ onClick={() => {
+ railPanelStore.closeAll();
+ onCreate();
+ }}
+ className={cn(
+ 'flex h-6 w-6 shrink-0 items-center justify-center rounded-md -my-1',
+ 'text-[var(--text-tertiary)] transition-colors hover:text-[var(--text-secondary)]',
+ // globals.css 移除了 Chromium 默认 outline,键盘可达按钮必须自带
+ // token 化 focus 环(DESIGN.md §10;codex review)。
+ 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]',
+ 'disabled:opacity-40 disabled:hover:text-[var(--text-tertiary)]',
+ )}
+ >
+ <SquarePen size={14} strokeWidth={2} />
+ </button>
+ </span>
+ </Tip>
+ );
+ };
if (!panelState.openSection || !panelState.anchor) return null;
@@ -4334,6 +4404,7 @@ function RailPanels({
t('ccAgent.sidebar.newDialogue'),
onCreateDialogue,
isCreateDialogueDisabled,
+ t('ccAgent.sidebar.creationInProgress'),
),
)}
<div className="max-h-[420px] overflow-y-auto [scrollbar-width:thin]">
@@ -4476,11 +4547,10 @@ function RailPanels({
projectDisplayLabelWithMachine(openProject),
openProject.sessions.length,
panelHeadCreateButton(
- isDeviceLinkWriteBlocked(openProject)
- ? t('ccAgent.remoteSession.actionsUnavailable')
- : t('ccAgent.sidebar.projectAction.newInDirectory'),
+ t('ccAgent.sidebar.projectAction.newInDirectory'),
() => onCreateInProject(openProject),
isDeviceLinkWriteBlocked(openProject),
+ t('ccAgent.remoteSession.actionsUnavailable'),
),
)}
<div className="max-h-[420px] overflow-y-auto [scrollbar-width:thin]">
diff --git a/apps/desktop/src/renderer/features/cc-agent/SessionContentHeader.tsx b/apps/desktop/src/renderer/features/cc-agent/SessionContentHeader.tsx
index 7b4c4e6e8a..e778c347a1 100644
--- a/apps/desktop/src/renderer/features/cc-agent/SessionContentHeader.tsx
+++ b/apps/desktop/src/renderer/features/cc-agent/SessionContentHeader.tsx
@@ -643,18 +643,20 @@ export function SessionContentHeader({
}}
>
<DropdownMenuTrigger asChild>
- <button
- className={cn(
- 'flex h-7 w-7 shrink-0 items-center justify-center rounded-md',
- 'text-[var(--cmd-palette-item-meta)] transition-colors',
- 'hover:bg-titlebar-button-hover hover:text-foreground',
- 'focus-visible:outline-none data-[state=open]:bg-titlebar-button-hover',
- )}
- aria-label={t('ccAgent.sessionHeader.moreActions')}
- style={WINDOW_NO_DRAG_STYLE}
- >
- <Ellipsis size={15} />
- </button>
+ <Tip text={t('ccAgent.sessionHeader.moreActions')} side="bottom">
+ <button
+ className={cn(
+ 'flex h-7 w-7 shrink-0 items-center justify-center rounded-md',
+ 'text-[var(--cmd-palette-item-meta)] transition-colors',
+ 'hover:bg-titlebar-button-hover hover:text-foreground',
+ 'focus-visible:outline-none data-[state=open]:bg-titlebar-button-hover',
+ )}
+ aria-label={t('ccAgent.sessionHeader.moreActions')}
+ style={WINDOW_NO_DRAG_STYLE}
+ >
+ <Ellipsis size={15} />
+ </button>
+ </Tip>
</DropdownMenuTrigger>
<DropdownMenuContent
align="start"
diff --git a/apps/desktop/src/renderer/features/cc-agent/sidebar/AutomationSessionGroupItem.tsx b/apps/desktop/src/renderer/features/cc-agent/sidebar/AutomationSessionGroupItem.tsx
index 3f8aa27b46..bfda29f930 100644
--- a/apps/desktop/src/renderer/features/cc-agent/sidebar/AutomationSessionGroupItem.tsx
+++ b/apps/desktop/src/renderer/features/cc-agent/sidebar/AutomationSessionGroupItem.tsx
@@ -74,6 +74,14 @@ interface FrozenGroupState {
visibleSessionIds: string[];
}
+const AUTOMATION_GROUP_INLINE_ACTION_SELECTOR = '[data-automation-group-inline-action="true"]';
+
+function isAutomationGroupInlineAction(target: EventTarget | null): boolean {
+ return (
+ target instanceof Element && target.closest(AUTOMATION_GROUP_INLINE_ACTION_SELECTOR) !== null
+ );
+}
+
export function AutomationSessionGroupItem({
group,
activeSessionId,
@@ -114,6 +122,7 @@ export function AutomationSessionGroupItem({
const [showAll, setShowAll] = useState(false);
const [frozen, setFrozen] = useState<FrozenGroupState | null>(null);
const [menuOpen, setMenuOpen] = useState(false);
+ const [rowTooltipOpen, setRowTooltipOpen] = useState(false);
const [countdownNowMs, setCountdownNowMs] = useState(() => Date.now());
// 组头 = 组内「最新一条」运行的代理:状态、running/loading、点击打开目标都跟这条一致。
// 用 group.sessions 派生(仅活动时间排序,不掺 running/notifications),引用随组内成员
@@ -292,6 +301,13 @@ export function AutomationSessionGroupItem({
group.sessions.length > 0
? t('ccAgent.sidebar.automationGroup.runCount', { count: group.sessions.length })
: '';
+ const scheduleBindingLabel = t('ccAgent.sidebar.scheduleBinding.viewTask');
+ const toggleGroupLabel = t(
+ collapsed
+ ? 'ccAgent.sidebar.automationGroup.expand'
+ : 'ccAgent.sidebar.automationGroup.collapse',
+ { title: group.title },
+ );
const rowTooltip = useMemo(
() =>
countdownText || stoppedText || runCountText ? (
@@ -318,11 +334,13 @@ export function AutomationSessionGroupItem({
<div className="flex w-full flex-col gap-0.5">
{/* 行 hover 浮层视觉与 SessionTooltip(PR 引用)对齐:右侧 align=start 弹出、
浅色 surface(--surface-elevated + --border-default + shadow-sm)、立即出现,
- 和侧栏其它 hover 卡片在同一套调色板下(规则 16)。 */}
+ 和侧栏其它 hover 卡片在同一套调色板下(规则 16)。行内动作有自己的 Tip,
+ 进入这些按钮时由受控 open 关闭行级浮层,避免两层提示重叠。 */}
<Tip
text={rowTooltip}
side="right"
delay={0}
+ controlledOpen={rowTooltipOpen}
contentClassName={cn(
'bg-[var(--surface-elevated)] text-[var(--text-primary)]',
'border-[var(--border-default)] dark:border-[var(--border-default)] shadow-sm',
@@ -334,6 +352,21 @@ export function AutomationSessionGroupItem({
标题 <button>(Tab focus + Enter/Space)天然提供。 */}
<div
onClick={openLatestSession}
+ onPointerOver={(event) => {
+ setRowTooltipOpen(!isAutomationGroupInlineAction(event.target));
+ }}
+ onPointerLeave={() => setRowTooltipOpen(false)}
+ onFocusCapture={(event) => {
+ setRowTooltipOpen(!isAutomationGroupInlineAction(event.target));
+ }}
+ onBlurCapture={(event) => {
+ const nextTarget = event.relatedTarget;
+ setRowTooltipOpen(
+ nextTarget instanceof Node &&
+ event.currentTarget.contains(nextTarget) &&
+ !isAutomationGroupInlineAction(nextTarget),
+ );
+ }}
className={cn(
// list 组头与普通 SessionCard 共用 10px 内容边距;只有展开后的子任务
// 由下方 pl-3 容器额外缩进。text 模式继续沿用 SessionItem 的树形缩进。
@@ -346,15 +379,7 @@ export function AutomationSessionGroupItem({
latestSession && 'cursor-pointer',
)}
>
- <button
- type="button"
- onClick={(event) => {
- event.stopPropagation();
- openLatestSession();
- }}
- disabled={!latestSession}
- className="flex min-w-0 items-center gap-1.5 text-left disabled:cursor-default"
- >
+ <span className="flex min-w-0 items-center gap-1.5">
{/* list 复用 SessionCard 的 12px 状态槽,text 复用 SessionItem 的 15px 槽;
这样首图标和标题都能落在各自模式的普通任务列上。分组 agentKind 取
最新一条 run(同一 schedule 所有 run 走同一 agent),缺失时退化为
@@ -375,24 +400,23 @@ export function AutomationSessionGroupItem({
/>
</span>
{/* text 延续 vendor → Timer → 标题;list 把 Timer 排到标题右侧,避免它
- 被误读成一层缩进,同时保留自动任务身份和点击入口。 */}
- <span className="flex min-w-0 items-center gap-1.5">
- {/* Timer 点击跳自动化页对应条目。宿主已是 title <button>,不能嵌套
- button,用 span role="button" + stopPropagation 拦下行点击。 */}
- <span
- role="button"
- tabIndex={-1}
- aria-label={t('ccAgent.sidebar.scheduleBinding.viewTask')}
- title={t('ccAgent.sidebar.scheduleBinding.viewTask')}
- onClick={(e) => {
- e.stopPropagation();
+ 被误读成一层缩进,同时保留自动任务身份和点击入口。Timer 与标题是
+ 同级按钮,避免 role=button 嵌进 title button 后无法进入 Tab 顺序。 */}
+ <Tip text={scheduleBindingLabel} side="bottom">
+ <button
+ type="button"
+ data-automation-group-inline-action="true"
+ aria-label={scheduleBindingLabel}
+ onClick={(event) => {
+ event.stopPropagation();
navigate(
group.scheduleId ? scheduleFocusPath(group.scheduleId) : '/cc-agent/scheduled',
);
}}
- onPointerDown={(e) => e.stopPropagation()}
+ onPointerDown={(event) => event.stopPropagation()}
className={cn(
'relative inline-flex size-3 shrink-0 cursor-pointer items-center justify-center',
+ 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]',
sessionVariant === 'list' && 'order-2',
)}
>
@@ -403,240 +427,253 @@ export function AutomationSessionGroupItem({
activeForeground={hasActiveHidden}
running={isRunning}
/>
- </span>
+ </button>
+ </Tip>
+ <button
+ type="button"
+ onClick={(event) => {
+ event.stopPropagation();
+ openLatestSession();
+ }}
+ disabled={!latestSession}
+ className="min-w-0 truncate text-left disabled:cursor-default"
+ >
<span className="min-w-0 truncate">{group.title}</span>
- </span>
- </button>
+ </button>
+ </span>
{/* 展开箭头挪到标题后,视觉上属于「标题右侧的次要控件」,和右侧 meta/操作
槽用 ml-auto 分开;shrink-0 保证长标题挤压时不会先把 chevron 挤没。 */}
- <button
- type="button"
- onClick={(event) => {
- // 阻止冒泡到行级 onClick(否则一次点击既切展开又打开会话)。
- event.stopPropagation();
- setFrozen(null);
- // 收起文件夹时顺手复位轴 2,下次展开从「前 5 条」开始,而不是停在「显示全部」。
- if (!collapsed) setShowAll(false);
- toggleCollapsed();
- }}
- aria-expanded={!collapsed}
- aria-label={t('ccAgent.sidebar.automationGroup.aria', {
- title: group.title,
- count: group.sessions.length,
- attention: attentionCount,
- })}
- className={cn(
- 'flex size-5 shrink-0 items-center justify-center rounded-md',
- hasActiveHidden
- ? 'hover:bg-[color-mix(in_srgb,var(--sidebar-item-active-foreground)_14%,transparent)]'
- : 'hover:bg-sidebar-item-hover',
- )}
- >
- <ToggleIcon
- size={12}
- strokeWidth={2}
- className={
+ <Tip text={toggleGroupLabel} side="bottom">
+ <button
+ type="button"
+ data-automation-group-inline-action="true"
+ onClick={(event) => {
+ // 阻止冒泡到行级 onClick(否则一次点击既切展开又打开会话)。
+ event.stopPropagation();
+ setFrozen(null);
+ // 收起文件夹时顺手复位轴 2,下次展开从「前 5 条」开始,而不是停在「显示全部」。
+ if (!collapsed) setShowAll(false);
+ toggleCollapsed();
+ }}
+ aria-expanded={!collapsed}
+ aria-label={toggleGroupLabel}
+ className={cn(
+ 'flex size-5 shrink-0 items-center justify-center rounded-md',
hasActiveHidden
- ? 'text-[var(--sidebar-item-active-foreground)]'
- : 'text-[var(--cmd-palette-item-meta)]'
- }
- />
- </button>
+ ? 'hover:bg-[color-mix(in_srgb,var(--sidebar-item-active-foreground)_14%,transparent)]'
+ : 'hover:bg-sidebar-item-hover',
+ )}
+ >
+ <ToggleIcon
+ size={12}
+ strokeWidth={2}
+ className={
+ hasActiveHidden
+ ? 'text-[var(--sidebar-item-active-foreground)]'
+ : 'text-[var(--cmd-palette-item-meta)]'
+ }
+ />
+ </button>
+ </Tip>
{/* focus 隐藏条件用命名 group(/slot) 收窄到本槽位:行内 toggle/title
button 点击后焦点常驻行内,整行 group-focus-within 会让选中态
(非 hover)的 meta 文本被永久隐藏,与 SessionItem 同款修法。 */}
<div className="group/slot relative ml-auto flex h-6 max-w-[96px] shrink-0 items-center justify-end">
<div className="grid h-6 max-w-[96px] grid-cols-[max-content] items-center justify-items-end">
- {/* 右侧状态槽 —— 与 SessionItem 同款五档色表 / 图标尺寸(size-4 wrapper +
+ {/* 右侧状态槽 —— 与 SessionItem 同款五档色表 / 图标尺寸(size-4 wrapper +
size-2 dot / size-12 spinner),让分组头和普通任务行状态语义视觉可比。
showRightStatus=true 时渲染状态图标(error/awaiting/done 圆点 + running
spinner),false 时回落到 meta 相对时间文字。scheduleId 存在时统一 hover
fade 出让位给 [Run][More] 按钮组。 */}
- <div
- className={cn(
- // 字体 / 色号与普通任务行的信息槽(SessionInfoMeta)完全同款——含
- // tabular-nums(C 期给普通行加的等宽数字,分组头当时漏跟),
- // 让「9 分钟 / 4 小时」这类时间在两种行里对齐、粗细一致
- // (2026-08-12 用户裁决)。
- 'col-start-1 row-start-1 flex items-center gap-1 text-xs font-medium tabular-nums',
- hasActiveHidden
- ? 'text-[var(--sidebar-item-active-foreground)]'
- : 'text-sidebar-action-icon',
- scheduleId &&
- !menuOpen &&
- 'group-hover:opacity-0 group-focus-within/slot:opacity-0',
- menuOpen && 'opacity-0',
- )}
- >
- {showRightStatus ? (
- groupRightStatusKind === 'error' ? (
- <span
- role="img"
- className="inline-flex size-4 items-center justify-center"
- aria-label={t('ccAgent.sidebar.status.error', 'Failed — click to view')}
- title={t('ccAgent.sidebar.status.error', 'Failed — click to view')}
- >
+ <div
+ className={cn(
+ // 字体 / 色号与普通任务行的信息槽(SessionInfoMeta)完全同款——含
+ // tabular-nums(C 期给普通行加的等宽数字,分组头当时漏跟),
+ // 让「9 分钟 / 4 小时」这类时间在两种行里对齐、粗细一致
+ // (2026-08-12 用户裁决)。
+ 'col-start-1 row-start-1 flex items-center gap-1 text-xs font-medium tabular-nums',
+ hasActiveHidden
+ ? 'text-[var(--sidebar-item-active-foreground)]'
+ : 'text-sidebar-action-icon',
+ scheduleId &&
+ !menuOpen &&
+ 'group-hover:opacity-0 group-focus-within/slot:opacity-0',
+ menuOpen && 'opacity-0',
+ )}
+ >
+ {showRightStatus ? (
+ groupRightStatusKind === 'error' ? (
<span
- className="size-2 rounded-full"
- style={{
- backgroundColor: hasActiveHidden
- ? 'var(--sidebar-item-active-foreground)'
- : 'var(--card-status-error)',
- }}
- aria-hidden
- />
- </span>
- ) : groupRightStatusKind === 'awaiting' ? (
- <span
- role="img"
- className="inline-flex size-4 items-center justify-center"
- aria-label={t('ccAgent.sidebar.status.needsAttention', 'Awaiting your input')}
- title={t('ccAgent.sidebar.status.needsAttention', 'Awaiting your input')}
- >
+ role="img"
+ className="inline-flex size-4 items-center justify-center"
+ aria-label={t('ccAgent.sidebar.status.error', 'Failed — click to view')}
+ title={t('ccAgent.sidebar.status.error', 'Failed — click to view')}
+ >
+ <span
+ className="size-2 rounded-full"
+ style={{
+ backgroundColor: hasActiveHidden
+ ? 'var(--sidebar-item-active-foreground)'
+ : 'var(--card-status-error)',
+ }}
+ aria-hidden
+ />
+ </span>
+ ) : groupRightStatusKind === 'awaiting' ? (
<span
- className="size-2 rounded-full"
- style={{
- backgroundColor: hasActiveHidden
- ? 'var(--sidebar-item-active-foreground)'
- : 'var(--card-status-awaiting)',
- }}
- aria-hidden
+ role="img"
+ className="inline-flex size-4 items-center justify-center"
+ aria-label={t('ccAgent.sidebar.status.needsAttention', 'Awaiting your input')}
+ title={t('ccAgent.sidebar.status.needsAttention', 'Awaiting your input')}
+ >
+ <span
+ className="size-2 rounded-full"
+ style={{
+ backgroundColor: hasActiveHidden
+ ? 'var(--sidebar-item-active-foreground)'
+ : 'var(--card-status-awaiting)',
+ }}
+ aria-hidden
+ />
+ </span>
+ ) : groupRightStatusKind === 'running' ? (
+ <Spinner
+ role="img"
+ size={12}
+ strokeWidth={2}
+ className={cn(
+ 'size-4',
+ hasActiveHidden
+ ? 'text-sidebar-item-active-foreground'
+ : 'text-sidebar-action-icon',
+ )}
+ aria-label={t('ccAgent.sidebar.status.running', 'Running')}
+ title={t('ccAgent.sidebar.status.running', 'Running')}
/>
- </span>
- ) : groupRightStatusKind === 'running' ? (
- <Spinner
- role="img"
- size={12}
- strokeWidth={2}
+ ) : (
+ <span
+ role="img"
+ className="inline-flex size-4 items-center justify-center"
+ aria-label={t('ccAgent.sidebar.status.done', 'Completed — click to view')}
+ title={t('ccAgent.sidebar.status.done', 'Completed — click to view')}
+ >
+ <span
+ className="size-2 rounded-full"
+ style={{
+ backgroundColor: hasActiveHidden
+ ? 'var(--sidebar-item-active-foreground)'
+ : 'var(--card-status-done)',
+ }}
+ aria-hidden
+ />
+ </span>
+ )
+ ) : (
+ <span className="min-w-0 truncate text-right">{meta}</span>
+ )}
+ </div>
+ {scheduleId && (
+ <>
+ <div
+ aria-hidden
className={cn(
- 'size-4',
- hasActiveHidden
- ? 'text-sidebar-item-active-foreground'
- : 'text-sidebar-action-icon',
+ 'invisible col-start-1 row-start-1 h-6 w-[42px]',
+ !menuOpen && 'hidden group-hover:block group-focus-within/slot:block',
)}
- aria-label={t('ccAgent.sidebar.status.running', 'Running')}
- title={t('ccAgent.sidebar.status.running', 'Running')}
/>
- ) : (
- <span
- role="img"
- className="inline-flex size-4 items-center justify-center"
- aria-label={t('ccAgent.sidebar.status.done', 'Completed — click to view')}
- title={t('ccAgent.sidebar.status.done', 'Completed — click to view')}
- >
- <span
- className="size-2 rounded-full"
- style={{
- backgroundColor: hasActiveHidden
- ? 'var(--sidebar-item-active-foreground)'
- : 'var(--card-status-done)',
- }}
- aria-hidden
- />
- </span>
- )
- ) : (
- <span className="min-w-0 truncate text-right">{meta}</span>
- )}
- </div>
- {scheduleId && (
- <>
- <div
- aria-hidden
- className={cn(
- 'invisible col-start-1 row-start-1 h-6 w-[42px]',
- !menuOpen && 'hidden group-hover:block group-focus-within/slot:block',
- )}
- />
- <div
- className={cn(
- 'absolute right-0 top-0 flex h-6 items-center gap-0.5',
- 'opacity-0 transition-opacity',
- menuOpen
- ? 'opacity-100'
- : 'group-hover:opacity-100 group-focus-within/slot:opacity-100',
- )}
- >
- {/* 高频 Run 继续直点;Edit/Pause/Resume/Delete 收进 More 菜单,避免 Edit
- 和左侧 Timer chip 形成重复入口,同时保留原来菜单里的低频操作空间。 */}
- <Tip text={t('ccAgent.sidebar.automationGroup.menu.runNow')} side="bottom">
- <button
- type="button"
- onClick={(event) => {
- event.stopPropagation();
- // 点击后主动 blur:group/slot 的 focus-within 会让操作按钮
- // 常驻可见 + meta 常隐,鼠标移开也不恢复;显式失焦让 hover 语义
- // 重新接管。
- event.currentTarget.blur();
- onScheduleAction(group, 'run');
- }}
- aria-label={t('ccAgent.sidebar.automationGroup.menu.runNow')}
+ <div
className={cn(
- 'flex size-5 shrink-0 items-center justify-center rounded-md',
- 'transition-colors',
- actionButtonToneClassName,
+ 'absolute right-0 top-0 flex h-6 items-center gap-0.5',
+ 'opacity-0 transition-opacity',
+ menuOpen
+ ? 'opacity-100'
+ : 'group-hover:opacity-100 group-focus-within/slot:opacity-100',
)}
>
- <Play size={14} strokeWidth={2} />
- </button>
- </Tip>
- <DropdownMenu open={menuOpen} onOpenChange={setMenuOpen}>
- <DropdownMenuTrigger asChild>
- <button
- type="button"
- onClick={(event) => {
- event.stopPropagation();
- event.currentTarget.blur();
- }}
- onPointerDown={(event) => event.stopPropagation()}
- aria-label={t('ccAgent.sidebar.automationGroup.menu.more')}
- className={cn(
- 'flex size-5 shrink-0 items-center justify-center rounded-md',
- 'transition-colors',
- actionButtonToneClassName,
- )}
- >
- <EllipsisVertical size={14} strokeWidth={2} />
- </button>
- </DropdownMenuTrigger>
- <DropdownMenuContent
- align="end"
- sideOffset={2}
- onClick={(event) => event.stopPropagation()}
- className={cn(MENU_CONTENT_CLASS, 'min-w-36 overflow-hidden')}
- >
- <DropdownMenuItem
- onSelect={() => onScheduleAction(group, 'edit')}
- className={MENU_ITEM_CLASS}
- >
- {t('ccAgent.sidebar.automationGroup.menu.edit')}
- </DropdownMenuItem>
- {group.scheduleStatus !== 'expired' && (
- <DropdownMenuItem
- onSelect={() => onScheduleAction(group, 'toggle-pause')}
- className={MENU_ITEM_CLASS}
+ {/* 高频 Run 继续直点;Edit/Pause/Resume/Delete 收进 More 菜单,避免 Edit
+ 和左侧 Timer chip 形成重复入口,同时保留原来菜单里的低频操作空间。 */}
+ <Tip text={t('ccAgent.sidebar.automationGroup.menu.runNow')} side="bottom">
+ <button
+ type="button"
+ data-automation-group-inline-action="true"
+ onClick={(event) => {
+ event.stopPropagation();
+ // 点击后主动 blur:group/slot 的 focus-within 会让操作按钮
+ // 常驻可见 + meta 常隐,鼠标移开也不恢复;显式失焦让 hover 语义
+ // 重新接管。
+ event.currentTarget.blur();
+ onScheduleAction(group, 'run');
+ }}
+ aria-label={t('ccAgent.sidebar.automationGroup.menu.runNow')}
+ className={cn(
+ 'flex size-5 shrink-0 items-center justify-center rounded-md',
+ 'transition-colors',
+ actionButtonToneClassName,
+ )}
>
- {group.scheduleStatus === 'paused'
- ? t('ccAgent.sidebar.automationGroup.menu.resume')
- : t('ccAgent.sidebar.automationGroup.menu.pause')}
- </DropdownMenuItem>
- )}
- <DropdownMenuSeparator className={MENU_SEPARATOR_CLASS} />
- <DropdownMenuItem
- onSelect={() => onScheduleAction(group, 'delete')}
- disabled={
- group.scheduleSource === 'project' &&
- (!group.workingDir || !group.projectConfigId)
- }
- className={cn(MENU_ITEM_CLASS, 'text-[hsl(var(--destructive))]')}
- >
- {t('ccAgent.sidebar.automationGroup.menu.delete')}
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
- </div>
- </>
- )}
+ <Play size={14} strokeWidth={2} />
+ </button>
+ </Tip>
+ <DropdownMenu open={menuOpen} onOpenChange={setMenuOpen}>
+ <DropdownMenuTrigger asChild>
+ <Tip text={t('ccAgent.sidebar.automationGroup.menu.more')} side="bottom">
+ <button
+ type="button"
+ data-automation-group-inline-action="true"
+ onClick={(event) => {
+ event.stopPropagation();
+ event.currentTarget.blur();
+ }}
+ onPointerDown={(event) => event.stopPropagation()}
+ aria-label={t('ccAgent.sidebar.automationGroup.menu.more')}
+ className={cn(
+ 'flex size-5 shrink-0 items-center justify-center rounded-md',
+ 'transition-colors',
+ actionButtonToneClassName,
+ )}
+ >
+ <EllipsisVertical size={14} strokeWidth={2} />
+ </button>
+ </Tip>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent
+ align="end"
+ sideOffset={2}
+ onClick={(event) => event.stopPropagation()}
+ className={cn(MENU_CONTENT_CLASS, 'min-w-36 overflow-hidden')}
+ >
+ <DropdownMenuItem
+ onSelect={() => onScheduleAction(group, 'edit')}
+ className={MENU_ITEM_CLASS}
+ >
+ {t('ccAgent.sidebar.automationGroup.menu.edit')}
+ </DropdownMenuItem>
+ {group.scheduleStatus !== 'expired' && (
+ <DropdownMenuItem
+ onSelect={() => onScheduleAction(group, 'toggle-pause')}
+ className={MENU_ITEM_CLASS}
+ >
+ {group.scheduleStatus === 'paused'
+ ? t('ccAgent.sidebar.automationGroup.menu.resume')
+ : t('ccAgent.sidebar.automationGroup.menu.pause')}
+ </DropdownMenuItem>
+ )}
+ <DropdownMenuSeparator className={MENU_SEPARATOR_CLASS} />
+ <DropdownMenuItem
+ onSelect={() => onScheduleAction(group, 'delete')}
+ disabled={
+ group.scheduleSource === 'project' &&
+ (!group.workingDir || !group.projectConfigId)
+ }
+ className={cn(MENU_ITEM_CLASS, 'text-[hsl(var(--destructive))]')}
+ >
+ {t('ccAgent.sidebar.automationGroup.menu.delete')}
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </div>
+ </>
+ )}
</div>
</div>
</div>
@@ -676,11 +713,7 @@ export function AutomationSessionGroupItem({
hideBottomDivider={nextHighlighted}
/>
) : (
- <SessionItem
- key={session.id}
- {...commonProps}
- insideAutomationGroup
- />
+ <SessionItem key={session.id} {...commonProps} insideAutomationGroup />
);
})}
{!showAll && childView.isOverflowing && (
diff --git a/apps/desktop/src/renderer/features/cc-agent/sidebar/ConversationSearchBox.tsx b/apps/desktop/src/renderer/features/cc-agent/sidebar/ConversationSearchBox.tsx
index 9b5278b68c..2f2a2d5701 100644
--- a/apps/desktop/src/renderer/features/cc-agent/sidebar/ConversationSearchBox.tsx
+++ b/apps/desktop/src/renderer/features/cc-agent/sidebar/ConversationSearchBox.tsx
@@ -607,18 +607,19 @@ export function ConversationSearchBox({
return (
<Popover open={open} onOpenChange={handleOpenChange}>
<PopoverTrigger asChild>
- <button
- type="button"
- onClick={search.clearLock}
- className={cn(
- triggerClassName ??
- 'flex h-9 w-9 shrink-0 items-center justify-center rounded-full text-foreground transition-colors hover:bg-sidebar-item-hover',
- )}
- aria-label={t('ccAgent.search.open')}
- title={t('ccAgent.search.open')}
- >
- <Search size={18} className="shrink-0" />
- </button>
+ <Tip text={t('ccAgent.search.open')} side="right">
+ <button
+ type="button"
+ onClick={search.clearLock}
+ className={cn(
+ triggerClassName ??
+ 'flex h-9 w-9 shrink-0 items-center justify-center rounded-full text-foreground transition-colors hover:bg-sidebar-item-hover',
+ )}
+ aria-label={t('ccAgent.search.open')}
+ >
+ <Search size={18} className="shrink-0" />
+ </button>
+ </Tip>
</PopoverTrigger>
<PopoverContent
align="start"
diff --git a/apps/desktop/src/renderer/features/cc-agent/sidebar/RailNav.tsx b/apps/desktop/src/renderer/features/cc-agent/sidebar/RailNav.tsx
index 047db79a58..5352728052 100644
--- a/apps/desktop/src/renderer/features/cc-agent/sidebar/RailNav.tsx
+++ b/apps/desktop/src/renderer/features/cc-agent/sidebar/RailNav.tsx
@@ -30,6 +30,7 @@ import {
import { AttentionDot } from '@/components/sidebar/AttentionDot';
import { SortableList } from '@/components/sidebar/SortableList';
import { useReducedMotion } from '@/hooks/useReducedMotion';
+import { Tip } from '@/components/ui/tooltip';
import { isOrcaWorkerSession, resolveSessionRoute } from '@/lib/orcaSessionIdentity';
import { projectIdentityKeyForSession } from '../lib/projectGrouping';
import { getSessionDisplayTitle } from '../lib/sessionDisplayTitle';
@@ -398,48 +399,53 @@ export function RailNav({
['dialogues', <MessageCircle key="i" size={18} aria-hidden />, dialoguesAgg],
] as const
).map(([key, icon, agg]) => (
- <button
+ <Tip
key={key}
- data-rail-panel-trigger={key}
- aria-label={t(`ccAgent.sidebar.railNav.${key}`)}
- title={t(`ccAgent.sidebar.railNav.${key}`)}
- aria-haspopup="menu"
- aria-expanded={panelState.openSection === key}
- // 同 section 已打开时 hover 不重复 open:重复调用会把键盘打开态
- // (openedViaKeyboard)覆写成 false、并清掉已展开的项目三级,破坏
- // popover 显式关闭契约(copilot review);锚点不变,重开本无意义。
- onMouseEnter={(e) => {
- if (panelState.openSection !== key) {
- openSectionAt(key, e.currentTarget);
- } else {
- // 不重开,但要取消可能在途的收回计时(离开瓷砖 120ms 内折返;
- // copilot review)——全局 pointermove 保活通常已覆盖,这里兜底。
- railPanelStore.cancelClose();
- }
- }}
- onMouseLeave={() => railPanelStore.scheduleClose()}
- // 键盘激活(Enter/Space 的合成 click,detail===0):按 popover 焦点契约
- // 打开——焦点移入面板、hover 收回让位、显式关闭(codex review)。
- onClick={(e) => openSectionAt(key, e.currentTarget, e.detail === 0)}
- className={cn(
- 'relative flex h-9 w-9 shrink-0 items-center justify-center rounded-full transition-colors duration-150',
- panelState.openSection === key
- ? 'bg-[var(--chat-input-chip-bg)] text-[var(--msg-assistant-text)]'
- : 'text-[hsl(var(--titlebar-icon))] hover:bg-sidebar-item-hover',
- )}
+ text={t(`ccAgent.sidebar.railNav.${key}`)}
+ side="right"
+ controlledOpen={panelState.openSection === key ? false : undefined}
>
- <span
+ <button
+ data-rail-panel-trigger={key}
+ aria-label={t(`ccAgent.sidebar.railNav.${key}`)}
+ aria-haspopup="menu"
+ aria-expanded={panelState.openSection === key}
+ // 同 section 已打开时 hover 不重复 open:重复调用会把键盘打开态
+ // (openedViaKeyboard)覆写成 false、并清掉已展开的项目三级,破坏
+ // popover 显式关闭契约(copilot review);锚点不变,重开本无意义。
+ onMouseEnter={(e) => {
+ if (panelState.openSection !== key) {
+ openSectionAt(key, e.currentTarget);
+ } else {
+ // 不重开,但要取消可能在途的收回计时(离开瓷砖 120ms 内折返;
+ // copilot review)——全局 pointermove 保活通常已覆盖,这里兜底。
+ railPanelStore.cancelClose();
+ }
+ }}
+ onMouseLeave={() => railPanelStore.scheduleClose()}
+ // 键盘激活(Enter/Space 的合成 click,detail===0):按 popover 焦点契约
+ // 打开——焦点移入面板、hover 收回让位、显式关闭(codex review)。
+ onClick={(e) => openSectionAt(key, e.currentTarget, e.detail === 0)}
className={cn(
- 'inline-flex',
- agg.running && 'text-[var(--status-bar-accent)] session-status-breathing',
+ 'relative flex h-9 w-9 shrink-0 items-center justify-center rounded-full transition-colors duration-150',
+ panelState.openSection === key
+ ? 'bg-[var(--chat-input-chip-bg)] text-[var(--msg-assistant-text)]'
+ : 'text-[hsl(var(--titlebar-icon))] hover:bg-sidebar-item-hover',
)}
>
- {icon}
- </span>
- {agg.dotTone && (
- <AttentionDot size={6} tone={agg.dotTone} className="absolute right-1.5 top-1.5" />
- )}
- </button>
+ <span
+ className={cn(
+ 'inline-flex',
+ agg.running && 'text-[var(--status-bar-accent)] session-status-breathing',
+ )}
+ >
+ {icon}
+ </span>
+ {agg.dotTone && (
+ <AttentionDot size={6} tone={agg.dotTone} className="absolute right-1.5 top-1.5" />
+ )}
+ </button>
+ </Tip>
))}
{preview && <SessionPreviewCard preview={preview} />}
diff --git a/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionCard.tsx b/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionCard.tsx
index 851dcc5279..ee1745818d 100644
--- a/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionCard.tsx
+++ b/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionCard.tsx
@@ -88,6 +88,7 @@ import {
} from '@/features/scheduler/lib/scheduleSessionBinding';
import { loadScheduleSidebarIndexRuns } from '@/features/scheduler/lib/scheduleSidebarIndexRuns';
import { resolveSidebarRightStatus } from './sidebarRightStatus';
+import { Tip } from '@/components/ui/tooltip';
import { SidebarRightStatusIndicator } from './SidebarRightStatusIndicator';
import { shouldPrefetchSessionOnPointerDown } from './sessionSwitchPrefetch';
import {
@@ -580,17 +581,18 @@ export function SessionCard({
activeForeground={isActive}
/>
) : showAutomationTimer ? (
- <button
- type="button"
- className="inline-flex shrink-0 cursor-pointer items-center justify-center focus:outline-none"
- aria-label={t('ccAgent.sidebar.scheduleBinding.viewTask')}
- title={t('ccAgent.sidebar.automationGenerated')}
- onClick={(e) => void handleAutomationIconClick(e)}
- onKeyDown={(e) => e.stopPropagation()}
- onPointerDown={(e) => e.stopPropagation()}
- >
- <AutomationTimerIcon size={iconSize} activeForeground={isActive} />
- </button>
+ <Tip text={t('ccAgent.sidebar.scheduleBinding.viewTask')}>
+ <button
+ type="button"
+ className="inline-flex shrink-0 cursor-pointer items-center justify-center focus:outline-none"
+ aria-label={t('ccAgent.sidebar.scheduleBinding.viewTask')}
+ onClick={(e) => void handleAutomationIconClick(e)}
+ onKeyDown={(e) => e.stopPropagation()}
+ onPointerDown={(e) => e.stopPropagation()}
+ >
+ <AutomationTimerIcon size={iconSize} activeForeground={isActive} />
+ </button>
+ </Tip>
) : null;
// list 变体标题前缀:状态图标 + 自动化徽章 + 间隔(保持 main 既有行为不变)。
@@ -1362,33 +1364,35 @@ function CardAction({
children: ReactNode;
}) {
return (
- <button
- type="button"
- aria-label={label}
- onClick={(e) => {
- e.stopPropagation();
- onClick(e);
- }}
- onPointerDown={(e) => e.stopPropagation()}
- onDoubleClick={(e) => e.stopPropagation()}
- className={cn(
- variant === 'list'
- ? cn(
- 'shrink-0 size-5 flex items-center justify-center rounded-md',
- 'focus:outline-none',
- isActive
- ? 'text-sidebar-item-active-foreground hover:text-sidebar-item-active-foreground hover:bg-[color-mix(in_srgb,var(--sidebar-item-active-foreground)_14%,transparent)]'
- : 'text-sidebar-action-icon hover:bg-sidebar-item-hover hover:text-foreground',
- )
- : cn(
- 'flex size-6 items-center justify-center rounded-[7px]',
- 'bg-[var(--cmd-palette-bg)] text-[var(--text-tertiary)]',
- 'border border-sidebar-border',
- 'hover:bg-sidebar-item-hover hover:text-foreground focus:outline-none',
- ),
- )}
- >
- {children}
- </button>
+ <Tip text={label}>
+ <button
+ type="button"
+ aria-label={label}
+ onClick={(e) => {
+ e.stopPropagation();
+ onClick(e);
+ }}
+ onPointerDown={(e) => e.stopPropagation()}
+ onDoubleClick={(e) => e.stopPropagation()}
+ className={cn(
+ variant === 'list'
+ ? cn(
+ 'shrink-0 size-5 flex items-center justify-center rounded-md',
+ 'focus:outline-none',
+ isActive
+ ? 'text-sidebar-item-active-foreground hover:text-sidebar-item-active-foreground hover:bg-[color-mix(in_srgb,var(--sidebar-item-active-foreground)_14%,transparent)]'
+ : 'text-sidebar-action-icon hover:bg-sidebar-item-hover hover:text-foreground',
+ )
+ : cn(
+ 'flex size-6 items-center justify-center rounded-[7px]',
+ 'bg-[var(--cmd-palette-bg)] text-[var(--text-tertiary)]',
+ 'border border-sidebar-border',
+ 'hover:bg-sidebar-item-hover hover:text-foreground focus:outline-none',
+ ),
+ )}
+ >
+ {children}
+ </button>
+ </Tip>
);
}
diff --git a/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionItem.tsx b/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionItem.tsx
index 9e98473532..b5098c015f 100644
--- a/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionItem.tsx
+++ b/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionItem.tsx
@@ -88,6 +88,7 @@ import type { FolderPickerOption } from '@/components/new-chat/FolderPickerPopov
import { RemoteProjectIcon } from './RemoteProjectIcon';
import { SessionShareExportDialog } from './SessionShareExportDialog';
import { isRemoteSessionWriteBlocked } from '../lib/remoteSessionWriteGuard';
+import { Tip } from '@/components/ui/tooltip';
import { prefetchDirtyWorktreeForRemoval } from '@/lib/worktreeRemovalWarning';
import { useSessionAttentionKind } from '@/lib/sessionAttentionStore';
import { useSessionAttentionUrgency } from '../contexts/SessionAttentionUrgencyContext';
@@ -120,6 +121,14 @@ function loadScheduleSidebarIndexRunsCached(): Promise<ScheduleSidebarIndexRun[]
return _scheduleIndexPromise;
}
+const SESSION_ROW_INTERACTIVE_SELECTOR = 'button, a, input, select, textarea, [role="button"]';
+
+function isNestedSessionRowAction(target: EventTarget | null, row: Element): boolean {
+ if (!(target instanceof Element)) return false;
+ const interactive = target.closest(SESSION_ROW_INTERACTIVE_SELECTOR);
+ return interactive !== null && interactive !== row;
+}
+
const log = createLogger('SessionItem');
interface SidebarTitleMarqueeProps {
@@ -514,6 +523,7 @@ export const SessionItem = memo(function SessionItem({
// 右键菜单弹出位置:null = 关闭;{x,y} = 在该屏幕坐标处弹出(fixed 定位的
// 隐形 trigger 锚定到这里)。与 ProjectNode 同款 coordinate-anchored 模式。
const [menuPos, setMenuPos] = useState<{ x: number; y: number } | null>(null);
+ const [rowTooltipOpen, setRowTooltipOpen] = useState(false);
// Codex 风行内 archive 确认:archivePending=true 时右侧图标按钮被一个红色
// "Confirm" 胶囊替换;4s 不动 or 点别处 → 自动撤回。第二次点击 Confirm 才真正
@@ -886,6 +896,10 @@ export const SessionItem = memo(function SessionItem({
draggable={splitDragEnabled && (dragContainerState.nativeSortable || !needsSplitDragHandle)}
role="button"
tabIndex={0}
+ onPointerOver={(event) => {
+ setRowTooltipOpen(!isNestedSessionRowAction(event.target, event.currentTarget));
+ }}
+ onPointerLeave={() => setRowTooltipOpen(false)}
onPointerDownCapture={(event) => {
dragStartTargetRef.current = event.target instanceof Element ? event.target : null;
}}
@@ -1015,19 +1029,20 @@ export const SessionItem = memo(function SessionItem({
{boundSchedules.length > 0 ? (
<ScheduleBindingBadge schedules={boundSchedules} activeForeground={isActive} />
) : isAutomationGenerated ? (
- <button
- type="button"
- className="inline-flex shrink-0 cursor-pointer focus:outline-none"
- aria-label={t('ccAgent.sidebar.scheduleBinding.viewTask')}
- title={t('ccAgent.sidebar.automationGenerated')}
- onClick={(e) => {
- e.stopPropagation();
- void handleAutomationIconClick();
- }}
- onPointerDown={(e) => e.stopPropagation()}
- >
- <AutomationTimerIcon size={10} activeForeground={isActive} />
- </button>
+ <Tip text={t('ccAgent.sidebar.scheduleBinding.viewTask')}>
+ <button
+ type="button"
+ className="inline-flex shrink-0 cursor-pointer focus:outline-none"
+ aria-label={t('ccAgent.sidebar.scheduleBinding.viewTask')}
+ onClick={(e) => {
+ e.stopPropagation();
+ void handleAutomationIconClick();
+ }}
+ onPointerDown={(e) => e.stopPropagation()}
+ >
+ <AutomationTimerIcon size={10} activeForeground={isActive} />
+ </button>
+ </Tip>
) : null}
<SidebarTitleMarquee
title={displayTitle}
@@ -1139,9 +1154,7 @@ export const SessionItem = memo(function SessionItem({
{/* Action 按钮组(hover/menu open 时浮现,archivePending 期间整组让位给红色 pill)。
尺寸/视觉与 Project Header 的 ProjectAction 同套(size-5 / icon 14 /
strokeWidth 2 / gap-0.5);普通行 hover 走 sidebar-item-hover,选中行
- 则用 active foreground 的半透明叠色保持红色胶囊内的反色体系。唯一差异
- 是 session 行的三个按钮**故意不挂 Tip 浮层** —— 图标语义已足够直观,
- tooltip 在密集 sidebar 列表里反而干扰视觉。
+ 则用 active foreground 的半透明叠色保持红色胶囊内的反色体系。
组装顺序固定为 [Run(automation only), More, Archive | Undo]:
- 非 archived:More + Archive;Archive pill 撤回(超时/点外面)后
按钮立即还原,符合用户对 "撤回 = 回到点击前" 的直觉预期。
@@ -1355,6 +1368,7 @@ export const SessionItem = memo(function SessionItem({
sessionId={session.id}
prRefs={prRefs}
isAutomationSession={showAutomationTooltip}
+ controlledOpen={rowTooltipOpen}
>
{row}
</SessionTooltip>
@@ -1364,8 +1378,7 @@ export const SessionItem = memo(function SessionItem({
/** SessionItem 右侧 hover action 图标按钮 —— 尺寸/视觉与 Project Header 的
* ProjectAction 基本一致(size-5 / icon 14×14 / strokeWidth 2 / 圆角 md /
* 普通行 hover 用 sidebar-item-hover + foreground;选中行保持 active foreground,
- * hover 只叠一层同色半透明高光),区别是这里
- * **不挂 Tip 浮层**,图标语义已经够直观,sidebar 密集列表里少干扰为先。 */
+ * hover 只叠一层同色半透明高光)。 */
function SessionAction({
label,
onClick,
@@ -1377,27 +1390,27 @@ function SessionAction({
isActive: boolean;
children: ReactNode;
}) {
- // 这里**故意不挂 Tip 浮层** —— 三个按钮(More/Archive/Undo)的图标语义都足够
- // 直观,加 tooltip 反而让 sidebar 视觉更乱。aria-label 保留给屏幕阅读器。
return (
- <button
- type="button"
- aria-label={label}
- onClick={(e) => {
- e.stopPropagation();
- onClick(e);
- }}
- onPointerDown={(e) => e.stopPropagation()}
- onDoubleClick={(e) => e.stopPropagation()}
- className={cn(
- 'shrink-0 size-5 flex items-center justify-center rounded-md',
- 'focus:outline-none',
- isActive
- ? 'text-sidebar-item-active-foreground hover:text-sidebar-item-active-foreground hover:bg-[color-mix(in_srgb,var(--sidebar-item-active-foreground)_14%,transparent)]'
- : 'text-sidebar-action-icon hover:bg-sidebar-item-hover hover:text-foreground',
- )}
- >
- {children}
- </button>
+ <Tip text={label}>
+ <button
+ type="button"
+ aria-label={label}
+ onClick={(e) => {
+ e.stopPropagation();
+ onClick(e);
+ }}
+ onPointerDown={(e) => e.stopPropagation()}
+ onDoubleClick={(e) => e.stopPropagation()}
+ className={cn(
+ 'shrink-0 size-5 flex items-center justify-center rounded-md',
+ 'focus:outline-none',
+ isActive
+ ? 'text-sidebar-item-active-foreground hover:text-sidebar-item-active-foreground hover:bg-[color-mix(in_srgb,var(--sidebar-item-active-foreground)_14%,transparent)]'
+ : 'text-sidebar-action-icon hover:bg-sidebar-item-hover hover:text-foreground',
+ )}
+ >
+ {children}
+ </button>
+ </Tip>
);
}
diff --git a/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionShareExportDialog.tsx b/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionShareExportDialog.tsx
index 5867e027ef..1bbdb8bbce 100644
--- a/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionShareExportDialog.tsx
+++ b/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionShareExportDialog.tsx
@@ -17,6 +17,7 @@ import { useTranslation } from 'react-i18next';
import { cn } from '@/lib/utils';
import { Spinner } from '@/components/ui/spinner';
+import { Tip } from '@/components/ui/tooltip';
import { toast } from '@/lib/toast';
import { createLogger } from '@/lib/logger';
import { extractIpcError } from '@/utils/ipcError';
@@ -192,14 +193,28 @@ export function SessionShareExportDialog({
color: 'var(--confirm-title)',
}}
/>
- <button
- type="button"
- onClick={() => setShowPass((v) => !v)}
- aria-label={t(showPass ? 'sessionShare.export.hidePassword' : 'sessionShare.export.showPassword')}
- className="absolute right-2 top-1/2 -translate-y-1/2 text-[var(--text-tertiary)] hover:text-[var(--text-primary)]"
+ <Tip
+ text={t(
+ showPass
+ ? 'sessionShare.export.hidePassword'
+ : 'sessionShare.export.showPassword',
+ )}
+ side="bottom"
+ contentClassName="z-[10001]"
>
- {showPass ? <EyeOff size={14} /> : <Eye size={14} />}
- </button>
+ <button
+ type="button"
+ onClick={() => setShowPass((v) => !v)}
+ aria-label={t(
+ showPass
+ ? 'sessionShare.export.hidePassword'
+ : 'sessionShare.export.showPassword',
+ )}
+ className="absolute right-2 top-1/2 -translate-y-1/2 text-[var(--text-tertiary)] hover:text-[var(--text-primary)]"
+ >
+ {showPass ? <EyeOff size={14} /> : <Eye size={14} />}
+ </button>
+ </Tip>
</div>
<input
type={showPass ? 'text' : 'password'}
@@ -215,7 +230,11 @@ export function SessionShareExportDialog({
/>
{(mismatch || tooShort) && (
<p className="text-xs" style={{ color: 'var(--error-fg)' }}>
- {t(mismatch ? 'sessionShare.export.passwordMismatch' : 'sessionShare.export.passwordTooShort')}
+ {t(
+ mismatch
+ ? 'sessionShare.export.passwordMismatch'
+ : 'sessionShare.export.passwordTooShort',
+ )}
</p>
)}
</div>
diff --git a/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionTooltip.tsx b/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionTooltip.tsx
index f571cde4a8..36602ef137 100644
--- a/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionTooltip.tsx
+++ b/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionTooltip.tsx
@@ -49,6 +49,11 @@ export interface SessionTooltipProps {
* 计划信息次之,sourceLabel 只是「来自哪个项目」的静态标签)。
*/
isAutomationSession?: boolean;
+ /**
+ * 受控开关。普通任务行在指针进入内嵌动作时传 false,避免行级详情与动作 Tip 重叠。
+ * 未提供时保持各变体原有的 Radix 非受控行为。
+ */
+ controlledOpen?: boolean;
children: ReactNode;
}
@@ -57,20 +62,29 @@ export function SessionTooltip({
prRefs,
sourceLabel,
isAutomationSession,
+ controlledOpen,
children,
}: SessionTooltipProps) {
if (prRefs.length > 0) {
return (
- <PrTooltip sessionId={sessionId} prRefs={prRefs}>
+ <PrTooltip sessionId={sessionId} prRefs={prRefs} controlledOpen={controlledOpen}>
{children}
</PrTooltip>
);
}
if (isAutomationSession) {
- return <AutomationTooltip sessionId={sessionId}>{children}</AutomationTooltip>;
+ return (
+ <AutomationTooltip sessionId={sessionId} controlledOpen={controlledOpen}>
+ {children}
+ </AutomationTooltip>
+ );
}
if (sourceLabel) {
- return <SourceTooltip sourceLabel={sourceLabel}>{children}</SourceTooltip>;
+ return (
+ <SourceTooltip sourceLabel={sourceLabel} controlledOpen={controlledOpen}>
+ {children}
+ </SourceTooltip>
+ );
}
return <>{children}</>;
}
@@ -78,21 +92,28 @@ export function SessionTooltip({
function PrTooltip({
sessionId,
prRefs,
+ controlledOpen,
children,
}: {
sessionId: string;
prRefs: readonly SessionPrRef[];
+ controlledOpen?: boolean;
children: ReactNode;
}) {
const { statuses, fetchStatusesForSession } = usePrStatuses();
+ useEffect(() => {
+ if (controlledOpen) fetchStatusesForSession(sessionId);
+ }, [controlledOpen, fetchStatusesForSession, sessionId]);
+
return (
// 独立 Provider + delayDuration=0:hover 立即弹出,不吃 sidebar 顶层 Provider
// 的 500ms 默认延迟。skipDelayDuration 也归零,行间移动同样无跳变。
<Tooltip.Provider delayDuration={0} skipDelayDuration={0}>
<Tooltip.Root
+ open={controlledOpen}
onOpenChange={(open) => {
- if (open) fetchStatusesForSession(sessionId);
+ if (open && controlledOpen === undefined) fetchStatusesForSession(sessionId);
}}
>
<Tooltip.Trigger
@@ -130,12 +151,21 @@ function PrTooltip({
* 拉到的 nextFireAt 用一次性 formatSidebarFutureTime 转成 "N 分钟后运行",不做秒级 tick
* (tooltip 通常只停留几秒,静态文案够用)。
*/
-function AutomationTooltip({ sessionId, children }: { sessionId: string; children: ReactNode }) {
+function AutomationTooltip({
+ sessionId,
+ controlledOpen,
+ children,
+}: {
+ sessionId: string;
+ controlledOpen?: boolean;
+ children: ReactNode;
+}) {
const { t } = useTranslation();
const [open, setOpen] = useState(false);
+ const effectiveOpen = controlledOpen ?? open;
const [runs, setRuns] = useState<ScheduleSidebarIndexRun[] | null>(null);
useEffect(() => {
- if (!open || runs !== null) return;
+ if (!effectiveOpen || runs !== null) return;
let cancelled = false;
loadScheduleSidebarIndexRuns()
.then((next) => {
@@ -147,7 +177,7 @@ function AutomationTooltip({ sessionId, children }: { sessionId: string; childre
return () => {
cancelled = true;
};
- }, [open, runs]);
+ }, [effectiveOpen, runs]);
const hit = runs?.find((r) => r.sessionId === sessionId) ?? null;
const countdownText =
@@ -163,7 +193,7 @@ function AutomationTooltip({ sessionId, children }: { sessionId: string; childre
return (
<Tooltip.Provider delayDuration={0} skipDelayDuration={0}>
- <Tooltip.Root onOpenChange={setOpen}>
+ <Tooltip.Root open={controlledOpen} onOpenChange={setOpen}>
<Tooltip.Trigger asChild onFocus={(event) => event.preventDefault()}>
{children}
</Tooltip.Trigger>
@@ -181,11 +211,19 @@ function AutomationTooltip({ sessionId, children }: { sessionId: string; childre
);
}
-function SourceTooltip({ sourceLabel, children }: { sourceLabel: string; children: ReactNode }) {
+function SourceTooltip({
+ sourceLabel,
+ controlledOpen,
+ children,
+}: {
+ sourceLabel: string;
+ controlledOpen?: boolean;
+ children: ReactNode;
+}) {
return (
// 独立 Provider + delayDuration=0:与 PrTooltip 同规,hover 立即弹出。
<Tooltip.Provider delayDuration={0} skipDelayDuration={0}>
- <Tooltip.Root>
+ <Tooltip.Root open={controlledOpen}>
<Tooltip.Trigger asChild onFocus={(event) => event.preventDefault()}>
{children}
</Tooltip.Trigger>
diff --git a/apps/desktop/src/renderer/features/cc-agent/sidebar/__tests__/SessionCard.visual.test.ts b/apps/desktop/src/renderer/features/cc-agent/sidebar/__tests__/SessionCard.visual.test.ts
index 0d02bc6bc3..6393166ed3 100644
--- a/apps/desktop/src/renderer/features/cc-agent/sidebar/__tests__/SessionCard.visual.test.ts
+++ b/apps/desktop/src/renderer/features/cc-agent/sidebar/__tests__/SessionCard.visual.test.ts
@@ -65,6 +65,7 @@ vi.mock('react-i18next', () => ({
}));
vi.mock('@/components/ui/tooltip', () => ({
+ Tip: ({ children }: { children: ReactNode }) => children,
Tooltip: {
Provider: ({ children }: { children: ReactNode }) => children,
Root: ({ children }: { children: ReactNode }) => children,
@@ -421,9 +422,7 @@ describe('SessionCard visual cases', () => {
it('uses the unified Timer for automation cases without a bound schedule', () => {
renderCase('automation-timer');
- expect(screen.getByRole('button', { name: '查看自动化任务' }).getAttribute('title')).toBe(
- '由自动化创建',
- );
+ expect(screen.getByRole('button', { name: '查看自动化任务' }).getAttribute('title')).toBeNull();
expect(
screen.getByRole('button', { name: '查看自动化任务' }).querySelector('.lucide-timer'),
).not.toBeNull();
diff --git a/apps/desktop/src/renderer/features/cc-agent/sidebar/__tests__/sessionCardReviewRegressions.test.ts b/apps/desktop/src/renderer/features/cc-agent/sidebar/__tests__/sessionCardReviewRegressions.test.ts
index 2bd1aec696..eabddebadb 100644
--- a/apps/desktop/src/renderer/features/cc-agent/sidebar/__tests__/sessionCardReviewRegressions.test.ts
+++ b/apps/desktop/src/renderer/features/cc-agent/sidebar/__tests__/sessionCardReviewRegressions.test.ts
@@ -290,9 +290,6 @@ describe('SessionCard review regressions', () => {
'const hasAutomationMeta = boundSchedules.length > 0 || isAutomationGenerated;',
);
expect(sessionItemSource).toContain("!isEditing && hasAutomationMeta ? 'gap-1.5' : 'gap-2.5'");
- expect(automationGroupSource).toContain(
- 'className="flex min-w-0 items-center gap-1.5 text-left disabled:cursor-default"',
- );
expect(automationGroupSource).toContain('className="flex min-w-0 items-center gap-1.5"');
});
diff --git a/apps/desktop/src/renderer/features/cc-agent/sidebar/__tests__/sessionTooltip.test.ts b/apps/desktop/src/renderer/features/cc-agent/sidebar/__tests__/sessionTooltip.test.ts
index 3f9099a64b..88d280d8f1 100644
--- a/apps/desktop/src/renderer/features/cc-agent/sidebar/__tests__/sessionTooltip.test.ts
+++ b/apps/desktop/src/renderer/features/cc-agent/sidebar/__tests__/sessionTooltip.test.ts
@@ -92,6 +92,30 @@ describe('SessionTooltip', () => {
expect(screen.queryByText('XDMaker')).toBeNull();
});
+ it('honors the controlled open state used to suppress row details over inline actions', async () => {
+ const renderTooltip = (controlledOpen: boolean) =>
+ createElement(
+ SessionTooltip,
+ {
+ sessionId: 'session-1',
+ prRefs: [],
+ sourceLabel: 'XDMaker',
+ controlledOpen,
+ } as unknown as ComponentProps<typeof SessionTooltip>,
+ createElement('div', null, 'Session row'),
+ );
+
+ const { rerender } = render(renderTooltip(false));
+ fireEvent.pointerMove(screen.getByText('Session row'), { pointerType: 'mouse' });
+ expect(screen.queryByRole('tooltip')).toBeNull();
+
+ rerender(renderTooltip(true));
+ expect((await screen.findByRole('tooltip')).textContent).toContain('XDMaker');
+
+ rerender(renderTooltip(false));
+ expect(screen.queryByRole('tooltip')).toBeNull();
+ });
+
it('lets a long repository label shrink without pushing the PR status outside the tooltip', async () => {
const longRepoRef = {
...prRef,
diff --git a/apps/desktop/src/renderer/features/cc-agent/sidebar/sections/PinnedSection.tsx b/apps/desktop/src/renderer/features/cc-agent/sidebar/sections/PinnedSection.tsx
index 73814ee14e..7a5d2ff224 100644
--- a/apps/desktop/src/renderer/features/cc-agent/sidebar/sections/PinnedSection.tsx
+++ b/apps/desktop/src/renderer/features/cc-agent/sidebar/sections/PinnedSection.tsx
@@ -342,17 +342,19 @@ export function PinnedSection({
图标 = 当前选中的显示模式(2026-08-12 用户裁决),不再恒为网格。 */}
<div className={cn(HEADER_HOVER_ACTION_CLASS, 'flex items-center gap-0.5')}>
<ViewStyleMenu mode={mode} setMode={setMode}>
- <button
- type="button"
- aria-label={t('ccAgent.sidebar.viewStyle')}
- className={cn(
- 'flex h-5 w-5 shrink-0 items-center justify-center rounded-md',
- 'text-[var(--sidebar-list-muted)]',
- 'transition-colors hover:text-[var(--sidebar-nav-text)]',
- )}
- >
- <ViewStyleTriggerIcon size={13} strokeWidth={2} />
- </button>
+ <Tip text={t('ccAgent.sidebar.viewStyle')} side="bottom">
+ <button
+ type="button"
+ aria-label={t('ccAgent.sidebar.viewStyle')}
+ className={cn(
+ 'flex h-5 w-5 shrink-0 items-center justify-center rounded-md',
+ 'text-[var(--sidebar-list-muted)]',
+ 'transition-colors hover:text-[var(--sidebar-nav-text)]',
+ )}
+ >
+ <ViewStyleTriggerIcon size={13} strokeWidth={2} />
+ </button>
+ </Tip>
</ViewStyleMenu>
</div>
</div>
diff --git a/apps/desktop/src/renderer/features/right-sidebar/TabBar.tsx b/apps/desktop/src/renderer/features/right-sidebar/TabBar.tsx
index 75775be044..27786788ef 100644
--- a/apps/desktop/src/renderer/features/right-sidebar/TabBar.tsx
+++ b/apps/desktop/src/renderer/features/right-sidebar/TabBar.tsx
@@ -42,6 +42,7 @@ import type { TFunction } from 'i18next';
import { useTranslation } from 'react-i18next';
import { ChromeIconButton } from '@/components/title-bar/ChromeIconButton';
import { RightSidebarToggle } from '@/components/layout/RightSidebarToggle';
+import { Tip } from '@/components/ui/tooltip';
import { SortableList } from '@/components/sidebar/SortableList';
import { useReducedMotion } from '@/hooks/useReducedMotion';
import { cn } from '@/lib/utils';
@@ -251,7 +252,6 @@ export function TabBar({
{onDetach && (
<ChromeIconButton
aria-label={t('rightSidebar.tabs.controls.detachAria')}
- title={t('rightSidebar.tabs.controls.detachAria')}
onClick={onDetach}
>
<PictureInPicture2 size={14} />
@@ -436,22 +436,24 @@ export function TabStrip({
className={cn('relative flex shrink-0 items-center', addButtonWrapperClassName)}
style={{ WebkitAppRegion: 'no-drag' } as React.CSSProperties}
>
- <button
- type="button"
- aria-label={t('rightSidebar.tabs.addAria')}
- aria-haspopup="menu"
- aria-expanded={dropdownOpen}
- onClick={() => setDropdownOpen((v) => !v)}
- className={cn(
- 'inline-flex h-6 w-6 items-center justify-center rounded-full transition-colors',
- addButtonClassName,
- dropdownOpen
- ? 'bg-[var(--surface-chip)] text-[var(--text-primary)]'
- : 'text-[var(--titlebar-icon)] hover:bg-[var(--surface-hover)] hover:text-[var(--text-primary)]',
- )}
- >
- <Plus size={13} />
- </button>
+ <Tip text={t('rightSidebar.tabs.addAria')} side="bottom">
+ <button
+ type="button"
+ aria-label={t('rightSidebar.tabs.addAria')}
+ aria-haspopup="menu"
+ aria-expanded={dropdownOpen}
+ onClick={() => setDropdownOpen((v) => !v)}
+ className={cn(
+ 'inline-flex h-6 w-6 items-center justify-center rounded-full transition-colors',
+ addButtonClassName,
+ dropdownOpen
+ ? 'bg-[var(--surface-chip)] text-[var(--text-primary)]'
+ : 'text-[var(--titlebar-icon)] hover:bg-[var(--surface-hover)] hover:text-[var(--text-primary)]',
+ )}
+ >
+ <Plus size={13} />
+ </button>
+ </Tip>
{dropdownOpen && (
<AddTabDropdown
anchorRef={addButtonWrapperRef}
@@ -636,23 +638,25 @@ function TabPill({
)}
</span>
</button>
- <button
- type="button"
- data-no-drag
- onClick={(e) => {
- e.stopPropagation();
- onClose();
- }}
- aria-label={closeAriaLabel}
- className={cn(
- 'inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full text-[var(--text-tertiary)] transition-opacity hover:text-[var(--text-primary)]',
- // chip:close 常驻显形(Chrome 式)——若 hover 才显形,常态下右侧会留出
- // 一块看不见的占位空白,文字视觉上不居中;flush(Win)维持 hover 显形不变。
- pillVariant === 'flush' && 'opacity-0 group-hover:opacity-100',
- )}
- >
- <X size={10} />
- </button>
+ <Tip text={closeAriaLabel}>
+ <button
+ type="button"
+ data-no-drag
+ onClick={(e) => {
+ e.stopPropagation();
+ onClose();
+ }}
+ aria-label={closeAriaLabel}
+ className={cn(
+ 'inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full text-[var(--text-tertiary)] transition-opacity hover:text-[var(--text-primary)]',
+ // chip:close 常驻显形(Chrome 式)——若 hover 才显形,常态下右侧会留出
+ // 一块看不见的占位空白,文字视觉上不居中;flush(Win)维持 hover 显形不变。
+ pillVariant === 'flush' && 'opacity-0 group-hover:opacity-100',
+ )}
+ >
+ <X size={10} />
+ </button>
+ </Tip>
</div>
);
}
diff --git a/apps/desktop/src/renderer/features/right-sidebar/__tests__/RightSidebarShell.test.ts b/apps/desktop/src/renderer/features/right-sidebar/__tests__/RightSidebarShell.test.ts
index 1ad6f523eb..3b5766340d 100644
--- a/apps/desktop/src/renderer/features/right-sidebar/__tests__/RightSidebarShell.test.ts
+++ b/apps/desktop/src/renderer/features/right-sidebar/__tests__/RightSidebarShell.test.ts
@@ -307,17 +307,22 @@ describe('RightSidebarShell empty state', () => {
});
it('mounts only the active body first, then idle-mounts and keeps the rest alive', async () => {
- const idleCallbacks: IdleRequestCallback[] = [];
+ const idleCallbacks: Array<{ id: number; callback: IdleRequestCallback }> = [];
+ let nextIdleCallbackId = 0;
Object.defineProperty(window, 'requestIdleCallback', {
configurable: true,
value: vi.fn((callback: IdleRequestCallback) => {
- idleCallbacks.push(callback);
- return idleCallbacks.length;
+ const id = ++nextIdleCallbackId;
+ idleCallbacks.push({ id, callback });
+ return id;
}),
});
Object.defineProperty(window, 'cancelIdleCallback', {
configurable: true,
- value: vi.fn(),
+ value: vi.fn((id: number) => {
+ const index = idleCallbacks.findIndex((entry) => entry.id === id);
+ if (index >= 0) idleCallbacks.splice(index, 1);
+ }),
});
const mountA = vi.fn();
const unmountA = vi.fn();
@@ -388,7 +393,7 @@ describe('RightSidebarShell empty state', () => {
expect(idleCallbacks).toHaveLength(1);
act(() => {
- idleCallbacks.shift()?.({
+ idleCallbacks.shift()?.callback({
didTimeout: false,
timeRemaining: () => 50,
});
diff --git a/apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/BackgroundTasksBody.tsx b/apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/BackgroundTasksBody.tsx
index afcfac81c5..37495aac69 100644
--- a/apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/BackgroundTasksBody.tsx
+++ b/apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/BackgroundTasksBody.tsx
@@ -50,11 +50,9 @@ import type { LucideIcon } from 'lucide-react';
import { cn } from '@/lib/utils';
import { Spinner } from '@/components/ui/spinner';
+import { Tip } from '@/components/ui/tooltip';
import { isSidebarWindow } from '@/lib/sidebarWindow';
-import {
- getSessionDeviceId,
- useRemoteDevices,
-} from '@/features/device-link/remoteProjectsStore';
+import { getSessionDeviceId, useRemoteDevices } from '@/features/device-link/remoteProjectsStore';
import { makerChatStore, EMPTY_TASK_UPDATES } from '@/lib/makerChatStore';
import type { AgentTaskUpdate, ChatMessage } from '@/lib/makerChatStore';
import {
@@ -232,21 +230,44 @@ function StopButton({ sessionId, taskId }: { sessionId: string; taskId: string }
},
[sessionId, taskId, stopping],
);
- return (
+ const actionLabel = t('rightSidebar.backgroundTasks.stop');
+ const label = stopping
+ ? `${actionLabel} — ${t('rightSidebar.backgroundTasks.stopping')}`
+ : actionLabel;
+ const button = (
<button
type="button"
onClick={handleStop}
disabled={stopping}
- aria-label={t('rightSidebar.backgroundTasks.stop')}
- title={t('rightSidebar.backgroundTasks.stop')}
+ aria-label={actionLabel}
+ aria-hidden={stopping ? true : undefined}
className={cn(
'inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-lg text-[var(--text-secondary)] transition-colors hover:bg-[var(--surface-hover)] hover:text-[var(--text-primary)]',
+ 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]',
stopping && 'cursor-default opacity-50',
)}
>
<Square size={12} aria-hidden="true" />
</button>
);
+
+ return (
+ <Tip text={label} side="bottom">
+ {stopping ? (
+ <span
+ role="button"
+ aria-disabled="true"
+ aria-label={label}
+ tabIndex={0}
+ className="inline-flex rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]"
+ >
+ {button}
+ </span>
+ ) : (
+ button
+ )}
+ </Tip>
+ );
}
// ---------------------------------------------------------------------------
@@ -443,15 +464,16 @@ function WorkflowDetail({
return (
<div className="flex min-h-0 flex-1 flex-col">
<div className="flex shrink-0 items-center gap-1.5 border-b border-[var(--border-default)] px-2 py-1.5">
- <button
- type="button"
- onClick={onBack}
- aria-label={t('rightSidebar.backgroundTasks.back')}
- title={t('rightSidebar.backgroundTasks.back')}
- className="inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-lg text-[var(--text-secondary)] transition-colors hover:bg-[var(--surface-hover)] hover:text-[var(--text-primary)]"
- >
- <ArrowLeft size={14} aria-hidden="true" />
- </button>
+ <Tip text={t('rightSidebar.backgroundTasks.back')} side="bottom">
+ <button
+ type="button"
+ onClick={onBack}
+ aria-label={t('rightSidebar.backgroundTasks.back')}
+ className="inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-lg text-[var(--text-secondary)] transition-colors hover:bg-[var(--surface-hover)] hover:text-[var(--text-primary)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]"
+ >
+ <ArrowLeft size={14} aria-hidden="true" />
+ </button>
+ </Tip>
<span className="inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-[var(--surface-chip)] text-[var(--text-secondary)]">
<Workflow size={12} aria-hidden="true" />
</span>
diff --git a/apps/desktop/src/renderer/features/right-sidebar/plugins/ios-simulator/IOSSimulatorInstanceGrid.tsx b/apps/desktop/src/renderer/features/right-sidebar/plugins/ios-simulator/IOSSimulatorInstanceGrid.tsx
index 106b168519..a6c13631fd 100644
--- a/apps/desktop/src/renderer/features/right-sidebar/plugins/ios-simulator/IOSSimulatorInstanceGrid.tsx
+++ b/apps/desktop/src/renderer/features/right-sidebar/plugins/ios-simulator/IOSSimulatorInstanceGrid.tsx
@@ -14,6 +14,7 @@ import {
Send,
Smartphone,
UnlockKeyhole,
+ type LucideIcon,
} from 'lucide-react';
import { useTranslation } from 'react-i18next';
@@ -27,6 +28,7 @@ import type {
IOSSimulatorSessionStatus,
IOSSimulatorToolResponse,
} from '../../../../../shared/iosSimulatorIpc';
+import { Tip } from '@/components/ui/tooltip';
interface IOSSimulatorInstanceGridProps {
sessionId: string;
@@ -66,6 +68,52 @@ interface TileGesture {
startYRatio: number;
}
+function SimulatorIconButton({
+ icon: Icon,
+ label,
+ disabled = false,
+ disabledLabel,
+ onClick,
+}: {
+ icon: LucideIcon;
+ label: string;
+ disabled?: boolean;
+ disabledLabel?: string;
+ onClick: () => void;
+}) {
+ const accessibleLabel = disabled && disabledLabel ? `${label} — ${disabledLabel}` : label;
+ const button = (
+ <button
+ type="button"
+ aria-label={label}
+ aria-hidden={disabled ? true : undefined}
+ disabled={disabled}
+ onClick={onClick}
+ className="inline-flex h-7 w-7 items-center justify-center rounded-full border border-[var(--border-default)] bg-[var(--surface)] text-[var(--text-primary)] hover:bg-[var(--surface-hover)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)] disabled:opacity-50"
+ >
+ <Icon size={12} aria-hidden="true" />
+ </button>
+ );
+
+ return (
+ <Tip text={accessibleLabel} side="bottom">
+ {disabled ? (
+ <span
+ role="button"
+ aria-disabled="true"
+ aria-label={accessibleLabel}
+ tabIndex={0}
+ className="inline-flex rounded-full focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]"
+ >
+ {button}
+ </span>
+ ) : (
+ button
+ )}
+ </Tip>
+ );
+}
+
function routeFor(instance: IOSSimulatorPublicInstance) {
return {
instanceId: instance.instanceId,
@@ -513,6 +561,10 @@ export function IOSSimulatorInstanceGrid({
const agentBusy = agentBusyInstanceIds.has(instance.instanceId);
const routeInvalidated = invalidatedRouteKeys[instance.instanceId] === routeKey(instance);
const busy = isTileBusy(instance);
+ const controlsUnavailableLabel = agentBusy
+ ? t('rightSidebar.iosSimulator.agentBusyDescription')
+ : t('rightSidebar.iosSimulator.controlsUnavailable');
+ const textToSend = tileText[instance.instanceId] ?? '';
const error = tileErrors[instance.instanceId];
return (
<article
@@ -581,28 +633,29 @@ export function IOSSimulatorInstanceGrid({
className="h-7 w-full rounded-full border border-[var(--border-default)] bg-[var(--surface)] pl-7 pr-2 text-10 text-[var(--text-primary)] placeholder:text-[var(--text-placeholder)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)] disabled:opacity-50"
/>
</div>
- <button
- type="button"
- aria-label={`${instance.simulatorName} ${t('rightSidebar.iosSimulator.sendText')}`}
- disabled={busy || !(tileText[instance.instanceId] ?? '')}
+ <SimulatorIconButton
+ icon={Send}
+ label={`${instance.simulatorName} ${t('rightSidebar.iosSimulator.sendText')}`}
+ disabled={busy || !textToSend}
+ disabledLabel={
+ busy
+ ? controlsUnavailableLabel
+ : t('rightSidebar.iosSimulator.enterTextBeforeSending')
+ }
onClick={() => void sendTileText(instance)}
- className="inline-flex h-7 w-7 items-center justify-center rounded-full border border-[var(--border-default)] bg-[var(--surface)] text-[var(--text-primary)] hover:bg-[var(--surface-hover)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)] disabled:opacity-50"
- >
- <Send size={12} aria-hidden="true" />
- </button>
- <button
- type="button"
- aria-label={`${instance.simulatorName} ${t('rightSidebar.iosSimulator.pressHome')}`}
+ />
+ <SimulatorIconButton
+ icon={House}
+ label={`${instance.simulatorName} ${t('rightSidebar.iosSimulator.pressHome')}`}
disabled={busy}
+ disabledLabel={controlsUnavailableLabel}
onClick={() => void callTile(instance, 'press_home', {})}
- className="inline-flex h-7 w-7 items-center justify-center rounded-full border border-[var(--border-default)] bg-[var(--surface)] text-[var(--text-primary)] hover:bg-[var(--surface-hover)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)] disabled:opacity-50"
- >
- <House size={12} aria-hidden="true" />
- </button>
- <button
- type="button"
- aria-label={`${instance.simulatorName} ${t('rightSidebar.iosSimulator.rotateDevice')}`}
+ />
+ <SimulatorIconButton
+ icon={RotateCw}
+ label={`${instance.simulatorName} ${t('rightSidebar.iosSimulator.rotateDevice')}`}
disabled={busy}
+ disabledLabel={controlsUnavailableLabel}
onClick={() =>
void callTile(instance, 'set_orientation', {
orientation:
@@ -611,28 +664,21 @@ export function IOSSimulatorInstanceGrid({
: 'LANDSCAPE',
})
}
- className="inline-flex h-7 w-7 items-center justify-center rounded-full border border-[var(--border-default)] bg-[var(--surface)] text-[var(--text-primary)] hover:bg-[var(--surface-hover)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)] disabled:opacity-50"
- >
- <RotateCw size={12} aria-hidden="true" />
- </button>
- <button
- type="button"
- aria-label={`${instance.simulatorName} ${t('rightSidebar.iosSimulator.lockScreen')}`}
+ />
+ <SimulatorIconButton
+ icon={LockKeyhole}
+ label={`${instance.simulatorName} ${t('rightSidebar.iosSimulator.lockScreen')}`}
disabled={busy}
+ disabledLabel={controlsUnavailableLabel}
onClick={() => void callTile(instance, 'lock_screen', {})}
- className="inline-flex h-7 w-7 items-center justify-center rounded-full border border-[var(--border-default)] bg-[var(--surface)] text-[var(--text-primary)] hover:bg-[var(--surface-hover)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)] disabled:opacity-50"
- >
- <LockKeyhole size={12} aria-hidden="true" />
- </button>
- <button
- type="button"
- aria-label={`${instance.simulatorName} ${t('rightSidebar.iosSimulator.unlockScreen')}`}
+ />
+ <SimulatorIconButton
+ icon={UnlockKeyhole}
+ label={`${instance.simulatorName} ${t('rightSidebar.iosSimulator.unlockScreen')}`}
disabled={busy}
+ disabledLabel={controlsUnavailableLabel}
onClick={() => void callTile(instance, 'unlock_screen', {})}
- className="inline-flex h-7 w-7 items-center justify-center rounded-full border border-[var(--border-default)] bg-[var(--surface)] text-[var(--text-primary)] hover:bg-[var(--surface-hover)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)] disabled:opacity-50"
- >
- <UnlockKeyhole size={12} aria-hidden="true" />
- </button>
+ />
</div>
{agentBusy && (
<div className="border-t border-[var(--border-default)] px-2 py-1 text-10 text-[var(--warning-accent)]">
diff --git a/apps/desktop/src/renderer/features/right-sidebar/plugins/ios-simulator/__tests__/IOSSimulatorTabBody.test.tsx b/apps/desktop/src/renderer/features/right-sidebar/plugins/ios-simulator/__tests__/IOSSimulatorTabBody.test.tsx
index b63820da22..24dfd0f659 100644
--- a/apps/desktop/src/renderer/features/right-sidebar/plugins/ios-simulator/__tests__/IOSSimulatorTabBody.test.tsx
+++ b/apps/desktop/src/renderer/features/right-sidebar/plugins/ios-simulator/__tests__/IOSSimulatorTabBody.test.tsx
@@ -173,6 +173,17 @@ function preparePointerTarget(container: HTMLElement): HTMLImageElement {
return image;
}
+function expectDisabledIconButton(label: string, accessibleLabel: string): void {
+ const button = Array.from(
+ document.querySelectorAll<HTMLButtonElement>('button[aria-label]'),
+ ).find((candidate) => candidate.getAttribute('aria-label') === label);
+ expect(button?.disabled).toBe(true);
+ expect(button?.getAttribute('aria-hidden')).toBe('true');
+ expect(button?.parentElement?.getAttribute('role')).toBe('button');
+ expect(button?.parentElement?.getAttribute('aria-disabled')).toBe('true');
+ expect(button?.parentElement?.getAttribute('aria-label')).toBe(accessibleLabel);
+}
+
function installFakeH264DecoderRuntime(): void {
class FakeVideoDecoder {
static async isConfigSupported() {
@@ -1763,19 +1774,20 @@ describe('IOSSimulatorTabBody', () => {
const rendered = render(
<IOSSimulatorTabBody state={{ instanceId: 'instance-a' }} ctx={ctx} active shellVisible />,
);
- fireEvent.click(
- await screen.findByRole('button', {
- name: 'rightSidebar.iosSimulator.nativeRecovery.action',
- }),
- );
+ const recoveryButtonA = (await screen.findByRole('button', {
+ name: 'rightSidebar.iosSimulator.nativeRecovery.action',
+ })) as HTMLButtonElement;
+ await waitFor(() => expect(recoveryButtonA.disabled).toBe(false));
+ fireEvent.click(recoveryButtonA);
await waitFor(() => expect(api.retryNativeRoute).toHaveBeenCalledTimes(1));
rendered.rerender(
<IOSSimulatorTabBody state={{ instanceId: 'instance-b' }} ctx={ctx} active shellVisible />,
);
- const recoveryButtonB = await screen.findByRole('button', {
+ const recoveryButtonB = (await screen.findByRole('button', {
name: 'rightSidebar.iosSimulator.nativeRecovery.action',
- });
+ })) as HTMLButtonElement;
+ await waitFor(() => expect(recoveryButtonB.disabled).toBe(false));
fireEvent.click(recoveryButtonB);
await waitFor(() => {
expect(api.retryNativeRoute).toHaveBeenCalledTimes(2);
@@ -2673,6 +2685,10 @@ describe('IOSSimulatorTabBody', () => {
}),
);
});
+ expectDisabledIconButton(
+ 'iPhone B rightSidebar.iosSimulator.sendText',
+ 'iPhone B rightSidebar.iosSimulator.sendText — rightSidebar.iosSimulator.enterTextBeforeSending',
+ );
fireEvent.click(
screen.getByRole('button', {
@@ -2819,13 +2835,26 @@ describe('IOSSimulatorTabBody', () => {
value: () => ({ left: 0, top: 0, width: 200, height: 400 }),
},
});
- expect(
- (
- screen.getByRole('button', {
- name: 'iPhone B rightSidebar.iosSimulator.pressHome',
- }) as HTMLButtonElement
- ).disabled,
- ).toBe(true);
+ expectDisabledIconButton(
+ 'iPhone B rightSidebar.iosSimulator.pressHome',
+ 'iPhone B rightSidebar.iosSimulator.pressHome — rightSidebar.iosSimulator.agentBusyDescription',
+ );
+ expectDisabledIconButton(
+ 'iPhone B rightSidebar.iosSimulator.rotateDevice',
+ 'iPhone B rightSidebar.iosSimulator.rotateDevice — rightSidebar.iosSimulator.agentBusyDescription',
+ );
+ expectDisabledIconButton(
+ 'iPhone B rightSidebar.iosSimulator.lockScreen',
+ 'iPhone B rightSidebar.iosSimulator.lockScreen — rightSidebar.iosSimulator.agentBusyDescription',
+ );
+ expectDisabledIconButton(
+ 'iPhone B rightSidebar.iosSimulator.unlockScreen',
+ 'iPhone B rightSidebar.iosSimulator.unlockScreen — rightSidebar.iosSimulator.agentBusyDescription',
+ );
+ expectDisabledIconButton(
+ 'iPhone B rightSidebar.iosSimulator.sendText',
+ 'iPhone B rightSidebar.iosSimulator.sendText — rightSidebar.iosSimulator.agentBusyDescription',
+ );
fireEvent.pointerDown(image, { pointerId: 41, button: 0, clientX: 20, clientY: 40 });
fireEvent.pointerUp(image, { pointerId: 41, clientX: 180, clientY: 360 });
@@ -2867,13 +2896,10 @@ describe('IOSSimulatorTabBody', () => {
};
await waitFor(
() =>
- expect(
- (
- screen.getByRole('button', {
- name: 'iPhone B rightSidebar.iosSimulator.pressHome',
- }) as HTMLButtonElement
- ).disabled,
- ).toBe(true),
+ expectDisabledIconButton(
+ 'iPhone B rightSidebar.iosSimulator.pressHome',
+ 'iPhone B rightSidebar.iosSimulator.pressHome — rightSidebar.iosSimulator.agentBusyDescription',
+ ),
{ timeout: 2_000 },
);
expect(api.status).toHaveBeenCalledOnce();
@@ -2980,13 +3006,10 @@ describe('IOSSimulatorTabBody', () => {
});
await waitFor(() => expect(api.status).toHaveBeenCalledTimes(2), { timeout: 2_000 });
await waitFor(() => expect(screen.queryByAltText('iPhone B')).toBeNull());
- expect(
- (
- screen.getByRole('button', {
- name: 'iPhone B rightSidebar.iosSimulator.pressHome',
- }) as HTMLButtonElement
- ).disabled,
- ).toBe(true);
+ expectDisabledIconButton(
+ 'iPhone B rightSidebar.iosSimulator.pressHome',
+ 'iPhone B rightSidebar.iosSimulator.pressHome — rightSidebar.iosSimulator.controlsUnavailable',
+ );
expect(URL.revokeObjectURL).toHaveBeenCalledWith('blob:ios-simulator-1');
fireEvent.pointerUp(staleImage, {
pointerId: 31,
diff --git a/apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/SubagentsBody.tsx b/apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/SubagentsBody.tsx
index 929e9295ca..622bc2c00c 100644
--- a/apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/SubagentsBody.tsx
+++ b/apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/SubagentsBody.tsx
@@ -21,6 +21,7 @@ import type {
import { MarkdownRenderer } from '@/components/chat/MarkdownRenderer';
import { Spinner } from '@/components/ui/spinner';
+import { Tip } from '@/components/ui/tooltip';
import { getDataOwnerGeneration } from '@/contexts/dataOwnerGeneration';
import { cn } from '@/lib/utils';
import { formatCompactTokens } from '@/lib/usageFormat';
@@ -272,15 +273,16 @@ function HeaderBack({
const { t } = useTranslation();
return (
<div className="flex h-11 shrink-0 items-center gap-2 border-b border-[var(--border-default)] px-3">
- <button
- type="button"
- onClick={onBack}
- title={t('rightSidebar.subagents.back')}
- aria-label={t('rightSidebar.subagents.back')}
- className="inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-lg text-[var(--text-secondary)] hover:bg-[var(--surface-hover)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]"
- >
- <ArrowLeft size={15} aria-hidden="true" />
- </button>
+ <Tip text={t('rightSidebar.subagents.back')} side="bottom">
+ <button
+ type="button"
+ onClick={onBack}
+ aria-label={t('rightSidebar.subagents.back')}
+ className="inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-lg text-[var(--text-secondary)] hover:bg-[var(--surface-hover)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]"
+ >
+ <ArrowLeft size={15} aria-hidden="true" />
+ </button>
+ </Tip>
<span className="min-w-0 flex-1 truncate text-13 font-medium text-[var(--text-primary)]">
{title}
</span>
diff --git a/apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/BrowserChrome.tsx b/apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/BrowserChrome.tsx
index 74a52ea438..a5bb86a00f 100644
--- a/apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/BrowserChrome.tsx
+++ b/apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/BrowserChrome.tsx
@@ -53,6 +53,7 @@ import {
DropdownMenuItem,
DropdownMenuTrigger,
} from '@/components/ui/dropdown-menu';
+import { Tip } from '@/components/ui/tooltip';
import { cn } from '@/lib/utils';
import { parseOmnibox } from './lib/parseOmnibox';
@@ -120,213 +121,223 @@ export const BrowserChrome = forwardRef<BrowserChromeHandle, BrowserChromeProps>
) {
const { t } = useTranslation();
- // URL pill 编辑态 —— 点 / focus 进入,Enter / Esc / blur 退出。
- // editingValue 是编辑态的临时 buffer,提交才 onNavigate 出去。
- const [editing, setEditing] = useState(false);
- const [editingValue, setEditingValue] = useState('');
- const inputRef = useRef<HTMLInputElement | null>(null);
- const suppressNextBlurSubmitRef = useRef(false);
+ // URL pill 编辑态 —— 点 / focus 进入,Enter / Esc / blur 退出。
+ // editingValue 是编辑态的临时 buffer,提交才 onNavigate 出去。
+ const [editing, setEditing] = useState(false);
+ const [editingValue, setEditingValue] = useState('');
+ const inputRef = useRef<HTMLInputElement | null>(null);
+ const suppressNextBlurSubmitRef = useRef(false);
- // 进入编辑态时只负责 focus/select。editingValue 在 beginEdit 同步写入,避免
- // input 首帧先显示空值 / 旧值、下一帧再跳成 URL 的视觉闪动。
- useLayoutEffect(() => {
- if (editing) {
- requestAnimationFrame(() => {
- inputRef.current?.focus();
- inputRef.current?.select();
- });
- }
- }, [editing]);
+ // 进入编辑态时只负责 focus/select。editingValue 在 beginEdit 同步写入,避免
+ // input 首帧先显示空值 / 旧值、下一帧再跳成 URL 的视觉闪动。
+ useLayoutEffect(() => {
+ if (editing) {
+ requestAnimationFrame(() => {
+ inputRef.current?.focus();
+ inputRef.current?.select();
+ });
+ }
+ }, [editing]);
- const beginEdit = useCallback(() => {
- suppressNextBlurSubmitRef.current = false;
- setEditingValue(url);
- setEditing(true);
- }, [url]);
- const exitEdit = useCallback(() => setEditing(false), []);
+ const beginEdit = useCallback(() => {
+ suppressNextBlurSubmitRef.current = false;
+ setEditingValue(url);
+ setEditing(true);
+ }, [url]);
+ const exitEdit = useCallback(() => setEditing(false), []);
- // 暴露 imperative API:Cmd/Ctrl+L 由 BrowserTabBody 监听 keydown 调到这里。
- // 行为:进编辑态 + 下一帧 select all(focus+select 的副作用在 editing effect 里)。
- useImperativeHandle(
- ref,
- () => ({
- focusUrlBar: beginEdit,
- }),
- [beginEdit],
- );
+ // 暴露 imperative API:Cmd/Ctrl+L 由 BrowserTabBody 监听 keydown 调到这里。
+ // 行为:进编辑态 + 下一帧 select all(focus+select 的副作用在 editing effect 里)。
+ useImperativeHandle(
+ ref,
+ () => ({
+ focusUrlBar: beginEdit,
+ }),
+ [beginEdit],
+ );
- const submitValue = useCallback((value: string, options?: { ctrlEnter?: boolean }) => {
- const next = parseOmnibox(value, options);
- onNavigate(next);
- setEditing(false);
- }, [onNavigate]);
+ const submitValue = useCallback(
+ (value: string, options?: { ctrlEnter?: boolean }) => {
+ const next = parseOmnibox(value, options);
+ onNavigate(next);
+ setEditing(false);
+ },
+ [onNavigate],
+ );
- const ignoreNextBlurSubmit = useCallback(() => {
- suppressNextBlurSubmitRef.current = true;
- }, []);
+ const ignoreNextBlurSubmit = useCallback(() => {
+ suppressNextBlurSubmitRef.current = true;
+ }, []);
- const handleBlur = useCallback((e: React.FocusEvent<HTMLInputElement>) => {
- if (suppressNextBlurSubmitRef.current) {
- suppressNextBlurSubmitRef.current = false;
- return;
- }
- submitValue(e.currentTarget.value);
- }, [submitValue]);
+ const handleBlur = useCallback(
+ (e: React.FocusEvent<HTMLInputElement>) => {
+ if (suppressNextBlurSubmitRef.current) {
+ suppressNextBlurSubmitRef.current = false;
+ return;
+ }
+ submitValue(e.currentTarget.value);
+ },
+ [submitValue],
+ );
- const handleKey = useCallback(
- (e: React.KeyboardEvent<HTMLInputElement>) => {
- if (e.key === 'Enter' && !e.nativeEvent.isComposing) {
- e.preventDefault();
- ignoreNextBlurSubmit();
- const value = e.currentTarget.value;
- if (e.ctrlKey && !e.metaKey && !e.shiftKey && !e.altKey) {
- submitValue(value, { ctrlEnter: true });
- } else {
- submitValue(value);
+ const handleKey = useCallback(
+ (e: React.KeyboardEvent<HTMLInputElement>) => {
+ if (e.key === 'Enter' && !e.nativeEvent.isComposing) {
+ e.preventDefault();
+ ignoreNextBlurSubmit();
+ const value = e.currentTarget.value;
+ if (e.ctrlKey && !e.metaKey && !e.shiftKey && !e.altKey) {
+ submitValue(value, { ctrlEnter: true });
+ } else {
+ submitValue(value);
+ }
+ } else if (e.key === 'Escape') {
+ e.preventDefault();
+ ignoreNextBlurSubmit();
+ exitEdit();
}
- } else if (e.key === 'Escape') {
- e.preventDefault();
- ignoreNextBlurSubmit();
- exitEdit();
- }
- },
- [ignoreNextBlurSubmit, submitValue, exitEdit],
- );
+ },
+ [ignoreNextBlurSubmit, submitValue, exitEdit],
+ );
- // URL pill 显示态展示:about:blank / 空 → 显示"新标签"占位文案,否则显示 URL。
- // 长 URL 截断走 CSS truncate。
- const displayValue = url && url !== 'about:blank'
- ? url
- : t('rightSidebar.browser.newTab');
+ // URL pill 显示态展示:about:blank / 空 → 显示"新标签"占位文案,否则显示 URL。
+ // 长 URL 截断走 CSS truncate。
+ const displayValue = url && url !== 'about:blank' ? url : t('rightSidebar.browser.newTab');
- // 是否 https:左侧 lock icon 决定。about:blank 等非 web 协议显示 unlock 占位。
- const isSecure = url.startsWith('https://');
+ // 是否 https:左侧 lock icon 决定。about:blank 等非 web 协议显示 unlock 占位。
+ const isSecure = url.startsWith('https://');
- // 「更多」菜单里复制链接只要求有有效页面 URL;系统浏览器打开还要由宿主确认
- // 当前协议/页面类型有对应的安全 IPC 能力。比如本地 HTML 走 openFileInBrowser,
- // 其它 file/data/custom scheme 不应显示一个点击必失败的可用菜单项。
- const hasValidLink = Boolean(url) && url !== 'about:blank';
+ // 「更多」菜单里复制链接只要求有有效页面 URL;系统浏览器打开还要由宿主确认
+ // 当前协议/页面类型有对应的安全 IPC 能力。比如本地 HTML 走 openFileInBrowser,
+ // 其它 file/data/custom scheme 不应显示一个点击必失败的可用菜单项。
+ const hasValidLink = Boolean(url) && url !== 'about:blank';
- return (
- <div className="flex h-10 shrink-0 items-center gap-1 border-b border-[var(--border-default)] bg-content-area px-2">
- {/* 左:导航按钮 */}
- <ChromeIconButton
- icon={ArrowLeft}
- disabled={!canGoBack}
- onClick={onGoBack}
- tooltip={t('rightSidebar.browser.goBack')}
- />
- <ChromeIconButton
- icon={ArrowRight}
- disabled={!canGoForward}
- onClick={onGoForward}
- tooltip={t('rightSidebar.browser.goForward')}
- />
- <ChromeIconButton
- icon={RotateCw}
- reducedMotionIcon={isLoading ? XIcon : undefined}
- spinning={isLoading}
- onClick={isLoading ? onStop : onReload}
- tooltip={
- isLoading
- ? t('rightSidebar.browser.stop')
- : t('rightSidebar.browser.reload')
- }
- />
+ return (
+ <div className="flex h-10 shrink-0 items-center gap-1 border-b border-[var(--border-default)] bg-content-area px-2">
+ {/* 左:导航按钮 */}
+ <ChromeIconButton
+ icon={ArrowLeft}
+ disabled={!canGoBack}
+ onClick={onGoBack}
+ tooltip={t('rightSidebar.browser.goBack')}
+ disabledTooltip={t('rightSidebar.browser.goBackUnavailable')}
+ />
+ <ChromeIconButton
+ icon={ArrowRight}
+ disabled={!canGoForward}
+ onClick={onGoForward}
+ tooltip={t('rightSidebar.browser.goForward')}
+ disabledTooltip={t('rightSidebar.browser.goForwardUnavailable')}
+ />
+ <ChromeIconButton
+ icon={RotateCw}
+ reducedMotionIcon={isLoading ? XIcon : undefined}
+ spinning={isLoading}
+ onClick={isLoading ? onStop : onReload}
+ tooltip={isLoading ? t('rightSidebar.browser.stop') : t('rightSidebar.browser.reload')}
+ />
- {/* 中:URL pill */}
- <div
- className={cn(
- 'mx-1 flex h-7 min-w-0 flex-1 items-center gap-1.5 rounded-full border',
- 'bg-[var(--surface-elevated)] px-2.5',
- editing
- ? 'border-[var(--focus-ring)] ring-1 ring-[var(--focus-ring-soft)]'
- : 'border-[var(--border-default)]',
- )}
- >
- {isSecure ? (
- <Lock size={11} strokeWidth={2} className="shrink-0 text-[var(--text-tertiary)]" />
- ) : (
- <Unlock size={11} strokeWidth={2} className="shrink-0 text-[var(--text-tertiary)]" />
- )}
- {editing ? (
- <input
- ref={inputRef}
- type="text"
- value={editingValue}
- onChange={(e) => setEditingValue(e.target.value)}
- onKeyDown={handleKey}
- onBlur={handleBlur}
- placeholder={t('rightSidebar.browser.urlPlaceholder')}
- className={cn(
- 'min-w-0 flex-1 bg-transparent text-12 leading-none text-[var(--text-primary)]',
- 'placeholder:text-[var(--text-tertiary)] outline-none',
- )}
- />
- ) : (
- <button
- type="button"
- onClick={beginEdit}
- // 整个 pill 中部区域都可点 → 进编辑态。truncate 让长 URL 单行省略。
- className="min-w-0 flex-1 truncate text-left text-12 leading-none text-[var(--text-primary)]"
- title={url}
- >
- {displayValue}
- </button>
- )}
- </div>
- {/* 右侧工具区交互约定:
+ {/* 中:URL pill */}
+ <div
+ className={cn(
+ 'mx-1 flex h-7 min-w-0 flex-1 items-center gap-1.5 rounded-full border',
+ 'bg-[var(--surface-elevated)] px-2.5',
+ editing
+ ? 'border-[var(--focus-ring)] ring-1 ring-[var(--focus-ring-soft)]'
+ : 'border-[var(--border-default)]',
+ )}
+ >
+ {isSecure ? (
+ <Lock size={11} strokeWidth={2} className="shrink-0 text-[var(--text-tertiary)]" />
+ ) : (
+ <Unlock size={11} strokeWidth={2} className="shrink-0 text-[var(--text-tertiary)]" />
+ )}
+ {editing ? (
+ <input
+ ref={inputRef}
+ type="text"
+ value={editingValue}
+ onChange={(e) => setEditingValue(e.target.value)}
+ onKeyDown={handleKey}
+ onBlur={handleBlur}
+ placeholder={t('rightSidebar.browser.urlPlaceholder')}
+ className={cn(
+ 'min-w-0 flex-1 bg-transparent text-12 leading-none text-[var(--text-primary)]',
+ 'placeholder:text-[var(--text-tertiary)] outline-none',
+ )}
+ />
+ ) : (
+ <button
+ type="button"
+ onClick={beginEdit}
+ // 整个 pill 中部区域都可点 → 进编辑态。truncate 让长 URL 单行省略。
+ className="min-w-0 flex-1 truncate text-left text-12 leading-none text-[var(--text-primary)]"
+ title={url}
+ data-native-title="truncated-text"
+ >
+ {displayValue}
+ </button>
+ )}
+ </div>
+ {/* 右侧工具区交互约定:
camera = 截图(capturePage → 剪贴板,已实现);
message-square-plus = 页面评论(评论模式点选元素 → 评论进 composer,
已实现,active 态高亮);ellipsis = 更多菜单(系统浏览器打开 / 复制链接)。 */}
- <ChromeIconButton
- icon={Camera}
- onClick={onCaptureScreenshot}
- tooltip={t('rightSidebar.browser.screenshot')}
- />
- {/* detached 子窗口无 composer,评论无处落点 —— 直接不渲染该按钮。 */}
- {commentSupported && (
<ChromeIconButton
- icon={MessageSquarePlus}
- active={commentActive}
- onClick={onToggleComment}
- tooltip={t('rightSidebar.browser.comment')}
+ icon={Camera}
+ onClick={onCaptureScreenshot}
+ tooltip={t('rightSidebar.browser.screenshot')}
/>
- )}
- {/* 更多菜单:trigger 复用 chrome 图标按钮视觉(默认态 + 菜单打开时 active 高亮,
+ {/* detached 子窗口无 composer,评论无处落点 —— 直接不渲染该按钮。 */}
+ {commentSupported && (
+ <ChromeIconButton
+ icon={MessageSquarePlus}
+ active={commentActive}
+ onClick={onToggleComment}
+ tooltip={
+ commentActive
+ ? t('rightSidebar.browser.exitCommentMode')
+ : t('rightSidebar.browser.comment')
+ }
+ />
+ )}
+ {/* 更多菜单:trigger 复用 chrome 图标按钮视觉(默认态 + 菜单打开时 active 高亮,
走 data-[state=open])。菜单项在无有效链接(新标签空白态)时置灰。 */}
- <DropdownMenu onOpenChange={onOverlayOpenChange}>
- <DropdownMenuTrigger asChild>
- <button
- type="button"
- title={t('rightSidebar.browser.moreTools')}
- aria-label={t('rightSidebar.browser.moreTools')}
- className={cn(
- 'flex size-6 shrink-0 items-center justify-center rounded-md transition-colors',
- 'text-sidebar-action-icon hover:bg-sidebar-item-active hover:text-sidebar-item-active-foreground',
- 'data-[state=open]:bg-sidebar-item-active data-[state=open]:text-sidebar-item-active-foreground',
- )}
- >
- <Ellipsis size={14} strokeWidth={2} />
- </button>
- </DropdownMenuTrigger>
- <DropdownMenuContent align="end" className="min-w-[9rem]">
- <DropdownMenuItem
- disabled={!hasValidLink || !canOpenInSystemBrowser}
- onSelect={onOpenInSystemBrowser}
- >
- <ExternalLink size={14} strokeWidth={2} className="mr-2 shrink-0" />
- {t('rightSidebar.browser.openInSystemBrowser')}
- </DropdownMenuItem>
- <DropdownMenuItem disabled={!hasValidLink} onSelect={onCopyLink}>
- <LinkIcon size={14} strokeWidth={2} className="mr-2 shrink-0" />
- {t('rightSidebar.browser.copyLink')}
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
- </div>
- );
-});
+ <DropdownMenu onOpenChange={onOverlayOpenChange}>
+ <DropdownMenuTrigger asChild>
+ <Tip text={t('rightSidebar.browser.moreTools')} side="bottom">
+ <button
+ type="button"
+ aria-label={t('rightSidebar.browser.moreTools')}
+ className={cn(
+ 'flex size-6 shrink-0 items-center justify-center rounded-md transition-colors',
+ 'text-sidebar-action-icon hover:bg-sidebar-item-active hover:text-sidebar-item-active-foreground',
+ 'data-[state=open]:bg-sidebar-item-active data-[state=open]:text-sidebar-item-active-foreground',
+ 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]',
+ )}
+ >
+ <Ellipsis size={14} strokeWidth={2} />
+ </button>
+ </Tip>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end" className="min-w-[9rem]">
+ <DropdownMenuItem
+ disabled={!hasValidLink || !canOpenInSystemBrowser}
+ onSelect={onOpenInSystemBrowser}
+ >
+ <ExternalLink size={14} strokeWidth={2} className="mr-2 shrink-0" />
+ {t('rightSidebar.browser.openInSystemBrowser')}
+ </DropdownMenuItem>
+ <DropdownMenuItem disabled={!hasValidLink} onSelect={onCopyLink}>
+ <LinkIcon size={14} strokeWidth={2} className="mr-2 shrink-0" />
+ {t('rightSidebar.browser.copyLink')}
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </div>
+ );
+ },
+);
/**
* Chrome 内一类小图标按钮:24×24(默认)/ inlinePill 用 18×18(URL pill 内嵌的
@@ -342,6 +353,7 @@ function ChromeIconButton({
spinning = false,
onClick,
tooltip,
+ disabledTooltip,
}: {
icon: React.ComponentType<{ size?: number; strokeWidth?: number; className?: string }>;
/** reduced-motion 下用静态动作图标表达 loading 状态,避免刷新/空闲态无法区分。 */
@@ -359,17 +371,21 @@ function ChromeIconButton({
spinning?: boolean;
onClick: () => void;
tooltip: string;
+ /** 禁用态必须解释不可用原因,不能只重复可用态动作名。 */
+ disabledTooltip?: string;
}) {
- return (
+ const accessibleLabel = disabled ? (disabledTooltip ?? tooltip) : tooltip;
+ const button = (
<button
type="button"
disabled={disabled}
onClick={onClick}
- title={tooltip}
- aria-label={tooltip}
+ aria-label={accessibleLabel}
+ aria-hidden={disabled ? true : undefined}
aria-busy={spinning || undefined}
className={cn(
'flex shrink-0 items-center justify-center rounded-md transition-colors',
+ 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]',
inlinePill ? 'size-[18px]' : 'size-6',
disabled
? 'text-[var(--text-tertiary)] opacity-40'
@@ -389,14 +405,29 @@ function ChromeIconButton({
</>
) : (
<span
- className={cn(
- 'inline-flex',
- spinning && 'animate-spinner motion-reduce:animate-none',
- )}
+ className={cn('inline-flex', spinning && 'animate-spinner motion-reduce:animate-none')}
>
<Icon size={size} strokeWidth={2} />
</span>
)}
</button>
);
+
+ return (
+ <Tip text={accessibleLabel} side="bottom">
+ {disabled ? (
+ <span
+ role="button"
+ aria-disabled="true"
+ aria-label={accessibleLabel}
+ tabIndex={0}
+ className="inline-flex rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]"
+ >
+ {button}
+ </span>
+ ) : (
+ button
+ )}
+ </Tip>
+ );
}
diff --git a/apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/BrowserCommentPopover.tsx b/apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/BrowserCommentPopover.tsx
index d6e00675a9..f2ff5d154f 100644
--- a/apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/BrowserCommentPopover.tsx
+++ b/apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/BrowserCommentPopover.tsx
@@ -25,6 +25,7 @@ import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react
import { SlidersHorizontal } from 'lucide-react';
import { useTranslation } from 'react-i18next';
+import { Tip } from '@/components/ui/tooltip';
import { parseCssColor } from '@/lib/browserComments';
import { cn } from '@/lib/utils';
@@ -182,7 +183,10 @@ export function BrowserCommentPopover({
const styles: Record<string, string> = {};
for (const [property, value] of Object.entries(nextEdits)) {
const trimmed = value.trim();
- if (trimmed && !isSameStyleValue(property, trimmed, designBaseline.styles[property] ?? '')) {
+ if (
+ trimmed &&
+ !isSameStyleValue(property, trimmed, designBaseline.styles[property] ?? '')
+ ) {
styles[property] = trimmed;
}
}
@@ -267,6 +271,29 @@ export function BrowserCommentPopover({
'placeholder:text-[var(--text-tertiary)] outline-none',
'focus:border-[var(--focus-ring)] focus:ring-1 focus:ring-[var(--focus-ring-soft)]',
);
+ const styleTweaksLabel = submitting
+ ? t('rightSidebar.browser.styleTweaksSubmitting')
+ : showStyles
+ ? t('rightSidebar.browser.styleTweaksCollapse')
+ : t('rightSidebar.browser.styleTweaksExpand');
+ const styleTweaksButton = (
+ <button
+ type="button"
+ aria-label={styleTweaksLabel}
+ aria-hidden={submitting ? true : undefined}
+ onClick={() => setShowStyles((v) => !v)}
+ disabled={submitting}
+ className={cn(
+ 'flex size-6 items-center justify-center rounded-md transition-colors',
+ 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]',
+ showStyles || changes.length > 0
+ ? 'bg-sidebar-item-active text-sidebar-item-active-foreground'
+ : 'text-sidebar-action-icon hover:bg-sidebar-item-active hover:text-sidebar-item-active-foreground',
+ )}
+ >
+ <SlidersHorizontal size={13} strokeWidth={2} />
+ </button>
+ );
return (
<div
@@ -360,21 +387,21 @@ export function BrowserCommentPopover({
<div className="flex items-center justify-between gap-1.5">
{/* 左:样式编辑开关(Codex "config icon next to the text input")。 */}
{designBaseline ? (
- <button
- type="button"
- aria-label={t('rightSidebar.browser.styleTweaks')}
- title={t('rightSidebar.browser.styleTweaks')}
- onClick={() => setShowStyles((v) => !v)}
- disabled={submitting}
- className={cn(
- 'flex size-6 items-center justify-center rounded-md transition-colors',
- showStyles || changes.length > 0
- ? 'bg-sidebar-item-active text-sidebar-item-active-foreground'
- : 'text-sidebar-action-icon hover:bg-sidebar-item-active hover:text-sidebar-item-active-foreground',
+ <Tip text={styleTweaksLabel} side="bottom">
+ {submitting ? (
+ <span
+ role="button"
+ aria-disabled="true"
+ aria-label={styleTweaksLabel}
+ tabIndex={0}
+ className="inline-flex rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]"
+ >
+ {styleTweaksButton}
+ </span>
+ ) : (
+ styleTweaksButton
)}
- >
- <SlidersHorizontal size={13} strokeWidth={2} />
- </button>
+ </Tip>
) : (
<span />
)}
diff --git a/apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/BrowserTabBody.tsx b/apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/BrowserTabBody.tsx
index 7cc2934171..b8760d83db 100644
--- a/apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/BrowserTabBody.tsx
+++ b/apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/BrowserTabBody.tsx
@@ -37,14 +37,12 @@ import { createLogger } from '@/lib/logger';
import { isSidebarWindow } from '@/lib/sidebarWindow';
import { toast } from '@/lib/toast';
import { cn } from '@/lib/utils';
+import { Tip } from '@/components/ui/tooltip';
import { mapIpcErrorToI18nKey } from '@/utils/ipcError';
import { browserWebviewPool } from '../../lib/browserWebviewPool';
import { findNativePopupSurfaceForTab } from '../../lib/nativePopupTabs';
-import {
- forceKillBrowserTab,
- setForegroundBrowserTab,
-} from '../../lib/rsbBrowserBridge';
+import { forceKillBrowserTab, setForegroundBrowserTab } from '../../lib/rsbBrowserBridge';
import { isLocalHtmlFileUrl } from '../../lib/openInSidebarBrowser';
import { closeTab } from '../../store';
import { useBrowserWebview } from '../../hooks/useBrowserWebview';
@@ -134,10 +132,7 @@ export function BrowserTabBody({ state, ctx, active, shellVisible }: BrowserTabB
url: browser.url || state.url,
reload: browser.reload,
enabled:
- active === true &&
- ctx.remoteHostId === null &&
- deviceLinkDeviceId === null &&
- !browser.crash,
+ active === true && ctx.remoteHostId === null && deviceLinkDeviceId === null && !browser.crash,
});
// 把 pool 的 wrapper 挂进 slot —— useLayoutEffect(在 paint 前移 DOM,避免闪)。
@@ -413,10 +408,7 @@ export function BrowserTabBody({ state, ctx, active, shellVisible }: BrowserTabB
// 主线程被打断重启),对 crashed/killed/oom 走 navigate(等价于 reload,但能
// 容忍 webContents 已经死掉的情况)。两种都会触发 did-start-loading → 清 crash。
const handleRecover = useCallback(() => {
- if (
- browser.crash?.reason === 'unresponsive' ||
- browser.crash?.reason === 'navigation-loop'
- ) {
+ if (browser.crash?.reason === 'unresponsive' || browser.crash?.reason === 'navigation-loop') {
browser.reload();
} else {
browser.navigate(state.url || 'about:blank');
@@ -546,14 +538,16 @@ export function BrowserTabBody({ state, ctx, active, shellVisible }: BrowserTabB
>
{t('rightSidebar.browser.resourceAlert.terminate')}
</button>
- <button
- type="button"
- aria-label={t('rightSidebar.browser.resourceAlert.dismiss')}
- onClick={browser.dismissResourceAlert}
- className="flex size-5 items-center justify-center rounded-full text-[var(--text-tertiary)] hover:bg-[var(--surface-hover)] hover:text-[var(--text-secondary)]"
- >
- <X size={12} strokeWidth={2} />
- </button>
+ <Tip text={t('rightSidebar.browser.resourceAlert.dismiss')} side="bottom">
+ <button
+ type="button"
+ aria-label={t('rightSidebar.browser.resourceAlert.dismiss')}
+ onClick={browser.dismissResourceAlert}
+ className="flex size-5 items-center justify-center rounded-full text-[var(--text-tertiary)] hover:bg-[var(--surface-hover)] hover:text-[var(--text-secondary)]"
+ >
+ <X size={12} strokeWidth={2} />
+ </button>
+ </Tip>
</div>
)}
{/* 评论模式提示条:点选中显示操作说明,固定在 slot 顶部居中,不挡 chrome。 */}
@@ -618,18 +612,18 @@ function BrowserCrashBanner({
cause === 'resource-memory'
? 'rightSidebar.browser.crash.resourceKilledTitle'
: reason === 'navigation-loop'
- ? 'rightSidebar.browser.crash.navigationLoopTitle'
- : reason === 'unresponsive'
- ? 'rightSidebar.browser.crash.unresponsiveTitle'
- : 'rightSidebar.browser.crash.crashedTitle';
+ ? 'rightSidebar.browser.crash.navigationLoopTitle'
+ : reason === 'unresponsive'
+ ? 'rightSidebar.browser.crash.unresponsiveTitle'
+ : 'rightSidebar.browser.crash.crashedTitle';
const descKey =
cause === 'resource-memory'
? 'rightSidebar.browser.crash.resourceKilledDesc'
: reason === 'navigation-loop'
- ? 'rightSidebar.browser.crash.navigationLoopDesc'
- : reason === 'unresponsive'
- ? 'rightSidebar.browser.crash.unresponsiveDesc'
- : 'rightSidebar.browser.crash.crashedDesc';
+ ? 'rightSidebar.browser.crash.navigationLoopDesc'
+ : reason === 'unresponsive'
+ ? 'rightSidebar.browser.crash.unresponsiveDesc'
+ : 'rightSidebar.browser.crash.crashedDesc';
return (
<div className="absolute inset-0 flex items-center justify-center bg-[var(--overlay-modal)] backdrop-blur-sm">
<div className="flex max-w-xs flex-col items-center gap-3 rounded-lg border border-[var(--border-default)] bg-[var(--surface-elevated)] px-6 py-5 text-center">
diff --git a/apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/__tests__/BrowserChrome.test.ts b/apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/__tests__/BrowserChrome.test.ts
index 2a1e721290..e99558ce57 100644
--- a/apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/__tests__/BrowserChrome.test.ts
+++ b/apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/__tests__/BrowserChrome.test.ts
@@ -49,6 +49,9 @@ function renderChrome(
commentSupported?: boolean;
canOpenInSystemBrowser?: boolean;
isLoading?: boolean;
+ canGoBack?: boolean;
+ canGoForward?: boolean;
+ commentActive?: boolean;
onReload?: () => void;
onStop?: () => void;
} = {},
@@ -62,15 +65,15 @@ function renderChrome(
ref,
url,
isLoading: extra.isLoading ?? false,
- canGoBack: false,
- canGoForward: false,
+ canGoBack: extra.canGoBack ?? false,
+ canGoForward: extra.canGoForward ?? false,
onNavigate,
onReload: extra.onReload ?? vi.fn(),
onStop: extra.onStop ?? vi.fn(),
onGoBack: vi.fn(),
onGoForward: vi.fn(),
onCaptureScreenshot: vi.fn(),
- commentActive: false,
+ commentActive: extra.commentActive ?? false,
onToggleComment: vi.fn(),
onOpenInSystemBrowser,
onCopyLink,
@@ -102,16 +105,21 @@ describe('BrowserChrome', () => {
it('renders the page-comment button by default (commentSupported defaults to true)', () => {
renderChrome();
+ expect(screen.getByRole('button', { name: 'rightSidebar.browser.comment' })).toBeTruthy();
+ });
+
+ it('describes exiting comment mode while the page-comment tool is active', () => {
+ renderChrome('https://www.taptap.cn/', { commentActive: true });
+
expect(
- screen.getByRole('button', { name: 'rightSidebar.browser.comment' }),
+ screen.getByRole('button', { name: 'rightSidebar.browser.exitCommentMode' }),
).toBeTruthy();
+ expect(screen.queryByRole('button', { name: 'rightSidebar.browser.comment' })).toBeNull();
});
it('hides the page-comment button when commentSupported is false (detached sidebar window has no composer)', () => {
renderChrome('https://www.taptap.cn/', { commentSupported: false });
- expect(
- screen.queryByRole('button', { name: 'rightSidebar.browser.comment' }),
- ).toBeNull();
+ expect(screen.queryByRole('button', { name: 'rightSidebar.browser.comment' })).toBeNull();
});
it('shows a compositor-friendly refresh animation while loading and stops on click', () => {
@@ -131,9 +139,9 @@ describe('BrowserChrome', () => {
expect(spinner?.classList.contains('motion-reduce:hidden')).toBe(true);
expect(button.querySelector('.lucide-rotate-cw')).toBeTruthy();
expect(
- button.querySelector('.lucide-x')?.parentElement?.classList.contains(
- 'motion-reduce:inline-flex',
- ),
+ button
+ .querySelector('.lucide-x')
+ ?.parentElement?.classList.contains('motion-reduce:inline-flex'),
).toBe(true);
fireEvent.click(button);
@@ -155,6 +163,28 @@ describe('BrowserChrome', () => {
expect(onStop).not.toHaveBeenCalled();
});
+ it('explains why back and forward navigation are unavailable', () => {
+ renderChrome();
+
+ expect(
+ screen
+ .getByRole('button', { name: 'rightSidebar.browser.goBackUnavailable' })
+ .getAttribute('aria-disabled'),
+ ).toBe('true');
+ expect(
+ screen
+ .getByRole('button', { name: 'rightSidebar.browser.goForwardUnavailable' })
+ .getAttribute('aria-disabled'),
+ ).toBe('true');
+ });
+
+ it('uses action labels when back and forward navigation are available', () => {
+ renderChrome('https://www.taptap.cn/', { canGoBack: true, canGoForward: true });
+
+ expect(screen.getByRole('button', { name: 'rightSidebar.browser.goBack' })).toBeTruthy();
+ expect(screen.getByRole('button', { name: 'rightSidebar.browser.goForward' })).toBeTruthy();
+ });
+
it('routes the refresh spinner through the approved semantic cycle token', () => {
const animation = (
tailwindConfig.theme?.extend?.animation as Record<string, string> | undefined
@@ -171,9 +201,7 @@ describe('BrowserChrome', () => {
fireEvent.click(
screen.getByRole('button', { name: 'rightSidebar.browser.openInSystemBrowser' }),
);
- fireEvent.click(
- screen.getByRole('button', { name: 'rightSidebar.browser.copyLink' }),
- );
+ fireEvent.click(screen.getByRole('button', { name: 'rightSidebar.browser.copyLink' }));
expect(onOpenInSystemBrowser).toHaveBeenCalledTimes(1);
expect(onCopyLink).toHaveBeenCalledTimes(1);
diff --git a/apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/__tests__/BrowserCommentPopover.test.tsx b/apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/__tests__/BrowserCommentPopover.test.tsx
index d54f639535..fb89ee049c 100644
--- a/apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/__tests__/BrowserCommentPopover.test.tsx
+++ b/apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/__tests__/BrowserCommentPopover.test.tsx
@@ -21,11 +21,13 @@ const EMPTY_DRAFT: BrowserCommentEditorDraft = {
function ControlledPopover({
initialDraft = EMPTY_DRAFT,
designBaseline = null,
+ submitting = false,
onEditorDraftChange = vi.fn(),
onPreviewDesign = vi.fn(),
}: {
initialDraft?: BrowserCommentEditorDraft;
designBaseline?: BrowserCommentDesignBaseline | null;
+ submitting?: boolean;
onEditorDraftChange?: (draft: BrowserCommentEditorDraft) => void;
onPreviewDesign?: (payload: { styles: Record<string, string>; text: string | null }) => void;
}) {
@@ -34,7 +36,7 @@ function ControlledPopover({
<div>
<BrowserCommentPopover
anchor={{ x: 120, y: 80 }}
- submitting={false}
+ submitting={submitting}
designBaseline={designBaseline}
editorDraft={draft}
onEditorDraftChange={(next) => {
@@ -86,7 +88,7 @@ describe('BrowserCommentPopover', () => {
/>,
);
- fireEvent.click(screen.getByRole('button', { name: 'rightSidebar.browser.styleTweaks' }));
+ fireEvent.click(screen.getByRole('button', { name: 'rightSidebar.browser.styleTweaksExpand' }));
fireEvent.change(screen.getByDisplayValue('Save'), {
target: { value: 'Save changes' },
});
@@ -102,6 +104,27 @@ describe('BrowserCommentPopover', () => {
});
});
+ it('describes the next style-toggle action and the submitting disabled reason', () => {
+ const designBaseline: BrowserCommentDesignBaseline = {
+ styles: {},
+ editableText: 'Save',
+ provenance: {},
+ };
+ const { rerender } = render(<ControlledPopover designBaseline={designBaseline} />);
+
+ fireEvent.click(screen.getByRole('button', { name: 'rightSidebar.browser.styleTweaksExpand' }));
+ expect(
+ screen.getByRole('button', { name: 'rightSidebar.browser.styleTweaksCollapse' }),
+ ).toBeTruthy();
+
+ rerender(<ControlledPopover designBaseline={designBaseline} submitting />);
+ expect(
+ screen
+ .getByRole('button', { name: 'rightSidebar.browser.styleTweaksSubmitting' })
+ .getAttribute('aria-disabled'),
+ ).toBe('true');
+ });
+
it('replays restored design edits when it binds to a replacement target', async () => {
const onPreviewDesign = vi.fn();
render(
diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.json
index 866e748b5b..bc6dbb8169 100644
--- a/apps/desktop/src/renderer/i18n/locales/en/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json
@@ -4857,7 +4857,7 @@
"titleBar": {
"menu": "Menu",
"minimize": "Minimize",
- "maximize": "Maximize",
+ "maximizeOrRestore": "Maximize or Restore Window",
"close": "Close",
"menuItems": {
"settings": "Settings",
@@ -4886,6 +4886,8 @@
},
"contentHeader": {
"toggleSidebar": "Toggle sidebar",
+ "collapseSidebar": "Collapse Sidebar",
+ "expandSidebar": "Expand Sidebar",
"collapsePanel": "Collapse",
"expandPanel": "Expand"
},
@@ -5100,6 +5102,8 @@
"rotateDevice": "Rotate Device",
"lockScreen": "Lock Screen",
"unlockScreen": "Unlock Screen",
+ "controlsUnavailable": "Simulator controls are temporarily unavailable",
+ "enterTextBeforeSending": "Enter text before sending",
"agentBusyTitle": "Agent Using This Device",
"agentBusyDescription": "Manual input is paused until the current Agent action finishes.",
"takeControl": "Take Control",
@@ -5176,19 +5180,24 @@
"urlPlaceholder": "Enter URL or search",
"goBack": "Back",
"goForward": "Forward",
+ "goBackUnavailable": "No previous page",
+ "goForwardUnavailable": "No next page",
"reload": "Reload",
"stop": "Stop loading",
"screenshot": "Screenshot",
"screenshotCopied": "Screenshot copied to clipboard",
"screenshotFailed": "Screenshot failed",
"comment": "Comment on the page",
+ "exitCommentMode": "Exit comment mode",
"commentModeHint": "Click an element or Shift-drag an area · Cmd/Ctrl-click to add instantly · Esc to exit",
"commentPlaceholder": "Describe the change you want here…",
"commentSubmit": "Add comment",
"commentCancel": "Cancel",
"commentAdded": "Comment added to the chat input",
"commentFailed": "Failed to add comment",
- "styleTweaks": "Style tweaks",
+ "styleTweaksExpand": "Show style controls",
+ "styleTweaksCollapse": "Hide style controls",
+ "styleTweaksSubmitting": "Submitting comment…",
"styleReset": "Reset",
"styleTextLabel": "Text",
"moreTools": "More",
@@ -5584,6 +5593,7 @@
"completed": "Completed",
"empty": "No background tasks in this session yet",
"stop": "Stop",
+ "stopping": "Stopping…",
"back": "Back",
"progressSummary": "{{done}}/{{total}} agents",
"tokens": "{{value}} tokens",
@@ -7446,6 +7456,7 @@
"scopeLocalSessions": "This device’s sessions",
"dialogues": "Chat",
"newDialogue": "New session",
+ "creationInProgress": "Creation is already in progress",
"dialoguesToggleExpand": "Expand Chat",
"dialoguesToggleCollapse": "Collapse Chat",
"loadingDialogues": "Loading…",
@@ -7565,6 +7576,8 @@
"hiddenCount": "{{count}} hidden",
"stopped": "Stopped",
"aria": "{{title}} automation sessions, {{count}} runs, {{attention}} pending",
+ "expand": "Expand {{title}} runs",
+ "collapse": "Collapse {{title}} runs",
"menu": {
"runNow": "Run now",
"more": "More actions",
@@ -7634,6 +7647,7 @@
"delete": "Delete selected sessions",
"clear": "Clear selection",
"archiveNone": "No selected sessions can be archived",
+ "actionInProgress": "Another action is already in progress",
"skipRunning": "{{count}} running",
"skipAttached": "{{count}} remotely controlled",
"skipNotActive": "{{count}} not active",
diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.json
index 129ba1f753..f361042362 100644
--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json
@@ -4855,7 +4855,7 @@
"titleBar": {
"menu": "メニュー",
"minimize": "最小化",
- "maximize": "最大化",
+ "maximizeOrRestore": "ウィンドウを最大化または元のサイズに戻す",
"close": "閉じる",
"menuItems": {
"settings": "設定",
@@ -4884,6 +4884,8 @@
},
"contentHeader": {
"toggleSidebar": "サイドバーを切り替え",
+ "collapseSidebar": "サイドバーを折りたたむ",
+ "expandSidebar": "サイドバーを展開",
"collapsePanel": "折りたたみ",
"expandPanel": "展開"
},
@@ -5098,6 +5100,8 @@
"rotateDevice": "デバイスを回転",
"lockScreen": "画面をロック",
"unlockScreen": "画面をロック解除",
+ "controlsUnavailable": "シミュレータの操作は一時的に使用できません",
+ "enterTextBeforeSending": "送信するテキストを入力してください",
"agentBusyTitle": "Agent がこのデバイスを使用中",
"agentBusyDescription": "現在の Agent 操作が終わるまで手動入力は一時停止されます。",
"takeControl": "操作を引き継ぐ",
@@ -5174,19 +5178,24 @@
"urlPlaceholder": "URL を入力または検索",
"goBack": "戻る",
"goForward": "進む",
+ "goBackUnavailable": "前のページはありません",
+ "goForwardUnavailable": "次のページはありません",
"reload": "再読み込み",
"stop": "読み込み停止",
"screenshot": "スクリーンショット",
"screenshotCopied": "スクリーンショットをクリップボードにコピーしました",
"screenshotFailed": "スクリーンショットに失敗しました",
"comment": "ページにコメント",
+ "exitCommentMode": "コメントモードを終了",
"commentModeHint": "要素をクリック / Shift ドラッグで範囲選択 · Cmd/Ctrl+クリックで即追加 · Esc で終了",
"commentPlaceholder": "ここをどう変えたいか記述してください…",
"commentSubmit": "コメントを追加",
"commentCancel": "キャンセル",
"commentAdded": "コメントを入力欄に追加しました",
"commentFailed": "コメントの追加に失敗しました",
- "styleTweaks": "スタイル調整",
+ "styleTweaksExpand": "スタイル調整を表示",
+ "styleTweaksCollapse": "スタイル調整を隠す",
+ "styleTweaksSubmitting": "コメントを送信中…",
"styleReset": "リセット",
"styleTextLabel": "テキスト",
"moreTools": "その他",
@@ -5582,6 +5591,7 @@
"completed": "完了",
"empty": "このセッションにバックグラウンドタスクはまだありません",
"stop": "停止",
+ "stopping": "停止中…",
"back": "戻る",
"progressSummary": "{{done}}/{{total}} Agent",
"tokens": "{{value}} tokens",
@@ -7434,6 +7444,7 @@
"scopeLocalSessions": "このデバイスのセッション",
"dialogues": "会話",
"newDialogue": "新規セッション",
+ "creationInProgress": "作成処理が進行中です",
"dialoguesToggleExpand": "会話を展開",
"dialoguesToggleCollapse": "会話を折りたたむ",
"loadingDialogues": "読み込み中…",
@@ -7553,6 +7564,8 @@
"hiddenCount": "{{count}} 件折りたたみ",
"stopped": "停止中",
"aria": "{{title}} の自動化セッション、{{count}} 回実行、{{attention}} 件対応待ち",
+ "expand": "{{title}} の実行履歴を展開",
+ "collapse": "{{title}} の実行履歴を折りたたむ",
"menu": {
"runNow": "今すぐ実行",
"more": "その他の操作",
@@ -7622,6 +7635,7 @@
"delete": "選択したセッションを削除",
"clear": "選択を解除",
"archiveNone": "選択中のセッションにアーカイブ可能な項目がありません",
+ "actionInProgress": "別の操作を処理中です",
"skipRunning": "{{count}} 件は実行中",
"skipAttached": "{{count}} 件は遠隔操作中",
"skipNotActive": "{{count}} 件はアクティブではありません",
diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.json
index 7adbf3151c..a3e7016a51 100644
--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json
@@ -4855,7 +4855,7 @@
"titleBar": {
"menu": "메뉴",
"minimize": "최소화",
- "maximize": "최대화",
+ "maximizeOrRestore": "창 최대화 또는 복원",
"close": "닫기",
"menuItems": {
"settings": "설정",
@@ -4884,6 +4884,8 @@
},
"contentHeader": {
"toggleSidebar": "사이드바 전환",
+ "collapseSidebar": "사이드바 접기",
+ "expandSidebar": "사이드바 펼치기",
"collapsePanel": "접기",
"expandPanel": "펼치기"
},
@@ -5098,6 +5100,8 @@
"rotateDevice": "기기 회전",
"lockScreen": "화면 잠금",
"unlockScreen": "화면 잠금 해제",
+ "controlsUnavailable": "시뮬레이터 제어를 일시적으로 사용할 수 없습니다",
+ "enterTextBeforeSending": "보낼 텍스트를 먼저 입력하세요",
"agentBusyTitle": "Agent가 이 기기를 사용 중",
"agentBusyDescription": "현재 Agent 작업이 끝날 때까지 수동 입력이 일시 중지됩니다.",
"takeControl": "기기 제어권 가져오기",
@@ -5174,19 +5178,24 @@
"urlPlaceholder": "URL 입력 또는 검색",
"goBack": "뒤로",
"goForward": "앞으로",
+ "goBackUnavailable": "이전 페이지가 없습니다",
+ "goForwardUnavailable": "다음 페이지가 없습니다",
"reload": "새로 고침",
"stop": "로드 중지",
"screenshot": "스크린샷",
"screenshotCopied": "스크린샷을 클립보드에 복사했습니다",
"screenshotFailed": "스크린샷에 실패했습니다",
"comment": "페이지에 코멘트",
+ "exitCommentMode": "코멘트 모드 종료",
"commentModeHint": "요소 클릭 / Shift 드래그로 영역 선택 · Cmd/Ctrl+클릭 시 바로 추가 · Esc로 종료",
"commentPlaceholder": "여기를 어떻게 바꿀지 설명하세요…",
"commentSubmit": "코멘트 추가",
"commentCancel": "취소",
"commentAdded": "코멘트를 입력창에 추가했습니다",
"commentFailed": "코멘트 추가에 실패했습니다",
- "styleTweaks": "스타일 조정",
+ "styleTweaksExpand": "스타일 조정 열기",
+ "styleTweaksCollapse": "스타일 조정 닫기",
+ "styleTweaksSubmitting": "코멘트 제출 중…",
"styleReset": "재설정",
"styleTextLabel": "텍스트",
"moreTools": "더 보기",
@@ -5582,6 +5591,7 @@
"completed": "완료",
"empty": "이 세션에는 아직 백그라운드 작업이 없습니다",
"stop": "중지",
+ "stopping": "중지 중…",
"back": "뒤로",
"progressSummary": "{{done}}/{{total}} Agent",
"tokens": "{{value}} tokens",
@@ -7434,6 +7444,7 @@
"scopeLocalSessions": "이 기기의 세션",
"dialogues": "대화",
"newDialogue": "새 세션",
+ "creationInProgress": "생성이 이미 진행 중입니다",
"dialoguesToggleExpand": "대화 펼치기",
"dialoguesToggleCollapse": "대화 접기",
"loadingDialogues": "불러오는 중…",
@@ -7553,6 +7564,8 @@
"hiddenCount": "{{count}}개 접힘",
"stopped": "중지됨",
"aria": "{{title}} 자동화 세션, {{count}}회 실행, {{attention}}개 대기",
+ "expand": "{{title}} 실행 기록 펼치기",
+ "collapse": "{{title}} 실행 기록 접기",
"menu": {
"runNow": "지금 실행",
"more": "추가 작업",
@@ -7622,6 +7635,7 @@
"delete": "선택한 세션 삭제",
"clear": "선택 해제",
"archiveNone": "선택한 세션 중 보관할 수 있는 항목이 없습니다",
+ "actionInProgress": "다른 작업을 처리하는 중입니다",
"skipRunning": "{{count}}개 실행 중",
"skipAttached": "{{count}}개 원격 인계 중",
"skipNotActive": "{{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 75ef7967ed..f7684e9027 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
@@ -4855,7 +4855,7 @@
"titleBar": {
"menu": "菜单",
"minimize": "最小化",
- "maximize": "最大化",
+ "maximizeOrRestore": "最大化或还原窗口",
"close": "关闭",
"menuItems": {
"settings": "设置",
@@ -4884,6 +4884,8 @@
},
"contentHeader": {
"toggleSidebar": "切换侧边栏",
+ "collapseSidebar": "收起侧边栏",
+ "expandSidebar": "展开侧边栏",
"collapsePanel": "收起",
"expandPanel": "展开"
},
@@ -5098,6 +5100,8 @@
"rotateDevice": "旋转设备",
"lockScreen": "锁定屏幕",
"unlockScreen": "解锁屏幕",
+ "controlsUnavailable": "模拟器控制暂时不可用",
+ "enterTextBeforeSending": "请先输入要发送的文本",
"agentBusyTitle": "Agent 正在使用此设备",
"agentBusyDescription": "当前 Agent 操作结束前,手动输入已暂停。",
"takeControl": "接管设备",
@@ -5174,19 +5178,24 @@
"urlPlaceholder": "输入网址或搜索关键词",
"goBack": "后退",
"goForward": "前进",
+ "goBackUnavailable": "没有可后退的页面",
+ "goForwardUnavailable": "没有可前进的页面",
"reload": "刷新",
"stop": "停止加载",
"screenshot": "截图",
"screenshotCopied": "已复制截图到剪贴板",
"screenshotFailed": "截图失败",
"comment": "页面评论",
+ "exitCommentMode": "退出评论模式",
"commentModeHint": "点击元素或 Shift 拖拽框选区域 · Cmd/Ctrl+点击直接添加 · Esc 退出",
"commentPlaceholder": "描述这里需要怎么改…",
"commentSubmit": "添加评论",
"commentCancel": "取消",
"commentAdded": "评论已添加到输入框",
"commentFailed": "评论添加失败",
- "styleTweaks": "样式调整",
+ "styleTweaksExpand": "展开样式调整",
+ "styleTweaksCollapse": "收起样式调整",
+ "styleTweaksSubmitting": "正在提交评论…",
"styleReset": "重置",
"styleTextLabel": "文本",
"moreTools": "更多",
@@ -5582,6 +5591,7 @@
"completed": "已完成",
"empty": "本任务暂无后台作业",
"stop": "停止",
+ "stopping": "正在停止…",
"back": "返回",
"progressSummary": "{{done}}/{{total}} Agent",
"tokens": "{{value}} tokens",
@@ -7434,6 +7444,7 @@
"scopeLocalSessions": "本机任务",
"dialogues": "对话",
"newDialogue": "新任务",
+ "creationInProgress": "正在创建,请稍候",
"dialoguesToggleExpand": "展开对话",
"dialoguesToggleCollapse": "收起对话",
"loadingDialogues": "加载中…",
@@ -7553,6 +7564,8 @@
"hiddenCount": "{{count}} 已收起",
"stopped": "已停止",
"aria": "{{title}} 自动化生成的任务,{{count}} 次运行,{{attention}} 个待处理",
+ "expand": "展开 {{title}} 的运行记录",
+ "collapse": "收起 {{title}} 的运行记录",
"menu": {
"runNow": "立即运行",
"more": "更多操作",
@@ -7622,6 +7635,7 @@
"delete": "删除所选任务",
"clear": "清除选择",
"archiveNone": "所选任务没有可归档项",
+ "actionInProgress": "正在处理另一项操作",
"skipRunning": "{{count}} 个运行中",
"skipAttached": "{{count}} 个远程接管中",
"skipNotActive": "{{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 11f686ebf9..9aee62c273 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
@@ -4855,7 +4855,7 @@
"titleBar": {
"menu": "選單",
"minimize": "最小化",
- "maximize": "最大化",
+ "maximizeOrRestore": "最大化或還原視窗",
"close": "關閉",
"menuItems": {
"settings": "設定",
@@ -4884,6 +4884,8 @@
},
"contentHeader": {
"toggleSidebar": "切換側邊欄",
+ "collapseSidebar": "收起側邊欄",
+ "expandSidebar": "展開側邊欄",
"collapsePanel": "收起",
"expandPanel": "展開"
},
@@ -5098,6 +5100,8 @@
"rotateDevice": "旋转裝置",
"lockScreen": "鎖定螢幕",
"unlockScreen": "解鎖螢幕",
+ "controlsUnavailable": "模擬器控制暫時不可用",
+ "enterTextBeforeSending": "請先輸入要傳送的文字",
"agentBusyTitle": "Agent 正在使用此裝置",
"agentBusyDescription": "當前 Agent 操作結束前,手动輸入已暫停。",
"takeControl": "接管裝置",
@@ -5174,19 +5178,24 @@
"urlPlaceholder": "輸入網址或搜尋關鍵詞",
"goBack": "後退",
"goForward": "前進",
+ "goBackUnavailable": "沒有可後退的頁面",
+ "goForwardUnavailable": "沒有可前進的頁面",
"reload": "重新整理",
"stop": "停止載入",
"screenshot": "截圖",
"screenshotCopied": "已複製截圖到剪貼簿",
"screenshotFailed": "截圖失敗",
"comment": "頁面評論",
+ "exitCommentMode": "退出評論模式",
"commentModeHint": "點選元素或 Shift 拖拽框選區域 · Cmd/Ctrl+點選直接新增 · Esc 退出",
"commentPlaceholder": "描述這裡需要怎麼改…",
"commentSubmit": "新增評論",
"commentCancel": "取消",
"commentAdded": "評論已新增到輸入框",
"commentFailed": "評論新增失敗",
- "styleTweaks": "樣式調整",
+ "styleTweaksExpand": "展開樣式調整",
+ "styleTweaksCollapse": "收起樣式調整",
+ "styleTweaksSubmitting": "正在提交評論…",
"styleReset": "重置",
"styleTextLabel": "文字",
"moreTools": "更多",
@@ -5582,6 +5591,7 @@
"completed": "已完成",
"empty": "本任務暫無後臺作業",
"stop": "停止",
+ "stopping": "正在停止…",
"back": "返回",
"progressSummary": "{{done}}/{{total}} Agent",
"tokens": "{{value}} tokens",
@@ -7434,6 +7444,7 @@
"scopeLocalSessions": "本機任務",
"dialogues": "對話",
"newDialogue": "新任務",
+ "creationInProgress": "正在建立,請稍候",
"dialoguesToggleExpand": "展開對話",
"dialoguesToggleCollapse": "收起對話",
"loadingDialogues": "載入中…",
@@ -7553,6 +7564,8 @@
"hiddenCount": "{{count}} 已收起",
"stopped": "已停止",
"aria": "{{title}} 自動化生成的任務,{{count}} 次執行,{{attention}} 個待處理",
+ "expand": "展開 {{title}} 的執行記錄",
+ "collapse": "收起 {{title}} 的執行記錄",
"menu": {
"runNow": "立即執行",
"more": "更多操作",
@@ -7622,6 +7635,7 @@
"delete": "刪除所選任務",
"clear": "清除選擇",
"archiveNone": "所選任務沒有可歸檔項",
+ "actionInProgress": "正在處理另一項操作",
"skipRunning": "{{count}} 個執行中",
"skipAttached": "{{count}} 個遠端接管中",
"skipNotActive": "{{count}} 個非活躍狀態",
diff --git a/docs/design-rules/DESIGN.md b/docs/design-rules/DESIGN.md
index ca08204aae..34cd143218 100644
--- a/docs/design-rules/DESIGN.md
+++ b/docs/design-rules/DESIGN.md
@@ -1013,6 +1013,36 @@ peek 有值 → 调用方跳过重验 → 链路恢复后也不再问。两端
(不变量 A,含三种错误修法各自的反例)、
`apps/desktop/src/renderer/__tests__/chatClickabilitySignal.test.ts`(源码级守卫)。
+### 14.6 Icon-only Controls and Tooltips
+
+- **Delivery contract for new and modified icon-only controls:** every icon-only interactive
+ control has two labels: a localized accessible name (`aria-label`) and a visible `Tip`.
+ Familiar glyphs, dense lists, and actions that only appear on hover are not exemptions: if
+ the control has no persistent text label, users must not have to guess what it does.
+- **Describe the action that will happen next.** Stateful controls say `Expand Sidebar` or
+ `Collapse Sidebar`, not the vague `Toggle Sidebar`; their tooltip and accessible name
+ change together. A disabled icon-only control explains why it is unavailable.
+- **Do not duplicate persistent labels.** A button that already contains a visible text
+ label normally does not need a tooltip. Decorative icons are silent and are not made
+ focusable.
+- **Tooltips supplement; they do not carry risk alone.** Destructive consequences,
+ permission requests, and other information needed before acting must remain visible in
+ the interface or confirmation flow.
+- **Desktop action controls use the shared Radix `Tip`, not native `title`.** Native `title`
+ remains acceptable for truncated persistent text, marked explicitly where the element is
+ interactive. Shared icon-button primitives own this behavior wherever possible.
+- **Windows system window controls are the narrow platform exception.** The shared
+ `WindowControls` minimize, maximize / restore, and close buttons follow familiar Windows window
+ chrome and do not require a visible `Tip`; they still expose localized accessible names. The
+ maximize toggle uses a state-independent name because the Renderer does not own the native
+ maximized state. This exception does not apply to Cindy-specific title-bar actions or panel
+ controls.
+- **Migration is incremental and guarded by surface.** Recursive regression coverage currently
+ enforces this contract for app chrome, the title bar, the left sidebar and session list, and
+ the right sidebar (`components/layout`, `components/sidebar`, `components/title-bar`,
+ `features/cc-agent/sidebar`, and `features/right-sidebar`). Legacy feature-local controls
+ outside those roots migrate when touched; their existence is not an exemption for new work.
+
## 15. CINDY Skin Family(品牌化可选 family)
> This section records the CINDY skin family; it does **not** rewrite the §1–7 default-skin rules. Values were finalized from design-stage working files (`skin-docs/10-specs/` desktop, `skin-docs/30-mobile/` mobile errata — **not in this repo**, same status as the §16 login working files) plus the user's final sign-off of 2026-07-18. Zero discretion at implementation time: within the repo, the authoritative encodings are the theme files (`cindy-light.ts` / `cindy-dark.ts`), `cindyDecisionData.ts`, and the frozen tests — this section is their prose summary.