@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,400 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useState, useEffect, useRef, useCallback } from "react";
|
|
4
|
+
import {
|
|
5
|
+
X,
|
|
6
|
+
Save,
|
|
7
|
+
Loader2,
|
|
8
|
+
Copy,
|
|
9
|
+
Check,
|
|
10
|
+
File,
|
|
11
|
+
Plus,
|
|
12
|
+
Minus,
|
|
13
|
+
Edit3,
|
|
14
|
+
} from "lucide-react";
|
|
15
|
+
import { DiffEditor, type Monaco } from "@monaco-editor/react";
|
|
16
|
+
import type { editor } from "monaco-editor";
|
|
17
|
+
import { Button } from "@/components/ui/button";
|
|
18
|
+
import { cn } from "@/lib/utils";
|
|
19
|
+
import type { GitFile } from "@/lib/git-status";
|
|
20
|
+
import type { MultiRepoGitFile } from "@/lib/multi-repo-git";
|
|
21
|
+
|
|
22
|
+
type AnyGitFile = GitFile | MultiRepoGitFile;
|
|
23
|
+
|
|
24
|
+
interface FileEditDialogProps {
|
|
25
|
+
open: boolean;
|
|
26
|
+
onOpenChange: (open: boolean) => void;
|
|
27
|
+
workingDirectory: string;
|
|
28
|
+
file: AnyGitFile;
|
|
29
|
+
allFiles: AnyGitFile[];
|
|
30
|
+
onFileSelect: (file: AnyGitFile) => void;
|
|
31
|
+
onStage: (file: AnyGitFile) => void;
|
|
32
|
+
onUnstage: (file: AnyGitFile) => void;
|
|
33
|
+
onSave: () => void;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function getLanguageFromPath(path: string): string {
|
|
37
|
+
const ext = path.split(".").pop()?.toLowerCase() || "";
|
|
38
|
+
const map: Record<string, string> = {
|
|
39
|
+
ts: "typescript",
|
|
40
|
+
tsx: "typescript",
|
|
41
|
+
js: "javascript",
|
|
42
|
+
jsx: "javascript",
|
|
43
|
+
json: "json",
|
|
44
|
+
md: "markdown",
|
|
45
|
+
css: "css",
|
|
46
|
+
scss: "scss",
|
|
47
|
+
html: "html",
|
|
48
|
+
py: "python",
|
|
49
|
+
rb: "ruby",
|
|
50
|
+
go: "go",
|
|
51
|
+
rs: "rust",
|
|
52
|
+
java: "java",
|
|
53
|
+
c: "c",
|
|
54
|
+
cpp: "cpp",
|
|
55
|
+
h: "c",
|
|
56
|
+
hpp: "cpp",
|
|
57
|
+
sh: "shell",
|
|
58
|
+
bash: "shell",
|
|
59
|
+
yml: "yaml",
|
|
60
|
+
yaml: "yaml",
|
|
61
|
+
xml: "xml",
|
|
62
|
+
sql: "sql",
|
|
63
|
+
};
|
|
64
|
+
return map[ext] || "plaintext";
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function getStatusIcon(status: GitFile["status"]) {
|
|
68
|
+
switch (status) {
|
|
69
|
+
case "modified":
|
|
70
|
+
return <Edit3 className="h-3 w-3 text-yellow-500" />;
|
|
71
|
+
case "added":
|
|
72
|
+
case "untracked":
|
|
73
|
+
return <Plus className="h-3 w-3 text-green-500" />;
|
|
74
|
+
case "deleted":
|
|
75
|
+
return <Minus className="h-3 w-3 text-red-500" />;
|
|
76
|
+
default:
|
|
77
|
+
return <File className="h-3 w-3" />;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function FileEditDialog({
|
|
82
|
+
open,
|
|
83
|
+
onOpenChange,
|
|
84
|
+
workingDirectory,
|
|
85
|
+
file,
|
|
86
|
+
allFiles,
|
|
87
|
+
onFileSelect,
|
|
88
|
+
onStage,
|
|
89
|
+
onUnstage,
|
|
90
|
+
onSave,
|
|
91
|
+
}: FileEditDialogProps) {
|
|
92
|
+
const [originalContent, setOriginalContent] = useState("");
|
|
93
|
+
const [modifiedContent, setModifiedContent] = useState("");
|
|
94
|
+
const [initialModified, setInitialModified] = useState("");
|
|
95
|
+
const [loading, setLoading] = useState(true);
|
|
96
|
+
const [saving, setSaving] = useState(false);
|
|
97
|
+
const [error, setError] = useState<string | null>(null);
|
|
98
|
+
const [copied, setCopied] = useState(false);
|
|
99
|
+
|
|
100
|
+
const editorRef = useRef<editor.IStandaloneDiffEditor | null>(null);
|
|
101
|
+
|
|
102
|
+
// For multi-repo files, use repoPath; otherwise use workingDirectory
|
|
103
|
+
const baseDir =
|
|
104
|
+
"repoPath" in file && file.repoPath ? file.repoPath : workingDirectory;
|
|
105
|
+
// Expand ~ to home directory for display
|
|
106
|
+
const expandedBaseDir = baseDir.startsWith("~")
|
|
107
|
+
? baseDir.replace("~", process.env.HOME || "/Users")
|
|
108
|
+
: baseDir;
|
|
109
|
+
const filePath = `${expandedBaseDir}/${file.path}`;
|
|
110
|
+
const fileName = file.path.split("/").pop() || file.path;
|
|
111
|
+
const repoName = "repoName" in file ? file.repoName : null;
|
|
112
|
+
const hasChanges = modifiedContent !== initialModified;
|
|
113
|
+
|
|
114
|
+
useEffect(() => {
|
|
115
|
+
if (!open) return;
|
|
116
|
+
setLoading(true);
|
|
117
|
+
setError(null);
|
|
118
|
+
|
|
119
|
+
// Use baseDir for git operations (repo path for multi-repo, working directory otherwise)
|
|
120
|
+
const gitBasePath = baseDir;
|
|
121
|
+
|
|
122
|
+
Promise.all([
|
|
123
|
+
fetch(`/api/files/content?path=${encodeURIComponent(filePath)}`).then(
|
|
124
|
+
(r) => r.json()
|
|
125
|
+
),
|
|
126
|
+
fetch(
|
|
127
|
+
`/api/git/file-content?path=${encodeURIComponent(gitBasePath)}&file=${encodeURIComponent(file.path)}`
|
|
128
|
+
).then((r) => r.json()),
|
|
129
|
+
])
|
|
130
|
+
.then(([modData, origData]) => {
|
|
131
|
+
if (modData.error) {
|
|
132
|
+
setError(modData.error);
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
setModifiedContent(modData.content || "");
|
|
136
|
+
setInitialModified(modData.content || "");
|
|
137
|
+
setOriginalContent(
|
|
138
|
+
origData.error || file.status === "untracked"
|
|
139
|
+
? ""
|
|
140
|
+
: origData.content || ""
|
|
141
|
+
);
|
|
142
|
+
})
|
|
143
|
+
.catch(() => setError("Failed to load file"))
|
|
144
|
+
.finally(() => setLoading(false));
|
|
145
|
+
}, [open, filePath, baseDir, file.path, file.status]);
|
|
146
|
+
|
|
147
|
+
const handleSave = async () => {
|
|
148
|
+
setSaving(true);
|
|
149
|
+
try {
|
|
150
|
+
const res = await fetch("/api/files/content", {
|
|
151
|
+
method: "POST",
|
|
152
|
+
headers: { "Content-Type": "application/json" },
|
|
153
|
+
body: JSON.stringify({ path: filePath, content: modifiedContent }),
|
|
154
|
+
});
|
|
155
|
+
const data = await res.json();
|
|
156
|
+
if (data.error) setError(data.error);
|
|
157
|
+
else {
|
|
158
|
+
setInitialModified(modifiedContent);
|
|
159
|
+
onSave();
|
|
160
|
+
}
|
|
161
|
+
} catch {
|
|
162
|
+
setError("Failed to save");
|
|
163
|
+
} finally {
|
|
164
|
+
setSaving(false);
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const handleClose = () => {
|
|
169
|
+
if (hasChanges && !confirm("Discard unsaved changes?")) return;
|
|
170
|
+
onOpenChange(false);
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
const handleEditorMount = useCallback((ed: editor.IStandaloneDiffEditor) => {
|
|
174
|
+
editorRef.current = ed;
|
|
175
|
+
ed.getModifiedEditor().onDidChangeModelContent(() => {
|
|
176
|
+
setModifiedContent(ed.getModifiedEditor().getValue() ?? "");
|
|
177
|
+
});
|
|
178
|
+
}, []);
|
|
179
|
+
|
|
180
|
+
const handleBeforeMount = useCallback((monaco: Monaco) => {
|
|
181
|
+
// Suppress common "cannot find module" errors while keeping useful syntax validation
|
|
182
|
+
// These errors occur because we don't have the project's full TypeScript context
|
|
183
|
+
const diagnosticOptions = {
|
|
184
|
+
noSemanticValidation: false,
|
|
185
|
+
noSyntaxValidation: false,
|
|
186
|
+
diagnosticCodesToIgnore: [
|
|
187
|
+
2307, // Cannot find module
|
|
188
|
+
2792, // Cannot find module (path aliases)
|
|
189
|
+
2304, // Cannot find name (global types)
|
|
190
|
+
1149, // File name differs from already included file
|
|
191
|
+
1005, // ':' expected (JSX confusion)
|
|
192
|
+
2365, // Operator '<' cannot be applied (JSX confusion)
|
|
193
|
+
17004, // Cannot use JSX unless '--jsx' flag provided
|
|
194
|
+
1161, // Unterminated regular expression literal
|
|
195
|
+
1003, // Identifier expected
|
|
196
|
+
1109, // Expression expected
|
|
197
|
+
1160, // Unterminated template literal
|
|
198
|
+
],
|
|
199
|
+
};
|
|
200
|
+
monaco.languages.typescript.typescriptDefaults.setDiagnosticsOptions(
|
|
201
|
+
diagnosticOptions
|
|
202
|
+
);
|
|
203
|
+
monaco.languages.typescript.javascriptDefaults.setDiagnosticsOptions(
|
|
204
|
+
diagnosticOptions
|
|
205
|
+
);
|
|
206
|
+
|
|
207
|
+
monaco.editor.defineTheme("agentOsDiff", {
|
|
208
|
+
base: "vs-dark",
|
|
209
|
+
inherit: true,
|
|
210
|
+
rules: [],
|
|
211
|
+
colors: {
|
|
212
|
+
"editor.background": "#0a0a0a",
|
|
213
|
+
"editorGutter.background": "#0a0a0a",
|
|
214
|
+
"diffEditor.insertedTextBackground": "#22c55e25",
|
|
215
|
+
"diffEditor.insertedLineBackground": "#22c55e15",
|
|
216
|
+
"diffEditor.removedTextBackground": "#ef444425",
|
|
217
|
+
"diffEditor.removedLineBackground": "#ef444415",
|
|
218
|
+
"diffEditor.unchangedRegionBackground": "#141414",
|
|
219
|
+
},
|
|
220
|
+
});
|
|
221
|
+
}, []);
|
|
222
|
+
|
|
223
|
+
if (!open) return null;
|
|
224
|
+
|
|
225
|
+
return (
|
|
226
|
+
<div
|
|
227
|
+
className="fixed inset-0 z-50 flex bg-black/60 backdrop-blur-sm"
|
|
228
|
+
onClick={handleClose}
|
|
229
|
+
>
|
|
230
|
+
<div
|
|
231
|
+
className="bg-background m-auto flex h-[90vh] w-[95vw] max-w-7xl overflow-hidden rounded-lg shadow-2xl"
|
|
232
|
+
onClick={(e) => e.stopPropagation()}
|
|
233
|
+
>
|
|
234
|
+
{/* Left sidebar - file list grouped by repo */}
|
|
235
|
+
<div className="flex w-[280px] flex-shrink-0 flex-col border-r">
|
|
236
|
+
<div className="text-muted-foreground border-b px-3 py-2 text-xs font-medium">
|
|
237
|
+
CHANGED FILES
|
|
238
|
+
</div>
|
|
239
|
+
<div className="flex-1 overflow-y-auto">
|
|
240
|
+
{(() => {
|
|
241
|
+
// Group files by repo
|
|
242
|
+
const grouped = new Map<string, typeof allFiles>();
|
|
243
|
+
for (const f of allFiles) {
|
|
244
|
+
const repoKey = "repoName" in f && f.repoName ? f.repoName : "";
|
|
245
|
+
const existing = grouped.get(repoKey) || [];
|
|
246
|
+
existing.push(f);
|
|
247
|
+
grouped.set(repoKey, existing);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
return Array.from(grouped.entries()).map(([repoKey, files]) => (
|
|
251
|
+
<div key={repoKey || "default"}>
|
|
252
|
+
{repoKey && (
|
|
253
|
+
<div className="bg-muted/50 text-muted-foreground px-3 py-1.5 text-xs font-medium">
|
|
254
|
+
{repoKey}
|
|
255
|
+
</div>
|
|
256
|
+
)}
|
|
257
|
+
{files.map((f) => {
|
|
258
|
+
const isSelected =
|
|
259
|
+
"repoPath" in f && "repoPath" in file
|
|
260
|
+
? f.path === file.path && f.repoPath === file.repoPath
|
|
261
|
+
: f.path === file.path;
|
|
262
|
+
return (
|
|
263
|
+
<button
|
|
264
|
+
key={`${"repoPath" in f ? f.repoPath : ""}-${f.path}`}
|
|
265
|
+
onClick={() => onFileSelect(f)}
|
|
266
|
+
className={cn(
|
|
267
|
+
"hover:bg-accent/50 flex w-full items-center gap-2 px-3 py-2 text-left text-sm",
|
|
268
|
+
isSelected && "bg-accent"
|
|
269
|
+
)}
|
|
270
|
+
>
|
|
271
|
+
{getStatusIcon(f.status)}
|
|
272
|
+
<div className="min-w-0 flex-1">
|
|
273
|
+
<div className="truncate">
|
|
274
|
+
{f.path.split("/").pop()}
|
|
275
|
+
</div>
|
|
276
|
+
<div className="text-muted-foreground truncate text-xs">
|
|
277
|
+
{f.path.includes("/")
|
|
278
|
+
? f.path.slice(0, f.path.lastIndexOf("/"))
|
|
279
|
+
: f.status}
|
|
280
|
+
</div>
|
|
281
|
+
</div>
|
|
282
|
+
</button>
|
|
283
|
+
);
|
|
284
|
+
})}
|
|
285
|
+
</div>
|
|
286
|
+
));
|
|
287
|
+
})()}
|
|
288
|
+
</div>
|
|
289
|
+
</div>
|
|
290
|
+
|
|
291
|
+
{/* Right side - editor */}
|
|
292
|
+
<div className="flex min-w-0 flex-1 flex-col">
|
|
293
|
+
{/* Header */}
|
|
294
|
+
<div className="flex items-center justify-between border-b px-4 py-2">
|
|
295
|
+
<div className="flex min-w-0 items-center gap-2">
|
|
296
|
+
<span className="truncate font-mono text-sm">{fileName}</span>
|
|
297
|
+
<button
|
|
298
|
+
onClick={() => {
|
|
299
|
+
navigator.clipboard.writeText(file.path);
|
|
300
|
+
setCopied(true);
|
|
301
|
+
setTimeout(() => setCopied(false), 2000);
|
|
302
|
+
}}
|
|
303
|
+
className="text-muted-foreground hover:text-foreground"
|
|
304
|
+
>
|
|
305
|
+
{copied ? (
|
|
306
|
+
<Check className="h-3.5 w-3.5 text-green-500" />
|
|
307
|
+
) : (
|
|
308
|
+
<Copy className="h-3.5 w-3.5" />
|
|
309
|
+
)}
|
|
310
|
+
</button>
|
|
311
|
+
{hasChanges && (
|
|
312
|
+
<span className="rounded bg-yellow-500/20 px-1.5 text-xs text-yellow-500">
|
|
313
|
+
Unsaved
|
|
314
|
+
</span>
|
|
315
|
+
)}
|
|
316
|
+
</div>
|
|
317
|
+
<div className="flex items-center gap-2">
|
|
318
|
+
<Button
|
|
319
|
+
variant="outline"
|
|
320
|
+
size="sm"
|
|
321
|
+
onClick={() => (file.staged ? onUnstage(file) : onStage(file))}
|
|
322
|
+
>
|
|
323
|
+
{file.staged ? (
|
|
324
|
+
<>
|
|
325
|
+
<Minus className="mr-1 h-3 w-3" />
|
|
326
|
+
Unstage
|
|
327
|
+
</>
|
|
328
|
+
) : (
|
|
329
|
+
<>
|
|
330
|
+
<Plus className="mr-1 h-3 w-3" />
|
|
331
|
+
Stage
|
|
332
|
+
</>
|
|
333
|
+
)}
|
|
334
|
+
</Button>
|
|
335
|
+
<Button
|
|
336
|
+
size="sm"
|
|
337
|
+
onClick={handleSave}
|
|
338
|
+
disabled={!hasChanges || saving}
|
|
339
|
+
>
|
|
340
|
+
{saving ? (
|
|
341
|
+
<Loader2 className="mr-1 h-3 w-3 animate-spin" />
|
|
342
|
+
) : (
|
|
343
|
+
<Save className="mr-1 h-3 w-3" />
|
|
344
|
+
)}
|
|
345
|
+
Save
|
|
346
|
+
</Button>
|
|
347
|
+
<Button variant="ghost" size="icon" onClick={handleClose}>
|
|
348
|
+
<X className="h-4 w-4" />
|
|
349
|
+
</Button>
|
|
350
|
+
</div>
|
|
351
|
+
</div>
|
|
352
|
+
|
|
353
|
+
{error && (
|
|
354
|
+
<div className="bg-red-500/10 px-4 py-2 text-sm text-red-500">
|
|
355
|
+
{error}
|
|
356
|
+
</div>
|
|
357
|
+
)}
|
|
358
|
+
|
|
359
|
+
{/* Editor */}
|
|
360
|
+
<div className="flex-1 overflow-hidden">
|
|
361
|
+
{loading ? (
|
|
362
|
+
<div className="flex h-full items-center justify-center">
|
|
363
|
+
<Loader2 className="text-muted-foreground h-8 w-8 animate-spin" />
|
|
364
|
+
</div>
|
|
365
|
+
) : (
|
|
366
|
+
<DiffEditor
|
|
367
|
+
original={originalContent}
|
|
368
|
+
modified={modifiedContent}
|
|
369
|
+
language={getLanguageFromPath(file.path)}
|
|
370
|
+
theme="agentOsDiff"
|
|
371
|
+
onMount={handleEditorMount}
|
|
372
|
+
beforeMount={handleBeforeMount}
|
|
373
|
+
options={{
|
|
374
|
+
readOnly: false,
|
|
375
|
+
originalEditable: false,
|
|
376
|
+
renderSideBySide: false,
|
|
377
|
+
fontSize: 13,
|
|
378
|
+
lineHeight: 20,
|
|
379
|
+
minimap: { enabled: false },
|
|
380
|
+
lineNumbers: "on",
|
|
381
|
+
scrollBeyondLastLine: false,
|
|
382
|
+
hideUnchangedRegions: {
|
|
383
|
+
enabled: true,
|
|
384
|
+
revealLineCount: 3,
|
|
385
|
+
minimumLineCount: 5,
|
|
386
|
+
},
|
|
387
|
+
scrollbar: {
|
|
388
|
+
verticalScrollbarSize: 8,
|
|
389
|
+
horizontalScrollbarSize: 8,
|
|
390
|
+
},
|
|
391
|
+
padding: { top: 8, bottom: 8 },
|
|
392
|
+
}}
|
|
393
|
+
/>
|
|
394
|
+
)}
|
|
395
|
+
</div>
|
|
396
|
+
</div>
|
|
397
|
+
</div>
|
|
398
|
+
</div>
|
|
399
|
+
);
|
|
400
|
+
}
|