Skip to content

improvement(pinning): move pin into the context menu and make folders pinnable - #6039

Merged
waleedlatif1 merged 1 commit into
stagingfrom
feat/pin-context-menu-folders
Jul 29, 2026
Merged

improvement(pinning): move pin into the context menu and make folders pinnable#6039
waleedlatif1 merged 1 commit into
stagingfrom
feat/pin-context-menu-folders

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

Pinning moved out of the hover-revealed inline button and into the right-click context menu, and folders became pinnable.

  • Removed the inline pin affordance. PinButton is deleted (no consumers left), along with the ResourceCell.endAdornment slot it was the only user of and the group class DataRow carried solely so the button could reveal on hover.
  • Added Pin / Unpin to the three row context menusFileRowContextMenu, KnowledgeBaseContextMenu, TableContextMenu — using the Pin icon from @sim/emcn/icons and matching the neighbouring Rename / Copy ID / Delete items. The label reflects current state. On Files it is hidden in multi-select (like Rename), since a pin targets one row.
  • Folders are pinnable. 'folder' added to pinnedResourceTypeSchema and to PINNED_RESOURCES in the same change, so filterToActiveResources resolves folder pins rather than failing them closed. No migration — pinned_item.resource_type is plain text, not a pgEnum. Wired into the Files folder rows only; KB and table folders don't exist yet and are being built in parallel PRs.
  • Pinned-first ordering preserved on all three lists, and extended to the Files folder list.

One deviation worth reviewing

The brief specified backing folder pins with the generic folder table. That would ship broken: #6025 moved only workflow folders onto it. File folders — the only pinnable folders today — are still read and written against workspace_file_folders, and folder's resource_type = 'file' rows are a one-time backfill from migration 0272 that no folder created afterwards ever reaches. Resolving against folder would 404 every pin on a folder made since that migration.

So PINNED_RESOURCES.folder points at workspaceFileFolder, documented in a TSDoc at the callsite. The 0272 backfill preserved folder ids, so when the file-folder cutover lands this entry repoints at folder (scoped to resourceType = 'file') without invalidating a single existing pin.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Other: ___________

Testing

  • bunx tsc --noEmit clean in apps/sim
  • bun run lint and bun run check:api-validation pass
  • bunx vitest run --root apps/sim lib/pinned-items app/api/pinned-items app/workspace — 98 files / 1221 tests green
  • New tests: resources.test.ts gains a case asserting folder pins resolve (regression guard for the contract/lookup-map pair — adding the enum member without the PINNED_RESOURCES entry would silently drop every folder pin), and the pre-existing "unknown resourceType fails closed" case was retargeted off 'folder' since it is now a known type. app/api/pinned-items/route.test.ts gains a POST case covering folder end to end.

Reviewers should focus on the workspace_file_folders vs folder choice above, and on the context-menu separator logic in TableContextMenu / KnowledgeBaseContextMenu — the new item joins the existing info group, so the surrounding separator conditions were widened to include it.

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)

… pinnable

- Replaces the hover-revealed inline pin button on Files, Knowledge, and Tables
  with a Pin/Unpin item in each row's right-click menu, labelled from current state
- Deletes `PinButton` and the now-unused `ResourceCell.endAdornment` slot (plus the
  `group` class `DataRow` only carried for it)
- Adds `folder` to `pinnedResourceTypeSchema` and `PINNED_RESOURCES` — no migration
  needed, `pinned_item.resource_type` is plain text — and wires Pin/Unpin into the
  Files folder rows, which sort pinned-first like every other list
- Folder pins resolve against `workspace_file_folders`, not the generic `folder`
  table: file folders are still read and written there, and `folder`'s
  `resource_type = 'file'` rows are a one-time backfill new folders never reach
@vercel

vercel Bot commented Jul 29, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Jul 29, 2026 1:16am

Request Review

@cursor

cursor Bot commented Jul 29, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Touches the pinned-items API and multi-surface list UX; the workspace_file_folders vs generic folder mapping is the main correctness risk for new folder pins.

Overview
Pinning moves from hover-revealed row buttons to right-click Pin / Unpin on Files, Knowledge, and Tables. The shared PinButton and ResourceCell.endAdornment (plus row group hover styling) are removed so list rows no longer carry inline pin chrome.

Folders join the pinned-items contract (folder on pinnedResourceTypeSchema and POST). Existence checks resolve folder pins against workspace_file_folders, not the generic folder table, so pins match live file folders after the workflow-folder migration. Files wires separate pin queries for files vs folders, toggles pin from the file row menu (hidden on multi-select), and keeps pinned-first ordering for folders as well as files.

Knowledge and Tables drop inline pins and call usePinItem / useUnpinItem from their context menus with Pin/Unpin labels driven by current state. Tests cover folder POST and folder resolution in filterToActiveResources.

Reviewed by Cursor Bugbot for commit 6cdfd4d. Configure here.

@greptile-apps

greptile-apps Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Moves pin/unpin from hover PinButton into row context menus (files, knowledge bases, tables), makes file folders pinnable via resourceType: 'folder', and resolves folder pins against workspace_file_folders until the generic folder cutover.

  • Removes inline PinButton / endAdornment and row group hover styling
  • Adds Pin/Unpin to Files, Knowledge, and Tables context menus
  • Extends pinned resource contract and PINNED_RESOURCES with folderworkspaceFileFolder
  • Pins folders first in the Files folder list; keeps pinned-first ordering on file/KB/table lists

Confidence Score: 5/5

This PR appears safe to merge; pin moves to context menus and folder pins resolve against the live file-folder table with matching API/tests.

Folder pins use workspaceFileFolder with deletedAt/workspace checks; file and folder pinned-first sorts remain; context-menu handlers pin the right-clicked row with stable mutation.mutate; no remaining PinButton consumers or blocking contract gaps.

Important Files Changed

Filename Overview
apps/sim/lib/pinned-items/resources.ts Adds folder pin resolution to workspaceFileFolder with soft-delete and workspace scoping; intentional vs generic folder table.
apps/sim/app/workspace/[workspaceId]/files/files.tsx Folder pin set, pinned-first folder sort, context-menu pin toggle for file vs folder resource types.
apps/sim/app/workspace/[workspaceId]/knowledge/knowledge.tsx Removes row PinButton; wires pin toggle and pinned label on knowledge base context menu.
apps/sim/app/workspace/[workspaceId]/tables/tables.tsx Removes row PinButton; wires pin toggle and pinned label on table context menu.
apps/sim/lib/api/contracts/pinned-items.ts Extends pinnedResourceTypeSchema with folder.
apps/sim/components/pin-button.tsx Deletes unused PinButton after context-menu migration.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  UI[Files / KB / Tables list]
  CM[Context menu Pin / Unpin]
  Hook[usePinItem / useUnpinItem]
  API[POST/DELETE /api/pinned-items]
  Res[PINNED_RESOURCES lookup]
  FF[workspace_file_folders]
  Other[workflow / files / KB / tables tables]
  UI --> CM --> Hook --> API --> Res
  Res -->|folder| FF
  Res -->|other types| Other
Loading

Reviews (1): Last reviewed commit: "improvement(pinning): move pin into the ..." | Re-trigger Greptile

@waleedlatif1
waleedlatif1 merged commit 591702b into staging Jul 29, 2026
20 checks passed
@waleedlatif1
waleedlatif1 deleted the feat/pin-context-menu-folders branch July 29, 2026 01:28
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