sessions: Preserve explicit unread marks on the active session #336744

Merged
benibenj opened 3:51am on September 18, 2026 wanted to merge 200 Ξ” into microsoft/vscode main from
benibenj/agents/fix-active-session-read-unread-issue

Pull Request Overview

  • Opened on September 18, 2026
  • Status Merged
  • Commit count 1 with first commit September 18, 2026

Total Delta

200 Total Diff Delta

Open Days

Open 0 weekdays

Test Delta

126 Diff Delta in Test Files
Breakdown by Phase

How long has this pull request spent in each phase of its lifecycle?

Fraction of total time Business days Phase
N/A 0.2 days Issue creation to work beginning
 
0.0 days Authoring 1 commit before pull request opened for review
 
0.0 days Awaiting first review
 
0.8 days Merge to deploy (still awaiting deployment)

Total time for pull request 0.0 business days from first commit authored to merge
Still awaiting deployment

Author avatar

sessions: Preserve explicit unread marks on the active session

Closes #336721.

Summary

The active-session watcher immediately marked explicit unread updates as read again. Preserve that user intent until the user switches away and returns, or explicitly marks the session read.


  • Keep normal automatic reading of active-session updates and existing inactive-session behavior.

  • Preserve the unread mark when reopening the already-active session from the main or flat sessions list.

  • Add regression coverage for navigation, provider updates, and Mark as Read / Mark All as Read.

Validation


  • Client compilation completed with zero errors (npm run gulp compile-client).

  • Hygiene passed for all six changed files.

  • Both affected test suites passed: 293 passing, 2 pending.

Steps to reproduce: * Open the Agents window and focus a session. * While that session remains focused, use Mark as Unread on it. * Observe the session's unread state.

Expected: The focused session is marked as unread and displays its unread indicator.

Actual: Nothing changes; the session remains read. This appears to reproduce only when the session being marked as unread is currently focused.

Additional context: See the attached screen recording.

https://github.com/user-attachments/assets/2ef1bf40-1ff1-44f3-9d39-a702009599ac

Version: 1.139.0-insider
Commit: 046944034292b5479b4e9a50ad1a508033ffb64f
Date: 2026-09-17T03:41:14Z
Electron: 43.6.0
ElectronBuildId: 15274685
Chromium: 150.0.7871.250
Node.js: 24.20.0
V8: 15.0.245.31-electron.0
@github/copilot: 1.0.84-5
@github/copilot-sdk: 1.0.13
OS: Darwin arm64 25.6.0

Comments Threads Pending Resolution

ljharb reviewed on September 18, 2026
ljharb left a comment

## Copilot review overview

### 🟑 Changes recommended

Active-session provider replacements can still erase explicit unread intent without user navigation.

*Get a fresh assessment by requesting another Copilot review.*

**Review effort:** Balanced
**Findings:** 1 Medium severity

Open (1)

- Medium severity [Preserve unread intent across active-session replacement](#discussion_r4045694474) Β· New

What changed in this PR

Preserves explicit unread state for the active Agents session until navigation or an explicit read action.

**Changes:**
- Tracks explicit unread intent during active-session updates.
- Avoids marking already-active list entries read.
- Adds regression coverage for navigation and read actions.

| File | Description |
| ---- | ----------- |
| `sessionsManagementService.test.ts` | Tests read-state transitions. |
| `sessionsManagement.ts` | Adds read-preservation options. |
| `sessionsService.ts` | Updates active-session read handling. |
| `sessionsManagementService.ts` | Tracks explicit unread intent. |
| `sessionsList.test.ts` | Tests main and flat list behavior. |
| `sessionsList.ts` | Preserves unread state when reopening active rows. |

---

πŸ’‘ Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

ljharb reviewed on September 18, 2026
src/vs/sessions/services/sessions/browser/sessionsService.ts
491
			const isRead = activeSession?.isRead.read(reader);
492
			const activeSessionChanged = activeSession?.sessionId !== previousActiveSessionId;
493
			previousActiveSessionId = activeSession?.sessionId;
492 494
			if (activeSession && 
(
activeSession
Changed || !
isRead
)) {
493 495
				this.sessionsManagementService.markRead(activeSession
, { preserveExplicitUnread: !activeSessionChanged }).catch(onUnexpectedError
);

Resolved Comment Threads

No resolved comments have been left on this PR.