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

View file

@ -20,7 +20,7 @@ interface TabBarProps {
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 overflows after growing, snap to the right edge so the new tab is visible.
function nextTabListScrollLeft(input: {
@ -66,9 +66,8 @@ export function TabBar({
[closeTab, onTabSwitch]
);
// React to tab list growth (port of opencode's createFileTabListSync).
// Uses a MutationObserver instead of a tab-id effect so the scroll catches
// the moment the new tab is added to the DOM, not after activation lands.
// React to tab list growth via a MutationObserver so the scroll catches the
// moment a new tab is added to the DOM, not after activation lands.
// Also remaps vertical wheel motion to horizontal scroll.
useEffect(() => {
const el = scrollRef.current;
@ -195,8 +194,7 @@ export function TabBar({
<div
className={cn(
// Solid bg + soft left-fade so tabs scrolling underneath the
// + button get visually masked into the bar's background —
// 1:1 port of opencode's `> .sticky` rule in tabs.css.
// + button get visually masked into the bar's background.
"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:bg-gradient-to-r before:from-transparent before:to-main-panel"