Skip to content

automations: fix: limit New badge to returning Agents users - #334898

Merged
Ulugbek Abdullaev (ulugbekna) merged 3 commits into
mainfrom
ulugbekna/agents/automation-badge-visibility-fix
Sep 7, 2026
Merged

automations: fix: limit New badge to returning Agents users#334898
Ulugbek Abdullaev (ulugbekna) merged 3 commits into
mainfrom
ulugbekna/agents/automation-badge-visibility-fix

Conversation

@ulugbekna

@ulugbekna Ulugbek Abdullaev (ulugbekna) commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Restrict the Automations New badge to returning Agents-window users with no prior Automation discovery, and stop treating loading or failed catalogues as proof that Automations are unused.

Follow-up to #334091. The badge designs and renderer already exist; this changes eligibility, lifecycle handling, and related tests.

Rebased onto 70a1d06d93f6a90d3cae4bf84754b096d818ef40. The rebase reuses the canonical catalogueState API introduced by #334836 instead of retaining a parallel discovery contract. The PR now changes 15 files rather than 24.

Why

The previous badge sampled the seen bit, definitions, and runs once, synchronously. If all were empty, it resolved the style and displayed New.

That causes two problems:

  • A first-time Agents-window user sees a promotion even though the whole interface is new.
  • Agent Host providers register and hydrate asynchronously. Empty arrays can mean "not loaded yet" or "unavailable", and the one-shot check deliberately ignored later definitions/runs. Unreadable legacy data can also produce an empty projection without establishing non-use.

Implementation

Returning-window detection without storage infrastructure changes

SessionsWindowUsageService snapshots whether the existing application-scoped, machine-targeted agentSessions.telemetry.summary.appLaunchCount was nonzero before recording the current open.

The first window therefore retains hadPriorWindowOpen = false even after it stores count 1. Later windows, including users whose count was written by older builds, are recognized without relying on chat/session history.

The usage service owns the increment; SessionsLifecycleTracker receives the captured count through SessionsTelemetryContribution rather than incrementing it a second time. The stored format and telemetry event schemas are unchanged, although the increment now occurs when the usage service is instantiated rather than specifically when the telemetry tracker is constructed.

This uses ordinary application storage. No shared storage API, IPC, IndexedDB, or base/platform changes are included. Two simultaneous first opens can both read zero and remain unbadged; that conservative false negative is acceptable for a discovery cue.

Reuse upstream catalogue completeness

The badge reads the existing IAutomationService.catalogueState and accepts only ready. loading, unavailable, and error all suppress it.

Upstream already provides:

  • Aggregation over registered provider stores and the global legacy store, with precedence error > loading > unavailable > ready.
  • A loading guard until initial provider contributions settle, plus reactive updates for provider registration and catalogue changes.
  • Observable legacy-ledger readability and Agent Host subscription health, without conflating those with migration authority.
  • Conservative connection-state mapping: unsupported, disabled, and disconnected hosts remain unavailable unless their legacy storage reports an error.

The shared contract, aggregate and legacy implementations, Agent Host store implementations, provider interface, and architecture specification are unchanged from upstream. The former optional initialDiscoveryState API and its duplicated implementation are no longer part of this PR.

The local provider still needs the lifecycle fix: clear its connection listeners and Automation connection on host exit, then use its existing start binding to reconnect. This prevents a stale ready catalogue from surviving local host shutdown.

Migrated definitions and execution remain Agent Host-owned. Legacy ledgers remain compatibility sources; no schema, scheduling, permission, or session-template change is introduced.

Conservative badge lifecycle

For an unseen returning user, the badge waits until LifecyclePhase.Eventually, then evaluates the current aggregate once. It shows only when the catalogue is ready and definitions/runs are empty. It does not await a retrying migration promise.

Scenario Behavior
First Agents window Hidden; no direct badge-style treatment request.
Returning user, ready and empty catalogue Show the resolved style.
Existing definition/run or Automations view activation Persist seen and hide.
Loading, unavailable, or errored catalogue at the startup decision Suppress for that badge-state instance without recording seen.
Catalogue regresses after eligibility Suppress; recovery does not automatically reveal it again.
Definition/run appears later, including through tools Retire the badge and persist seen.
Developer reset Explicitly preview despite prior-use/readiness/evidence gates, until Automations is activated.

The startup phase is an opportunity for initial providers to populate, not a guarantee that every future provider has registered. The aggregate includes upstream's initial-provider-settlement guard; later data/readiness changes remain observable.

The existing hidden style setting, ExP styles, and accessible row labels are preserved. Style refreshes cannot bypass eligibility, and disposed states do not resume presentation after async work. The evidence observer is cleared on retirement.

Scope and tradeoffs

  • No new telemetry event or user-visible setting.
  • No badge CSS, renderer redesign, or screenshot-baseline change.
  • A slow, unsupported, unavailable, or errored source can hide the badge even for a user with no Automations; silence is preferred to a misleading promotion.
  • Prior-use evidence is local application state, not account-wide adoption tracking. Historical view-only use before the seen bit existed cannot be reconstructed exactly.
  • Startup suppression and developer preview are in-memory badge state; normal seen dismissal is persisted.

