Skip to main content

HostActionContext

interface

The context an interceptor runs in, not the one a handler runs in. It is deliberately narrower than ContextBase. An interceptor sits in the middle of an action that is already running, so state arrives as a StateSnapshot read at this instant rather than a live handle, and there is no `on`, no `emit`, and no writable state. Reach for the members here to decide whether the action should proceed.

interface HostActionContext

Import

import { HostActionContext } from '@modular/sdk';

Members12

actionoptional
HostActionEnvelope<HostActionId>

The full envelope, present whenever an action is actually in flight.

actions
HostActionRunner

Dispatch another action, for example to repair state before continuing.

actor
HostActor

Who caused the action being intercepted.

ai
AiRuntimeApi

Text answers, agents, models, and sessions.

clipboard
HostClipboardCapabilities

Clipboard writes.

commands
CommandsViewApi

Run a command by id.

events
HostEventCapabilities

Observe commits made while this interceptor is alive.

scope
HostScope

Where it applies.

signal
HostActionAbortSignal

Cancellation for the run you are sitting inside.

source
HostActionSource

How it was triggered.

trace
HostTraceContext

The trace this interceptor's work is recorded under.

state
<TValue>(declaration: StateDeclaration<TValue>) => StateSnapshot<TValue> | <TName extends 'editor.selection' | 'host.scope' | 'workbench.colorTheme' | 'workbench.layout' | 'workbench.windowState' | 'workspace.focusedEditorGroupTab'>(name: TName) => StateSnapshot<BuiltInStateValue<TName>>

Reads state as of now. Snapshots do not update, unlike handles.

Notes

category
Context