Skip to content

fix: allow fresh session device binding#677

Merged
thymikee merged 1 commit into
mainfrom
fix/session-lock-fresh-binding
Jun 3, 2026
Merged

fix: allow fresh session device binding#677
thymikee merged 1 commit into
mainfrom
fix/session-lock-fresh-binding

Conversation

@thymikee
Copy link
Copy Markdown
Member

@thymikee thymikee commented Jun 3, 2026

Summary

Allow fresh named sessions to use compatible explicit device selectors for their first binding while preserving existing-session selector conflict checks.

Deepen request binding into src/daemon/request-binding.ts so fresh/existing session lock identity and locked request binding live behind one daemon module instead of being split across admission and execution scope.

Fresh session binding now locks both the first-binding session key and the resolved device key when possible. That prevents concurrent fresh requests with the same session name but different explicit devices from racing and overwriting the session binding.

Fresh locked open requests still use compatible selectors for first binding, but incompatible selectors now fail during lock-policy validation instead of later during device resolution.

Apple-family fresh-session lock policy now treats explicit --platform macos as a desktop Apple selector, including strip/reject handling for stale iOS-only selectors.

Centralize selector intent in src/daemon/device-selector-intent.ts and reuse session-selector conflict logic when deciding whether a request still targets the active session device. Touched files: 10. Scope stayed within daemon request binding/session selector behavior and focused tests.

Validation

Verified focused daemon behavior with pnpm exec vitest run src/daemon/__tests__/request-lock-policy.test.ts src/daemon/__tests__/request-router-lock-policy.test.ts src/daemon/handlers/__tests__/session-device-utils.test.ts src/daemon/__tests__/request-execution-scope.test.ts, including fresh --session + --udid binding, default lock-platform device serialization, same-session/different-device first-binding serialization, incompatible fresh-session selector rejection before binding, macOS-under-Apple selector handling, and simulator-set selector conflict reuse.

Ran pnpm check:fallow --base origin/main and pnpm check:quick successfully. pnpm check:unit passed unsandboxed: 230 unit files / 2037 tests and 7 smoke tests.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 3, 2026

Size Report

Metric Base Current Diff
JS raw 1.1 MB 1.1 MB +1.0 kB
JS gzip 365.7 kB 366.2 kB +462 B
npm tarball 470.7 kB 471.2 kB +507 B
npm unpacked 1.6 MB 1.6 MB +1.0 kB

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 25.5 ms 25.6 ms +0.1 ms
CLI --help 40.5 ms 40.8 ms +0.3 ms

Top changed chunks:

Chunk Raw diff Gzip diff
dist/src/2415.js +992 B +450 B
dist/src/session.js +21 B +12 B

@thymikee thymikee force-pushed the fix/session-lock-fresh-binding branch from 987b6f2 to 26f3886 Compare June 3, 2026 00:13
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 987b6f2d80

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/daemon/request-lock-policy.ts Outdated
flags: CommandFlags,
lockPlatform: NormalizedLockPlatform,
): void {
for (const key of freshSessionSelectorKeysForPlatform(lockPlatform, flags.target)) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Treat macOS platform as desktop for Apple locks

When the lock platform is apple and a fresh request uses --platform macos --udid ... or --ios-simulator-device-set ... without an explicit --target desktop, this call passes only flags.target as undefined, so freshSessionSelectorKeysForPlatform() takes the non-desktop Apple branch and does not flag the iOS-only selector. With reject the request gets past lock-policy validation and then fails later during device resolution; with strip it leaves the stale iOS selector instead of stripping it before targeting the host Mac. Please account for flags.platform === 'macos' as a desktop Apple request here.

Useful? React with 👍 / 👎.

@thymikee thymikee force-pushed the fix/session-lock-fresh-binding branch 7 times, most recently from 2c57efa to 3f334a4 Compare June 3, 2026 01:34
@thymikee thymikee force-pushed the fix/session-lock-fresh-binding branch from 3f334a4 to c0316e6 Compare June 3, 2026 02:38
@thymikee thymikee merged commit 6946c2f into main Jun 3, 2026
18 checks passed
@thymikee thymikee deleted the fix/session-lock-fresh-binding branch June 3, 2026 03:16
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 3, 2026

PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-06-03 03:16 UTC

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