fix(mobile): show the provider account badge on thread rows #9899
Mergedvitalyiegorov(GitHub profile, opens in a new tab)merged 1 commit into
main fromrefs/pull/9899/headmerged by juliusmarminge View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- apps/mobile/src/features/threads/thread-provider-instance.ts line 38OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +18,21 @@18+19+/**20+ * Environment-scoped instance map. Default instance ids are literally the21+ * driver slug (`defaultInstanceIdForDriver`), so every environment running22+ * the same driver reports the same id — flattening across environments23+ * would clobber entries and mis-resolve accent colors and badges.24+ */25+export type ThreadProviderInstanceMap = ReadonlyMap<26+ EnvironmentId,27+ ReadonlyMap<string, ThreadRowProviderInstance>28+>;29+30+export function deriveThreadProviderInstances(31+ serverConfigs: ReadonlyMap<EnvironmentId, ServerConfig>,32+): ThreadProviderInstanceMap {33+ const byEnvironment = new Map<EnvironmentId, ReadonlyMap<string, ThreadRowProviderInstance>>();34+ for (const [environmentId, config] of serverConfigs) {35+ const withoutBadge = config.providers.map((provider) => ({36+ driver: provider.driver,37+ displayName:38+ provider.displayName?.trim() || PROVIDER_DISPLAY_NAMES[provider.driver] || provider.driver,
- apps/mobile/src/features/threads/thread-provider-instance.ts line 38OutdatedResolvedby vitalyiegorov(GitHub profile, opens in a new tab)@@ -0,0 +18,21 @@18+19+/**20+ * Environment-scoped instance map. Default instance ids are literally the21+ * driver slug (`defaultInstanceIdForDriver`), so every environment running22+ * the same driver reports the same id — flattening across environments23+ * would clobber entries and mis-resolve accent colors and badges.24+ */25+export type ThreadProviderInstanceMap = ReadonlyMap<26+ EnvironmentId,27+ ReadonlyMap<string, ThreadRowProviderInstance>28+>;29+30+export function deriveThreadProviderInstances(31+ serverConfigs: ReadonlyMap<EnvironmentId, ServerConfig>,32+): ThreadProviderInstanceMap {33+ const byEnvironment = new Map<EnvironmentId, ReadonlyMap<string, ThreadRowProviderInstance>>();34+ for (const [environmentId, config] of serverConfigs) {35+ const withoutBadge = config.providers.map((provider) => ({36+ driver: provider.driver,37+ displayName:38+ provider.displayName?.trim() || PROVIDER_DISPLAY_NAMES[provider.driver] || provider.driver,packages/client-runtime/src/state/providerInstanceBadge.ts lines 21 to 21OutdatedResolvedby vitalyiegorov(GitHub profile, opens in a new tab)@@ -0,0 +1,21 @@1+/**2+ * Provider account badge rule, shared by web and mobile so the two clients3+ * cannot drift on when an instance's icon needs its accent-color initials4+ * badge.5+ *6+ * @module providerInstanceBadge7+ */8+import type { ProviderDriverKind } from "@t3tools/contracts";9+10+/**11+ * Turn a display name into up to two initials for the badge: the first two12+ * characters of a single word, or the first character of each of the first13+ * two words.14+ */15+export function providerInstanceInitials(label: string): string {16+ const words = label.replace(/[_-]+/g, " ").split(/\s+/u).filter(Boolean);17+ if (words.length === 0) return "";18+ if (words.length === 1) return words[0]!.slice(0, 2).toUpperCase();19+ return words20+ .slice(0, 2)21+ .map((word) => word[0]?.toUpperCase() ?? "")
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
juliusmarminge merged this2c8e95a
juliusmarminge closed this
Sign in to join this conversation.


cursor[bot](GitHub profile, opens in a new tab) reviewed
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.