Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.
fix(web): show provider account accent badge in sidebar rows and hover card (#5980)
Vitaly Iegorova5d35321bd62
diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsxindex a7a5b638c..016a4c682 100644--- a/apps/web/src/components/Sidebar.tsx+++ b/apps/web/src/components/Sidebar.tsx@@ -158,7 +158,11 @@ import {import { ProjectFavicon } from "./ProjectFavicon";import { ProviderInstanceIcon } from "./chat/ProviderInstanceIcon";import { getTriggerDisplayModelLabel } from "./chat/providerIconUtils";-import { deriveProviderInstanceEntries, type ProviderInstanceEntry } from "../providerInstances";+import {+ deriveProviderInstanceEntries,+ shouldShowInstanceBadge,+ type ProviderInstanceEntry,+} from "../providerInstances";import { primaryServerProvidersAtom } from "../state/server";import { useThreadRunningTerminalIds } from "../state/terminalSessions";import { stackedThreadToast, toastManager } from "./ui/toast";@@ -247,7 +251,8 @@ function SidebarThreadTooltip({projectCwd,projectFaviconPath,environmentLabel,- driverKind,+ providerEntry,+ showInstanceBadge,modelInstanceId,modelLabel,branchMismatch,@@ -259,7 +264,8 @@ function SidebarThreadTooltip({projectCwd: string | null;projectFaviconPath: string | null;environmentLabel: string | null;- driverKind: ProviderInstanceEntry["driverKind"] | null;+ providerEntry: ProviderInstanceEntry | null;+ showInstanceBadge: boolean;modelInstanceId: string;modelLabel: string;branchMismatch: {@@ -269,6 +275,7 @@ function SidebarThreadTooltip({terminalStatus: TerminalStatusIndicator | null;terminalProcessCount: number;}) {+ const driverKind = providerEntry?.driverKind ?? null;return (<TooltipPopupside="right"@@ -317,10 +324,21 @@ function SidebarThreadTooltip({<div className="flex min-w-0 items-center gap-2"><ProviderInstanceIcondriverKind={driverKind}- displayName={thread.session?.providerName ?? modelInstanceId}+ displayName={+ providerEntry?.displayName ?? thread.session?.providerName ?? modelInstanceId+ }+ accentColor={providerEntry?.accentColor}+ // Initials would swallow a size-3 glyph: accent dot, name in label.+ showBadge={showInstanceBadge && providerEntry?.accentColor !== undefined}+ badgeContent="none"+ badgeClassName="h-2 min-w-2 px-0"iconClassName="size-3 shrink-0 grayscale opacity-60"/>- <div className="min-w-0 truncate text-foreground/75">{modelLabel}</div>+ <div className="min-w-0 truncate text-foreground/75">+ {showInstanceBadge && providerEntry+ ? `${modelLabel} · ${providerEntry.displayName}`+ : modelLabel}+ </div></div>) : null}{terminalStatus ? (@@ -867,6 +885,9 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: {const modelInstanceId = thread.session?.providerInstanceId ?? thread.modelSelection.instanceId;const providerEntry = props.providerEntryByInstanceId.get(modelInstanceId) ?? null;const driverKind = providerEntry?.driverKind ?? null;+ const showInstanceBadge =+ providerEntry !== null &&+ shouldShowInstanceBadge(providerEntry, props.providerEntryByInstanceId.values());const selectedModel = providerEntry?.models.find((model) => model.slug === thread.modelSelection.model,);@@ -884,7 +905,8 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: {projectCwd={props.projectCwd}projectFaviconPath={props.projectFaviconPath}environmentLabel={props.environmentLabel}- driverKind={driverKind}+ providerEntry={providerEntry}+ showInstanceBadge={showInstanceBadge}modelInstanceId={modelInstanceId}modelLabel={modelLabel}branchMismatch={branchMismatch}@@ -1481,11 +1503,19 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: {</span>) : null}{driverKind ? (- <span className="inline-flex shrink-0 items-center opacity-60">+ <span className="inline-flex shrink-0 items-center"><ProviderInstanceIcondriverKind={driverKind}- displayName={thread.session?.providerName ?? modelInstanceId}- iconClassName="size-3.5"+ displayName={+ providerEntry?.displayName ??+ thread.session?.providerName ??+ modelInstanceId+ }+ accentColor={providerEntry?.accentColor}+ showBadge={showInstanceBadge}+ // Glyph dims, badge stays saturated; offset matches the composer trigger.+ iconClassName="size-3.5 opacity-60"+ badgeClassName="right-[-0.1875rem] bottom-[-0.1875rem] h-3 min-w-3 px-0.5 text-[7px]"/></span>) : null}@@ -1542,7 +1572,9 @@ const SidebarSearchResultRow = memo(function SidebarSearchResultRow(props: {});const modelInstanceId = thread.session?.providerInstanceId ?? thread.modelSelection.instanceId;const providerEntry = props.providerEntryByInstanceId.get(modelInstanceId) ?? null;- const driverKind = providerEntry?.driverKind ?? null;+ const showInstanceBadge =+ providerEntry !== null &&+ shouldShowInstanceBadge(providerEntry, props.providerEntryByInstanceId.values());const selectedModel = providerEntry?.models.find((model) => model.slug === thread.modelSelection.model,);@@ -1600,7 +1632,8 @@ const SidebarSearchResultRow = memo(function SidebarSearchResultRow(props: {projectCwd={props.projectCwd}projectFaviconPath={props.projectFaviconPath}environmentLabel={props.environmentLabel}- driverKind={driverKind}+ providerEntry={providerEntry}+ showInstanceBadge={showInstanceBadge}modelInstanceId={modelInstanceId}modelLabel={modelLabel}branchMismatch={branchMismatch}diff --git a/apps/web/src/components/chat/ModelPickerSidebar.tsx b/apps/web/src/components/chat/ModelPickerSidebar.tsxindex 05b44dcb7..df35cbd90 100644--- a/apps/web/src/components/chat/ModelPickerSidebar.tsx+++ b/apps/web/src/components/chat/ModelPickerSidebar.tsx@@ -1,10 +1,14 @@import { type ProviderInstanceId } from "@t3tools/contracts";-import { memo, useLayoutEffect, useMemo, useRef, useState } from "react";+import { memo, useLayoutEffect, useRef, useState } from "react";import { SparklesIcon, StarIcon } from "lucide-react";import { ProviderInstanceIcon } from "./ProviderInstanceIcon";import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";import { cn } from "~/lib/utils";-import { isProviderInstancePickerReady, type ProviderInstanceEntry } from "../../providerInstances";+import {+ isProviderInstancePickerReady,+ shouldShowInstanceBadge,+ type ProviderInstanceEntry,+} from "../../providerInstances";/*** Build the hover tooltip for an instance button. Mirrors the old@@ -65,14 +69,6 @@ export const ModelPickerSidebar = memo(function ModelPickerSidebar(props: {const [hoveredInstanceId, setHoveredInstanceId] = useState<ProviderInstanceId | null>(null);const sidebarContentRef = useRef<HTMLDivElement>(null);const [selectedIndicatorTop, setSelectedIndicatorTop] = useState<number | null>(null);- const duplicateDriverCounts = useMemo(() => {- const counts = new Map<string, number>();- for (const entry of props.instanceEntries) {- counts.set(entry.driverKind, (counts.get(entry.driverKind) ?? 0) + 1);- }- return counts;- }, [props.instanceEntries]);-useLayoutEffect(() => {const content = sidebarContentRef.current;if (!content) {@@ -143,8 +139,7 @@ export const ModelPickerSidebar = memo(function ModelPickerSidebar(props: {const isSelected = props.selectedInstanceId === entry.instanceId;const isHovered = hoveredInstanceId === entry.instanceId;const showNewBadge = props.newBadgeInstanceIds?.has(entry.instanceId) ?? false;- const showInstanceBadge =- Boolean(entry.accentColor) || (duplicateDriverCounts.get(entry.driverKind) ?? 0) > 1;+ const showInstanceBadge = shouldShowInstanceBadge(entry, props.instanceEntries);const tooltip = isUnavailable? describeUnavailableInstance(entry)diff --git a/apps/web/src/components/chat/ProviderModelPicker.tsx b/apps/web/src/components/chat/ProviderModelPicker.tsxindex a9b3a3981..bd374a0fd 100644--- a/apps/web/src/components/chat/ProviderModelPicker.tsx+++ b/apps/web/src/components/chat/ProviderModelPicker.tsx@@ -16,7 +16,7 @@ import {getTriggerDisplayModelLabel,getTriggerDisplayModelName,} from "./providerIconUtils";-import type { ProviderInstanceEntry } from "../../providerInstances";+import { shouldShowInstanceBadge, type ProviderInstanceEntry } from "../../providerInstances";import { ComposerControl, ComposerControlChevron } from "./ComposerControl";export const ProviderModelPicker = memo(function ProviderModelPicker(props: {@@ -67,10 +67,8 @@ export const ProviderModelPicker = memo(function ProviderModelPicker(props: {selectedInstanceOptions[0];const triggerTitle = selectedModel ? getTriggerDisplayModelName(selectedModel) : props.model;const triggerLabel = selectedModel ? getTriggerDisplayModelLabel(selectedModel) : props.model;- const duplicateDriverCount = props.instanceEntries.filter(- (entry) => activeEntry !== null && entry.driverKind === activeEntry.driverKind,- ).length;- const showInstanceBadge = Boolean(activeEntry?.accentColor) || duplicateDriverCount > 1;+ const showInstanceBadge =+ activeEntry !== null && shouldShowInstanceBadge(activeEntry, props.instanceEntries);const setIsMenuOpen = (open: boolean) => {props.onOpenChange?.(open);diff --git a/apps/web/src/providerInstances.ts b/apps/web/src/providerInstances.tsindex 337e68d44..fd4ca7da9 100644--- a/apps/web/src/providerInstances.ts+++ b/apps/web/src/providerInstances.ts@@ -109,6 +109,23 @@ function driverKindLabel(driverKind: ProviderDriverKind): string {return PROVIDER_DISPLAY_NAMES[driverKind] ?? formatProviderDriverKindLabel(driverKind);}+/**+ * Whether an instance's icon carries the account badge: accent color set, or+ * several instances sharing a driver so the brand glyph alone is ambiguous.+ * Shared by the composer trigger, the picker rail, and sidebar rows.+ */+export function shouldShowInstanceBadge(+ entry: ProviderInstanceEntry,+ entries: Iterable<ProviderInstanceEntry>,+): boolean {+ if (entry.accentColor) return true;+ let sharedDriverCount = 0;+ for (const candidate of entries) {+ if (candidate.driverKind === entry.driverKind && ++sharedDriverCount > 1) return true;+ }+ return false;+}+export function normalizeProviderAccentColor(value: string | undefined): string | undefined {const trimmed = value?.trim();if (!trimmed) return undefined;