Skip to content

fix(daemon): put non-takeover options first in DEVICE_IN_USE hints - #4469

Merged
thymikee merged 5 commits into
mainfrom
fix/device-in-use-hint-ownership
Nov 12, 2026
Merged

thymikee merged 5 commits into
mainfrom
fix/device-in-use-hint-ownership

Conversation

@thymikee

@thymikee thymikee commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Summary

The DEVICE_IN_USE hint told a refused caller to rerun with --session <owner> or to close --session <owner>. On a shared host, an agent followed that hint and drove another agent's session.

The hints now list choosing another device (agent-device devices) and --wait <ms> first. Reuse or close comes last, and only "if that session is yours". This applies to the open, selector-conflict, and recording-session hints. The foreign-workspace hint keeps its close, conditioned on "if that workspace is yours" (#2580). The doctor same-device check drops its verbatim command field and keeps a shell-quoted, conditional close in its hint. Typed details are unchanged. Every variant fits the 400-character redaction cap.

Example:
The holding session may belong to another agent or user. Run agent-device devices and open another device with a device selector. To wait for the device to free up, run the same open with --wait <ms>. Only if that session is yours: reuse --session checkout, or run agent-device close --session checkout first.

10 files changed. No linked issue.

Validation

validation: CI

  • Head f322703: vitest run packages/daemon/src: 3834 passed. The length test derives the longest bounded address (30 characters) from the web name validator and workspace routing. Explicit native names have no length limit.
  • New tests: safe options come before takeover (open and foreign-workspace builders), the length cap holds, and the doctor quotes a;b $(x) and emits no command.
  • Wording only; no device run needed.

🤖 Generated with Claude Code

Recovery hints told a refused caller to reuse or close the holding
session outright. On a shared host another agent followed that and drove
a session it did not own. The hints now offer another device and --wait
first, and offer reuse or close only if that session is the caller's.
The same rule covers the selector-conflict, foreign-workspace, recording
and doctor same-device hints. Typed details are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 6.22 MB 6.22 MB -258 B
Package (unpacked) 6.22 MB 6.22 MB -258 B
Package (download) 1.89 MB 1.89 MB +6 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 21.7 ms 20.3 ms -1.3 ms
CLI --help 48.4 ms 43.5 ms -5.0 ms

…sion

The same-device doctor check put close --session <other> in its command
field, which agents run verbatim. The daemon cannot tell whether that
session is the caller's, so the check now omits command and keeps the
close only in its conditional hint.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment •

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.

All reported issues were addressed

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment •

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.

All reported issues were addressed across 10 files

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Condition the foreign-workspace close on the workspace, since that
session is often the caller's own from another folder. Close a recording
session after record stop only if it still exists. Shell-quote the
session address in the doctor's same-device close suggestion. Extend the
ordering test to the foreign-workspace builder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@apex-sentinel-staging

apex-sentinel-staging Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Apex Sentinel

Verdict: approve

Since the last review: 0 new · 0 still open · 1 no longer raised (1 marked fixed)

No findings.

Reviewed with this repository's own Sentinel configuration (9cbbae2c857d).

Feedback goes in the review comment threads, as a reply under the inline comment of a finding:

Reply @apex-sentinel-staging note ... to add context, or @apex-sentinel-staging pivot ... if it is wrong — I will re-check the cited code.

Useful? Reply @apex-sentinel-staging like, or @apex-sentinel-staging dislike <why> if it is not.

Comment @apex-sentinel-staging review on this conversation to run a full review.

Earlier reviews

Review of 85ab4388 · 12.11.2026 10:35 UTC

Apex Sentinel

Verdict: approve

1 finding(s): 1 minor.

🟡 Minor (1)

Where Finding
packages/daemon/src/core/session-recovery-hints.test.ts:126 400-char cap test only covers the 28-char fixture, so long session names still overflow

Reviewed with this repository's own Sentinel configuration (9cbbae2c857d).

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Apex Sentinel: 1 new finding on 85ab438. The verdict and the full list are in the summary comment.

thymikee and others added 2 commits November 12, 2026 11:39
A 30-character web session name pushed the recording selector-conflict
hint to 403 characters, past the 400-character redaction cap. The length
test now derives its address from the web session name validator and the
implicit workspace addresses session routing builds, and the recording
hint is shorter.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@thymikee

Copy link
Copy Markdown
Member Author

This PR is ready at eb4f27b: the hints now list other devices and --wait first, and reuse or close comes last and only for a session you own. No conflicts. Six CI jobs (the Smoke Tests, Numeric Ranges, Coverage and one review check) are still running with no failures, and the diff does not touch those areas. I read the diff and ran no tests or device. I did not execute the new length test, and I estimated hint lengths by hand against the 400-character cap.

Not blocking, and you can take or leave these: the versioned CLI help at cli-help.ts:313 and device-verification.md:38 still tell agents to reuse or close the holder without the ownership condition, so they should follow the new hint order. The comments at session-recovery-hints.ts:22 and request-lock-policy.ts:139 still describe the old reuse/close lead. The recording hint at session-recovery-hints.ts:101 is circular in a selector conflict and omits the different --session name advice, so it could share the per-context lead with the open-session builder. The doctor warning dropping its command field changes public JSON, so it is worth its own line in the PR body. The recording test fixture uses a cast, no test asserts recording or selector-conflict hint order, and the 400 in the cap test could name its source.

Of the earlier review threads, the foreign-workspace one (discussion) does not apply, because the holder is often your own session from another folder and close stays last and conditional. These are fixed at this commit and can be resolved: foreign-workspace ordering test, recording hint close, doctor shell quoting, and length test.

Before merge, wait for the pending jobs to pass. Aligning the help text and the verification doc in the same push would be worth it.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 12, 2026
@thymikee
thymikee merged commit 18dd00e into main Nov 12, 2026
20 checks passed
@thymikee
thymikee deleted the fix/device-in-use-hint-ownership branch November 12, 2026 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant