Skip to content

fix(desktop): restore dragging workspaces out of sections#2564

Closed
Kitenite wants to merge 2 commits into
superset-sh:mainfrom
Kitenite:kitenite/please-fix-draggin
Closed

fix(desktop): restore dragging workspaces out of sections#2564
Kitenite wants to merge 2 commits into
superset-sh:mainfrom
Kitenite:kitenite/please-fix-draggin

Conversation

@Kitenite
Copy link
Copy Markdown
Collaborator

@Kitenite Kitenite commented Mar 18, 2026

Summary

  • keep the V1 workspace sidebar root drop target available for append/empty-root drops
  • make single-workspace cross-container drops position-aware so dropping on a top-level row moves the workspace out of its section and inserts before or after that row
  • reuse the same indexed move path for section/root append drop targets so V1 drag behavior stays consistent

Testing

  • bunx biome check apps/desktop/src/lib/trpc/routers/workspaces/procedures/sections.ts apps/desktop/src/renderer/react-query/workspaces/index.ts apps/desktop/src/renderer/react-query/workspaces/useMoveWorkspaceToSectionAtIndex.ts apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/hooks/useSectionDropZone.ts apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/ProjectSection/ProjectSection.tsx apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceSection/WorkspaceSection.tsx apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/useWorkspaceDnD.ts apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/WorkspaceListItem.tsx
  • bun run --cwd apps/desktop typecheck

Summary by CodeRabbit

  • New Features

    • Workspace drag-and-drop now supports precise position targeting within sections
  • Improvements

    • Enhanced drop zone visibility with improved visual feedback during reorganization
    • Better interaction handling for workspace drag-and-drop operations

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 18, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 378d41c6-a94d-4ea9-914d-273050674fc3

📥 Commits

Reviewing files that changed from the base of the PR and between d9653ea and 9677845.

📒 Files selected for processing (8)
  • apps/desktop/src/lib/trpc/routers/workspaces/procedures/sections.ts
  • apps/desktop/src/renderer/react-query/workspaces/index.ts
  • apps/desktop/src/renderer/react-query/workspaces/useMoveWorkspaceToSectionAtIndex.ts
  • apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/ProjectSection/ProjectSection.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/WorkspaceListItem.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/useWorkspaceDnD.ts
  • apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceSection/WorkspaceSection.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/hooks/useSectionDropZone.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/ProjectSection/ProjectSection.tsx

📝 Walkthrough

Walkthrough

Adds target-index-aware drop handling across the workspace sidebar (client DnD hooks and components), a new TRPC procedure to move a workspace to a section at a specific index, and a small router-side reordering/normalization helper surface. Also exports and uses a new react-query hook to call the procedure.

Changes

