mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-05-31 00:55:42 +08:00
Compare commits
7 Commits
main
...
fix/use-fa
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
15d7419a3c | ||
|
|
d0cc85e76b | ||
|
|
661b8bd137 | ||
|
|
b80c7105d4 | ||
|
|
6f8fd37ab0 | ||
|
|
50b3b90235 | ||
|
|
dd6614bca3 |
@@ -36,7 +36,7 @@ export const CLAUDE_FALLBACK_MODELS: ProviderModelsDefinition = {
|
||||
description: 'Haiku 4.5 · Fastest for quick answers · $1/$5 per Mtok',
|
||||
},
|
||||
],
|
||||
DEFAULT: 'default',
|
||||
DEFAULT: 'sonnet',
|
||||
};
|
||||
type ClaudeInitEvent = {
|
||||
sessionId?: string;
|
||||
|
||||
@@ -401,6 +401,14 @@ export default function ChatComposer({
|
||||
<PromptInputSubmit
|
||||
disabled={!input.trim() || isLoading}
|
||||
className="h-10 w-10 sm:h-10 sm:w-10"
|
||||
onMouseDown={(event) => {
|
||||
event.preventDefault();
|
||||
onSubmit(event as unknown as MouseEvent<HTMLButtonElement>);
|
||||
}}
|
||||
onTouchStart={(event) => {
|
||||
event.preventDefault();
|
||||
onSubmit(event as unknown as TouchEvent<HTMLButtonElement>);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</PromptInputFooter>
|
||||
|
||||
@@ -1,93 +1,12 @@
|
||||
import { useState, type ReactNode } from 'react';
|
||||
import { useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import {
|
||||
Activity,
|
||||
BarChart3,
|
||||
BookOpen,
|
||||
Clock,
|
||||
Download,
|
||||
ExternalLink,
|
||||
GitBranch,
|
||||
Loader2,
|
||||
RefreshCw,
|
||||
ServerCrash,
|
||||
ShieldAlert,
|
||||
Terminal,
|
||||
Trash2,
|
||||
type LucideIcon,
|
||||
} from 'lucide-react';
|
||||
|
||||
import { Trash2, RefreshCw, GitBranch, Loader2, ServerCrash, ShieldAlert, ExternalLink, BookOpen, Download, BarChart3 } from 'lucide-react';
|
||||
import { usePlugins } from '../../../contexts/PluginsContext';
|
||||
import type { Plugin } from '../../../contexts/PluginsContext';
|
||||
|
||||
import PluginIcon from './PluginIcon';
|
||||
|
||||
const STARTER_PLUGIN_URL = 'https://github.com/cloudcli-ai/cloudcli-plugin-starter';
|
||||
const TERMINAL_PLUGIN_URL = 'https://github.com/cloudcli-ai/cloudcli-plugin-terminal';
|
||||
const SCHEDULED_PROMPT_PLUGIN_URL = 'https://github.com/grostim/cloudcli-cron';
|
||||
const CLAUDE_WATCH_PLUGIN_URL = 'https://github.com/satsuki19980613/cloudcli-claude-watch';
|
||||
|
||||
type PluginRecommendation = {
|
||||
id: string;
|
||||
translationKey: string;
|
||||
repoUrl: string;
|
||||
installedNames: string[];
|
||||
icon: LucideIcon;
|
||||
source: 'official' | 'unofficial';
|
||||
};
|
||||
|
||||
const OFFICIAL_PLUGIN_RECOMMENDATIONS: PluginRecommendation[] = [
|
||||
{
|
||||
id: 'project-stats',
|
||||
translationKey: 'starterPlugin',
|
||||
repoUrl: STARTER_PLUGIN_URL,
|
||||
installedNames: ['project-stats'],
|
||||
icon: BarChart3,
|
||||
source: 'official',
|
||||
},
|
||||
{
|
||||
id: 'web-terminal',
|
||||
translationKey: 'terminalPlugin',
|
||||
repoUrl: TERMINAL_PLUGIN_URL,
|
||||
installedNames: ['web-terminal'],
|
||||
icon: Terminal,
|
||||
source: 'official',
|
||||
},
|
||||
];
|
||||
|
||||
const UNOFFICIAL_PLUGIN_RECOMMENDATIONS: PluginRecommendation[] = [
|
||||
{
|
||||
id: 'cloudcli-claude-watch',
|
||||
translationKey: 'claudeWatchPlugin',
|
||||
repoUrl: CLAUDE_WATCH_PLUGIN_URL,
|
||||
installedNames: ['cloudcli-claude-watch'],
|
||||
icon: Activity,
|
||||
source: 'unofficial',
|
||||
},
|
||||
{
|
||||
id: 'workspace-scheduled-prompts',
|
||||
translationKey: 'scheduledPromptPlugin',
|
||||
repoUrl: SCHEDULED_PROMPT_PLUGIN_URL,
|
||||
installedNames: ['workspace-scheduled-prompts'],
|
||||
icon: Clock,
|
||||
source: 'unofficial',
|
||||
},
|
||||
];
|
||||
|
||||
function repoSlug(repoUrl: string) {
|
||||
return repoUrl.replace(/^https?:\/\/(www\.)?github\.com\//, '');
|
||||
}
|
||||
|
||||
function normalizeRepoUrl(repoUrl: string | null) {
|
||||
return repoUrl?.replace(/\.git$/, '').replace(/\/$/, '').toLowerCase() ?? null;
|
||||
}
|
||||
|
||||
function pluginMatchesRecommendation(plugin: Plugin, recommendation: PluginRecommendation) {
|
||||
return (
|
||||
recommendation.installedNames.includes(plugin.name)
|
||||
|| normalizeRepoUrl(plugin.repoUrl) === normalizeRepoUrl(recommendation.repoUrl)
|
||||
);
|
||||
}
|
||||
|
||||
/* ─── Toggle Switch ─────────────────────────────────────────────────────── */
|
||||
function ToggleSwitch({ checked, onChange, ariaLabel }: { checked: boolean; onChange: (v: boolean) => void; ariaLabel: string }) {
|
||||
@@ -289,95 +208,117 @@ function PluginCard({
|
||||
);
|
||||
}
|
||||
|
||||
/* ─── Recommendation Section ────────────────────────────────────────────── */
|
||||
function RecommendationSection({
|
||||
title,
|
||||
description,
|
||||
children,
|
||||
}: {
|
||||
title: string;
|
||||
description: string;
|
||||
children: ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<section className="space-y-2">
|
||||
<div>
|
||||
<h4 className="text-xs font-semibold uppercase tracking-wide text-muted-foreground">
|
||||
{title}
|
||||
</h4>
|
||||
<p className="mt-0.5 text-xs text-muted-foreground/70">
|
||||
{description}
|
||||
</p>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
{children}
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
/* ─── Plugin Recommendation Card ────────────────────────────────────────── */
|
||||
function PluginRecommendationCard({
|
||||
recommendation,
|
||||
onInstall,
|
||||
disabled,
|
||||
installing,
|
||||
}: {
|
||||
recommendation: PluginRecommendation;
|
||||
onInstall: () => void;
|
||||
disabled: boolean;
|
||||
installing: boolean;
|
||||
}) {
|
||||
/* ─── Starter Plugin Card ───────────────────────────────────────────────── */
|
||||
function StarterPluginCard({ onInstall, installing }: { onInstall: () => void; installing: boolean }) {
|
||||
const { t } = useTranslation('settings');
|
||||
const Icon = recommendation.icon;
|
||||
const isOfficial = recommendation.source === 'official';
|
||||
const accentClass = isOfficial ? 'bg-blue-500/30' : 'bg-amber-500/40';
|
||||
const hoverClass = isOfficial ? 'hover:border-blue-400 dark:hover:border-blue-500' : 'hover:border-amber-400 dark:hover:border-amber-500';
|
||||
const iconClass = isOfficial ? 'text-blue-500' : 'text-amber-500';
|
||||
|
||||
return (
|
||||
<div className={`relative flex overflow-hidden rounded-lg border border-dashed border-border bg-card transition-all duration-200 ${hoverClass}`}>
|
||||
<div className={`w-[3px] flex-shrink-0 ${accentClass}`} />
|
||||
<div className="relative flex overflow-hidden rounded-lg border border-dashed border-border bg-card transition-all duration-200 hover:border-blue-400 dark:hover:border-blue-500">
|
||||
<div className="w-[3px] flex-shrink-0 bg-blue-500/30" />
|
||||
<div className="min-w-0 flex-1 p-4">
|
||||
<div className="flex items-start justify-between gap-3">
|
||||
<div className="flex min-w-0 items-center gap-2.5">
|
||||
<div className={`h-5 w-5 flex-shrink-0 ${iconClass}`}>
|
||||
<Icon className="h-5 w-5" />
|
||||
<div className="h-5 w-5 flex-shrink-0 text-blue-500">
|
||||
<BarChart3 className="h-5 w-5" />
|
||||
</div>
|
||||
<div className="min-w-0">
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<span className="text-sm font-semibold leading-none text-foreground">
|
||||
{t(`pluginSettings.${recommendation.translationKey}.name`)}
|
||||
{t('pluginSettings.starterPlugin.name')}
|
||||
</span>
|
||||
<span className="rounded bg-blue-50 px-1.5 py-0.5 text-[10px] font-medium text-blue-600 dark:bg-blue-950/50 dark:text-blue-400">
|
||||
{t('pluginSettings.starterPlugin.badge')}
|
||||
</span>
|
||||
<span className="rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground">
|
||||
{t('pluginSettings.tab')}
|
||||
</span>
|
||||
</div>
|
||||
<p className="mt-1 text-sm leading-snug text-muted-foreground">
|
||||
{t(`pluginSettings.${recommendation.translationKey}.description`)}
|
||||
{t('pluginSettings.starterPlugin.description')}
|
||||
</p>
|
||||
<a
|
||||
href={recommendation.repoUrl}
|
||||
href={STARTER_PLUGIN_URL}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="mt-1 inline-flex items-center gap-1 text-xs text-muted-foreground/60 transition-colors hover:text-foreground"
|
||||
>
|
||||
<GitBranch className="h-3 w-3" />
|
||||
{repoSlug(recommendation.repoUrl)}
|
||||
cloudcli-ai/cloudcli-plugin-starter
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
onClick={onInstall}
|
||||
disabled={disabled}
|
||||
className="flex flex-shrink-0 items-center gap-1.5 rounded-md bg-foreground px-4 py-2 text-sm font-medium text-background transition-opacity hover:opacity-90 disabled:opacity-50"
|
||||
disabled={installing}
|
||||
className="flex flex-shrink-0 items-center gap-1.5 rounded-md bg-blue-600 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-blue-700 disabled:opacity-50"
|
||||
>
|
||||
{installing ? (
|
||||
<Loader2 className="h-3.5 w-3.5 animate-spin" />
|
||||
) : (
|
||||
<Download className="h-3.5 w-3.5" />
|
||||
)}
|
||||
{installing ? t('pluginSettings.installing') : t(`pluginSettings.${recommendation.translationKey}.install`)}
|
||||
{installing ? t('pluginSettings.installing') : t('pluginSettings.starterPlugin.install')}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/* ─── Terminal Plugin Card ──────────────────────────────────────────────── */
|
||||
function TerminalPluginCard({ onInstall, installing }: { onInstall: () => void; installing: boolean }) {
|
||||
const { t } = useTranslation('settings');
|
||||
|
||||
return (
|
||||
<div className="relative flex overflow-hidden rounded-lg border border-dashed border-border bg-card transition-all duration-200 hover:border-blue-400 dark:hover:border-blue-500">
|
||||
<div className="w-[3px] flex-shrink-0 bg-blue-500/30" />
|
||||
<div className="min-w-0 flex-1 p-4">
|
||||
<div className="flex items-start justify-between gap-3">
|
||||
<div className="flex min-w-0 items-center gap-2.5">
|
||||
<div className="h-5 w-5 flex-shrink-0 text-blue-500">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" className="h-5 w-5">
|
||||
<rect x="3" y="3" width="18" height="18" rx="2"/>
|
||||
<path d="M7 8l4 4-4 4"/>
|
||||
<line x1="13" y1="16" x2="17" y2="16"/>
|
||||
</svg>
|
||||
</div>
|
||||
<div className="min-w-0">
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<span className="text-sm font-semibold leading-none text-foreground">
|
||||
{t('pluginSettings.terminalPlugin.name')}
|
||||
</span>
|
||||
<span className="rounded bg-blue-50 px-1.5 py-0.5 text-[10px] font-medium text-blue-600 dark:bg-blue-950/50 dark:text-blue-400">
|
||||
{t('pluginSettings.terminalPlugin.badge')}
|
||||
</span>
|
||||
<span className="rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground">
|
||||
{t('pluginSettings.tab')}
|
||||
</span>
|
||||
</div>
|
||||
<p className="mt-1 text-sm leading-snug text-muted-foreground">
|
||||
{t('pluginSettings.terminalPlugin.description')}
|
||||
</p>
|
||||
<a
|
||||
href={TERMINAL_PLUGIN_URL}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="mt-1 inline-flex items-center gap-1 text-xs text-muted-foreground/60 transition-colors hover:text-foreground"
|
||||
>
|
||||
<GitBranch className="h-3 w-3" />
|
||||
cloudcli-ai/cloudcli-plugin-terminal
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
onClick={onInstall}
|
||||
disabled={installing}
|
||||
className="flex flex-shrink-0 items-center gap-1.5 rounded-md bg-blue-600 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-blue-700 disabled:opacity-50"
|
||||
>
|
||||
{installing ? (
|
||||
<Loader2 className="h-3.5 w-3.5 animate-spin" />
|
||||
) : (
|
||||
<Download className="h-3.5 w-3.5" />
|
||||
)}
|
||||
{installing ? t('pluginSettings.installing') : t('pluginSettings.terminalPlugin.install')}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -393,7 +334,8 @@ export default function PluginSettingsTab() {
|
||||
|
||||
const [gitUrl, setGitUrl] = useState('');
|
||||
const [installing, setInstalling] = useState(false);
|
||||
const [installingRecommendation, setInstallingRecommendation] = useState<string | null>(null);
|
||||
const [installingStarter, setInstallingStarter] = useState(false);
|
||||
const [installingTerminal, setInstallingTerminal] = useState(false);
|
||||
const [installError, setInstallError] = useState<string | null>(null);
|
||||
const [confirmUninstall, setConfirmUninstall] = useState<string | null>(null);
|
||||
const [updatingPlugins, setUpdatingPlugins] = useState<Set<string>>(new Set());
|
||||
@@ -422,18 +364,24 @@ export default function PluginSettingsTab() {
|
||||
setInstalling(false);
|
||||
};
|
||||
|
||||
const handleInstallRecommendation = async (recommendation: PluginRecommendation) => {
|
||||
if (installingRecommendation) return;
|
||||
setInstallingRecommendation(recommendation.id);
|
||||
const handleInstallStarter = async () => {
|
||||
setInstallingStarter(true);
|
||||
setInstallError(null);
|
||||
try {
|
||||
const result = await installPlugin(recommendation.repoUrl);
|
||||
if (!result.success) {
|
||||
setInstallError(result.error || t('pluginSettings.installFailed'));
|
||||
}
|
||||
} finally {
|
||||
setInstallingRecommendation(null);
|
||||
const result = await installPlugin(STARTER_PLUGIN_URL);
|
||||
if (!result.success) {
|
||||
setInstallError(result.error || t('pluginSettings.installFailed'));
|
||||
}
|
||||
setInstallingStarter(false);
|
||||
};
|
||||
|
||||
const handleInstallTerminal = async () => {
|
||||
setInstallingTerminal(true);
|
||||
setInstallError(null);
|
||||
const result = await installPlugin(TERMINAL_PLUGIN_URL);
|
||||
if (!result.success) {
|
||||
setInstallError(result.error || t('pluginSettings.installFailed'));
|
||||
}
|
||||
setInstallingTerminal(false);
|
||||
};
|
||||
|
||||
const handleUninstall = async (name: string) => {
|
||||
@@ -450,50 +398,8 @@ export default function PluginSettingsTab() {
|
||||
}
|
||||
};
|
||||
|
||||
const isRecommendationInstalled = (recommendation: PluginRecommendation) => {
|
||||
return plugins.some((plugin) => pluginMatchesRecommendation(plugin, recommendation));
|
||||
};
|
||||
|
||||
const isOfficialPlugin = (plugin: Plugin) => {
|
||||
return OFFICIAL_PLUGIN_RECOMMENDATIONS.some((recommendation) => (
|
||||
pluginMatchesRecommendation(plugin, recommendation)
|
||||
));
|
||||
};
|
||||
|
||||
const officialPlugins = plugins.filter(isOfficialPlugin);
|
||||
const otherPlugins = plugins.filter((plugin) => !isOfficialPlugin(plugin));
|
||||
const officialRecommendations = OFFICIAL_PLUGIN_RECOMMENDATIONS.filter(
|
||||
(recommendation) => !isRecommendationInstalled(recommendation),
|
||||
);
|
||||
const unofficialRecommendations = UNOFFICIAL_PLUGIN_RECOMMENDATIONS.filter(
|
||||
(recommendation) => !isRecommendationInstalled(recommendation),
|
||||
);
|
||||
const hasOfficialSection = officialPlugins.length > 0 || officialRecommendations.length > 0;
|
||||
const hasOtherSection = otherPlugins.length > 0 || unofficialRecommendations.length > 0;
|
||||
|
||||
const renderPluginCard = (plugin: Plugin, index: number) => {
|
||||
const handleToggle = async (enabled: boolean) => {
|
||||
const r = await togglePlugin(plugin.name, enabled);
|
||||
if (!r.success) {
|
||||
setInstallError(r.error || t('pluginSettings.toggleFailed'));
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<PluginCard
|
||||
key={plugin.name}
|
||||
plugin={plugin}
|
||||
index={index}
|
||||
onToggle={(enabled) => void handleToggle(enabled)}
|
||||
onUpdate={() => void handleUpdate(plugin.name)}
|
||||
onUninstall={() => void handleUninstall(plugin.name)}
|
||||
updating={updatingPlugins.has(plugin.name)}
|
||||
confirmingUninstall={confirmUninstall === plugin.name}
|
||||
onCancelUninstall={() => setConfirmUninstall(null)}
|
||||
updateError={updateErrors[plugin.name] ?? null}
|
||||
/>
|
||||
);
|
||||
};
|
||||
const hasStarterInstalled = plugins.some((p) => p.name === 'project-stats');
|
||||
const hasTerminalInstalled = plugins.some((p) => p.name === 'web-terminal');
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
@@ -550,49 +456,51 @@ export default function PluginSettingsTab() {
|
||||
</span>
|
||||
</p>
|
||||
|
||||
{/* Plugin sections */}
|
||||
{/* Official plugin suggestions — above the list */}
|
||||
{!loading && (!hasStarterInstalled || !hasTerminalInstalled) && (
|
||||
<div className="space-y-2">
|
||||
{!hasStarterInstalled && (
|
||||
<StarterPluginCard onInstall={handleInstallStarter} installing={installingStarter} />
|
||||
)}
|
||||
{!hasTerminalInstalled && (
|
||||
<TerminalPluginCard onInstall={handleInstallTerminal} installing={installingTerminal} />
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Plugin List */}
|
||||
{loading ? (
|
||||
<div className="flex items-center justify-center gap-2 py-10 text-sm text-muted-foreground">
|
||||
<Loader2 className="h-4 w-4 animate-spin" />
|
||||
{t('pluginSettings.scanningPlugins')}
|
||||
</div>
|
||||
) : plugins.length === 0 ? (
|
||||
<p className="py-8 text-center text-sm text-muted-foreground">{t('pluginSettings.noPluginsInstalled')}</p>
|
||||
) : (
|
||||
<div className="space-y-4">
|
||||
{hasOfficialSection && (
|
||||
<RecommendationSection
|
||||
title={t('pluginSettings.sections.officialTitle')}
|
||||
description={t('pluginSettings.sections.officialDescription')}
|
||||
>
|
||||
{officialPlugins.map((plugin, index) => renderPluginCard(plugin, index))}
|
||||
{officialRecommendations.map((recommendation) => (
|
||||
<PluginRecommendationCard
|
||||
key={recommendation.id}
|
||||
recommendation={recommendation}
|
||||
onInstall={() => void handleInstallRecommendation(recommendation)}
|
||||
disabled={!!installingRecommendation}
|
||||
installing={installingRecommendation === recommendation.id}
|
||||
/>
|
||||
))}
|
||||
</RecommendationSection>
|
||||
)}
|
||||
<div className="space-y-2">
|
||||
{plugins.map((plugin, index) => {
|
||||
const handleToggle = async (enabled: boolean) => {
|
||||
const r = await togglePlugin(plugin.name, enabled);
|
||||
if (!r.success) {
|
||||
setInstallError(r.error || t('pluginSettings.toggleFailed'));
|
||||
}
|
||||
};
|
||||
|
||||
{hasOtherSection && (
|
||||
<RecommendationSection
|
||||
title={t('pluginSettings.sections.unofficialTitle')}
|
||||
description={t('pluginSettings.sections.unofficialDescription')}
|
||||
>
|
||||
{otherPlugins.map((plugin, index) => renderPluginCard(plugin, officialPlugins.length + index))}
|
||||
{unofficialRecommendations.map((recommendation) => (
|
||||
<PluginRecommendationCard
|
||||
key={recommendation.id}
|
||||
recommendation={recommendation}
|
||||
onInstall={() => void handleInstallRecommendation(recommendation)}
|
||||
disabled={!!installingRecommendation}
|
||||
installing={installingRecommendation === recommendation.id}
|
||||
/>
|
||||
))}
|
||||
</RecommendationSection>
|
||||
)}
|
||||
return (
|
||||
<PluginCard
|
||||
key={plugin.name}
|
||||
plugin={plugin}
|
||||
index={index}
|
||||
onToggle={(enabled) => void handleToggle(enabled)}
|
||||
onUpdate={() => void handleUpdate(plugin.name)}
|
||||
onUninstall={() => void handleUninstall(plugin.name)}
|
||||
updating={updatingPlugins.has(plugin.name)}
|
||||
confirmingUninstall={confirmUninstall === plugin.name}
|
||||
onCancelUninstall={() => setConfirmUninstall(null)}
|
||||
updateError={updateErrors[plugin.name] ?? null}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Check, ChevronDown, ChevronRight, Edit3, Star, Trash2, X } from 'lucide-react';
|
||||
import { Check, ChevronDown, ChevronRight, Edit3, Folder, FolderOpen, Star, Trash2, X } from 'lucide-react';
|
||||
import type { TFunction } from 'i18next';
|
||||
|
||||
import { Button } from '../../../../shared/view/ui';
|
||||
@@ -131,28 +131,18 @@ export default function SidebarProjectItem({
|
||||
>
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex min-w-0 flex-1 items-center gap-3">
|
||||
<button
|
||||
<div
|
||||
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',
|
||||
'w-8 h-8 rounded-lg flex items-center justify-center transition-colors',
|
||||
isExpanded ? 'bg-primary/10' : 'bg-muted',
|
||||
)}
|
||||
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>
|
||||
{isExpanded ? (
|
||||
<FolderOpen className="h-4 w-4 text-primary" />
|
||||
) : (
|
||||
<Folder className="h-4 w-4 text-muted-foreground" />
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="min-w-0 flex-1">
|
||||
{isEditing ? (
|
||||
@@ -222,6 +212,29 @@ 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) => {
|
||||
@@ -268,28 +281,11 @@ export default function SidebarProjectItem({
|
||||
onClick={selectAndToggleProject}
|
||||
>
|
||||
<div className="flex min-w-0 flex-1 items-center gap-3">
|
||||
<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>
|
||||
{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="min-w-0 flex-1 text-left">
|
||||
{isEditing ? (
|
||||
<div className="space-y-1">
|
||||
@@ -356,6 +352,26 @@ 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,8 +1,7 @@
|
||||
import { useEffect, useRef } from 'react';
|
||||
import { Check, Edit2, Trash2, X } from 'lucide-react';
|
||||
import type { TFunction } from 'i18next';
|
||||
|
||||
import { Badge, Button, Tooltip } from '../../../../shared/view/ui';
|
||||
import { Badge, Button } from '../../../../shared/view/ui';
|
||||
import { cn } from '../../../../lib/utils';
|
||||
import type { Project, ProjectSession, LLMProvider } from '../../../../types/app';
|
||||
import type { SessionWithProvider } from '../../types/types';
|
||||
@@ -77,28 +76,7 @@ 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.
|
||||
@@ -119,13 +97,7 @@ 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">
|
||||
<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 className="h-2 w-2 animate-pulse rounded-full bg-green-500" />
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -196,12 +168,7 @@ 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={cn(
|
||||
'ml-auto flex-shrink-0 text-[11px] text-muted-foreground transition-opacity duration-200',
|
||||
isEditing ? 'opacity-0' : 'group-hover:opacity-0',
|
||||
)}
|
||||
>
|
||||
<span className="ml-auto flex-shrink-0 text-[11px] text-muted-foreground transition-opacity duration-200 group-hover:opacity-0">
|
||||
{compactSessionAge}
|
||||
</span>
|
||||
)}
|
||||
@@ -213,14 +180,8 @@ export default function SidebarSessionItem({
|
||||
</div>
|
||||
</Button>
|
||||
|
||||
<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 ? (
|
||||
<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 ? (
|
||||
<>
|
||||
<input
|
||||
type="text"
|
||||
|
||||
@@ -45,7 +45,6 @@
|
||||
"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",
|
||||
|
||||
@@ -472,12 +472,6 @@
|
||||
"starterPluginLabel": "Starter Plugin",
|
||||
"starter": "Starter",
|
||||
"docs": "Docs",
|
||||
"sections": {
|
||||
"officialTitle": "Official Plugins",
|
||||
"officialDescription": "Maintained by the CloudCLI team and ready for direct install.",
|
||||
"unofficialTitle": "Other Plugins",
|
||||
"unofficialDescription": "Unofficial plugins and integrations from other users. Review the source before installing."
|
||||
},
|
||||
"starterPlugin": {
|
||||
"name": "Project Stats",
|
||||
"badge": "starter",
|
||||
@@ -490,18 +484,6 @@
|
||||
"description": "Integrated terminal with full shell access directly within the interface.",
|
||||
"install": "Install"
|
||||
},
|
||||
"scheduledPromptPlugin": {
|
||||
"name": "Scheduled Prompts",
|
||||
"badge": "unofficial",
|
||||
"description": "Schedule workspace prompts, review run history, and manage recurring local tasks.",
|
||||
"install": "Install"
|
||||
},
|
||||
"claudeWatchPlugin": {
|
||||
"name": "Claude Watch",
|
||||
"badge": "unofficial",
|
||||
"description": "Watch long-running Claude Code sessions for hangs and expose process controls.",
|
||||
"install": "Install"
|
||||
},
|
||||
"morePlugins": "More",
|
||||
"enable": "Enable",
|
||||
"disable": "Disable",
|
||||
|
||||
@@ -45,7 +45,6 @@
|
||||
"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,7 +45,6 @@
|
||||
"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,7 +45,6 @@
|
||||
"removeFromFavorites": "お気に入りから削除",
|
||||
"editSessionName": "セッション名を手動で編集",
|
||||
"deleteSession": "このセッションを完全に削除",
|
||||
"activeSessionIndicator": "最近アクティブなセッション(過去10分以内)",
|
||||
"save": "保存",
|
||||
"cancel": "キャンセル",
|
||||
"openCommandPalette": "コマンドパレットを開く"
|
||||
|
||||
@@ -45,7 +45,6 @@
|
||||
"removeFromFavorites": "즐겨찾기에서 제거",
|
||||
"editSessionName": "세션 이름 직접 편집",
|
||||
"deleteSession": "이 세션 영구 삭제",
|
||||
"activeSessionIndicator": "최근 활성 세션 (지난 10분)",
|
||||
"save": "저장",
|
||||
"cancel": "취소",
|
||||
"openCommandPalette": "명령 팔레트 열기"
|
||||
|
||||
@@ -45,7 +45,6 @@
|
||||
"removeFromFavorites": "Удалить из избранного",
|
||||
"editSessionName": "Вручную редактировать имя сеанса",
|
||||
"deleteSession": "Удалить этот сеанс навсегда",
|
||||
"activeSessionIndicator": "Недавно активный сеанс (последние 10 минут)",
|
||||
"save": "Сохранить",
|
||||
"cancel": "Отмена",
|
||||
"clearSearch": "Очистить поиск",
|
||||
|
||||
@@ -45,7 +45,6 @@
|
||||
"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,7 +45,6 @@
|
||||
"removeFromFavorites": "从收藏移除",
|
||||
"editSessionName": "手动编辑会话名称",
|
||||
"deleteSession": "永久删除此会话",
|
||||
"activeSessionIndicator": "最近活跃的会话(最近 10 分钟)",
|
||||
"save": "保存",
|
||||
"cancel": "取消",
|
||||
"clearSearch": "清除搜索",
|
||||
|
||||
Reference in New Issue
Block a user