mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-02 03:55:55 +00:00
* refactor(web): migrate from Next.js to Vite + React Router
* fix: update build pipelines for Vite migration (out → dist)
- Dockerfile: npm run build → npx vite build, web/out → web/dist
- pyproject.toml: package-data web/out/** → web/dist/**
- paths.py: support both web/dist (Vite) and web/out (legacy) with fallback
* fix: remove .next from git tracking, add to .gitignore
1334 cached files from web/.next/ were accidentally committed.
Added .next/ to both root and web/.gitignore.
* fix: update build process to use Vite and correct output directory
* fix: update pnpm-lock.yaml and eslint config for Vite migration
* style: fix prettier formatting issues
* fix: add eslint-plugin-react-hooks for Vite migration
* fix: remove undefined eslint rule reference, downgrade react-hooks plugin to v5
* fix(web): clean up remaining Next.js artifacts in Vite migration
- Add vite-env.d.ts for import.meta.env and asset type declarations
- Remove dead layout.tsx (providers already in main.tsx)
- Fix useSearchParams destructuring to [searchParams] tuple (11 locations)
- Replace process.env.NEXT_PUBLIC_* with import.meta.env.VITE_*
- Fix langbotIcon.src to langbotIcon (Vite returns URL string)
- Fix Link href to Link to for react-router-dom
- Fix navigate({ scroll: false }) to { preventScrollReset: true }
- Fix [router] dependency arrays to [navigate]
- Remove Next.js plugin from tsconfig, set rsc: false in components.json
- Replace next lint with eslint in lint-staged
* feat: add tools API endpoint and tools-selector form type
Backend:
- Add GET /api/v1/tools — list all available tools (plugin + MCP)
- Add GET /api/v1/tools/<tool_name> — get specific tool details
Frontend:
- Add TOOLS_SELECTOR form type for plugin config forms
- Multi-select dialog with tool name and description
- Add PluginTool entity type and API client methods
* Revert "feat: add tools API endpoint and tools-selector form type"
This reverts commit 3c637fc563.
191 lines
5.6 KiB
TypeScript
191 lines
5.6 KiB
TypeScript
import React from 'react';
|
|
import { useTranslation } from 'react-i18next';
|
|
import { Progress } from '@/components/ui/progress';
|
|
import {
|
|
Download,
|
|
Package,
|
|
Settings,
|
|
Rocket,
|
|
CheckCircle2,
|
|
XCircle,
|
|
Loader2,
|
|
X,
|
|
ListTodo,
|
|
} from 'lucide-react';
|
|
import { Button } from '@/components/ui/button';
|
|
import {
|
|
Popover,
|
|
PopoverContent,
|
|
PopoverTrigger,
|
|
} from '@/components/ui/popover';
|
|
import { Badge } from '@/components/ui/badge';
|
|
import {
|
|
usePluginInstallTasks,
|
|
InstallStage,
|
|
PluginInstallTask,
|
|
} from './PluginInstallTaskContext';
|
|
import { cn } from '@/lib/utils';
|
|
|
|
const STAGE_ICONS: Record<string, React.ElementType> = {
|
|
[InstallStage.DOWNLOADING]: Download,
|
|
[InstallStage.INSTALLING_DEPS]: Package,
|
|
[InstallStage.INITIALIZING]: Settings,
|
|
[InstallStage.LAUNCHING]: Rocket,
|
|
[InstallStage.DONE]: CheckCircle2,
|
|
[InstallStage.ERROR]: XCircle,
|
|
};
|
|
|
|
function TaskQueueItem({
|
|
task,
|
|
onClick,
|
|
onRemove,
|
|
}: {
|
|
task: PluginInstallTask;
|
|
onClick: () => void;
|
|
onRemove: () => void;
|
|
}) {
|
|
const { t } = useTranslation();
|
|
const isDone = task.stage === InstallStage.DONE;
|
|
const isError = task.stage === InstallStage.ERROR;
|
|
const isRunning = !isDone && !isError;
|
|
const StageIcon = STAGE_ICONS[task.stage] || Download;
|
|
|
|
const stageLabel = (() => {
|
|
switch (task.stage) {
|
|
case InstallStage.DOWNLOADING:
|
|
return t('plugins.installProgress.downloading');
|
|
case InstallStage.INSTALLING_DEPS:
|
|
return t('plugins.installProgress.installingDeps');
|
|
case InstallStage.INITIALIZING:
|
|
return t('plugins.installProgress.initializing');
|
|
case InstallStage.LAUNCHING:
|
|
return t('plugins.installProgress.launching');
|
|
case InstallStage.DONE:
|
|
return t('plugins.installProgress.completed');
|
|
case InstallStage.ERROR:
|
|
return t('plugins.installProgress.failed');
|
|
default:
|
|
return '';
|
|
}
|
|
})();
|
|
|
|
return (
|
|
<div
|
|
className="flex items-center gap-2.5 px-3 py-2 rounded-lg hover:bg-muted/60 cursor-pointer transition-colors group"
|
|
onClick={onClick}
|
|
>
|
|
<div
|
|
className={cn(
|
|
'flex items-center justify-center w-7 h-7 rounded-full shrink-0',
|
|
isDone &&
|
|
'bg-green-100 dark:bg-green-900/30 text-green-600 dark:text-green-400',
|
|
isError &&
|
|
'bg-red-100 dark:bg-red-900/30 text-red-600 dark:text-red-400',
|
|
isRunning &&
|
|
'bg-blue-100 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400',
|
|
)}
|
|
>
|
|
{isRunning ? (
|
|
<Loader2 className="w-3.5 h-3.5 animate-spin" />
|
|
) : (
|
|
<StageIcon className="w-3.5 h-3.5" />
|
|
)}
|
|
</div>
|
|
|
|
<div className="flex-1 min-w-0">
|
|
<div className="text-sm font-medium truncate">{task.pluginName}</div>
|
|
<div className="flex items-center gap-2">
|
|
<span className="text-xs text-muted-foreground">{stageLabel}</span>
|
|
{isRunning && (
|
|
<span className="text-xs text-muted-foreground">
|
|
{task.overallProgress}%
|
|
</span>
|
|
)}
|
|
</div>
|
|
{isRunning && (
|
|
<Progress value={task.overallProgress} className="h-1 mt-1" />
|
|
)}
|
|
</div>
|
|
|
|
{(isDone || isError) && (
|
|
<Button
|
|
variant="ghost"
|
|
size="icon"
|
|
className="w-6 h-6 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity"
|
|
onClick={(e) => {
|
|
e.stopPropagation();
|
|
onRemove();
|
|
}}
|
|
>
|
|
<X className="w-3 h-3" />
|
|
</Button>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export default function PluginInstallTaskQueue() {
|
|
const { t } = useTranslation();
|
|
const { tasks, setSelectedTaskId, removeTask, clearCompletedTasks } =
|
|
usePluginInstallTasks();
|
|
|
|
const runningCount = tasks.filter(
|
|
(t) => t.stage !== InstallStage.DONE && t.stage !== InstallStage.ERROR,
|
|
).length;
|
|
const hasCompleted = tasks.some(
|
|
(t) => t.stage === InstallStage.DONE || t.stage === InstallStage.ERROR,
|
|
);
|
|
|
|
return (
|
|
<Popover>
|
|
<PopoverTrigger asChild>
|
|
<Button variant="outline" className="relative px-4 py-5 cursor-pointer">
|
|
<ListTodo className="w-4 h-4 mr-2" />
|
|
{t('plugins.installProgress.taskQueue')}
|
|
{runningCount > 0 && (
|
|
<Badge
|
|
variant="default"
|
|
className="ml-2 h-5 min-w-5 px-1.5 text-xs"
|
|
>
|
|
{runningCount}
|
|
</Badge>
|
|
)}
|
|
</Button>
|
|
</PopoverTrigger>
|
|
<PopoverContent className="w-[340px] p-2" align="end">
|
|
<div className="flex items-center justify-between px-2 py-1.5 mb-1">
|
|
<span className="text-sm font-semibold">
|
|
{t('plugins.installProgress.taskQueue')}
|
|
</span>
|
|
{hasCompleted && (
|
|
<Button
|
|
variant="ghost"
|
|
size="sm"
|
|
className="h-6 text-xs px-2"
|
|
onClick={clearCompletedTasks}
|
|
>
|
|
{t('plugins.installProgress.clearCompleted')}
|
|
</Button>
|
|
)}
|
|
</div>
|
|
<div className="max-h-[300px] overflow-y-auto space-y-0.5">
|
|
{tasks.length === 0 ? (
|
|
<div className="py-6 text-center text-sm text-muted-foreground">
|
|
{t('plugins.installProgress.noTasks')}
|
|
</div>
|
|
) : (
|
|
tasks.map((task) => (
|
|
<TaskQueueItem
|
|
key={task.id}
|
|
task={task}
|
|
onClick={() => setSelectedTaskId(task.id)}
|
|
onRemove={() => removeTask(task.id)}
|
|
/>
|
|
))
|
|
)}
|
|
</div>
|
|
</PopoverContent>
|
|
</Popover>
|
|
);
|
|
}
|