Skip to content

sessions: refactor: build the sessions list model in a pure function - #350673

Queued
Ulugbek Abdullaev (ulugbekna) wants to merge 2 commits into
mainfrom
ulugbekna-sessions-list-model-builder
Queued

Ulugbek Abdullaev (ulugbekna) wants to merge 2 commits into
mainfrom
ulugbekna-sessions-list-model-builder

Conversation

@ulugbekna

@ulugbekna Ulugbek Abdullaev (ulugbekna) commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: b7c93b8e36eebc9b73c3d31ec51866c3b0ba9745

Dimension Assessment Rationale
Change confidence 8.5/10 ↑ Merged latest origin/main (b755f682b20, #351162) cleanly and wired inboxScopeBar / appliesScopeBarPick() into the model builder; pnpm run build-fast --client-only, pnpm run typecheck-client, pnpm run oxlint (8 files), and 774 unit tests across sessionsListModel.test.ts (13 DOM-free tests), sessionsList.test.ts, sessionsViewPane.test.ts, and editorWindowSessionsList.test.ts all passed.
↓ CI checks on b7c93b8e36e are still pending; live Code OSS verification was performed on an earlier revision (af880f46dd2) prior to merging recent main changes; PR is currently in draft.

Why

SessionsList previously built its tree nodes inline while mutating scattered render-state fields, writing legacy collapse-key migrations to storage, and logging setting experiment triggers mid-render. Extracting model construction into a pure function separates data derivation from widget side effects and allows testing list grouping, capping, ordering, Inbox transitions and priority ordering, scoping, pinned headers, workspace pin/collapse aliases, separate Groups/Workspaces mode, and comparison attachment without a DOM or workbench harness.

What changed

Validation

  • pnpm run build-fast --client-only - passed
  • pnpm run typecheck-client - passed (0 errors)
  • pnpm run oxlint on all 8 changed files - passed (0 errors/warnings)
  • ./scripts/test.sh --reporter dot --run src/vs/workbench/contrib/sessions/test/browser/views/sessionsListModel.test.ts --run src/vs/sessions/contrib/sessions/test/browser/sessionsList.test.ts --run src/vs/sessions/contrib/sessions/test/browser/sessionsViewPane.test.ts --run src/vs/workbench/contrib/sessions/test/browser/editorWindowSessionsList.test.ts - 774 passing

Copilot AI balanced review requested due to automatic review settings November 27, 2026 11:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Saved collapse-state entries are not filtered to booleans, allowing malformed values to override defaults and block fallback to a valid legacy key.

1 open issue
What changed in this PR

Extracts sessions-list model construction from the VS Code widget into a pure function, separating data derivation from rendering and storage side effects.

Changes:

  • Adds an explicit model input/result contract and a consolidated render snapshot.
  • Integrates the builder into the widget and threads explicit time through date-grouping helpers.
  • Adds five DOM-free tests covering grouping, capping, Inbox transitions, migrations, and comparison attachment.
File Description
src/​vs/​workbench/​contrib/​sessions/​test/​browser/​views/​sessionsListModel.test.ts Adds focused model-builder tests.
src/​vs/​workbench/​contrib/​sessions/​browser/​views/​sessionsListRenderers.ts Imports the relocated connector-position type.
src/​vs/​workbench/​contrib/​sessions/​browser/​views/​sessionsListModel.ts Adds model construction, snapshots, and deferred side-effect results.
src/​vs/​workbench/​contrib/​sessions/​browser/​views/​sessionsListHelpers.ts Adds explicit time inputs and relocates date-order logic.
src/​vs/​workbench/​contrib/​sessions/​browser/​views/​sessionsListDragAndDrop.ts Removes the relocated date-order helper.
src/​vs/​workbench/​contrib/​sessions/​browser/​views/​sessionsListCommon.ts Houses the shared connector-position type.
src/​vs/​workbench/​contrib/​sessions/​browser/​views/​sessionsList.ts Delegates model construction and applies results to the widget.

Review effort: Balanced

@github-actions

github-actions Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Base: b755f682 Current: 2393294d

No screenshot changes.

@ulugbekna
Ulugbek Abdullaev (ulugbekna) force-pushed the ulugbekna-sessions-list-model-builder branch from 28eb357 to 72353fa Compare November 30, 2026 16:37
@ulugbekna
Ulugbek Abdullaev (ulugbekna) added this pull request to the merge queue Nov 30, 2026
Any commits made after this event will not be merged.

@connor4312 Connor Peet (connor4312) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No blocking issues found. I left two P2 comments on search after a workspace-layout change and on keeping scope policy consistent.

Written by Connor's agent

@@ -6707,10 +5721,10 @@ export class SessionsList extends Disposable implements ISessionsList {
* {@link getRowGroupDepth}, that is the group the session is a member of, or else the group that its workspace,
* repository, or environment section is placed in, and their parents.
*/
private getSessionGroupSearchNames(session: ISession): string[] {
private getSessionGroupSearchNames(session: ISession, comparisonSectionIds: ReadonlyMap<string, string> = this._renderSnapshot.comparisonSectionIds, listWorkspaces: ISessionListWorkspaces | undefined = this._renderSnapshot.listWorkspaces): string[] {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

P2: Preserve an explicitly absent workspace lookup during search. When Group by Workspace switches from separate rows to the flat layout during a search, the new search context deliberately passes undefined for listWorkspaces. This default (and the one on getUngroupedSectionIds) instead uses the previous render’s lookup. For a comparison’s originating session in a workspace section nested under a custom group, that resolves the previous section key and can cache the wrong group-name match before tree.setChildren reuses it. Pass a context object or otherwise distinguish omitted context from an explicit undefined at both call boundaries, and add a regression test that switches the layout with a group-name search active.

Written by Connor's agent


const inbox = grouping === SessionsGrouping.Inbox;
const appliesScopeFilters = scopePickFixed || scopeBar || scopeChips;
const scopedByBar = (inbox && inboxScopeBar) || appliesScopeFilters;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

P2: Resolve the scope policy once for both pending and persisted rows. SessionsList.update() already computes appliesScopeBarPick() and ignoresEnvironmentExclusions() for drafts and scheduled rows, but filtering now reconstructs both from raw flags here, and model assembly reconstructs the pick rule again. A future Inbox or fixed-scope change can therefore affect scheduled rows, persisted rows, and comparison headers differently. Pass the resolved policy booleans into the model (or use one shared resolver) and use those same values in all three paths.

Written by Connor's agent

This branch has not been deployed

No deployments
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.

7 participants