Skip to content

fix(app): correct offline sync processing counter and percent display - #13688

Merged
kodjima33 merged 3 commits into
BasedHardware:mainfrom
apoorvdarshan:cursor/fix-offline-processing-display-86c6
Sep 14, 2026
Merged

kodjima33 merged 3 commits into
BasedHardware:mainfrom
apoorvdarshan:cursor/fix-offline-processing-display-86c6

Conversation

@apoorvdarshan

@apoorvdarshan apoorvdarshan commented Sep 13, 2026 •

Copy link
Copy Markdown
Collaborator

What changed and why

Fixes #4772.

Before: upload progress could show remaining-based percentages (100% at start) and counters like -75/1 when multi-recording totals were clobbered by per-chunk 1/1 device reports.

After:

  • Shared display helpers compute completed processed/total and 0–100% completion (not remaining).
  • Sync status cards show X of Y · Z% during upload/download and post-upload server processing.
  • Upload progress reports after each batch; ring download byte ticks no longer overwrite multi-file totals.
  • Legacy negative “remaining” offset handled when total > 1.

Product invariants affected

none

How it was verified

  • Diff vs upstream main: 8 files, +250 / −39.
  • Added app/test/unit/offline_processing_display_test.dart.
  • Flutter tests were not run on the Cloud Agent VM (no Flutter SDK). Locally: cd app && flutter test test/unit/offline_processing_display_test.dart

Failure class (fixes)

Failure-Class: none

Review in cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 8 files

Confidence score: 4/5

  • In app/lib/pages/conversations/sync_page.dart, the device-download progress treats StorageSync’s 1-based active-file index as a completed count, so the first file is shown as completed (1 of Y · 1%) prematurely; convert the index before passing it to SyncCa....
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="app/lib/pages/conversations/sync_page.dart">

<violation number="1" location="app/lib/pages/conversations/sync_page.dart:621">
P2: During device download, the first file now displays as completed (`1 of Y · 1%`) because `StorageSync` supplies a 1-based active-file index. Convert the download index to a completed count before passing it to `SyncCardProgressLine`; keep upload's already-completed count unchanged.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

