From db38b586d56dc01f97ba3051c8957f02742d74bf Mon Sep 17 00:00:00 2001 From: jtricerolph Date: Thu, 6 Aug 2026 14:11:32 +0000 Subject: [PATCH 1/3] Add update-available banner + versioned /health endpoint Co-Authored-By: Claude Sonnet 5 --- backend/src/index.js | 3 +- frontend/src/App.tsx | 30 +++++++++------- frontend/src/components/UpdateBanner.tsx | 44 ++++++++++++++++++++++++ frontend/src/hooks/useVersionCheck.ts | 43 +++++++++++++++++++++++ 4 files changed, 107 insertions(+), 13 deletions(-) create mode 100644 frontend/src/components/UpdateBanner.tsx create mode 100644 frontend/src/hooks/useVersionCheck.ts diff --git a/backend/src/index.js b/backend/src/index.js index 046877b..f1ec079 100644 --- a/backend/src/index.js +++ b/backend/src/index.js @@ -10,6 +10,7 @@ import { activityRoutes } from './routes/activity.js' import { eventsRoutes } from './routes/events.js' const app = Fastify({ logger: true, trustProxy: true }) +const startedAt = Date.now() await app.register(cookie) await app.register(cors, { @@ -17,7 +18,7 @@ await app.register(cors, { credentials: true, }) -app.get('/health', async () => ({ status: 'healthy' })) +app.get('/health', async () => ({ status: 'healthy', version: process.env.BUILD_VERSION || String(startedAt) })) await app.register(roomRoutes) await app.register(taskRoutes) diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 74d4452..d57055d 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1,22 +1,28 @@ import { BrowserRouter, Routes, Route, Navigate } from 'react-router-dom' import AuthGate from './components/AuthGate' +import { UpdateBanner } from './components/UpdateBanner' +import { useVersionCheck } from './hooks/useVersionCheck' import Layout from './components/Layout' import Planner from './pages/Planner' import Settings from './pages/Settings' export default function App() { + const updateAvailable = useVersionCheck('/room-planner/health') return ( - - - - - } /> - } /> - } /> - } /> - - - - + <> + + + + + } /> + } /> + } /> + } /> + + + + + + ) } diff --git a/frontend/src/components/UpdateBanner.tsx b/frontend/src/components/UpdateBanner.tsx new file mode 100644 index 0000000..b492c67 --- /dev/null +++ b/frontend/src/components/UpdateBanner.tsx @@ -0,0 +1,44 @@ +import { RefreshCw } from 'lucide-react' + +export function UpdateBanner({ visible }: { visible: boolean }) { + if (!visible) return null + return ( +
+ A new version is available. + +
+ ) +} diff --git a/frontend/src/hooks/useVersionCheck.ts b/frontend/src/hooks/useVersionCheck.ts new file mode 100644 index 0000000..e4fed28 --- /dev/null +++ b/frontend/src/hooks/useVersionCheck.ts @@ -0,0 +1,43 @@ +import { useEffect, useState } from 'react' + +const POLL_MS = 2 * 60 * 1000 + +export function useVersionCheck(healthUrl: string) { + const [updateAvailable, setUpdateAvailable] = useState(false) + + useEffect(() => { + let seenVersion: string | null = null + + async function check() { + try { + const res = await fetch(healthUrl, { cache: 'no-store' }) + if (!res.ok) return + const data = await res.json() + const v: string | undefined = data.version + if (!v) return + if (seenVersion === null) { + seenVersion = v + } else if (v !== seenVersion) { + setUpdateAvailable(true) + } + } catch { + // network error — skip silently + } + } + + check() + const interval = setInterval(check, POLL_MS) + + function onVisible() { + if (document.visibilityState === 'visible') check() + } + document.addEventListener('visibilitychange', onVisible) + + return () => { + clearInterval(interval) + document.removeEventListener('visibilitychange', onVisible) + } + }, [healthUrl]) + + return updateAvailable +} From 16c70f5ba423a47c7c10e0a463c6a88a08062083 Mon Sep 17 00:00:00 2001 From: jtricerolph Date: Thu, 6 Aug 2026 14:11:40 +0000 Subject: [PATCH 2/3] Fix past-departure room cards incorrectly merging with prior night MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A past-departure record only marks that a checkout happened on the viewed date — it never occupied the night before, so it must not merge with the previous card the way a booking still actively occupying viewDate would. Co-Authored-By: Claude Sonnet 5 --- backend/src/lib/booking-flow.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/backend/src/lib/booking-flow.js b/backend/src/lib/booking-flow.js index e02dd97..5f3b5b1 100644 --- a/backend/src/lib/booking-flow.js +++ b/backend/src/lib/booking-flow.js @@ -89,6 +89,10 @@ export function classifyRoom(site, allBookings, viewDate, yesterday, tomorrow, o // Determine flow type let flowType = 'vacant' + // True when primaryBooking is a historical depart-only record (set below) rather + // than a booking that actually occupies viewDate — the room was vacant that night. + let isPastDepartureRecord = false + if (primaryBooking) { const status = (primaryBooking.booking_status || '').toLowerCase() if (status === 'blocked') { @@ -113,6 +117,7 @@ export function classifyRoom(site, allBookings, viewDate, yesterday, tomorrow, o } else if (effectiveDeparting && opts.past) { primaryBooking = effectiveDeparting flowType = 'depart' + isPastDepartureRecord = true } const arrivalDate = primaryBooking ? toDateStr(primaryBooking.booking_arrival) : null @@ -158,7 +163,10 @@ export function classifyRoom(site, allBookings, viewDate, yesterday, tomorrow, o flow_type: flowType, booking: primaryBooking, - spans_previous: isVacantFlow + // A past-departure record only marks that a checkout happened on viewDate — it + // never occupied the night before viewDate, so it must not merge with the prior + // card the way a booking that's still actively occupying viewDate would. + spans_previous: (isVacantFlow || isPastDepartureRecord) ? prevVacant : !!primaryBooking && !!arrivalDate && arrivalDate < viewDate, spans_next: isVacantFlow ? nextVacant : spansNext, From 52af5f86bc099280ecfd5aed65e2d53ca2b75487 Mon Sep 17 00:00:00 2001 From: jtricerolph Date: Thu, 6 Aug 2026 14:12:12 +0000 Subject: [PATCH 3/3] Add iOS install hint + Apple PWA meta tags iOS Safari has no beforeinstallprompt API, so the portal's Install button (?install=1) silently did nothing there. IosInstallHint now shows Share -> Add to Home Screen steps on Safari, or a prompt to switch to Safari first if opened in another iOS browser/in-app webview (those can't install PWAs on iOS at all). Also added apple-mobile-web-app-title + apple-touch-icon so the home screen icon isn't a page screenshot. Co-Authored-By: Claude Sonnet 5 --- frontend/index.html | 2 + frontend/src/App.tsx | 2 + frontend/src/components/IosInstallHint.tsx | 89 ++++++++++++++++++++++ 3 files changed, 93 insertions(+) create mode 100644 frontend/src/components/IosInstallHint.tsx diff --git a/frontend/index.html b/frontend/index.html index 79eb4a3..79cc39e 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -6,6 +6,8 @@ + + Room Planner diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index d57055d..8a845de 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1,6 +1,7 @@ import { BrowserRouter, Routes, Route, Navigate } from 'react-router-dom' import AuthGate from './components/AuthGate' import { UpdateBanner } from './components/UpdateBanner' +import IosInstallHint from './components/IosInstallHint' import { useVersionCheck } from './hooks/useVersionCheck' import Layout from './components/Layout' import Planner from './pages/Planner' @@ -23,6 +24,7 @@ export default function App() { + ) } diff --git a/frontend/src/components/IosInstallHint.tsx b/frontend/src/components/IosInstallHint.tsx new file mode 100644 index 0000000..da58dd2 --- /dev/null +++ b/frontend/src/components/IosInstallHint.tsx @@ -0,0 +1,89 @@ +import { useEffect, useState } from 'react' +import { Share, ExternalLink, X } from 'lucide-react' + +function isIos() { + return /iPad|iPhone|iPod/.test(navigator.userAgent) || + // iPadOS 13+ reports as 'MacIntel' but has touch support, unlike a real Mac + (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1) +} + +function isStandalone() { + return window.matchMedia('(display-mode: standalone)').matches || + (window.navigator as unknown as { standalone?: boolean }).standalone === true +} + +// Safari's UA also matches "Safari", so this checks for the other iOS +// browsers/in-app webviews that spoof it — none of them can add to the +// home screen; only Safari itself can. +function isNonSafariIosBrowser() { + return /CriOS|FxiOS|EdgiOS|OPiOS|mercury|GSA|DuckDuckGo|Instagram|FBAN|FBAV|Line\//.test(navigator.userAgent) +} + +/** + * iOS has no `beforeinstallprompt` API — Safari never fires it, so the + * portal's Install button (?install=1) does nothing there. This shows the + * manual steps instead: Share -> Add to Home Screen in Safari, or a prompt + * to switch to Safari first if the page was opened in another browser/app. + */ +export default function IosInstallHint() { + const [mode, setMode] = useState<'safari' | 'other' | null>(null) + + useEffect(() => { + if (!isIos() || isStandalone()) return + if (!new URLSearchParams(window.location.search).has('install')) return + setMode(isNonSafariIosBrowser() ? 'other' : 'safari') + }, []) + + if (!mode) return null + + return ( +
+
+ + +
+ {mode === 'safari' + ? + : } +
+ + {mode === 'safari' ? ( +

+ To install this app, tap the Share icon in Safari's + toolbar, then choose Add to Home Screen. +

+ ) : ( +

+ iOS only allows installing apps from Safari. Open this + page in Safari, then tap Share → Add to Home Screen. +

+ )} +
+
+ ) +}