Skip to content

improvement(sidebar): interleave folders and workflows by sort order in all resource pickers#4215

Merged
waleedlatif1 merged 3 commits intostagingfrom
improvement/plus-menu-focus-fix
Apr 17, 2026
Merged

improvement(sidebar): interleave folders and workflows by sort order in all resource pickers#4215
waleedlatif1 merged 3 commits intostagingfrom
improvement/plus-menu-focus-fix

Conversation

@waleedlatif1
Copy link
Copy Markdown
Collaborator

@waleedlatif1 waleedlatif1 commented Apr 17, 2026

Summary

  • Merged separate Folders/Workflows submenus into a single nested Workflows tree (matching the expanded sidebar's interleaved sortOrder-based ordering) in both the @ plus-menu dropdown and the add-resource dropdown
  • Widened both dropdowns from 240px → 320px and removed type labels from search results to reduce truncation
  • Fixed isOpen/onSwitch regression: WorkflowFolderTreeItems now forwards node.isOpen so clicking an already-open workflow switches to its existing tab instead of creating a duplicate
  • Applied the same interleaved sortOrder ordering to the collapsed sidebar's root-level folder+workflow flyout list

Test plan

  • Open the @ plus-menu in Mothership — Workspace submenu shows a single Workflows tree with folders and workflows interleaved by sort order
  • Open the add-resource dropdown (+ in resource tabs) — same Workflows tree structure and ordering
  • Verify search results in both dropdowns show no type labels and fit in 320px width
  • Click a workflow already open as a tab from the tree — confirms it switches to the existing tab (not duplicated)
  • Collapse the sidebar and open the workflow flyout — root-level folders and workflows are interleaved by sort order, not folders-first

…in all resource pickers

- Merge folder/workflow submenus into a single Workflows tree sorted by sortOrder in both the @ plus-menu and add-resource dropdowns
- Widen both dropdowns from 240px to 320px and remove type labels from search results
- Fix isOpen/onSwitch regression: WorkflowFolderTreeItems now forwards node.isOpen so already-open tabs are switched to rather than duplicated
- Apply same interleaved sortOrder ordering to the collapsed sidebar's root-level folder+workflow list
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 17, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment Apr 17, 2026 7:57pm

Request Review

@cursor
Copy link
Copy Markdown

cursor Bot commented Apr 17, 2026

PR Summary

Medium Risk
UI logic changes to workflow/folder ordering and selection behavior across multiple menus; risk is mainly regressions in navigation/tab switching and menu structure rather than data/security issues.

Overview
Updates resource pickers to present Workflows as a single nested folder/workflow tree, interleaving items by sortOrder (and nesting by folder relationships) instead of separate folders/workflows sections. This tree is shared between the resource-tab add dropdown and the @ plus-menu workspace submenu via new exported helpers (buildWorkflowFolderTree, WorkflowFolderTreeItems).

Both dropdowns are widened to 320px and search results no longer show per-type labels, reducing truncation. Workflow selection now forwards isOpen through the tree so selecting an already-open workflow can switch tabs (onSwitch) instead of opening duplicates.

In the collapsed sidebar workflow flyout, root-level folders and workflows are now merged and sorted together (using compareByOrder) so the collapsed view matches the expanded sidebar’s interleaved ordering.

Reviewed by Cursor Bugbot for commit 91da7df. Configure here.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 17, 2026

Greptile Summary

This PR merges the separate Folders and Workflows submenus into a single interleaved tree (sorted by sortOrder) across three surfaces: the @ plus-menu dropdown, the add-resource dropdown, and the collapsed sidebar flyout. It also widens both dropdowns from 240px → 320px and removes type labels from search results. The shared buildWorkflowFolderTree utility and WorkflowFolderTreeItems component are cleanly extracted from add-resource-dropdown.tsx and reused in plus-menu-dropdown.tsx.

Previous review concerns have been fully addressed: the empty-folder omission is now documented with a comment, and the intentional isOpen ignore in PlusMenuDropdown is understood.

Confidence Score: 5/5

Safe to merge — no P0 or P1 issues found; all prior review concerns are resolved.

The tree-building logic is a pure function with correct sorting and tie-breaking. CollapsedFolderItems returns a fragment so splitting the call per node is DOM-equivalent. The isOpen ignore in PlusMenuDropdown is intentional. compareByOrder exists in sidebar utils. No new stale-closure issues were introduced by the useCallback removals.

No files require special attention.

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/home/components/mothership-view/components/add-resource-dropdown/add-resource-dropdown.tsx Adds buildWorkflowFolderTree utility and WorkflowFolderTreeItems component; replaces the old split workflow/folder submenus with a single interleaved tree in AddResourceDropdown. Logic is correct and handles empty-folder pruning with an explanatory comment.
apps/sim/app/workspace/[workspaceId]/home/components/user-input/components/plus-menu-dropdown.tsx Imports and uses buildWorkflowFolderTree / WorkflowFolderTreeItems from add-resource-dropdown; removes several useCallback / useRef-ref patterns for non-critical handlers; intentionally ignores isOpen (no tab-switch semantics in the chat context).
apps/sim/app/workspace/[workspaceId]/w/components/sidebar/sidebar.tsx Adds collapsedRootItems memo to interleave root-level folders and workflows by sortOrder; renders them one-by-one via CollapsedFolderItems / CollapsedWorkflowFlyoutItem. CollapsedFolderItems returns a fragment so splitting the array into individual calls is DOM-equivalent to the old all-at-once call.
apps/sim/app/workspace/[workspaceId]/home/components/mothership-view/components/add-resource-dropdown/index.ts Barrel export updated to expose the new WorkflowTreeNode type, buildWorkflowFolderTree, and WorkflowFolderTreeItems.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["useAvailableResources()\n(workflowItems + folderItems with folderId/sortOrder)"] --> B["buildWorkflowFolderTree()"]
    B --> C["WorkflowTreeNode[]\n(interleaved by sortOrder)"]

    C --> D["AddResourceDropdown\nworkflowTree useMemo"]
    C --> E["PlusMenuDropdown\nworkflowTree useMemo"]

    D --> F["WorkflowFolderTreeItems\nonSelect = select()\n(handles isOpen → onSwitch)"]
    E --> G["WorkflowFolderTreeItems\nonSelect = handleSelect()\n(isOpen ignored — chat context)"]

    F --> H["DropdownMenuSub (folder)\nor DropdownMenuItem (workflow)"]
    G --> H

    subgraph "Sidebar (collapsed flyout)"
        I["folderTree + workflowsByFolder.root"] --> J["collapsedRootItems useMemo\n.sort(compareByOrder)"]
        J --> K["CollapsedFolderItems nodes=[item.node]\nor CollapsedWorkflowFlyoutItem"]
    end
Loading

Reviews (2): Last reviewed commit: "chore: remove extraneous inline comment" | Re-trigger Greptile

…, document empty-folder omission

Use id.localeCompare as the sort tiebreaker in buildWorkflowFolderTree to match the sidebar's
compareByOrder fallback (sortOrder → id) instead of name. Add a comment clarifying that empty
folders are intentionally omitted from the tree view.
@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 91da7df. Configure here.

@waleedlatif1 waleedlatif1 merged commit 351873a into staging Apr 17, 2026
14 checks passed
@waleedlatif1 waleedlatif1 deleted the improvement/plus-menu-focus-fix branch April 17, 2026 20:01
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