fix(web): resolve sidebar provider icons from the thread's own environment #7292
main fromrefs/pull/7292/head·merged by t3dotgg(GitHub profile, opens in a new tab) View on GitHubWhat 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
deriveProviderEntriesByEnvironmentinproviderInstances.tsbuilds a nested map (environmentId → instanceId → ProviderInstanceEntry) — with a doc note that default instance ids are driver slugs, so lookups must never cross environments. Sidebar.tsxfeeds it fromenvironmentServerConfigsAtom(already read in the component for capability flags — now read once), and the two render sites pass each rowproviderEntriesByEnvironment.get(thread.environmentId)— the same per-thread lookup idiom the file already uses forprojectCwdByKeyandenvironmentLabelById.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
claudewith 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:
- 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.
- Primary set + id collision →
defaultInstanceIdForDrivermakes 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.
| Before | After | |
|---|---|---|
| Sidebar rows | ![]() | ![]() |
| Hover details card (remote thread) | ![]() | ![]() |
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
deriveProviderEntriesByEnvironmentin providerInstances.ts, which builds a nestedReadonlyMapofenvironmentId → 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.
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
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
Approvability#
Verdict: Approved at
3885685Macroscope'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).macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.




Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
add9f7e1-867c-48d4-ae2f-5e234cb40960You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
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