feat(fe): add client resilience, data viewers, quota UI & full bilingual i18n
Pull Request Overview: Client Resilience, Quota Waiver Policy & Bilingual Localization
This pull request introduces connection resilience, client-side data handling utilities, an automatic quota exemption policy for connection/provider failures, and complete English/Vietnamese bilingual localization across the platform.
Frontend Changes (data-crawler-fe)
1. Real-Time SSE Resilience & Connection Recovery
-
Exponential Backoff Algorithm (
use-event-source.ts):- Implemented progressive retry intervals: 1s → 2s → 4s → 8s → 16s → max 30s.
- Added event listeners for
onlineand tabvisibilitychangeto trigger immediate reconnects when connectivity returns.
-
Visual SSE Status Badge (
sse-status-badge.tsx):- Emerald (Live): Real-time active stream with ping animation.
-
Amber (Reconnecting): Spinner with countdown timer (
Reconnecting (2s)...). - Rose (Disconnected): Alert state with an interactive "Retry" button.
2. Network State Detection
-
Offline Banner (
network-status-banner.tsx):- Sticky earth-orange notification informing users when the browser loses Internet connection.
-
React 19 Compliant Hook (
use-network-status.ts):- Complies with React 19 rules (initializes via lazy state function to avoid cascading re-renders).
3. Desktop Web Notifications
-
Web Notification Utility (
web-notifications.ts):- Alerts users upon job completion only when the tab is backgrounded (
document.hidden === true).
- Alerts users upon job completion only when the tab is backgrounded (
-
Interactive Toggle Button (
notification-toggle-button.tsx):- Provides permission requesting, visual state indicators, and feedback toasts.
4. Client Data Handling Utilities
-
JSON Syntax Highlighter (
json-viewer.tsx):- High-performance tokenized syntax coloring, compact/formatted view toggle, search query filter, and line number gutter.
-
Reusable Copy Button (
copy-button.tsx):- Smooth 2-second checkmark transition with optional toast notifications.
-
File Downloader Helper (
download-helper.ts):- Standardized filename generation and automatic
URL.revokeObjectURL()memory cleanup.
- Standardized filename generation and automatic
5. Full Bilingual Localization (English & Vietnamese)
-
Central Dictionary (
translations.ts):- Added 100% matching translation keys across
viandenfor:network,sse,notifications,jsonViewer,copyAction,crawlErrors,quota, andjobDetail. - Aligned semantic labels (
Nguyên nhân:<->Reason:).
- Added 100% matching translation keys across
-
Crawl Error Localization Helper (
crawl-error-helper.ts):- Translates technical raw errors (HTTP 402, Timeouts, Refused, DNS) into user-friendly explanations according to the active locale.
-
UI Deduplication (
crawl-jobs/[id]/page.tsx):- Removed duplicate badges and streamlined root cause presentation to a single, concise informational box.