return parts.isEmpty ? null : parts.join(' · ');
return SyncCardProgressLine.subtitle(
phase: s.phase,
currentFile: s.currentFile,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: During device download, the first file now displays as completed (1 of Y · 1%) because StorageSync supplies a 1-based active-file index. Convert the download index to a completed count before passing it to SyncCardProgressLine; keep upload's already-completed count unchanged.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At app/lib/pages/conversations/sync_page.dart, line 621:

<comment>During device download, the first file now displays as completed (`1 of Y · 1%`) because `StorageSync` supplies a 1-based active-file index. Convert the download index to a completed count before passing it to `SyncCardProgressLine`; keep upload's already-completed count unchanged.</comment>

<file context>
@@ -610,12 +616,13 @@ class _SyncPageState extends State<SyncPage> {
-    return parts.isEmpty ? null : parts.join(' · ');
+    return SyncCardProgressLine.subtitle(
+      phase: s.phase,
+      currentFile: s.currentFile,
+      totalFiles: s.totalFiles,
+      counterLabel: (processed, total) => context.l10n.syncCardProgressOf(processed, total),
</file context>
Suggested change
currentFile: s.currentFile,
currentFile: s.phase == SyncPhase.downloadingFromDevice && s.currentFile != null && s.currentFile! > 0 ? s.currentFile! - 1 : s.currentFile,

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Valid. SyncCardProgressLine.subtitle now decrements the active file index during downloadingFromDevice (StorageSync is 1-based) while leaving upload currentFile (completed count) unchanged—first file shows 0/Y · 0%.

Comment thread app/lib/providers/sync_provider.dart Resolved
Comment thread app/lib/providers/sync_provider.dart Resolved
@Git-on-my-level

Copy link
Copy Markdown
Member

Verified against #4772 — this fixes both reported symptoms (percent reading as remaining, -75/1-style counters). Read through the full diff; the approach and scoping look right.

What checks out

  • offline_processing_display.dart (new): normalizeCounts clamps to [0, total] and recovers the legacy negative remaining offset (-75/100 → 25 done) exactly as the issue describes; completionPercent/completionFraction are completed-based, and serverJobCounts scopes the meter to the tracked upload batch so still-missing recordings never count as processed.
  • sync_card_progress_line.dart (new): converting the 1-based device-download index to a completed count (current -= 1) matches how ring_storage_sync reports; upload keeps the completed-count semantics, and the X of Y · Z% line matches the issue's expected output (25/100 · 25%).
  • sync_provider.dart: seeding _uploadedWalIdsAtSyncStart per _performSync pass and diffing after (_recordNewlyAcceptedUploads) is a clean way to scope the batch across partial drains; draining _trackedServerJobWalIds on WalStatus.synced keeps it bounded; the onWalSyncedProgress guard preserving multi-file totals from per-chunk 1/1 device reports addresses the clobbering directly.
  • local_wal_sync.dart: recomputing done from WAL statuses inside reportUploadProgress() (called before upload and after each batch) removes the stale filesUploaded counter — good simplification.
  • ring_storage_sync.dart: dropping currentFile: 1, totalFiles: 1 from byte-tick progress is the minimal correct fix so device download no longer overwrites multi-recording totals.
  • auto_sync_page.dart / sync_page.dart: both cards keep the localized background hint as fallback when the meter can't be computed — reasonable.
  • Tests: the new unit test asserts the exact cases from the issue, including the batch-scoping scenarios (partial drain, later sync). The deletion_consistency_test.dart and chat_content_blocks_test.dart edits are mechanical test-double signature updates matching main's ActionItems API (dueStartDate/dueEndDate) — no assertions changed.

All three concerns from the earlier bot review (mixed-drain miscounting, cross-sync scope mixing, first-file-shows-completed) are addressed on the current head, and CI is green including Dart Analyze & Tests.

One note (non-blocking): _trackedServerJobWalIds is in-memory, so after an app restart with WALs still awaiting server processing, the meter falls back to 0/N — accurate, but it loses continuity from the pre-restart session. If that matters for long processing queues, a persisted scope could be a follow-up.

Thanks for the clean fix and the responsive follow-up commits. Leaving the final merge call to the maintainers.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level Git-on-my-level added positive-signal Automation verified a genuine fix/quality contribution flutter flutter work labels Sep 13, 2026
@apoorvdarshan

Copy link
Copy Markdown
Collaborator Author

@Git-on-my-level Thanks for the thorough pass — glad the #4772 symptoms and the earlier bot concerns check out on the current head. Noted the non-blocking follow-up about persisting _trackedServerJobWalIds across app restarts for long processing queues; leaving that out of this PR.

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Real fix for offline sync progress display (fixes #4772), reasonable diff with tests. Not merging: mergeStateStatus is DIRTY (merge conflicts) — per policy we don't rebase/force-push PR branches. Leaving approved; needs the author (or Nik) to rebase.

cursoragent and others added 3 commits September 13, 2026 22:06
Fixes BasedHardware#4772.

Before: upload progress could show remaining-based percentages (100% at
start) and counters like -75/1 when multi-recording totals were clobbered
by per-chunk 1/1 device reports.

After: shared display helpers compute completed processed/total and 0–100%
completion; sync status cards show counter + percent during upload/download
and during post-upload server processing; upload progress reports after each
batch; ring download ticks no longer overwrite multi-file totals.

Verification: added app/test/unit/offline_processing_display_test.dart
(flutter test not run on this VM — no Flutter SDK installed).

Co-authored-by: Apoorv Darshan <[email protected]>
- Track WAL ids accepted (202) per sync pass; derive processed/total from
  that scope instead of _totalWalsToProcess vs global uploadedWals.
- Reinit single-WAL sync totals; preserve multi-file counts on 1/1 download ticks.
- Convert 1-based device download index to completed count in progress line.

Verification: Flutter unavailable on Cloud VM; run locally:
  cd app && flutter test test/unit/offline_processing_display_test.dart

Co-authored-by: Apoorv Darshan <[email protected]>
- dart format sync_provider.dart and offline_processing_display.dart
- import BleAudioCodec in offline_processing_display_test.dart
- align ActionItemsFetcher test stubs with dueStartDate/dueEndDate (BasedHardware#13570)
- drop dead filesUploaded counter after reportUploadProgress refactor

Verified: dart format --set-exit-if-changed on touched files; bash app/scripts/analyze_ratchet.sh; flutter test offline_processing_display_test.dart deletion_consistency_test.dart chat_content_blocks_test.dart

Co-authored-by: Apoorv Darshan <[email protected]>
@cursor
cursor Bot force-pushed the cursor/fix-offline-processing-display-86c6 branch from 1cf0dc3 to b066cd4 Compare September 13, 2026 22:07
@apoorvdarshan

Copy link
Copy Markdown
Collaborator Author

@kodjima33 Rebased cursor/fix-offline-processing-display-86c6 onto latest main (force-pushed). Resolved one formatting conflict in app/test/providers/deletion_consistency_test.dart during rebase — should be mergeable now.

@Git-on-my-level

Copy link
Copy Markdown
Member

Follow-up after the rebase onto b066cd4c: I diffed all eight changed files between the previously approved commit (1cf0dc3) and the new head, and every one is byte-identical (sync_provider.dart, local_wal_sync.dart, auto_sync_page.dart, sync_page.dart, ring_storage_sync.dart, both new helpers, and the unit test). The force-push only picked up latest main plus the formatting-conflict resolution in deletion_consistency_test.dart, so the earlier verification pass and @kodjima33's approval still describe exactly the code on this head — the approval shows as dismissed purely because the branch moved, not because anything was re-litigated.

Checks are green on the new head (Dart Analyze & Tests, Android Compile Smoke, Formatting, Hygiene). Also confirmed the new progress lines only render existing localized strings (syncCardProgressOf, processingProgress, syncProcessingBackgroundHint), so no translation churn came in with this change.

Two residual notes stay non-blocking as discussed: _trackedServerJobWalIds in sync_provider.dart is session-scoped, so an app restart mid-processing falls back to the pending-only branch of serverJobCounts (background hint rather than wrong numbers), and retained-WAL trimming can drift processed upward over a long window. Both are reasonable to leave until they surface in practice.

Thanks @apoorvdarshan — this closes out #4772 cleanly.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

app bug fix, fixes #4772: offline sync progress showed remaining-based/negative percentages. Confidence 4/5 (root cause explained, linked issue, tests added, CI green; diff slightly over the 300-line soft cap at 369 total but otherwise solid) — merging.

@kodjima33
kodjima33 merged commit c82eff8 into BasedHardware:main Sep 14, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flutter flutter work positive-signal Automation verified a genuine fix/quality contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Offline Processing Display Counter errors

4 participants