Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

fix: clear stale schedule pauses and repeated Claude setup prompts (#7606)

Ezra Ellette6a443fb1ff9e
diff --git a/apps/screenpipe-app-tauri/components/chat/standalone/hooks/__tests__/acp-warmup.test.ts b/apps/screenpipe-app-tauri/components/chat/standalone/hooks/__tests__/acp-warmup.test.ts
index 56844a558..3e3961aac 100644
--- a/apps/screenpipe-app-tauri/components/chat/standalone/hooks/__tests__/acp-warmup.test.ts
+++ b/apps/screenpipe-app-tauri/components/chat/standalone/hooks/__tests__/acp-warmup.test.ts
@@ -184,4 +184,62 @@ describe("ACP warmup fires exactly when it should", () => {
await waitFor(() => expect(piStartInFlightRef.current).toBe(false));
expect(setPiStarting).toHaveBeenLastCalledWith(false);
});
+ it.each(["cancelled", "failed"])("does not reopen %s warmup on new chats or remounts", async (outcome) => {
+ warmupMocks.piStart.mockReset();
+ warmupMocks.piStart.mockResolvedValue(outcome === "cancelled"
+ ? { status: "ok", data: { running: false, startupError: "ACP authentication cancelled" } }
+ : { status: "error", error: "Authentication required" });
+ const piSessionIdRef = { current: "first-chat" };
+ const options = {
+ enabled: true,
+ activePreset: { id: `declined-${outcome}`, provider: "acp", acpAgent: { id: "claude-acp" } } as any,
+ piInfo: null,
+ piStartInFlightRef: { current: false },
+ piSessionIdRef,
+ piProjectDirForSession: vi.fn(async () => "/tmp/chat"),
+ buildProviderConfig: vi.fn(() => ({ provider: "acp" }) as any),
+ userToken: null,
+ setPiInfo: vi.fn(),
+ setPiStarting: vi.fn(),
+ setRunningConfigFromProviderConfig: vi.fn(),
+ syncThinkingLevelAfterStart: vi.fn(),
+ };
+ const first = renderHook(() => useAcpWarmup(options));
+ await waitFor(() => expect(warmupMocks.piStart).toHaveBeenCalledTimes(1));
+ await waitFor(() => expect(options.piStartInFlightRef.current).toBe(false));
+ piSessionIdRef.current = "second-chat";
+ first.rerender();
+ first.unmount();
+ const reopened = renderHook(() => useAcpWarmup(options));
+ await act(async () => {});
+ expect(warmupMocks.piStart).toHaveBeenCalledTimes(1);
+ reopened.unmount();
+ });
+
+ it("continues warming new conversations after a successful handshake", async () => {
+ warmupMocks.piStart.mockReset();
+ warmupMocks.piStart.mockResolvedValue({ status: "ok", data: { running: true } });
+ const piSessionIdRef = { current: "first-ready-chat" };
+ const options = {
+ enabled: true,
+ activePreset: { id: "ready-preset", provider: "acp", acpAgent: { id: "claude-acp" } } as any,
+ piInfo: null,
+ piStartInFlightRef: { current: false },
+ piSessionIdRef,
+ piProjectDirForSession: vi.fn(async () => "/tmp/chat"),
+ buildProviderConfig: vi.fn(() => ({ provider: "acp" }) as any),
+ userToken: null,
+ setPiInfo: vi.fn(),
+ setPiStarting: vi.fn(),
+ setRunningConfigFromProviderConfig: vi.fn(),
+ syncThinkingLevelAfterStart: vi.fn(),
+ };
+ const hook = renderHook(() => useAcpWarmup(options));
+ await waitFor(() => expect(options.setPiInfo).toHaveBeenCalledTimes(1));
+ piSessionIdRef.current = "second-ready-chat";
+ hook.rerender();
+ await waitFor(() => expect(warmupMocks.piStart).toHaveBeenCalledTimes(2));
+ hook.unmount();
+ });
+
});
diff --git a/apps/screenpipe-app-tauri/components/chat/standalone/hooks/use-acp-warmup.ts b/apps/screenpipe-app-tauri/components/chat/standalone/hooks/use-acp-warmup.ts
index 54d3dc435..91bcef051 100644
--- a/apps/screenpipe-app-tauri/components/chat/standalone/hooks/use-acp-warmup.ts
+++ b/apps/screenpipe-app-tauri/components/chat/standalone/hooks/use-acp-warmup.ts
@@ -7,6 +7,11 @@ import { commands } from "@/lib/utils/tauri";
import type { AIPreset, PiInfo } from "@/lib/utils/tauri";
import type { ResolvedPiProviderConfig } from "@/components/chat/standalone/hooks/use-pi-session-lifecycle";
+// A new conversation (or remounted chat view) is not consent to reopen a
+// declined sign-in. Keep unsuccessful automatic starts quiet for this webview;
+// sending a message or using the sign-in retry still starts the agent normally.
+const pendingOrFailedWarmups = new Set<string>();
+
/**
* Connect an ACP agent when it is selected, not when the first message is sent.
*
@@ -80,10 +85,13 @@ export function useAcpWarmup({
const key = `${sessionId}:${presetId}:${agentId}`;
if (attemptedRef.current === key) return;
+ const agentKey = JSON.stringify([presetId, agentId]);
+ if (pendingOrFailedWarmups.has(agentKey)) return;
attemptedRef.current = key;
const preset = activePreset;
if (!preset) return;
+ pendingOrFailedWarmups.add(agentKey);
let cancelled = false;
piStartInFlightRef.current = true;
@@ -100,6 +108,9 @@ export function useAcpWarmup({
userToken ?? null,
providerConfig,
);
+ if (result.status === "ok" && result.data.running) {
+ pendingOrFailedWarmups.delete(agentKey);
+ }
if (cancelled) return;
if (result.status === "ok" && result.data.running) {
setPiInfo(result.data);
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/capture_session.rs b/apps/screenpipe-app-tauri/src-tauri/src/capture_session.rs
index 31314ccc7..996fd9dac 100644
--- a/apps/screenpipe-app-tauri/src-tauri/src/capture_session.rs
+++ b/apps/screenpipe-app-tauri/src-tauri/src/capture_session.rs
@@ -44,6 +44,7 @@ pub struct CaptureSession {
shutdown_tx: broadcast::Sender<()>,
disk_pressure_data_dir: PathBuf,
vision_task: Option<tokio::task::JoinHandle<()>>,
+ schedule_task: Option<tokio::task::JoinHandle<()>>,
ui_recorder_handle: Option<screenpipe_engine::UiRecorderHandle>,
audio_manager: Arc<screenpipe_audio::audio_manager::AudioManager>,
audio_disabled: bool,
@@ -74,6 +75,22 @@ impl CaptureSession {
let (shutdown_tx, _) = broadcast::channel::<()>(1);
reconfigure_audio_manager(server, config).await?;
+ // A capture restart keeps this process alive. Disabling the schedule
+ // must clear the previous session's pause before starting capture.
+ screenpipe_engine::schedule_monitor::reset_schedule_paused();
+ let schedule_task = config.schedule_enabled.then(|| {
+ screenpipe_engine::schedule_monitor::start_schedule_monitor(
+ config.schedule_rules.clone(),
+ shutdown_tx.subscribe(),
+ )
+ });
+ info!(
+ schedule_enabled = config.schedule_enabled,
+ schedule_rules = config.schedule_rules.len(),
+ schedule_paused = screenpipe_engine::schedule_monitor::schedule_paused(),
+ "capture session schedule initialized"
+ );
+
// --- Capture trigger sender (set by VisionManager, consumed by UI recorder) ---
let mut capture_trigger_tx: Option<screenpipe_engine::event_driven_capture::TriggerSender> =
None;
@@ -296,15 +313,6 @@ impl CaptureSession {
config.user_name.clone(),
);
- // --- Schedule monitor ---
- if config.schedule_enabled {
- screenpipe_engine::schedule_monitor::start_schedule_monitor(
- config.schedule_rules.clone(),
- shutdown_tx.subscribe(),
- );
- info!("work-hours schedule monitor started");
- }
-
// --- Snapshot compaction ---
if config.disable_snapshot_compaction {
info!("snapshot compaction disabled by recording settings");
@@ -324,6 +332,7 @@ impl CaptureSession {
shutdown_tx,
disk_pressure_data_dir: server.data_path.clone(),
vision_task,
+ schedule_task,
ui_recorder_handle,
audio_manager: server.audio_manager.clone(),
audio_disabled: config.disable_audio,
@@ -367,6 +376,14 @@ impl CaptureSession {
// Broadcast shutdown to VisionManager, meeting watcher, schedule monitor, compaction
let _ = self.shutdown_tx.send(());
+ // Join before allowing a replacement session to initialize the shared
+ // schedule flag; an old monitor must never re-pause the new session.
+ if let Some(schedule_task) = self.schedule_task.take() {
+ if let Err(error) = schedule_task.await {
+ failures.push(format!("schedule_stop: {error}"));
+ }
+ }
+
// Stop audio recording (but don't shutdown — keep the Arc valid for queries)
if !self.audio_disabled {
if let Err(e) = self.audio_manager.stop().await {
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/feedback_upload.rs b/apps/screenpipe-app-tauri/src-tauri/src/feedback_upload.rs
index 21b802bc9..570f50cda 100644
--- a/apps/screenpipe-app-tauri/src-tauri/src/feedback_upload.rs
+++ b/apps/screenpipe-app-tauri/src-tauri/src/feedback_upload.rs
@@ -841,6 +841,73 @@ mod tests {
assert!(!report.contains("hunter2"));
}
+ #[cfg(unix)]
+ #[tokio::test]
+ async fn starter_skill_failure_reaches_support_after_rotation_and_redaction() {
+ use std::os::unix::fs::symlink;
+ let root = tempfile::tempdir().unwrap();
+ let skills = root.path().canonicalize().unwrap().join("skills");
+ std::fs::create_dir(&skills).unwrap();
+ let (name, body) = screenpipe_core::starter_skills::STARTER_SKILLS[0];
+ symlink(root.path().join("missing"), skills.join(name)).unwrap();
+ let cause = screenpipe_core::starter_skills::install_one(&skills, name, body)
+ .unwrap_err()
+ .to_string();
+ let logs = tempfile::tempdir().unwrap();
+ std::fs::write(logs.path().join("screenpipe-app.2026-10-12.log"),
+ format!("WARN AI tool background setup could not connect one tool failure=Claude Code: {cause} password=hunter2\n")).unwrap();
+ std::fs::write(logs.path().join("screenpipe-app.2026-10-13.log"),
+ "INFO capture session schedule initialized schedule_enabled=false schedule_rules=0 schedule_paused=false\n").unwrap();
+ let files = crate::log_files::collect_log_files(&[logs.path().to_path_buf()]).await;
+ let raw = collect_log_text_from_files(files).await;
+ let redacted = crate::feedback_redact::redact_diagnostics_locally(raw)
+ .await
+ .unwrap();
+ let server = MockServer::start().await;
+ Mock::given(method("POST"))
+ .and(path("/api/logs"))
+ .respond_with(ResponseTemplate::new(200).set_body_json(json!({"data": {
+ "signedUrl": format!("{}/upload/log", server.uri()), "path": "logs/report.log"
+ }})))
+ .mount(&server)
+ .await;
+ Mock::given(method("PUT"))
+ .and(path("/upload/log"))
+ .respond_with(ResponseTemplate::new(200))
+ .mount(&server)
+ .await;
+ Mock::given(method("POST"))
+ .and(path("/api/logs/confirm"))
+ .respond_with(ResponseTemplate::new(200).set_body_json(json!({"data": {"id": 42}})))
+ .mount(&server)
+ .await;
+ upload_report(
+ &Client::new(),
+ &server.uri(),
+ &request(),
+ redacted,
+ None,
+ None,
+ )
+ .await
+ .unwrap();
+ let requests = server.received_requests().await.unwrap();
+ let upload = requests.iter().find(|r| r.method == "PUT").unwrap();
+ let report = String::from_utf8_lossy(&upload.body);
+ for expected in [
+ "Claude Code",
+ "screenpipe-recall/SKILL.md",
+ "os error 2",
+ "repair the link and retry",
+ "existing files were preserved",
+ "schedule_enabled=false",
+ "schedule_paused=false",
+ ] {
+ assert!(report.contains(expected), "missing {expected}: {report}");
+ }
+ assert!(!report.contains("hunter2"));
+ }
+
#[tokio::test]
async fn monitor_discovery_failure_reaches_support_after_collection_and_redaction() {
let server = MockServer::start().await;
diff --git a/crates/screenpipe-core/src/starter_skills.rs b/crates/screenpipe-core/src/starter_skills.rs
index 90d835591..3452d55b8 100644
--- a/crates/screenpipe-core/src/starter_skills.rs
+++ b/crates/screenpipe-core/src/starter_skills.rs
@@ -103,7 +103,10 @@ fn regular(path: &Path, directory: bool) -> io::Result<bool> {
}
Ok(_) => Err(io::Error::new(
io::ErrorKind::InvalidInput,
- "starter skill path must not be a symlink or special file",
+ format!(
+ "starter skill path must not be a symlink or special file: {}; existing files were preserved",
+ path.display()
+ ),
)),
Err(e) if e.kind() == io::ErrorKind::NotFound => Ok(false),
Err(e) => Err(e),
@@ -124,6 +127,21 @@ fn ensure_root(root: &Path) -> io::Result<()> {
fs::create_dir_all(root)
}
+/// Linked starter skills are user-managed collisions, just like unmarked
+/// regular files. We may use an existing readable skill, but never write or
+/// remove either the link or its target (including a linked ownership marker).
+fn linked_skill(dir: &Path) -> io::Result<bool> {
+ for path in [dir.to_path_buf(), dir.join("SKILL.md"), dir.join(MARKER)] {
+ match fs::symlink_metadata(&path) {
+ Ok(metadata) if metadata.file_type().is_symlink() => return Ok(true),
+ Ok(_) => {}
+ Err(error) if error.kind() == io::ErrorKind::NotFound => {}
+ Err(error) => return Err(error),
+ }
+ }
+ Ok(false)
+}
+
pub fn install_one(root: &Path, name: &str, content: &str) -> io::Result<PathBuf> {
if !STARTER_SKILLS.iter().any(|(key, _)| *key == name) {
return Err(io::Error::new(
@@ -133,9 +151,28 @@ pub fn install_one(root: &Path, name: &str, content: &str) -> io::Result<PathBuf
}
ensure_root(root)?;
let dir = root.join(name);
+ let path = dir.join("SKILL.md");
+ if linked_skill(&dir)? {
+ // Checking the target type first avoids reading a pipe/device. A
+ // dangling link remains an actionable failure, not a claimed install.
+ let readable = fs::metadata(&path).and_then(|metadata| {
+ if !metadata.is_file() {
+ return Err(io::Error::new(
+ io::ErrorKind::InvalidInput,
+ "target is not a regular file",
+ ));
+ }
+ fs::read_to_string(&path)
+ });
+ return readable.map(|_| path.clone()).map_err(|error| {
+ io::Error::new(error.kind(), format!(
+ "linked starter skill is not a readable regular file: {}: {error}; repair the link and retry; existing files were preserved",
+ path.display()
+ ))
+ });
+ }
regular(&dir, true)?;
fs::create_dir_all(&dir)?;
- let path = dir.join("SKILL.md");
let marker = dir.join(MARKER);
let exists = regular(&path, false)?;
let owned = regular(&marker, false)?;
@@ -217,9 +254,15 @@ pub fn install_store(root: &Path) -> io::Result<Vec<PathBuf>> {
pub fn is_current_or_custom(root: &Path, name: &str, content: &str) -> bool {
let dir = root.join(name);
+ if !dir.join("SKILL.md").is_file() {
+ return false;
+ }
let Ok(current) = fs::read_to_string(dir.join("SKILL.md")) else {
return false;
};
+ if linked_skill(&dir).unwrap_or(false) {
+ return true;
+ }
if current == content {
return true;
}
@@ -235,6 +278,9 @@ pub fn remove_one(root: &Path, name: &str) -> io::Result<bool> {
}
ensure_root(root)?;
let dir = root.join(name);
+ if linked_skill(&dir)? {
+ return Ok(false);
+ }
if !regular(&dir, true)? {
return Ok(false);
}
@@ -377,9 +423,9 @@ mod tests {
}
#[cfg(unix)]
#[test]
- fn reject_links_at_root_directory_file_and_marker() {
+ fn reject_linked_roots_and_unreadable_linked_skills() {
use std::os::unix::fs::symlink;
- for part in ["root", "directory", "file", "marker"] {
+ for part in ["root", "directory", "marker"] {
let t = Temp::new();
let outside = Temp::new();
let (name, body) = STARTER_SKILLS[0];
@@ -394,15 +440,78 @@ mod tests {
} else {
fs::create_dir(&dir).unwrap();
fs::write(outside.0.join("target"), "unchanged").unwrap();
- symlink(
- outside.0.join("target"),
- dir.join(if part == "file" { "SKILL.md" } else { MARKER }),
- )
- .unwrap();
+ symlink(outside.0.join("target"), dir.join(MARKER)).unwrap();
}
}
assert!(install_one(&root, name, body).is_err());
assert!(!outside.0.join("SKILL.md").exists());
}
}
+ #[cfg(unix)]
+ #[test]
+ fn preserve_linked_starters_across_install_refresh_and_disconnect() {
+ use std::os::unix::fs::symlink;
+ for part in ["directory", "file", "marker"] {
+ let t = Temp::new();
+ let outside = Temp::new();
+ let (name, _) = STARTER_SKILLS[0];
+ let dir = t.0.join(name);
+ let original = "user-managed recall skill";
+ fs::write(outside.0.join("SKILL.md"), original).unwrap();
+ if part == "directory" {
+ symlink(&outside.0, &dir).unwrap();
+ } else {
+ fs::create_dir(&dir).unwrap();
+ if part == "file" {
+ symlink(outside.0.join("SKILL.md"), dir.join("SKILL.md")).unwrap();
+ } else {
+ fs::write(dir.join("SKILL.md"), original).unwrap();
+ symlink(outside.0.join("SKILL.md"), dir.join(MARKER)).unwrap();
+ }
+ }
+ let link = match part {
+ "directory" => dir.clone(),
+ "file" => dir.join("SKILL.md"),
+ _ => dir.join(MARKER),
+ };
+ let target = fs::read_link(&link).unwrap();
+ // Remaining starter skills still install despite the collision.
+ assert_eq!(install(&t.0).unwrap().len(), STARTER_SKILLS.len());
+ install_one(&t.0, name, "new bundled version").unwrap();
+ assert!(is_current_or_custom(&t.0, name, "new bundled version"));
+ assert!(!remove_one(&t.0, name).unwrap());
+ assert_eq!(fs::read_link(&link).unwrap(), target);
+ assert_eq!(fs::read_to_string(dir.join("SKILL.md")).unwrap(), original);
+ assert_eq!(
+ fs::read_to_string(outside.0.join("SKILL.md")).unwrap(),
+ original
+ );
+ }
+ }
+
+ #[cfg(unix)]
+ #[test]
+ fn broken_link_reports_path_preserves_link_and_recovers_after_repair() {
+ use std::os::unix::fs::symlink;
+ let t = Temp::new();
+ let outside = Temp::new();
+ let (name, body) = STARTER_SKILLS[0];
+ let dir = t.0.join(name);
+ let target = outside.0.join("missing");
+ symlink(&target, &dir).unwrap();
+ let error = install_one(&t.0, name, body).unwrap_err().to_string();
+ assert!(error.contains(&dir.join("SKILL.md").display().to_string()));
+ assert!(error.contains("repair the link and retry"));
+ assert!(!is_current_or_custom(&t.0, name, body));
+ assert!(!remove_one(&t.0, name).unwrap());
+ assert_eq!(fs::read_link(&dir).unwrap(), target);
+ fs::create_dir(&target).unwrap();
+ fs::write(target.join("SKILL.md"), "repaired user skill").unwrap();
+ install_one(&t.0, name, body).unwrap();
+ assert!(is_current_or_custom(&t.0, name, body));
+ assert_eq!(
+ fs::read_to_string(target.join("SKILL.md")).unwrap(),
+ "repaired user skill"
+ );
+ }
}
diff --git a/crates/screenpipe-engine/src/cli/agent.rs b/crates/screenpipe-engine/src/cli/agent.rs
index 68e517734..e7e685a0b 100644
--- a/crates/screenpipe-engine/src/cli/agent.rs
+++ b/crates/screenpipe-engine/src/cli/agent.rs
@@ -2018,6 +2018,55 @@ mod tests {
assert!(body.contains("${SCREENPIPE_LOCAL_API_URL:-http://10.0.0.5:3030}/search"));
}
+ #[cfg(unix)]
+ #[test]
+ fn test_linked_starter_connect_restart_disconnect_and_opt_out() {
+ use std::os::unix::fs::symlink;
+ let home = tempfile::tempdir().unwrap();
+ let home = home.path().canonicalize().unwrap();
+ let custom = tempfile::tempdir().unwrap();
+ std::fs::write(custom.path().join("SKILL.md"), "user recall instructions").unwrap();
+ std::fs::create_dir_all(home.join(".claude/skills")).unwrap();
+ std::fs::write(home.join(".claude.json"), "{}").unwrap();
+ let link = home.join(".claude/skills/screenpipe-recall");
+ symlink(custom.path(), &link).unwrap();
+ let bun = Path::new("/test/bun");
+ let opted_out = BTreeSet::new();
+ install_skills_in("claude-code", "http://localhost:3030", &home).unwrap();
+ // Each fresh reconciler represents a new app process.
+ for _ in 0..2 {
+ let report = reconcile_detected_desktop_in(
+ &home,
+ bun,
+ None,
+ "http://localhost:3030",
+ &opted_out,
+ );
+ assert!(report.failures.is_empty(), "{:?}", report.failures);
+ assert!(desktop_skills_current(
+ &layout_in("claude-code", &home).unwrap()
+ ));
+ }
+ let layout = layout_in("claude-code", &home).unwrap();
+ remove_skills_from(layout.skills_dir.as_ref().unwrap()).unwrap();
+ remove_mcp_json(&layout.mcp_path).unwrap();
+ let report = reconcile_detected_desktop_in(
+ &home,
+ bun,
+ None,
+ "http://localhost:3030",
+ &BTreeSet::from(["claude-code".into()]),
+ );
+ assert_eq!(report.opted_out, 1);
+ assert!(report.failures.is_empty());
+ assert!(!home.join(".claude/skills/screenpipe-api").exists());
+ assert_eq!(std::fs::read_link(link).unwrap(), custom.path());
+ assert_eq!(
+ std::fs::read_to_string(custom.path().join("SKILL.md")).unwrap(),
+ "user recall instructions"
+ );
+ }
+
#[test]
fn test_api_skill_does_not_embed_agent_self_improvement_policy() {
assert!(!API_SKILL_MD.contains("After completing a complex Screenpipe query"));
diff --git a/crates/screenpipe-engine/src/schedule_monitor.rs b/crates/screenpipe-engine/src/schedule_monitor.rs
index a896323cc..b76049e79 100644
--- a/crates/screenpipe-engine/src/schedule_monitor.rs
+++ b/crates/screenpipe-engine/src/schedule_monitor.rs
@@ -131,10 +131,19 @@ fn current_record_mode_at(
///
/// Checks every 30 seconds whether the current local time falls within the
/// configured schedule rules. Updates `SCHEDULE_PAUSED` accordingly.
-pub fn start_schedule_monitor(rules: Vec<ScheduleRule>, mut shutdown: broadcast::Receiver<()>) {
+pub fn start_schedule_monitor(
+ rules: Vec<ScheduleRule>,
+ mut shutdown: broadcast::Receiver<()>,
+) -> tokio::task::JoinHandle<()> {
+ let windows = parse_schedule_windows(&rules);
+ // Establish the new session's policy before any capture task can run.
+ SCHEDULE_PAUSED.store(
+ !is_within_schedule_windows(&windows, &chrono::Local::now()),
+ Ordering::SeqCst,
+ );
tokio::spawn(async move {
- let windows = parse_schedule_windows(&rules);
info!(
+ schedule_paused = schedule_paused(),
"schedule monitor started with {} rules ({} valid windows)",
rules.len(),
windows.len()
@@ -166,7 +175,7 @@ pub fn start_schedule_monitor(rules: Vec<ScheduleRule>, mut shutdown: broadcast:
}
}
}
- });
+ })
}
#[cfg(test)]
@@ -275,9 +284,27 @@ mod tests {
assert!(is_within_schedule_windows(&windows, &now));
}
- #[test]
- fn global_flag_default_unpaused() {
- SCHEDULE_PAUSED.store(false, Ordering::SeqCst);
+ #[tokio::test]
+ async fn restart_after_scheduled_pause_applies_new_policy_before_capture() {
+ let (shutdown, _) = broadcast::channel(1);
+ // No allowed windows: even before the task is polled, capture is paused.
+ let task = start_schedule_monitor(vec![], shutdown.subscribe());
+ assert!(schedule_paused());
+ shutdown.send(()).unwrap();
+ task.await.unwrap();
+
+ // The desktop stays in the same process when the user disables the
+ // schedule and applies settings. Its new session must be unpaused.
+ reset_schedule_paused();
assert!(!schedule_paused());
+ tokio::task::yield_now().await;
+ assert!(!schedule_paused());
+
+ // Enabling it again must reapply the restriction, not inherit the reset.
+ let task = start_schedule_monitor(vec![], shutdown.subscribe());
+ assert!(schedule_paused());
+ shutdown.send(()).unwrap();
+ task.await.unwrap();
+ reset_schedule_paused();
}
}