fix(crawl-jobs): harmonize progress percentage, unlock export, and streamline crawled pages table
Summary of Changes
1. Harmonized Progress Percentage (Fix 99% Cap)
-
Problem: When a job was in
RUNNINGstatus, the progress formula artificially clamped progress to99%viaMath.min(isJobRunning ? 99 : 100, ...), displaying52 / 52 pages (99%). -
Solution:
- Standardized progress calculation across
recent-jobs-widget.tsx,crawler-task-table.tsx, and/crawl-jobs/[id]/page.tsx:const progressPercent = job?.status === "COMPLETED" || (targetPages > 0 && processedPages >= targetPages) ? 100 : targetPages > 0 ? Math.min(99, Math.round((processedPages / targetPages) * 100)) : 0; - When all target pages are processed (
processedPages >= targetPages), progress displays as100%.
- Standardized progress calculation across
2. Export Button Unlock
-
Problem: The "Export Data" button was disabled whenever
isJobRunningwas true, locking users out even when data was ready. -
Solution:
- Updated disabled condition to
disabled={(isJobRunning && processedPages < targetPages) || (job?.successPages || 0) === 0}, allowing users to export data immediately once target pages are finished.
- Updated disabled condition to
3. Crawled Pages Table UX Enhancement (/crawl-jobs/[id])
- Problem: Clicking through each page required targeting a small action button in the last column.
-
Solution:
- Completely removed the "Actions" / "Thao tác" column from the Crawled Pages table.
- Made each table row (
<tr>) directly clickable to open the page preview modal (markdown,cleanText,html,json). - Added row hover styles and
e.stopPropagation()on the source URL link so opening the URL in a new tab does not inadvertently trigger the preview modal.
4. Realtime Quota Cache Synchronization
- Added
USAGE_QUERY_KEYS.usageinvalidation on job creation, rerun, cancel, and deletion. - Harmonized profile query keys (
["auth", "me", "usage"]) for unified cache invalidation.