Repository navigation
feat(app): auto-remove synced local recording copies with a 30-day retention window - #20172
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 35ce41e096
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (wal.status == WalStatus.synced) { | ||
| wal.syncedAt = _now().millisecondsSinceEpoch ~/ 1000; |
There was a problem hiding this comment.
Wait for server acknowledgement before aging streamed WALs
When unlimited local storage is enabled during realtime capture, WalStatus.synced here only means CaptureController called markFrameSynced immediately after _socket.send (capture_controller.dart:380-387); the existing contract at local_wal_sync.dart:971-973 explicitly says these socket writes are transport attempts, not delivery confirmation. Assigning syncedAt therefore allows the default-on retention sweep to delete the only recording copy after 30 days when the server never acknowledged it or produced a transcript. Stamp these WALs only after the transcript/server acknowledgement, or exclude streaming-born WALs from this sweep.
AGENTS.md reference: app/AGENTS.md:L63-L63
Useful? React with 👍 / 👎.
| onChanged: (value) { | ||
| SharedPreferencesUtil().autoRemoveSyncedCopies = value; | ||
| setState(() {}); |
There was a problem hiding this comment.
Apply retention when the toggle is enabled
When a user already has expired synced copies and enables this setting while there are no pending uploads, this callback only saves the preference and never runs the retention sweep. A subsequent manual or background syncAll does not help because _syncAll returns at local_wal_sync.dart:1114-1117 when every WAL is already synced, before the new sweep at lines 1408-1412. The eligible files therefore remain until an app restart or an unrelated new upload; invoke the sweep when enabling the toggle or on the no-work sync path.
Useful? React with 👍 / 👎.
| var removed = 0; | ||
| for (final wal in expired) { | ||
| if (await _deleteWal(wal)) removed++; | ||
| } |
There was a problem hiding this comment.
Require confirmation for irreversible automatic deletion
With this preference enabled—and it defaults on for new installs—the retention sweep reaches this loop and permanently deletes each phone-local recording without a prompt or undo. The mobile UX contract's destructive-action policy explicitly classifies local recording files as irreversible and requires a destructive confirmation every time; automatic retention has no documented exception, and fresh users do not even opt in. Obtain the contract-required confirmation or an approved product-contract exception before deleting these files.
AGENTS.md reference: app/AGENTS.md:L4-L4
Useful? React with 👍 / 👎.
| child: Text( | ||
| context.l10n.localCopiesSection, | ||
| style: TextStyle(color: Colors.grey.shade500, fontSize: 13, fontWeight: FontWeight.w500), | ||
| ), |
There was a problem hiding this comment.
Use the shared settings section primitives
The new Local Copies section hand-builds its header with Colors.grey, a numeric fontSize, and local padding, followed by a card with BorderRadius.circular(20). The mobile UX contract requires settings sections to use OmiSectionHeader and OmiSettingsGroup, and explicitly forbids adding raw color, font-size, or radius values. Replace this local variant with the shared settings primitives and tokens.
AGENTS.md reference: app/AGENTS.md:L4-L4
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
25 issues found across 108 files
Confidence score: 4/5
- Day-count wording is grammatically wrong for some configured values in several locales, including
app_ru.arb,app_localizations_cs.dart, andapp_localizations_uk.dart. Add locale-appropriate plural forms. - The Chinese wording in
app_localizations_zh.dartcould make users think retention starts while syncing is still in progress. Clarify that the countdown starts after sync completes. app_hr.arbdescribes cloud copies as “cloudy copies,” which changes the meaning. Use the locale’s wording for copies stored in the cloud.auto_remove_synced_copies_test.dartdoes not verify that the preference survives a relaunch because it reuses the same cached state. Reload preferences before rerunning the migration.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="app/test/unit/auto_remove_synced_copies_test.dart">
<violation number="1" location="app/test/unit/auto_remove_synced_copies_test.dart:55">
P3: This test never reloads preferences or reinitializes the utility, so it verifies a second call in the same cache, not that the choice survives relaunch. Reload preferences before rerunning migration.</violation>
</file>
<file name="app/lib/l10n/app_localizations_zh.dart">
<violation number="1" location="app/lib/l10n/app_localizations_zh.dart:11928">
P2: This phrasing can read as waiting until syncing has lasted `$days` days, rather than `$days` days after sync completes. Use `同步完成 $days 天后` to make the retention start point clear.</violation>
</file>
<file name="app/lib/l10n/app_localizations_it.dart">
<violation number="1" location="app/lib/l10n/app_localizations_it.dart:12208">
P3: Both strings render `1 giorni` when `days` is 1. Use singular-aware Italian wording in both methods (`1 giorno`).</violation>
</file>
<file name="app/lib/l10n/app_hr.arb">
<violation number="1" location="app/lib/l10n/app_hr.arb:11333">
P3: `Oblačne kopije` reads as “cloudy copies”; this locale uses `u oblaku` for cloud storage. Use `Kopije u oblaku se zadržavaju.`</violation>
</file>
<file name="app/lib/pages/conversations/auto_sync_page.dart">
<violation number="1" location="app/lib/pages/conversations/auto_sync_page.dart:414">
P3: These new toggle rows are not wrapped in a clipped `Material`, so their `InkWell` splash can bleed outside the rounded cards. Wrap each row in `ClipRRect` and `Material` (or use `OmiSettingsGroup`).</violation>
</file>
<file name="app/lib/l10n/app_localizations_sl.dart">
<violation number="1" location="app/lib/l10n/app_localizations_sl.dart:12170">
P3: A one-day retention value produces ungrammatical Slovene (“po 1 dneh”; the description also says “1 dni”). Add a singular form (“po 1 dnevu” / “1 dan”) in the localization template.</violation>
</file>
<file name="app/lib/l10n/app_bs.arb">
<violation number="1" location="app/lib/l10n/app_bs.arb:11333">
P3: The new feature strings mix two orthographic variants of the same word: the title uses "sinhronizirane" while the description uses "sinkronizacije". Pick one variant (sinhron- matches the title and the dominant form in this file) so the setting block reads consistently.</violation>
</file>
<file name="app/lib/l10n/app_ru.arb">
<violation number="1" location="app/lib/l10n/app_ru.arb:3810">
P2: Russian requires three plural forms for days (1 день, 2-4 дня, 5-20/25-30 дней), but these strings hardcode {days} дней. For any configured value ending in 1-4 (e.g. 21, 32, 44 days) the UI renders grammatically wrong text like "через 21 дней". The retention value is read from a configurable preference (autoRemoveSyncedCopiesDays defaults to 30, which happens to be correct), so the defect becomes user-visible as soon as a non-30 window is configured. Use ICU plural syntax — this needs the template app_en.arb to define {days, plural, ...} and all affected locales to mirror it, since gen-l10n validates placeholders against the template.</violation>
</file>
<file name="app/lib/l10n/app_localizations_ro.dart">
<violation number="1" location="app/lib/l10n/app_localizations_ro.dart:12194">
P3: These Romanian strings hardcode the plural form "zile". If `days` is ever 1, the toggle renders "după 1 zile" / "la 1 zile", which is grammatically incorrect in Romanian (singular is "1 zi"). The codebase already handles this correctly elsewhere (e.g. `confidenceNextLabels` uses `intl.pluralLogic`), and the preference `autoRemoveSyncedCopiesDays` is a configurable setting, so the singular case isn't impossible. Since these are generated files, fix the `app_ro.arb` strings with an ICU plural block and re-run `python3 scripts/l10n.py` / gen-l10n rather than editing this file directly.</violation>
</file>
<file name="app/lib/l10n/app_localizations_ta.dart">
<violation number="1" location="app/lib/l10n/app_localizations_ta.dart:12226">
P3: The Tamil description reads literally as “after $days synced days”: 'ஒத்திசைத்த' is a past relative participle (it needs a following noun, e.g. 'synced $days days'), so it does not form the intended “X days after sync”. Use the conjunctive participle 'ஒத்திசைத்து ...' (after having synced ...) so the phrase parses as the retention window.</violation>
</file>
<file name="app/lib/l10n/app_localizations_ca.dart">
<violation number="1" location="app/lib/l10n/app_localizations_ca.dart:12208">
P3: `autoRemoveSyncedCopiesDays` always renders the plural "dies", so a window of 1 day would show "...després de 1 dies" (Catalan requires "1 dia", also for 21/31/...). Wrap the string in `intl.Intl.pluralLogic` like `confidenceNextLabels` in this same file; the fix belongs in the ARB template (`app_en.arb`) plus the translated ARBs, then regenerate.</violation>
</file>
<file name="app/lib/l10n/app_localizations_uk.dart">
<violation number="1" location="app/lib/l10n/app_localizations_uk.dart:12164">
P3: The Ukrainian strings hardcode the plural "днів", which is only correct for counts ending in 0/5–9 or 11–14 (e.g. 30). For days == 1 it must read "день", and for 2–4 (also 22–24...) it must read "дні", so "через 2 днів" / "через 1 днів" would render whenever the value differs. This PR ships a configurable retention window backed by SharedPreferencesUtil.autoRemoveSyncedCopiesDays (default 30, with a setter), so any non-30 value produces grammatically wrong text. The same issue applies to autoRemoveSyncedCopiesDescription. Either pluralize via intl.Intl.pluralLogic (e.g. 'день' one / 'дні' few / 'днів' many), which requires adding a plural placeholder in the template app_en.arb and mirrored ARBs, or keep the window fixed at 30.</violation>
</file>
<file name="app/lib/l10n/app_localizations_de.dart">
<violation number="1" location="app/lib/l10n/app_localizations_de.dart:12236">
P3: The German strings are case/plural-sensitive: `nach $days Tagen` (dative) and `$days Tage` are only grammatical for 2–∞ days. If the retention window is ever 1 (the preference is configurable and the function accepts any int), the UI would render "nach 1 Tagen" / "1 Tage". Note this file is generated from `app_de.arb`; fix the ARB and run gen-l10n, using a plural-style placeholder so 1 day gets "nach 1 Tag".</violation>
</file>
<file name="app/lib/l10n/app_localizations_be.dart">
<violation number="1" location="app/lib/l10n/app_localizations_be.dart:12171">
P3: The string hardcodes the plural 'дзён', which is only correct for 5+ (and 11–14, 25–30…) counts. Since the retention window is configurable, 'праз 21 дзень' and 'праз 22 дні' would be rendered incorrectly. Use ICU pluralization via Intl.pluralLogic (as done for confidenceNextLabels in the same file), with one/few/many forms.</violation>
</file>
<file name="app/lib/l10n/app_localizations_nl.dart">
<violation number="1" location="app/lib/l10n/app_localizations_nl.dart:12178">
P3: These strings render ungrammatical Dutch for the singular: with `days` == 1 they show "na 1 dagen" / "Verwijdert lokale kopieën 1 dagen na synchronisatie" instead of "na 1 dag". Plain-int placeholders (as in app_en.arb) cannot express this, and the retention window is exposed as configurable, so the 30-day default is not the only value that can reach these strings. Add plural placeholders to `autoRemoveSyncedCopiesDays` and `autoRemoveSyncedCopiesDescription` in the template ARB (e.g. `{days, plural, one {...dag} other {..$days dagen}}`) via scripts/l10n.py, then regenerate so the Dutch (and all) translations pluralize correctly.</violation>
</file>
<file name="app/lib/l10n/app_da.arb">
<violation number="1" location="app/lib/l10n/app_da.arb:3817">
P3: Danish renders '{days} dage', but for a value of 1 the correct form is '1 dag'. The {days} placeholder is a general int and autoRemoveSyncedCopiesDays is a configurable preference (currently always 30), so use ICU plural in both keys: '{days, plural, =1{1 dag} other{{days} dage}}'. The same applies to the English template ('1 days'), so apply the change there too via l10n.py to keep all locales in sync.</violation>
</file>
<file name="app/lib/l10n/app_localizations_fr.dart">
<violation number="1" location="app/lib/l10n/app_localizations_fr.dart:12241">
P3: These strings always render 'jours', so a 1-day retention window would display 'après 1 jours' / '1 jours après la synchronisation', which is incorrect French ('1 jour'). The `days` parameter exists precisely because the window is configurable, and this codebase already handles French plurals via `intl.Intl.pluralLogic` (see `confidenceNextLabels` here and the ICU plural in `app_fr.arb`). Make the template ARB use `{days, plural, one{...} other{...}}` so gen-l10n emits plural-aware strings, or guard the singular case.</violation>
</file>
<file name="app/lib/l10n/app_localizations_en.dart">
<violation number="1" location="app/lib/l10n/app_localizations_en.dart:12127">
P3: The `days` placeholder renders without a plural form, so a 1-day retention window shows "Synced copies deleted after 1 days" / "Deletes local copies 1 days after sync". `autoRemoveSyncedCopiesDays` is a configurable preference (setter in app/lib/backend/preferences.dart:907, default 30), so a singular value is reachable. Define ICU plural forms (`{days, plural, one{1 day} other{# days}}`) in app/lib/l10n/app_en.arb and regenerate, following the existing `intl.pluralLogic` convention used by `confidenceNextLabels` and 20+ other strings.</violation>
</file>
<file name="app/lib/l10n/app_sv.arb">
<violation number="1" location="app/lib/l10n/app_sv.arb:3775">
P3: These strings interpolate `{days}` without ICU plural handling, so a retention window of 1 day renders as "1 dagar" (grammatically wrong in Swedish; the template "after {days} days" has the same issue). `autoRemoveSyncedCopiesDays` is read from `SharedPreferencesUtil.autoRemoveSyncedCopiesDays` and can be set to 1, so this is reachable. Use ICU plural syntax (`{days, plural, =1{1 dag} other{{days} dagar}}`) as the rest of this file does for count strings, and mirror the plural form in the `app_en.arb` template.</violation>
</file>
<file name="app/lib/l10n/app_localizations_pl.dart">
<violation number="1" location="app/lib/l10n/app_localizations_pl.dart:12176">
P3: Both interpolated strings render ungrammatical Polish when `days == 1`: 'Zsynchronizowane kopie są usuwane po 1 dniach' and 'Usuwa lokalne kopie 1 dni po synchronizacji' (correct forms: 'po 1 dniu' / '1 dzień po synchronizacji'). The window is fixed at 30 today, but the placeholder-based signature makes the string the future surface for any configurable value, and 30-only correctness depends on a value that is never written. Restructure the template string to a plural message (`{days, plural, ...}`) so gen-l10n emits `intl.Intl.pluralLogic`, or use phrasing that stays correct for all counts.</violation>
</file>
<file name="app/lib/l10n/app_localizations_lv.dart">
<violation number="1" location="app/lib/l10n/app_localizations_lv.dart:12165">
P3: `autoRemoveSyncedCopiesDays(int days)` hardcodes the plural dative 'dienām' ('Sinhronizētās kopijas tiek dzēstas pēc $days dienām'). If `days` is 1 or ends in 1 (21, 31...), the string becomes 'pēc 1 dienām', which is ungrammatical in Latvian ('pēc 1 dienas'); the same problem affects 'Dzēš vietējās kopijas $days dienas pēc sinhronizācijas.'. Since the retention window is a configurable parameter, use gen-l10n ICU plural selection on `days` in the template ARB (`app_en.arb`) so the singular/plural noun form matches the value, instead of a single number-agnostic string.</violation>
</file>
<file name="app/lib/l10n/app_ar.arb">
<violation number="1" location="app/lib/l10n/app_ar.arb:3775">
P3: Arabic inflection of the number is wrong for most configured values. `{days}` is a configurable retention window (default 30; the UI passes the user-selected value into this string), and Arabic inflects the noun by number: 2 takes "يومين", 3–10 take "أيام" (e.g. "بعد 7 أيام"), only 11+ takes "يومًا". Because the template declares `days` as a plain placeholder, the translator cannot use "{days, plural, …}" here — gen-l10n rejects a plural ICU form that the template doesn't use — so the wording is only correct when the window is 11+ days. Recommend switching the template key to a plural ICU form (`{days, plural, =1{…} =2{…} few{…} other{…}}`) and mirroring it in this entry, so values such as 7 days render correctly.</violation>
</file>
<file name="app/lib/l10n/app_localizations_sk.dart">
<violation number="1" location="app/lib/l10n/app_localizations_sk.dart:12132">
P3: The Slovak strings hardcode a single noun form for the day count, but Slovak agrees numerals with the noun (1 → „deň“/„dni“, 2–4 → „dni“, 5+ → „dní“/„dňoch“). `$days dní po synchronizácii` and `po $days dňoch` are wrong for days 1–4 and for numbers ending in 1 (21, 31, …), and this file's established convention is `intl.Intl.pluralLogic` with one/few/many cases for every other count-dependent string. The retention window is configurable (`SharedPreferencesUtil.autoRemoveSyncedCopiesDays` has a setter and the PR describes a configurable policy), so non-30 values are reachable. Apply the same one/few/many/one handling used elsewhere in this file, to both methods.</violation>
</file>
<file name="app/test/unit/local_wal_sync_test.dart">
<violation number="1" location="app/test/unit/local_wal_sync_test.dart:481">
P3: These WALs are created without a `filePath`, so `_deleteWal` (local_wal_sync.dart) skips the `File.delete` branch entirely and returns true after only removing the record from the index lists. The tests therefore assert list mutation, not the file deletion the feature exists for; the failure branch (delete exception → return false, record retained) is never exercised. Give each expired record a real file path (and a non-existent one to cover the failure branch) so the on-disk path is actually verified.</violation>
</file>
<file name="app/lib/l10n/app_localizations_cs.dart">
<violation number="1" location="app/lib/l10n/app_localizations_cs.dart:12137">
P2: Czech requires plural agreement on the interpolated day count, but both strings use a single fixed form. With days=1, `po 1 dnech` (locative plural) should be `po 1 dni`, and with days=1–4 `$days dní` (genitive plural) should be `1 den` / `2–4 dny`. The retention window is a user-configurable preference (default 30), and the codebase already renders count-dependent strings with `intl.Intl.pluralLogic` (see `confidenceNextLabels`), so these forms render incorrectly whenever the value falls outside the ≥5 range. Reword the source strings in `app_cs.arb` (e.g. pluralize via `flushbar`-style pluralLogic, or phrase the sentence so the count is not inflected) and regenerate.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
|
|
||
| @override | ||
| String autoRemoveSyncedCopiesDescription(int days) { | ||
| return '在同步 $days 天后删除本地副本。云端副本会保留。'; |
There was a problem hiding this comment.
P2: This phrasing can read as waiting until syncing has lasted $days days, rather than $days days after sync completes. Use 同步完成 $days 天后 to make the retention start point clear.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/lib/l10n/app_localizations_zh.dart, line 11928:
<comment>This phrasing can read as waiting until syncing has lasted `$days` days, rather than `$days` days after sync completes. Use `同步完成 $days 天后` to make the retention start point clear.</comment>
<file context>
@@ -11914,4 +11914,20 @@ class AppLocalizationsZh extends AppLocalizations {
+
+ @override
+ String autoRemoveSyncedCopiesDescription(int days) {
+ return '在同步 $days 天后删除本地副本。云端副本会保留。';
+ }
+
</file context>
| return '在同步 $days 天后删除本地副本。云端副本会保留。'; | |
| return '同步完成 $days 天后删除本地副本。云端副本会保留。'; |
|
|
||
| @override | ||
| String autoRemoveSyncedCopiesDays(int days) { | ||
| return 'Sinhronizētās kopijas tiek dzēstas pēc $days dienām'; |
There was a problem hiding this comment.
P3: autoRemoveSyncedCopiesDays(int days) hardcodes the plural dative 'dienām' ('Sinhronizētās kopijas tiek dzēstas pēc $days dienām'). If days is 1 or ends in 1 (21, 31...), the string becomes 'pēc 1 dienām', which is ungrammatical in Latvian ('pēc 1 dienas'); the same problem affects 'Dzēš vietējās kopijas $days dienas pēc sinhronizācijas.'. Since the retention window is a configurable parameter, use gen-l10n ICU plural selection on days in the template ARB (app_en.arb) so the singular/plural noun form matches the value, instead of a single number-agnostic string.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/lib/l10n/app_localizations_lv.dart, line 12165:
<comment>`autoRemoveSyncedCopiesDays(int days)` hardcodes the plural dative 'dienām' ('Sinhronizētās kopijas tiek dzēstas pēc $days dienām'). If `days` is 1 or ends in 1 (21, 31...), the string becomes 'pēc 1 dienām', which is ungrammatical in Latvian ('pēc 1 dienas'); the same problem affects 'Dzēš vietējās kopijas $days dienas pēc sinhronizācijas.'. Since the retention window is a configurable parameter, use gen-l10n ICU plural selection on `days` in the template ARB (`app_en.arb`) so the singular/plural noun form matches the value, instead of a single number-agnostic string.</comment>
<file context>
@@ -12156,4 +12156,20 @@ class AppLocalizationsLv extends AppLocalizations {
+
+ @override
+ String autoRemoveSyncedCopiesDays(int days) {
+ return 'Sinhronizētās kopijas tiek dzēstas pēc $days dienām';
+ }
+
</file context>
| "updateRequiredMessage": "لم يعد هذا الإصدار من Omi مدعومًا. حدّث التطبيق لمواصلة التسجيل والمزامنة." | ||
| "updateRequiredMessage": "لم يعد هذا الإصدار من Omi مدعومًا. حدّث التطبيق لمواصلة التسجيل والمزامنة.", | ||
| "autoRemoveSyncedCopiesTitle": "إزالة النسخ المتزامنة تلقائيًا", | ||
| "autoRemoveSyncedCopiesDays": "يتم حذف النسخ المتزامنة بعد {days} يومًا", |
There was a problem hiding this comment.
P3: Arabic inflection of the number is wrong for most configured values. {days} is a configurable retention window (default 30; the UI passes the user-selected value into this string), and Arabic inflects the noun by number: 2 takes "يومين", 3–10 take "أيام" (e.g. "بعد 7 أيام"), only 11+ takes "يومًا". Because the template declares days as a plain placeholder, the translator cannot use "{days, plural, …}" here — gen-l10n rejects a plural ICU form that the template doesn't use — so the wording is only correct when the window is 11+ days. Recommend switching the template key to a plural ICU form ({days, plural, =1{…} =2{…} few{…} other{…}}) and mirroring it in this entry, so values such as 7 days render correctly.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/lib/l10n/app_ar.arb, line 3775:
<comment>Arabic inflection of the number is wrong for most configured values. `{days}` is a configurable retention window (default 30; the UI passes the user-selected value into this string), and Arabic inflects the noun by number: 2 takes "يومين", 3–10 take "أيام" (e.g. "بعد 7 أيام"), only 11+ takes "يومًا". Because the template declares `days` as a plain placeholder, the translator cannot use "{days, plural, …}" here — gen-l10n rejects a plural ICU form that the template doesn't use — so the wording is only correct when the window is 11+ days. Recommend switching the template key to a plural ICU form (`{days, plural, =1{…} =2{…} few{…} other{…}}`) and mirroring it in this entry, so values such as 7 days render correctly.</comment>
<file context>
@@ -3770,5 +3770,9 @@
- "updateRequiredMessage": "لم يعد هذا الإصدار من Omi مدعومًا. حدّث التطبيق لمواصلة التسجيل والمزامنة."
+ "updateRequiredMessage": "لم يعد هذا الإصدار من Omi مدعومًا. حدّث التطبيق لمواصلة التسجيل والمزامنة.",
+ "autoRemoveSyncedCopiesTitle": "إزالة النسخ المتزامنة تلقائيًا",
+ "autoRemoveSyncedCopiesDays": "يتم حذف النسخ المتزامنة بعد {days} يومًا",
+ "autoRemoveSyncedCopiesDescription": "يحذف النسخ المحلية بعد {days} يومًا من المزامنة. تبقى النسخ السحابية محفوظة.",
+ "localCopiesSection": "النسخ المحلية"
</file context>
|
|
||
| @override | ||
| String autoRemoveSyncedCopiesDays(int days) { | ||
| return 'Synchronizované kópie sa odstránia po $days dňoch'; |
There was a problem hiding this comment.
P3: The Slovak strings hardcode a single noun form for the day count, but Slovak agrees numerals with the noun (1 → „deň“/„dni“, 2–4 → „dni“, 5+ → „dní“/„dňoch“). $days dní po synchronizácii and po $days dňoch are wrong for days 1–4 and for numbers ending in 1 (21, 31, …), and this file's established convention is intl.Intl.pluralLogic with one/few/many cases for every other count-dependent string. The retention window is configurable (SharedPreferencesUtil.autoRemoveSyncedCopiesDays has a setter and the PR describes a configurable policy), so non-30 values are reachable. Apply the same one/few/many/one handling used elsewhere in this file, to both methods.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/lib/l10n/app_localizations_sk.dart, line 12132:
<comment>The Slovak strings hardcode a single noun form for the day count, but Slovak agrees numerals with the noun (1 → „deň“/„dni“, 2–4 → „dni“, 5+ → „dní“/„dňoch“). `$days dní po synchronizácii` and `po $days dňoch` are wrong for days 1–4 and for numbers ending in 1 (21, 31, …), and this file's established convention is `intl.Intl.pluralLogic` with one/few/many cases for every other count-dependent string. The retention window is configurable (`SharedPreferencesUtil.autoRemoveSyncedCopiesDays` has a setter and the PR describes a configurable policy), so non-30 values are reachable. Apply the same one/few/many/one handling used elsewhere in this file, to both methods.</comment>
<file context>
@@ -12123,4 +12123,20 @@ class AppLocalizationsSk extends AppLocalizations {
+
+ @override
+ String autoRemoveSyncedCopiesDays(int days) {
+ return 'Synchronizované kópie sa odstránia po $days dňoch';
+ }
+
</file context>
| }); | ||
|
|
||
| group('synced-copy auto-remove (expired synced retention)', () { | ||
| Wal syncedCopy( |
There was a problem hiding this comment.
P3: These WALs are created without a filePath, so _deleteWal (local_wal_sync.dart) skips the File.delete branch entirely and returns true after only removing the record from the index lists. The tests therefore assert list mutation, not the file deletion the feature exists for; the failure branch (delete exception → return false, record retained) is never exercised. Give each expired record a real file path (and a non-existent one to cover the failure branch) so the on-disk path is actually verified.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/test/unit/local_wal_sync_test.dart, line 481:
<comment>These WALs are created without a `filePath`, so `_deleteWal` (local_wal_sync.dart) skips the `File.delete` branch entirely and returns true after only removing the record from the index lists. The tests therefore assert list mutation, not the file deletion the feature exists for; the failure branch (delete exception → return false, record retained) is never exercised. Give each expired record a real file path (and a non-existent one to cover the failure branch) so the on-disk path is actually verified.</comment>
<file context>
@@ -477,6 +477,88 @@ void main() {
});
+ group('synced-copy auto-remove (expired synced retention)', () {
+ Wal syncedCopy(
+ {required int syncedAt, WalStatus status = WalStatus.synced, WalStorage storage = WalStorage.disk}) =>
+ Wal(
</file context>
PR #20172 review (codex + cubic): - Streamed WALs marked synced by socket-send bookkeeping are transport-only, not server-confirmed: they no longer start the retention clock (syncedAt stays 0 until a server-confirmed transition stamps it), so the sweep can never delete the only copy of an unacknowledged recording. A WAL that receives new unacked frames also resets its clock. - The migration commits its marker only after the upgrade-pin write succeeds, so a failed write retries on the next launch. - The sweep runs on the no-pending-work early-return path and when the toggle is enabled, so expired copies age out without waiting for a restart. - Sweep covers all three durable buckets (active, retired, foreign), matching the device-wide scope of the existing retention cap. - Local Copies settings section uses OmiSettingsGroup/OmiSettingsRow instead of hand-rolled header/radius (UX contract). - Tests: streamed-syncedAt==0 contract, sdcard/flashPage exclusion, non-default retention window; test names updated to match asserted behavior.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 291f6d2e3f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| /// local file is only a safety copy. Existing installs are pinned OFF once by | ||
| /// [migrateAutoRemoveSyncedCopiesDefault] so upgrading users keep today's | ||
| /// keep-everything behaviour until they opt in. | ||
| bool get autoRemoveSyncedCopies => getBool('autoRemoveSyncedCopies', defaultValue: true); |
There was a problem hiding this comment.
Preserve the auto-remove opt-out across sign-out
When an upgrading user has been pinned OFF, signing out calls clearPreferencesForSignOut() (app/lib/pages/settings/sign_out.dart:43-65), whose keep-list contains neither this preference nor its migration marker. The getter therefore flips immediately to its ON default; after relaunch the now-missing onboardingCompleted value makes the migration record the install as pre-onboarding, and startup retention includes retired/foreign WALs. Consequently, once any server-confirmed copies are 30 days old, a sign-out and relaunch can permanently delete the previous account's local recordings despite that user never opting in. Preserve both device-wide keys across sign-out or otherwise retain the OFF cohort decision.
Useful? React with 👍 / 👎.
| for (final wal in expired) { | ||
| if (await _deleteWal(wal)) removed++; |
There was a problem hiding this comment.
Delete only the exact expired WAL
If two recordings share a device and second-level timerStart but differ in codec or another filename component, they have distinct files and are treated as distinct by _chunk() (local_wal_sync.dart:554-556), yet both have the same Wal.id because it omits those components (wal.dart:238). Passing one expired synced recording to _deleteWal therefore removes every matching ID from all three inventories (local_wal_sync.dart:785-787), including a still-pending recording, while deleting only the expired recording's file; that pending audio becomes orphaned and can never upload. The automatic sweep should remove the exact WAL (or use a genuinely unique identity), rather than invoking ID-wide deletion.
Useful? React with 👍 / 👎.
…tention window - Wal.syncedAt stamped at every synced transition; 0 = unknown age, never removed. Serialized as synced_at in the WAL index. - LocalWalSyncImpl._removeExpiredSyncedCopies deletes phone-disk synced copies older than the window; hooked at WAL init and after a full upload pass, logged as wal_synced_copy_autoremove. - Preference exposed in the Manage Storage sheet and on the Offline Sync page (one shared Icons.auto_delete row treatment). Existing onboarded installs are pinned OFF once at startup; fresh installs default ON at 30 days. - Manage Storage rows moved onto OmiColors/OmiType/OmiRadius tokens so the sheet renders correctly in light and dark mode.
Review findings (Devin swe-2-high), each verified at file:line before fixing: - Streamed WALs that land already-synced (_chunk new/updated WAL, finalize tail buffer) now stamp syncedAt, so live-streamed recordings are eligible for auto-remove instead of silently never aging out. - Startup default migration writes the preference key BEFORE the marker, so a crash mid-migration retries on the next launch instead of leaving an existing install pinned to the ON default without consent. - The Manage Storage auto-remove row holds its tapped value locally: the sheet is stateless and would otherwise visually snap the switch back while the stored preference had already changed.
…oarding-state Round-2 review finding: onboardingCompleted is set during launch 1 for new users, so a launch-2 migration keyed on it pinned fresh installs to OFF, defeating the default-ON requirement. The split is now decided on the first launch that runs this build: - already onboarded = an upgrading install: pin OFF once (key before marker, so a crash mid-migration retries); - not yet onboarded = a fresh install: mark it immediately so no later launch mistakes it for an upgrade; the ON default governs until the user toggles. Adds a launch-1/launch-2 regression test for the onboard-after-install path.
PR #20172 review (codex + cubic): - Streamed WALs marked synced by socket-send bookkeeping are transport-only, not server-confirmed: they no longer start the retention clock (syncedAt stays 0 until a server-confirmed transition stamps it), so the sweep can never delete the only copy of an unacknowledged recording. A WAL that receives new unacked frames also resets its clock. - The migration commits its marker only after the upgrade-pin write succeeds, so a failed write retries on the next launch. - The sweep runs on the no-pending-work early-return path and when the toggle is enabled, so expired copies age out without waiting for a restart. - Sweep covers all three durable buckets (active, retired, foreign), matching the device-wide scope of the existing retention cap. - Local Copies settings section uses OmiSettingsGroup/OmiSettingsRow instead of hand-rolled header/radius (UX contract). - Tests: streamed-syncedAt==0 contract, sdcard/flashPage exclusion, non-default retention window; test names updated to match asserted behavior.
291f6d2 to
5ebb501
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5ebb501aa3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (!(prefs.getBool('onboardingCompleted') ?? false)) { | ||
| await prefs.setBool(markerKey, true); | ||
| return; |
There was a problem hiding this comment.
Retry a failed fresh-install marker write
When SharedPreferences.setBool returns false for a fresh pre-onboarding install, this branch still returns as though the cohort marker were durable. If the user completes onboarding before the next launch, the missing marker makes that launch enter the existing-install branch and pin auto-remove OFF, reversing the intended default. Check the boolean result and retry or otherwise avoid allowing later onboarding state to reclassify the install.
Useful? React with 👍 / 👎.
| var removed = 0; | ||
| for (final wal in expired) { | ||
| if (await _deleteWal(wal)) removed++; | ||
| } |
There was a problem hiding this comment.
Stop an in-flight sweep after the setting is disabled
When a user enables auto-remove with many expired files and then switches it back off before the asynchronous sweep finishes, this loop continues deleting every WAL captured in expired: the preference is checked only once before the loop, and the toggle remains interactive while deletion runs. The UI can therefore show auto-remove as disabled while additional irreversible deletions continue; re-check the preference or use cancellation/serialization between iterations.
Useful? React with 👍 / 👎.
| final expired = [..._retiredWals, ..._foreignWals, ..._wals] | ||
| .where((wal) => | ||
| wal.storage == WalStorage.disk && | ||
| wal.status == WalStatus.synced && | ||
| wal.syncedAt > 0 && | ||
| wal.syncedAt <= cutoff) |
There was a problem hiding this comment.
Require an actual cloud-audio backup before deletion
When Store Audio on Cloud is disabled, a WAL still reaches WalStatus.synced after transcription completes, but the backend explicitly stores/finalizes conversation audio only when private_cloud_sync_enabled is true (backend/utils/sync/pipeline.py:2342-2347,2647-2650). This filter therefore deletes the only recording bytes after 30 days even though the UI promises that cloud copies are kept; the new preference is also independent of the adjacent cloud-storage toggle. Retention needs durable per-WAL proof that audio was actually persisted to cloud storage, rather than treating processing completion as that proof.
Useful? React with 👍 / 👎.
5ebb501 to
092633c
Compare
origin/main (298baab) does not compile: the detail-v3 merge reintroduced `ChatPage(startFresh: ...)` after #20015's revert removed the parameter, and the frost-previews merge dropped `_buildCardContent` while keeping its call site. Both breaks are on main with no lane changes applied; this restores compilation so the mobile lanes (including this PR's) can run. - conversation_list_item.dart: restore `_buildCardContent` from 3f1ab32 (locked-preview frost wrapper around the mobile card content). - conversation_detail/page.dart: drop the `startFresh` argument — the revert's contract is that every entry point resumes the current conversation, and `initialChatContext` already scopes the chat to this conversation.
092633c to
d7a0377
Compare
What changed
Adds an auto-remove retention policy for synced phone-local recording copies, surfaced in the Manage Storage sheet and on the Offline Sync page.
Wal.syncedAt(serializedsynced_at), stamped at every synced transition — including the_chunk/_flushstreaming paths.0= unknown age — legacy records are never removed.LocalWalSyncImpl._removeExpiredSyncedCopiesdeletes phone-disk synced copies older than the retention window (default 30 days). Hooked at WAL init and after a full upload pass; logged aswal_synced_copy_autoremove.autoRemoveSyncedCopies+autoRemoveSyncedCopiesDays(30). One-time startup migration decides on the FIRST launch that runs this build: installs already onboarded (upgrades) pin OFF once, key written before the marker so a mid-migration crash retries; pre-onboarding installs are marked immediately so onboarding during launch 1 can never re-classify them as upgrades — they keep the ON default.Icons.auto_deleteOmiSettingsRow.togglein both surfaces; the row is identical in both places by design (request: "use the same icon for the toggle for consistency"). The Manage Storage row holds its own toggle state so the switch does not snap back while the sheet is open.OmiColors/OmiType/OmiRadiustokens so the sheet renders correctly in light and dark mode (fixes the dark-charcoal-on-light-mode sheet).Deliberate decisions
Failure class
Failure-Class: new
The new definition
FC-launch-later-cohort-misclassification(.github/failure-classes/FC-launch-later-cohort-misclassification.json): a one-time persisted-default migration re-derived the install cohort fromonboardingCompleted, a flag the same install flips during launch 1, so launch 2 pinned fresh installs to the existing-user OFF default. The earlierfix:commits close review findings on this same unmerged feature branch before first publication.A fourth
fix:commit (5ebb501) is a compile unblock for code inherited from origin/main (298baab), where the conversation-detail-v3 merge reintroducedChatPage(startFresh: …)after #20015's revert removed the parameter and the frost-previews merge dropped_buildCardContentwhile keeping its call site — verified broken on a pristine worktree of that commit with zero of this PR's changes applied. Closest registry class isFC-merged-past-red-analyzer-ratchet(merging past a red mobile check blocks every later PR — exactly the consequence here), declared asnewbecause the registry's definition is scoped to the unused-import ratchet specifically.Product invariants affected
app/lib/main.dartonly gains onestartupStage('autoremove_default', …)registration in the existing startup sequence; no routing, endpoint, Firebase project, or release-ring change. INV-UI-1, INV-UI-3 also apply: both new rows areOmiSettingsRow.togglewith the neutral-accentOmiSwitch; no new raw UI patterns (ratchet run locally, no increase). All copy comes fromapp_en.arbviascripts/l10n.py(49 locales).Evidence
app/test/unit/local_wal_sync_test.dart: sweep removes only expired synced disk WALs; never touches unknown-age (syncedAt == 0), pending, or mem records; no-op when the preference is off.app/test/unit/auto_remove_synced_copies_test.dart: migration pins existing installs OFF, leaves fresh installs on the ON default (including the launch-1-onboard-then-launch-2 path), never overwrites explicit choices, and runs once.flutter analyzeon touched files: only the documented missingfirebase_options_prod.dartenv artifact (generated byflutterfire configure, never committed) and pre-existing infos on untouched lines.python3 .github/scripts/check_mobile_ux_contract.py→OK: INV-UI-3 — no hand-rolled UI increase.flutter test test/unit/local_wal_sync_test.dart test/unit/auto_remove_synced_copies_test.dart test/unit/sdcard_legacy_sync_test.dart→ 58/58 pass.OmiSettingsGroup/OmiSettingsRow.Line-Count-Exception: app/lib/services/wals/local_wal_sync.dart | 1720 -> 1815 | 95-line synced-copy retention sweep + hooks colocated with the existing retention-policy code it mirrors; extracting it would sever access to the private WAL index and delete paths it composes.