mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-03-10 08:27:40 +00:00
* feat: new plugin system
* Potential fix for code scanning alert no. 312: Uncontrolled data used in path expression
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
* Update manifest.json
* feat(plugins): add SVG icon support with authenticated inline rendering
* fix: coderabbit changes and new plugin name & repo
* fix: design changes to plugins settings tab
* fix(plugins): prevent git arg injection, add repo URL detection
* fix: lint errors and deleting plugin error on windows
* fix: coderabbit nitpick comments
* fix(plugins): harden path traversal and respect enabled state
Use realpathSync to canonicalize paths before the plugin asset
boundary check, preventing symlink-based traversal bypasses that
could escape the plugin directory.
PluginTabContent now guards on plugin.enabled before mounting the
plugin module, and re-mounts when the enabled state changes so
toggling a plugin takes effect without a page reload.
PluginIcon safely handles a missing iconFile prop and skips
processing non-OK fetch responses instead of attempting to parse
error bodies as SVG.
Register 'plugins' as a known main tab so the settings router
preserves the tab on navigation.
* fix(plugins): support concurrent plugin updates
Replace single updatingPlugin string state with a Set to allow
multiple plugins to update simultaneously. Also disable the update
button and show a descriptive tooltip when a plugin has no git
remote configured.
* fix(plugins): async shutdown and asset/RPC fixes
Await stopPluginServer/stopAllPlugins in signal handlers and route
handlers so process exit and state transitions wait for clean plugin
shutdown instead of racing ahead.
Validate asset paths are regular files before streaming to prevent
directory traversal returning unexpected content; add a stream error
handler to avoid unhandled crashes on read failures.
Fix RPC proxy body detection to use the content-length header instead
of Object.keys, so falsy but valid JSON payloads (null, false, 0, {})
are forwarded correctly to plugin servers.
Track in-flight start operations via a startingPlugins map to prevent
duplicate concurrent plugin starts.
* refactor(git-panel): simplify setCommitMessage with plain function
* fix(plugins): harden input validation and scan reliability
- Validate plugin names against [a-zA-Z0-9_-] allowlist in
manifest and asset routes to prevent path traversal via URL
- Strip embedded credentials (user:pass@) from git remote URLs
before exposing them to the client
- Skip .tmp-* directories during scan to avoid partial installs
from in-progress updates appearing as broken plugins
- Deduplicate plugins sharing the same manifest name to prevent
ambiguous state
- Guard RPC proxy error handler against writing to an already-sent
response, preventing uncaught exceptions on aborted requests
* fix(git-panel): reset changes view on project switch
* refactor: move plugin content to /view folder
* fix: resolve type error in MobileNav and PluginTabContent components
---------
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Haileyesus <118998054+blackmammoth@users.noreply.github.com>
Co-authored-by: Haileyesus <something@gmail.com>
180 lines
7.0 KiB
TypeScript
180 lines
7.0 KiB
TypeScript
import { useState, useRef, useEffect, type Dispatch, type SetStateAction } from 'react';
|
|
import {
|
|
MessageSquare,
|
|
Folder,
|
|
Terminal,
|
|
GitBranch,
|
|
ClipboardCheck,
|
|
Ellipsis,
|
|
Puzzle,
|
|
Box,
|
|
Database,
|
|
Globe,
|
|
Wrench,
|
|
Zap,
|
|
BarChart3,
|
|
type LucideIcon,
|
|
} from 'lucide-react';
|
|
import { useTasksSettings } from '../../contexts/TasksSettingsContext';
|
|
import { usePlugins } from '../../contexts/PluginsContext';
|
|
import { AppTab } from '../../types/app';
|
|
|
|
const PLUGIN_ICON_MAP: Record<string, LucideIcon> = {
|
|
Puzzle, Box, Database, Globe, Terminal, Wrench, Zap, BarChart3, Folder, MessageSquare, GitBranch,
|
|
};
|
|
|
|
type CoreTabId = Exclude<AppTab, `plugin:${string}` | 'preview'>;
|
|
type CoreNavItem = {
|
|
id: CoreTabId;
|
|
icon: LucideIcon;
|
|
label: string;
|
|
};
|
|
|
|
type MobileNavProps = {
|
|
activeTab: AppTab;
|
|
setActiveTab: Dispatch<SetStateAction<AppTab>>;
|
|
isInputFocused: boolean;
|
|
};
|
|
|
|
export default function MobileNav({ activeTab, setActiveTab, isInputFocused }: MobileNavProps) {
|
|
const { tasksEnabled, isTaskMasterInstalled } = useTasksSettings();
|
|
const shouldShowTasksTab = Boolean(tasksEnabled && isTaskMasterInstalled);
|
|
const { plugins } = usePlugins();
|
|
const [moreOpen, setMoreOpen] = useState(false);
|
|
const moreRef = useRef<HTMLDivElement | null>(null);
|
|
|
|
const enabledPlugins = plugins.filter((p) => p.enabled);
|
|
const hasPlugins = enabledPlugins.length > 0;
|
|
const isPluginActive = activeTab.startsWith('plugin:');
|
|
|
|
// Close the menu on outside tap
|
|
useEffect(() => {
|
|
if (!moreOpen) return;
|
|
const handleTap = (e: PointerEvent) => {
|
|
const target = e.target;
|
|
if (moreRef.current && target instanceof Node && !moreRef.current.contains(target)) {
|
|
setMoreOpen(false);
|
|
}
|
|
};
|
|
document.addEventListener('pointerdown', handleTap);
|
|
return () => document.removeEventListener('pointerdown', handleTap);
|
|
}, [moreOpen]);
|
|
|
|
// Close menu when a plugin tab is selected
|
|
const selectPlugin = (name: string) => {
|
|
const pluginTab = `plugin:${name}` as AppTab;
|
|
setActiveTab(pluginTab);
|
|
setMoreOpen(false);
|
|
};
|
|
|
|
const baseCoreItems: CoreNavItem[] = [
|
|
{ id: 'chat', icon: MessageSquare, label: 'Chat' },
|
|
{ id: 'shell', icon: Terminal, label: 'Shell' },
|
|
{ id: 'files', icon: Folder, label: 'Files' },
|
|
{ id: 'git', icon: GitBranch, label: 'Git' },
|
|
];
|
|
const coreItems: CoreNavItem[] = shouldShowTasksTab
|
|
? [...baseCoreItems, { id: 'tasks', icon: ClipboardCheck, label: 'Tasks' }]
|
|
: baseCoreItems;
|
|
|
|
return (
|
|
<div
|
|
className={`fixed bottom-0 left-0 right-0 z-50 transform px-3 pb-[max(8px,env(safe-area-inset-bottom))] transition-transform duration-300 ease-in-out ${isInputFocused ? 'translate-y-full' : 'translate-y-0'
|
|
}`}
|
|
>
|
|
<div className="nav-glass mobile-nav-float rounded-2xl border border-border/30">
|
|
<div className="flex items-center justify-around gap-0.5 px-1 py-1.5">
|
|
{coreItems.map((item) => {
|
|
const Icon = item.icon;
|
|
const isActive = activeTab === item.id;
|
|
|
|
return (
|
|
<button
|
|
key={item.id}
|
|
onClick={() => setActiveTab(item.id)}
|
|
onTouchStart={(e) => {
|
|
e.preventDefault();
|
|
setActiveTab(item.id);
|
|
}}
|
|
className={`relative flex flex-1 touch-manipulation flex-col items-center justify-center gap-0.5 rounded-xl px-3 py-2 transition-all duration-200 active:scale-95 ${isActive
|
|
? 'text-primary'
|
|
: 'text-muted-foreground hover:text-foreground'
|
|
}`}
|
|
aria-label={item.label}
|
|
aria-current={isActive ? 'page' : undefined}
|
|
>
|
|
{isActive && (
|
|
<div className="bg-primary/8 dark:bg-primary/12 absolute inset-0 rounded-xl" />
|
|
)}
|
|
<Icon
|
|
className={`relative z-10 transition-all duration-200 ${isActive ? 'h-5 w-5' : 'h-[18px] w-[18px]'}`}
|
|
strokeWidth={isActive ? 2.4 : 1.8}
|
|
/>
|
|
<span className={`relative z-10 text-[10px] font-medium transition-all duration-200 ${isActive ? 'opacity-100' : 'opacity-60'}`}>
|
|
{item.label}
|
|
</span>
|
|
</button>
|
|
);
|
|
})}
|
|
|
|
{/* "More" button — only shown when there are enabled plugins */}
|
|
{hasPlugins && (
|
|
<div ref={moreRef} className="relative flex-1">
|
|
<button
|
|
onClick={() => setMoreOpen((v) => !v)}
|
|
onTouchStart={(e) => {
|
|
e.preventDefault();
|
|
setMoreOpen((v) => !v);
|
|
}}
|
|
className={`relative flex w-full touch-manipulation flex-col items-center justify-center gap-0.5 rounded-xl px-3 py-2 transition-all duration-200 active:scale-95 ${
|
|
isPluginActive || moreOpen
|
|
? 'text-primary'
|
|
: 'text-muted-foreground hover:text-foreground'
|
|
}`}
|
|
aria-label="More plugins"
|
|
aria-expanded={moreOpen}
|
|
>
|
|
{(isPluginActive && !moreOpen) && (
|
|
<div className="bg-primary/8 dark:bg-primary/12 absolute inset-0 rounded-xl" />
|
|
)}
|
|
<Ellipsis
|
|
className={`relative z-10 transition-all duration-200 ${isPluginActive ? 'h-5 w-5' : 'h-[18px] w-[18px]'}`}
|
|
strokeWidth={isPluginActive ? 2.4 : 1.8}
|
|
/>
|
|
<span className={`relative z-10 text-[10px] font-medium transition-all duration-200 ${isPluginActive || moreOpen ? 'opacity-100' : 'opacity-60'}`}>
|
|
More
|
|
</span>
|
|
</button>
|
|
|
|
{/* Popover menu */}
|
|
{moreOpen && (
|
|
<div className="animate-in fade-in slide-in-from-bottom-2 absolute bottom-full right-0 z-[60] mb-2 min-w-[180px] rounded-xl border border-border/40 bg-popover py-1.5 shadow-lg duration-150">
|
|
{enabledPlugins.map((p) => {
|
|
const Icon = PLUGIN_ICON_MAP[p.icon] || Puzzle;
|
|
const isActive = activeTab === `plugin:${p.name}`;
|
|
|
|
return (
|
|
<button
|
|
key={p.name}
|
|
onClick={() => selectPlugin(p.name)}
|
|
className={`flex w-full items-center gap-2.5 px-3.5 py-2.5 text-sm transition-colors ${
|
|
isActive
|
|
? 'bg-primary/8 text-primary'
|
|
: 'text-foreground hover:bg-muted/60'
|
|
}`}
|
|
>
|
|
<Icon className="h-4 w-4 flex-shrink-0" strokeWidth={isActive ? 2.2 : 1.8} />
|
|
<span className="truncate">{p.displayName}</span>
|
|
</button>
|
|
);
|
|
})}
|
|
</div>
|
|
)}
|
|
</div>
|
|
)}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|