Skip to content

feat(dsh): isolate multi-tab sessions and device leases - #93

Merged
HarveySang merged 4 commits into
mainfrom
codex/multi-tab-session-device-isolation
Sep 4, 2026
Merged

feat(dsh): isolate multi-tab sessions and device leases#93
HarveySang merged 4 commits into
mainfrom
codex/multi-tab-session-device-isolation

Conversation

@HarveySang

@HarveySang HarveySang commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

What changed?

  • Scope root tasks and client snapshots by DSH session, with exact task/attempt identities and stale-callback guards.
  • Separate per-session device preferences from all-or-nothing multi-device leases. Reject conflicting ownership and make stale stop/release requests harmless.
  • Bind nested agents to their original task, cancel on owning-session/plugin disposal, and keep tab switching independent of task lifetime.
  • Keep the managed browser globally serial with an exact owner and session-scoped install approval/status.
  • Fix slow-poll starvation and stale browser ownership. Reconcile durable, session-owned command outcomes so immediate device-busy failures do not become misleading launch timeouts or disappear from the sidebar.
  • Update local HTTP contracts, regression tests, reload compatibility, and English/Chinese/Japanese behavior documentation.

Why?

Allow independent DSH sessions to use non-conflicting phones without sharing messages, task state, errors, stop actions, or device ownership. Preserve single-session multi-phone execution.

Accepted verification gate

The maintainer explicitly approved multi-phone automated logic verification plus single-phone real-device acceptance for this merge. Two simultaneous physical phones are not required for this PR's revised gate.

双设备并行已验证逻辑,未做双真机实测。 Automated concurrency checks do not establish real dual-device concurrency or prove that every supported Host permits simultaneous real-device tasks.

Automated verification

Verified candidate source at 2c1dcf2d8af8d2693bcf664a468ad54bc370720e in an isolated worktree:

  • pnpm run check: 45 test files / 301 tests passed, including type checks, builds, and plugin structure validation.
  • npm pack --dry-run and actual tarball creation: passed.
  • git diff --check and staged diff check: passed.
  • Coverage includes concurrent sessions, same-session root rejection, all-or-nothing multi-device acquisition, conflicts without partial leases, exact stop, stale stop/attempt release, nested-agent isolation, cancellation/disposal, client generations and background state/error isolation, HTTP ownership/same-origin checks, and global browser-owner serialization.
  • The immediate command-failure regression was reproduced on the real test Host; four new tests failed before the fix and passed afterwards.
  • Latest push and pull-request CI: Node 22.19.0 / 24 checks and packaged-plugin compatibility across all four supported DSH versions passed.

Single-phone real-device acceptance

Used one authorized Android phone with DSH 0.1.1-rc.2, in a separate test profile loaded from the candidate tarball. Installed client-bundle hashes matched the tested build. No model/phone execution was mocked.

  • Execute a phone task: inspect the system Settings home page, report its title, and return to the launcher; completed successfully.
  • Switch sessions and Chat/OpenGUI views during execution; the owning task remains active, its device selection stays locked, and its stop controls remain scoped.
  • Create a new session without cancelling the background phone task or copying its messages, errors, or stop control.
  • Compete for the same phone from another session: show an immediate device-busy error only in that session; the owner keeps running. Switching back or creating another session does not display that error.
  • Stop through the real UI, then immediately start a replacement task in the same session.
  • Replay the stopped task's exact HTTP stop request: receive 409; the replacement task and attempt remain active and unchanged.
  • The replacement phone task completes, the Host returns an empty task batch, the stop button disappears, and the phone is back at the launcher.

Real dual-phone concurrency, real multi-phone batch execution, and real browser-versus-phone competition remain unverified physically; their ownership and concurrency logic is covered by automated tests. They are not claimed as real-device acceptance here.

Delivery boundaries

  • One atomic PR; rollback is a revert of this PR, with no data migration or recovery step.
  • No dependency, configuration, credential, version, tag, or release changes. Preferences and leases are process-local.
  • No WorkBuddy files changed or included.
  • The existing DSH instance was not replaced or restarted; only the isolated test Host loaded the candidate.
  • This merges source only. A package release is a separate, unrequested action.

@gofenix
gofenix requested a review from VicarDa September 3, 2026 02:17
Schedule task polls after completion so slow responses are not continually invalidated. Recheck the full browser owner identity after asynchronous status reads to prevent cross-session attribution. Add regression coverage for slow polls, retry/disconnect, and owner handoffs.
Track durable command outcomes so immediate device conflicts do not become launch timeouts. Keep consumed command sessions visible and ignore stale admission or completion callbacks.
@HarveySang
HarveySang marked this pull request as ready for review September 4, 2026 15:17
@HarveySang
HarveySang merged commit 5fae2bf into main Sep 4, 2026
14 checks passed
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.

1 participant