Cohort / File(s) Summary
Project section drop zone
apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/ProjectSection/ProjectSection.tsx
Ungrouped drop zone element is always rendered; getTargetIndex added to its dropZone config; min-h-8 styling now applied based on (no children
Workspace section drop config
apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceSection/WorkspaceSection.tsx
Added getTargetIndex: () => workspaces.length to the section dropZone options so drop targets can resolve insertion index.
Section drop-zone hook
apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/hooks/useSectionDropZone.ts
Hook now accepts optional getTargetIndex?: () => number; uses useMoveWorkspaceToSectionAtIndex for single-item drops and passes targetIndex: getTargetIndex?.() ?? 0.
Workspace DnD hook & usage
apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/useWorkspaceDnD.ts, apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/WorkspaceListItem.tsx
DnD API changed: hook returns { isDragging, setNodeRef } (replacing drag/drop); new pointer-based getTargetIndexFromPointer computes insertion index; drop handler calls move-to-section-at-index mutation with computed targetIndex. WorkspaceListItem updated to use setNodeRef.
React-query hook export
apps/desktop/src/renderer/react-query/workspaces/index.ts, apps/desktop/src/renderer/react-query/workspaces/useMoveWorkspaceToSectionAtIndex.ts
New hook useMoveWorkspaceToSectionAtIndex added and exported; performs TRPC mutation and invalidates workspace queries on success, shows toast on error.
Server/router: section procedures
apps/desktop/src/lib/trpc/routers/workspaces/procedures/sections.ts
New helpers for normalizing/persisting order and a new public procedure `moveWorkspaceToSectionAtIndex({ workspaceId, sectionId

Sequence Diagram(s)

mermaid
sequenceDiagram
rect rgba(173, 216, 230, 0.5)
participant User
end
rect rgba(144, 238, 144, 0.5)
participant Renderer as "Renderer (React DnD)"
end
rect rgba(255, 228, 181, 0.5)
participant TRPC as "Electron TRPC Client"
end
rect rgba(255, 182, 193, 0.5)
participant Router as "Server Router / Procedures"
end
rect rgba(221, 160, 221, 0.5)
participant DB as "Database / Ordering Helpers"
end

User->>Renderer: Drag workspace, hover/position over drop target
Renderer->>Renderer: getTargetIndexFromPointer(pointer) -> compute targetIndex
Renderer->>TRPC: call moveWorkspaceToSectionAtIndex(workspaceId, sectionId, targetIndex)
TRPC->>Router: invoke procedure with validated ids + targetIndex
Router->>DB: validate workspace/section, update sectionId if needed
Router->>DB: reorder/persist child order (using helpers)
DB-->>Router: ack
Router-->>TRPC: success
TRPC-->>Renderer: mutation resolved
Renderer->>Renderer: invalidateWorkspaceQueries -> refresh UI

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐰
I hopped along the sidebar trail,
Found drop-zones steady, never pale,
I nudged the stacks to find their place,
With indexes set and gentle grace,
Happy trails — one less hidden space!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the primary change: restoring the ability to drag workspaces out of sections in the desktop sidebar.
Description check ✅ Passed The description provides a clear summary of the changes and lists testing steps performed, covering the main objectives of the PR.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/ProjectSection/ProjectSection.tsx`:
- Around line 326-327: The drag-over classes on the ungrouped drop zone set
border style and color but omit border width, so the visual cue can be
invisible; update the conditional class string where
ungroupedDropZone.isDragOver is used in ProjectSection (the JSX that builds the
drop-zone classes) to include the "border" utility (e.g., add "border" alongside
"border-solid border-primary/30") so the border appears when isDragOver is true.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8e733c9f-e3f8-4f70-8f4e-758ed44ec68a

📥 Commits

Reviewing files that changed from the base of the PR and between aa42634 and d9653ea.

📒 Files selected for processing (1)
  • apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/ProjectSection/ProjectSection.tsx

Comment on lines +326 to +327
ungroupedDropZone.isDragOver &&
"bg-primary/5 border-solid border-primary/30",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Add explicit border width in drag-over state

At Line 326-327, the drag-over classes set border style/color but not width, so the border cue may not render. Add border to make the drop feedback consistently visible.

Suggested patch
  ungroupedDropZone.isDragOver &&
-   "bg-primary/5 border-solid border-primary/30",
+   "bg-primary/5 border border-solid border-primary/30",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
ungroupedDropZone.isDragOver &&
"bg-primary/5 border-solid border-primary/30",
ungroupedDropZone.isDragOver &&
"bg-primary/5 border border-solid border-primary/30",
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/ProjectSection/ProjectSection.tsx`
around lines 326 - 327, The drag-over classes on the ungrouped drop zone set
border style and color but omit border width, so the visual cue can be
invisible; update the conditional class string where
ungroupedDropZone.isDragOver is used in ProjectSection (the JSX that builds the
drop-zone classes) to include the "border" utility (e.g., add "border" alongside
"border-solid border-primary/30") so the border appears when isDragOver is true.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 8 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/desktop/src/lib/trpc/routers/workspaces/procedures/sections.ts">

<violation number="1" location="apps/desktop/src/lib/trpc/routers/workspaces/procedures/sections.ts:27">
P2: Filter out soft-deleting workspaces when reordering section items; otherwise `targetIndex` can map to the wrong visible position.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

const sectionWorkspaces = localDb
.select()
.from(workspaces)
.where(eq(workspaces.sectionId, sectionId))
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot Mar 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Filter out soft-deleting workspaces when reordering section items; otherwise targetIndex can map to the wrong visible position.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/desktop/src/lib/trpc/routers/workspaces/procedures/sections.ts, line 27:

<comment>Filter out soft-deleting workspaces when reordering section items; otherwise `targetIndex` can map to the wrong visible position.</comment>

<file context>
@@ -19,6 +20,150 @@ function randomSectionColor(): string {
+	const sectionWorkspaces = localDb
+		.select()
+		.from(workspaces)
+		.where(eq(workspaces.sectionId, sectionId))
+		.all()
+		.sort((a, b) => a.tabOrder - b.tabOrder);
</file context>
Suggested change
.where(eq(workspaces.sectionId, sectionId))
.where(
and(eq(workspaces.sectionId, sectionId), isNull(workspaces.deletingAt)),
)
Fix with Cubic

@Kitenite Kitenite closed this by deleting the head repository Mar 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant