Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): resolve sidebar provider icons from the thread's own environment #7292

Mergedvitalyiegorov(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/7292/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHub

What Changed

Sidebar v2 now resolves each thread's provider identity from that thread's own environment instead of a single flat map built from primaryServerProvidersAtom:

  • New pure helper deriveProviderEntriesByEnvironment in providerInstances.ts builds a nested map (environmentId → instanceId → ProviderInstanceEntry) — with a doc note that default instance ids are driver slugs, so lookups must never cross environments.
  • Sidebar.tsx feeds it from environmentServerConfigsAtom (already read in the component for capability flags — now read once), and the two render sites pass each row providerEntriesByEnvironment.get(thread.environmentId) — the same per-thread lookup idiom the file already uses for projectCwdByKey and environmentLabelById. SidebarThreadRow, SidebarSearchResultRow, and the hover card are unchanged; they keep receiving the same flat per-environment map as before, now scoped correctly. The account-badge heuristic from #5980 therefore counts duplicate accounts within one environment only.
  • Focused unit tests cover the collision case: two environments both carrying instance id claude with different accent colors resolve independently, and an environment with no providers yields no entries rather than falling back across environments.

One deliberate trade: a thread on an environment whose config hasn't streamed yet (still connecting, or offline) now renders no provider icon until the config arrives, instead of borrowing a colliding entry from the primary environment — no icon is honest; the wrong account is not. This also aligns web with mobile, which already resolves the driver per environment and renders nothing when that environment's config is absent (apps/mobile/src/features/home/HomeScreen.tsx, ThreadNavigationSidebar.tsx).

Why

Fixes #5289. The flat primary-only map fails non-primary environments (T3 Connect, hosted app.t3.codes, multi-environment) in two ways:

  1. No primary set → the map is empty → provider icon, account accent badge (#5977/#5980), and the hover card's provider line vanish for every row — the symptom in #5289.
  2. Primary set + id collision → defaultInstanceIdForDriver makes default instance ids literally the driver slug ("claude"), so remote threads resolve the primary environment's entry and render the wrong account's color and name — the sidebar misattributes which account/quota a remote thread burns.

#5300 attempted this with a flat merged map across environments; that shape silently clobbers colliding default ids (last environment wins), which is why this PR scopes the map per environment instead — the same pattern CommandPalette.tsx already ships for its own thread list.

UI Changes

Reproduced with a real two-environment setup: a primary dev environment plus a second headless server paired via Settings → Connections, seeded with the same threads but distinct account accent colors (envB-* accounts in red/amber). Remote rows carry the server glyph.

BeforeAfter
Sidebar rowsRemote rows borrow the primary environment's badges (purple VI, blue W1)Remote rows show their own environment's badges (amber EW, red EV) while primary rows keep VI
Hover details card (remote thread)Hover card claims the primary account work-1@example.com for a remote threadHover card shows the thread's real account envB-work-1@example.com with its own accent

Before: remote rows either render no icon at all (no primary set — the #5289 report) or the wrong account (collision, shown above: purple "VI"/blue "W1" borrowed from the primary). After: each row wears its own environment's identity — same thread titles visible side by side with primary "VI" (purple) vs remote "EV" (red). No motion changes, so no video.

To verify locally: run a dev client, start a second server (node apps/server/src/bin.ts serve --port <p> --base-dir <tmp>) with different provider accent colors in its settings.json, pair it via Settings → Connections → Add environment, and compare the remote rows' badges and hover card before/after this change.

Verified with: new unit tests (vp test run apps/web/src/providerInstances.test.ts, 29 pass), vp fmt --check, vp lint --report-unused-disable-directives on the changed files, vp run --filter @t3tools/web typecheck, and the integrated two-environment pass above. Primary-environment rendering is unchanged (re-captured locally to confirm).

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes (n/a — no motion changes)

Made by Claude Fable 5 in Claude Code.

Note

Fix sidebar provider icons to resolve from each thread's own environment

  • Previously, the sidebar used a single flat provider map shared across all environments, causing icon lookups to potentially resolve from the wrong environment.
  • Adds deriveProviderEntriesByEnvironment in providerInstances.ts, which builds a nested ReadonlyMap of environmentId → instanceId → ProviderInstanceEntry.
  • Sidebar.tsx now passes providerEntriesByEnvironment.get(thread.environmentId) to each thread item, scoping icon lookups to the thread's own environment with a fallback to an empty map.
  • Behavioral Change: provider entries are now strictly scoped per environment — icons will not fall back to entries from other environments.
Macroscope summarized a84833a.

Note

Low Risk Scoped UI lookup change with a pure helper and tests; no auth or server behavior changes, only slightly different icon display while an environment config is still loading.

Overview Fixes multi-environment sidebar provider identity (#5289): thread rows, search results, and hover cards no longer build provider metadata from primaryServerProvidersAtom alone.

Adds deriveProviderEntriesByEnvironment — a nested environmentId → instanceId → ProviderInstanceEntry map — because default instance ids are driver slugs and flattening across environments clobbered entries (wrong accent/name) or left remote rows with no icon when the primary map was empty.

Sidebar.tsx now derives that map from environmentServerConfigsAtom and passes providerEntriesByEnvironment.get(thread.environmentId) (with an empty-map fallback) into each row. Trade-off: until an environment's config streams in, a thread shows no provider icon rather than borrowing a colliding primary entry.

Unit tests cover same-id instances across two environments and no cross-environment fallback.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit a84833affcad9d4908e149d0a05f1cfcdb7092ef. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    2. 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: add9f7e1-867c-48d4-ae2f-5e234cb40960

      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

      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.
    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Approved at 3885685

      Macroscope's review found this PR approvable — This is a straightforward bug fix that corrects provider icon resolution by scoping lookups to each thread's environment instead of using a flat map that could collide across environments. The change is well-documented, includes unit tests, and has a safe fallback.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).

Sign in to join this conversation.