Skip to content

fix(app): avoid synced UI when WALs remain pending (#7240) - #11085

Merged
kodjima33 merged 1 commit into
BasedHardware:mainfrom
aryanorastar:fix/7240-synced-status-pending
Aug 4, 2026
Merged

kodjima33 merged 1 commit into
BasedHardware:mainfrom
aryanorastar:fix/7240-synced-status-pending

Conversation

@aryanorastar

@aryanorastar aryanorastar commented Aug 4, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes #7240 where the app can mark recordings/conversations as synced even though some associated WALs are still left in an uploaded/pending state.

What changed

  • SyncProvider now refreshes WAL state before updating syncState.completed.syncedConversations.
  • It filters the “synced conversations” pointers down to only those conversations whose associated WALs are fully WalStatus.synced.

Regression test

  • flutter test test/providers/sync_provider_fully_synced_conversations_test.dart

Product invariants affected

none

Failure class (fixes)

Failure-Class: none

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@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.

5 issues found across 3 files

Confidence score: 1/5

  • In .github/workflows/solve_issue.yml, untrusted repository_dispatch fields are interpolated into Bash, which can allow arbitrary command execution and full workflow-token abuse if a payload is crafted — treat inputs as untrusted, validate/whitelist them, and pass values safely (no direct shell interpolation).
  • In .github/workflows/solve_issue.yml, successful runs can open PRs with only ai_fix.txt because the real fixer step is commented out, so automation may create misleading “fix” PRs and churn reviewer time — re-enable the agent step and add a guard that fails when no substantive code change is produced.
  • In app/lib/providers/sync_provider.dart, the sync check can return true when WAL indexing is actually missing if conversationId is null, so users may see conversations as synced when they are not — ensure downloaded WALs get a conversationId or make the null-path fail the synced check until indexing is confirmed.
  • In .github/workflows/solve_issue.yml, repeated dispatches for the same issue can race on branch/PR creation and runs are non-reproducible due to unpinned aider-chat, which can cause flaky or conflicting automation outcomes — add issue-keyed workflow concurrency and pin the agent version.
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=".github/workflows/solve_issue.yml">

<violation number="1" location=".github/workflows/solve_issue.yml:30">
P2: Agent setup is non-reproducible because `pip install aider-chat` pulls whatever version is latest at runtime. Pin an explicit version (or lockfile/hash) so runs stay stable and auditable.</violation>

<violation number="2" location=".github/workflows/solve_issue.yml:40">
P1: Successful runs currently open pull requests containing only the placeholder `ai_fix.txt`, not an AI-generated issue fix: the only agent operation is an `echo` and the aider command remains commented out. The workflow should either invoke and validate the configured agent before committing, or avoid creating a success PR until a real change has been produced.</violation>

<violation number="3" location=".github/workflows/solve_issue.yml:44">
P0: A crafted `repository_dispatch` payload can execute arbitrary shell commands because `issue_number` and `chat_id` are interpolated directly into Bash source. This is especially dangerous here because the workflow has repository/PR write permissions and exposes `ANTHROPIC_API_KEY`; passing payload values through step `env` variables and using quoted parameter expansions (with numeric validation for `issue_number`) would prevent payload text from becoming shell syntax.</violation>

<violation number="4" location=".github/workflows/solve_issue.yml:50">
P2: Multiple `solve_issue` dispatches for the same issue can collide on branch push and PR creation because this workflow has no concurrency guard. A workflow-level concurrency group keyed by issue number would serialize runs and avoid race-driven failures.</violation>
</file>

<file name="app/lib/providers/sync_provider.dart">

<violation number="1" location="app/lib/providers/sync_provider.dart:709">
P1: A conversation can still be shown as synced when its WAL is not indexed because `conversationId` is null. Device-download WALs are created without that field, so `walsForConversation` is empty and the `return true` branch bypasses their `uploaded`/pending status. The filter needs a reliable WAL-to-conversation mapping (or must conservatively handle unlinked WALs) before treating the lookup as proof that no local WALs exist.</violation>
</file>

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

Re-trigger cubic

Comment thread .github/workflows/solve_issue.yml Outdated

git config --global user.name "AI Agent"
git config --global user.email "[email protected]"
git checkout -b fix-issue-${{ github.event.client_payload.issue_number }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P0: A crafted repository_dispatch payload can execute arbitrary shell commands because issue_number and chat_id are interpolated directly into Bash source. This is especially dangerous here because the workflow has repository/PR write permissions and exposes ANTHROPIC_API_KEY; passing payload values through step env variables and using quoted parameter expansions (with numeric validation for issue_number) would prevent payload text from becoming shell syntax.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At .github/workflows/solve_issue.yml, line 44:

<comment>A crafted `repository_dispatch` payload can execute arbitrary shell commands because `issue_number` and `chat_id` are interpolated directly into Bash source. This is especially dangerous here because the workflow has repository/PR write permissions and exposes `ANTHROPIC_API_KEY`; passing payload values through step `env` variables and using quoted parameter expansions (with numeric validation for `issue_number`) would prevent payload text from becoming shell syntax.</comment>

<file context>
@@ -0,0 +1,71 @@
+          
+          git config --global user.name "AI Agent"
+          git config --global user.email "[email protected]"
+          git checkout -b fix-issue-${{ github.event.client_payload.issue_number }}
+          
+          # Dummy change
</file context>

Comment thread .github/workflows/solve_issue.yml Outdated
run: |
# Dummy script for demonstration purposes. In reality, you'd run aider here:
# aider --message "Fix issue #${{ github.event.client_payload.issue_number }}"
echo "AI Agent is solving issue #${{ github.event.client_payload.issue_number }}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1: Successful runs currently open pull requests containing only the placeholder ai_fix.txt, not an AI-generated issue fix: the only agent operation is an echo and the aider command remains commented out. The workflow should either invoke and validate the configured agent before committing, or avoid creating a success PR until a real change has been produced.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At .github/workflows/solve_issue.yml, line 40:

<comment>Successful runs currently open pull requests containing only the placeholder `ai_fix.txt`, not an AI-generated issue fix: the only agent operation is an `echo` and the aider command remains commented out. The workflow should either invoke and validate the configured agent before committing, or avoid creating a success PR until a real change has been produced.</comment>

<file context>
@@ -0,0 +1,71 @@
+        run: |
+          # Dummy script for demonstration purposes. In reality, you'd run aider here:
+          # aider --message "Fix issue #${{ github.event.client_payload.issue_number }}"
+          echo "AI Agent is solving issue #${{ github.event.client_payload.issue_number }}"
+          
+          git config --global user.name "AI Agent"
</file context>


bool isFullySynced(SyncedConversationPointer pointer) {
final walsForConversation = byConversationId[pointer.conversation.id] ?? const <Wal>[];
if (walsForConversation.isEmpty) return true; // No local WALs → nothing pending.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1: A conversation can still be shown as synced when its WAL is not indexed because conversationId is null. Device-download WALs are created without that field, so walsForConversation is empty and the return true branch bypasses their uploaded/pending status. The filter needs a reliable WAL-to-conversation mapping (or must conservatively handle unlinked WALs) before treating the lookup as proof that no local WALs exist.

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

<comment>A conversation can still be shown as synced when its WAL is not indexed because `conversationId` is null. Device-download WALs are created without that field, so `walsForConversation` is empty and the `return true` branch bypasses their `uploaded`/pending status. The filter needs a reliable WAL-to-conversation mapping (or must conservatively handle unlinked WALs) before treating the lookup as proof that no local WALs exist.</comment>

<file context>
@@ -676,9 +680,37 @@ class SyncProvider extends ChangeNotifier implements IWalServiceListener, IWalSy
+
+    bool isFullySynced(SyncedConversationPointer pointer) {
+      final walsForConversation = byConversationId[pointer.conversation.id] ?? const <Wal>[];
+      if (walsForConversation.isEmpty) return true; // No local WALs → nothing pending.
+      return walsForConversation.every((w) => w.status == WalStatus.synced);
+    }
</file context>

Comment thread .github/workflows/solve_issue.yml Outdated

- name: Install AI Agent (Sweep / Aider)
run: |
pip install aider-chat

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: Agent setup is non-reproducible because pip install aider-chat pulls whatever version is latest at runtime. Pin an explicit version (or lockfile/hash) so runs stay stable and auditable.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At .github/workflows/solve_issue.yml, line 30:

<comment>Agent setup is non-reproducible because `pip install aider-chat` pulls whatever version is latest at runtime. Pin an explicit version (or lockfile/hash) so runs stay stable and auditable.</comment>

<file context>
@@ -0,0 +1,71 @@
+
+      - name: Install AI Agent (Sweep / Aider)
+        run: |
+          pip install aider-chat
+          # If using Aider, you can configure it here.
+          # For a real implementation, you'd pass the Anthropic/OpenAI keys as secrets.
</file context>

Comment thread .github/workflows/solve_issue.yml Outdated
echo "Fix for issue #${{ github.event.client_payload.issue_number }}" >> ai_fix.txt
git add ai_fix.txt
git commit -m "fix: resolve issue #${{ github.event.client_payload.issue_number }}"
git push origin fix-issue-${{ github.event.client_payload.issue_number }}

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: Multiple solve_issue dispatches for the same issue can collide on branch push and PR creation because this workflow has no concurrency guard. A workflow-level concurrency group keyed by issue number would serialize runs and avoid race-driven failures.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At .github/workflows/solve_issue.yml, line 50:

<comment>Multiple `solve_issue` dispatches for the same issue can collide on branch push and PR creation because this workflow has no concurrency guard. A workflow-level concurrency group keyed by issue number would serialize runs and avoid race-driven failures.</comment>

<file context>
@@ -0,0 +1,71 @@
+          echo "Fix for issue #${{ github.event.client_payload.issue_number }}" >> ai_fix.txt
+          git add ai_fix.txt
+          git commit -m "fix: resolve issue #${{ github.event.client_payload.issue_number }}"
+          git push origin fix-issue-${{ github.event.client_payload.issue_number }}
+
+      - name: Create Pull Request
</file context>

@aryanorastar
aryanorastar force-pushed the fix/7240-synced-status-pending branch from 080cbdc to dffe61e Compare August 4, 2026 09:51
@Git-on-my-level

Copy link
Copy Markdown
Member

Thanks @aryanorastar — this is a clean, well-scoped fix for #7240. Filtering synced-conversation pointers to only those whose WALs are fully WalStatus.synced, and refreshing WALs before updating the synced UI, directly addresses the reported mismatch (synced badge while recordings are still uploaded/pending). The regression test covers both the pending-WAL and no-local-WAL cases, and CI (Dart Analyze & Tests, Android Compile Smoke) is green on the current head.

One edge worth a look before merge: filterFullySyncedConversations treats a conversation as fully synced when it has no conversationId-linked WALs (return true on empty). In the normal flow WALs are stamped with a conversationId via stampConversationId() before upload, so this is rarely hit — but if any un-stamped WAL ever reaches uploaded/pending (e.g. legacy persisted WALs), it would not be counted against its conversation and the conversation could still surface as synced. Consider either conservatively withholding when unlinked uploaded/pending WALs exist, or documenting the invariant that uploaded WALs always carry a conversationId. Flagging for maintainer review on that point; otherwise this looks good to merge.


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 needs-maintainer-review Needs a human maintainer to sign off before merge flutter flutter work labels Aug 4, 2026

@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.

Conversations were marked synced while their WALs were still pending; SyncProvider now refreshes WAL state and only counts fully-synced conversations. Regression test included. 5/5 - merging.

@kodjima33
kodjima33 merged commit 0e4cfb3 into BasedHardware:main Aug 4, 2026
40 of 42 checks passed
mdmohsin7 added a commit that referenced this pull request Aug 5, 2026
#11134)

## Summary

Reverts #11084 (`75e4e1789d`), which added
`CaptureController.onRecordingDeviceDisconnected()` and the
`DeviceProvider` hook that starts a **phone-mic batch recording whenever
the wearable disconnects mid-session**.

## Why

**This behaviour was already reviewed and rejected.** #11066 proposed
the same phone-side fallback and received `CHANGES_REQUESTED` from the
app maintainer:

> The tagged issue actually means recording on the device offline when
not connected to bluetooth. Right now it does record offline but it
breaks sometimes. This PR is not the right fix for this

#11066 was closed, and #11078 was opened specifically so a phone-side
fallback could be scoped on its own merits. **#11078 is still open and
unapproved.**

**The PR description did not match its diff.** #11084 is titled
"preserve on-device offline batch across BLE disconnect" and its body
states it "prevents the phone-mic fallback from triggering". Before
#11084 there was no such fallback to prevent:
`onRecordingDeviceDisconnected` did not exist and nothing called it, and
`_startPhoneMicBatch` was reachable only from user-initiated paths. The
PR introduced the feature together with a guard for it; the
Implementation section listed neither the new method nor the
`device_provider.dart` call site.

**The guard does not cover Omi hardware.** It reads:

```dart
final bool isOnDeviceOfflineBatchActive = SharedPreferencesUtil().batchModeEnabled &&
    _recordingDevice != null &&
    (_recordingDevice!.type == DeviceType.limitless || _offlineSessionStartSeconds != 0);
```

It consults `batchModeEnabled`, but ring-buffer capture is keyed on
firmware (`WalSyncs.isRingBufferFirmware`, 3.0.20+) and is independent
of that pref. With batch mode off, an Omi on 3.0.20+ keeps writing to
its on-device ring while the phone starts its own mic batch — the same
interval is captured twice and syncs as duplicate conversations, plus an
unrequested mic activation and the battery cost.

#11084 did address the technical review notes from #11066
(`deviceRecord` state, awaited stop hand-off,
`deviceSupportsTranscribeLater`). The product objection was not
addressed.

## Scope

Revert only. #11064 and #11085 from the same batch are left in place —
#11064 is a genuine sort fix, and #11085 needs a real fix rather than a
revert (its `filterFullySyncedConversations` never releases a WAL
retired to `WalStatus.outsideRecoveryWindow` by #10995, so those
conversations stay filtered out of the synced list; tracked separately).

#7194 remains open on its actual subject: on-device offline recording
that works but is flaky across disconnects.

## Verification

```
flutter analyze lib/services/capture/capture_controller.dart lib/utils/batch_recording.dart \
  lib/providers/device_provider.dart test/unit/batch_recording_phone_test.dart
  -> 1 info (unnecessary_import at device_provider.dart:4), confirmed pre-existing on main; 0 new

flutter test test/unit/batch_recording_phone_test.dart test/providers/capture_provider_test.dart \
  test/providers/sync_provider_fully_synced_conversations_test.dart \
  test/unit/synced_conversation_pointer_order_test.dart
  -> 89 tests, all passed

grep shouldFallbackToPhoneOnDeviceDisconnect | onRecordingDeviceDisconnected |
     isRecordingDuringDeviceDisconnect | _phoneMicBatchStopCompleter
  -> no matches remain under app/

make preflight -> 11 checks passed
```

Clean revert: no later commit touched `capture_controller.dart`,
`batch_recording.dart`, `device_provider.dart`, or
`batch_recording_phone_test.dart` between #11084 and `84e4c1828b`.

## Product invariants affected

none

## Failure class (fixes)

No `fix:` commits; no declaration required.


<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/11134?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flutter flutter work needs-maintainer-review Needs a human maintainer to sign off before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Offline recordings: synced status OK but not synced some are pending

3 participants