Skip to content

Commit d877157

Browse files
committed
Revert "feat: allow folder drag-drop to speed workspace setup (#173)"
This reverts commit c2f12de.
1 parent debb11e commit d877157

12 files changed

Lines changed: 30 additions & 553 deletions

File tree

src-tauri/src/bin/codex_monitor_daemon.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -126,20 +126,12 @@ impl DaemonState {
126126
result
127127
}
128128

129-
async fn is_workspace_path_dir(&self, path: String) -> bool {
130-
PathBuf::from(&path).is_dir()
131-
}
132-
133129
async fn add_workspace(
134130
&self,
135131
path: String,
136132
codex_bin: Option<String>,
137133
client_version: String,
138134
) -> Result<WorkspaceInfo, String> {
139-
if !PathBuf::from(&path).is_dir() {
140-
return Err("Workspace path must be a folder.".to_string());
141-
}
142-
143135
let name = PathBuf::from(&path)
144136
.file_name()
145137
.and_then(|s| s.to_str())
@@ -1482,11 +1474,6 @@ async fn handle_rpc_request(
14821474
let workspaces = state.list_workspaces().await;
14831475
serde_json::to_value(workspaces).map_err(|err| err.to_string())
14841476
}
1485-
"is_workspace_path_dir" => {
1486-
let path = parse_string(&params, "path")?;
1487-
let is_dir = state.is_workspace_path_dir(path).await;
1488-
serde_json::to_value(is_dir).map_err(|err| err.to_string())
1489-
}
14901477
"add_workspace" => {
14911478
let path = parse_string(&params, "path")?;
14921479
let codex_bin = parse_optional_string(&params, "codex_bin");

src-tauri/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,6 @@ pub fn run() {
281281
settings::update_app_settings,
282282
codex::codex_doctor,
283283
workspaces::list_workspaces,
284-
workspaces::is_workspace_path_dir,
285284
workspaces::add_workspace,
286285
workspaces::add_clone,
287286
workspaces::add_worktree,

src-tauri/src/workspaces.rs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -411,25 +411,6 @@ pub(crate) async fn list_workspaces(
411411
Ok(result)
412412
}
413413

414-
#[tauri::command]
415-
pub(crate) async fn is_workspace_path_dir(
416-
path: String,
417-
state: State<'_, AppState>,
418-
app: AppHandle,
419-
) -> Result<bool, String> {
420-
if remote_backend::is_remote_mode(&*state).await {
421-
let response = remote_backend::call_remote(
422-
&*state,
423-
app,
424-
"is_workspace_path_dir",
425-
json!({ "path": path }),
426-
)
427-
.await?;
428-
return serde_json::from_value(response).map_err(|err| err.to_string());
429-
}
430-
Ok(PathBuf::from(&path).is_dir())
431-
}
432-
433414
#[tauri::command]
434415
pub(crate) async fn add_workspace(
435416
path: String,
@@ -448,10 +429,6 @@ pub(crate) async fn add_workspace(
448429
return serde_json::from_value(response).map_err(|err| err.to_string());
449430
}
450431

451-
if !PathBuf::from(&path).is_dir() {
452-
return Err("Workspace path must be a folder.".to_string());
453-
}
454-
455432
let name = PathBuf::from(&path)
456433
.file_name()
457434
.and_then(|s| s.to_str())

src-tauri/tauri.conf.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"height": 700,
1919
"minWidth": 360,
2020
"minHeight": 600,
21-
"dragDropEnabled": true,
21+
"dragDropEnabled": false,
2222
"titleBarStyle": "Overlay",
2323
"hiddenTitle": true,
2424
"transparent": true,

src/App.tsx

Lines changed: 6 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
2-
import { AlignLeft, Columns2, FolderOpen } from "lucide-react";
2+
import { AlignLeft, Columns2 } from "lucide-react";
33
import "./styles/base.css";
44
import "./styles/buttons.css";
55
import "./styles/sidebar.css";
@@ -37,7 +37,6 @@ import { TabletLayout } from "./features/layout/components/TabletLayout";
3737
import { PhoneLayout } from "./features/layout/components/PhoneLayout";
3838
import { useLayoutNodes } from "./features/layout/hooks/useLayoutNodes";
3939
import { useWorkspaces } from "./features/workspaces/hooks/useWorkspaces";
40-
import { useWorkspaceDropZone } from "./features/workspaces/hooks/useWorkspaceDropZone";
4140
import { useThreads } from "./features/threads/hooks/useThreads";
4241
import { useWindowDrag } from "./features/layout/hooks/useWindowDrag";
4342
import { useGitStatus } from "./features/git/hooks/useGitStatus";
@@ -343,8 +342,6 @@ function MainApp() {
343342
activeWorkspaceId,
344343
setActiveWorkspaceId,
345344
addWorkspace,
346-
addWorkspaceFromPath,
347-
filterWorkspacePaths,
348345
addCloneAgent,
349346
addWorktreeAgent,
350347
connectWorkspace,
@@ -1393,21 +1390,14 @@ function MainApp() {
13931390
listThreadsForWorkspace
13941391
});
13951392

1396-
const handleWorkspaceAdded = useCallback(
1397-
(workspace: WorkspaceInfo) => {
1398-
setActiveThreadId(null, workspace.id);
1399-
if (isCompact) {
1400-
setActiveTab("codex");
1401-
}
1402-
},
1403-
[isCompact, setActiveTab, setActiveThreadId],
1404-
);
1405-
14061393
const handleAddWorkspace = useCallback(async () => {
14071394
try {
14081395
const workspace = await addWorkspace();
14091396
if (workspace) {
1410-
handleWorkspaceAdded(workspace);
1397+
setActiveThreadId(null, workspace.id);
1398+
if (isCompact) {
1399+
setActiveTab("codex");
1400+
}
14111401
}
14121402
} catch (error) {
14131403
const message = error instanceof Error ? error.message : String(error);
@@ -1420,75 +1410,7 @@ function MainApp() {
14201410
});
14211411
alert(`Failed to add workspace.\n\n${message}`);
14221412
}
1423-
}, [addDebugEntry, addWorkspace, handleWorkspaceAdded]);
1424-
1425-
const handleAddWorkspaceFromPath = useCallback(
1426-
async (path: string) => {
1427-
try {
1428-
const workspace = await addWorkspaceFromPath(path);
1429-
if (workspace) {
1430-
handleWorkspaceAdded(workspace);
1431-
}
1432-
} catch (error) {
1433-
const message = error instanceof Error ? error.message : String(error);
1434-
addDebugEntry({
1435-
id: `${Date.now()}-client-add-workspace-error`,
1436-
timestamp: Date.now(),
1437-
source: "error",
1438-
label: "workspace/add error",
1439-
payload: message
1440-
});
1441-
alert(`Failed to add workspace.\n\n${message}`);
1442-
}
1443-
},
1444-
[addDebugEntry, addWorkspaceFromPath, handleWorkspaceAdded],
1445-
);
1446-
1447-
const dropIndicatorTimeoutRef = useRef<number | null>(null);
1448-
const [dropIndicatorActive, setDropIndicatorActive] = useState(false);
1449-
const showDropAddIndicator = useCallback(() => {
1450-
setDropIndicatorActive(true);
1451-
if (dropIndicatorTimeoutRef.current !== null) {
1452-
window.clearTimeout(dropIndicatorTimeoutRef.current);
1453-
}
1454-
dropIndicatorTimeoutRef.current = window.setTimeout(() => {
1455-
dropIndicatorTimeoutRef.current = null;
1456-
setDropIndicatorActive(false);
1457-
}, 900);
1458-
}, []);
1459-
1460-
useEffect(() => {
1461-
return () => {
1462-
if (dropIndicatorTimeoutRef.current !== null) {
1463-
window.clearTimeout(dropIndicatorTimeoutRef.current);
1464-
}
1465-
};
1466-
}, []);
1467-
1468-
const handleDropWorkspacePaths = useCallback(
1469-
async (paths: string[]) => {
1470-
showDropAddIndicator();
1471-
const uniquePaths = Array.from(
1472-
new Set(paths.map((path) => path.trim()).filter(Boolean)),
1473-
);
1474-
const allowedPaths = await filterWorkspacePaths(uniquePaths);
1475-
allowedPaths.forEach((path) => {
1476-
void handleAddWorkspaceFromPath(path);
1477-
});
1478-
},
1479-
[filterWorkspacePaths, handleAddWorkspaceFromPath, showDropAddIndicator],
1480-
);
1481-
1482-
const {
1483-
dropTargetRef: workspaceDropTargetRef,
1484-
isDragOver: isWorkspaceDropActive,
1485-
handleDragOver: handleWorkspaceDragOver,
1486-
handleDragEnter: handleWorkspaceDragEnter,
1487-
handleDragLeave: handleWorkspaceDragLeave,
1488-
handleDrop: handleWorkspaceDrop,
1489-
} = useWorkspaceDropZone({
1490-
onDropPaths: handleDropWorkspacePaths,
1491-
});
1413+
}, [addDebugEntry, addWorkspace, isCompact, setActiveTab, setActiveThreadId]);
14921414

14931415
const handleAddAgent = useCallback(
14941416
async (workspace: (typeof workspaces)[number]) => {
@@ -1757,10 +1679,6 @@ function MainApp() {
17571679
onDebug: addDebugEntry,
17581680
});
17591681
const isDefaultScale = Math.abs(uiScale - 1) < 0.001;
1760-
const dropOverlayActive = isWorkspaceDropActive || dropIndicatorActive;
1761-
const dropOverlayText = isWorkspaceDropActive
1762-
? "Drop Project Here"
1763-
: "Adding Project...";
17641682
const appClassName = `app ${isCompact ? "layout-compact" : "layout-desktop"}${
17651683
isPhone ? " layout-phone" : ""
17661684
}${isTablet ? " layout-tablet" : ""}${
@@ -2179,31 +2097,9 @@ function MainApp() {
21792097
"--ui-scale": String(uiScale)
21802098
} as React.CSSProperties
21812099
}
2182-
ref={workspaceDropTargetRef}
2183-
onDragOver={handleWorkspaceDragOver}
2184-
onDragEnter={handleWorkspaceDragEnter}
2185-
onDragLeave={handleWorkspaceDragLeave}
2186-
onDrop={handleWorkspaceDrop}
21872100
>
21882101
<div className="drag-strip" id="titlebar" data-tauri-drag-region />
21892102
<TitlebarExpandControls {...sidebarToggleProps} />
2190-
<div
2191-
className={`workspace-drop-overlay${
2192-
dropOverlayActive ? " is-active" : ""
2193-
}`}
2194-
aria-hidden
2195-
>
2196-
<div
2197-
className={`workspace-drop-overlay-text${
2198-
dropOverlayText === "Adding Project..." ? " is-busy" : ""
2199-
}`}
2200-
>
2201-
{dropOverlayText === "Drop Project Here" && (
2202-
<FolderOpen className="workspace-drop-overlay-icon" aria-hidden />
2203-
)}
2204-
{dropOverlayText}
2205-
</div>
2206-
</div>
22072103
{isPhone ? (
22082104
<PhoneLayout
22092105
approvalToastsNode={approvalToastsNode}

src/features/threads/hooks/useThreads.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1002,7 +1002,6 @@ export function useThreads({
10021002
getCustomName,
10031003
handleWorkspaceConnected,
10041004
handleItemUpdate,
1005-
handleTerminalInteraction,
10061005
handleToolOutputDelta,
10071006
markProcessing,
10081007
onDebug,

src/features/workspaces/hooks/useWorkspaceDropZone.test.ts

Lines changed: 0 additions & 113 deletions
This file was deleted.

0 commit comments

Comments
 (0)