Repository navigation
sessions: refactor: build the sessions list model in a pure function - #350673
Ulugbek Abdullaev (ulugbekna) wants to merge 2 commits into
Conversation
4b469ce
There was a problem hiding this comment.
🟡 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
af880f4
|
Base:
|
Co-authored-by: Copilot App <[email protected]>
28eb357 to
72353fa
Compare
Co-authored-by: Copilot App <[email protected]>
Connor Peet (connor4312)
left a comment
There was a problem hiding this comment.
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[] { | |||
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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

Agent assessment
Self-reported assessment, not an independent review.
Assessed revision:
b7c93b8e36eebc9b73c3d31ec51866c3b0ba9745origin/main(b755f682b20, #351162) cleanly and wiredinboxScopeBar/appliesScopeBarPick()into the model builder;pnpm run build-fast --client-only,pnpm run typecheck-client,pnpm run oxlint(8 files), and 774 unit tests acrosssessionsListModel.test.ts(13 DOM-free tests),sessionsList.test.ts,sessionsViewPane.test.ts, andeditorWindowSessionsList.test.tsall passed.↓ CI checks on
b7c93b8e36eare still pending; live Code OSS verification was performed on an earlier revision (af880f46dd2) prior to merging recentmainchanges; PR is currently in draft.Why
SessionsListpreviously 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
sessionsListModel.ts): AddedbuildSessionsListModel()andfilterSessionsForList(), which accept an explicitISessionsListModelInput(includingnow,separateGroupsAndWorkspaces,listWorkspaces,listedWorkspaceLabels,scoped,hasSessionScope,scopeBar,inboxScopeBar,scopeChips,scopePickFixed,isSessionInScope,pinnedSectionIds,headerAliases, andinboxPriorityOrder) and return tree children, separate navigation sections, filtered sessions, an immutableISessionsListRenderSnapshot(includingrenderedPinnedHeaderIds,headerAliases,spacedHeaderIds,mutedHeaderIds, andlistWorkspaces), deferredmigratedCollapseStateKeys,filterTrace, and experimenttriggers.sessionsList.ts): Replaced inline tree assembly and mutable per-render maps/sets with a single_renderSnapshotupdated inapplyModelResult(), where trace logging, storage migrations, experiment triggers, navigation sections,tree.setChildren(), and spaced/muted header re-measurement are applied. Inbox mode continues to reactively observecomputeInboxPlacements()overfilterSessionsForList()and passes the precomputed result intobuildSessionsListModel(). Preserves list-side scoping from sessions: workspaces filter bar in every grouping and list-side scoping #350603, editor Chat-view Inbox options from Sessions: Inbox Mode in the editor window's Chat view sessions list #350638, pinned custom groups and grouping sections from sessions: pin custom groups and folders in the sessions list #350669, separate Groups/Workspaces mode from Agents window: separate groups and workspaces in Group by Workspace #350686,ISessionAgentMergeServicefrom sessions: show the Changes of a chat in several repositories per repository #350808, workspace pin/collapse aliases from sessions: keep a workspace's pin across layouts and through a rename #350801, Inbox priority head-start ordering from sessions: give Inbox attention priority a head start over recency #350844, Agents-mode fixed scope pick & worktree filter observable from Agents mode: folders follow the focused session #350796, workspace-file section naming/collapse keys from sessions: list a session started from a workspace under the workspace's name #351020, experimental filter chips from Sessions: add experimental filter chips #350805, workspace-aware scope matching from Agents mode: Open in New Window on a folder, workspace or repository row opens a scoped Agents-mode window #351074, empty managed workspace listing from sessions: give each new workspace its own file, show it in the sessions list right away, select it in the new chat, and share the workspaces across profiles #351094, hidden-by-default Inbox scope bar handling from sessions: hide the workspace and environment filters in Inbox by default #351162, and filters non-boolean entries when constructingsavedSectionCollapseState.sessionsListHelpers.ts,sessionsListCommon.ts,sessionsListDragAndDrop.ts,sessionsListRenderers.ts): Threaded optionalnowMsthroughgroupSessionsForList,groupByDate, andpartitionByDate; movedSessionGroupConnectorPositiontosessionsListCommon.tsandkeepDateSectionOrdertosessionsListHelpers.tsso the pure model has no UI/DnD dependency.sessionsListModel.test.ts,sessionsList.test.ts): Added 13 DOM-free unit tests insessionsListModel.test.tscovering workspace folder capping, emptylistedWorkspaceLabelswithout capping, Date grouping and next time-boundary calculation, Inbox placements and Working-section collapse transitions, Inbox priority ordering (HeadStartvsStrictwithNeedsInputalways first), non-mutating legacy collapse-key migrations/experiment triggers, comparison group attachment,scopeBar/inboxScopeBar/scopeChips/scopePickFixed/ list-side session scoping, pinned groups/sections, separate Groups/Workspaces sections, and header pin/collapse aliases; added a regression test insessionsList.test.tsfor ignoring non-boolean saved collapse-state entries.Validation
pnpm run build-fast --client-only- passedpnpm run typecheck-client- passed (0 errors)pnpm run oxlinton 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