mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-05-30 08:15:31 +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 type { TFunction } from 'i18next';
|
||||||
|
|
||||||
import { Button } from '../../../../shared/view/ui';
|
import { Button } from '../../../../shared/view/ui';
|
||||||
@@ -131,18 +131,28 @@ export default function SidebarProjectItem({
|
|||||||
>
|
>
|
||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between">
|
||||||
<div className="flex min-w-0 flex-1 items-center gap-3">
|
<div className="flex min-w-0 flex-1 items-center gap-3">
|
||||||
<div
|
<button
|
||||||
className={cn(
|
className={cn(
|
||||||
'w-8 h-8 rounded-lg flex items-center justify-center transition-colors',
|
'w-8 h-8 rounded-lg flex items-center justify-center active:scale-90 transition-all duration-150 border',
|
||||||
isExpanded ? 'bg-primary/10' : 'bg-muted',
|
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 ? (
|
<Star
|
||||||
<FolderOpen className="h-4 w-4 text-primary" />
|
className={cn(
|
||||||
) : (
|
'w-4 h-4 transition-colors',
|
||||||
<Folder className="h-4 w-4 text-muted-foreground" />
|
isStarred
|
||||||
|
? 'text-yellow-600 dark:text-yellow-400 fill-current'
|
||||||
|
: 'text-gray-600 dark:text-gray-400',
|
||||||
)}
|
)}
|
||||||
</div>
|
/>
|
||||||
|
</button>
|
||||||
|
|
||||||
<div className="min-w-0 flex-1">
|
<div className="min-w-0 flex-1">
|
||||||
{isEditing ? (
|
{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
|
<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"
|
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) => {
|
onClick={(event) => {
|
||||||
@@ -281,11 +268,28 @@ export default function SidebarProjectItem({
|
|||||||
onClick={selectAndToggleProject}
|
onClick={selectAndToggleProject}
|
||||||
>
|
>
|
||||||
<div className="flex min-w-0 flex-1 items-center gap-3">
|
<div className="flex min-w-0 flex-1 items-center gap-3">
|
||||||
{isExpanded ? (
|
<div
|
||||||
<FolderOpen className="h-4 w-4 flex-shrink-0 text-primary" />
|
className={cn(
|
||||||
) : (
|
'w-6 h-6 flex items-center justify-center rounded cursor-pointer transition-all duration-200',
|
||||||
<Folder className="h-4 w-4 flex-shrink-0 text-muted-foreground" />
|
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">
|
<div className="min-w-0 flex-1 text-left">
|
||||||
{isEditing ? (
|
{isEditing ? (
|
||||||
<div className="space-y-1">
|
<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
|
<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"
|
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) => {
|
onClick={(event) => {
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
|
import { useEffect, useRef } from 'react';
|
||||||
import { Check, Edit2, Trash2, X } from 'lucide-react';
|
import { Check, Edit2, Trash2, X } from 'lucide-react';
|
||||||
import type { TFunction } from 'i18next';
|
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 { cn } from '../../../../lib/utils';
|
||||||
import type { Project, ProjectSession, LLMProvider } from '../../../../types/app';
|
import type { Project, ProjectSession, LLMProvider } from '../../../../types/app';
|
||||||
import type { SessionWithProvider } from '../../types/types';
|
import type { SessionWithProvider } from '../../types/types';
|
||||||
@@ -76,7 +77,28 @@ export default function SidebarSessionItem({
|
|||||||
}: SidebarSessionItemProps) {
|
}: SidebarSessionItemProps) {
|
||||||
const sessionView = createSessionViewModel(session, currentTime, t);
|
const sessionView = createSessionViewModel(session, currentTime, t);
|
||||||
const isSelected = selectedSession?.id === session.id;
|
const isSelected = selectedSession?.id === session.id;
|
||||||
|
const isEditing = editingSession === session.id;
|
||||||
const compactSessionAge = formatCompactSessionAge(sessionView.sessionTime, currentTime);
|
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)
|
// Sessions are owned by a project identified by `projectId` (DB primary key)
|
||||||
// after the projectName → projectId migration.
|
// after the projectName → projectId migration.
|
||||||
@@ -97,7 +119,13 @@ export default function SidebarSessionItem({
|
|||||||
<div className="group relative">
|
<div className="group relative">
|
||||||
{sessionView.isActive && (
|
{sessionView.isActive && (
|
||||||
<div className="absolute left-0 top-1/2 -translate-x-1 -translate-y-1/2 transform">
|
<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>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
@@ -168,7 +196,12 @@ export default function SidebarSessionItem({
|
|||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<div className="truncate text-xs font-medium text-foreground">{sessionView.sessionName}</div>
|
<div className="truncate text-xs font-medium text-foreground">{sessionView.sessionName}</div>
|
||||||
{compactSessionAge && (
|
{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}
|
{compactSessionAge}
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
@@ -180,8 +213,14 @@ export default function SidebarSessionItem({
|
|||||||
</div>
|
</div>
|
||||||
</Button>
|
</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">
|
<div
|
||||||
{editingSession === session.id ? (
|
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
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
|
|||||||
@@ -45,6 +45,7 @@
|
|||||||
"removeFromFavorites": "Aus Favoriten entfernen",
|
"removeFromFavorites": "Aus Favoriten entfernen",
|
||||||
"editSessionName": "Sitzungsname manuell bearbeiten",
|
"editSessionName": "Sitzungsname manuell bearbeiten",
|
||||||
"deleteSession": "Diese Sitzung dauerhaft löschen",
|
"deleteSession": "Diese Sitzung dauerhaft löschen",
|
||||||
|
"activeSessionIndicator": "Kürzlich aktive Sitzung (letzte 10 Minuten)",
|
||||||
"save": "Speichern",
|
"save": "Speichern",
|
||||||
"cancel": "Abbrechen",
|
"cancel": "Abbrechen",
|
||||||
"clearSearch": "Suche leeren",
|
"clearSearch": "Suche leeren",
|
||||||
|
|||||||
@@ -45,6 +45,7 @@
|
|||||||
"removeFromFavorites": "Remove from favorites",
|
"removeFromFavorites": "Remove from favorites",
|
||||||
"editSessionName": "Manually edit session name",
|
"editSessionName": "Manually edit session name",
|
||||||
"deleteSession": "Delete this session permanently",
|
"deleteSession": "Delete this session permanently",
|
||||||
|
"activeSessionIndicator": "Recently active session (last 10 minutes)",
|
||||||
"save": "Save",
|
"save": "Save",
|
||||||
"cancel": "Cancel",
|
"cancel": "Cancel",
|
||||||
"clearSearch": "Clear search",
|
"clearSearch": "Clear search",
|
||||||
|
|||||||
@@ -45,6 +45,7 @@
|
|||||||
"removeFromFavorites": "Rimuovi dai preferiti",
|
"removeFromFavorites": "Rimuovi dai preferiti",
|
||||||
"editSessionName": "Modifica manualmente il nome della sessione",
|
"editSessionName": "Modifica manualmente il nome della sessione",
|
||||||
"deleteSession": "Elimina questa sessione permanentemente",
|
"deleteSession": "Elimina questa sessione permanentemente",
|
||||||
|
"activeSessionIndicator": "Sessione attiva di recente (ultimi 10 minuti)",
|
||||||
"save": "Salva",
|
"save": "Salva",
|
||||||
"cancel": "Annulla",
|
"cancel": "Annulla",
|
||||||
"clearSearch": "Cancella ricerca",
|
"clearSearch": "Cancella ricerca",
|
||||||
|
|||||||
@@ -45,6 +45,7 @@
|
|||||||
"removeFromFavorites": "お気に入りから削除",
|
"removeFromFavorites": "お気に入りから削除",
|
||||||
"editSessionName": "セッション名を手動で編集",
|
"editSessionName": "セッション名を手動で編集",
|
||||||
"deleteSession": "このセッションを完全に削除",
|
"deleteSession": "このセッションを完全に削除",
|
||||||
|
"activeSessionIndicator": "最近アクティブなセッション(過去10分以内)",
|
||||||
"save": "保存",
|
"save": "保存",
|
||||||
"cancel": "キャンセル",
|
"cancel": "キャンセル",
|
||||||
"openCommandPalette": "コマンドパレットを開く"
|
"openCommandPalette": "コマンドパレットを開く"
|
||||||
|
|||||||
@@ -45,6 +45,7 @@
|
|||||||
"removeFromFavorites": "즐겨찾기에서 제거",
|
"removeFromFavorites": "즐겨찾기에서 제거",
|
||||||
"editSessionName": "세션 이름 직접 편집",
|
"editSessionName": "세션 이름 직접 편집",
|
||||||
"deleteSession": "이 세션 영구 삭제",
|
"deleteSession": "이 세션 영구 삭제",
|
||||||
|
"activeSessionIndicator": "최근 활성 세션 (지난 10분)",
|
||||||
"save": "저장",
|
"save": "저장",
|
||||||
"cancel": "취소",
|
"cancel": "취소",
|
||||||
"openCommandPalette": "명령 팔레트 열기"
|
"openCommandPalette": "명령 팔레트 열기"
|
||||||
|
|||||||
@@ -45,6 +45,7 @@
|
|||||||
"removeFromFavorites": "Удалить из избранного",
|
"removeFromFavorites": "Удалить из избранного",
|
||||||
"editSessionName": "Вручную редактировать имя сеанса",
|
"editSessionName": "Вручную редактировать имя сеанса",
|
||||||
"deleteSession": "Удалить этот сеанс навсегда",
|
"deleteSession": "Удалить этот сеанс навсегда",
|
||||||
|
"activeSessionIndicator": "Недавно активный сеанс (последние 10 минут)",
|
||||||
"save": "Сохранить",
|
"save": "Сохранить",
|
||||||
"cancel": "Отмена",
|
"cancel": "Отмена",
|
||||||
"clearSearch": "Очистить поиск",
|
"clearSearch": "Очистить поиск",
|
||||||
|
|||||||
@@ -45,6 +45,7 @@
|
|||||||
"removeFromFavorites": "Favorilerden çıkar",
|
"removeFromFavorites": "Favorilerden çıkar",
|
||||||
"editSessionName": "Oturum adını elle düzenle",
|
"editSessionName": "Oturum adını elle düzenle",
|
||||||
"deleteSession": "Bu oturumu kalıcı olarak sil",
|
"deleteSession": "Bu oturumu kalıcı olarak sil",
|
||||||
|
"activeSessionIndicator": "Yakın zamanda etkin oturum (son 10 dakika)",
|
||||||
"save": "Kaydet",
|
"save": "Kaydet",
|
||||||
"cancel": "İptal",
|
"cancel": "İptal",
|
||||||
"clearSearch": "Aramayı temizle",
|
"clearSearch": "Aramayı temizle",
|
||||||
|
|||||||
@@ -45,6 +45,7 @@
|
|||||||
"removeFromFavorites": "从收藏移除",
|
"removeFromFavorites": "从收藏移除",
|
||||||
"editSessionName": "手动编辑会话名称",
|
"editSessionName": "手动编辑会话名称",
|
||||||
"deleteSession": "永久删除此会话",
|
"deleteSession": "永久删除此会话",
|
||||||
|
"activeSessionIndicator": "最近活跃的会话(最近 10 分钟)",
|
||||||
"save": "保存",
|
"save": "保存",
|
||||||
"cancel": "取消",
|
"cancel": "取消",
|
||||||
"clearSearch": "清除搜索",
|
"clearSearch": "清除搜索",
|
||||||
|
|||||||
Reference in New Issue
Block a user