@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,146 @@
|
|
|
1
|
+
import { Input } from "@/components/ui/input";
|
|
2
|
+
import { Button } from "@/components/ui/button";
|
|
3
|
+
import {
|
|
4
|
+
Select,
|
|
5
|
+
SelectContent,
|
|
6
|
+
SelectItem,
|
|
7
|
+
SelectTrigger,
|
|
8
|
+
SelectValue,
|
|
9
|
+
} from "@/components/ui/select";
|
|
10
|
+
import { Plus } from "lucide-react";
|
|
11
|
+
import type { ProjectWithDevServers } from "@/lib/projects";
|
|
12
|
+
import type { AgentType } from "@/lib/providers";
|
|
13
|
+
|
|
14
|
+
interface ProjectSelectorProps {
|
|
15
|
+
projects: ProjectWithDevServers[];
|
|
16
|
+
projectId: string | null;
|
|
17
|
+
onProjectChange: (projectId: string | null) => void;
|
|
18
|
+
workingDirectory: string;
|
|
19
|
+
agentType: AgentType;
|
|
20
|
+
showNewProject: boolean;
|
|
21
|
+
onShowNewProjectChange: (show: boolean) => void;
|
|
22
|
+
newProjectName: string;
|
|
23
|
+
onNewProjectNameChange: (name: string) => void;
|
|
24
|
+
creatingProject: boolean;
|
|
25
|
+
onCreateProject: () => void;
|
|
26
|
+
canCreateProject: boolean;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function ProjectSelector({
|
|
30
|
+
projects,
|
|
31
|
+
projectId,
|
|
32
|
+
onProjectChange,
|
|
33
|
+
workingDirectory,
|
|
34
|
+
agentType,
|
|
35
|
+
showNewProject,
|
|
36
|
+
onShowNewProjectChange,
|
|
37
|
+
newProjectName,
|
|
38
|
+
onNewProjectNameChange,
|
|
39
|
+
creatingProject,
|
|
40
|
+
onCreateProject,
|
|
41
|
+
canCreateProject,
|
|
42
|
+
}: ProjectSelectorProps) {
|
|
43
|
+
const selectedProject = projects.find((p) => p.id === projectId);
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<div className="space-y-2">
|
|
47
|
+
<label className="text-sm font-medium">Project</label>
|
|
48
|
+
{showNewProject ? (
|
|
49
|
+
<div className="flex gap-2">
|
|
50
|
+
<Input
|
|
51
|
+
value={newProjectName}
|
|
52
|
+
onChange={(e) => onNewProjectNameChange(e.target.value)}
|
|
53
|
+
placeholder="Project name"
|
|
54
|
+
onKeyDown={(e) => {
|
|
55
|
+
if (e.key === "Enter") {
|
|
56
|
+
e.preventDefault();
|
|
57
|
+
onCreateProject();
|
|
58
|
+
} else if (e.key === "Escape") {
|
|
59
|
+
onShowNewProjectChange(false);
|
|
60
|
+
onNewProjectNameChange("");
|
|
61
|
+
}
|
|
62
|
+
}}
|
|
63
|
+
disabled={creatingProject}
|
|
64
|
+
/>
|
|
65
|
+
<Button
|
|
66
|
+
type="button"
|
|
67
|
+
variant="outline"
|
|
68
|
+
size="sm"
|
|
69
|
+
onClick={onCreateProject}
|
|
70
|
+
disabled={
|
|
71
|
+
!newProjectName.trim() ||
|
|
72
|
+
creatingProject ||
|
|
73
|
+
!workingDirectory ||
|
|
74
|
+
workingDirectory === "~"
|
|
75
|
+
}
|
|
76
|
+
>
|
|
77
|
+
{creatingProject ? "Creating..." : "Create"}
|
|
78
|
+
</Button>
|
|
79
|
+
<Button
|
|
80
|
+
type="button"
|
|
81
|
+
variant="ghost"
|
|
82
|
+
size="sm"
|
|
83
|
+
onClick={() => {
|
|
84
|
+
onShowNewProjectChange(false);
|
|
85
|
+
onNewProjectNameChange("");
|
|
86
|
+
}}
|
|
87
|
+
disabled={creatingProject}
|
|
88
|
+
>
|
|
89
|
+
Cancel
|
|
90
|
+
</Button>
|
|
91
|
+
</div>
|
|
92
|
+
) : (
|
|
93
|
+
<div className="flex gap-2">
|
|
94
|
+
<Select
|
|
95
|
+
value={projectId || "none"}
|
|
96
|
+
onValueChange={(v) => onProjectChange(v === "none" ? null : v)}
|
|
97
|
+
>
|
|
98
|
+
<SelectTrigger className="flex-1">
|
|
99
|
+
<SelectValue placeholder="Select a project" />
|
|
100
|
+
</SelectTrigger>
|
|
101
|
+
<SelectContent>
|
|
102
|
+
<SelectItem value="none">
|
|
103
|
+
<span className="text-muted-foreground">
|
|
104
|
+
No project (uncategorized)
|
|
105
|
+
</span>
|
|
106
|
+
</SelectItem>
|
|
107
|
+
{projects
|
|
108
|
+
.filter((p) => !p.is_uncategorized)
|
|
109
|
+
.map((project) => (
|
|
110
|
+
<SelectItem key={project.id} value={project.id}>
|
|
111
|
+
{project.name}
|
|
112
|
+
</SelectItem>
|
|
113
|
+
))}
|
|
114
|
+
</SelectContent>
|
|
115
|
+
</Select>
|
|
116
|
+
{canCreateProject && (
|
|
117
|
+
<Button
|
|
118
|
+
type="button"
|
|
119
|
+
variant="outline"
|
|
120
|
+
size="icon"
|
|
121
|
+
onClick={() => onShowNewProjectChange(true)}
|
|
122
|
+
title="Create new project"
|
|
123
|
+
>
|
|
124
|
+
<Plus className="h-4 w-4" />
|
|
125
|
+
</Button>
|
|
126
|
+
)}
|
|
127
|
+
</div>
|
|
128
|
+
)}
|
|
129
|
+
{showNewProject && (
|
|
130
|
+
<p className="text-muted-foreground text-xs">
|
|
131
|
+
{workingDirectory && workingDirectory !== "~"
|
|
132
|
+
? `New project will use: ${workingDirectory}, ${agentType}`
|
|
133
|
+
: "Enter a working directory above to create a project"}
|
|
134
|
+
</p>
|
|
135
|
+
)}
|
|
136
|
+
{!showNewProject &&
|
|
137
|
+
selectedProject &&
|
|
138
|
+
!selectedProject.is_uncategorized && (
|
|
139
|
+
<p className="text-muted-foreground text-xs">
|
|
140
|
+
Settings inherited: {selectedProject.working_directory},{" "}
|
|
141
|
+
{selectedProject.agent_type}
|
|
142
|
+
</p>
|
|
143
|
+
)}
|
|
144
|
+
</div>
|
|
145
|
+
);
|
|
146
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Input } from "@/components/ui/input";
|
|
2
|
+
import { Button } from "@/components/ui/button";
|
|
3
|
+
import { GitBranch, Loader2, FolderOpen } from "lucide-react";
|
|
4
|
+
import type { GitInfo } from "./NewSessionDialog.types";
|
|
5
|
+
|
|
6
|
+
interface WorkingDirectoryInputProps {
|
|
7
|
+
value: string;
|
|
8
|
+
onChange: (value: string) => void;
|
|
9
|
+
gitInfo: GitInfo | null;
|
|
10
|
+
checkingGit: boolean;
|
|
11
|
+
onBrowse: () => void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function WorkingDirectoryInput({
|
|
15
|
+
value,
|
|
16
|
+
onChange,
|
|
17
|
+
gitInfo,
|
|
18
|
+
checkingGit,
|
|
19
|
+
onBrowse,
|
|
20
|
+
}: WorkingDirectoryInputProps) {
|
|
21
|
+
return (
|
|
22
|
+
<div className="space-y-2">
|
|
23
|
+
<label className="text-sm font-medium">Working Directory</label>
|
|
24
|
+
<div className="flex gap-2">
|
|
25
|
+
<div className="relative flex-1">
|
|
26
|
+
<Input
|
|
27
|
+
value={value}
|
|
28
|
+
onChange={(e) => onChange(e.target.value)}
|
|
29
|
+
placeholder="~/projects/my-app"
|
|
30
|
+
/>
|
|
31
|
+
{checkingGit && (
|
|
32
|
+
<div className="absolute top-1/2 right-3 -translate-y-1/2">
|
|
33
|
+
<Loader2 className="text-muted-foreground h-4 w-4 animate-spin" />
|
|
34
|
+
</div>
|
|
35
|
+
)}
|
|
36
|
+
</div>
|
|
37
|
+
<Button
|
|
38
|
+
type="button"
|
|
39
|
+
variant="outline"
|
|
40
|
+
size="icon"
|
|
41
|
+
onClick={onBrowse}
|
|
42
|
+
title="Browse directories"
|
|
43
|
+
>
|
|
44
|
+
<FolderOpen className="h-4 w-4" />
|
|
45
|
+
</Button>
|
|
46
|
+
</div>
|
|
47
|
+
{gitInfo?.isGitRepo && (
|
|
48
|
+
<p className="text-muted-foreground flex items-center gap-1 text-xs">
|
|
49
|
+
<GitBranch className="h-3 w-3" />
|
|
50
|
+
Git repo on {gitInfo.currentBranch}
|
|
51
|
+
</p>
|
|
52
|
+
)}
|
|
53
|
+
</div>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { Input } from "@/components/ui/input";
|
|
2
|
+
import {
|
|
3
|
+
Select,
|
|
4
|
+
SelectContent,
|
|
5
|
+
SelectItem,
|
|
6
|
+
SelectTrigger,
|
|
7
|
+
SelectValue,
|
|
8
|
+
} from "@/components/ui/select";
|
|
9
|
+
import type { GitInfo } from "./NewSessionDialog.types";
|
|
10
|
+
|
|
11
|
+
interface WorktreeSectionProps {
|
|
12
|
+
gitInfo: GitInfo;
|
|
13
|
+
useWorktree: boolean;
|
|
14
|
+
onUseWorktreeChange: (checked: boolean) => void;
|
|
15
|
+
featureName: string;
|
|
16
|
+
onFeatureNameChange: (value: string) => void;
|
|
17
|
+
baseBranch: string;
|
|
18
|
+
onBaseBranchChange: (value: string) => void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function WorktreeSection({
|
|
22
|
+
gitInfo,
|
|
23
|
+
useWorktree,
|
|
24
|
+
onUseWorktreeChange,
|
|
25
|
+
featureName,
|
|
26
|
+
onFeatureNameChange,
|
|
27
|
+
baseBranch,
|
|
28
|
+
onBaseBranchChange,
|
|
29
|
+
}: WorktreeSectionProps) {
|
|
30
|
+
if (!gitInfo.isGitRepo) return null;
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<div className="bg-accent/40 space-y-3 rounded-lg p-3">
|
|
34
|
+
<div className="flex items-center gap-2">
|
|
35
|
+
<input
|
|
36
|
+
type="checkbox"
|
|
37
|
+
id="useWorktree"
|
|
38
|
+
checked={useWorktree}
|
|
39
|
+
onChange={(e) => onUseWorktreeChange(e.target.checked)}
|
|
40
|
+
className="border-border bg-background accent-primary h-4 w-4 rounded"
|
|
41
|
+
/>
|
|
42
|
+
<label
|
|
43
|
+
htmlFor="useWorktree"
|
|
44
|
+
className="cursor-pointer text-sm font-medium"
|
|
45
|
+
>
|
|
46
|
+
Create isolated worktree
|
|
47
|
+
</label>
|
|
48
|
+
</div>
|
|
49
|
+
|
|
50
|
+
{useWorktree && (
|
|
51
|
+
<div className="space-y-3 pl-6">
|
|
52
|
+
<div className="space-y-1">
|
|
53
|
+
<label className="text-muted-foreground text-xs">
|
|
54
|
+
Feature Name
|
|
55
|
+
</label>
|
|
56
|
+
<Input
|
|
57
|
+
value={featureName}
|
|
58
|
+
onChange={(e) => onFeatureNameChange(e.target.value)}
|
|
59
|
+
placeholder="add-dark-mode"
|
|
60
|
+
className="h-8 text-sm"
|
|
61
|
+
/>
|
|
62
|
+
{featureName && (
|
|
63
|
+
<p className="text-muted-foreground text-xs">
|
|
64
|
+
Branch: feature/
|
|
65
|
+
{featureName
|
|
66
|
+
.toLowerCase()
|
|
67
|
+
.replace(/[^a-z0-9]+/g, "-")
|
|
68
|
+
.replace(/^-+|-+$/g, "")
|
|
69
|
+
.slice(0, 50)}
|
|
70
|
+
</p>
|
|
71
|
+
)}
|
|
72
|
+
</div>
|
|
73
|
+
<div className="space-y-1">
|
|
74
|
+
<label className="text-muted-foreground text-xs">Base Branch</label>
|
|
75
|
+
<Select value={baseBranch} onValueChange={onBaseBranchChange}>
|
|
76
|
+
<SelectTrigger className="h-8 text-sm">
|
|
77
|
+
<SelectValue />
|
|
78
|
+
</SelectTrigger>
|
|
79
|
+
<SelectContent>
|
|
80
|
+
{gitInfo.branches.map((branch) => (
|
|
81
|
+
<SelectItem key={branch} value={branch}>
|
|
82
|
+
{branch}
|
|
83
|
+
</SelectItem>
|
|
84
|
+
))}
|
|
85
|
+
</SelectContent>
|
|
86
|
+
</Select>
|
|
87
|
+
</div>
|
|
88
|
+
</div>
|
|
89
|
+
)}
|
|
90
|
+
</div>
|
|
91
|
+
);
|
|
92
|
+
}
|
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
import { useState, useEffect, useCallback } from "react";
|
|
2
|
+
import { getProviderDefinition, type AgentType } from "@/lib/providers";
|
|
3
|
+
import type { ProjectWithDevServers } from "@/lib/projects";
|
|
4
|
+
import { setPendingPrompt } from "@/stores/initialPrompt";
|
|
5
|
+
import { useCreateSession } from "@/data/sessions";
|
|
6
|
+
import {
|
|
7
|
+
type GitInfo,
|
|
8
|
+
SKIP_PERMISSIONS_KEY,
|
|
9
|
+
AGENT_TYPE_KEY,
|
|
10
|
+
RECENT_DIRS_KEY,
|
|
11
|
+
USE_TMUX_KEY,
|
|
12
|
+
MAX_RECENT_DIRS,
|
|
13
|
+
AGENT_OPTIONS,
|
|
14
|
+
generateFeatureName,
|
|
15
|
+
} from "../NewSessionDialog.types";
|
|
16
|
+
|
|
17
|
+
interface UseNewSessionFormOptions {
|
|
18
|
+
open: boolean;
|
|
19
|
+
projects: ProjectWithDevServers[];
|
|
20
|
+
selectedProjectId?: string;
|
|
21
|
+
onCreated: (sessionId: string) => void;
|
|
22
|
+
onClose: () => void;
|
|
23
|
+
onCreateProject?: (
|
|
24
|
+
name: string,
|
|
25
|
+
workingDirectory: string,
|
|
26
|
+
agentType: AgentType
|
|
27
|
+
) => Promise<string | null>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function useNewSessionForm({
|
|
31
|
+
open,
|
|
32
|
+
projects,
|
|
33
|
+
selectedProjectId,
|
|
34
|
+
onCreated,
|
|
35
|
+
onClose,
|
|
36
|
+
onCreateProject,
|
|
37
|
+
}: UseNewSessionFormOptions) {
|
|
38
|
+
// React Query mutation
|
|
39
|
+
const createSession = useCreateSession();
|
|
40
|
+
|
|
41
|
+
// Form state
|
|
42
|
+
const [name, setName] = useState("");
|
|
43
|
+
const [workingDirectory, setWorkingDirectory] = useState("~");
|
|
44
|
+
const [projectId, setProjectId] = useState<string | null>(null);
|
|
45
|
+
const [agentType, setAgentType] = useState<AgentType>("claude");
|
|
46
|
+
const [skipPermissions, setSkipPermissions] = useState(false);
|
|
47
|
+
const [useTmux, setUseTmux] = useState(true);
|
|
48
|
+
const [initialPrompt, setInitialPrompt] = useState("");
|
|
49
|
+
|
|
50
|
+
// Worktree state
|
|
51
|
+
const [useWorktree, setUseWorktree] = useState(false);
|
|
52
|
+
const [featureName, setFeatureName] = useState("");
|
|
53
|
+
const [baseBranch, setBaseBranch] = useState("main");
|
|
54
|
+
const [gitInfo, setGitInfo] = useState<GitInfo | null>(null);
|
|
55
|
+
const [checkingGit, setCheckingGit] = useState(false);
|
|
56
|
+
|
|
57
|
+
// UI state
|
|
58
|
+
const [showNewProject, setShowNewProject] = useState(false);
|
|
59
|
+
const [newProjectName, setNewProjectName] = useState("");
|
|
60
|
+
const [creatingProject, setCreatingProject] = useState(false);
|
|
61
|
+
const [advancedOpen, setAdvancedOpen] = useState(false);
|
|
62
|
+
const [showDirectoryPicker, setShowDirectoryPicker] = useState(false);
|
|
63
|
+
|
|
64
|
+
// Creation step for loading overlay
|
|
65
|
+
const [creationStep, setCreationStep] = useState<
|
|
66
|
+
"creating" | "worktree" | "setup" | "done"
|
|
67
|
+
>("creating");
|
|
68
|
+
|
|
69
|
+
// Recent directories
|
|
70
|
+
const [recentDirs, setRecentDirs] = useState<string[]>([]);
|
|
71
|
+
|
|
72
|
+
// Check if working directory is a git repo
|
|
73
|
+
const checkGitRepo = useCallback(async (path: string) => {
|
|
74
|
+
if (!path || path === "~") {
|
|
75
|
+
setGitInfo(null);
|
|
76
|
+
setUseWorktree(false);
|
|
77
|
+
setFeatureName("");
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
setCheckingGit(true);
|
|
82
|
+
try {
|
|
83
|
+
const res = await fetch("/api/git/check", {
|
|
84
|
+
method: "POST",
|
|
85
|
+
headers: { "Content-Type": "application/json" },
|
|
86
|
+
body: JSON.stringify({ path }),
|
|
87
|
+
});
|
|
88
|
+
const data = await res.json();
|
|
89
|
+
setGitInfo(data);
|
|
90
|
+
if (data.defaultBranch) {
|
|
91
|
+
setBaseBranch(data.defaultBranch);
|
|
92
|
+
}
|
|
93
|
+
if (data.isGitRepo) {
|
|
94
|
+
setUseWorktree(true);
|
|
95
|
+
setFeatureName(generateFeatureName());
|
|
96
|
+
} else {
|
|
97
|
+
setUseWorktree(false);
|
|
98
|
+
setFeatureName("");
|
|
99
|
+
}
|
|
100
|
+
} catch {
|
|
101
|
+
setGitInfo(null);
|
|
102
|
+
setUseWorktree(false);
|
|
103
|
+
setFeatureName("");
|
|
104
|
+
} finally {
|
|
105
|
+
setCheckingGit(false);
|
|
106
|
+
}
|
|
107
|
+
}, []);
|
|
108
|
+
|
|
109
|
+
// Debounce git check
|
|
110
|
+
useEffect(() => {
|
|
111
|
+
const timer = setTimeout(() => {
|
|
112
|
+
checkGitRepo(workingDirectory);
|
|
113
|
+
}, 500);
|
|
114
|
+
return () => clearTimeout(timer);
|
|
115
|
+
}, [workingDirectory, checkGitRepo]);
|
|
116
|
+
|
|
117
|
+
// Load preferences from localStorage
|
|
118
|
+
useEffect(() => {
|
|
119
|
+
const savedSkipPerms = localStorage.getItem(SKIP_PERMISSIONS_KEY);
|
|
120
|
+
if (savedSkipPerms !== null) {
|
|
121
|
+
setSkipPermissions(savedSkipPerms === "true");
|
|
122
|
+
}
|
|
123
|
+
const savedAgentType = localStorage.getItem(AGENT_TYPE_KEY);
|
|
124
|
+
if (
|
|
125
|
+
savedAgentType &&
|
|
126
|
+
AGENT_OPTIONS.some((opt) => opt.value === savedAgentType)
|
|
127
|
+
) {
|
|
128
|
+
setAgentType(savedAgentType as AgentType);
|
|
129
|
+
}
|
|
130
|
+
const savedUseTmux = localStorage.getItem(USE_TMUX_KEY);
|
|
131
|
+
if (savedUseTmux !== null) {
|
|
132
|
+
setUseTmux(savedUseTmux === "true");
|
|
133
|
+
}
|
|
134
|
+
try {
|
|
135
|
+
const saved = localStorage.getItem(RECENT_DIRS_KEY);
|
|
136
|
+
if (saved) {
|
|
137
|
+
setRecentDirs(JSON.parse(saved));
|
|
138
|
+
}
|
|
139
|
+
} catch {
|
|
140
|
+
// Ignore parse errors
|
|
141
|
+
}
|
|
142
|
+
}, []);
|
|
143
|
+
|
|
144
|
+
// Initialize from selectedProjectId or first available project when dialog opens
|
|
145
|
+
useEffect(() => {
|
|
146
|
+
if (open) {
|
|
147
|
+
// Use selectedProjectId if provided
|
|
148
|
+
if (selectedProjectId) {
|
|
149
|
+
setProjectId(selectedProjectId);
|
|
150
|
+
const project = projects.find((p) => p.id === selectedProjectId);
|
|
151
|
+
if (project && !project.is_uncategorized) {
|
|
152
|
+
setWorkingDirectory(project.working_directory);
|
|
153
|
+
setAgentType(project.agent_type);
|
|
154
|
+
}
|
|
155
|
+
} else {
|
|
156
|
+
// Otherwise, select first non-uncategorized project
|
|
157
|
+
const firstProject = projects.find((p) => !p.is_uncategorized);
|
|
158
|
+
if (firstProject) {
|
|
159
|
+
setProjectId(firstProject.id);
|
|
160
|
+
setWorkingDirectory(firstProject.working_directory);
|
|
161
|
+
setAgentType(firstProject.agent_type);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}, [open, selectedProjectId, projects]);
|
|
166
|
+
|
|
167
|
+
useEffect(() => {
|
|
168
|
+
if (!skipPermissions) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (getProviderDefinition(agentType).autoApproveFlag) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
setSkipPermissions(false);
|
|
177
|
+
localStorage.setItem(SKIP_PERMISSIONS_KEY, "false");
|
|
178
|
+
}, [agentType, skipPermissions]);
|
|
179
|
+
|
|
180
|
+
// Save directory to recent list
|
|
181
|
+
const addRecentDirectory = useCallback((dir: string) => {
|
|
182
|
+
if (!dir || dir === "~") return;
|
|
183
|
+
setRecentDirs((prev) => {
|
|
184
|
+
const filtered = prev.filter((d) => d !== dir);
|
|
185
|
+
const updated = [dir, ...filtered].slice(0, MAX_RECENT_DIRS);
|
|
186
|
+
localStorage.setItem(RECENT_DIRS_KEY, JSON.stringify(updated));
|
|
187
|
+
return updated;
|
|
188
|
+
});
|
|
189
|
+
}, []);
|
|
190
|
+
|
|
191
|
+
// Handlers
|
|
192
|
+
const handleProjectChange = useCallback(
|
|
193
|
+
(newProjectId: string | null) => {
|
|
194
|
+
setProjectId(newProjectId);
|
|
195
|
+
if (newProjectId) {
|
|
196
|
+
const project = projects.find((p) => p.id === newProjectId);
|
|
197
|
+
if (project && !project.is_uncategorized) {
|
|
198
|
+
setWorkingDirectory(project.working_directory);
|
|
199
|
+
setAgentType(project.agent_type);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
[projects]
|
|
204
|
+
);
|
|
205
|
+
|
|
206
|
+
const handleSkipPermissionsChange = (checked: boolean) => {
|
|
207
|
+
setSkipPermissions(checked);
|
|
208
|
+
localStorage.setItem(SKIP_PERMISSIONS_KEY, String(checked));
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
const handleAgentTypeChange = (value: AgentType) => {
|
|
212
|
+
setAgentType(value);
|
|
213
|
+
localStorage.setItem(AGENT_TYPE_KEY, value);
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
const handleUseTmuxChange = (checked: boolean) => {
|
|
217
|
+
setUseTmux(checked);
|
|
218
|
+
localStorage.setItem(USE_TMUX_KEY, String(checked));
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
const handleSubmit = async (e: React.FormEvent) => {
|
|
222
|
+
e.preventDefault();
|
|
223
|
+
createSession.reset(); // Clear any previous errors
|
|
224
|
+
|
|
225
|
+
if (useWorktree) {
|
|
226
|
+
if (!featureName.trim()) {
|
|
227
|
+
return; // Validation handled by button disabled state
|
|
228
|
+
}
|
|
229
|
+
if (!gitInfo?.isGitRepo) {
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
setCreationStep("creating");
|
|
235
|
+
|
|
236
|
+
// For worktree sessions, show step progression
|
|
237
|
+
let stepTimer: NodeJS.Timeout | undefined;
|
|
238
|
+
if (useWorktree) {
|
|
239
|
+
setCreationStep("worktree");
|
|
240
|
+
// Progress to "setup" step after 2s (worktree creation is usually fast)
|
|
241
|
+
stepTimer = setTimeout(() => {
|
|
242
|
+
setCreationStep("setup");
|
|
243
|
+
}, 2000);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
createSession.mutate(
|
|
247
|
+
{
|
|
248
|
+
name: name.trim() || undefined,
|
|
249
|
+
workingDirectory,
|
|
250
|
+
projectId,
|
|
251
|
+
agentType,
|
|
252
|
+
useWorktree,
|
|
253
|
+
featureName: useWorktree ? featureName.trim() : null,
|
|
254
|
+
baseBranch: useWorktree ? baseBranch : null,
|
|
255
|
+
autoApprove: skipPermissions,
|
|
256
|
+
useTmux,
|
|
257
|
+
initialPrompt: initialPrompt.trim() || null,
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
onSuccess: (data) => {
|
|
261
|
+
if (stepTimer) clearTimeout(stepTimer);
|
|
262
|
+
setCreationStep("done");
|
|
263
|
+
if (data.initialPrompt) {
|
|
264
|
+
setPendingPrompt(data.session.id, data.initialPrompt);
|
|
265
|
+
}
|
|
266
|
+
addRecentDirectory(workingDirectory);
|
|
267
|
+
// Small delay to show "done" state before closing
|
|
268
|
+
setTimeout(() => {
|
|
269
|
+
resetForm();
|
|
270
|
+
onCreated(data.session.id);
|
|
271
|
+
}, 300);
|
|
272
|
+
},
|
|
273
|
+
onError: () => {
|
|
274
|
+
if (stepTimer) clearTimeout(stepTimer);
|
|
275
|
+
setCreationStep("creating");
|
|
276
|
+
},
|
|
277
|
+
}
|
|
278
|
+
);
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
const handleCreateProject = async () => {
|
|
282
|
+
if (
|
|
283
|
+
!newProjectName.trim() ||
|
|
284
|
+
!onCreateProject ||
|
|
285
|
+
!workingDirectory ||
|
|
286
|
+
workingDirectory === "~"
|
|
287
|
+
)
|
|
288
|
+
return;
|
|
289
|
+
setCreatingProject(true);
|
|
290
|
+
try {
|
|
291
|
+
const newId = await onCreateProject(
|
|
292
|
+
newProjectName.trim(),
|
|
293
|
+
workingDirectory,
|
|
294
|
+
agentType
|
|
295
|
+
);
|
|
296
|
+
if (newId) {
|
|
297
|
+
setProjectId(newId);
|
|
298
|
+
setShowNewProject(false);
|
|
299
|
+
setNewProjectName("");
|
|
300
|
+
}
|
|
301
|
+
} finally {
|
|
302
|
+
setCreatingProject(false);
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
const resetForm = () => {
|
|
307
|
+
setName("");
|
|
308
|
+
setWorkingDirectory("~");
|
|
309
|
+
setProjectId(null);
|
|
310
|
+
setUseWorktree(false);
|
|
311
|
+
setFeatureName("");
|
|
312
|
+
setInitialPrompt("");
|
|
313
|
+
setShowNewProject(false);
|
|
314
|
+
setNewProjectName("");
|
|
315
|
+
setCreationStep("creating");
|
|
316
|
+
createSession.reset();
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
const handleClose = () => {
|
|
320
|
+
resetForm();
|
|
321
|
+
onClose();
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
return {
|
|
325
|
+
// Form values
|
|
326
|
+
name,
|
|
327
|
+
setName,
|
|
328
|
+
workingDirectory,
|
|
329
|
+
setWorkingDirectory,
|
|
330
|
+
projectId,
|
|
331
|
+
agentType,
|
|
332
|
+
skipPermissions,
|
|
333
|
+
useTmux,
|
|
334
|
+
initialPrompt,
|
|
335
|
+
setInitialPrompt,
|
|
336
|
+
// Worktree
|
|
337
|
+
useWorktree,
|
|
338
|
+
setUseWorktree,
|
|
339
|
+
featureName,
|
|
340
|
+
setFeatureName,
|
|
341
|
+
baseBranch,
|
|
342
|
+
setBaseBranch,
|
|
343
|
+
gitInfo,
|
|
344
|
+
checkingGit,
|
|
345
|
+
// UI
|
|
346
|
+
showNewProject,
|
|
347
|
+
setShowNewProject,
|
|
348
|
+
newProjectName,
|
|
349
|
+
setNewProjectName,
|
|
350
|
+
creatingProject,
|
|
351
|
+
advancedOpen,
|
|
352
|
+
setAdvancedOpen,
|
|
353
|
+
showDirectoryPicker,
|
|
354
|
+
setShowDirectoryPicker,
|
|
355
|
+
// Submission
|
|
356
|
+
isLoading: createSession.isPending,
|
|
357
|
+
creationStep,
|
|
358
|
+
error: createSession.error?.message ?? null,
|
|
359
|
+
// Recent
|
|
360
|
+
recentDirs,
|
|
361
|
+
// Handlers
|
|
362
|
+
handleProjectChange,
|
|
363
|
+
handleSkipPermissionsChange,
|
|
364
|
+
handleAgentTypeChange,
|
|
365
|
+
handleUseTmuxChange,
|
|
366
|
+
handleSubmit,
|
|
367
|
+
handleCreateProject,
|
|
368
|
+
handleClose,
|
|
369
|
+
};
|
|
370
|
+
}
|