@@ -50,12 +50,8 @@ import {
5050 prepareOpenCommandDetails ,
5151 type ResolvedOpenRuntimeHintPlan ,
5252} from './session-open-prepare.ts' ;
53- import {
54- buildDeviceInUseBySessionError ,
55- buildForeignWorkspaceSessionConflict ,
56- } from '../../../core/session-recovery-hints.ts' ;
57- import { describeOpenWaitForRefusal } from '../../open-device-contention-wait.ts' ;
58- import { isImplicitSessionScopeConflict , resolvePublicSessionName } from '../../session-routing.ts' ;
53+ import { findSessionDeviceConflict } from '../../open-device-contention-wait.ts' ;
54+ import { resolvePublicSessionName } from '../../session-routing.ts' ;
5955import { applicationLifecycleExecutionFromRequest } from '../../application-lifecycle-execution.ts' ;
6056import {
6157 abandonDeviceClaim ,
@@ -72,7 +68,6 @@ import { buildDeviceClaimConflictError } from '../../../resources/device/device-
7268import { deviceClaimRuleForOwner } from '../../../resources/device/device-claim-rule.ts' ;
7369import {
7470 errorResponse ,
75- type DaemonFailureResponse ,
7671 type DaemonResponse ,
7772} from '@agent-device/kernel/contracts' ;
7873
@@ -438,28 +433,6 @@ async function prepareOpenDispatchSession(params: {
438433 return { type : 'session' , ref : sessionStore . refresh ( ref ) } ;
439434}
440435
441- /**
442- * The refusal an open gets when another session already holds the device, or a device that
443- * overlaps it. The wait an expired `--wait` budget spent is carried into the recovery text, because
444- * a caller that waited is not helped by being told to wait.
445- */
446- function findNewSessionDeviceConflict ( params : {
447- req : DaemonRequest ;
448- device : DeviceInfo ;
449- sessionStore : SessionStore ;
450- } ) : DaemonFailureResponse | undefined {
451- const { req, device, sessionStore } = params ;
452- const inUse = sessionStore . findByDevice ( device . id ) ;
453- if ( ! inUse ) return undefined ;
454- // The wait the caller paid for belongs to `open` alone: an interaction that hits the same busy
455- // device cannot wait for it, and would be sent off with a flag its own command rejects.
456- const attempt = describeOpenWaitForRefusal ( req ) ;
457- if ( isImplicitSessionScopeConflict ( req , inUse . session ) ) {
458- return buildForeignWorkspaceSessionConflict ( inUse , device , attempt ) ;
459- }
460- return buildDeviceInUseBySessionError ( inUse , device , attempt ) ;
461- }
462-
463436async function acquireDeviceClaimForOwner ( params : {
464437 host : HostEnvironment ;
465438 req : DaemonRequest ;
@@ -529,7 +502,7 @@ export async function openNewSessionWithDeviceClaim(params: {
529502 platformServices,
530503 } = params ;
531504 requireOpenSessionAdmission ( sessionStore , sessionName , undefined ) ;
532- const conflict = findNewSessionDeviceConflict ( { req, device, sessionStore } ) ;
505+ const conflict = findSessionDeviceConflict ( { req, device, sessionStore } ) ;
533506 if ( conflict ) return { type : 'response' , response : conflict } ;
534507
535508 const ownerClaim = await acquireDeviceClaimForOwner ( {
0 commit comments