Polish AI notes send controls in diff headers (#2551)
This commit is contained in:
@@ -723,6 +723,8 @@
|
||||
|
||||
.editor-header-path {
|
||||
display: block;
|
||||
min-width: 0;
|
||||
flex: 0 1 auto;
|
||||
padding: 0;
|
||||
max-width: 100%;
|
||||
border: none;
|
||||
|
||||
@@ -40,7 +40,7 @@ import type {
|
||||
GitDiffResult,
|
||||
GitStatusEntry
|
||||
} from '../../../../shared/types'
|
||||
import { Check, Copy, MessageSquare, PanelLeftOpen, Trash2 } from 'lucide-react'
|
||||
import { Check, Copy, MessageSquare, PanelLeftOpen, Sparkles, Trash2 } from 'lucide-react'
|
||||
import { toast } from 'sonner'
|
||||
import { DiffSectionItem } from './DiffSectionItem'
|
||||
import { DiffNotesSendMenu } from './DiffNotesSendMenu'
|
||||
@@ -1055,17 +1055,19 @@ export default function CombinedDiffViewer({
|
||||
{isCommitMode && commitCompare ? ` in ${commitCompare.compareRef}` : ''}
|
||||
</span>
|
||||
{diffCommentCount > 0 && (
|
||||
<div className="ml-2 flex shrink-0 items-center overflow-hidden rounded-md border border-border/60 bg-muted/20">
|
||||
<div className="ml-1 flex shrink-0 items-center overflow-hidden rounded-full border border-border/70 bg-muted/40">
|
||||
<Popover>
|
||||
<PopoverTrigger asChild>
|
||||
<button
|
||||
type="button"
|
||||
className="inline-flex h-7 items-center gap-1 px-2 text-[11px] leading-none text-muted-foreground transition-colors hover:bg-accent hover:text-foreground"
|
||||
className="inline-flex h-6 items-center gap-1 pl-2 pr-1.5 text-[11px] font-medium leading-none text-foreground/80 transition-colors hover:bg-accent hover:text-foreground"
|
||||
aria-label={`Show ${diffCommentCount} AI ${diffCommentCount === 1 ? 'note' : 'notes'}`}
|
||||
>
|
||||
<MessageSquare className="size-3" />
|
||||
AI notes
|
||||
<span className="tabular-nums">{diffCommentCount}</span>
|
||||
<Sparkles className="size-3 text-violet-500 dark:text-violet-400" />
|
||||
<span>AI notes</span>
|
||||
<span className="rounded-full bg-background/80 px-1 text-[10px] tabular-nums text-muted-foreground">
|
||||
{diffCommentCount}
|
||||
</span>
|
||||
</button>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent align="start" side="bottom" sideOffset={6} className="w-80 p-0">
|
||||
@@ -1082,7 +1084,8 @@ export default function CombinedDiffViewer({
|
||||
worktreeId={file.worktreeId}
|
||||
groupId={activeGroupId ?? file.worktreeId}
|
||||
comments={diffCommentsForWorktree}
|
||||
triggerClassName="h-7 rounded-none border-l border-border/60 px-2"
|
||||
actionLabel="Send"
|
||||
triggerClassName="h-6 gap-1 rounded-none border-l border-border/70 px-2 text-[11px] font-medium leading-none text-foreground/80 hover:bg-accent hover:text-foreground"
|
||||
iconClassName="size-3"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { useMemo } from 'react'
|
||||
import { Send } from 'lucide-react'
|
||||
import { Send, Sparkles } from 'lucide-react'
|
||||
import type { DiffComment } from '../../../../shared/types'
|
||||
import { useAppStore } from '@/store'
|
||||
import {
|
||||
@@ -24,6 +24,9 @@ export function DiffNotesSendMenu({
|
||||
filePath,
|
||||
showFileScope = false,
|
||||
triggerClassName,
|
||||
triggerLabel,
|
||||
triggerCount,
|
||||
actionLabel,
|
||||
iconClassName = 'size-3.5',
|
||||
align = 'end'
|
||||
}: {
|
||||
@@ -33,6 +36,9 @@ export function DiffNotesSendMenu({
|
||||
filePath?: string
|
||||
showFileScope?: boolean
|
||||
triggerClassName?: string
|
||||
triggerLabel?: string
|
||||
triggerCount?: number
|
||||
actionLabel?: string
|
||||
iconClassName?: string
|
||||
align?: 'start' | 'center' | 'end'
|
||||
}): React.JSX.Element {
|
||||
@@ -65,10 +71,25 @@ export function DiffNotesSendMenu({
|
||||
triggerClassName
|
||||
)}
|
||||
disabled={!hasUnsentNotes}
|
||||
aria-label="Send notes to a new agent"
|
||||
aria-label={
|
||||
triggerLabel ? `Send ${triggerLabel} to a new agent` : 'Send notes to a new agent'
|
||||
}
|
||||
onClick={(event) => event.stopPropagation()}
|
||||
>
|
||||
{triggerLabel ? (
|
||||
<>
|
||||
<Sparkles className="size-3 text-violet-500 dark:text-violet-400" />
|
||||
<span className="whitespace-nowrap">{triggerLabel}</span>
|
||||
{triggerCount !== undefined ? (
|
||||
<span className="rounded-full bg-background/80 px-1 text-[10px] tabular-nums text-muted-foreground">
|
||||
{triggerCount}
|
||||
</span>
|
||||
) : null}
|
||||
<span className="mx-0.5 h-3 w-px bg-border/70" aria-hidden />
|
||||
</>
|
||||
) : null}
|
||||
<Send className={iconClassName} />
|
||||
{actionLabel ? <span className="whitespace-nowrap">{actionLabel}</span> : null}
|
||||
</button>
|
||||
</DropdownMenuTrigger>
|
||||
</TooltipTrigger>
|
||||
@@ -81,11 +102,11 @@ export function DiffNotesSendMenu({
|
||||
<>
|
||||
<DropdownMenuLabel>Send notes</DropdownMenuLabel>
|
||||
<DropdownMenuSub>
|
||||
<DropdownMenuSubTrigger disabled={unsentFileNotes.length === 0}>
|
||||
This file
|
||||
<span className="ml-auto text-[11px] tabular-nums text-muted-foreground">
|
||||
{unsentFileNotes.length}
|
||||
</span>
|
||||
<DropdownMenuSubTrigger
|
||||
disabled={unsentFileNotes.length === 0}
|
||||
className="[&>svg:last-child]:ml-0"
|
||||
>
|
||||
<NoteScopeMenuRow label="This file" count={unsentFileNotes.length} />
|
||||
</DropdownMenuSubTrigger>
|
||||
<DropdownMenuSubContent className="min-w-[180px]">
|
||||
<QuickLaunchAgentMenuItems
|
||||
@@ -100,11 +121,11 @@ export function DiffNotesSendMenu({
|
||||
</DropdownMenuSubContent>
|
||||
</DropdownMenuSub>
|
||||
<DropdownMenuSub>
|
||||
<DropdownMenuSubTrigger disabled={unsentNotes.length === 0}>
|
||||
All unsent notes
|
||||
<span className="ml-auto text-[11px] tabular-nums text-muted-foreground">
|
||||
{unsentNotes.length}
|
||||
</span>
|
||||
<DropdownMenuSubTrigger
|
||||
disabled={unsentNotes.length === 0}
|
||||
className="[&>svg:last-child]:ml-0"
|
||||
>
|
||||
<NoteScopeMenuRow label="All unsent notes" count={unsentNotes.length} />
|
||||
</DropdownMenuSubTrigger>
|
||||
<DropdownMenuSubContent className="min-w-[180px]">
|
||||
<QuickLaunchAgentMenuItems
|
||||
@@ -134,3 +155,12 @@ export function DiffNotesSendMenu({
|
||||
</DropdownMenu>
|
||||
)
|
||||
}
|
||||
|
||||
function NoteScopeMenuRow({ label, count }: { label: string; count: number }): React.JSX.Element {
|
||||
return (
|
||||
<span className="grid min-w-0 flex-1 grid-cols-[minmax(0,1fr)_auto] items-center gap-3">
|
||||
<span className="truncate">{label}</span>
|
||||
<span className="text-[11px] tabular-nums text-muted-foreground">{count}</span>
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import {
|
||||
Columns2,
|
||||
Copy,
|
||||
@@ -108,6 +108,10 @@ export function EditorPanelHeader({
|
||||
const headerCopyState = getEditorHeaderCopyState(activeFile)
|
||||
const diffComments = useAppStore((s) => s.getDiffComments(activeFile.worktreeId))
|
||||
const activeGroupId = useAppStore((s) => s.activeGroupIdByWorktree[activeFile.worktreeId])
|
||||
const fileDiffComments = useMemo(
|
||||
() => diffComments.filter((comment) => comment.filePath === activeFile.relativePath),
|
||||
[activeFile.relativePath, diffComments]
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
const closeMenu = (): void => setPathMenuOpen(false)
|
||||
@@ -208,14 +212,17 @@ export function EditorPanelHeader({
|
||||
</Tooltip>
|
||||
</TooltipProvider>
|
||||
)}
|
||||
{isSingleDiff && diffComments.length > 0 && (
|
||||
{isSingleDiff && fileDiffComments.length > 0 && (
|
||||
<DiffNotesSendMenu
|
||||
worktreeId={activeFile.worktreeId}
|
||||
groupId={activeGroupId ?? activeFile.worktreeId}
|
||||
comments={diffComments}
|
||||
filePath={activeFile.relativePath}
|
||||
showFileScope
|
||||
triggerClassName="p-1 flex-shrink-0"
|
||||
triggerLabel="AI notes"
|
||||
triggerCount={fileDiffComments.length}
|
||||
triggerClassName="h-6 shrink-0 gap-1 rounded-full border border-border/70 bg-muted/40 px-2 text-[11px] font-medium leading-none text-foreground/80 hover:bg-accent hover:text-foreground"
|
||||
iconClassName="size-3"
|
||||
/>
|
||||
)}
|
||||
{canOpenPreviewToSide && (
|
||||
|
||||
Reference in New Issue
Block a user