fix(#75): preserve Race Hub meeting/session on Weekend return

Add an explicit Back to Weekend link that deep-links to /?meeting_key&session_key,
restore that focus on the adaptive Weekend home with a Continue analysis CTA, and
regenerate Race Hub visual baselines against the integrated #80 nav.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-12 19:40:04 -04:00
parent 5d5987cc7e
commit 469028b07a
20 changed files with 370 additions and 37 deletions

View File

@@ -1,7 +1,8 @@
import { useEffect, useState } from 'react'
import { useQuery } from '@tanstack/react-query'
import { useNavigate } from '@tanstack/react-router'
import { Link, useNavigate } from '@tanstack/react-router'
import { fetchRaceHub, fetchWeekend, fetchWeekendContext } from '../api'
import { weekendFocusSearch } from '../lib/routeSearch'
import { DatasetStrip } from '../components/DatasetStrip'
import { RaceStoryCanvas } from '../components/RaceStoryCanvas'
import { TabBar, type Tab } from '../components/TabBar'
@@ -123,9 +124,9 @@ export function RaceHubPage({ sessionKey }: Props) {
>
Retry
</button>
<a href="/" className="rh-recover-btn">
Back to Command Center
</a>
<Link to="/" search={{}} className="rh-recover-btn" data-testid="rh-back-weekend">
Back to Weekend
</Link>
</div>
</div>
</div>
@@ -150,9 +151,9 @@ export function RaceHubPage({ sessionKey }: Props) {
>
Browse Weekends
</button>
<a href="/" className="rh-empty-action">
Back to Command Center
</a>
<Link to="/" search={{}} className="rh-empty-action" data-testid="rh-back-weekend">
Back to Weekend
</Link>
</div>
</div>
{switcherOpen && (
@@ -183,14 +184,10 @@ export function RaceHubPage({ sessionKey }: Props) {
)
}
if (raceHubQuery.isError || !data) {
const backMeeting = context?.focus_meeting?.meeting_key
const backSession =
defaultAnalysisSessionKey(context) ??
context?.previous_completed_session?.session.session_key
const backHref =
backSession && backSession > 0
? `/race-hub?session_key=${backSession}`
: '/race-hub'
const backMeeting =
context?.focus_meeting?.meeting_key ??
context?.previous_completed_session?.meeting?.meeting_key
const backSearch = weekendFocusSearch(backMeeting, sessionKey)
return (
<div className="rh-page" data-testid="race-hub-error" style={accentStyle}>
@@ -209,14 +206,16 @@ export function RaceHubPage({ sessionKey }: Props) {
>
Retry
</button>
<a
href={backHref}
<Link
to="/"
search={backSearch}
className="rh-recover-btn"
data-testid="rh-back-weekend"
data-meeting-key={backMeeting ?? undefined}
data-session-key={sessionKey}
>
Back to Weekend
</a>
</Link>
</div>
</div>
</div>
@@ -242,6 +241,16 @@ export function RaceHubPage({ sessionKey }: Props) {
return (
<div className="rh-page" data-testid="race-hub" style={accentStyle}>
<div className="rh-topbar">
<Link
to="/"
search={weekendFocusSearch(meetingKey, sessionKey)}
className="rh-back-weekend"
data-testid="rh-back-weekend"
data-meeting-key={meetingKey ?? undefined}
data-session-key={sessionKey}
>
Back to Weekend
</Link>
<span className="rh-topbar-label mono">
box-box · race hub
{data.meeting?.year ? ` · ${data.meeting.year}` : ''}

View File

@@ -4,6 +4,7 @@ import { BetweenSessionsView } from '../components/weekend/BetweenSessionsView'
import { LiveHandoffView } from '../components/weekend/LiveHandoffView'
import { PreSessionView } from '../components/weekend/PreSessionView'
import { WeekendError, WeekendLimited, WeekendLoading } from '../components/weekend/StatusViews'
import { WeekendFocusBanner } from '../components/weekend/WeekendFocusBanner'
import { resolveViewState } from '../lib/weekendContext'
import type {
WeekendBriefingItem,
@@ -59,8 +60,21 @@ function renderState(view: WeekendViewState, args: RenderArgs) {
}
}
export function WeekendPage({ preview = false }: { preview?: boolean }) {
export function WeekendPage({
preview = false,
focusMeetingKey,
focusSessionKey,
}: {
preview?: boolean
/** Restored from `/?meeting_key=` when returning from Race Hub analysis. */
focusMeetingKey?: number
/** Restored from `/?session_key=` when returning from Race Hub analysis. */
focusSessionKey?: number
}) {
const { context, loadState, error, championship, briefing, now } = useWeekendContext()
const hasFocus =
(focusMeetingKey != null && focusMeetingKey > 0) ||
(focusSessionKey != null && focusSessionKey > 0)
if (loadState === 'loading') {
return (
@@ -87,7 +101,12 @@ export function WeekendPage({ preview = false }: { preview?: boolean }) {
data-state={view}
data-temporal-state={context.temporal_state}
data-preview={preview ? 'true' : undefined}
data-meeting-key={focusMeetingKey ?? undefined}
data-session-key={focusSessionKey ?? undefined}
>
{hasFocus && (
<WeekendFocusBanner meetingKey={focusMeetingKey} sessionKey={focusSessionKey} />
)}
{renderState(view, { context, now, championship, briefing, preview })}
</main>
)