Skip to content

feat: update sidebar and knowledge - #3804

Merged
waleedlatif1 merged 4 commits into
simstudioai:stagingfrom
adithyaakrishna:feat/knowledge
Mar 27, 2026
Merged

feat: update sidebar and knowledge#3804
waleedlatif1 merged 4 commits into
simstudioai:stagingfrom
adithyaakrishna:feat/knowledge

Conversation

@adithyaakrishna

Copy link
Copy Markdown
Contributor

Summary

  • Fix multiple renderers on the sidebar and the knowledge page.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Other: Fix multiple rerenders

Testing

  • Use the sidebar to go to each and every page
  • Go to the knowledge page and do alll actions however you used to do on Prod

Checklist

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

@vercel

vercelBot commented Mar 27, 2026

Copy link
Copy Markdown

@adithyaakrishna is attempting to deploy a commit to the Sim Team on Vercel.

A member of the Team first needs to authorize it.

@cursor

cursorBot commented Mar 27, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Mostly performance-focused refactors (memoization, stable callbacks/refs) but they touch interactive UI flows (search debounce, context menus, row selection), so regressions would be UX-related rather than data/security-critical.

Overview
Reduces unnecessary React rerenders across the Resource table shell, knowledge base list page, and the main workspace sidebar by memoizing components, extracting row/search subcomponents, and reusing stable JSX/icon/constants.

On Knowledge, replaces the useDebounce hook with a local timer-based debounce and moves row/context-menu handlers to use refs for the latest state (avoiding stale closures and click/context-menu conflicts). The sidebar similarly switches several handlers to read isCollapsed from a ref and memoizes collapsed-menu icons/actions and common callbacks to keep React.memo effective.

Written by Cursor Bugbot for commit 68ccc33. This will update automatically on new commits. Configure here.

@greptile-apps

greptile-appsBot commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR focuses on eliminating unnecessary re-renders across the sidebar and knowledge pages by applying React.memo, stable useCallback/useMemo refs, hoisted static JSX constants, and ref-based stale-closure patterns throughout the resource and knowledge component trees.\n\nKey changes:\n- resource.tsx: Splits the monolithic row-render loop into dedicated memoised sub-components (DataRow, CreateRow, CellContent, ResourceColGroup, DataTableSkeleton, Pagination) and promotes Resource itself to a memoised export.\n- resource-options-bar.tsx: Extracts SearchSection into a standalone memoised component with the localValue + lastReportedRef sync pattern, correctly fixing the previous stale-ref typing regression.\n- knowledge.tsx: Replaces useDebounce with a manual ref-based debounce, adds stale-closure-breaking refs, passes the live debouncedSearchQuery as searchConfig.value, and wires up onClearAll — both previously flagged issues are resolved.\n- sidebar.tsx: Introduces isCollapsedRef to stabilise callbacks, removes isCollapsed from nav-item keys (preventing mount/unmount on collapse toggle), and extracts memoised icon elements and primary-action objects.\n- Modal components: All five knowledge modals are wrapped in memo to prevent cascading re-renders.\n\nOne minor item: the onClearAll callback inside searchConfig's useMemo is an inline lambda, creating a new reference every debounce tick. See inline comment for a useCallback fix.

Confidence Score: 5/5

Safe to merge — no P0/P1 issues found; all previously flagged bugs are correctly resolved.

All three previously reviewed P1 issues are properly addressed. The remaining finding is a P2 style suggestion about an inline lambda inside useMemo that creates unnecessary reference churn but has no user-visible impact.

No files require special attention; knowledge.tsx has the single P2 style note about onClearAll.

Important Files Changed

FilenameOverview
apps/sim/app/workspace/[workspaceId]/components/resource/resource.tsxSplits the large row-rendering block into memoized sub-components; adds stable callbacks and hoists static JSX/function constants.
apps/sim/app/workspace/[workspaceId]/components/resource/components/resource-options-bar/resource-options-bar.tsxExtracts SearchSection into a memoized component with correct local state sync pattern, fixing the previous stale-ref typing bug.
apps/sim/app/workspace/[workspaceId]/knowledge/knowledge.tsxReplaces useDebounce with inline ref-based debounce, breaks stale closures with refs, wires up onClearAll. Minor: onClearAll lambda inside useMemo creates new reference every debounce cycle.
apps/sim/app/workspace/[workspaceId]/w/components/sidebar/sidebar.tsxStabilises callbacks with isCollapsedRef, removes isCollapsed from nav-item keys, extracts stable memoized values for collapsed menus.
apps/sim/app/workspace/[workspaceId]/components/resource/components/resource-header/resource-header.tsxHoists HEADER_PLUS_ICON to module scope and wraps BreadcrumbSegment in memo.
apps/sim/app/workspace/[workspaceId]/components/resource/components/owner-cell/owner-cell.tsxWraps OwnerAvatar in memo and extracts inline prop type into a named interface.

Sequence Diagram

sequenceDiagram
participant User
participant SearchSection
participant Knowledge
participant ResourceTable
User->>SearchSection: types character
SearchSection->>SearchSection: setLocalValue — input updates immediately
SearchSection->>Knowledge: search.onChange(char)
Knowledge->>Knowledge: debounce timer starts (300ms)
Note over SearchSection: localValue reflects typing instantly
Knowledge-->>Knowledge: setDebouncedSearchQuery fires
Knowledge-->>SearchSection: search.value updated (new prop)
SearchSection->>SearchSection: sync guard fires, setLocalValue(search.value)
Note over SearchSection: no visible jump, values already match
Knowledge->>ResourceTable: rows re-filtered
User->>SearchSection: clicks X clear button
SearchSection->>SearchSection: setLocalValue, lastReportedRef reset
SearchSection->>Knowledge: search.onClearAll() called
Knowledge->>Knowledge: debounce 300ms then setDebouncedSearchQuery
Knowledge-->>ResourceTable: rows unfiltered
Loading

Reviews (2): Last reviewed commit: "chore: fix review changes" | Re-trigger Greptile

Comment threadapps/sim/app/workspace/[workspaceId]/knowledge/knowledge.tsx
Comment threadapps/sim/app/workspace/[workspaceId]/knowledge/knowledge.tsx
@adithyaakrishna

Copy link
Copy Markdown
ContributorAuthor

@greptile review

@cursorcursorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Comment threadapps/sim/app/workspace/[workspaceId]/knowledge/knowledge.tsx Outdated
@vercel

vercelBot commented Mar 27, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
ProjectDeploymentActionsUpdated (UTC)
docsSkippedSkippedMar 27, 2026 0:58am

Request Review

@waleedlatif1
waleedlatif1 merged commit db17982 into simstudioai:stagingMar 27, 2026
12 checks passed
waleedlatif1 pushed a commit that referenced this pull request Apr 4, 2026
* feat: update sidebar and knowledge
* chore: fix rernders on knowledge
* chore: fix review changes
* chore: fix review changes
Sign up for freeto 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.

2 participants

@adithyaakrishna@waleedlatif1