X Tutup
Skip to content

[Agent] refactor(recording): @MainActor, Swift 6 async/await, single source of truth#2860

Merged
github-actions[bot] merged 1 commit intodevelopfrom
agent/recording-mainactor
Mar 10, 2026
Merged

[Agent] refactor(recording): @MainActor, Swift 6 async/await, single source of truth#2860
github-actions[bot] merged 1 commit intodevelopfrom
agent/recording-mainactor

Conversation

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented Mar 9, 2026

Summary

Addresses all AI review feedback from #2752 in a single focused refactor:

  • MAJOR: PVRecordingManager annotated @MainActor for Swift 6 compile-time concurrency safety. startRecording() and stopRecording(presenter:) converted to async throws, replacing DispatchQueue.main.async with direct assignment.
  • NIT: RPPreviewViewControllerDelegate extracted to a private PreviewDelegate: NSObject inner class, removing NSObject inheritance from PVRecordingManager itself.
  • MINOR (dual source of truth): RetroMenuView.recordingButton now reads from AppState.shared.emulationUIState.isRecording (the SwiftUI-observable flag) instead of PVRecordingManager.shared.isRecording directly.
  • MINOR (discardRecording): Added discardScreenRecording() to PVEmulatorViewController+Recording — the canonical call site that also updates AppState, keeping all recording state changes consistent.
  • Docs: Added RECORDING.md with architecture notes and rules for future agents/contributors.

Changes

  • PVRecordingManager.swift@MainActor, async throws API, PreviewDelegate inner class
  • PVEmulatorViewController+Recording.swiftTask { @MainActor in try await ... } call sites, new discardScreenRecording()
  • RetroMenuView.swift — read recording state from AppState (single source of truth)
  • RECORDING.md — architecture documentation

Design

AppState.shared.emulationUIState.isRecording is the single SwiftUI-observable source of truth for recording state. PVRecordingManager.isRecording is the manager's internal guard only (prevents double-start/stop). The VC extension is the only layer that updates AppState.

Depends on: #2752
Part of #2714

Generated with Claude Code

@github-actions github-actions bot requested a review from JoeMatt as a code owner March 9, 2026 23:07
@github-actions github-actions bot enabled auto-merge (squash) March 9, 2026 23:07
@github-actions github-actions bot added agent-work PR or issue being worked on by the AI agent ai-reviewing AI code review in progress labels Mar 9, 2026
@github-actions
Copy link
Contributor Author

github-actions bot commented Mar 9, 2026

🤖 PR created. AI review starting automatically.

@github-actions
Copy link
Contributor Author

github-actions bot commented Mar 9, 2026

⚠️ Merge dependency not yet satisfied — this PR has a Depends on: #N link to an open PR. Merge order matters to avoid conflicts. The dependency check is advisory only — merging is still allowed.

@github-actions github-actions bot force-pushed the agent/recording-mainactor branch 2 times, most recently from 5a19e32 to 6d3919f Compare March 10, 2026 00:01
@github-actions
Copy link
Contributor Author

github-actions bot commented Mar 10, 2026

PR 2860 approved - ready for human review. JoeMatt assigned.

Copy link
Contributor Author

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

AI Code Review Cycle 1/3 - Reviewer: claude-opus-4-6 - APPROVE - Well-structured refactor. No CRITICAL or MAJOR issues. MINOR: PreviewDelegate nested class at PVRecordingManager.swift:115 should be annotated @mainactor for Swift 6 strict concurrency (it calls dismiss which is MainActor-isolated). NIT: Task { @mainactor in } wrappers in PVEmulatorViewController+Recording.swift:31,47 are redundant since UIViewController is already MainActor.

@github-actions
Copy link
Contributor Author

No description provided.

@github-actions github-actions bot disabled auto-merge March 10, 2026 00:10
@github-actions github-actions bot enabled auto-merge (squash) March 10, 2026 00:10
@github-actions github-actions bot added ready-for-review AI approved; awaiting human review and removed ai-reviewing AI code review in progress labels Mar 10, 2026
@github-actions github-actions bot force-pushed the agent/recording-mainactor branch from 6d3919f to efbf5cd Compare March 10, 2026 00:19
@github-actions github-actions bot added the ai-reviewing AI code review in progress label Mar 10, 2026
@github-actions
Copy link
Contributor Author

