Skip to content

fix(v2): make /auto-resume pause strictly per-session, reset on restart - #53

Closed
famewolf wants to merge 2 commits into
Mte90:masterfrom
famewolf:fix/per-session-auto-resume-toggle
Closed

famewolf wants to merge 2 commits into
Mte90:masterfrom
famewolf:fix/per-session-auto-resume-toggle

Conversation

@famewolf

Copy link
Copy Markdown
Contributor

Summary

/auto-resume off used to pause every session on this machine. The v2 code honoured a global * wildcard in the pause marker file (written by auto-resume-toggle --all), and the marker (~/.config/opencode/auto-resume.paused) kept the pause stuck until someone deleted the file. The README already documented pause as per-session and restart-cleared; the code did not do either. This PR makes the code match the doc.

 isPaused(sid)
-  return s.has("*") || s.has(sid)
+  return s.has(sid)

 setPaused(sid, on)
-  // no validation
+  if (!sid || !sid.startsWith("ses_")) return

 setup()
-  writeFileSync(PAUSED_MARKER_FILE, "", "utf8")   // stale marker kept
+  unlinkSync(PAUSED_MARKER_FILE)                 // restart re-arms all sessions
  • Slash command /auto-resume off|on is now strictly the current session; other sessions are unaffected.
  • auto-resume-toggle --all writes *, which the v2 build ignores — per-session IDs only.
  • A pause lasts for the current opencode process only; restart deletes the marker and re-arms auto-resume.

Evidence

Before (upstream v1.2.7 with this branch's tests present, fix absent):

$ bun run test        # build + full suite on a pristine v1.2.7 tree
1099 pass / 2 fail — exactly the 2 new session-pause tests fail
  (global '*' wildcard; restart reset). No other test changed.

After (branch fix/per-session-auto-resume-toggle, cherry-picked cleanly onto v1.2.7 35e5607):

$ bun test src/v2/index.session-pause.test.ts
4 pass / 0 fail (12 expect() calls)

$ bun run test        # build + full suite (1101 tests, 107 files)
1100 pass / 1 fail — src/dispatch.test.ts
  "service-only setup context is silent" passes in isolation (10/10);
  it reads the global console for a 100 ms window and is scheduling-sensitive,
  with no involvement in pause behavior (unrelated to this change).

Tests isolate HOME (temp dir via top-level await import("./index?session-pause=…")), so the real ~/.config/opencode/auto-resume.paused is never touched. The four tests: per-session pause + other session still recovers; */invalid ids rejected; on re-enables only the target session; restart deletes the marker and re-arms.

Merge Danger

Door: Two-way door — behavior change confined to v2 pause semantics; reverting restores the global wildcard.

Blast Radius: Minor. v1 behavior is untouched. v2 users who used --all for a machine-wide pause will get per-session pauses instead, and any pause they had set will be re-armed after a restart. Both move in the safe direction: a forgotten pause can no longer silently disable recovery.

One code behavior change, one README section, one new test file. No migration, no schema, no new dependency.

- README: /auto-resume off|on is strictly session-scoped; the old --all
  global wildcard is ignored by v2; pause marker is deleted at startup,
  re-arming every session after a restart.
- src/v2/index.ts: source-of-truth comment matches per-session behavior.
- src/v2/index.session-pause.test.ts: bun:test suite covering per-session
  pause, wildcard/invalid-id rejection, off/on roundtrip, restart reset.
@Mte90

Mte90 commented Nov 20, 2026 •

Copy link
Copy Markdown
Owner

I am working on this stale file because I don't like the approach because with multiple opencode instances on the same machine there are problems.

@Mte90

Mte90 commented Nov 20, 2026

Copy link
Copy Markdown
Owner

So it seems that I already fixed with the latest commit.

@Mte90 Mte90 closed this Nov 20, 2026
@famewolf
famewolf deleted the fix/per-session-auto-resume-toggle branch November 20, 2026 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants