mirror of
https://github.com/nomadkaraoke/karaoke-gen.git
synced 2026-11-30 09:14:03 +09:00
## Summary Three independent fixes bundled together: 1. **`revoke_session` idempotency** — stops the recurring `Error revoking session` prod error on `karaoke-backend`. Firestore `document.update()` raises `NotFound` (404) when a session doc is already gone (logged out / expired / cleaned up); logout against an already-absent session now succeeds instead of erroring. 2. **`query-error-patterns.py` crash** — `last_seen`/`first_seen` are stored as ISO-8601 strings in Firestore, but the sort key and `--hours` filter did `float(value)`, raising `ValueError` and breaking the `--json` path that `/prod-investigate` relies on. Added a `_to_epoch()` helper handling datetime objects, ISO strings, and numeric epochs. 3. **Mobile header overlap** — `AppHeader` was `position: fixed` and each consumer cleared it with a hardcoded top padding. On narrow viewports the header wraps to 3 rows (149px on a 412px Pixel), exceeding the 112px offset, hiding the "Create Karaoke Video" heading and the top of the form behind it (worse across locales with longer button labels). Switched `AppHeader` to `position: sticky` (matching the already-working jobs-page header) so content always clears it at any height, and removed the now-redundant magic-number offsets. ## Changes - `backend/services/user_service.py` — catch `google_exceptions.NotFound` in `revoke_session`, return `True` - `backend/tests/test_revoke_session.py` — new unit tests (existing / missing / unexpected-error paths) - `scripts/query-error-patterns.py` — `_to_epoch()` helper for sort + `--hours` filter - `frontend/components/app-header.tsx` — `fixed` → `sticky` - `frontend/app/[locale]/app/page.tsx`, `frontend/app/[locale]/app/referrals/page.tsx` — drop hardcoded top padding - `pyproject.toml` — bump to 0.174.17 ## Testing - [x] Backend tests pass locally (47 passed incl. 3 new `revoke_session` tests) - [x] `query-error-patterns.py --json` and `--hours` verified against live Firestore - [x] Mobile header fix verified in Playwright at 412px (Pixel) and 1280px — overlap eliminated (title moves from 12px behind the header to a clear gap below it) - [x] CodeRabbit CLI review: 0 findings ## Review - [x] Local CodeRabbit review completed - [x] Review feedback addressed (none) @coderabbitai ignore --- 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
177 lines
6.3 KiB
TypeScript
177 lines
6.3 KiB
TypeScript
"use client"
|
|
|
|
import { Link } from "@/i18n/routing"
|
|
import { Button } from "./ui/button"
|
|
import {
|
|
DropdownMenu,
|
|
DropdownMenuContent,
|
|
DropdownMenuItem,
|
|
DropdownMenuLabel,
|
|
DropdownMenuSeparator,
|
|
DropdownMenuTrigger,
|
|
} from "./ui/dropdown-menu"
|
|
import { HelpCircle, Mail, Phone, Users, Moon, Sun } from "lucide-react"
|
|
import LanguageSwitcher from "./LanguageSwitcher"
|
|
import { AuthStatus } from "./auth"
|
|
import { TenantLogo } from "./tenant-logo"
|
|
import { useTranslations } from "next-intl"
|
|
import { useTenant } from "@/lib/tenant"
|
|
import { useTheme } from "@/lib/theme"
|
|
import {
|
|
Tooltip,
|
|
TooltipContent,
|
|
TooltipProvider,
|
|
TooltipTrigger,
|
|
} from "./ui/tooltip"
|
|
import { ReactNode, useState, useEffect } from "react"
|
|
|
|
/**
|
|
* Shared app header used across all /app/* pages.
|
|
* Matches the dashboard header style. Pass page-specific
|
|
* buttons via the `children` prop (rendered before the
|
|
* standard right-side controls).
|
|
*
|
|
* Mobile: two rows — row 1 (brand + auth), row 2 (actions with text labels).
|
|
* Desktop (sm+): single row as before.
|
|
*/
|
|
export function AppHeader({ children }: { children?: ReactNode }) {
|
|
const t = useTranslations('dashboard')
|
|
const tHeader = useTranslations('header')
|
|
const { branding, isDefault: isDefaultTenant } = useTenant()
|
|
const { isDarkMode, toggleTheme } = useTheme()
|
|
const [mounted, setMounted] = useState(false)
|
|
|
|
useEffect(() => { setMounted(true) }, [])
|
|
|
|
return (
|
|
<header className="sticky top-0 z-50 bg-dark-900/80 backdrop-blur-md border-b border-dark-700">
|
|
{/* Desktop: single row (sm+) */}
|
|
<div className="hidden sm:flex px-4 py-3 items-center justify-between gap-2">
|
|
<div className="flex items-center gap-3 min-w-0">
|
|
<Link href="/app">
|
|
{isDefaultTenant ? (
|
|
/* eslint-disable-next-line @next/next/no-img-element */
|
|
<img src="/nomad-karaoke-logo.svg" alt="Nomad Karaoke" className="h-10 shrink-0" />
|
|
) : (
|
|
<TenantLogo size="sm" />
|
|
)}
|
|
</Link>
|
|
<div className="min-w-0">
|
|
<Link href="/app" className="text-xl font-bold truncate block" style={{ color: 'var(--text)' }}>
|
|
{isDefaultTenant ? t('title') : branding.site_title}
|
|
</Link>
|
|
</div>
|
|
</div>
|
|
<div className="flex items-center gap-2 shrink-0">
|
|
{children}
|
|
<HelpDropdown tHeader={tHeader} />
|
|
<Link href="/app/referrals" className="flex items-center gap-1.5 text-sm hover:underline min-h-[40px] px-3" style={{ color: 'var(--text-muted)' }}>
|
|
<Users className="w-4 h-4" />
|
|
<span>{t('referrals')}</span>
|
|
</Link>
|
|
<LanguageSwitcher />
|
|
<AuthStatus />
|
|
{mounted && <ThemeToggle isDarkMode={isDarkMode} toggleTheme={toggleTheme} t={t} />}
|
|
</div>
|
|
</div>
|
|
|
|
{/* Mobile: two rows (< sm) */}
|
|
<div className="sm:hidden">
|
|
{/* Row 1: Brand + Auth */}
|
|
<div className="px-3 py-2 flex items-center justify-between gap-2">
|
|
<div className="flex items-center gap-2 min-w-0">
|
|
<Link href="/app">
|
|
{isDefaultTenant ? (
|
|
/* eslint-disable-next-line @next/next/no-img-element */
|
|
<img src="/nomad-karaoke-logo.svg" alt="Nomad Karaoke" className="h-8 shrink-0" />
|
|
) : (
|
|
<TenantLogo size="sm" />
|
|
)}
|
|
</Link>
|
|
<div className="min-w-0">
|
|
<Link href="/app" className="text-base font-bold truncate block" style={{ color: 'var(--text)' }}>
|
|
{isDefaultTenant ? t('title') : branding.site_title}
|
|
</Link>
|
|
</div>
|
|
</div>
|
|
<AuthStatus />
|
|
</div>
|
|
{/* Row 2: Action buttons with text labels */}
|
|
<div className="px-3 pb-2 flex items-center gap-1 flex-wrap">
|
|
{children}
|
|
<HelpDropdown tHeader={tHeader} showLabel />
|
|
<Link href="/app/referrals" className="flex items-center gap-1.5 text-sm hover:underline min-h-[36px] px-2" style={{ color: 'var(--text-muted)' }}>
|
|
<Users className="w-4 h-4" />
|
|
<span>{t('referrals')}</span>
|
|
</Link>
|
|
<LanguageSwitcher showLabel />
|
|
{mounted && <ThemeToggle isDarkMode={isDarkMode} toggleTheme={toggleTheme} t={t} />}
|
|
</div>
|
|
</div>
|
|
</header>
|
|
)
|
|
}
|
|
|
|
function HelpDropdown({ tHeader, showLabel }: { tHeader: ReturnType<typeof useTranslations>; showLabel?: boolean }) {
|
|
return (
|
|
<DropdownMenu>
|
|
<DropdownMenuTrigger asChild>
|
|
<Button
|
|
variant="ghost"
|
|
size="sm"
|
|
className="min-h-[40px] px-2 sm:px-3"
|
|
style={{ color: 'var(--text-muted)' }}
|
|
>
|
|
<HelpCircle className="w-4 h-4" />
|
|
{showLabel && <span className="ms-1.5 text-sm">{tHeader('needHelp')}</span>}
|
|
</Button>
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent align="end" className="w-64">
|
|
<DropdownMenuLabel className="text-sm font-normal">
|
|
{tHeader('helpPrompt')}
|
|
</DropdownMenuLabel>
|
|
<DropdownMenuSeparator />
|
|
<DropdownMenuItem asChild>
|
|
<a href="mailto:andrew@nomadkaraoke.com">
|
|
<Mail className="w-4 h-4 me-2" />
|
|
andrew@nomadkaraoke.com
|
|
</a>
|
|
</DropdownMenuItem>
|
|
<DropdownMenuItem asChild>
|
|
<a href="tel:+18036363267">
|
|
<Phone className="w-4 h-4 me-2" />
|
|
+1 (803) 636-3267
|
|
</a>
|
|
</DropdownMenuItem>
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
)
|
|
}
|
|
|
|
function ThemeToggle({ isDarkMode, toggleTheme, t }: { isDarkMode: boolean; toggleTheme: () => void; t: ReturnType<typeof useTranslations> }) {
|
|
return (
|
|
<TooltipProvider>
|
|
<Tooltip>
|
|
<TooltipTrigger asChild>
|
|
<Button
|
|
variant="ghost"
|
|
size="sm"
|
|
onClick={toggleTheme}
|
|
className="min-h-[40px] px-2 sm:px-3"
|
|
style={{ color: 'var(--text-muted)' }}
|
|
>
|
|
{isDarkMode ? (
|
|
<Sun className="w-4 h-4" />
|
|
) : (
|
|
<Moon className="w-4 h-4" />
|
|
)}
|
|
</Button>
|
|
</TooltipTrigger>
|
|
<TooltipContent side="bottom">
|
|
<p>{isDarkMode ? t('switchToLightMode') : t('switchToDarkMode')}</p>
|
|
</TooltipContent>
|
|
</Tooltip>
|
|
</TooltipProvider>
|
|
)
|
|
}
|