* feat: tabbed right sidebar, context panel, floating diff comments * fix: auto-close left sidebar when context panel opens - Increase default context panel width from 520 to 600 pixels - Increase sidebar minimum width from 200 to 300 pixels - Replace collapsible component with custom button in diff view * refactoring: rework sidebars, tabs, and file tree layout - Rewrite AnimatedTabs as segment-style with sliding indicator - Upgrade SidebarFilesTree to match FilesView features (context menus, git status, file icons, CRUD dialogs, fuzzy search ranking) - Restructure FilesView header: tabs row + actions row, remove breadcrumbs - Show relative path in context panel header, track active tab - Allow left sidebar to stay open alongside context panel - Hide diff/files tabs from header on desktop (mobile-only) - Move chevron after group name in session sidebar - Compact tab heights in right sidebar and git view - Size PreviewToggleButton to match other action buttons - Remove directory loading spinner from folder icons * feat: add project icon and color customization - Enable users to assign custom icons to projects - Allow users to choose accent colors for projects - Stabilize repo status UI during project switching * feat: add scroll fade indicators to editor tabs * style: reduce spacing and icon sizes in header * style: adjust tab component padding from uniform to vertical-horizontal * feat: Add session state indicators to project tabs * feat: Enhance session status handling and improve UI responsiveness * fix: preserve upstream tracking on branch rename * fix: improve initial remote selection for pull requests - Uses saved remote name from previous session when available - Selects remote based on tracking branch when possible - Falls back to origin or first available remote * perf(diff): faster highlight, stable stacked scroll - split/unified Pierre worker pools; prefer shiki-wasm - align diff CSS line-height; disable scroll anchoring; drop WebKit compositing hacks - harden stacked pin/align (cancel on user scroll/input); prevent overscroll - make overlay scrollbar MutationObserver optional; disable for diff container * feat: handle binary files in diff view * fix: adjust project tabs layout and drag regions * style: update drag overlay visual styling * feat: enable number keys to switch projects in the sidebar * fix: recognize octet-stream as text-based MIME type * feat: add keyboard navigation to context panel * feat: add session pinning to sidebar - Pin important sessions to keep them at the top - Pinned sessions persist across browser sessions * refactor: move context usage display from chat input to header
182 lines
6.0 KiB
TypeScript
182 lines
6.0 KiB
TypeScript
import React, { useCallback, useMemo } from 'react';
|
|
import {
|
|
RiCheckboxLine,
|
|
RiCheckboxBlankLine,
|
|
RiArrowGoBackLine,
|
|
RiLoader4Line,
|
|
} from '@remixicon/react';
|
|
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';
|
|
import type { GitStatus } from '@/lib/api/types';
|
|
|
|
type ChangeDescriptor = {
|
|
code: string;
|
|
color: string;
|
|
description: string;
|
|
};
|
|
|
|
const CHANGE_DESCRIPTORS: Record<string, ChangeDescriptor> = {
|
|
'?': { code: '?', color: 'var(--status-info)', description: 'Untracked file' },
|
|
A: { code: 'A', color: 'var(--status-success)', description: 'New file' },
|
|
D: { code: 'D', color: 'var(--status-error)', description: 'Deleted file' },
|
|
R: { code: 'R', color: 'var(--status-info)', description: 'Renamed file' },
|
|
C: { code: 'C', color: 'var(--status-info)', description: 'Copied file' },
|
|
M: { code: 'M', color: 'var(--status-warning)', description: 'Modified file' },
|
|
};
|
|
|
|
const DEFAULT_DESCRIPTOR = CHANGE_DESCRIPTORS.M;
|
|
|
|
function getChangeSymbol(file: GitStatus['files'][number]): string {
|
|
const indexCode = file.index?.trim();
|
|
const workingCode = file.working_dir?.trim();
|
|
|
|
if (indexCode && indexCode !== '?') return indexCode.charAt(0);
|
|
if (workingCode) return workingCode.charAt(0);
|
|
|
|
return indexCode?.charAt(0) || workingCode?.charAt(0) || 'M';
|
|
}
|
|
|
|
function describeChange(file: GitStatus['files'][number]): ChangeDescriptor {
|
|
const symbol = getChangeSymbol(file);
|
|
return CHANGE_DESCRIPTORS[symbol] ?? DEFAULT_DESCRIPTOR;
|
|
}
|
|
|
|
interface ChangeRowProps {
|
|
file: GitStatus['files'][number];
|
|
checked: boolean;
|
|
onToggle: () => void;
|
|
onViewDiff: () => void;
|
|
onRevert: () => void;
|
|
isReverting: boolean;
|
|
stats?: { insertions: number; deletions: number };
|
|
}
|
|
|
|
export const ChangeRow = React.memo<ChangeRowProps>(function ChangeRow({
|
|
file,
|
|
checked,
|
|
onToggle,
|
|
onViewDiff,
|
|
onRevert,
|
|
isReverting,
|
|
stats,
|
|
}) {
|
|
const descriptor = useMemo(() => describeChange(file), [file]);
|
|
const indicatorLabel = descriptor.description;
|
|
const insertions = stats?.insertions ?? 0;
|
|
const deletions = stats?.deletions ?? 0;
|
|
|
|
const handleKeyDown = useCallback(
|
|
(event: React.KeyboardEvent) => {
|
|
if (event.key === ' ') {
|
|
event.preventDefault();
|
|
onToggle();
|
|
} else if (event.key === 'Enter') {
|
|
event.preventDefault();
|
|
onViewDiff();
|
|
}
|
|
},
|
|
[onToggle, onViewDiff]
|
|
);
|
|
|
|
const handleToggleClick = useCallback(
|
|
(event: React.MouseEvent) => {
|
|
event.preventDefault();
|
|
event.stopPropagation();
|
|
onToggle();
|
|
},
|
|
[onToggle]
|
|
);
|
|
|
|
const handleRevertClick = useCallback(
|
|
(event: React.MouseEvent) => {
|
|
event.preventDefault();
|
|
event.stopPropagation();
|
|
onRevert();
|
|
},
|
|
[onRevert]
|
|
);
|
|
|
|
return (
|
|
<li>
|
|
<div
|
|
className="group flex items-center gap-2 px-3 py-1.5 hover:bg-sidebar/40 cursor-pointer"
|
|
role="button"
|
|
tabIndex={0}
|
|
onClick={onViewDiff}
|
|
onKeyDown={handleKeyDown}
|
|
>
|
|
<button
|
|
type="button"
|
|
onClick={handleToggleClick}
|
|
aria-pressed={checked}
|
|
aria-label={`Select ${file.path}`}
|
|
className="flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"
|
|
>
|
|
{checked ? (
|
|
<RiCheckboxLine className="size-4 text-primary" />
|
|
) : (
|
|
<RiCheckboxBlankLine className="size-4" />
|
|
)}
|
|
</button>
|
|
<span
|
|
className="typography-micro font-semibold w-4 text-center uppercase"
|
|
style={{ color: descriptor.color }}
|
|
title={indicatorLabel}
|
|
aria-label={indicatorLabel}
|
|
>
|
|
{descriptor.code}
|
|
</span>
|
|
{(() => {
|
|
const lastSlash = file.path.lastIndexOf('/');
|
|
if (lastSlash === -1) {
|
|
return (
|
|
<span
|
|
className="flex-1 min-w-0 truncate typography-ui-label text-foreground"
|
|
style={{ direction: 'rtl', textAlign: 'left' }}
|
|
title={file.path}
|
|
>
|
|
{file.path}
|
|
</span>
|
|
);
|
|
}
|
|
const dir = file.path.slice(0, lastSlash);
|
|
const name = file.path.slice(lastSlash);
|
|
return (
|
|
<span className="flex-1 min-w-0 flex items-baseline overflow-hidden" title={file.path}>
|
|
<span
|
|
className="min-w-0 truncate typography-ui-label text-muted-foreground"
|
|
style={{ direction: 'rtl', textAlign: 'left' }}
|
|
>
|
|
{dir}
|
|
</span>
|
|
<span className="flex-shrink-0 typography-ui-label"><span className="text-muted-foreground">/</span><span className="text-foreground">{name.slice(1)}</span></span>
|
|
</span>
|
|
);
|
|
})()}
|
|
<span className="shrink-0 typography-micro">
|
|
<span style={{ color: 'var(--status-success)' }}>+{insertions}</span>
|
|
<span className="text-muted-foreground mx-0.5">/</span>
|
|
<span style={{ color: 'var(--status-error)' }}>-{deletions}</span>
|
|
</span>
|
|
<Tooltip delayDuration={200}>
|
|
<TooltipTrigger asChild>
|
|
<button
|
|
type="button"
|
|
onClick={handleRevertClick}
|
|
disabled={isReverting}
|
|
className="flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50"
|
|
aria-label={`Revert changes for ${file.path}`}
|
|
>
|
|
{isReverting ? (
|
|
<RiLoader4Line className="size-3.5 animate-spin" />
|
|
) : (
|
|
<RiArrowGoBackLine className="size-3.5" />
|
|
)}
|
|
</button>
|
|
</TooltipTrigger>
|
|
<TooltipContent sideOffset={8}>Revert changes</TooltipContent>
|
|
</Tooltip>
|
|
</div>
|
|
</li>
|
|
);
|
|
});
|