Skip to content
Source
Sign inSign up
pingdotgg/t3code

feat(web): select diagnostics environment #4486

Closedcolonelpanic8(GitHub profile, opens in a new tab)wants to merge 6 commits intomain fromrefs/pull/4486/headopened View on GitHub

What Changed

Adds an explicit diagnostics-source picker and routes every diagnostics request through the selected backend.

Why

Client-only mode has no primary local environment, so the diagnostics page previously had no backend to query. Diagnostics are backend-specific, not client-specific.

Behavior

  • Defaults to primary, then active, then first available environment.
  • Keeps an explicit machine selection while it remains connected.
  • Gives a clear Connections call to action when no environments are available.
  • Replaces indefinite loading states with an explanatory notice when the selected environment is not connected, and disables refresh / "Open logs folder" while it is unreachable.
  • Keys logs-folder errors and in-flight process signals by environment, so one machine's state never leaks into another's.

UI evidence

All shots come from the same build, light theme, and one 1800px-wide window. Two environments are configured: dev-workstation (this machine, connected) and demo-box (a saved remote backend that was deliberately shut down).

"Before" is acccd0e9f (this branch's pre-review-fix head); "after" is eb272e4f6. The branch has since been rebased onto upstream main as 0db411ea1815; that rebase changed no file content, so these captures still reflect the current head exactly.

1. Selecting an environment that is not connected

Diagnostics RPCs only resolve while the environment's supervisor is connected, so before this fix the page waited forever.

Before — acccd0e9f: every stat reads ..., every table sits on "Loading live processes…" / "Collecting process resource samples…" / "Loading failures…" / "Loading span names…" indefinitely, and all three refresh icons spin forever. "Open logs folder" is still enabled even though it cannot work.

Before: diagnostics for a disconnected environment load forever

After — eb272e4f6 (content-identical to current head 0db411ea1815): every stat reads —, and every table explains the actual state ("Reconnecting to demo-box… Reason: …") instead of pretending to load. The refresh icons are static and disabled, and "Open logs folder" is disabled too.

After: diagnostics for a disconnected environment explain the connection state

The notice wording follows the connection phase, so a backend that is offline, available, connecting, or error gets its own message rather than the reconnecting one shown here.

2. The new "Diagnostics source" picker

This is what the PR adds; there is no equivalent on main, where the page always queried the primary backend.

Diagnostics collected from the selected backend, with its connection status and URL under the heading:

After: diagnostics page with the Diagnostics source row and live data

Picker open — machine choice is explicit, and local vs remote backends are distinguished by icon:

After: the environment picker open, listing both machines

Verification

  • vp test run apps/web/src/components/settings/DiagnosticsSettings.logic.test.ts
  • vp check (passes; existing repo warnings only)
  • Web integration: paired two isolated servers as separate environments, opened /settings/diagnostics, confirmed diagnostics are collected from whichever machine is selected, then killed the remote backend and re-checked the page on both the pre-fix and current commits to produce the before/after images above.
  • vp run typecheck is blocked by an incomplete local dependency tree (apps/marketing cannot find astro); focused web typecheck also reports 10 pre-existing errors outside this change.

Note

Medium Risk Touches live process signaling and multi-environment diagnostics routing; mistakes could show wrong-machine data or leave actions enabled when disconnected, though the PR explicitly gates on connectivity and keys state by environment.

Overview Adds a Diagnostics source row with an environment picker so process, resource, and trace diagnostics run against a chosen backend instead of always using the primary server.

Resolution follows selected → primary → active → first available, with recovery when a saved machine drops off the catalog and a Manage connections path when none exist. Diagnostics RPCs and UI actions only run when that environment is connected; cached query data is not shown while disconnected, so stats show — instead of stale values and refresh, logs folder, and process signals are disabled. Empty tables show connection-phase notices (offline, reconnecting, error, etc.) instead of indefinite loading spinners.

Panel state is scoped per environment: in-flight process signals and logs-folder open/errors are keyed by environmentId, and the process table resets on switch via key={environmentId}. Pure helpers in DiagnosticsSettings.logic cover resolution, notices, and pending-signal tracking, with unit tests.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 2628089aeb368203cba7ce108f8c839aa7d59132. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Add environment selection to the diagnostics settings panel

  • Adds an environment selector to DiagnosticsSettingsPanel so users can target any available environment for diagnostics, not just the primary one.
  • Introduces resolveDiagnosticsEnvironmentId to determine the active diagnostics environment with a defined fallback precedence (selected → primary → active → first available → null).
  • Suppresses data queries and disables action buttons when the selected environment is not connected; shows a diagnosticsConnectionNotice string instead of stale data.
  • Replaces the single signalingPid with a per-environment pendingSignals set so multiple in-flight process signals can be tracked and displayed concurrently.
  • Scopes the async 'Open logs folder' result to the environment that initiated it via a new LogsDirectoryState interface keyed by environmentId.
Macroscope summarized 2628089.
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro Plus

      Run ID: 81fe8608-f11a-4a2d-af3b-2ac3fc8aab0d

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create PR with unit tests

      Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

      ❤️ Share
      Comment `@coderabbitai help` to get the list of available commands.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Needs human review

      This PR introduces a new user-facing feature for selecting diagnostics environments, adding new UI components, state management patterns, and connection-awareness behavior. New features with user-facing behavior changes warrant human review.

      You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

      Fix All in Cursor ❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard/bugbot). Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 470cfef105bd3eb9c5fc8fc8aa9494bc9d98cf12. Configure [here](https://www.cursor.com/dashboard/bugbot).
    5. Closing as part of the open-PR backlog sweep (wave 1).

      Reason: Jul conflicted diagnostics-environment picker; stale colonelpanic8 stack.

      Reopen if this is still wanted and you’re willing to rebase onto current main.

    6. juliusmarminge closed this

Sign in to join this conversation.