Skip to content

Commit f195b3b

Browse files
committed
refactor(desktop): resolve the executor flag in its own module
1 parent 9e92d98 commit f195b3b

2 files changed

Lines changed: 13 additions & 12 deletions

File tree

‎apps/sim/lib/desktop/application/executor.ts‎

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { getErrorMessage } from '@sim/utils/errors'
44
import { generateId } from '@sim/utils/id'
55
import { isPlainRecord, omit } from '@sim/utils/object'
66
import { defineOperation } from '@/lib/core/application'
7-
import { isFeatureEnabled } from '@/lib/core/config/feature-flags'
87
import { OrchestrationError } from '@/lib/core/orchestration/types'
98
import { defineAuthorizedCredentialUserUseCase } from '@/lib/credentials/application/authorized-user-use-case'
109
import {
@@ -23,12 +22,9 @@ import {
2322
DesktopCallRevokedError,
2423
DesktopDeviceUnrecognizedError,
2524
} from '@/lib/desktop/executor/errors'
25+
import { isDesktopBackgroundExecutorEnabled } from '@/lib/desktop/executor/flag'
2626
import { classifyDesktopInbox, type DesktopInboxEntry } from '@/lib/desktop/executor/inbox'
27-
import {
28-
isDesktopPresenceAvailable,
29-
markDesktopPresent,
30-
releaseDesktopPresence,
31-
} from '@/lib/desktop/executor/presence'
27+
import { markDesktopPresent, releaseDesktopPresence } from '@/lib/desktop/executor/presence'
3228
import {
3329
acknowledgeDesktopCallResult,
3430
claimOfferedDesktopCall,
@@ -64,12 +60,6 @@ async function requireBoundDevice(principal: SessionPrincipal, deviceId: string)
6460
return device
6561
}
6662

67-
/** Whether new turns from this user may bind to a desktop. Never consulted for runs already bound. */
68-
async function isDesktopBackgroundExecutorEnabled(userId: string): Promise<boolean> {
69-
if (!isDesktopPresenceAvailable()) return false
70-
return isFeatureEnabled('mothership-desktop-background-executor', { userId })
71-
}
72-
7363
export interface RegisterDesktopDeviceInput extends DeviceInput {
7464
name: string
7565
appVersion: string
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { isFeatureEnabled } from '@/lib/core/config/feature-flags'
2+
import { isDesktopPresenceAvailable } from '@/lib/desktop/executor/presence'
3+
4+
/**
5+
* Whether this user's new turns may bind to a desktop, and whether the UI shows background desktop
6+
* activity. Never consulted for a run already bound: it keeps running on its desktop until it ends.
7+
*/
8+
export async function isDesktopBackgroundExecutorEnabled(userId: string): Promise<boolean> {
9+
if (!isDesktopPresenceAvailable()) return false
10+
return isFeatureEnabled('mothership-desktop-background-executor', { userId })
11+
}

0 commit comments

Comments
 (0)