Skip to content

fix(web): avoid repeated session list scans in sidebar computeds - #1563

Merged
wbxl2000 merged 1 commit into
mainfrom
fix/web-session-list-jank
Jul 12, 2026
Merged

fix(web): avoid repeated session list scans in sidebar computeds#1563
wbxl2000 merged 1 commit into
mainfrom
fix/web-session-list-jank

Conversation

@wbxl2000

Copy link
Copy Markdown
Collaborator

Related Issue

No linked issue — the problem is explained below.

Problem

With many sessions, the web sidebar visibly stutters. A Chrome Performance recording shows animation-frame tasks of ~87–89 ms against a 16.7 ms frame budget at 60 Hz. Bottom-up attributes ~60 ms (71.5% of the selected range) to isSessionEffectivelyRunning() re-running rawState.sessions.find(): the three sidebar list computeds (sessions, sessionsForView, workspaceGroups) each re-scan the whole reactive session array once per row, so the per-frame work grows roughly quadratically with the session count.

What changed

isSessionEffectivelyRunning() now takes the AppSession object the caller already holds instead of a session id:

  • sessions, sessionsForView, and workspaceGroups pass the row's session directly — no more per-row find() over the whole list.
  • activity (active session only, outside any list loop) keeps a single explicit find() and passes the result in.
  • Not-found still returns false; the BTW side-chat, running-task, and tasks-not-yet-loaded rules are untouched, so all spinner behavior is identical.
  • No new caches, maps, exports, or modules; this is the minimal fix. Remaining smaller hotspots (workspaceIdForSession, toSorted) are intentionally left for a follow-up only if profiling still shows long tasks.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • Behavior is unchanged and covered by the existing test suite (25 files / 380 tests pass); typecheck and production build pass. This is an internal data-passing change, so no new test file was added.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update — internal performance fix with no user-facing behavior change.

@changeset-bot

changeset-bot Bot commented Jul 12, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 4086b95

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Jul 12, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@4086b95
npx https://pkg.pr.new/@moonshot-ai/kimi-code@4086b95

commit: 4086b95

@wbxl2000
wbxl2000 merged commit c982386 into main Jul 12, 2026
11 checks passed
@wbxl2000
wbxl2000 deleted the fix/web-session-list-jank branch July 12, 2026 03:51
@github-actions github-actions Bot mentioned this pull request Jul 12, 2026
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