Skip to content

Add sleep auto handoff to cloud#11049

Merged
dplakon merged 6 commits into
masterfrom
dplakon/sleep-auto-handoff
May 19, 2026
Merged

Add sleep auto handoff to cloud#11049
dplakon merged 6 commits into
masterfrom
dplakon/sleep-auto-handoff

Conversation

@dplakon
Copy link
Copy Markdown
Contributor

@dplakon dplakon commented May 15, 2026

Description

Adds a macOS-only Auto handoff on sleep setting under Warp Agent → Cloud Handoff.

When enabled, Warp listens for macOS sleep events and attempts to hand off the last-focused eligible local Warp Agent session to Cloud Mode using the existing local-to-cloud handoff flow. This also adds a warplocal://action/auto_handoff_to_cloud trigger for testing and hook-driven invocation; the trigger now respects the same Auto handoff on sleep opt-in setting.

The setting defaults to off so existing users do not silently enable automatic cloud handoff or workspace snapshot upload.

davinci_the_scene_starts_with_a_slightly_ajar_laptop__the_.mp4
Screenshot 2026-05-15 at 5 06 56 PM

Linked Issue

No linked issue.

  • The linked issue is labeled ready-to-spec or ready-to-implement.
  • Where appropriate, screenshots or a short video of the implementation are included below (especially for user-visible or UI changes).

Testing

  • cargo fmt

  • cargo clippy --workspace --all-targets --all-features --tests -- -D warnings

  • cargo nextest run -p warp auto_handoff --no-fail-fast — 13 passed

  • cargo nextest run -p warp last_focused_terminal_tracks_most_recent_globally conversation_switch_updates_last_focused_terminal_state --no-fail-fast — 2 passed

  • git --no-pager diff --check origin/master...HEAD

  • Manual smoke test with ./script/run --open_with_launchd and warplocal://action/auto_handoff_to_cloud in the original implementation checkout

  • I have manually tested my changes locally with ./script/run

Screenshots / Videos

Not included in this update. The PR now notes the setting is opt-in and the URI trigger respects that opt-in; please attach UI media from a local app session if required for review.

Agent Mode

  • Warp Agent Mode - This PR was created via Warp's AI Agent Mode

CHANGELOG-OZ: Added a macOS setting to automatically hand off active local Warp Agent sessions to Cloud Mode before sleep.

Co-Authored-By: Oz oz-agent@warp.dev

@cla-bot cla-bot Bot added the cla-signed label May 15, 2026
@dplakon dplakon requested a review from harryalbert May 15, 2026 20:45
@harryalbert harryalbert marked this pull request as ready for review May 15, 2026 20:48
@oz-for-oss
Copy link
Copy Markdown
Contributor

oz-for-oss Bot commented May 15, 2026

@harryalbert

I'm starting a first review of this pull request.

You can view the conversation on Warp.

I completed the review and no human review was requested for this pull request.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Copy link
Copy Markdown
Contributor

@oz-for-oss oz-for-oss Bot left a comment

Choose a reason for hiding this comment

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

Overview

This PR adds a macOS sleep-triggered automatic local-to-cloud handoff path, a settings toggle, and a warplocal://action/auto_handoff_to_cloud trigger. The core flow is integrated with the existing handoff implementation, but there are blocking correctness and privacy issues before merge.

Concerns

  • The user-facing settings change has no screenshot or recording attached, which is required for visual/UI changes.
  • The new last-focused conversation accessor can return stale data when the focused pane changes conversations without a focus change, which can cause auto handoff to validate/mark one conversation while handing off another.

Security

  • The new setting defaults automatic cloud handoff on for existing eligible users, which can fork local conversations and upload workspace snapshots on sleep without an explicit opt-in to this new automatic behavior.
  • The URI trigger bypasses the new auto-handoff opt-out, allowing warplocal://action/auto_handoff_to_cloud to initiate the same cloud handoff even after the user disables the sleep setting.

Verdict

Found: 0 critical, 4 important, 0 suggestions

Request changes

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Comment thread app/src/settings_view/ai_page.rs Outdated
Comment thread app/src/ai/active_agent_views_model.rs
Comment thread app/src/settings/ai.rs Outdated
Comment thread app/src/workspace/auto_handoff.rs Outdated
@dplakon dplakon force-pushed the dplakon/sleep-auto-handoff branch 2 times, most recently from f0a1e51 to 88ecf8a Compare May 15, 2026 21:41
Copy link
Copy Markdown
Contributor

@harryalbert harryalbert left a comment

Choose a reason for hiding this comment

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

Very cool change. Just had a few thoughts/comments.