Validation

After rebasing, using fresh transpiled output:

  • 290 focused unit tests passed across window usage, lifecycle tracker, telemetry contribution, badge, Sessions list, Agent Host Automation store, aggregate Automation service, and legacy Automation service, plus the targeted local host exit/restart regression.
  • npm run typecheck-client passed.
  • Targeted ESLint passed for all 15 changed TypeScript files; the final lifecycle-fixture adjustment was rechecked.
  • git diff --check passed.
  • Verified zero diff from the new base for base/platform code, workbench storage services, generic fixture utilities, shared Automation contracts, aggregate/legacy implementations, Agent Host stores, and the architecture specification.
  • Reviewed the rebase range-diff to confirm the prior-window snapshot, telemetry integration, and local-host cleanup were preserved.

The badge regressions cover all three non-ready catalogue states both at startup and after presentation, including recovery remaining quiet. The local-host regression starts with a completed catalogue and checks ready -> unavailable -> ready across exit/restart.

The earlier review concerns remain covered: unsupported hosts never imply a ready catalogue, and upstream now directly tests provider registration, live aggregate updates, startup settlement, and the full precedence matrix in both provider orders. This PR also checks aggregate error for a future-schema global legacy ledger.

Earlier validation exercised all 15 badge variants across Dark, Light, and Dark High Contrast. Visual fixtures were not rerun after this rebase; no visual styles or screenshot baselines changed.

To rerun the focused tests:

npm run transpile-client
./scripts/test.sh \
  --run src/vs/sessions/services/sessions/test/browser/sessionsWindowUsageService.test.ts \
  --run src/vs/sessions/contrib/sessions/test/browser/sessionsLifecycleTracker.test.ts \
  --run src/vs/sessions/contrib/sessions/test/browser/sessionsTelemetry.contribution.test.ts \
  --run src/vs/sessions/contrib/sessions/test/browser/automationsNewBadge.test.ts \
  --run src/vs/sessions/contrib/sessions/test/browser/sessionsList.test.ts \
  --run src/vs/sessions/contrib/providers/agentHost/test/browser/agentHostAutomationStore.test.ts \
  --run src/vs/sessions/contrib/automations/test/browser/providerAutomationService.test.ts \
  --run src/vs/sessions/contrib/automations/test/browser/automationService.test.ts \
  --run src/vs/sessions/contrib/providers/agentHost/test/browser/localAgentHostSessionsProvider.test.ts \
  --grep '^(AutomationsNewBadgeState|SessionsWindowUsageService|SessionsLifecycleTracker|SessionsTelemetryContribution|Sessions - SessionsList|ProviderAutomationService|AutomationService|AgentHostAutomationStore|LocalAgentHostSessionsProvider Automation catalogue state follows)' \
  --reporter dot

For visual iteration in a development Agents window, Developer: Reset Automations New Badge force-previews the current sessions.automations.newBadgeStyle (accent, soft, or outline). Opening Automations dismisses it. This previews presentation, not production returning-user eligibility.

Copilot AI balanced review requested due to automatic review settings September 7, 2026 10:57

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.

Copilot review overview

🟡 Changes recommended

The aggregate discovery contract needs direct tests, and its documentation currently overstates unsupported-host readiness.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review tier: Balanced
Findings: 2 Low severity

New issues introduced by this change (2)
Severity Finding
Low severity src/​vs/​sessions/​AUTOMATIONS.md — This sentence is too broad: an unsupported host forwards its provider-scoped legacy store's…
Low severity src/​vs/​sessions/​contrib/​automations/​browser/​providerAutomationService.ts — The aggregate precedence and reactivity introduced here are not exercised by…
What changed in this PR

Restricts the Automations New badge to returning Agents-window users after authoritative Automation discovery.

Changes:

  • Tracks prior Agents-window usage without double-counting telemetry.
  • Adds provider discovery states and conservative badge eligibility.
  • Expands unit tests, fixtures, and architecture documentation.
