diff --git a/client/src/components/Chat/Messages/Content/__tests__/WebSearch.test.tsx b/client/src/components/Chat/Messages/Content/__tests__/WebSearch.test.tsx index fb777ea849..1ebc4cc1ff 100644 --- a/client/src/components/Chat/Messages/Content/__tests__/WebSearch.test.tsx +++ b/client/src/components/Chat/Messages/Content/__tests__/WebSearch.test.tsx @@ -410,6 +410,11 @@ describe('WebSearch', () => { expect(screen.getByText('4.7')).toBeInTheDocument(); expect(screen.getByText('Blue Bottle Coffee')).toBeInTheDocument(); + const placeLink = screen.getByText('Blue Bottle Coffee').closest('a'); + expect(placeLink?.getAttribute('href')).toContain('google.com/maps'); + expect(placeLink?.getAttribute('href')).toContain( + encodeURIComponent('Blue Bottle Coffee, 300 S Broadway'), + ); expect(screen.getByText('Coffee shop \u00b7 300 S Broadway')).toBeInTheDocument(); expect(screen.getByText('4.6')).toBeInTheDocument(); expect(screen.getByText('(812)')).toBeInTheDocument(); diff --git a/client/src/components/Chat/Messages/Content/verticals.tsx b/client/src/components/Chat/Messages/Content/verticals.tsx index e3b841179e..4d04f4d067 100644 --- a/client/src/components/Chat/Messages/Content/verticals.tsx +++ b/client/src/components/Chat/Messages/Content/verticals.tsx @@ -6,12 +6,33 @@ import type { PlaceResult, ShoppingResult, } from 'librechat-data-provider'; +import { isMacPlatform } from '~/utils/shortcuts'; import { useLocalize } from '~/hooks'; import { cn } from '~/utils'; const MAX_VERTICAL_ITEMS = 8; const MAX_PLACES = 5; +/** Platform-native map link: Apple devices open Apple Maps, everything else + * Google Maps. Both are keyless https links that fall back to a web map when + * the native app is unavailable, so a misdetected platform still works. */ +export function mapLink(place: PlaceResult): string { + const query = [place.name, place.address].filter(Boolean).join(', '); + const coords = + place.latitude != null && place.longitude != null ? `${place.latitude},${place.longitude}` : ''; + if (isMacPlatform) { + const params = new URLSearchParams(); + if (query) { + params.set('q', query); + } + if (coords) { + params.set('ll', coords); + } + return `https://maps.apple.com/?${params.toString()}`; + } + return `https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(query || coords)}`; +} + export interface SearchVerticalData { images: ImageResult[]; shopping: ShoppingResult[]; @@ -135,25 +156,29 @@ function PlaceList({ places, label }: { places: PlaceResult[]; label: string }) {places.slice(0, MAX_PLACES).map((place, i) => (
  • 0 && 'border-t border-border-light', - )} + className={cn(i > 0 && 'border-t border-border-light')} > -
  • ))}