🤖 Fix: Show a popup to alert users when they are offline or have a poor network connection (Resolves #120)#121
Conversation
🤖 Codex-Style Code Review by OpenCode
PR Review: Network Status Alert BannerSummaryA well-executed feature adding an offline/poor-network banner to the app. The composable pattern is consistent with the existing codebase, i18n is properly integrated, and the component follows PR Size: Medium (~160 lines) 🎉 Strengths
🔴 Blocking IssuesNone identified. 🟡 Important Issues1. Prop type mismatch:
defineProps<{
isOnline: boolean | null
isPoorConnection: boolean
}>()
const isOnline = ref(typeof navigator !== 'undefined' ? navigator.onLine : true) // Ref<boolean>The composable always produces a Suggestion: Either:
2. Edge case:
const isOnline = ref(typeof navigator !== 'undefined' ? navigator.onLine : true)If Suggestion: const isOnline = ref(typeof navigator !== 'undefined' && navigator.onLine !== undefined ? navigator.onLine : true)3.
.network-banner__text {
font-weight: 600;
white-space: nowrap;
}On narrow viewports (e.g., 320px width), long translations like "Your network connection is unstable" with Suggestion: Either remove 🟢 Minor Nits1. Redundant
role="alert"
aria-live="assertive"The 2. Vue If the page loads while offline, the banner mounts as visible — the enter transition only plays when the element is inserted into the DOM via Not actionable unless this is considered undesirable UX. 3. No test coverage No tests are included for
🔒 Security Considerations
Verdict✅ Approve — This is a clean, well-structured feature that follows the project's conventions. The three 🟡 items above are suggestions worth addressing but not blocking. |
AI: Resolves #120
This Pull Request was automatically generated by OpenCode to address Issue #120.
📝 AI Modification Summary & Conclusion:
Implementation Summary: Offline / Poor Network Alert Popup
Objective
Show a popup banner to alert users when they are offline or have a poor network connection, inform them that the application is reading data from cache, and support i18n for all messages.
Files Modified
1.
src/i18n/en.ts,src/i18n/zh.ts,src/i18n/de.ts,src/i18n/fr.ts,src/i18n/ja.tsnetworktranslation section in each language file with three keys:offline— "You are currently offline" (translated per locale)poorConnection— "Your network connection is unstable" (translated per locale)usingCache— "Reading data from cache" (translated per locale)2.
src/services/useNetworkStatus.ts(new file)navigator.onLine+ browseronline/offlineevents for binary connectivitynavigator.connection) for connection quality (effectiveTypeandsaveData)isOnline—true/falsereflecting browser online statusisPoorConnection—truewheneffectiveTypeis'slow-2g'or'2g', orsaveDatais enabledonMounted/onUnmounted3.
src/components/utils/NetworkStatusBanner.vue(new file)<Transition>for smooth slide-in/out animation--offline(red background, white text) when the user is completely disconnected--poor(yellow background, dark text) when the connection is slow/unstablenetwork.offlineornetwork.poorConnection), and a secondary cache notice (network.usingCache)useI18n()for translated messagesrole="alert"andaria-live="assertive"4.
src/App.vue<NetworkStatusBanner>before<CookieNotice>at the top of the appuseNetworkStatuscomposable and passed its reactive state (isOnline,isPoorConnection) as props to the bannerTechnical Decisions
navigator.onLine,Network Information API) and Vue built-insnetworktranslation section and accessed viauseI18n()t()function — consistent with the existing i18n architectureCookieNotice.vuecomponent structure (reactive visibility, scoped CSS, flex layout) for consistency