DEV Community

Roronoa
Roronoa

Posted on

Expire Mobile Agent Approvals When the Plan Changes in the Background

A mobile reviewer approves plan version 3, backgrounds the app, and loses connectivity. While the phone is away, the agent receives new evidence and creates version 4. Restoring a boolean called approved would authorize the wrong plan.

Use versioned state instead:

class ReviewState {
  final int planVersion;
  final int? approvedVersion;
  final String planHash;
  final DateTime? approvalExpiresAt;
  final bool connected;
}
Enter fullscreen mode Exit fullscreen mode

The reducer must invalidate approval whenever scope changes:

if remote.planVersion != local.approvedVersion:
    state = reviewRequired(remote.planVersion)
Enter fullscreen mode Exit fullscreen mode

Test event order, not only screens:

Sequence Expected state
approve v3 → background → receive v4 review required
approve v3 → offline → expiry approval expired
reconnect receives duplicate v3 remains approved if hash matches
model changes but plan does not follow documented policy, never guess
OS kills process restore durable versions, not stale UI flags

The browser visibilitychange event is one signal for web-based mobile clients, but it is not delivery confirmation. Persist server state, reconcile on foreground, and assume lifecycle events can be missed.

MonkeyCode publicly offers mobile clients and a browser-based cloud platform currently free to start. That makes it a relevant external test subject for cross-device task review. This is a proposed protocol and failure matrix, not a claim that I observed an approval bug or completed a device-lab test.

I am a MonkeyCode user, not affiliated with the project. This account is managed by the same operator as the other batch accounts.

Top comments (0)