Also, just to double-check, this doesn't auto-cancel cloud conversations if they're focused, right (from the code it looks like it doesn't but just wanted to make sure)?

ctx: &mut ModelContext<Self>,
) {
match event {
SystemStatsEvent::CpuWillSleep => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm a little concerned about using this event as the trigger for handoff, just because handoff involves some async processes that could take a while and might not reliably trigger before the computer shuts down.

I'm not sure if there's a great way to fix this reliably, but I'm curious if you ran into it when testing this feature w/ longer conversations that might have taken longer to hand off

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it's a good call out. I'm hoping some of the work on improving speed for handoff would be a potential fix here. I will do some research on a better solution, but it does have a 30s buffer.

Comment thread app/src/workspace/auto_handoff.rs Outdated
Comment thread app/src/workspace/view.rs
Comment thread app/src/workspace/view.rs
Comment thread app/src/settings/ai.rs
Comment thread app/src/settings_view/ai_page.rs Outdated
@dplakon dplakon force-pushed the dplakon/sleep-auto-handoff branch from 88ecf8a to 7a348fe Compare May 18, 2026 16:11
dplakon and others added 2 commits May 18, 2026 16:52
Co-Authored-By: Oz <oz-agent@warp.dev>
Co-Authored-By: Oz <oz-agent@warp.dev>
Copy link
Copy Markdown
Contributor

@harryalbert harryalbert left a comment

Choose a reason for hiding this comment

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

Approving to unblock, but had a few more comments that would be good to address before merging

Comment thread app/src/workspace/auto_handoff.rs
Comment thread app/src/workspace/auto_handoff.rs Outdated
Comment thread app/src/workspace/auto_handoff.rs Outdated
Comment thread app/src/workspace/view.rs Outdated
@dplakon dplakon force-pushed the dplakon/sleep-auto-handoff branch from 7a348fe to 932ba2e Compare May 18, 2026 22:05
Copy link
Copy Markdown
Contributor

@dplakon had the agent take a look, and it had one other comment that I also think is worth addressing:

app/src/workspace/auto_handoff.rs:198-207 and app/src/workspace/view.rs:13677-13685 — automatic handoff starts while AutoCloudHandoffController is already inside an update(...), but several early failure paths call record_automatic_handoff_failed(), which immediately does another AutoCloudHandoffController::handle(ctx).update(...). WarpUI treats same-model reentry as a circular update, so a race like “focused conversation changed/disappeared between selection and handoff start” can panic the client instead of cleanly bailing out.

dplakon and others added 4 commits May 18, 2026 17:37
@dplakon dplakon enabled auto-merge (squash) May 19, 2026 14:33
@dplakon dplakon merged commit 1bb368b into master May 19, 2026
25 checks passed
@dplakon dplakon deleted the dplakon/sleep-auto-handoff branch May 19, 2026 14:58
lawsmd pushed a commit to lawsmd/cortex that referenced this pull request May 22, 2026
## Description
Adds a macOS-only **Auto handoff on sleep** setting under Warp Agent →
Cloud Handoff.

When enabled, Warp listens for macOS sleep events and attempts to hand
off the last-focused eligible local Warp Agent session to Cloud Mode
using the existing local-to-cloud handoff flow. This also adds a
`warplocal://action/auto_handoff_to_cloud` trigger for testing and
hook-driven invocation; the trigger now respects the same **Auto handoff
on sleep** opt-in setting.

The setting defaults to off so existing users do not silently enable
automatic cloud handoff or workspace snapshot upload.


https://github.com/user-attachments/assets/38161805-065a-49b4-a4e6-18403de5b0a1

<img width="906" height="238" alt="Screenshot 2026-05-15 at 5 06 56 PM"
src="https://github.com/user-attachments/assets/ccf951e4-3749-4add-a30f-868af3f41183"
/>

## Linked Issue
No linked issue.

- [ ] The linked issue is labeled `ready-to-spec` or
`ready-to-implement`.
- [x] Where appropriate, screenshots or a short video of the
implementation are included below (especially for user-visible or UI
changes).

## Testing
- [x] `cargo fmt`
- [x] `cargo clippy --workspace --all-targets --all-features --tests --
-D warnings`
- [x] `cargo nextest run -p warp auto_handoff --no-fail-fast` — 13
passed
- [x] `cargo nextest run -p warp
last_focused_terminal_tracks_most_recent_globally
conversation_switch_updates_last_focused_terminal_state --no-fail-fast`
— 2 passed
- [x] `git --no-pager diff --check origin/master...HEAD`
- [x] Manual smoke test with `./script/run --open_with_launchd` and
`warplocal://action/auto_handoff_to_cloud` in the original
implementation checkout

- [x] I have manually tested my changes locally with `./script/run`

### Screenshots / Videos
Not included in this update. The PR now notes the setting is opt-in and
the URI trigger respects that opt-in; please attach UI media from a
local app session if required for review.

## Agent Mode
- [x] Warp Agent Mode - This PR was created via Warp's AI Agent Mode

CHANGELOG-OZ: Added a macOS setting to automatically hand off active
local Warp Agent sessions to Cloud Mode before sleep.

Co-Authored-By: Oz <oz-agent@warp.dev>

---------

Co-authored-by: Oz <oz-agent@warp.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants