Skip to content

feat: update sidebar and knowledge#3804

Open
adithyaakrishna wants to merge 4 commits intosimstudioai:stagingfrom
adithyaakrishna:feat/knowledge
Open

feat: update sidebar and knowledge#3804
adithyaakrishna wants to merge 4 commits intosimstudioai:stagingfrom
adithyaakrishna:feat/knowledge

Conversation

@adithyaakrishna
Copy link
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
Copy link

vercel bot commented Mar 27, 2026

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

A member of the Team first needs to authorize it.

@cursor
Copy link

cursor bot commented Mar 27, 2026

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
Copy link
Contributor

greptile-apps bot commented Mar 27, 2026

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

Filename Overview
apps/sim/app/workspace/[workspaceId]/components/resource/resource.tsx Splits 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.tsx Extracts 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.tsx Replaces 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.tsx Stabilises 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.tsx Hoists HEADER_PLUS_ICON to module scope and wraps BreadcrumbSegment in memo.
apps/sim/app/workspace/[workspaceId]/components/resource/components/owner-cell/owner-cell.tsx Wraps 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

@adithyaakrishna
Copy link
Contributor Author

@greptile review

Copy link

@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.

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.

@vercel
Copy link

vercel bot commented Mar 27, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Mar 27, 2026 0:58am

Request Review

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