refactor(icon-rail, tabs): remove unused separators and improve comments for clarity in SearchSpaceAvatar and TabBar components

This commit is contained in:
Anish Sarkar 2026-05-03 18:56:58 +05:30
parent 89beced3c0
commit 3eb1cc9cf6
2 changed files with 6 additions and 12 deletions

View file

@ -7,14 +7,12 @@ import {
ContextMenu, ContextMenu,
ContextMenuContent, ContextMenuContent,
ContextMenuItem, ContextMenuItem,
ContextMenuSeparator,
ContextMenuTrigger, ContextMenuTrigger,
} from "@/components/ui/context-menu"; } from "@/components/ui/context-menu";
import { import {
DropdownMenu, DropdownMenu,
DropdownMenuContent, DropdownMenuContent,
DropdownMenuItem, DropdownMenuItem,
DropdownMenuSeparator,
DropdownMenuTrigger, DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu"; } from "@/components/ui/dropdown-menu";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip"; import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
@ -157,7 +155,6 @@ export function SearchSpaceAvatar({
{tCommon("settings")} {tCommon("settings")}
</DropdownMenuItem> </DropdownMenuItem>
)} )}
{onSettings && onDelete && <DropdownMenuSeparator />}
{onDelete && isOwner && ( {onDelete && isOwner && (
<DropdownMenuItem onClick={onDelete}> <DropdownMenuItem onClick={onDelete}>
<Trash2 className="mr-2 h-4 w-4" /> <Trash2 className="mr-2 h-4 w-4" />
@ -190,7 +187,7 @@ export function SearchSpaceAvatar({
{avatarButton} {avatarButton}
</div> </div>
</DropdownMenuTrigger> </DropdownMenuTrigger>
<DropdownMenuContent className="w-48">{menuItems}</DropdownMenuContent> <DropdownMenuContent>{menuItems}</DropdownMenuContent>
</DropdownMenu> </DropdownMenu>
); );
} }
@ -208,14 +205,13 @@ export function SearchSpaceAvatar({
{tooltipContent} {tooltipContent}
</TooltipContent> </TooltipContent>
</Tooltip> </Tooltip>
<ContextMenuContent className="w-48"> <ContextMenuContent>
{onSettings && ( {onSettings && (
<ContextMenuItem onClick={onSettings}> <ContextMenuItem onClick={onSettings}>
<Settings className="mr-2 h-4 w-4" /> <Settings className="mr-2 h-4 w-4" />
{tCommon("settings")} {tCommon("settings")}
</ContextMenuItem> </ContextMenuItem>
)} )}
{onSettings && onDelete && <ContextMenuSeparator />}
{onDelete && isOwner && ( {onDelete && isOwner && (
<ContextMenuItem onClick={onDelete}> <ContextMenuItem onClick={onDelete}>
<Trash2 className="mr-2 h-4 w-4" /> <Trash2 className="mr-2 h-4 w-4" />

View file

@ -20,7 +20,7 @@ interface TabBarProps {
className?: string; className?: string;
} }
// Pure scroll-target calculation (port of opencode's nextTabListScrollLeft). // Pure scroll-target calculation for the tab list.
// - When the list shrinks (a tab was closed), do not move the scroll. // - When the list shrinks (a tab was closed), do not move the scroll.
// - When the list overflows after growing, snap to the right edge so the new tab is visible. // - When the list overflows after growing, snap to the right edge so the new tab is visible.
function nextTabListScrollLeft(input: { function nextTabListScrollLeft(input: {
@ -66,9 +66,8 @@ export function TabBar({
[closeTab, onTabSwitch] [closeTab, onTabSwitch]
); );
// React to tab list growth (port of opencode's createFileTabListSync). // React to tab list growth via a MutationObserver so the scroll catches the
// Uses a MutationObserver instead of a tab-id effect so the scroll catches // moment a new tab is added to the DOM, not after activation lands.
// the moment the new tab is added to the DOM, not after activation lands.
// Also remaps vertical wheel motion to horizontal scroll. // Also remaps vertical wheel motion to horizontal scroll.
useEffect(() => { useEffect(() => {
const el = scrollRef.current; const el = scrollRef.current;
@ -195,8 +194,7 @@ export function TabBar({
<div <div
className={cn( className={cn(
// Solid bg + soft left-fade so tabs scrolling underneath the // Solid bg + soft left-fade so tabs scrolling underneath the
// + button get visually masked into the bar's background — // + button get visually masked into the bar's background.
// 1:1 port of opencode's `> .sticky` rule in tabs.css.
"sticky right-0 z-10 flex h-full shrink-0 items-center bg-main-panel pl-3 pr-1", "sticky right-0 z-10 flex h-full shrink-0 items-center bg-main-panel pl-3 pr-1",
"before:content-[''] before:absolute before:inset-y-0 before:-left-4 before:w-4 before:pointer-events-none", "before:content-[''] before:absolute before:inset-y-0 before:-left-4 before:w-4 before:pointer-events-none",
"before:bg-gradient-to-r before:from-transparent before:to-main-panel" "before:bg-gradient-to-r before:from-transparent before:to-main-panel"