@mrpatronz/nexusflow 0.2.13 → 0.2.17
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/.github/dependabot.yml +52 -52
- package/.github/workflows/dependabot-merge.yml +53 -0
- package/.github/workflows/release.yml +112 -100
- package/.vscode/launch.json +17 -17
- package/.vscode/tasks.json +17 -17
- package/GETTING_STARTED.md +114 -109
- package/README.md +336 -311
- package/desktop/build-installer.js +228 -0
- package/desktop/build.js +118 -0
- package/desktop/installer/nexusflow.iss +35 -0
- package/desktop/neutralino.config.json +39 -0
- package/desktop/package-lock.json +1060 -0
- package/desktop/package.json +14 -0
- package/dist/commands/desktop.d.ts +12 -0
- package/dist/commands/desktop.d.ts.map +1 -0
- package/dist/commands/desktop.js +119 -0
- package/dist/commands/desktop.js.map +1 -0
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +1 -3
- package/dist/commands/sync.js.map +1 -1
- package/dist/commands/tui.d.ts +8 -0
- package/dist/commands/tui.d.ts.map +1 -0
- package/dist/commands/tui.js +386 -0
- package/dist/commands/tui.js.map +1 -0
- package/dist/commands/ui.d.ts +3 -1
- package/dist/commands/ui.d.ts.map +1 -1
- package/dist/commands/ui.js +76 -19
- package/dist/commands/ui.js.map +1 -1
- package/dist/generators/base.d.ts.map +1 -1
- package/dist/generators/base.js +78 -66
- package/dist/generators/base.js.map +1 -1
- package/dist/generators/codex.js +11 -11
- package/dist/generators/copilot.js +17 -17
- package/dist/generators/cursor.js +5 -5
- package/dist/generators/index.js +50 -50
- package/dist/generators/map-generator.js +14 -14
- package/dist/generators/skills-generator.js +28 -28
- package/dist/gui/app_logo.png +0 -0
- package/dist/gui/assets/index-Ct3qq-X4.js +25 -0
- package/dist/gui/assets/index-P_ZrgHXg.css +1 -0
- package/dist/gui/icons.svg +24 -24
- package/dist/gui/index.html +18 -18
- package/dist/index.js +43 -0
- package/dist/index.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +182 -1
- package/dist/server.js.map +1 -1
- package/dist/server.test.js +78 -0
- package/dist/server.test.js.map +1 -1
- package/dist/types.d.ts +4 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/git.d.ts +16 -0
- package/dist/utils/git.d.ts.map +1 -1
- package/dist/utils/git.js +52 -0
- package/dist/utils/git.js.map +1 -1
- package/dist/utils/multi-git.d.ts +2 -0
- package/dist/utils/multi-git.d.ts.map +1 -1
- package/dist/utils/multi-git.js +5 -2
- package/dist/utils/multi-git.js.map +1 -1
- package/dist/utils/update-check.d.ts +3 -1
- package/dist/utils/update-check.d.ts.map +1 -1
- package/dist/utils/update-check.js +23 -6
- package/dist/utils/update-check.js.map +1 -1
- package/dist/utils/workflows.d.ts +11 -0
- package/dist/utils/workflows.d.ts.map +1 -0
- package/dist/utils/workflows.js +156 -0
- package/dist/utils/workflows.js.map +1 -0
- package/dist/utils/workflows.test.d.ts +2 -0
- package/dist/utils/workflows.test.d.ts.map +1 -0
- package/dist/utils/workflows.test.js +86 -0
- package/dist/utils/workflows.test.js.map +1 -0
- package/extension/media/icon.svg +1 -0
- package/extension/package-lock.json +2673 -2811
- package/extension/package.json +108 -70
- package/extension/src/extension.ts +631 -204
- package/extension/tsconfig.json +21 -19
- package/gui/README.md +73 -73
- package/gui/e2e/wizard.spec.ts +346 -327
- package/gui/eslint.config.js +26 -26
- package/gui/index.html +17 -17
- package/gui/package-lock.json +3079 -3118
- package/gui/package.json +36 -36
- package/gui/playwright.config.ts +41 -41
- package/gui/public/app_logo.png +0 -0
- package/gui/public/icons.svg +24 -24
- package/gui/src/App.css +1 -1
- package/gui/src/App.tsx +3407 -2722
- package/gui/src/assets/vite.svg +1 -1
- package/gui/src/features/changes/ChangesViewer.tsx +388 -388
- package/gui/src/features/knowledge/KnowledgeBase.tsx +84 -84
- package/gui/src/features/onboarding/OnboardingWizard.tsx +230 -230
- package/gui/src/features/plan/ImplementationPlan.tsx +32 -32
- package/gui/src/features/services/ServiceConsole.tsx +250 -250
- package/gui/src/features/sessions/SessionHistory.tsx +195 -195
- package/gui/src/features/workspace/WorkspaceList.tsx +666 -666
- package/gui/src/index.css +152 -110
- package/gui/src/main.tsx +94 -10
- package/gui/src/types.ts +62 -62
- package/gui/tsconfig.app.json +25 -25
- package/gui/tsconfig.json +7 -7
- package/gui/tsconfig.node.json +24 -24
- package/gui/vite.config.ts +12 -12
- package/package.json +56 -56
- package/resources/workflows/plan-implement-review.md +8 -0
- package/resources/workflows/research-verify.md +6 -0
- package/resources/workflows/solo-developer.md +3 -0
- package/scripts/simulate-workspaces.ts +55 -55
- package/src/analyzers/detect-apis.ts +290 -290
- package/src/analyzers/detect-deps.ts +315 -315
- package/src/analyzers/detect-existing.ts +74 -74
- package/src/analyzers/detect-ports.ts +110 -110
- package/src/analyzers/index.ts +97 -97
- package/src/analyzers/messaging-analyzer.ts +254 -254
- package/src/analyzers/readme-summarizer.ts +102 -102
- package/src/analyzers/run-analyzer.ts +269 -269
- package/src/analyzers/tech-stack.ts +283 -283
- package/src/commands/add-repo.ts +157 -157
- package/src/commands/commands.test.ts +155 -155
- package/src/commands/commit.ts +131 -131
- package/src/commands/create.ts +207 -207
- package/src/commands/desktop.ts +128 -0
- package/src/commands/diff.ts +125 -125
- package/src/commands/doctor.ts +357 -357
- package/src/commands/handoff.ts +266 -266
- package/src/commands/init.ts +134 -134
- package/src/commands/list.ts +46 -46
- package/src/commands/logs.ts +63 -63
- package/src/commands/mcp.ts +92 -92
- package/src/commands/open.ts +129 -129
- package/src/commands/pack.ts +73 -73
- package/src/commands/refresh.ts +147 -147
- package/src/commands/remove.ts +98 -98
- package/src/commands/start.ts +117 -117
- package/src/commands/status.ts +54 -54
- package/src/commands/stop.ts +55 -55
- package/src/commands/sync.ts +151 -153
- package/src/commands/tui.ts +424 -0
- package/src/commands/ui.ts +111 -47
- package/src/core/config.test.ts +96 -96
- package/src/core/config.ts +115 -115
- package/src/core/graph.ts +344 -344
- package/src/core/packer.test.ts +99 -99
- package/src/core/packer.ts +107 -107
- package/src/core/scanner.test.ts +61 -61
- package/src/core/scanner.ts +91 -91
- package/src/core/workspace.ts +380 -380
- package/src/core/worktree.ts +120 -120
- package/src/generators/antigravity.ts +32 -32
- package/src/generators/base.ts +240 -227
- package/src/generators/claude.ts +34 -34
- package/src/generators/codex.ts +48 -48
- package/src/generators/copilot.ts +56 -56
- package/src/generators/cursor.ts +44 -44
- package/src/generators/index.ts +250 -250
- package/src/generators/map-generator.test.ts +159 -159
- package/src/generators/map-generator.ts +542 -542
- package/src/generators/plan-generator.ts +481 -481
- package/src/generators/skills-generator.ts +259 -259
- package/src/index.ts +426 -382
- package/src/mcp/server.ts +294 -294
- package/src/orchestration/detect.ts +313 -313
- package/src/orchestration/index.ts +7 -7
- package/src/orchestration/runner.ts +283 -283
- package/src/server.test.ts +555 -464
- package/src/server.ts +1308 -1104
- package/src/types.ts +408 -403
- package/src/utils/detect-ai.test.ts +44 -44
- package/src/utils/detect-ai.ts +84 -84
- package/src/utils/detect-editors.test.ts +48 -48
- package/src/utils/detect-editors.ts +57 -57
- package/src/utils/git.test.ts +74 -74
- package/src/utils/git.ts +117 -61
- package/src/utils/local-ai.test.ts +130 -130
- package/src/utils/local-ai.ts +111 -111
- package/src/utils/multi-git.ts +313 -306
- package/src/utils/prompts.ts +209 -209
- package/src/utils/session-finder.ts +483 -483
- package/src/utils/system-scanner.test.ts +89 -89
- package/src/utils/system-scanner.ts +96 -96
- package/src/utils/update-check.ts +309 -275
- package/src/utils/workflows.test.ts +114 -0
- package/src/utils/workflows.ts +178 -0
- package/tsconfig.json +19 -19
- package/vitest.config.ts +14 -14
- package/dist/gui/assets/index-CFWwqFux.js +0 -23
- package/dist/gui/assets/index-Dvc9QMvl.css +0 -2
|
@@ -1,388 +1,388 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
import { FolderGit2, RefreshCw, Check, Save, ChevronDown, ChevronRight, Copy } from 'lucide-react';
|
|
3
|
-
import type { Feature } from '../../types.js';
|
|
4
|
-
|
|
5
|
-
interface ChangesViewerProps {
|
|
6
|
-
ws: Feature;
|
|
7
|
-
gitChanges: any[];
|
|
8
|
-
gitChangesLoading: boolean;
|
|
9
|
-
syncLoading: boolean;
|
|
10
|
-
syncResults: any[] | null;
|
|
11
|
-
commitMessage: string;
|
|
12
|
-
showCommitModal: boolean;
|
|
13
|
-
commitLoading: boolean;
|
|
14
|
-
commitResults: any[] | null;
|
|
15
|
-
setSyncResults: (val: any[] | null) => void;
|
|
16
|
-
setCommitResults: (val: any[] | null) => void;
|
|
17
|
-
setCommitMessage: (val: string) => void;
|
|
18
|
-
setShowCommitModal: (val: boolean) => void;
|
|
19
|
-
fetchGitChanges: (wsId: string) => Promise<void>;
|
|
20
|
-
handleSyncAll: (wsId: string) => Promise<void>;
|
|
21
|
-
handleCommitAll: (wsId: string) => Promise<void>;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const API_BASE = import.meta.env.DEV ? 'http://localhost:3000' : '';
|
|
25
|
-
|
|
26
|
-
export const ChangesViewer: React.FC<ChangesViewerProps> = ({
|
|
27
|
-
ws,
|
|
28
|
-
gitChanges,
|
|
29
|
-
gitChangesLoading,
|
|
30
|
-
syncLoading,
|
|
31
|
-
syncResults,
|
|
32
|
-
commitMessage,
|
|
33
|
-
showCommitModal,
|
|
34
|
-
commitLoading,
|
|
35
|
-
commitResults,
|
|
36
|
-
setSyncResults,
|
|
37
|
-
setCommitResults,
|
|
38
|
-
setCommitMessage,
|
|
39
|
-
setShowCommitModal,
|
|
40
|
-
fetchGitChanges,
|
|
41
|
-
handleSyncAll,
|
|
42
|
-
handleCommitAll,
|
|
43
|
-
}) => {
|
|
44
|
-
const [expandedFiles, setExpandedFiles] = useState<Record<string, boolean>>({});
|
|
45
|
-
const [diffCache, setDiffCache] = useState<Record<string, string>>({});
|
|
46
|
-
const [diffLoading, setDiffLoading] = useState<Record<string, boolean>>({});
|
|
47
|
-
const [diffErrors, setDiffErrors] = useState<Record<string, string>>({});
|
|
48
|
-
const [copiedKey, setCopiedKey] = useState<string>('');
|
|
49
|
-
|
|
50
|
-
const toggleFileExpansion = async (repoName: string, fileName: string) => {
|
|
51
|
-
const cacheKey = `${repoName}/${fileName}`;
|
|
52
|
-
const newExpanded = !expandedFiles[cacheKey];
|
|
53
|
-
setExpandedFiles((prev) => ({ ...prev, [cacheKey]: newExpanded }));
|
|
54
|
-
|
|
55
|
-
if (newExpanded && !diffCache[cacheKey]) {
|
|
56
|
-
setDiffLoading((prev) => ({ ...prev, [cacheKey]: true }));
|
|
57
|
-
setDiffErrors((prev) => ({ ...prev, [cacheKey]: '' }));
|
|
58
|
-
try {
|
|
59
|
-
const encodedId = encodeURIComponent(ws.branchName);
|
|
60
|
-
const encodedRepo = encodeURIComponent(repoName);
|
|
61
|
-
const encodedFile = encodeURIComponent(fileName);
|
|
62
|
-
const res = await fetch(
|
|
63
|
-
`${API_BASE}/api/workspace/${encodedId}/changes/diff?repo=${encodedRepo}&file=${encodedFile}`
|
|
64
|
-
);
|
|
65
|
-
if (!res.ok) {
|
|
66
|
-
throw new Error(`Failed to load diff: ${res.statusText}`);
|
|
67
|
-
}
|
|
68
|
-
const data = await res.json();
|
|
69
|
-
setDiffCache((prev) => ({ ...prev, [cacheKey]: data.diff || '' }));
|
|
70
|
-
} catch (err: any) {
|
|
71
|
-
setDiffErrors((prev) => ({ ...prev, [cacheKey]: err.message || 'Unknown error' }));
|
|
72
|
-
} finally {
|
|
73
|
-
setDiffLoading((prev) => ({ ...prev, [cacheKey]: false }));
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
const renderDiffContent = (diffText: string) => {
|
|
79
|
-
if (!diffText || !diffText.trim()) {
|
|
80
|
-
return <div className="text-slate-500 italic p-3 font-mono text-[11px]">No diff details available.</div>;
|
|
81
|
-
}
|
|
82
|
-
const lines = diffText.split('\n');
|
|
83
|
-
return (
|
|
84
|
-
<pre className="font-mono text-[11px] leading-relaxed overflow-x-auto p-4 rounded-xl bg-slate-950/70 border border-slate-900/80 text-slate-350 max-h-[450px] overflow-y-auto custom-scrollbar select-text">
|
|
85
|
-
{lines.map((line, idx) => {
|
|
86
|
-
let lineClass: string;
|
|
87
|
-
if (line.startsWith('+') && !line.startsWith('+++')) {
|
|
88
|
-
lineClass = 'text-emerald-400 bg-emerald-500/5 px-1 rounded-sm block w-full';
|
|
89
|
-
} else if (line.startsWith('-') && !line.startsWith('---')) {
|
|
90
|
-
lineClass = 'text-rose-400 bg-rose-500/5 px-1 rounded-sm block w-full';
|
|
91
|
-
} else if (line.startsWith('@@')) {
|
|
92
|
-
lineClass = 'text-indigo-400/85 font-semibold italic bg-indigo-500/5 px-1 block w-full';
|
|
93
|
-
} else if (
|
|
94
|
-
line.startsWith('diff') ||
|
|
95
|
-
line.startsWith('index') ||
|
|
96
|
-
line.startsWith('---') ||
|
|
97
|
-
line.startsWith('+++')
|
|
98
|
-
) {
|
|
99
|
-
lineClass = 'text-slate-500 font-bold block w-full';
|
|
100
|
-
} else {
|
|
101
|
-
lineClass = 'text-slate-350 px-1 block w-full';
|
|
102
|
-
}
|
|
103
|
-
return (
|
|
104
|
-
<code key={idx} className={lineClass}>
|
|
105
|
-
{line}
|
|
106
|
-
</code>
|
|
107
|
-
);
|
|
108
|
-
})}
|
|
109
|
-
</pre>
|
|
110
|
-
);
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
return (
|
|
114
|
-
<div className="animate-fade-in">
|
|
115
|
-
<header className="flex justify-between items-center mb-6 flex-wrap gap-3">
|
|
116
|
-
<h4 className="text-sm font-bold text-white flex items-center gap-2">
|
|
117
|
-
<FolderGit2 size={16} className="text-indigo-400" /> Active Workspace Git Diffs
|
|
118
|
-
</h4>
|
|
119
|
-
<div className="flex gap-2">
|
|
120
|
-
<button
|
|
121
|
-
className="inline-flex items-center justify-center gap-1.5 px-3.5 py-2 bg-slate-900 border border-slate-800/80 hover:bg-slate-850 hover:border-slate-700 rounded-xl text-[10px] font-bold transition-all cursor-pointer text-slate-300 hover:text-white"
|
|
122
|
-
onClick={() => fetchGitChanges(ws.branchName)}
|
|
123
|
-
disabled={gitChangesLoading}
|
|
124
|
-
>
|
|
125
|
-
<RefreshCw size={11} className={gitChangesLoading ? 'animate-spin text-indigo-400' : ''} /> Refresh Changes
|
|
126
|
-
</button>
|
|
127
|
-
<button
|
|
128
|
-
className="inline-flex items-center justify-center gap-1.5 px-3.5 py-2 bg-slate-900 border border-slate-800/80 hover:bg-slate-850 hover:border-indigo-500/30 hover:text-indigo-400 rounded-xl text-[10px] font-bold transition-all cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed"
|
|
129
|
-
onClick={() => handleSyncAll(ws.branchName)}
|
|
130
|
-
disabled={syncLoading}
|
|
131
|
-
>
|
|
132
|
-
{syncLoading ? <RefreshCw size={11} className="animate-spin text-indigo-300" /> : <RefreshCw size={11} />} Sync All
|
|
133
|
-
</button>
|
|
134
|
-
<button
|
|
135
|
-
className="inline-flex items-center justify-center gap-1.5 px-4 py-2 bg-emerald-600 hover:bg-emerald-500 text-white rounded-xl text-[10px] font-bold transition-all cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed shadow-md shadow-emerald-500/10"
|
|
136
|
-
onClick={() => setShowCommitModal(true)}
|
|
137
|
-
disabled={gitChanges.every((repo) => repo.files.length === 0) || commitLoading}
|
|
138
|
-
>
|
|
139
|
-
Commit & Push All
|
|
140
|
-
</button>
|
|
141
|
-
</div>
|
|
142
|
-
</header>
|
|
143
|
-
|
|
144
|
-
{/* Sync Results Banner */}
|
|
145
|
-
{syncResults && (
|
|
146
|
-
<div className="bg-indigo-500/5 border border-indigo-500/20 text-indigo-300 rounded-2xl p-5 mb-5 shadow-lg relative overflow-hidden before:absolute before:inset-y-0 before:left-0 before:w-[3px] before:bg-indigo-500">
|
|
147
|
-
<div className="flex justify-between items-center mb-3 border-b border-indigo-500/10 pb-2">
|
|
148
|
-
<h5 className="font-bold text-white font-mono text-xs">Rebase / Sync Action Logs</h5>
|
|
149
|
-
<button
|
|
150
|
-
className="text-indigo-400 hover:text-indigo-300 text-[10px] font-bold cursor-pointer"
|
|
151
|
-
onClick={() => setSyncResults(null)}
|
|
152
|
-
>
|
|
153
|
-
Dismiss
|
|
154
|
-
</button>
|
|
155
|
-
</div>
|
|
156
|
-
<div className="space-y-2">
|
|
157
|
-
{syncResults.map((r: any) => (
|
|
158
|
-
<div
|
|
159
|
-
key={r.repoName}
|
|
160
|
-
className="flex justify-between items-center font-mono text-[10px] bg-slate-950/30 p-2 rounded-lg border border-slate-900/60"
|
|
161
|
-
>
|
|
162
|
-
<span className="text-slate-300 font-semibold">{r.repoName}</span>
|
|
163
|
-
<span className={r.success ? 'text-emerald-400 font-bold' : 'text-rose-400 font-bold'}>
|
|
164
|
-
{r.success ? `✓ Synced (${r.message})` : `✗ Conflict: ${r.message}`}
|
|
165
|
-
</span>
|
|
166
|
-
</div>
|
|
167
|
-
))}
|
|
168
|
-
</div>
|
|
169
|
-
</div>
|
|
170
|
-
)}
|
|
171
|
-
|
|
172
|
-
{/* Commit Results Banner */}
|
|
173
|
-
{commitResults && (
|
|
174
|
-
<div className="bg-emerald-500/5 border border-emerald-500/20 text-emerald-300 rounded-2xl p-5 mb-5 shadow-lg relative overflow-hidden before:absolute before:inset-y-0 before:left-0 before:w-[3px] before:bg-emerald-500">
|
|
175
|
-
<div className="flex justify-between items-center mb-3 border-b border-emerald-500/10 pb-2">
|
|
176
|
-
<h5 className="font-bold text-white font-mono text-xs">Commit & Push Results</h5>
|
|
177
|
-
<button
|
|
178
|
-
className="text-emerald-400 hover:text-emerald-300 text-[10px] font-bold cursor-pointer"
|
|
179
|
-
onClick={() => setCommitResults(null)}
|
|
180
|
-
>
|
|
181
|
-
Dismiss
|
|
182
|
-
</button>
|
|
183
|
-
</div>
|
|
184
|
-
<div className="space-y-2">
|
|
185
|
-
{commitResults.map((r: any) => (
|
|
186
|
-
<div
|
|
187
|
-
key={r.repoName}
|
|
188
|
-
className="flex justify-between items-center font-mono text-[10px] bg-slate-950/30 p-2 rounded-lg border border-slate-900/60"
|
|
189
|
-
>
|
|
190
|
-
<span className="text-slate-300 font-semibold">{r.repoName}</span>
|
|
191
|
-
<span className={r.success ? 'text-emerald-400 font-bold' : 'text-rose-400 font-bold'}>
|
|
192
|
-
{r.success
|
|
193
|
-
? `✓ Committed ${r.filesChanged} file(s) (${r.commitHash ? r.commitHash.slice(0, 7) : 'no hash'})`
|
|
194
|
-
: `✗ Error: ${r.message}`}
|
|
195
|
-
</span>
|
|
196
|
-
</div>
|
|
197
|
-
))}
|
|
198
|
-
</div>
|
|
199
|
-
</div>
|
|
200
|
-
)}
|
|
201
|
-
|
|
202
|
-
{/* Interactive Commit Panel */}
|
|
203
|
-
{showCommitModal && (
|
|
204
|
-
<div className="bg-slate-950/50 border border-slate-850 rounded-2xl p-6 mb-6 shadow-xl relative overflow-hidden before:absolute before:inset-0 before:bg-gradient-to-b before:from-indigo-500/5 before:to-transparent before:pointer-events-none animate-slide-in">
|
|
205
|
-
<h5 className="text-xs font-bold text-white mb-3 flex items-center gap-1.5">
|
|
206
|
-
<Save size={13} className="text-indigo-400" /> Enter Commit Message
|
|
207
|
-
</h5>
|
|
208
|
-
<input
|
|
209
|
-
type="text"
|
|
210
|
-
className="w-full bg-slate-950/60 border border-slate-800 focus:border-indigo-500/80 focus:ring-1 focus:ring-indigo-500/35 rounded-xl px-4 py-3 text-xs font-mono text-white placeholder-slate-600 transition-all outline-none shadow-inner mb-4"
|
|
211
|
-
placeholder="feat: implement multi-repo logic..."
|
|
212
|
-
value={commitMessage}
|
|
213
|
-
onChange={(e) => setCommitMessage(e.target.value)}
|
|
214
|
-
onKeyDown={(e) => {
|
|
215
|
-
if (e.key === 'Enter' && commitMessage.trim()) handleCommitAll(ws.branchName);
|
|
216
|
-
}}
|
|
217
|
-
/>
|
|
218
|
-
<div className="flex justify-end gap-2.5">
|
|
219
|
-
<button
|
|
220
|
-
className="px-4 py-2.5 bg-slate-900 border border-slate-800/80 hover:bg-slate-800 rounded-xl text-[10px] font-bold transition-all cursor-pointer text-slate-400 hover:text-white"
|
|
221
|
-
onClick={() => {
|
|
222
|
-
setShowCommitModal(false);
|
|
223
|
-
setCommitMessage('');
|
|
224
|
-
}}
|
|
225
|
-
disabled={commitLoading}
|
|
226
|
-
>
|
|
227
|
-
Cancel
|
|
228
|
-
</button>
|
|
229
|
-
<button
|
|
230
|
-
className="px-4 py-2.5 bg-emerald-650 hover:bg-emerald-600 rounded-xl text-[10px] font-bold text-white transition-all cursor-pointer shadow-md shadow-emerald-500/10 disabled:opacity-40 disabled:cursor-not-allowed"
|
|
231
|
-
onClick={() => handleCommitAll(ws.branchName)}
|
|
232
|
-
disabled={commitLoading || !commitMessage.trim()}
|
|
233
|
-
>
|
|
234
|
-
{commitLoading ? 'Committing...' : 'Commit & Push All'}
|
|
235
|
-
</button>
|
|
236
|
-
</div>
|
|
237
|
-
</div>
|
|
238
|
-
)}
|
|
239
|
-
|
|
240
|
-
{gitChangesLoading ? (
|
|
241
|
-
<div className="flex justify-center py-20 animate-pulse">
|
|
242
|
-
<RefreshCw className="animate-spin text-indigo-400" size={24} />
|
|
243
|
-
</div>
|
|
244
|
-
) : (
|
|
245
|
-
<div className="space-y-6">
|
|
246
|
-
{gitChanges.every((repo) => repo.files.length === 0) ? (
|
|
247
|
-
<div className="flex flex-col items-center justify-center py-16 bg-slate-950/20 border border-slate-850 rounded-2xl text-center">
|
|
248
|
-
<div className="w-10 h-10 rounded-full bg-emerald-500/10 border border-emerald-500/20 flex items-center justify-center text-emerald-400 mb-3 shadow-md">
|
|
249
|
-
<Check size={20} />
|
|
250
|
-
</div>
|
|
251
|
-
<h5 className="text-sm font-bold text-white">No Uncommitted Changes</h5>
|
|
252
|
-
<p className="text-xs text-slate-500 mt-1">
|
|
253
|
-
Workspace repositories are completely in sync with Git feature branches.
|
|
254
|
-
</p>
|
|
255
|
-
</div>
|
|
256
|
-
) : (
|
|
257
|
-
gitChanges.map((repo) => {
|
|
258
|
-
if (repo.files.length === 0) return null;
|
|
259
|
-
const totalFilesChanged = repo.files.length;
|
|
260
|
-
const repoAdditions = repo.files.reduce((acc: number, f: any) => acc + (f.additions || 0), 0);
|
|
261
|
-
const repoDeletions = repo.files.reduce((acc: number, f: any) => acc + (f.deletions || 0), 0);
|
|
262
|
-
|
|
263
|
-
return (
|
|
264
|
-
<div
|
|
265
|
-
key={repo.repoName}
|
|
266
|
-
className="glass-card p-6 rounded-2xl border border-slate-800/40 relative overflow-hidden transition-all duration-300 before:absolute before:inset-x-0 before:top-0 before:h-[1px] before:bg-gradient-to-r before:from-indigo-500/10 via-purple-500/10 to-transparent"
|
|
267
|
-
>
|
|
268
|
-
<div className="flex justify-between items-center mb-4 flex-wrap gap-2">
|
|
269
|
-
<div className="flex items-center gap-2.5">
|
|
270
|
-
<h5 className="text-sm font-bold text-white font-mono">{repo.repoName}</h5>
|
|
271
|
-
<span className="text-[9px] px-2 py-0.5 rounded bg-slate-900 border border-slate-850 text-slate-400 font-mono font-bold uppercase tracking-wide">
|
|
272
|
-
{totalFilesChanged} file{totalFilesChanged === 1 ? '' : 's'} changed
|
|
273
|
-
</span>
|
|
274
|
-
{(repoAdditions > 0 || repoDeletions > 0) && (
|
|
275
|
-
<span className="text-[10px] font-mono font-bold bg-slate-950/40 border border-slate-900/60 px-2 py-0.5 rounded">
|
|
276
|
-
<span className="text-emerald-400 font-bold">+{repoAdditions}</span>{' '}
|
|
277
|
-
<span className="text-rose-400 font-bold">-{repoDeletions}</span>
|
|
278
|
-
</span>
|
|
279
|
-
)}
|
|
280
|
-
</div>
|
|
281
|
-
<span
|
|
282
|
-
className="text-[10px] text-slate-500 font-mono truncate max-w-[280px]"
|
|
283
|
-
title={repo.repoPath}
|
|
284
|
-
>
|
|
285
|
-
{repo.repoPath}
|
|
286
|
-
</span>
|
|
287
|
-
</div>
|
|
288
|
-
|
|
289
|
-
<div className="flex flex-col gap-3">
|
|
290
|
-
{repo.files.map((fileInfo: any) => {
|
|
291
|
-
const cacheKey = `${repo.repoName}/${fileInfo.file}`;
|
|
292
|
-
const isExpanded = !!expandedFiles[cacheKey];
|
|
293
|
-
const isLoading = !!diffLoading[cacheKey];
|
|
294
|
-
const fileDiff = diffCache[cacheKey] || '';
|
|
295
|
-
const error = diffErrors[cacheKey] || '';
|
|
296
|
-
|
|
297
|
-
return (
|
|
298
|
-
<div
|
|
299
|
-
key={fileInfo.file}
|
|
300
|
-
className="border border-slate-900 rounded-xl overflow-hidden bg-slate-950/20 hover:border-slate-800/80 transition-all duration-200"
|
|
301
|
-
>
|
|
302
|
-
{/* File Header Row */}
|
|
303
|
-
<div
|
|
304
|
-
className="flex justify-between items-center px-4 py-3 cursor-pointer select-none hover:bg-slate-900/40 transition-colors"
|
|
305
|
-
onClick={() => toggleFileExpansion(repo.repoName, fileInfo.file)}
|
|
306
|
-
>
|
|
307
|
-
<div className="flex items-center gap-2.5 min-w-0">
|
|
308
|
-
{isExpanded ? (
|
|
309
|
-
<ChevronDown size={14} className="text-indigo-400 shrink-0" />
|
|
310
|
-
) : (
|
|
311
|
-
<ChevronRight size={14} className="text-slate-500 shrink-0" />
|
|
312
|
-
)}
|
|
313
|
-
<span
|
|
314
|
-
className="font-mono text-slate-300 hover:text-white text-[11px] truncate max-w-[240px] sm:max-w-[480px]"
|
|
315
|
-
title={fileInfo.file}
|
|
316
|
-
>
|
|
317
|
-
{fileInfo.file}
|
|
318
|
-
</span>
|
|
319
|
-
{(fileInfo.additions > 0 || fileInfo.deletions > 0) && (
|
|
320
|
-
<span className="text-[9px] font-mono font-bold text-slate-500 shrink-0 ml-1">
|
|
321
|
-
<span className="text-emerald-500">+{fileInfo.additions}</span> /{' '}
|
|
322
|
-
<span className="text-rose-500">-{fileInfo.deletions}</span>
|
|
323
|
-
</span>
|
|
324
|
-
)}
|
|
325
|
-
</div>
|
|
326
|
-
<div className="flex items-center gap-2.5 shrink-0">
|
|
327
|
-
<span
|
|
328
|
-
className={`text-[8px] px-2 py-0.5 rounded font-bold uppercase tracking-wider ${
|
|
329
|
-
fileInfo.type === 'added'
|
|
330
|
-
? 'bg-emerald-500/10 text-emerald-400 border border-emerald-500/20'
|
|
331
|
-
: fileInfo.type === 'deleted'
|
|
332
|
-
? 'bg-rose-500/10 text-rose-400 border border-rose-500/20'
|
|
333
|
-
: 'bg-amber-500/10 text-amber-400 border border-amber-500/20'
|
|
334
|
-
}`}
|
|
335
|
-
>
|
|
336
|
-
{fileInfo.type}
|
|
337
|
-
</span>
|
|
338
|
-
</div>
|
|
339
|
-
</div>
|
|
340
|
-
|
|
341
|
-
{/* Diff Details Section */}
|
|
342
|
-
{isExpanded && (
|
|
343
|
-
<div className="border-t border-slate-900/60 p-3 bg-slate-950/40">
|
|
344
|
-
{isLoading ? (
|
|
345
|
-
<div className="flex items-center gap-2 text-[10px] text-indigo-400 p-2 font-mono">
|
|
346
|
-
<RefreshCw size={12} className="animate-spin" /> Loading diff...
|
|
347
|
-
</div>
|
|
348
|
-
) : error ? (
|
|
349
|
-
<div className="text-rose-400 text-[10px] p-2 font-mono">Error: {error}</div>
|
|
350
|
-
) : (
|
|
351
|
-
<div className="relative">
|
|
352
|
-
{/* Copy Button */}
|
|
353
|
-
<div className="absolute top-2 right-2 z-10">
|
|
354
|
-
<button
|
|
355
|
-
onClick={(e) => {
|
|
356
|
-
e.stopPropagation();
|
|
357
|
-
navigator.clipboard.writeText(fileDiff);
|
|
358
|
-
setCopiedKey(cacheKey);
|
|
359
|
-
setTimeout(() => setCopiedKey(''), 2000);
|
|
360
|
-
}}
|
|
361
|
-
className="p-1.5 bg-slate-900 border border-slate-800 hover:bg-slate-800 rounded-lg text-slate-400 hover:text-white transition-colors cursor-pointer shadow-md"
|
|
362
|
-
title="Copy Diff"
|
|
363
|
-
>
|
|
364
|
-
{copiedKey === cacheKey ? (
|
|
365
|
-
<Check size={12} className="text-emerald-400" />
|
|
366
|
-
) : (
|
|
367
|
-
<Copy size={12} />
|
|
368
|
-
)}
|
|
369
|
-
</button>
|
|
370
|
-
</div>
|
|
371
|
-
{renderDiffContent(fileDiff)}
|
|
372
|
-
</div>
|
|
373
|
-
)}
|
|
374
|
-
</div>
|
|
375
|
-
)}
|
|
376
|
-
</div>
|
|
377
|
-
);
|
|
378
|
-
})}
|
|
379
|
-
</div>
|
|
380
|
-
</div>
|
|
381
|
-
);
|
|
382
|
-
})
|
|
383
|
-
)}
|
|
384
|
-
</div>
|
|
385
|
-
)}
|
|
386
|
-
</div>
|
|
387
|
-
);
|
|
388
|
-
};
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { FolderGit2, RefreshCw, Check, Save, ChevronDown, ChevronRight, Copy } from 'lucide-react';
|
|
3
|
+
import type { Feature } from '../../types.js';
|
|
4
|
+
|
|
5
|
+
interface ChangesViewerProps {
|
|
6
|
+
ws: Feature;
|
|
7
|
+
gitChanges: any[];
|
|
8
|
+
gitChangesLoading: boolean;
|
|
9
|
+
syncLoading: boolean;
|
|
10
|
+
syncResults: any[] | null;
|
|
11
|
+
commitMessage: string;
|
|
12
|
+
showCommitModal: boolean;
|
|
13
|
+
commitLoading: boolean;
|
|
14
|
+
commitResults: any[] | null;
|
|
15
|
+
setSyncResults: (val: any[] | null) => void;
|
|
16
|
+
setCommitResults: (val: any[] | null) => void;
|
|
17
|
+
setCommitMessage: (val: string) => void;
|
|
18
|
+
setShowCommitModal: (val: boolean) => void;
|
|
19
|
+
fetchGitChanges: (wsId: string) => Promise<void>;
|
|
20
|
+
handleSyncAll: (wsId: string) => Promise<void>;
|
|
21
|
+
handleCommitAll: (wsId: string) => Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const API_BASE = import.meta.env.DEV ? 'http://localhost:3000' : '';
|
|
25
|
+
|
|
26
|
+
export const ChangesViewer: React.FC<ChangesViewerProps> = ({
|
|
27
|
+
ws,
|
|
28
|
+
gitChanges,
|
|
29
|
+
gitChangesLoading,
|
|
30
|
+
syncLoading,
|
|
31
|
+
syncResults,
|
|
32
|
+
commitMessage,
|
|
33
|
+
showCommitModal,
|
|
34
|
+
commitLoading,
|
|
35
|
+
commitResults,
|
|
36
|
+
setSyncResults,
|
|
37
|
+
setCommitResults,
|
|
38
|
+
setCommitMessage,
|
|
39
|
+
setShowCommitModal,
|
|
40
|
+
fetchGitChanges,
|
|
41
|
+
handleSyncAll,
|
|
42
|
+
handleCommitAll,
|
|
43
|
+
}) => {
|
|
44
|
+
const [expandedFiles, setExpandedFiles] = useState<Record<string, boolean>>({});
|
|
45
|
+
const [diffCache, setDiffCache] = useState<Record<string, string>>({});
|
|
46
|
+
const [diffLoading, setDiffLoading] = useState<Record<string, boolean>>({});
|
|
47
|
+
const [diffErrors, setDiffErrors] = useState<Record<string, string>>({});
|
|
48
|
+
const [copiedKey, setCopiedKey] = useState<string>('');
|
|
49
|
+
|
|
50
|
+
const toggleFileExpansion = async (repoName: string, fileName: string) => {
|
|
51
|
+
const cacheKey = `${repoName}/${fileName}`;
|
|
52
|
+
const newExpanded = !expandedFiles[cacheKey];
|
|
53
|
+
setExpandedFiles((prev) => ({ ...prev, [cacheKey]: newExpanded }));
|
|
54
|
+
|
|
55
|
+
if (newExpanded && !diffCache[cacheKey]) {
|
|
56
|
+
setDiffLoading((prev) => ({ ...prev, [cacheKey]: true }));
|
|
57
|
+
setDiffErrors((prev) => ({ ...prev, [cacheKey]: '' }));
|
|
58
|
+
try {
|
|
59
|
+
const encodedId = encodeURIComponent(ws.branchName);
|
|
60
|
+
const encodedRepo = encodeURIComponent(repoName);
|
|
61
|
+
const encodedFile = encodeURIComponent(fileName);
|
|
62
|
+
const res = await fetch(
|
|
63
|
+
`${API_BASE}/api/workspace/${encodedId}/changes/diff?repo=${encodedRepo}&file=${encodedFile}`
|
|
64
|
+
);
|
|
65
|
+
if (!res.ok) {
|
|
66
|
+
throw new Error(`Failed to load diff: ${res.statusText}`);
|
|
67
|
+
}
|
|
68
|
+
const data = await res.json();
|
|
69
|
+
setDiffCache((prev) => ({ ...prev, [cacheKey]: data.diff || '' }));
|
|
70
|
+
} catch (err: any) {
|
|
71
|
+
setDiffErrors((prev) => ({ ...prev, [cacheKey]: err.message || 'Unknown error' }));
|
|
72
|
+
} finally {
|
|
73
|
+
setDiffLoading((prev) => ({ ...prev, [cacheKey]: false }));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const renderDiffContent = (diffText: string) => {
|
|
79
|
+
if (!diffText || !diffText.trim()) {
|
|
80
|
+
return <div className="text-slate-500 italic p-3 font-mono text-[11px]">No diff details available.</div>;
|
|
81
|
+
}
|
|
82
|
+
const lines = diffText.split('\n');
|
|
83
|
+
return (
|
|
84
|
+
<pre className="font-mono text-[11px] leading-relaxed overflow-x-auto p-4 rounded-xl bg-slate-950/70 border border-slate-900/80 text-slate-350 max-h-[450px] overflow-y-auto custom-scrollbar select-text">
|
|
85
|
+
{lines.map((line, idx) => {
|
|
86
|
+
let lineClass: string;
|
|
87
|
+
if (line.startsWith('+') && !line.startsWith('+++')) {
|
|
88
|
+
lineClass = 'text-emerald-400 bg-emerald-500/5 px-1 rounded-sm block w-full';
|
|
89
|
+
} else if (line.startsWith('-') && !line.startsWith('---')) {
|
|
90
|
+
lineClass = 'text-rose-400 bg-rose-500/5 px-1 rounded-sm block w-full';
|
|
91
|
+
} else if (line.startsWith('@@')) {
|
|
92
|
+
lineClass = 'text-indigo-400/85 font-semibold italic bg-indigo-500/5 px-1 block w-full';
|
|
93
|
+
} else if (
|
|
94
|
+
line.startsWith('diff') ||
|
|
95
|
+
line.startsWith('index') ||
|
|
96
|
+
line.startsWith('---') ||
|
|
97
|
+
line.startsWith('+++')
|
|
98
|
+
) {
|
|
99
|
+
lineClass = 'text-slate-500 font-bold block w-full';
|
|
100
|
+
} else {
|
|
101
|
+
lineClass = 'text-slate-350 px-1 block w-full';
|
|
102
|
+
}
|
|
103
|
+
return (
|
|
104
|
+
<code key={idx} className={lineClass}>
|
|
105
|
+
{line}
|
|
106
|
+
</code>
|
|
107
|
+
);
|
|
108
|
+
})}
|
|
109
|
+
</pre>
|
|
110
|
+
);
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
return (
|
|
114
|
+
<div className="animate-fade-in">
|
|
115
|
+
<header className="flex justify-between items-center mb-6 flex-wrap gap-3">
|
|
116
|
+
<h4 className="text-sm font-bold text-white flex items-center gap-2">
|
|
117
|
+
<FolderGit2 size={16} className="text-indigo-400" /> Active Workspace Git Diffs
|
|
118
|
+
</h4>
|
|
119
|
+
<div className="flex gap-2">
|
|
120
|
+
<button
|
|
121
|
+
className="inline-flex items-center justify-center gap-1.5 px-3.5 py-2 bg-slate-900 border border-slate-800/80 hover:bg-slate-850 hover:border-slate-700 rounded-xl text-[10px] font-bold transition-all cursor-pointer text-slate-300 hover:text-white"
|
|
122
|
+
onClick={() => fetchGitChanges(ws.branchName)}
|
|
123
|
+
disabled={gitChangesLoading}
|
|
124
|
+
>
|
|
125
|
+
<RefreshCw size={11} className={gitChangesLoading ? 'animate-spin text-indigo-400' : ''} /> Refresh Changes
|
|
126
|
+
</button>
|
|
127
|
+
<button
|
|
128
|
+
className="inline-flex items-center justify-center gap-1.5 px-3.5 py-2 bg-slate-900 border border-slate-800/80 hover:bg-slate-850 hover:border-indigo-500/30 hover:text-indigo-400 rounded-xl text-[10px] font-bold transition-all cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed"
|
|
129
|
+
onClick={() => handleSyncAll(ws.branchName)}
|
|
130
|
+
disabled={syncLoading}
|
|
131
|
+
>
|
|
132
|
+
{syncLoading ? <RefreshCw size={11} className="animate-spin text-indigo-300" /> : <RefreshCw size={11} />} Sync All
|
|
133
|
+
</button>
|
|
134
|
+
<button
|
|
135
|
+
className="inline-flex items-center justify-center gap-1.5 px-4 py-2 bg-emerald-600 hover:bg-emerald-500 text-white rounded-xl text-[10px] font-bold transition-all cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed shadow-md shadow-emerald-500/10"
|
|
136
|
+
onClick={() => setShowCommitModal(true)}
|
|
137
|
+
disabled={gitChanges.every((repo) => repo.files.length === 0) || commitLoading}
|
|
138
|
+
>
|
|
139
|
+
Commit & Push All
|
|
140
|
+
</button>
|
|
141
|
+
</div>
|
|
142
|
+
</header>
|
|
143
|
+
|
|
144
|
+
{/* Sync Results Banner */}
|
|
145
|
+
{syncResults && (
|
|
146
|
+
<div className="bg-indigo-500/5 border border-indigo-500/20 text-indigo-300 rounded-2xl p-5 mb-5 shadow-lg relative overflow-hidden before:absolute before:inset-y-0 before:left-0 before:w-[3px] before:bg-indigo-500">
|
|
147
|
+
<div className="flex justify-between items-center mb-3 border-b border-indigo-500/10 pb-2">
|
|
148
|
+
<h5 className="font-bold text-white font-mono text-xs">Rebase / Sync Action Logs</h5>
|
|
149
|
+
<button
|
|
150
|
+
className="text-indigo-400 hover:text-indigo-300 text-[10px] font-bold cursor-pointer"
|
|
151
|
+
onClick={() => setSyncResults(null)}
|
|
152
|
+
>
|
|
153
|
+
Dismiss
|
|
154
|
+
</button>
|
|
155
|
+
</div>
|
|
156
|
+
<div className="space-y-2">
|
|
157
|
+
{syncResults.map((r: any) => (
|
|
158
|
+
<div
|
|
159
|
+
key={r.repoName}
|
|
160
|
+
className="flex justify-between items-center font-mono text-[10px] bg-slate-950/30 p-2 rounded-lg border border-slate-900/60"
|
|
161
|
+
>
|
|
162
|
+
<span className="text-slate-300 font-semibold">{r.repoName}</span>
|
|
163
|
+
<span className={r.success ? 'text-emerald-400 font-bold' : 'text-rose-400 font-bold'}>
|
|
164
|
+
{r.success ? `✓ Synced (${r.message})` : `✗ Conflict: ${r.message}`}
|
|
165
|
+
</span>
|
|
166
|
+
</div>
|
|
167
|
+
))}
|
|
168
|
+
</div>
|
|
169
|
+
</div>
|
|
170
|
+
)}
|
|
171
|
+
|
|
172
|
+
{/* Commit Results Banner */}
|
|
173
|
+
{commitResults && (
|
|
174
|
+
<div className="bg-emerald-500/5 border border-emerald-500/20 text-emerald-300 rounded-2xl p-5 mb-5 shadow-lg relative overflow-hidden before:absolute before:inset-y-0 before:left-0 before:w-[3px] before:bg-emerald-500">
|
|
175
|
+
<div className="flex justify-between items-center mb-3 border-b border-emerald-500/10 pb-2">
|
|
176
|
+
<h5 className="font-bold text-white font-mono text-xs">Commit & Push Results</h5>
|
|
177
|
+
<button
|
|
178
|
+
className="text-emerald-400 hover:text-emerald-300 text-[10px] font-bold cursor-pointer"
|
|
179
|
+
onClick={() => setCommitResults(null)}
|
|
180
|
+
>
|
|
181
|
+
Dismiss
|
|
182
|
+
</button>
|
|
183
|
+
</div>
|
|
184
|
+
<div className="space-y-2">
|
|
185
|
+
{commitResults.map((r: any) => (
|
|
186
|
+
<div
|
|
187
|
+
key={r.repoName}
|
|
188
|
+
className="flex justify-between items-center font-mono text-[10px] bg-slate-950/30 p-2 rounded-lg border border-slate-900/60"
|
|
189
|
+
>
|
|
190
|
+
<span className="text-slate-300 font-semibold">{r.repoName}</span>
|
|
191
|
+
<span className={r.success ? 'text-emerald-400 font-bold' : 'text-rose-400 font-bold'}>
|
|
192
|
+
{r.success
|
|
193
|
+
? `✓ Committed ${r.filesChanged} file(s) (${r.commitHash ? r.commitHash.slice(0, 7) : 'no hash'})`
|
|
194
|
+
: `✗ Error: ${r.message}`}
|
|
195
|
+
</span>
|
|
196
|
+
</div>
|
|
197
|
+
))}
|
|
198
|
+
</div>
|
|
199
|
+
</div>
|
|
200
|
+
)}
|
|
201
|
+
|
|
202
|
+
{/* Interactive Commit Panel */}
|
|
203
|
+
{showCommitModal && (
|
|
204
|
+
<div className="bg-slate-950/50 border border-slate-850 rounded-2xl p-6 mb-6 shadow-xl relative overflow-hidden before:absolute before:inset-0 before:bg-gradient-to-b before:from-indigo-500/5 before:to-transparent before:pointer-events-none animate-slide-in">
|
|
205
|
+
<h5 className="text-xs font-bold text-white mb-3 flex items-center gap-1.5">
|
|
206
|
+
<Save size={13} className="text-indigo-400" /> Enter Commit Message
|
|
207
|
+
</h5>
|
|
208
|
+
<input
|
|
209
|
+
type="text"
|
|
210
|
+
className="w-full bg-slate-950/60 border border-slate-800 focus:border-indigo-500/80 focus:ring-1 focus:ring-indigo-500/35 rounded-xl px-4 py-3 text-xs font-mono text-white placeholder-slate-600 transition-all outline-none shadow-inner mb-4"
|
|
211
|
+
placeholder="feat: implement multi-repo logic..."
|
|
212
|
+
value={commitMessage}
|
|
213
|
+
onChange={(e) => setCommitMessage(e.target.value)}
|
|
214
|
+
onKeyDown={(e) => {
|
|
215
|
+
if (e.key === 'Enter' && commitMessage.trim()) handleCommitAll(ws.branchName);
|
|
216
|
+
}}
|
|
217
|
+
/>
|
|
218
|
+
<div className="flex justify-end gap-2.5">
|
|
219
|
+
<button
|
|
220
|
+
className="px-4 py-2.5 bg-slate-900 border border-slate-800/80 hover:bg-slate-800 rounded-xl text-[10px] font-bold transition-all cursor-pointer text-slate-400 hover:text-white"
|
|
221
|
+
onClick={() => {
|
|
222
|
+
setShowCommitModal(false);
|
|
223
|
+
setCommitMessage('');
|
|
224
|
+
}}
|
|
225
|
+
disabled={commitLoading}
|
|
226
|
+
>
|
|
227
|
+
Cancel
|
|
228
|
+
</button>
|
|
229
|
+
<button
|
|
230
|
+
className="px-4 py-2.5 bg-emerald-650 hover:bg-emerald-600 rounded-xl text-[10px] font-bold text-white transition-all cursor-pointer shadow-md shadow-emerald-500/10 disabled:opacity-40 disabled:cursor-not-allowed"
|
|
231
|
+
onClick={() => handleCommitAll(ws.branchName)}
|
|
232
|
+
disabled={commitLoading || !commitMessage.trim()}
|
|
233
|
+
>
|
|
234
|
+
{commitLoading ? 'Committing...' : 'Commit & Push All'}
|
|
235
|
+
</button>
|
|
236
|
+
</div>
|
|
237
|
+
</div>
|
|
238
|
+
)}
|
|
239
|
+
|
|
240
|
+
{gitChangesLoading ? (
|
|
241
|
+
<div className="flex justify-center py-20 animate-pulse">
|
|
242
|
+
<RefreshCw className="animate-spin text-indigo-400" size={24} />
|
|
243
|
+
</div>
|
|
244
|
+
) : (
|
|
245
|
+
<div className="space-y-6">
|
|
246
|
+
{gitChanges.every((repo) => repo.files.length === 0) ? (
|
|
247
|
+
<div className="flex flex-col items-center justify-center py-16 bg-slate-950/20 border border-slate-850 rounded-2xl text-center">
|
|
248
|
+
<div className="w-10 h-10 rounded-full bg-emerald-500/10 border border-emerald-500/20 flex items-center justify-center text-emerald-400 mb-3 shadow-md">
|
|
249
|
+
<Check size={20} />
|
|
250
|
+
</div>
|
|
251
|
+
<h5 className="text-sm font-bold text-white">No Uncommitted Changes</h5>
|
|
252
|
+
<p className="text-xs text-slate-500 mt-1">
|
|
253
|
+
Workspace repositories are completely in sync with Git feature branches.
|
|
254
|
+
</p>
|
|
255
|
+
</div>
|
|
256
|
+
) : (
|
|
257
|
+
gitChanges.map((repo) => {
|
|
258
|
+
if (repo.files.length === 0) return null;
|
|
259
|
+
const totalFilesChanged = repo.files.length;
|
|
260
|
+
const repoAdditions = repo.files.reduce((acc: number, f: any) => acc + (f.additions || 0), 0);
|
|
261
|
+
const repoDeletions = repo.files.reduce((acc: number, f: any) => acc + (f.deletions || 0), 0);
|
|
262
|
+
|
|
263
|
+
return (
|
|
264
|
+
<div
|
|
265
|
+
key={repo.repoName}
|
|
266
|
+
className="glass-card p-6 rounded-2xl border border-slate-800/40 relative overflow-hidden transition-all duration-300 before:absolute before:inset-x-0 before:top-0 before:h-[1px] before:bg-gradient-to-r before:from-indigo-500/10 via-purple-500/10 to-transparent"
|
|
267
|
+
>
|
|
268
|
+
<div className="flex justify-between items-center mb-4 flex-wrap gap-2">
|
|
269
|
+
<div className="flex items-center gap-2.5">
|
|
270
|
+
<h5 className="text-sm font-bold text-white font-mono">{repo.repoName}</h5>
|
|
271
|
+
<span className="text-[9px] px-2 py-0.5 rounded bg-slate-900 border border-slate-850 text-slate-400 font-mono font-bold uppercase tracking-wide">
|
|
272
|
+
{totalFilesChanged} file{totalFilesChanged === 1 ? '' : 's'} changed
|
|
273
|
+
</span>
|
|
274
|
+
{(repoAdditions > 0 || repoDeletions > 0) && (
|
|
275
|
+
<span className="text-[10px] font-mono font-bold bg-slate-950/40 border border-slate-900/60 px-2 py-0.5 rounded">
|
|
276
|
+
<span className="text-emerald-400 font-bold">+{repoAdditions}</span>{' '}
|
|
277
|
+
<span className="text-rose-400 font-bold">-{repoDeletions}</span>
|
|
278
|
+
</span>
|
|
279
|
+
)}
|
|
280
|
+
</div>
|
|
281
|
+
<span
|
|
282
|
+
className="text-[10px] text-slate-500 font-mono truncate max-w-[280px]"
|
|
283
|
+
title={repo.repoPath}
|
|
284
|
+
>
|
|
285
|
+
{repo.repoPath}
|
|
286
|
+
</span>
|
|
287
|
+
</div>
|
|
288
|
+
|
|
289
|
+
<div className="flex flex-col gap-3">
|
|
290
|
+
{repo.files.map((fileInfo: any) => {
|
|
291
|
+
const cacheKey = `${repo.repoName}/${fileInfo.file}`;
|
|
292
|
+
const isExpanded = !!expandedFiles[cacheKey];
|
|
293
|
+
const isLoading = !!diffLoading[cacheKey];
|
|
294
|
+
const fileDiff = diffCache[cacheKey] || '';
|
|
295
|
+
const error = diffErrors[cacheKey] || '';
|
|
296
|
+
|
|
297
|
+
return (
|
|
298
|
+
<div
|
|
299
|
+
key={fileInfo.file}
|
|
300
|
+
className="border border-slate-900 rounded-xl overflow-hidden bg-slate-950/20 hover:border-slate-800/80 transition-all duration-200"
|
|
301
|
+
>
|
|
302
|
+
{/* File Header Row */}
|
|
303
|
+
<div
|
|
304
|
+
className="flex justify-between items-center px-4 py-3 cursor-pointer select-none hover:bg-slate-900/40 transition-colors"
|
|
305
|
+
onClick={() => toggleFileExpansion(repo.repoName, fileInfo.file)}
|
|
306
|
+
>
|
|
307
|
+
<div className="flex items-center gap-2.5 min-w-0">
|
|
308
|
+
{isExpanded ? (
|
|
309
|
+
<ChevronDown size={14} className="text-indigo-400 shrink-0" />
|
|
310
|
+
) : (
|
|
311
|
+
<ChevronRight size={14} className="text-slate-500 shrink-0" />
|
|
312
|
+
)}
|
|
313
|
+
<span
|
|
314
|
+
className="font-mono text-slate-300 hover:text-white text-[11px] truncate max-w-[240px] sm:max-w-[480px]"
|
|
315
|
+
title={fileInfo.file}
|
|
316
|
+
>
|
|
317
|
+
{fileInfo.file}
|
|
318
|
+
</span>
|
|
319
|
+
{(fileInfo.additions > 0 || fileInfo.deletions > 0) && (
|
|
320
|
+
<span className="text-[9px] font-mono font-bold text-slate-500 shrink-0 ml-1">
|
|
321
|
+
<span className="text-emerald-500">+{fileInfo.additions}</span> /{' '}
|
|
322
|
+
<span className="text-rose-500">-{fileInfo.deletions}</span>
|
|
323
|
+
</span>
|
|
324
|
+
)}
|
|
325
|
+
</div>
|
|
326
|
+
<div className="flex items-center gap-2.5 shrink-0">
|
|
327
|
+
<span
|
|
328
|
+
className={`text-[8px] px-2 py-0.5 rounded font-bold uppercase tracking-wider ${
|
|
329
|
+
fileInfo.type === 'added'
|
|
330
|
+
? 'bg-emerald-500/10 text-emerald-400 border border-emerald-500/20'
|
|
331
|
+
: fileInfo.type === 'deleted'
|
|
332
|
+
? 'bg-rose-500/10 text-rose-400 border border-rose-500/20'
|
|
333
|
+
: 'bg-amber-500/10 text-amber-400 border border-amber-500/20'
|
|
334
|
+
}`}
|
|
335
|
+
>
|
|
336
|
+
{fileInfo.type}
|
|
337
|
+
</span>
|
|
338
|
+
</div>
|
|
339
|
+
</div>
|
|
340
|
+
|
|
341
|
+
{/* Diff Details Section */}
|
|
342
|
+
{isExpanded && (
|
|
343
|
+
<div className="border-t border-slate-900/60 p-3 bg-slate-950/40">
|
|
344
|
+
{isLoading ? (
|
|
345
|
+
<div className="flex items-center gap-2 text-[10px] text-indigo-400 p-2 font-mono">
|
|
346
|
+
<RefreshCw size={12} className="animate-spin" /> Loading diff...
|
|
347
|
+
</div>
|
|
348
|
+
) : error ? (
|
|
349
|
+
<div className="text-rose-400 text-[10px] p-2 font-mono">Error: {error}</div>
|
|
350
|
+
) : (
|
|
351
|
+
<div className="relative">
|
|
352
|
+
{/* Copy Button */}
|
|
353
|
+
<div className="absolute top-2 right-2 z-10">
|
|
354
|
+
<button
|
|
355
|
+
onClick={(e) => {
|
|
356
|
+
e.stopPropagation();
|
|
357
|
+
navigator.clipboard.writeText(fileDiff);
|
|
358
|
+
setCopiedKey(cacheKey);
|
|
359
|
+
setTimeout(() => setCopiedKey(''), 2000);
|
|
360
|
+
}}
|
|
361
|
+
className="p-1.5 bg-slate-900 border border-slate-800 hover:bg-slate-800 rounded-lg text-slate-400 hover:text-white transition-colors cursor-pointer shadow-md"
|
|
362
|
+
title="Copy Diff"
|
|
363
|
+
>
|
|
364
|
+
{copiedKey === cacheKey ? (
|
|
365
|
+
<Check size={12} className="text-emerald-400" />
|
|
366
|
+
) : (
|
|
367
|
+
<Copy size={12} />
|
|
368
|
+
)}
|
|
369
|
+
</button>
|
|
370
|
+
</div>
|
|
371
|
+
{renderDiffContent(fileDiff)}
|
|
372
|
+
</div>
|
|
373
|
+
)}
|
|
374
|
+
</div>
|
|
375
|
+
)}
|
|
376
|
+
</div>
|
|
377
|
+
);
|
|
378
|
+
})}
|
|
379
|
+
</div>
|
|
380
|
+
</div>
|
|
381
|
+
);
|
|
382
|
+
})
|
|
383
|
+
)}
|
|
384
|
+
</div>
|
|
385
|
+
)}
|
|
386
|
+
</div>
|
|
387
|
+
);
|
|
388
|
+
};
|