github-actions bot commented Mar 10, 2026

✅ Ready for Human Review

Completed

  • 🚀 Agent started
  • 🤖 AI review approved
  • 🔀 Auto-merge enabled (squash)
  • 👤 @JoeMatt assigned for final review
  • 🏷️ Label set: ready-for-review

Completed: 2026-03-10 02:07 UTC

Copy link
Contributor Author

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

AI Code Review - Cycle 1/3

Reviewer: claude-opus-4-6
Clean refactor that adds @mainactor isolation to PVRecordingManager, converts the completion-handler API to async throws, extracts RPPreviewViewControllerDelegate into a private PreviewDelegate inner class, and establishes AppState.shared.emulationUIState.isRecording as the single source of truth for SwiftUI. The changes are well-scoped and introduce no new safety issues. CRITICAL - none. MAJOR - none. MINOR - In stopRecording(presenter:), if the RPScreenRecorder.stopRecording callback returns an error, PVRecordingManager.isRecording remains true (old code always reset to false). This is arguably better behavior (allows retry) and the VC layer correctly resets AppState.isRecording on both paths. NIT - none. Verdict: APPROVE

@github-actions
Copy link
Contributor Author

No description provided.

@github-actions github-actions bot force-pushed the agent/recording-mainactor branch from efbf5cd to 6612ed0 Compare March 10, 2026 00:27
@github-actions github-actions bot added ai-reviewing AI code review in progress and removed ai-reviewing AI code review in progress labels Mar 10, 2026
@github-actions github-actions bot force-pushed the agent/recording-mainactor branch from 6612ed0 to b7a1c4a Compare March 10, 2026 00:33
Copy link
Contributor Author

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

AI Code Review Cycle 1/3 - Reviewer: claude-opus-4-6. Clean refactoring: @mainactor isolation on PVRecordingManager, async throws API, extracted PreviewDelegate, single source of truth via AppState. No CRITICAL or MAJOR issues. MINOR: discardScreenRecording sets AppState synchronously while RPScreenRecorder cleanup is async (not harmful, worth a comment). NIT: RECORDING.md could live in docs/. Verdict: APPROVE

@github-actions
Copy link
Contributor Author

No description provided.

@github-actions github-actions bot removed the ai-reviewing AI code review in progress label Mar 10, 2026
@github-actions github-actions bot force-pushed the agent/recording-mainactor branch from b7a1c4a to f5ea97d Compare March 10, 2026 01:51
@github-actions github-actions bot added the ai-reviewing AI code review in progress label Mar 10, 2026
- Annotate PVRecordingManager with @mainactor for Swift 6 compile-time safety
- Convert startRecording/stopRecording to async throws, removing DispatchQueue.main.async
- Extract RPPreviewViewControllerDelegate to private PreviewDelegate (removes NSObject inheritance)
- Update PVEmulatorViewController+Recording to use Task { @mainactor in try await ... }
- Add discardScreenRecording() to VC extension so AppState stays consistent on discard
- Fix RetroMenuView.recordingButton to read from AppState (single source of truth)
- Add RECORDING.md with architecture notes and rules for future agents

Addresses AI review feedback on #2752 (MAJOR/MINOR/NIT items)
Part of #2714

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions github-actions bot force-pushed the agent/recording-mainactor branch from f5ea97d to d3bfae5 Compare March 10, 2026 02:00
Copy link
Contributor Author

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

⚠️ Max review cycles (3) reached. Escalating to human review. See previous reviews for outstanding issues.

@github-actions github-actions bot disabled auto-merge March 10, 2026 02:06
@github-actions github-actions bot enabled auto-merge (squash) March 10, 2026 02:07
@github-actions github-actions bot removed the ai-reviewing AI code review in progress label Mar 10, 2026
@github-actions github-actions bot merged commit d0ae0f8 into develop Mar 10, 2026
10 of 11 checks passed
@github-actions github-actions bot deleted the agent/recording-mainactor branch March 10, 2026 02:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-work PR or issue being worked on by the AI agent ready-for-review AI approved; awaiting human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

X Tutup