File Description
src/​vs/​workbench/​test/​browser/​componentFixtures/​sessions/​sessionsList.fixture.ts Updates badge fixtures for new dependencies.
src/​vs/​workbench/​contrib/​chat/​common/​automations/​automationService.ts Defines the discovery-state contract.
src/​vs/​sessions/​sessions.common.main.ts Loads the window-usage service.
src/​vs/​sessions/​services/​sessions/​test/​browser/​sessionsWindowUsageService.test.ts Tests usage counting.
src/​vs/​sessions/​services/​sessions/​common/​sessionsProvider.ts Exposes optional provider discovery state.
src/​vs/​sessions/​services/​sessions/​browser/​sessionsWindowUsageService.ts Records prior window usage.
src/​vs/​sessions/​contrib/​sessions/​test/​browser/​sessionsTelemetry.contribution.test.ts Updates telemetry test dependencies.
src/​vs/​sessions/​contrib/​sessions/​test/​browser/​sessionsListTestUtils.ts Stubs window-usage state.
src/​vs/​sessions/​contrib/​sessions/​test/​browser/​sessionsList.test.ts Updates accessible-label coverage.
src/​vs/​sessions/​contrib/​sessions/​test/​browser/​sessionsLifecycleTracker.test.ts Adapts lifecycle tracker tests.
src/​vs/​sessions/​contrib/​sessions/​test/​browser/​automationsNewBadge.test.ts Covers badge eligibility and suppression.
src/​vs/​sessions/​contrib/​sessions/​browser/​sessionsTelemetry.contribution.ts Passes the captured launch count.
src/​vs/​sessions/​contrib/​sessions/​browser/​sessionsLifecycleTracker.ts Removes duplicate launch counting.
src/​vs/​sessions/​contrib/​sessions/​browser/​automationsNewBadge.ts Implements conservative badge lifecycle.
src/​vs/​sessions/​contrib/​providers/​agentHost/​test/​browser/​localAgentHostSessionsProvider.test.ts Tests host reconnection discovery.
src/​vs/​sessions/​contrib/​providers/​agentHost/​test/​browser/​agentHostAutomationStore.test.ts Expands discovery-state tests.
src/​vs/​sessions/​contrib/​providers/​agentHost/​browser/​reconnectableAgentHostAutomationStore.ts Maps connection state to discovery.
src/​vs/​sessions/​contrib/​providers/​agentHost/​browser/​localAgentHostSessionsProvider.ts Clears Automation connections on exit.
src/​vs/​sessions/​contrib/​providers/​agentHost/​browser/​agentHostAutomationStore.ts Tracks catalogue health and readiness.
src/​vs/​sessions/​contrib/​automations/​test/​browser/​providerAutomationService.test.ts Covers unreadable legacy discovery.
src/​vs/​sessions/​contrib/​automations/​test/​browser/​automationService.test.ts Tests ledger discovery states.
src/​vs/​sessions/​contrib/​automations/​browser/​providerAutomationService.ts Aggregates provider discovery states.
src/​vs/​sessions/​contrib/​automations/​browser/​automationService.ts Derives discovery from ledger readability.
src/​vs/​sessions/​AUTOMATIONS.md Documents initial discovery semantics.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/vs/sessions/AUTOMATIONS.md Outdated
Comment thread src/vs/sessions/contrib/automations/browser/providerAutomationService.ts Outdated
Track prior Agents window opens with the existing machine-scoped counter. Gate badge presentation on provider discovery and Automation evidence while preserving the developer preview and experiment styles.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 7e75f732-f18f-42a7-b1e2-a034c03596eb
Include legacy ledger readability and live Agent Host catalogue health in badge eligibility. Propagate host disconnects, retain simple prior-window tracking, and add regression coverage without changing shared storage APIs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 7e75f732-f18f-42a7-b1e2-a034c03596eb
Exercise provider registration and live discovery precedence through the aggregate observable. Clarify that unsupported hosts are ready only when their legacy storage is readable.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 7e75f732-f18f-42a7-b1e2-a034c03596eb
@ulugbekna
Ulugbek Abdullaev (ulugbekna) force-pushed the ulugbekna/agents/automation-badge-visibility-fix branch from 8667286 to 9a615e6 Compare September 7, 2026 13:21
@ulugbekna
Ulugbek Abdullaev (ulugbekna) marked this pull request as ready for review September 7, 2026 15:34
@vs-code-engineering

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

Sandeep Somavarapu (@sandy081)

Matched files:

  • src/vs/sessions/services/sessions/browser/sessionsWindowUsageService.ts
  • src/vs/sessions/services/sessions/test/browser/sessionsWindowUsageService.test.ts

Ladislau Szomoru (@lszomoru)

Matched files:

  • src/vs/sessions/services/sessions/browser/sessionsWindowUsageService.ts
  • src/vs/sessions/services/sessions/test/browser/sessionsWindowUsageService.test.ts

@ulugbekna
Ulugbek Abdullaev (ulugbekna) merged commit b18d9a0 into main Sep 7, 2026
34 checks passed
@ulugbekna
Ulugbek Abdullaev (ulugbekna) deleted the ulugbekna/agents/automation-badge-visibility-fix branch September 7, 2026 15:39
@vs-code-engineering vs-code-engineering Bot added this to the 1.138.0 milestone Sep 7, 2026
@ulugbekna Ulugbek Abdullaev (ulugbekna) added the ~release-cherry-pick Trigger: cherry-pick this PR to the latest release branch label Sep 7, 2026
@vs-code-engineering vs-code-engineering Bot added release-cherry-pick Automated cherry-pick between release and main branches and removed ~release-cherry-pick Trigger: cherry-pick this PR to the latest release branch labels Sep 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-cherry-pick Automated cherry-pick between release and main branches

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants