Skip to content

feat(home): add folders to resource menu#4000

Merged
waleedlatif1 merged 7 commits intostagingfrom
waleedlatif1/add-folders-to-menu
Apr 7, 2026
Merged

feat(home): add folders to resource menu#4000
waleedlatif1 merged 7 commits intostagingfrom
waleedlatif1/add-folders-to-menu

Conversation

@waleedlatif1
Copy link
Copy Markdown
Collaborator

Summary

  • Add folders as a selectable resource type in the workspace resource menu (plus menu + add resource dropdown)
  • New Folder icon, resource registry config, embedded folder view showing contained workflows
  • Wired through all resource plumbing: type definitions, context mapping, name lookup, cache invalidation

Type of Change

  • New feature

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 7, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Apr 7, 2026 2:24am

Request Review

@cursor
Copy link
Copy Markdown

cursor bot commented Apr 7, 2026

PR Summary

Medium Risk
Introduces a new folder resource/context type across UI and chat APIs, including server-side context resolution that queries the DB; mistakes could break chat context serialization or degrade performance for large folders.

Overview
Adds Folders as a first-class selectable resource in the home “mothership” UI and copilot/mothership chat plumbing.

This extends resource/type enums and request schemas to accept folder, updates context serialization/mapping and tab name lookups, and adds cache invalidation for folder lists.

It also adds an embedded folder tab view (with a new Folder icon) that lists workflows in the folder, and enables agent context generation for folder attachments by resolving folder + workflow list content server-side.

Reviewed by Cursor Bugbot for commit 1d702eb. Configure here.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 7, 2026

Greptile Summary

This PR adds folders as a selectable resource type in the workspace resource menu (plus menu and add-resource dropdown), embedding a live folder view that lists contained workflows as clickable links opening in a new tab.

Key changes:

  • Extended all resource type discriminated unions (MothershipResourceType, ChatContext, AgentContextType, Zod schemas across three API routes) to include 'folder'
  • New resolveFolderResource(folderId, workspaceId) server function with workspace scoping on both the folder and workflow DB queries, wired into processContextsServer and resolveActiveResourceContext
  • New EmbeddedFolder component rendering a workflow list per folder with a folder-not-found fallback state, using existing useFolders + useWorkflows queries
  • RESOURCE_INVALIDATORS entry for folder invalidates folderKeys.lists() on resource_added SSE events
  • useResourceNameLookup extended to keep folder tab names in sync after renames
  • mapResourceToContext handles the new 'folder' case, producing { kind: 'folder', folderId, label }
  • New Folder SVG icon added to the EMCN icon library
  • Previously flagged workspace-scoping vulnerability in resolveFolderResource has been correctly fixed: both the folder lookup and the workflows lookup include eq(*.workspaceId, workspaceId) filters

Confidence Score: 5/5

Safe to merge — workspace scoping is correctly applied in resolveFolderResource, all type unions are consistently extended across every layer, and the embedded UI follows established component patterns.

No P0 or P1 issues found. The previously flagged workspace-scoping security concern has been addressed: both DB queries in resolveFolderResource filter on workspaceId. Type extensions are complete and consistent (Zod schemas, TypeScript unions, Zustand store types, React Query interfaces). EmbeddedFolder follows the exact same structure as EmbeddedWorkflow and EmbeddedFile. Cache invalidation and name-lookup hooks are properly updated.

No files require special attention.

Important Files Changed

Filename Overview
apps/sim/lib/copilot/process-contents.ts Adds resolveFolderResource with workspaceId scoping on both DB queries; folder kind handling wired into processContextsServer and resolveActiveResourceContext
apps/sim/app/workspace/[workspaceId]/home/components/mothership-view/components/resource-content/resource-content.tsx Adds EmbeddedFolder component with folder-not-found state and workflow list; ResourceActions returns null for folder type
apps/sim/app/workspace/[workspaceId]/home/components/mothership-view/components/resource-registry/resource-registry.tsx Registers folder type config and cache invalidator (folderKeys.lists()); follows established pattern for all other resource types
apps/sim/app/workspace/[workspaceId]/home/components/mothership-view/components/add-resource-dropdown/add-resource-dropdown.tsx Adds useFolders to useAvailableResources, surfacing folders in the resource picker dropdown
apps/sim/app/workspace/[workspaceId]/home/components/mothership-view/components/resource-tabs/resource-tabs.tsx Extends useResourceNameLookup with folder entries so tab labels reflect live renames
apps/sim/app/api/copilot/chat/resources/route.ts Extends Zod enums and VALID_RESOURCE_TYPES/GENERIC_TITLES sets to include folder
apps/sim/app/api/copilot/chat/route.ts Adds folder to context kind enum and folderId to context schema
apps/sim/app/api/mothership/chat/route.ts Extends resource attachment and message schemas; forwards folderId in context passthrough
apps/sim/lib/copilot/resource-types.ts Adds folder to MothershipResourceType union and VFS_DIR_TO_RESOURCE map
apps/sim/lib/copilot/resources.ts Adds Folder to GENERIC set for chat resource persistence
apps/sim/stores/panel/types.ts Adds folder discriminated union variant to ChatContext
apps/sim/hooks/queries/tasks.ts Adds folderId to TaskStoredMessageContext interface
apps/sim/components/emcn/icons/folder.tsx New Folder SVG icon component
apps/sim/components/emcn/icons/index.ts Re-exports the new Folder icon
apps/sim/app/workspace/[workspaceId]/home/components/user-input/components/constants.ts Adds mapResourceToContext case for folder, mapping to ChatContext kind folder
apps/sim/app/workspace/[workspaceId]/home/types.ts Adds folderId to ChatMessageContext interface

Sequence Diagram

sequenceDiagram
    participant U as User
    participant RT as ResourceTabs
    participant DD as AddResourceDropdown
    participant API as /api/copilot/chat/resources
    participant PC as processContextsServer
    participant DB as Database

    U->>DD: Clicks + → Folders → selects folder
    DD->>RT: onAdd({type:'folder', id, title})
    RT->>API: POST /add {type:'folder', id, title}
    API-->>RT: 200 OK (persisted to chat.resources)
    U->>U: Sends chat message with folder context
    Note over PC: ctx.kind='folder' && ctx.folderId && currentWorkspaceId
    PC->>DB: SELECT folder WHERE id=folderId AND workspaceId=wsId
    PC->>DB: SELECT workflows WHERE folderId=folderId AND workspaceId=wsId
    DB-->>PC: folder + workflow list
    PC-->>U: AgentContext with folder name and workflow inventory
Loading

Reviews (5): Last reviewed commit: "fix(home): add workspace scoping to fold..." | Re-trigger Greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

Fixed in 6471057 — added case 'folder' to the overlayContent switch and imported Folder as FolderIcon from @/components/emcn/icons. Folder mention chips now render with the folder icon.

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

@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 1d702eb. Configure here.

@waleedlatif1 waleedlatif1 merged commit 606477e into staging Apr 7, 2026
6 checks passed
@waleedlatif1 waleedlatif1 deleted the waleedlatif1/add-folders-to-menu branch April 7, 2026 02:25
emir-karabeg pushed a commit that referenced this pull request Apr 7, 2026
* feat(home): add folders to resource menu

* fix(home): add folder to API validation and dedup logic

* fix(home): add folder context processing and generic title dedup

* fix(home): add folder icon to mention chip overlay

* fix(home): add folder to AgentContextType and context persistence

* fix(home): add workspace scoping to folder resolver, fix folderId type and dedup

* user message
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