Skip to content

vscode: notification hygiene refactor — centralize connection guard, demote success toasts, add Output channel #794

Open

Description

@amrmelsayed

Problem

An audit of every vscode.window.show*Message call in packages/vscode/src/** surfaced 112 notification sites with four pervasive anti-patterns:

  1. The string 'Codev: Not connected to Tower' appears as an error toast in 17+ places across nearly every command.
  2. The same 'No builders available' / 'No data' info toast appears ~8 times for what's almost always a silent no-op situation.
  3. Success info toasts (Approved gate, Cleaned up builder X, Message sent, Dev server started/stopped, Tunnel connecting/disconnected, Copied #X, Running afx …, Cron: action — name) interrupt the user with information they could just glance at. ~10 sites.
  4. Technical error toasts dump raw ${err.message} content into a notification (Failed to ${action} — ${err.message}). ~13 sites. Notifications truncate and disappear; the actual exception detail is lost.

The cumulative effect is toast spam — most notifications are either redundant, ignorable, or unparseable in a hurry.

Scope (single PR consolidating T1–T4)

This issue groups four sub-refactors that share infrastructure and a theme. They're tracked together so the PR can land them atomically with one set of helpers / one Output channel.

T1 — Centralize the "Not connected to Tower" guard

  • Add a shared helper (e.g. requireConnected(connectionManager): boolean) used by every command instead of inline if (!connected) { showErrorMessage('Codev: Not connected to Tower'); return; }.
  • Add a persistent status-bar item ($(debug-disconnect) Codev) that's visible only when Tower is disconnected. Click → invokes codev.reconnect. Replaces the per-command toasts.
  • All 17+ inline "Not connected" toasts removed; commands invoke the helper, which renders a single transient toast on first invocation per disconnect (or no toast — relies on status-bar).

T2 — Centralize "No builders" / "No data" handling

  • Add pickBuilderOrNotify(builders, opts) shared helper that returns a builder or undefined. When builders.length === 0, it does not show a toast — it's a silent no-op for picker flows.
  • For tree-/sidebar-driven flows (Builders view), surface the "no builders" state as an inline placeholder row in the tree ((no active builders — spawn one to begin)) rather than a toast.
  • All 8 inline "No builders" / "No data" toasts removed.

T3 — Demote success info toasts to status-bar transients

  • Convert success notifications to vscode.window.setStatusBarMessage(msg, 3000).
  • Affects approximately: approve.ts:167, cleanup.ts:57, send.ts:40, dev-shared.ts:143, dev-shared.ts:165, stop-worktree-dev.ts:39, tunnel.ts:11, tunnel.ts:21, extension.ts:491, spawn.ts:48, cron.ts:37.
  • Two exceptions kept as toasts because they carry actionable buttons:
    • builder-spawn-handler.ts:63 ("Builder X spawned" with "Open Terminal" action) — keep.
    • notifications/gate-toast.ts wrapper (gate-blocked actions) — keep.

T4 — Add a Codev OutputChannel + central error reporter

  • Create a single vscode.OutputChannel named Codev on activation (likely already partly present — outputChannel is constructed in extension.ts:118; verify and consolidate).
  • Add a central reportError(action: string, err: unknown) helper that:
    • Appends a timestamped entry to the Output channel with the full stack/message.
    • Shows a single concise toast: Codev: <action> failed — see Output with a Show Output button (focuses the channel).
  • Replace all ~13 raw "Failed to ___ — ${err.message}" toasts with calls to reportError(...).
  • Affects approximately: extension.ts:415, extension.ts:440, extension.ts:457, terminal-manager.ts:182, approve.ts:164, cleanup.ts:53, dev-shared.ts:121, dev-shared.ts:138, send.ts:36, view-diff.ts:339, view-issue.ts:155, connection-manager.ts:211, connection-manager.ts:216.

Acceptance criteria

  • Shared requireConnected() helper exists; every command that previously inlined the "Not connected" toast now calls it.
  • Status-bar item visible only when disconnected; click invokes codev.reconnect.
  • Shared pickBuilderOrNotify() helper used by every "pick a builder" flow; no per-command "No builders" toasts remain.
  • Builders tree shows an inline placeholder when no builders exist instead of a toast.
  • Success info toasts demoted to setStatusBarMessage(msg, 3000) per the T3 list; two actionable exceptions preserved.
  • Codev OutputChannel exists; reportError() helper appends full detail and shows a concise toast + Show Output action.
  • All ~13 raw "Failed to ___" toasts go through reportError().
  • Pickers (showQuickPick, showInputBox) and explicit confirmation modals are untouched.

Out of scope

  • Restructuring how errors propagate from connectionManager / terminalManager (intentionally — boundary only, not core).
  • Auto-reconnect logic (T1 is about surfacing state, not changing reconnect policy).
  • Removing the gate-toast.ts wrapper or its action-button toasts.

Source

Derived from the toast audit run on 2026-05-21 across packages/vscode/src/**. 112 notification call sites inventoried; this issue covers the four recurring anti-patterns (T1–T4 in the audit synthesis).

Activity

  1. self-assigned this
    on May 21, 2026
  2. added
    type:refactor
    area/vscode
    project
    and removed
    type:refactor
    on May 21, 2026
  3. amrmelsayed commented on Aug 14, 2026

    @amrmelsayed
    CollaboratorAuthor

    Rescope (architect, 2026-08-14): the numbers are stale, and the problem has grown

    Re-counted against apps/vscode/src (the extension moved from packages/vscode, so every path in this issue needs re-resolving):

    Metric As filed Today
    window.show*Message call sites 112 139
    Codev: Not connected to Tower occurrences "17+" 31

    So the case for this refactor is stronger than when it was written, not weaker.

    What already exists: a single Codev OutputChannel is created at apps/vscode/src/extension.ts:201, which T4 anticipated ("likely already partly present, verify and consolidate"). That part is done.

    What does not exist: no requireConnected() helper, no pickBuilderOrNotify() helper, and no central reportError(). All three sub-refactors still have their full scope.

    Two notes for whoever plans this:

    1. Re-derive the call-site lists. The file:line inventories in T3 and T4 were accurate in May and will not survive the directory move plus three months of churn. Treat them as a description of the pattern, not a work list.
    2. Sequencing constraint. This rewrites call sites across the whole extension and therefore carries the largest merge-conflict surface of anything in the area/vscode backlog. It should run in a quiet lane rather than beside other vscode work.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/vscodeproject

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions