@atercates/claude-deck 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +123 -0
- package/app/api/claude/hidden/route.ts +66 -0
- package/app/api/claude/projects/[name]/sessions/route.ts +71 -0
- package/app/api/claude/projects/route.ts +44 -0
- package/app/api/code-search/available/route.ts +12 -0
- package/app/api/code-search/route.ts +47 -0
- package/app/api/dev-servers/[id]/logs/route.ts +23 -0
- package/app/api/dev-servers/[id]/restart/route.ts +20 -0
- package/app/api/dev-servers/[id]/route.ts +51 -0
- package/app/api/dev-servers/[id]/stop/route.ts +20 -0
- package/app/api/dev-servers/detect/route.ts +39 -0
- package/app/api/dev-servers/route.ts +48 -0
- package/app/api/exec/route.ts +60 -0
- package/app/api/files/content/route.ts +76 -0
- package/app/api/files/route.ts +37 -0
- package/app/api/files/upload-temp/route.ts +41 -0
- package/app/api/git/check/route.ts +54 -0
- package/app/api/git/clone/route.ts +99 -0
- package/app/api/git/commit/route.ts +75 -0
- package/app/api/git/discard/route.ts +38 -0
- package/app/api/git/file-content/route.ts +64 -0
- package/app/api/git/history/[hash]/diff/route.ts +38 -0
- package/app/api/git/history/[hash]/route.ts +34 -0
- package/app/api/git/history/route.ts +27 -0
- package/app/api/git/multi-status/route.ts +46 -0
- package/app/api/git/pr/route.ts +164 -0
- package/app/api/git/push/route.ts +64 -0
- package/app/api/git/stage/route.ts +40 -0
- package/app/api/git/status/route.ts +51 -0
- package/app/api/git/unstage/route.ts +46 -0
- package/app/api/groups/[...path]/route.ts +136 -0
- package/app/api/groups/route.ts +93 -0
- package/app/api/orchestrate/spawn/route.ts +45 -0
- package/app/api/orchestrate/workers/[id]/route.ts +89 -0
- package/app/api/orchestrate/workers/route.ts +31 -0
- package/app/api/projects/[id]/detect/route.ts +27 -0
- package/app/api/projects/[id]/dev-servers/[dsId]/route.ts +66 -0
- package/app/api/projects/[id]/dev-servers/route.ts +51 -0
- package/app/api/projects/[id]/repositories/[repoId]/route.ts +67 -0
- package/app/api/projects/[id]/repositories/route.ts +74 -0
- package/app/api/projects/[id]/route.ts +108 -0
- package/app/api/projects/detect/route.ts +33 -0
- package/app/api/projects/route.ts +59 -0
- package/app/api/sessions/[id]/claude-session/route.ts +42 -0
- package/app/api/sessions/[id]/fork/route.ts +74 -0
- package/app/api/sessions/[id]/mcp-config/route.ts +34 -0
- package/app/api/sessions/[id]/messages/route.ts +60 -0
- package/app/api/sessions/[id]/pr/route.ts +188 -0
- package/app/api/sessions/[id]/preview/route.ts +42 -0
- package/app/api/sessions/[id]/route.ts +229 -0
- package/app/api/sessions/[id]/send-keys/route.ts +119 -0
- package/app/api/sessions/[id]/summarize/route.ts +331 -0
- package/app/api/sessions/init-script/route.ts +84 -0
- package/app/api/sessions/route.ts +209 -0
- package/app/api/sessions/status/route.ts +237 -0
- package/app/api/system/route.ts +9 -0
- package/app/api/tmux/kill-all/route.ts +57 -0
- package/app/api/tmux/rename/route.ts +30 -0
- package/app/globals.css +174 -0
- package/app/icon.svg +11 -0
- package/app/layout.tsx +122 -0
- package/app/page.tsx +629 -0
- package/components/ChatMessage.tsx +65 -0
- package/components/ChatView.tsx +276 -0
- package/components/ClaudeProjects/ClaudeProjectCard.tsx +195 -0
- package/components/ClaudeProjects/ClaudeProjectsSection.tsx +89 -0
- package/components/ClaudeProjects/ClaudeSessionCard.tsx +100 -0
- package/components/ClaudeProjects/index.ts +1 -0
- package/components/CodeSearch/CodeSearchResults.tsx +177 -0
- package/components/ConductorPanel.tsx +256 -0
- package/components/DevServers/DevServerCard.tsx +311 -0
- package/components/DevServers/DevServersSection.tsx +91 -0
- package/components/DevServers/ServerLogsModal.tsx +151 -0
- package/components/DevServers/StartServerDialog.tsx +359 -0
- package/components/DevServers/index.ts +4 -0
- package/components/DiffViewer/DiffModal.tsx +151 -0
- package/components/DiffViewer/UnifiedDiff.tsx +185 -0
- package/components/DiffViewer/index.tsx +2 -0
- package/components/DirectoryPicker.tsx +355 -0
- package/components/FileExplorer/FileEditor.tsx +276 -0
- package/components/FileExplorer/FileTabs.tsx +118 -0
- package/components/FileExplorer/FileTree.tsx +214 -0
- package/components/FileExplorer/HtmlRenderer.tsx +16 -0
- package/components/FileExplorer/MarkdownRenderer.tsx +18 -0
- package/components/FileExplorer/index.tsx +520 -0
- package/components/FilePicker.tsx +339 -0
- package/components/FolderPicker.tsx +201 -0
- package/components/GitDrawer/FileEditDialog.tsx +400 -0
- package/components/GitDrawer/index.tsx +464 -0
- package/components/GitPanel/CommitForm.tsx +205 -0
- package/components/GitPanel/CommitHistory.tsx +174 -0
- package/components/GitPanel/CommitItem.tsx +196 -0
- package/components/GitPanel/FileChanges.tsx +414 -0
- package/components/GitPanel/GitPanelTabs.tsx +39 -0
- package/components/GitPanel/index.tsx +817 -0
- package/components/MessageInput.tsx +82 -0
- package/components/NewClaudeSessionDialog.tsx +166 -0
- package/components/NewSessionDialog/AdvancedSettings.tsx +78 -0
- package/components/NewSessionDialog/AgentSelector.tsx +37 -0
- package/components/NewSessionDialog/CreatingOverlay.tsx +94 -0
- package/components/NewSessionDialog/NewSessionDialog.types.ts +136 -0
- package/components/NewSessionDialog/ProjectSelector.tsx +146 -0
- package/components/NewSessionDialog/WorkingDirectoryInput.tsx +55 -0
- package/components/NewSessionDialog/WorktreeSection.tsx +92 -0
- package/components/NewSessionDialog/hooks/useNewSessionForm.ts +370 -0
- package/components/NewSessionDialog/index.tsx +106 -0
- package/components/NotificationSettings.tsx +127 -0
- package/components/PRCreationModal.tsx +272 -0
- package/components/Pane/DesktopTabBar.tsx +353 -0
- package/components/Pane/MobileTabBar.tsx +210 -0
- package/components/Pane/OpenInVSCode.tsx +69 -0
- package/components/Pane/PaneSkeletons.tsx +57 -0
- package/components/Pane/index.tsx +558 -0
- package/components/PaneLayout.tsx +60 -0
- package/components/Projects/DevServersSection.tsx +140 -0
- package/components/Projects/DirectoryField.tsx +92 -0
- package/components/Projects/NewProjectDialog.tsx +188 -0
- package/components/Projects/NewProjectDialog.types.ts +46 -0
- package/components/Projects/ProjectCard.tsx +276 -0
- package/components/Projects/ProjectSettingsDialog.tsx +811 -0
- package/components/Projects/hooks/useNewProjectForm.ts +249 -0
- package/components/Projects/index.ts +3 -0
- package/components/Providers.tsx +49 -0
- package/components/QuickSwitcher.tsx +306 -0
- package/components/SessionList/KillAllConfirm.tsx +46 -0
- package/components/SessionList/SelectionToolbar.tsx +164 -0
- package/components/SessionList/SessionList.types.ts +37 -0
- package/components/SessionList/SessionListHeader.tsx +71 -0
- package/components/SessionList/hooks/useSessionListMutations.ts +269 -0
- package/components/SessionList/index.tsx +189 -0
- package/components/ShellDrawer/index.tsx +106 -0
- package/components/SidebarFooter.tsx +55 -0
- package/components/Terminal/KeybarToggleButton.tsx +45 -0
- package/components/Terminal/ScrollToBottomButton.tsx +32 -0
- package/components/Terminal/SearchBar.tsx +71 -0
- package/components/Terminal/TerminalToolbar.tsx +551 -0
- package/components/Terminal/VirtualKeyboard.tsx +711 -0
- package/components/Terminal/constants.ts +20 -0
- package/components/Terminal/hooks/index.ts +5 -0
- package/components/Terminal/hooks/resize-handlers.ts +140 -0
- package/components/Terminal/hooks/terminal-init.ts +151 -0
- package/components/Terminal/hooks/touch-scroll.ts +155 -0
- package/components/Terminal/hooks/useTerminalConnection.ts +282 -0
- package/components/Terminal/hooks/useTerminalConnection.types.ts +39 -0
- package/components/Terminal/hooks/useTerminalSearch.ts +103 -0
- package/components/Terminal/hooks/websocket-connection.ts +274 -0
- package/components/Terminal/index.tsx +320 -0
- package/components/ThemeToggle.tsx +168 -0
- package/components/TmuxSessions.tsx +132 -0
- package/components/ToolCallDisplay.tsx +71 -0
- package/components/WorkerCard.tsx +245 -0
- package/components/a/ABadge.tsx +115 -0
- package/components/a/AButton.tsx +163 -0
- package/components/a/ADialog.tsx +93 -0
- package/components/a/ADropdownMenu.tsx +279 -0
- package/components/a/AIconButton.tsx +190 -0
- package/components/a/ASheet.tsx +150 -0
- package/components/a/ATooltip.tsx +77 -0
- package/components/a/index.ts +64 -0
- package/components/mobile/SwipeSidebar.tsx +122 -0
- package/components/ui/badge.tsx +41 -0
- package/components/ui/button.tsx +60 -0
- package/components/ui/context-menu.tsx +197 -0
- package/components/ui/dialog.tsx +143 -0
- package/components/ui/dropdown-menu.tsx +257 -0
- package/components/ui/input.tsx +21 -0
- package/components/ui/scroll-area.tsx +52 -0
- package/components/ui/select.tsx +159 -0
- package/components/ui/skeleton.tsx +111 -0
- package/components/ui/switch.tsx +31 -0
- package/components/ui/textarea.tsx +21 -0
- package/components/ui/tooltip.tsx +32 -0
- package/components/views/DesktopView.tsx +244 -0
- package/components/views/MobileView.tsx +110 -0
- package/components/views/types.ts +75 -0
- package/contexts/PaneContext.tsx +336 -0
- package/data/claude/index.ts +9 -0
- package/data/claude/keys.ts +6 -0
- package/data/claude/queries.ts +120 -0
- package/data/claude/useClaudeUpdates.ts +37 -0
- package/data/code-search/index.ts +2 -0
- package/data/code-search/keys.ts +7 -0
- package/data/code-search/queries.ts +61 -0
- package/data/dev-servers/index.ts +8 -0
- package/data/dev-servers/keys.ts +4 -0
- package/data/dev-servers/queries.ts +104 -0
- package/data/files/index.ts +3 -0
- package/data/files/keys.ts +4 -0
- package/data/files/queries.ts +25 -0
- package/data/git/keys.ts +15 -0
- package/data/git/queries.ts +395 -0
- package/data/groups/index.ts +1 -0
- package/data/groups/mutations.ts +95 -0
- package/data/projects/index.ts +10 -0
- package/data/projects/keys.ts +4 -0
- package/data/projects/queries.ts +193 -0
- package/data/repositories/index.ts +7 -0
- package/data/repositories/keys.ts +5 -0
- package/data/repositories/queries.ts +122 -0
- package/data/sessions/index.ts +12 -0
- package/data/sessions/keys.ts +8 -0
- package/data/sessions/queries.ts +218 -0
- package/data/statuses/index.ts +1 -0
- package/data/statuses/queries.ts +69 -0
- package/hooks/useCopyToClipboard.ts +48 -0
- package/hooks/useDevServersManager.ts +73 -0
- package/hooks/useDirectoryBrowser.ts +90 -0
- package/hooks/useDrawerAnimation.ts +27 -0
- package/hooks/useFileDrop.ts +87 -0
- package/hooks/useFileEditor.ts +184 -0
- package/hooks/useGroups.ts +37 -0
- package/hooks/useHomePath.ts +34 -0
- package/hooks/useKeyRepeat.ts +55 -0
- package/hooks/useKeybarVisibility.ts +42 -0
- package/hooks/useNotifications.ts +257 -0
- package/hooks/useProjects.ts +53 -0
- package/hooks/useSessionStatuses.ts +30 -0
- package/hooks/useSessions.ts +86 -0
- package/hooks/useSpeechRecognition.ts +124 -0
- package/hooks/useViewport.ts +32 -0
- package/hooks/useViewportHeight.ts +50 -0
- package/lib/async-operations.ts +35 -0
- package/lib/banner.ts +81 -0
- package/lib/claude/jsonl-cache.ts +86 -0
- package/lib/claude/jsonl-reader.ts +271 -0
- package/lib/claude/process-manager.ts +278 -0
- package/lib/claude/stream-parser.ts +173 -0
- package/lib/claude/types.ts +154 -0
- package/lib/claude/watcher.ts +71 -0
- package/lib/client/session-registry.ts +111 -0
- package/lib/code-search.ts +121 -0
- package/lib/db/index.ts +48 -0
- package/lib/db/migrations.ts +45 -0
- package/lib/db/queries.ts +460 -0
- package/lib/db/schema.ts +114 -0
- package/lib/db/types.ts +92 -0
- package/lib/db.ts +2 -0
- package/lib/dev-servers.ts +509 -0
- package/lib/diff-parser.ts +221 -0
- package/lib/env-setup.ts +285 -0
- package/lib/file-upload.ts +34 -0
- package/lib/file-utils.ts +50 -0
- package/lib/files.ts +207 -0
- package/lib/git-history.ts +294 -0
- package/lib/git-status.ts +391 -0
- package/lib/git.ts +257 -0
- package/lib/mcp-config.ts +81 -0
- package/lib/multi-repo-git.ts +179 -0
- package/lib/notifications.ts +219 -0
- package/lib/orchestration.ts +448 -0
- package/lib/panes.ts +232 -0
- package/lib/ports.ts +97 -0
- package/lib/pr-generation.ts +307 -0
- package/lib/pr.ts +234 -0
- package/lib/projects.ts +578 -0
- package/lib/providers/registry.ts +70 -0
- package/lib/providers.ts +121 -0
- package/lib/query-client.ts +14 -0
- package/lib/rangeSelectionUtils.ts +65 -0
- package/lib/status-detector.ts +375 -0
- package/lib/terminal-themes.ts +265 -0
- package/lib/theme-config.ts +327 -0
- package/lib/utils.ts +6 -0
- package/lib/worktrees.ts +262 -0
- package/mcp/orchestration-server.ts +438 -0
- package/package.json +139 -0
- package/postcss.config.mjs +7 -0
- package/public/icon.svg +10 -0
- package/public/icons/icon-128x128.png +0 -0
- package/public/icons/icon-144x144.png +0 -0
- package/public/icons/icon-152x152.png +0 -0
- package/public/icons/icon-192x192.png +0 -0
- package/public/icons/icon-384x384.png +0 -0
- package/public/icons/icon-512x512.png +0 -0
- package/public/icons/icon-72x72.png +0 -0
- package/public/icons/icon-96x96.png +0 -0
- package/public/manifest.json +61 -0
- package/public/sw.js +64 -0
- package/scripts/agent-os +91 -0
- package/scripts/install.sh +48 -0
- package/scripts/lib/ai-clis.sh +132 -0
- package/scripts/lib/commands.sh +487 -0
- package/scripts/lib/common.sh +89 -0
- package/scripts/lib/prerequisites.sh +462 -0
- package/scripts/setup.sh +134 -0
- package/server.ts +155 -0
- package/stores/fileOpen.ts +26 -0
- package/stores/index.ts +1 -0
- package/stores/initialPrompt.ts +24 -0
- package/stores/sessionSelection.ts +48 -0
- package/styles/themes.css +603 -0
- package/tsconfig.json +33 -0
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useCodeSearch } from "@/data/code-search";
|
|
4
|
+
import { Loader2, FileCode, Search } from "lucide-react";
|
|
5
|
+
import { useState, useEffect } from "react";
|
|
6
|
+
import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
|
|
7
|
+
import { vscDarkPlus } from "react-syntax-highlighter/dist/esm/styles/prism";
|
|
8
|
+
import { cn } from "@/lib/utils";
|
|
9
|
+
import type { FormattedMatch } from "@/lib/code-search";
|
|
10
|
+
|
|
11
|
+
interface CodeSearchResultsProps {
|
|
12
|
+
workingDirectory: string;
|
|
13
|
+
query: string;
|
|
14
|
+
onSelectFile: (file: string, line: number) => void;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function CodeSearchResults({
|
|
18
|
+
workingDirectory,
|
|
19
|
+
query,
|
|
20
|
+
onSelectFile,
|
|
21
|
+
}: CodeSearchResultsProps) {
|
|
22
|
+
const { data, isLoading, isError, error } = useCodeSearch(
|
|
23
|
+
workingDirectory,
|
|
24
|
+
query,
|
|
25
|
+
query.length > 2
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
29
|
+
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
const handleKeyDown = (e: KeyboardEvent) => {
|
|
32
|
+
if (!data?.results.length) return;
|
|
33
|
+
|
|
34
|
+
if (e.key === "ArrowDown") {
|
|
35
|
+
e.preventDefault();
|
|
36
|
+
setSelectedIndex((i) => Math.min(i + 1, data.results.length - 1));
|
|
37
|
+
} else if (e.key === "ArrowUp") {
|
|
38
|
+
e.preventDefault();
|
|
39
|
+
setSelectedIndex((i) => Math.max(i - 1, 0));
|
|
40
|
+
} else if (e.key === "Enter") {
|
|
41
|
+
e.preventDefault();
|
|
42
|
+
const result = data.results[selectedIndex];
|
|
43
|
+
if (result) {
|
|
44
|
+
onSelectFile(result.file, result.line);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
window.addEventListener("keydown", handleKeyDown);
|
|
50
|
+
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
51
|
+
}, [data, selectedIndex, onSelectFile]);
|
|
52
|
+
|
|
53
|
+
if (isLoading) {
|
|
54
|
+
return (
|
|
55
|
+
<div className="flex items-center justify-center p-8">
|
|
56
|
+
<Loader2 className="text-muted-foreground h-6 w-6 animate-spin" />
|
|
57
|
+
</div>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (isError) {
|
|
62
|
+
return (
|
|
63
|
+
<div className="text-destructive p-4 text-sm">
|
|
64
|
+
{error instanceof Error ? error.message : "Failed to search code"}
|
|
65
|
+
</div>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (query.length < 3) {
|
|
70
|
+
return (
|
|
71
|
+
<div className="text-muted-foreground flex flex-col items-center justify-center p-8">
|
|
72
|
+
<Search className="mb-2 h-8 w-8 opacity-50" />
|
|
73
|
+
<p className="text-sm">Type at least 3 characters to search</p>
|
|
74
|
+
</div>
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (!data?.results.length) {
|
|
79
|
+
return (
|
|
80
|
+
<div className="text-muted-foreground flex flex-col items-center justify-center p-8">
|
|
81
|
+
<FileCode className="mb-2 h-8 w-8 opacity-50" />
|
|
82
|
+
<p className="text-sm">No matches found for "{query}"</p>
|
|
83
|
+
</div>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<div className="flex flex-col divide-y">
|
|
89
|
+
{data.results.map((result, index) => (
|
|
90
|
+
<SearchResultItem
|
|
91
|
+
key={`${result.file}:${result.line}`}
|
|
92
|
+
result={result}
|
|
93
|
+
isSelected={index === selectedIndex}
|
|
94
|
+
onClick={() => onSelectFile(result.file, result.line)}
|
|
95
|
+
/>
|
|
96
|
+
))}
|
|
97
|
+
</div>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
interface SearchResultItemProps {
|
|
102
|
+
result: FormattedMatch;
|
|
103
|
+
isSelected: boolean;
|
|
104
|
+
onClick: () => void;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function SearchResultItem({
|
|
108
|
+
result,
|
|
109
|
+
isSelected,
|
|
110
|
+
onClick,
|
|
111
|
+
}: SearchResultItemProps) {
|
|
112
|
+
const language = getLanguageFromPath(result.file);
|
|
113
|
+
const fileName = result.file.split("/").pop() || result.file;
|
|
114
|
+
const filePath = result.file.includes("/")
|
|
115
|
+
? result.file.slice(0, result.file.lastIndexOf("/"))
|
|
116
|
+
: "";
|
|
117
|
+
|
|
118
|
+
return (
|
|
119
|
+
<button
|
|
120
|
+
onClick={onClick}
|
|
121
|
+
className={cn(
|
|
122
|
+
"flex min-h-[44px] flex-col gap-2 p-3 text-left transition-colors",
|
|
123
|
+
"hover:bg-accent",
|
|
124
|
+
isSelected && "bg-accent"
|
|
125
|
+
)}
|
|
126
|
+
>
|
|
127
|
+
<div className="flex items-center gap-2">
|
|
128
|
+
<FileCode className="text-muted-foreground h-4 w-4 flex-shrink-0" />
|
|
129
|
+
<div className="min-w-0 flex-1">
|
|
130
|
+
<span className="font-medium">{fileName}</span>
|
|
131
|
+
{filePath && (
|
|
132
|
+
<span className="text-muted-foreground text-xs"> · {filePath}</span>
|
|
133
|
+
)}
|
|
134
|
+
<span className="text-muted-foreground text-xs">
|
|
135
|
+
{" "}
|
|
136
|
+
· Line {result.line}
|
|
137
|
+
</span>
|
|
138
|
+
</div>
|
|
139
|
+
</div>
|
|
140
|
+
|
|
141
|
+
<div className="bg-muted/50 rounded p-2 font-mono text-xs">
|
|
142
|
+
<SyntaxHighlighter
|
|
143
|
+
language={language}
|
|
144
|
+
style={vscDarkPlus}
|
|
145
|
+
customStyle={{
|
|
146
|
+
background: "transparent",
|
|
147
|
+
padding: 0,
|
|
148
|
+
margin: 0,
|
|
149
|
+
}}
|
|
150
|
+
wrapLines
|
|
151
|
+
showLineNumbers={false}
|
|
152
|
+
>
|
|
153
|
+
{result.lineText}
|
|
154
|
+
</SyntaxHighlighter>
|
|
155
|
+
</div>
|
|
156
|
+
</button>
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function getLanguageFromPath(path: string): string {
|
|
161
|
+
const ext = path.split(".").pop()?.toLowerCase() || "";
|
|
162
|
+
const map: Record<string, string> = {
|
|
163
|
+
ts: "typescript",
|
|
164
|
+
tsx: "typescript",
|
|
165
|
+
js: "javascript",
|
|
166
|
+
jsx: "javascript",
|
|
167
|
+
json: "json",
|
|
168
|
+
md: "markdown",
|
|
169
|
+
css: "css",
|
|
170
|
+
html: "html",
|
|
171
|
+
py: "python",
|
|
172
|
+
rb: "ruby",
|
|
173
|
+
go: "go",
|
|
174
|
+
rs: "rust",
|
|
175
|
+
};
|
|
176
|
+
return map[ext] || "text";
|
|
177
|
+
}
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useState, useEffect, useCallback } from "react";
|
|
4
|
+
import { WorkerCard, type WorkerInfo, type WorkerStatus } from "./WorkerCard";
|
|
5
|
+
import { Button } from "./ui/button";
|
|
6
|
+
import {
|
|
7
|
+
RefreshCw,
|
|
8
|
+
Users,
|
|
9
|
+
CheckCircle,
|
|
10
|
+
Loader2,
|
|
11
|
+
AlertCircle,
|
|
12
|
+
XCircle,
|
|
13
|
+
} from "lucide-react";
|
|
14
|
+
import { cn } from "@/lib/utils";
|
|
15
|
+
|
|
16
|
+
interface WorkersSummary {
|
|
17
|
+
total: number;
|
|
18
|
+
pending: number;
|
|
19
|
+
running: number;
|
|
20
|
+
waiting: number;
|
|
21
|
+
completed: number;
|
|
22
|
+
failed: number;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface ConductorPanelProps {
|
|
26
|
+
conductorSessionId: string;
|
|
27
|
+
onAttachToWorker?: (workerId: string) => void;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function ConductorPanel({
|
|
31
|
+
conductorSessionId,
|
|
32
|
+
onAttachToWorker,
|
|
33
|
+
}: ConductorPanelProps) {
|
|
34
|
+
const [workers, setWorkers] = useState<WorkerInfo[]>([]);
|
|
35
|
+
const [summary, setSummary] = useState<WorkersSummary | null>(null);
|
|
36
|
+
const [expandedWorkers, setExpandedWorkers] = useState<Set<string>>(
|
|
37
|
+
new Set()
|
|
38
|
+
);
|
|
39
|
+
const [workerOutputs, setWorkerOutputs] = useState<Record<string, string>>(
|
|
40
|
+
{}
|
|
41
|
+
);
|
|
42
|
+
const [loading, setLoading] = useState(true);
|
|
43
|
+
const [refreshing, setRefreshing] = useState(false);
|
|
44
|
+
|
|
45
|
+
const fetchWorkers = useCallback(async () => {
|
|
46
|
+
try {
|
|
47
|
+
const res = await fetch(
|
|
48
|
+
`/api/orchestrate/workers?conductorId=${conductorSessionId}`
|
|
49
|
+
);
|
|
50
|
+
const data = await res.json();
|
|
51
|
+
if (data.workers) {
|
|
52
|
+
setWorkers(data.workers);
|
|
53
|
+
}
|
|
54
|
+
} catch (error) {
|
|
55
|
+
console.error("Failed to fetch workers:", error);
|
|
56
|
+
}
|
|
57
|
+
}, [conductorSessionId]);
|
|
58
|
+
|
|
59
|
+
const fetchSummary = useCallback(async () => {
|
|
60
|
+
try {
|
|
61
|
+
const res = await fetch(
|
|
62
|
+
`/api/orchestrate/workers?conductorId=${conductorSessionId}&summary=true`
|
|
63
|
+
);
|
|
64
|
+
const data = await res.json();
|
|
65
|
+
if (data.summary) {
|
|
66
|
+
setSummary(data.summary);
|
|
67
|
+
}
|
|
68
|
+
} catch (error) {
|
|
69
|
+
console.error("Failed to fetch summary:", error);
|
|
70
|
+
}
|
|
71
|
+
}, [conductorSessionId]);
|
|
72
|
+
|
|
73
|
+
const fetchWorkerOutput = useCallback(async (workerId: string) => {
|
|
74
|
+
try {
|
|
75
|
+
const res = await fetch(`/api/orchestrate/workers/${workerId}?lines=30`);
|
|
76
|
+
const data = await res.json();
|
|
77
|
+
if (data.output) {
|
|
78
|
+
setWorkerOutputs((prev) => ({ ...prev, [workerId]: data.output }));
|
|
79
|
+
}
|
|
80
|
+
} catch (error) {
|
|
81
|
+
console.error("Failed to fetch worker output:", error);
|
|
82
|
+
}
|
|
83
|
+
}, []);
|
|
84
|
+
|
|
85
|
+
const refresh = useCallback(async () => {
|
|
86
|
+
setRefreshing(true);
|
|
87
|
+
await Promise.all([fetchWorkers(), fetchSummary()]);
|
|
88
|
+
setRefreshing(false);
|
|
89
|
+
}, [fetchWorkers, fetchSummary]);
|
|
90
|
+
|
|
91
|
+
// Initial load
|
|
92
|
+
useEffect(() => {
|
|
93
|
+
const load = async () => {
|
|
94
|
+
setLoading(true);
|
|
95
|
+
await Promise.all([fetchWorkers(), fetchSummary()]);
|
|
96
|
+
setLoading(false);
|
|
97
|
+
};
|
|
98
|
+
load();
|
|
99
|
+
}, [fetchWorkers, fetchSummary]);
|
|
100
|
+
|
|
101
|
+
// Poll for updates every 5 seconds
|
|
102
|
+
useEffect(() => {
|
|
103
|
+
const interval = setInterval(refresh, 5000);
|
|
104
|
+
return () => clearInterval(interval);
|
|
105
|
+
}, [refresh]);
|
|
106
|
+
|
|
107
|
+
// Fetch output for expanded workers
|
|
108
|
+
useEffect(() => {
|
|
109
|
+
expandedWorkers.forEach((workerId) => {
|
|
110
|
+
if (!workerOutputs[workerId]) {
|
|
111
|
+
fetchWorkerOutput(workerId);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}, [expandedWorkers, workerOutputs, fetchWorkerOutput]);
|
|
115
|
+
|
|
116
|
+
const toggleExpand = (workerId: string) => {
|
|
117
|
+
setExpandedWorkers((prev) => {
|
|
118
|
+
const next = new Set(prev);
|
|
119
|
+
if (next.has(workerId)) {
|
|
120
|
+
next.delete(workerId);
|
|
121
|
+
} else {
|
|
122
|
+
next.add(workerId);
|
|
123
|
+
// Fetch output when expanding
|
|
124
|
+
fetchWorkerOutput(workerId);
|
|
125
|
+
}
|
|
126
|
+
return next;
|
|
127
|
+
});
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
const handleSendMessage = async (workerId: string, message: string) => {
|
|
131
|
+
try {
|
|
132
|
+
await fetch(`/api/orchestrate/workers/${workerId}`, {
|
|
133
|
+
method: "POST",
|
|
134
|
+
headers: { "Content-Type": "application/json" },
|
|
135
|
+
body: JSON.stringify({ action: "send", message }),
|
|
136
|
+
});
|
|
137
|
+
// Refresh output after sending
|
|
138
|
+
setTimeout(() => fetchWorkerOutput(workerId), 1000);
|
|
139
|
+
} catch (error) {
|
|
140
|
+
console.error("Failed to send message:", error);
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
const handleKillWorker = async (workerId: string) => {
|
|
145
|
+
if (!confirm("Kill this worker?")) return;
|
|
146
|
+
try {
|
|
147
|
+
await fetch(`/api/orchestrate/workers/${workerId}`, {
|
|
148
|
+
method: "DELETE",
|
|
149
|
+
});
|
|
150
|
+
await refresh();
|
|
151
|
+
} catch (error) {
|
|
152
|
+
console.error("Failed to kill worker:", error);
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
if (loading) {
|
|
157
|
+
return (
|
|
158
|
+
<div className="flex h-full items-center justify-center">
|
|
159
|
+
<Loader2 className="text-muted-foreground h-6 w-6 animate-spin" />
|
|
160
|
+
</div>
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (workers.length === 0) {
|
|
165
|
+
return (
|
|
166
|
+
<div className="text-muted-foreground flex h-full flex-col items-center justify-center">
|
|
167
|
+
<Users className="mb-4 h-12 w-12 opacity-50" />
|
|
168
|
+
<p className="text-lg font-medium">No workers yet</p>
|
|
169
|
+
<p className="text-sm">This conductor hasn't spawned any workers.</p>
|
|
170
|
+
<p className="mt-4 max-w-md text-center text-xs">
|
|
171
|
+
Use the MCP tools or API to spawn workers. The conductor can delegate
|
|
172
|
+
tasks to parallel worker sessions.
|
|
173
|
+
</p>
|
|
174
|
+
</div>
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return (
|
|
179
|
+
<div className="flex h-full flex-col">
|
|
180
|
+
{/* Header with summary */}
|
|
181
|
+
<div className="flex items-center justify-between border-b p-4">
|
|
182
|
+
<div className="flex items-center gap-4">
|
|
183
|
+
<div className="flex items-center gap-2">
|
|
184
|
+
<Users className="text-primary h-5 w-5" />
|
|
185
|
+
<span className="font-semibold">Workers</span>
|
|
186
|
+
<span className="text-muted-foreground">
|
|
187
|
+
({summary?.total || workers.length})
|
|
188
|
+
</span>
|
|
189
|
+
</div>
|
|
190
|
+
|
|
191
|
+
{summary && (
|
|
192
|
+
<div className="flex items-center gap-3 text-sm">
|
|
193
|
+
{summary.running > 0 && (
|
|
194
|
+
<div className="flex items-center gap-1 text-green-500">
|
|
195
|
+
<Loader2 className="h-3 w-3 animate-spin" />
|
|
196
|
+
<span>{summary.running} running</span>
|
|
197
|
+
</div>
|
|
198
|
+
)}
|
|
199
|
+
{summary.waiting > 0 && (
|
|
200
|
+
<div className="flex items-center gap-1 text-yellow-500">
|
|
201
|
+
<AlertCircle className="h-3 w-3" />
|
|
202
|
+
<span>{summary.waiting} waiting</span>
|
|
203
|
+
</div>
|
|
204
|
+
)}
|
|
205
|
+
{summary.completed > 0 && (
|
|
206
|
+
<div className="flex items-center gap-1 text-green-500">
|
|
207
|
+
<CheckCircle className="h-3 w-3" />
|
|
208
|
+
<span>{summary.completed} done</span>
|
|
209
|
+
</div>
|
|
210
|
+
)}
|
|
211
|
+
{summary.failed > 0 && (
|
|
212
|
+
<div className="flex items-center gap-1 text-red-500">
|
|
213
|
+
<XCircle className="h-3 w-3" />
|
|
214
|
+
<span>{summary.failed} failed</span>
|
|
215
|
+
</div>
|
|
216
|
+
)}
|
|
217
|
+
</div>
|
|
218
|
+
)}
|
|
219
|
+
</div>
|
|
220
|
+
|
|
221
|
+
<Button
|
|
222
|
+
variant="ghost"
|
|
223
|
+
size="icon-sm"
|
|
224
|
+
onClick={refresh}
|
|
225
|
+
disabled={refreshing}
|
|
226
|
+
>
|
|
227
|
+
<RefreshCw className={cn("h-4 w-4", refreshing && "animate-spin")} />
|
|
228
|
+
</Button>
|
|
229
|
+
</div>
|
|
230
|
+
|
|
231
|
+
{/* Workers grid */}
|
|
232
|
+
<div className="flex-1 overflow-auto p-4">
|
|
233
|
+
<div className="grid grid-cols-1 gap-3 lg:grid-cols-2">
|
|
234
|
+
{workers.map((worker) => (
|
|
235
|
+
<WorkerCard
|
|
236
|
+
key={worker.id}
|
|
237
|
+
worker={worker}
|
|
238
|
+
isExpanded={expandedWorkers.has(worker.id)}
|
|
239
|
+
output={workerOutputs[worker.id]}
|
|
240
|
+
onToggleExpand={() => toggleExpand(worker.id)}
|
|
241
|
+
onViewOutput={() => {
|
|
242
|
+
toggleExpand(worker.id);
|
|
243
|
+
fetchWorkerOutput(worker.id);
|
|
244
|
+
}}
|
|
245
|
+
onSendMessage={(msg) => handleSendMessage(worker.id, msg)}
|
|
246
|
+
onKill={() => handleKillWorker(worker.id)}
|
|
247
|
+
onAttach={
|
|
248
|
+
onAttachToWorker ? () => onAttachToWorker(worker.id) : undefined
|
|
249
|
+
}
|
|
250
|
+
/>
|
|
251
|
+
))}
|
|
252
|
+
</div>
|
|
253
|
+
</div>
|
|
254
|
+
</div>
|
|
255
|
+
);
|
|
256
|
+
}
|