Skip to content

Interface: ExtensionContext

Defined in: packages/sdk/src/types.ts:369

The object handed to Extension.activate. It is the only sanctioned way an extension touches the running app: register contributions, invoke commands, and read/drive state through the typed consumer services. Every register* call returns a Disposable and is also tracked on ExtensionContext.subscriptions.

Properties

extensionId

ts
readonly extensionId: string;

Defined in: packages/sdk/src/types.ts:371

The activating extension's id (its Extension.id).


subscriptions

ts
readonly subscriptions: Disposable[];

Defined in: packages/sdk/src/types.ts:373

Disposables tracked for this extension; the host disposes them on teardown.


workspaces

ts
readonly workspaces: WorkspaceService;

Defined in: packages/sdk/src/types.ts:405

Consumer API for driving workspace state — create, rename, reorder, activate, soft close/reopen, and hard delete. Subscribe to a frozen state for read access without depending on Valtio.


editors

ts
readonly editors: EditorService;

Defined in: packages/sdk/src/types.ts:411

The editor & document domain — open files into editor tabs, drive the active editor (save / close), and register editor save handlers. Opening editors lives here, not on ExtensionContext.workspaces.


layout

ts
readonly layout: LayoutService;

Defined in: packages/sdk/src/types.ts:417

Consumer API for app layout — side-panel collapse state. Read via getState/useServiceState/subscribe; drive via toggleSidePanel / setSidePanelCollapsed.


process

ts
readonly process: ProcessService;

Defined in: packages/sdk/src/types.ts:423

Persistent process / PTY sessions that survive app restarts — the core primitive under the terminal (and future task runners, REPLs). Spawn or re-attach a session and drive it via the returned ProcessSession.


terminals

ts
readonly terminals: TerminalService;

Defined in: packages/sdk/src/types.ts:431

Consumer API for the terminal domain — open a terminal tab in a workspace (create) or reap a workspace's terminals (closeWorkspace). The terminal is a core feature (a built-in DockKind like the editor); its tabs render from the workspace's records, and PTY sessions live on ExtensionContext.process.


files

ts
readonly files: FileService;

Defined in: packages/sdk/src/types.ts:437

Host-mediated filesystem access — read / write / list / watch, all routed through the host rather than raw Tauri. The single privileged chokepoint for the filesystem; watcher lifecycle is host-owned (see FileService).


ts
readonly search: SearchService;

Defined in: packages/sdk/src/types.ts:444

Cross-file content search over the workspace — the core primitive under the Search panel (and future quick-open / find-references). Runs a native search engine in the host (off the UI thread), honoring .gitignore, and resolves with matches grouped by file. See SearchService.


theme

ts
readonly theme: ThemeService;

Defined in: packages/sdk/src/types.ts:451

Consumer API for the theme domain — read the merged preset set + active theme, switch themes, and manage custom themes. Read via getState / subscribe; contribute a new preset via ExtensionContext.registerThemePreset.


dnd

ts
readonly dnd: DndService;

Defined in: packages/sdk/src/types.ts:458

Drag-and-drop — be a drag source (DndService.beginDrag) and a drop target (DndService.registerDropTarget), with typed payloads (DND_MIME) that interoperate across extensions. The host owns the drag affordance and the modifier-mode resolution.


ui

ts
readonly ui: UiService;

Defined in: packages/sdk/src/types.ts:465

User-interaction — the only sanctioned way to talk to the user (the host renders the chrome). Native file/folder pickers (UiService.pickFolder, UiService.pickFile, UiService.savePath) and transient toast notifications (UiService.notify). Mirrors VS Code's window.show*.

Methods

registerEditor()

ts
registerEditor(editor): Disposable;

Defined in: packages/sdk/src/types.ts:375

Register an Editor (a presenter for a file type's editor tab).

Parameters

editor

Editor

Returns

Disposable


registerFileType()

ts
registerFileType(type): Disposable;

Defined in: packages/sdk/src/types.ts:377

Register a FileType (declarative file metadata).

Parameters

type

FileType

Returns

Disposable


registerCommand()

ts
registerCommand(cmd): Disposable;

Defined in: packages/sdk/src/types.ts:379

Register a Command (a named, invokable action).

Parameters

cmd

Command

Returns

Disposable


registerMenuItem()

ts
registerMenuItem(item): Disposable;

Defined in: packages/sdk/src/types.ts:381

Register a MenuItemContribution (place a command in a menu).

Parameters

item

MenuItemContribution

Returns

Disposable


registerKeybinding()

ts
registerKeybinding(binding): Disposable;

Defined in: packages/sdk/src/types.ts:383

Register a Keybinding (bind a shortcut to a command).

Parameters

binding

Keybinding

Returns

Disposable


registerSidePanel()

ts
registerSidePanel(panel): Disposable;

Defined in: packages/sdk/src/types.ts:385

Register a SidePanel (a left/right column panel).

Parameters

panel

SidePanel

Returns

Disposable


registerDockPanelKind()

ts
registerDockPanelKind(kind): Disposable;

Defined in: packages/sdk/src/types.ts:387

Register a DockPanelKind (a center-dock tab kind).

Parameters

kind

DockPanelKind

Returns

Disposable


registerStatusItem()

ts
registerStatusItem(item): Disposable;

Defined in: packages/sdk/src/types.ts:389

Register a StatusItem (a status-bar widget).

Parameters

item

StatusItem

Returns

Disposable


registerSettingsPage()

ts
registerSettingsPage(page): Disposable;

Defined in: packages/sdk/src/types.ts:391

Register a SettingsPage (a page in the Settings dialog).

Parameters

page

SettingsPage

Returns

Disposable


registerThemePreset()

ts
registerThemePreset(preset): Disposable;

Defined in: packages/sdk/src/types.ts:393

Register a ThemePreset (a selectable theme in the picker).

Parameters

preset

ThemePreset

Returns

Disposable


executeCommand()

ts
executeCommand(id): void;

Defined in: packages/sdk/src/types.ts:399

Invoke a registered command by id — including commands contributed by other extensions. The minimal "operate" primitive; pairs with the typed services for read access.

Parameters

id

string

Returns

void


getExtension()

ts
getExtension<API>(id): ExtensionHandle<API> | undefined;

Defined in: packages/sdk/src/types.ts:479

Resolve a handle to another extension in order to consume the API it published (the value its Extension.activate returned). This is how features that live outside core — git, terminal, themes — expose capabilities to other extensions.

Returns undefined if no extension with that id is known. Even when known, the handle's api is undefined until that extension has activated — so always handle absence; the provider may be disabled or activate after you. Call this at use time, not in activate.

Type Parameters

API

API = unknown

the provider's published API type (import its types package).

Parameters

id

string

Returns

ExtensionHandle<API> | undefined