Repository navigation
[codex] Improve Rewind OCR quality - #8134
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 79af7afa75
ℹ️ 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".
| while true { | ||
| // Stop backfill if we went back to battery | ||
| if shouldPauseOCRForBattery() { | ||
| log("RewindIndexer: Backfill paused — back on battery after \(totalProcessed) screenshots") | ||
| return | ||
| } | ||
|
|
||
| let pending = try await RewindDatabase.shared.getBatterySkippedScreenshots(limit: batchSize) | ||
| if pending.isEmpty { break } | ||
|
|
||
| for screenshot in pending { |
There was a problem hiding this comment.
Keep legacy OCR backfill paused on battery
For users with existing skippedForBattery rows, plugging in starts this backfill from PowerMonitor.onACReconnected, but the loop now keeps fetching and OCRing batches without rechecking the current power source. If they unplug while a large legacy backlog is running, accurate OCR continues on battery until the queue is exhausted, undoing the battery-saving behavior; keep the old power check before each batch/item.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
2 issues found and verified against the latest diff
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
There was a problem hiding this comment.
1 issue found across 4 files (changes from recent commits).
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="desktop/macos/Desktop/Sources/Rewind/Services/PowerMonitor.swift">
<violation number="1" location="desktop/macos/Desktop/Sources/Rewind/Services/PowerMonitor.swift:10">
P2: `cachedIsOnBattery` is exposed as `nonisolated(unsafe)` mutable shared state and is read/written across executors without synchronization, creating a data race risk.</violation>
</file>
Tip: Review your code locally with the cubic CLI to iterate faster.
Fix all with cubic | Re-trigger cubic
| class PowerMonitor: ObservableObject { | ||
| static let shared = PowerMonitor() | ||
|
|
||
| nonisolated(unsafe) private static var cachedIsOnBattery = false |
There was a problem hiding this comment.
P2: cachedIsOnBattery is exposed as nonisolated(unsafe) mutable shared state and is read/written across executors without synchronization, creating a data race risk.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At desktop/macos/Desktop/Sources/Rewind/Services/PowerMonitor.swift, line 10:
<comment>`cachedIsOnBattery` is exposed as `nonisolated(unsafe)` mutable shared state and is read/written across executors without synchronization, creating a data race risk.</comment>
<file context>
@@ -7,6 +7,8 @@ import IOKit.ps
class PowerMonitor: ObservableObject {
static let shared = PowerMonitor()
+ nonisolated(unsafe) private static var cachedIsOnBattery = false
+
@Published private(set) var isOnBattery: Bool = false
</file context>
Summary
Fixes #8130.
skippedForBatterybackfill behavior for existing local rows.Review
Validation
xcrun swift test --package-path Desktop --filter RewindOCRQualityTestsResult: 3 tests passed.