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

Merged
TH
5d ago
+156-42

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