Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🐛 fix(chat): align git menu trigger highlights (#20520)

Bryan7a35562fbcec
diff --git a/src/features/ChatInput/ControlBar/BranchSwitcher.tsx b/src/features/ChatInput/ControlBar/BranchSwitcher.tsx
index 9bb9123d8f6..88560d74055 100644
--- a/src/features/ChatInput/ControlBar/BranchSwitcher.tsx
+++ b/src/features/ChatInput/ControlBar/BranchSwitcher.tsx
@@ -45,6 +45,7 @@ import { gitService } from '@/services/git';
import { useFetchGitWorkingTreeStatus } from '@/store/device';
import { openCreateBranchModal } from './CreateBranchModal';
+import { gitMenuTriggerStyles } from './gitMenuTriggerStyles';
import { openRenameBranchModal } from './RenameBranchModal';
import { useSwitchWorktree } from './useSwitchWorktree';
import { findWorktreeForBranch, getPathName } from './worktreeHelpers';
@@ -55,20 +56,6 @@ const styles = createStaticStyles(({ css }) => ({
text-overflow: ellipsis;
white-space: nowrap;
`,
- triggerAnchor: css`
- display: inline-flex;
- flex: none;
- `,
- /* See WorktreeSwitcher.triggerFill — keeps a full-row custom trigger's hover
- background aligned with the popup-open background. */
- triggerFill: css`
- display: flex;
- width: 100%;
-
- > * {
- flex: 1;
- }
- `,
footer: css`
border-block-start: 1px solid ${cssVar.colorSplit};
`,
@@ -474,8 +461,8 @@ const BranchSwitcher = memo<BranchSwitcherProps>(
return (
<DropdownMenuRoot open={open} onOpenChange={onOpenChange}>
- <DropdownMenuTrigger className={styles.triggerAnchor}>
- <div className={styles.triggerFill}>{children}</div>
+ <DropdownMenuTrigger>
+ <div className={gitMenuTriggerStyles.trigger}>{children}</div>
</DropdownMenuTrigger>
<DropdownMenuPortal>
<DropdownMenuPositioner placement={placement} sideOffset={8}>
diff --git a/src/features/ChatInput/ControlBar/WorktreeSwitcher.tsx b/src/features/ChatInput/ControlBar/WorktreeSwitcher.tsx
index 2f676ec9c37..2e51ae05118 100644
--- a/src/features/ChatInput/ControlBar/WorktreeSwitcher.tsx
+++ b/src/features/ChatInput/ControlBar/WorktreeSwitcher.tsx
@@ -37,6 +37,7 @@ import { useTranslation } from 'react-i18next';
import { gitService } from '@/services/git';
import { openCreateWorktreeModal } from './CreateWorktreeModal';
+import { gitMenuTriggerStyles } from './gitMenuTriggerStyles';
import { useSwitchWorktree } from './useSwitchWorktree';
import { getPathName, isDisabled, normalizeDisplayPath } from './worktreeHelpers';
@@ -319,20 +320,6 @@ const styles = createStaticStyles(({ css }) => ({
background: ${cssVar.colorFillTertiary};
}
`,
- triggerAnchor: css`
- display: inline-flex;
- flex: none;
- `,
- /* Custom row triggers (overview panel) must fill the stretched trigger, or the
- popup-open background paints wider than the row's own hover background. */
- triggerFill: css`
- display: flex;
- width: 100%;
-
- > * {
- flex: 1;
- }
- `,
}));
const TEMP_PATH_PREFIXES = ['/tmp', '/var/tmp', '/private/tmp'];
@@ -646,8 +633,8 @@ const WorktreeSwitcher = memo<WorktreeSwitcherProps>(
return (
<DropdownMenuRoot open={open} onOpenChange={setOpen}>
- <DropdownMenuTrigger className={styles.triggerAnchor}>
- <div className={children ? styles.triggerFill : undefined}>
+ <DropdownMenuTrigger>
+ <div className={gitMenuTriggerStyles.trigger}>
{open ? trigger : <Tooltip title={triggerTitle}>{trigger}</Tooltip>}
</div>
</DropdownMenuTrigger>
diff --git a/src/features/ChatInput/ControlBar/gitMenuTriggerStyles.ts b/src/features/ChatInput/ControlBar/gitMenuTriggerStyles.ts
new file mode 100644
index 00000000000..097cc970818
--- /dev/null
+++ b/src/features/ChatInput/ControlBar/gitMenuTriggerStyles.ts
@@ -0,0 +1,26 @@
+import { createStaticStyles, cssVar } from 'antd-style';
+
+export const gitMenuTriggerStyles = createStaticStyles(({ css }) => ({
+ trigger: css`
+ display: inline-flex;
+ flex: none;
+ min-width: 0;
+
+ /* The stable menu anchor must not paint behind the child's rounded chip or
+ overview row. Keep hover and popup-open feedback on that same surface. */
+ &&&[data-popup-open] {
+ background: transparent;
+ }
+
+ /* A column host stretches the anchor for overview rows; compact composer
+ chips use their intrinsic width instead of 100% of the whole git group. */
+ && > * {
+ flex: 1;
+ min-width: 0;
+ }
+
+ &[data-popup-open] > * {
+ background: ${cssVar.colorFillTertiary};
+ }
+ `,
+}));