Skip to content

Menu card lists mount every loaded page, so switching menus stutters on large workspaces #41405

Open

Description

@BenjaminX

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.17.0

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

  1. Use a workspace with a large number of apps and knowledge bases. Ours has 432 apps and 169 datasets.
  2. Open Studio and scroll far enough that infinite scroll loads several pages.
  3. Click between the top-level menu entries — Home, Studio, Agents, Knowledge, Skills, Integrations.

Related: #41396 is the same class of problem in the Web Apps sidebar, fixed in #41397. The difference is that the sidebar stays mounted across route changes, so its cost is repaint, while these page-level grids are re-mounted from scratch on every visit.

Studio, Knowledge, Skills and Snippets each flatten every loaded page into one array and render a card for every entry. React Query caches the whole infinite query, so returning to a list re-mounts every accumulated page in a single commit rather than the page-sized batches that scrolling adds.

Measurements from a Safari Web Inspector timeline recorded while clicking through the top-level menus (3.06s):

Metric Value
Rendering frames 23 in 3.06s (~7.5 fps), worst frame 976ms
composite 1067.7ms total, 35% of the recording
paint 12,112 records totaling 34.5ms (highly fragmented)
All script categories ~830ms combined
Navigation RSC payloads 340 B – 3.2 KB each, 12–58ms

So the cost is in painting and compositing, not in JavaScript or in loading.

Frame pacing tracks how many cards a route mounts, not how it fetches:

Route Entries in this workspace Stutters
Studio 432 yes
Knowledge 169 yes
Agents 8 no
Skills 4 no

Skills uses the same accumulating infinite query as Studio and does not stutter, so the driver is the number of mounted cards rather than the data-fetching pattern.

A controlled A/B/A sweep on the same deployment, interleaving factors across three rounds and taking medians so the collaboration-mode refetch cannot land on one factor (baseline re-measured first and last, 16.6 / 17.9 fps):

Change fps
baseline 17.3
mask-image: none everywhere 28.7
mask-image: none inside cards only 28.1
mask-image: none inside the left nav only 18.6

Every card carries CSS mask-image icons, and they are the largest single paint factor. The un-virtualized rows multiply exactly that cost.

Two things worth recording so they are not tried as fixes: disabling backdrop-filter made things about 2x worse, because it removes beneficial layer promotion; and content-visibility: auto on the cards was within noise, because it skips rendering for nodes that are already mounted and does not stop them being created on navigation.

✔️ Expected Behavior

Switching between menu entries costs about the same regardless of how many apps or knowledge bases a workspace holds, because the list only mounts the cards near the viewport.

❌ Actual Behavior

Every loaded page stays mounted and is re-mounted and repainted when returning to the list. On a workspace with 432 apps, switching to Studio or Knowledge drops to ~7.5 fps, and the clicked entry gives no feedback until the commit finishes, so the click often looks like it was missed and gets repeated.

Activity

  1. added
    feat:webapp
    on Aug 27, 2026
  2. dosubot commented on Aug 27, 2026

    @dosubot

    @BenjaminX this is an excellent analysis. The root cause is confirmed across all three list views — each flattens every loaded page into a single array and mounts every card unconditionally, with no virtualization.

    Studio (app-list-catalog.tsx line 104): appListPages.flatMap(...) feeds directly into apps.map(...) which renders every AppCard [1].

    Knowledge (datasets.tsx line 46): pages.flatMap(({ data }) => data) then datasets.map(...) renders every DatasetCard [2].

    Snippets (snippet-list/index.tsx lines 145–148): pages.flatMap(...) then snippets.map(...) renders every SnippetCard [3].

    This is structurally the same problem as #41396 (the Web Apps sidebar), where useVirtualizer was dropped in #39739 when cursor pagination was introduced [4]. The difference is that the sidebar rows stay mounted across route changes (persistent nav), while these card grids are page-level components that get fully re-mounted — so the cost here is React reconstructing all N cards from scratch in a single commit plus the subsequent paint/composite cost you measured.

    The fix for all three is to virtualize the card grid with @tanstack/react-virtual. One complication: these grids use grid-cols-[repeat(auto-fill,minmax(296px,1fr))] [5] [6], so you'd need to virtualize by row (grouping cards per row based on measured container width) rather than individual items. useVirtualizer supports this via count: Math.ceil(items.length / columnsPerRow) and rendering each row as a slice.

    Your mask-image A/B (17.3 → 28.7 fps, almost entirely from cards) confirms virtualization is the correct fix — removing off-screen nodes eliminates the per-card paint cost entirely. The icon implementation itself is an independent optimization worth tracking separately.

    It would make sense to link this issue, #41396, and the three affected components together so the virtualization fix can be applied consistently in one PR.

    To reply, just mention @dosu.


    Share context across your team and agents. Try Dosu.

    Leave Feedback Learn about dify with Dosu

  3. BenjaminX commented on Aug 27, 2026

    @BenjaminX
    ContributorAuthor

    Thanks — a PR doing exactly this is already open at #41406, so the analysis matches on every point.

    Row virtualization. That is the approach taken, with one refinement worth flagging: rather than computing columnsPerRow from the measured container width, the component reads the resolved grid-template-columns back off the grid element and counts the tracks, and reads row-gap the same way. auto-fill has already done that arithmetic, so re-deriving it in JS would mean two places that can disagree after any change to the track definition. A ResizeObserver re-chunks on width changes. Card height stays an explicit prop, since it belongs to the card rather than the grid.

    Scope is four lists, not three. Skills (features/skills/page.tsx) has the same shape and is included. It is also the control that pins the cause down: it uses the same accumulating infinite query as Studio, but this workspace only has 4 skills and it does not stutter, so the driver is the number of mounted cards rather than the fetching pattern.

    One owner rather than three call sites. Instead of repeating the virtualizer in each grid, the PR adds app/components/base/virtualized-card-grid, next to infinite-scroll-sentinel — the existing shared list utility with the same reach. Only the mechanism is shared; each list keeps its own track sizing and card height, so no page changes visually. The eleven other auto-fill grids in the tree are bounded (template pickers, the ≤100 starred row, home sections) or are skeletons and placeholder grids rather than lists, so they are deliberately left alone and can adopt the component in a few lines if they ever grow.

    Relationship to #41396. Agreed, and both are now cross-linked. The sidebar fix for that one landed in #41397; the difference you describe is the interesting part — the sidebar rows stay mounted across route changes, so its cost is repaint, while these page-level grids are re-mounted from scratch, so the cost is React reconstructing all N cards in a single commit and then painting them.

    That distinction also corrected something in my own reasoning worth recording: content-visibility: auto measured within noise on the cards, which I first read as evidence against virtualization. It is not — content-visibility skips rendering for nodes that are already mounted, so it can only help the scroll case, while only virtualization avoids constructing them on navigation.

    Icon implementation. Agreed that it is independent and not attempted here. One caveat for whoever picks it up: the generated stylesheet already splits 426 monochrome icons onto mask-image and 16 multi-color ones onto background-image, and the mask path is what lets monochrome icons inherit currentColor. Moving them to background-image would lose theming, and I have not measured background-image to actually be cheaper to paint.

    From Claude Code

  4. added
    status: blocked
    status: awaiting response
    and removed
    feat:webapp
    on Aug 27, 2026
  5. added
    1.17.0
    on Sep 3, 2026
  6. added this to the 1.17.1 milestone on Sep 3, 2026
  7. added
    review: high
    on Sep 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    1.17.0review: highstatus: awaiting responsestatus: blocked

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions