mirror of
https://github.com/stablyai/orca.git
synced 2026-10-07 16:02:29 +00:00
* feat(notifications): turn desktop notifications on or off per machine Settings > Notifications lists each machine (this computer, SSH targets, paired Orca servers) with a switch. Muted machines are stored as an opt-out list so a newly added machine still notifies. Both notification senders now name the machine a workspace runs on, and main skips the desktop banner for a muted one; phone push is unchanged. * fix(notifications): preserve phone alerts and honor machine mutes * fix(notifications): bind machine mutes to configured sources * fix(notifications): preserve chat completion subscriptions on owner collisions * fix(notifications): reduce machine settings clutter with a collapsed section * fix(notifications): align machine disclosure with settings rows * fix(notifications): clarify machine switches affect only this computer
52 lines
1.6 KiB
TypeScript
52 lines
1.6 KiB
TypeScript
import {
|
|
isRuntimeOwnedSshTargetId,
|
|
parseExecutionHostId,
|
|
toRuntimeExecutionHostId,
|
|
type ExecutionHostId
|
|
} from './execution-host'
|
|
import {
|
|
isEphemeralVmRuntimeEnvironment,
|
|
type PublicKnownRuntimeEnvironment
|
|
} from './runtime-environments'
|
|
|
|
/** A client-configured notification source, not authority for executing work. */
|
|
export type NotificationSourceId = ExecutionHostId
|
|
|
|
export type NotificationWorkspaceOwner = {
|
|
executionHostId: ExecutionHostId | null
|
|
runtimeEnvironmentId: string | null
|
|
}
|
|
|
|
type NotificationSourceCatalog = {
|
|
sshTargetLabels?: ReadonlyMap<string, string>
|
|
runtimeEnvironments?: readonly Pick<PublicKnownRuntimeEnvironment, 'id' | 'source'>[]
|
|
}
|
|
|
|
export function notificationSourceForOwner(
|
|
owner: NotificationWorkspaceOwner | null,
|
|
catalog: NotificationSourceCatalog
|
|
): NotificationSourceId | undefined {
|
|
if (!owner) {
|
|
return undefined
|
|
}
|
|
const host = parseExecutionHostId(owner.executionHostId)
|
|
const environmentId =
|
|
owner.runtimeEnvironmentId ?? (host?.kind === 'runtime' ? host.environmentId : null)
|
|
if (environmentId) {
|
|
const environment = catalog.runtimeEnvironments?.find((entry) => entry.id === environmentId)
|
|
if (!environment) {
|
|
return undefined
|
|
}
|
|
return isEphemeralVmRuntimeEnvironment(environment)
|
|
? 'local'
|
|
: toRuntimeExecutionHostId(environmentId)
|
|
}
|
|
if (host?.kind === 'ssh') {
|
|
if (isRuntimeOwnedSshTargetId(host.targetId)) {
|
|
return 'local'
|
|
}
|
|
return catalog.sshTargetLabels?.has(host.targetId) ? host.id : undefined
|
|
}
|
|
return host?.kind === 'local' ? host.id : undefined
|
|
}
|