1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
|
import { useState, useEffect, useCallback } from "react";
import type {
ContractWithRelations,
ContractPhase,
ContractStatus,
ContractRepository,
FileSummary,
TaskSummary,
TemplateSummary,
} from "../../lib/api";
import {
listTemplates,
getTemplate,
createFile,
} from "../../lib/api";
import { PhaseProgressBar } from "./PhaseProgressBar";
import { PhaseHint } from "./PhaseHint";
import { RepositoryPanel } from "./RepositoryPanel";
import { ContractCliInput } from "./ContractCliInput";
import { PhaseDeliverablesPanel } from "./PhaseDeliverablesPanel";
import { CommandModePanel } from "./CommandModePanel";
import { TaskTree } from "../mesh/TaskTree";
type Tab = "overview" | "repos" | "files" | "tasks";
interface ContractDetailProps {
contract: ContractWithRelations;
loading: boolean;
onBack: () => void;
onUpdate: (name: string, description: string) => void;
onDelete: () => void;
onPhaseChange: (phase: ContractPhase) => void;
onStatusChange: (status: ContractStatus) => void;
onFileSelect: (id: string) => void;
onTaskSelect: (id: string) => void;
onTaskCreate: (name: string, plan: string, repositoryUrl?: string) => void;
onRefresh: () => void;
// Repository callbacks
onAddRemoteRepo: (name: string, url: string, isPrimary: boolean) => void;
onAddLocalRepo: (name: string, path: string, isPrimary: boolean) => void;
onCreateManagedRepo: (name: string, isPrimary: boolean) => void;
onDeleteRepo: (repoId: string) => void;
onSetRepoPrimary: (repoId: string) => void;
// File creation callback for phase deliverables
onCreateFileFromTemplate?: (templateId: string, suggestedName: string) => void;
}
const statusConfig: Record<ContractStatus, { label: string; color: string }> = {
active: { label: "Active", color: "text-green-400" },
completed: { label: "Completed", color: "text-blue-400" },
archived: { label: "Archived", color: "text-[#555]" },
};
export function ContractDetail({
contract,
loading,
onBack,
onUpdate,
onDelete,
onPhaseChange,
onStatusChange,
onFileSelect,
onTaskSelect,
onTaskCreate,
onRefresh,
onAddRemoteRepo,
onAddLocalRepo,
onCreateManagedRepo,
onDeleteRepo,
onSetRepoPrimary,
onCreateFileFromTemplate,
}: ContractDetailProps) {
const [activeTab, setActiveTab] = useState<Tab>("overview");
const [isEditing, setIsEditing] = useState(false);
const [name, setName] = useState(contract.name);
const [description, setDescription] = useState(contract.description || "");
const handleSave = () => {
onUpdate(name, description);
setIsEditing(false);
};
const handleCancel = () => {
setName(contract.name);
setDescription(contract.description || "");
setIsEditing(false);
};
if (loading) {
return (
<div className="panel h-full flex items-center justify-center">
<div className="font-mono text-[#9bc3ff] text-sm">Loading...</div>
</div>
);
}
const tabs: { key: Tab; label: string; count?: number }[] = [
{ key: "overview", label: "Overview" },
{ key: "repos", label: "Repositories", count: contract.repositories.length },
{ key: "files", label: "Files", count: contract.files.length },
{ key: "tasks", label: "Tasks", count: contract.tasks.length },
];
return (
<div className="panel h-full flex flex-col min-h-0">
{/* Header */}
<div className="p-4 border-b border-dashed border-[rgba(117,170,252,0.35)]">
<div className="flex items-center justify-between mb-3">
<button
onClick={onBack}
className="font-mono text-xs text-[#75aafc] hover:text-[#9bc3ff] transition-colors"
>
← Back to list
</button>
<div className="flex items-center gap-2">
{isEditing ? (
<>
<button
onClick={handleCancel}
className="px-3 py-1.5 font-mono text-xs text-[#9bc3ff] border border-[rgba(117,170,252,0.25)] hover:border-[#3f6fb3] transition-colors uppercase"
>
Cancel
</button>
<button
onClick={handleSave}
className="px-3 py-1.5 font-mono text-xs text-[#dbe7ff] bg-[#0f3c78] border border-[#3f6fb3] hover:bg-[#153667] transition-colors uppercase"
>
Save
</button>
</>
) : (
<>
<button
onClick={() => setIsEditing(true)}
className="px-3 py-1.5 font-mono text-xs text-[#dbe7ff] border border-[#0f3c78] hover:border-[#3f6fb3] transition-colors uppercase"
>
Edit
</button>
<button
onClick={onDelete}
className="px-3 py-1.5 font-mono text-xs text-red-400 border border-red-400/30 hover:border-red-400/50 transition-colors uppercase"
>
Delete
</button>
</>
)}
</div>
</div>
{isEditing ? (
<div className="space-y-3">
<input
type="text"
value={name}
onChange={(e) => setName(e.target.value)}
className="w-full px-3 py-2 bg-[#0d1b2d] border border-[#3f6fb3] text-[#dbe7ff] font-mono text-sm focus:outline-none focus:border-[#75aafc]"
placeholder="Contract name"
/>
<textarea
value={description}
onChange={(e) => setDescription(e.target.value)}
className="w-full px-3 py-2 bg-[#0d1b2d] border border-[#3f6fb3] text-[#dbe7ff] font-mono text-sm focus:outline-none focus:border-[#75aafc] resize-none"
rows={2}
placeholder="Description (optional)"
/>
</div>
) : (
<>
<div className="flex items-center gap-3 mb-2">
<h2 className="font-mono text-lg text-[#dbe7ff]">
{contract.name}
</h2>
<span
className={`font-mono text-xs uppercase ${
statusConfig[contract.status].color
}`}
>
{statusConfig[contract.status].label}
</span>
{contract.localOnly && (
<span className="px-2 py-0.5 font-mono text-[10px] uppercase text-amber-400 border border-amber-400/30 bg-amber-400/10">
Local-Only
</span>
)}
</div>
{contract.description && (
<p className="font-mono text-sm text-[#9bc3ff] mb-3">
{contract.description}
</p>
)}
</>
)}
{/* Phase progress */}
<div className="mt-4 pt-4 border-t border-dashed border-[rgba(117,170,252,0.2)]">
<PhaseProgressBar
currentPhase={contract.phase}
onPhaseClick={onPhaseChange}
/>
</div>
</div>
{/* Tabs */}
<div className="flex border-b border-[rgba(117,170,252,0.2)]">
{tabs.map((tab) => (
<button
key={tab.key}
onClick={() => setActiveTab(tab.key)}
className={`
px-4 py-2 font-mono text-xs uppercase tracking-wider transition-colors
${
activeTab === tab.key
? "text-[#dbe7ff] border-b-2 border-[#75aafc]"
: "text-[#555] hover:text-[#9bc3ff]"
}
`}
>
{tab.label}
{tab.count !== undefined && tab.count > 0 && (
<span className="ml-1 text-[10px]">({tab.count})</span>
)}
</button>
))}
</div>
{/* Tab content */}
<div className="flex-1 overflow-y-auto p-4 min-h-0">
{activeTab === "overview" && (
<OverviewTab
contract={contract}
onStatusChange={onStatusChange}
onPhaseChange={onPhaseChange}
onCreateFile={onCreateFileFromTemplate}
onRefresh={onRefresh}
/>
)}
{activeTab === "repos" && (
<RepositoryPanel
repositories={contract.repositories}
onAddRemote={onAddRemoteRepo}
onAddLocal={onAddLocalRepo}
onCreateManaged={onCreateManagedRepo}
onDelete={onDeleteRepo}
onSetPrimary={onSetRepoPrimary}
/>
)}
{activeTab === "files" && (
<FilesTab
files={contract.files}
contractId={contract.id}
contractPhase={contract.phase}
onSelect={onFileSelect}
onRefresh={onRefresh}
/>
)}
{activeTab === "tasks" && (
<TasksTab
tasks={contract.tasks}
repositories={contract.repositories}
supervisorTaskId={contract.supervisorTaskId}
contractType={contract.contractType}
onSelect={onTaskSelect}
onCreate={onTaskCreate}
/>
)}
</div>
{/* Chat Input */}
<ContractCliInput
contractId={contract.id}
contract={contract}
onUpdate={onRefresh}
/>
</div>
);
}
// Overview tab
function OverviewTab({
contract,
onStatusChange,
onPhaseChange,
onCreateFile,
onRefresh,
}: {
contract: ContractWithRelations;
onStatusChange: (status: ContractStatus) => void;
onPhaseChange: (phase: ContractPhase) => void;
onCreateFile?: (templateId: string, suggestedName: string) => void;
onRefresh: () => void;
}) {
return (
<div className="space-y-6">
{/* Command Mode controls */}
<CommandModePanel contract={contract} onUpdate={onRefresh} />
{/* Phase deliverables checklist */}
<PhaseDeliverablesPanel
contract={contract}
onCreateFile={onCreateFile}
/>
{/* Phase hint */}
<PhaseHint contract={contract} onAdvancePhase={onPhaseChange} />
{/* Task progress summary */}
<TaskStatusSummary tasks={contract.tasks} />
{/* Stats */}
<div className="grid grid-cols-3 gap-4">
<StatCard label="Repositories" value={contract.repositories.length} />
<StatCard label="Files" value={contract.files.length} />
<StatCard label="Tasks" value={contract.tasks.length} />
</div>
{/* Status change */}
<div>
<h3 className="font-mono text-xs text-[#75aafc] uppercase mb-2">
Status
</h3>
<div className="flex gap-2">
{(["active", "completed", "archived"] as ContractStatus[]).map(
(status) => (
<button
key={status}
onClick={() => onStatusChange(status)}
className={`
px-3 py-1.5 font-mono text-xs uppercase transition-colors
${
contract.status === status
? "bg-[rgba(117,170,252,0.1)] text-[#9bc3ff] border border-[rgba(117,170,252,0.3)]"
: "text-[#555] border border-transparent hover:text-[#75aafc]"
}
`}
>
{status}
</button>
)
)}
</div>
</div>
{/* Metadata */}
<div>
<h3 className="font-mono text-xs text-[#75aafc] uppercase mb-2">
Details
</h3>
<div className="space-y-1 font-mono text-xs text-[#555]">
<p>Created: {new Date(contract.createdAt).toLocaleString()}</p>
<p>Updated: {new Date(contract.updatedAt).toLocaleString()}</p>
<p>Version: {contract.version}</p>
</div>
</div>
</div>
);
}
function StatCard({ label, value }: { label: string; value: number }) {
return (
<div className="p-3 border border-[rgba(117,170,252,0.2)]">
<div className="font-mono text-2xl text-[#dbe7ff]">{value}</div>
<div className="font-mono text-[10px] text-[#555] uppercase">{label}</div>
</div>
);
}
// Task status summary with progress bar
function TaskStatusSummary({ tasks }: { tasks: TaskSummary[] }) {
if (tasks.length === 0) return null;
// Count tasks by status
const statusCounts = {
done: 0,
merged: 0,
running: 0,
pending: 0,
failed: 0,
other: 0,
};
for (const task of tasks) {
switch (task.status) {
case "done":
statusCounts.done++;
break;
case "merged":
statusCounts.merged++;
break;
case "running":
case "initializing":
case "starting":
statusCounts.running++;
break;
case "pending":
statusCounts.pending++;
break;
case "failed":
statusCounts.failed++;
break;
default:
statusCounts.other++;
}
}
const completedCount = statusCounts.done + statusCounts.merged;
const progressPercent = (completedCount / tasks.length) * 100;
// Build summary parts
const parts: string[] = [];
if (completedCount > 0) parts.push(`${completedCount} done`);
if (statusCounts.running > 0) parts.push(`${statusCounts.running} running`);
if (statusCounts.pending > 0) parts.push(`${statusCounts.pending} pending`);
if (statusCounts.failed > 0) parts.push(`${statusCounts.failed} failed`);
return (
<div className="space-y-2">
<h3 className="font-mono text-xs text-[#75aafc] uppercase">
Task Progress
</h3>
{/* Progress bar */}
<div className="h-2 bg-[rgba(117,170,252,0.1)] rounded overflow-hidden">
<div
className="h-full bg-green-400 transition-all duration-300"
style={{ width: `${progressPercent}%` }}
/>
</div>
{/* Summary text */}
<div className="flex items-center justify-between">
<span className="font-mono text-xs text-[#9bc3ff]">
{parts.join(", ")}
</span>
<span className="font-mono text-xs text-[#555]">
{completedCount}/{tasks.length} completed
</span>
</div>
</div>
);
}
// Phase color mapping for badges
const phaseColors: Record<ContractPhase, string> = {
research: "bg-purple-500/20 text-purple-400 border-purple-400/30",
specify: "bg-blue-500/20 text-blue-400 border-blue-400/30",
plan: "bg-cyan-500/20 text-cyan-400 border-cyan-400/30",
execute: "bg-green-500/20 text-green-400 border-green-400/30",
review: "bg-yellow-500/20 text-yellow-400 border-yellow-400/30",
};
// Files tab with template creation
function FilesTab({
files,
contractId,
contractPhase,
onSelect,
onRefresh,
}: {
files: FileSummary[];
contractId: string;
contractPhase: ContractPhase;
onSelect: (id: string) => void;
onRefresh: () => void;
}) {
const [showTemplateModal, setShowTemplateModal] = useState(false);
const [templates, setTemplates] = useState<TemplateSummary[]>([]);
const [loadingTemplates, setLoadingTemplates] = useState(false);
const [creating, setCreating] = useState(false);
const [fileName, setFileName] = useState("");
const [selectedTemplateId, setSelectedTemplateId] = useState<string | null>(null);
// Load templates when modal opens
useEffect(() => {
if (showTemplateModal) {
setLoadingTemplates(true);
listTemplates(contractPhase)
.then((res) => setTemplates(res.templates))
.catch((err) => console.error("Failed to load templates:", err))
.finally(() => setLoadingTemplates(false));
}
}, [showTemplateModal, contractPhase]);
const handleCreateFromTemplate = useCallback(async () => {
if (!fileName.trim() || !selectedTemplateId) return;
setCreating(true);
try {
// Get the full template with body
const template = await getTemplate(selectedTemplateId);
// Create the file with contract (files must belong to contracts)
await createFile({
contractId,
name: fileName.trim(),
description: template.description,
body: template.suggestedBody,
});
// Reset and close
setShowTemplateModal(false);
setFileName("");
setSelectedTemplateId(null);
onRefresh();
} catch (err) {
console.error("Failed to create file from template:", err);
} finally {
setCreating(false);
}
}, [fileName, selectedTemplateId, contractId, onRefresh]);
const handleCloseModal = () => {
setShowTemplateModal(false);
setFileName("");
setSelectedTemplateId(null);
};
return (
<div className="space-y-4">
{/* Create from template button */}
<button
onClick={() => setShowTemplateModal(true)}
className="px-3 py-1.5 font-mono text-xs text-[#9bc3ff] border border-[rgba(117,170,252,0.25)] hover:border-[#3f6fb3] transition-colors"
>
+ Create from Template
</button>
{/* Template Selection Modal */}
{showTemplateModal && (
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/50">
<div className="w-full max-w-lg p-6 bg-[#0a1628] border border-[rgba(117,170,252,0.3)] max-h-[80vh] flex flex-col">
<div className="flex items-center justify-between mb-4">
<h3 className="font-mono text-sm text-[#75aafc] uppercase">
Create File from Template
</h3>
<span className={`px-2 py-0.5 text-[10px] font-mono uppercase border rounded ${phaseColors[contractPhase]}`}>
{contractPhase} phase
</span>
</div>
<div className="space-y-4 flex-1 overflow-y-auto">
{/* File name input */}
<div>
<label className="block font-mono text-xs text-[#555] uppercase mb-1">
File Name
</label>
<input
type="text"
value={fileName}
onChange={(e) => setFileName(e.target.value)}
placeholder="e.g., Project Requirements"
className="w-full px-3 py-2 bg-[#0d1b2d] border border-[#3f6fb3] text-[#dbe7ff] font-mono text-sm focus:outline-none focus:border-[#75aafc]"
autoFocus
/>
</div>
{/* Template selection */}
<div>
<label className="block font-mono text-xs text-[#555] uppercase mb-2">
Select Template
</label>
{loadingTemplates ? (
<p className="font-mono text-xs text-[#555]">Loading templates...</p>
) : templates.length === 0 ? (
<p className="font-mono text-xs text-[#555]">No templates available for {contractPhase} phase</p>
) : (
<div className="space-y-2 max-h-60 overflow-y-auto">
{templates.map((template) => (
<button
key={template.id}
onClick={() => setSelectedTemplateId(template.id)}
className={`w-full text-left p-3 border transition-colors ${
selectedTemplateId === template.id
? "border-[#75aafc] bg-[rgba(117,170,252,0.1)]"
: "border-[rgba(117,170,252,0.2)] hover:border-[rgba(117,170,252,0.4)]"
}`}
>
<div className="flex items-center justify-between mb-1">
<span className="font-mono text-sm text-[#dbe7ff]">
{template.name}
</span>
<span className="font-mono text-[10px] text-[#555]">
{template.elementCount} elements
</span>
</div>
<p className="font-mono text-xs text-[#555]">
{template.description}
</p>
</button>
))}
</div>
)}
</div>
</div>
<div className="flex gap-2 justify-end mt-4 pt-4 border-t border-[rgba(117,170,252,0.2)]">
<button
onClick={handleCloseModal}
className="px-4 py-2 font-mono text-xs text-[#9bc3ff] hover:text-[#dbe7ff] transition-colors"
>
Cancel
</button>
<button
onClick={handleCreateFromTemplate}
disabled={!fileName.trim() || !selectedTemplateId || creating}
className="px-4 py-2 font-mono text-xs text-[#dbe7ff] bg-[#0f3c78] border border-[#3f6fb3] hover:bg-[#153667] transition-colors disabled:opacity-50 disabled:cursor-not-allowed"
>
{creating ? "Creating..." : "Create File"}
</button>
</div>
</div>
</div>
)}
{/* File list */}
{files.length === 0 ? (
<p className="font-mono text-xs text-[#555]">
No files in this contract. Create one from a template above.
</p>
) : (
<div className="space-y-2">
{files.map((file) => (
<button
key={file.id}
onClick={() => onSelect(file.id)}
className="w-full text-left p-3 border border-[rgba(117,170,252,0.2)] hover:border-[rgba(117,170,252,0.4)] transition-colors"
>
<div className="flex items-center justify-between">
<div className="flex items-center gap-2">
<span className="font-mono text-sm text-[#dbe7ff]">
{file.name}
</span>
{file.contractPhase && (
<span
className={`px-1.5 py-0.5 text-[9px] font-mono uppercase border rounded ${
phaseColors[file.contractPhase]
}`}
title={`Added during ${file.contractPhase} phase`}
>
{file.contractPhase}
</span>
)}
</div>
<span className="font-mono text-[10px] text-[#555]">
v{file.version}
</span>
</div>
{file.description && (
<p className="font-mono text-xs text-[#555] mt-1 truncate">
{file.description}
</p>
)}
</button>
))}
</div>
)}
</div>
);
}
// Tasks tab - now using TaskTree for supervisor view
function TasksTab({
tasks,
repositories,
supervisorTaskId,
contractType,
onSelect,
onCreate,
}: {
tasks: TaskSummary[];
repositories: ContractRepository[];
supervisorTaskId: string | null;
contractType: string;
onSelect: (id: string) => void;
onCreate: (name: string, plan: string, repositoryUrl?: string) => void;
}) {
const [isCreating, setIsCreating] = useState(false);
const [taskName, setTaskName] = useState("");
const [taskPlan, setTaskPlan] = useState("# Plan\n\nDescribe what this task should accomplish...");
// Find primary repository or first ready one
const readyRepos = repositories.filter((r) => r.status === "ready");
const primaryRepo = readyRepos.find((r) => r.isPrimary) || readyRepos[0];
const [selectedRepoId, setSelectedRepoId] = useState<string>(primaryRepo?.id || "");
const handleCreate = () => {
if (!taskName.trim()) return;
const selectedRepo = repositories.find((r) => r.id === selectedRepoId);
// Get the URL - for remote repos it's repositoryUrl, for local it's the local path
const repoUrl = selectedRepo?.repositoryUrl || selectedRepo?.localPath;
onCreate(taskName.trim(), taskPlan, repoUrl || undefined);
setIsCreating(false);
setTaskName("");
setTaskPlan("# Plan\n\nDescribe what this task should accomplish...");
setSelectedRepoId(primaryRepo?.id || "");
};
const handleCancel = () => {
setIsCreating(false);
setTaskName("");
setTaskPlan("# Plan\n\nDescribe what this task should accomplish...");
setSelectedRepoId(primaryRepo?.id || "");
};
return (
<div className="space-y-4">
{/* TaskTree with supervisor view */}
<TaskTree
tasks={tasks}
supervisorTaskId={supervisorTaskId}
onSelect={onSelect}
/>
{/* Manual task creation - show for task-type contracts or contracts without supervisors */}
{(contractType === "task" || !supervisorTaskId) && (
<>
<div className="border-t border-[rgba(117,170,252,0.2)] pt-4">
<button
onClick={() => setIsCreating(true)}
className="px-3 py-1.5 font-mono text-xs text-[#9bc3ff] border border-[rgba(117,170,252,0.25)] hover:border-[#3f6fb3] transition-colors"
>
+ Create Task Manually
</button>
</div>
{/* Create Task Modal */}
{isCreating && (
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/50">
<div className="w-full max-w-lg p-6 bg-[#0a1628] border border-[rgba(117,170,252,0.3)]">
<h3 className="font-mono text-sm text-[#75aafc] uppercase mb-4">
Create Task
</h3>
<div className="space-y-4">
<div>
<label className="block font-mono text-xs text-[#555] uppercase mb-1">
Name
</label>
<input
type="text"
value={taskName}
onChange={(e) => setTaskName(e.target.value)}
placeholder="Task name"
className="w-full px-3 py-2 bg-[#0d1b2d] border border-[#3f6fb3] text-[#dbe7ff] font-mono text-sm focus:outline-none focus:border-[#75aafc]"
autoFocus
/>
</div>
{/* Repository selection */}
{readyRepos.length > 0 && (
<div>
<label className="block font-mono text-xs text-[#555] uppercase mb-1">
Repository
</label>
<select
value={selectedRepoId}
onChange={(e) => setSelectedRepoId(e.target.value)}
className="w-full px-3 py-2 bg-[#0d1b2d] border border-[#3f6fb3] text-[#dbe7ff] font-mono text-sm focus:outline-none focus:border-[#75aafc]"
>
<option value="">No repository</option>
{readyRepos.map((repo) => (
<option key={repo.id} value={repo.id}>
{repo.name}
{repo.isPrimary ? " (Primary)" : ""}
{" - "}
{repo.sourceType}
</option>
))}
</select>
</div>
)}
<div>
<label className="block font-mono text-xs text-[#555] uppercase mb-1">
Plan
</label>
<textarea
value={taskPlan}
onChange={(e) => setTaskPlan(e.target.value)}
rows={6}
className="w-full px-3 py-2 bg-[#0d1b2d] border border-[#3f6fb3] text-[#dbe7ff] font-mono text-sm focus:outline-none focus:border-[#75aafc] resize-none"
/>
</div>
<div className="flex gap-2 justify-end">
<button
onClick={handleCancel}
className="px-4 py-2 font-mono text-xs text-[#9bc3ff] hover:text-[#dbe7ff] transition-colors"
>
Cancel
</button>
<button
onClick={handleCreate}
disabled={!taskName.trim()}
className="px-4 py-2 font-mono text-xs text-[#dbe7ff] bg-[#0f3c78] border border-[#3f6fb3] hover:bg-[#153667] transition-colors disabled:opacity-50 disabled:cursor-not-allowed"
>
Create
</button>
</div>
</div>
</div>
</div>
)}
</>
)}
</div>
);
}
|