mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-05-30 00:05:33 +08:00
Compare commits
3 Commits
feature/im
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
951f58751c | ||
|
|
27e509a9b8 | ||
|
|
295bad9c00 |
@@ -1,4 +1,4 @@
|
||||
import { Check, ChevronDown, ChevronRight, Edit3, Folder, FolderOpen, Star, Trash2, X } from 'lucide-react';
|
||||
import { Check, ChevronDown, ChevronRight, Edit3, Star, Trash2, X } from 'lucide-react';
|
||||
import type { TFunction } from 'i18next';
|
||||
|
||||
import { Button } from '../../../../shared/view/ui';
|
||||
@@ -131,18 +131,28 @@ export default function SidebarProjectItem({
|
||||
>
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex min-w-0 flex-1 items-center gap-3">
|
||||
<div
|
||||
<button
|
||||
className={cn(
|
||||
'w-8 h-8 rounded-lg flex items-center justify-center transition-colors',
|
||||
isExpanded ? 'bg-primary/10' : 'bg-muted',
|
||||
'w-8 h-8 rounded-lg flex items-center justify-center active:scale-90 transition-all duration-150 border',
|
||||
isStarred
|
||||
? 'bg-yellow-500/10 dark:bg-yellow-900/30 border-yellow-200 dark:border-yellow-800'
|
||||
: 'bg-gray-500/10 dark:bg-gray-900/30 border-gray-200 dark:border-gray-800',
|
||||
)}
|
||||
onClick={(event) => {
|
||||
event.stopPropagation();
|
||||
toggleStarProject();
|
||||
}}
|
||||
title={isStarred ? t('tooltips.removeFromFavorites') : t('tooltips.addToFavorites')}
|
||||
>
|
||||
{isExpanded ? (
|
||||
<FolderOpen className="h-4 w-4 text-primary" />
|
||||
) : (
|
||||
<Folder className="h-4 w-4 text-muted-foreground" />
|
||||
)}
|
||||
</div>
|
||||
<Star
|
||||
className={cn(
|
||||
'w-4 h-4 transition-colors',
|
||||
isStarred
|
||||
? 'text-yellow-600 dark:text-yellow-400 fill-current'
|
||||
: 'text-gray-600 dark:text-gray-400',
|
||||
)}
|
||||
/>
|
||||
</button>
|
||||
|
||||
<div className="min-w-0 flex-1">
|
||||
{isEditing ? (
|
||||
@@ -212,29 +222,6 @@ export default function SidebarProjectItem({
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<button
|
||||
className={cn(
|
||||
'w-8 h-8 rounded-lg flex items-center justify-center active:scale-90 transition-all duration-150 border',
|
||||
isStarred
|
||||
? 'bg-yellow-500/10 dark:bg-yellow-900/30 border-yellow-200 dark:border-yellow-800'
|
||||
: 'bg-gray-500/10 dark:bg-gray-900/30 border-gray-200 dark:border-gray-800',
|
||||
)}
|
||||
onClick={(event) => {
|
||||
event.stopPropagation();
|
||||
toggleStarProject();
|
||||
}}
|
||||
title={isStarred ? t('tooltips.removeFromFavorites') : t('tooltips.addToFavorites')}
|
||||
>
|
||||
<Star
|
||||
className={cn(
|
||||
'w-4 h-4 transition-colors',
|
||||
isStarred
|
||||
? 'text-yellow-600 dark:text-yellow-400 fill-current'
|
||||
: 'text-gray-600 dark:text-gray-400',
|
||||
)}
|
||||
/>
|
||||
</button>
|
||||
|
||||
<button
|
||||
className="flex h-8 w-8 items-center justify-center rounded-lg border border-red-200 bg-red-500/10 active:scale-90 dark:border-red-800 dark:bg-red-900/30"
|
||||
onClick={(event) => {
|
||||
@@ -281,11 +268,28 @@ export default function SidebarProjectItem({
|
||||
onClick={selectAndToggleProject}
|
||||
>
|
||||
<div className="flex min-w-0 flex-1 items-center gap-3">
|
||||
{isExpanded ? (
|
||||
<FolderOpen className="h-4 w-4 flex-shrink-0 text-primary" />
|
||||
) : (
|
||||
<Folder className="h-4 w-4 flex-shrink-0 text-muted-foreground" />
|
||||
)}
|
||||
<div
|
||||
className={cn(
|
||||
'w-6 h-6 flex items-center justify-center rounded cursor-pointer transition-all duration-200',
|
||||
isStarred
|
||||
? 'hover:bg-yellow-50 dark:hover:bg-yellow-900/20'
|
||||
: 'opacity-40 hover:opacity-100 hover:bg-accent',
|
||||
)}
|
||||
onClick={(event) => {
|
||||
event.stopPropagation();
|
||||
toggleStarProject();
|
||||
}}
|
||||
title={isStarred ? t('tooltips.removeFromFavorites') : t('tooltips.addToFavorites')}
|
||||
>
|
||||
<Star
|
||||
className={cn(
|
||||
'w-3 h-3 transition-colors',
|
||||
isStarred
|
||||
? 'text-yellow-600 dark:text-yellow-400 fill-current'
|
||||
: 'text-muted-foreground',
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
<div className="min-w-0 flex-1 text-left">
|
||||
{isEditing ? (
|
||||
<div className="space-y-1">
|
||||
@@ -352,26 +356,6 @@ export default function SidebarProjectItem({
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<div
|
||||
className={cn(
|
||||
'w-6 h-6 opacity-0 group-hover:opacity-100 transition-all duration-200 flex items-center justify-center rounded cursor-pointer touch:opacity-100',
|
||||
isStarred ? 'hover:bg-yellow-50 dark:hover:bg-yellow-900/20 opacity-100' : 'hover:bg-accent',
|
||||
)}
|
||||
onClick={(event) => {
|
||||
event.stopPropagation();
|
||||
toggleStarProject();
|
||||
}}
|
||||
title={isStarred ? t('tooltips.removeFromFavorites') : t('tooltips.addToFavorites')}
|
||||
>
|
||||
<Star
|
||||
className={cn(
|
||||
'w-3 h-3 transition-colors',
|
||||
isStarred
|
||||
? 'text-yellow-600 dark:text-yellow-400 fill-current'
|
||||
: 'text-muted-foreground',
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
className="touch:opacity-100 flex h-6 w-6 cursor-pointer items-center justify-center rounded opacity-0 transition-all duration-200 hover:bg-accent group-hover:opacity-100"
|
||||
onClick={(event) => {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { useEffect, useRef } from 'react';
|
||||
import { Check, Edit2, Trash2, X } from 'lucide-react';
|
||||
import type { TFunction } from 'i18next';
|
||||
|
||||
import { Badge, Button } from '../../../../shared/view/ui';
|
||||
import { Badge, Button, Tooltip } from '../../../../shared/view/ui';
|
||||
import { cn } from '../../../../lib/utils';
|
||||
import type { Project, ProjectSession, LLMProvider } from '../../../../types/app';
|
||||
import type { SessionWithProvider } from '../../types/types';
|
||||
@@ -76,7 +77,28 @@ export default function SidebarSessionItem({
|
||||
}: SidebarSessionItemProps) {
|
||||
const sessionView = createSessionViewModel(session, currentTime, t);
|
||||
const isSelected = selectedSession?.id === session.id;
|
||||
const isEditing = editingSession === session.id;
|
||||
const compactSessionAge = formatCompactSessionAge(sessionView.sessionTime, currentTime);
|
||||
const editingContainerRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
// The rename panel sits inside a group-hover opacity wrapper, so leaving the row
|
||||
// would visually hide it. While editing, dismiss only when the user clicks outside
|
||||
// the panel (matches Escape / cancel-button behaviour).
|
||||
useEffect(() => {
|
||||
if (!isEditing) {
|
||||
return;
|
||||
}
|
||||
|
||||
const handlePointerDown = (event: MouseEvent) => {
|
||||
const container = editingContainerRef.current;
|
||||
if (container && !container.contains(event.target as Node)) {
|
||||
onCancelEditingSession();
|
||||
}
|
||||
};
|
||||
|
||||
document.addEventListener('mousedown', handlePointerDown);
|
||||
return () => document.removeEventListener('mousedown', handlePointerDown);
|
||||
}, [isEditing, onCancelEditingSession]);
|
||||
|
||||
// Sessions are owned by a project identified by `projectId` (DB primary key)
|
||||
// after the projectName → projectId migration.
|
||||
@@ -97,7 +119,13 @@ export default function SidebarSessionItem({
|
||||
<div className="group relative">
|
||||
{sessionView.isActive && (
|
||||
<div className="absolute left-0 top-1/2 -translate-x-1 -translate-y-1/2 transform">
|
||||
<div className="h-2 w-2 animate-pulse rounded-full bg-green-500" />
|
||||
<Tooltip content={t('tooltips.activeSessionIndicator')} position="right">
|
||||
<div
|
||||
role="status"
|
||||
aria-label={t('tooltips.activeSessionIndicator')}
|
||||
className="h-2 w-2 animate-pulse rounded-full bg-green-500"
|
||||
/>
|
||||
</Tooltip>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -168,7 +196,12 @@ export default function SidebarSessionItem({
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="truncate text-xs font-medium text-foreground">{sessionView.sessionName}</div>
|
||||
{compactSessionAge && (
|
||||
<span className="ml-auto flex-shrink-0 text-[11px] text-muted-foreground transition-opacity duration-200 group-hover:opacity-0">
|
||||
<span
|
||||
className={cn(
|
||||
'ml-auto flex-shrink-0 text-[11px] text-muted-foreground transition-opacity duration-200',
|
||||
isEditing ? 'opacity-0' : 'group-hover:opacity-0',
|
||||
)}
|
||||
>
|
||||
{compactSessionAge}
|
||||
</span>
|
||||
)}
|
||||
@@ -180,8 +213,14 @@ export default function SidebarSessionItem({
|
||||
</div>
|
||||
</Button>
|
||||
|
||||
<div className="absolute right-2 top-1/2 flex -translate-y-1/2 transform items-center gap-1 opacity-0 transition-all duration-200 group-hover:opacity-100">
|
||||
{editingSession === session.id ? (
|
||||
<div
|
||||
ref={editingContainerRef}
|
||||
className={cn(
|
||||
'absolute right-2 top-1/2 flex -translate-y-1/2 transform items-center gap-1 transition-all duration-200',
|
||||
isEditing ? 'opacity-100' : 'opacity-0 group-hover:opacity-100',
|
||||
)}
|
||||
>
|
||||
{isEditing ? (
|
||||
<>
|
||||
<input
|
||||
type="text"
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
"removeFromFavorites": "Aus Favoriten entfernen",
|
||||
"editSessionName": "Sitzungsname manuell bearbeiten",
|
||||
"deleteSession": "Diese Sitzung dauerhaft löschen",
|
||||
"activeSessionIndicator": "Kürzlich aktive Sitzung (letzte 10 Minuten)",
|
||||
"save": "Speichern",
|
||||
"cancel": "Abbrechen",
|
||||
"clearSearch": "Suche leeren",
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
"removeFromFavorites": "Remove from favorites",
|
||||
"editSessionName": "Manually edit session name",
|
||||
"deleteSession": "Delete this session permanently",
|
||||
"activeSessionIndicator": "Recently active session (last 10 minutes)",
|
||||
"save": "Save",
|
||||
"cancel": "Cancel",
|
||||
"clearSearch": "Clear search",
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
"removeFromFavorites": "Rimuovi dai preferiti",
|
||||
"editSessionName": "Modifica manualmente il nome della sessione",
|
||||
"deleteSession": "Elimina questa sessione permanentemente",
|
||||
"activeSessionIndicator": "Sessione attiva di recente (ultimi 10 minuti)",
|
||||
"save": "Salva",
|
||||
"cancel": "Annulla",
|
||||
"clearSearch": "Cancella ricerca",
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
"removeFromFavorites": "お気に入りから削除",
|
||||
"editSessionName": "セッション名を手動で編集",
|
||||
"deleteSession": "このセッションを完全に削除",
|
||||
"activeSessionIndicator": "最近アクティブなセッション(過去10分以内)",
|
||||
"save": "保存",
|
||||
"cancel": "キャンセル",
|
||||
"openCommandPalette": "コマンドパレットを開く"
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
"removeFromFavorites": "즐겨찾기에서 제거",
|
||||
"editSessionName": "세션 이름 직접 편집",
|
||||
"deleteSession": "이 세션 영구 삭제",
|
||||
"activeSessionIndicator": "최근 활성 세션 (지난 10분)",
|
||||
"save": "저장",
|
||||
"cancel": "취소",
|
||||
"openCommandPalette": "명령 팔레트 열기"
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
"removeFromFavorites": "Удалить из избранного",
|
||||
"editSessionName": "Вручную редактировать имя сеанса",
|
||||
"deleteSession": "Удалить этот сеанс навсегда",
|
||||
"activeSessionIndicator": "Недавно активный сеанс (последние 10 минут)",
|
||||
"save": "Сохранить",
|
||||
"cancel": "Отмена",
|
||||
"clearSearch": "Очистить поиск",
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
"removeFromFavorites": "Favorilerden çıkar",
|
||||
"editSessionName": "Oturum adını elle düzenle",
|
||||
"deleteSession": "Bu oturumu kalıcı olarak sil",
|
||||
"activeSessionIndicator": "Yakın zamanda etkin oturum (son 10 dakika)",
|
||||
"save": "Kaydet",
|
||||
"cancel": "İptal",
|
||||
"clearSearch": "Aramayı temizle",
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
"removeFromFavorites": "从收藏移除",
|
||||
"editSessionName": "手动编辑会话名称",
|
||||
"deleteSession": "永久删除此会话",
|
||||
"activeSessionIndicator": "最近活跃的会话(最近 10 分钟)",
|
||||
"save": "保存",
|
||||
"cancel": "取消",
|
||||
"clearSearch": "清除搜索",
|
||||
|
||||
Reference in New Issue
Block a user