Selkies
Developer ReferenceWeb client coreLib

lib/app-commands

Apps-panel command contract, shared by both dashboards.

The UI applies install and remove results optimistically, so every posted command is tracked here until the server's command watch settles it: a clean exit comes back as command_done and only clears the running state, a failure as a command_error system action whose message ends with the echoed command string, and matching that rolls the optimistic update back. Commands run through a shell on the server, in the environment of the session the applications use, so ~ in a launch command is the session user's home.

Which apps are installed is the server's answer, arriving with the server settings and again as an apps_installed system action when a command changes it. What is stored locally is a cache of it, so a panel opened before the server speaks shows the last answer rather than nothing.

Variables

INSTALLED_APPS_ROLLBACK_EVENT

const INSTALLED_APPS_ROLLBACK_EVENT: "installedAppsRollback" = "installedAppsRollback";

Defined in: lib/app-commands.js:22

Window event dispatched when a failed install or remove is rolled back.


INSTALLED_APPS_SERVER_EVENT

const INSTALLED_APPS_SERVER_EVENT: "installedAppsFromServer" = "installedAppsFromServer";

Defined in: lib/app-commands.js:25

Window event dispatched when the server's installed-apps list replaces the stored one.


APP_COMMAND_STATE_EVENT

const APP_COMMAND_STATE_EVENT: "appCommandState" = "appCommandState";

Defined in: lib/app-commands.js:28

Window event dispatched whenever the set of running commands changes.

Functions

pendingAppAction()

function pendingAppAction(app): "install" | "remove" | "update" | "launch";

Defined in: lib/app-commands.js:58

The action running for an app, so a list can show it and hold its buttons.

Parameters

ParameterTypeDescription
appstringThe app name.

Returns

"install" | "remove" | "update" | "launch"


resolveFinishedAppCommand()

function resolveFinishedAppCommand(command): void;

Defined in: lib/app-commands.js:70

Settles a command the server reported finishing cleanly. The optimistic update already holds, so this only stops it reading as still running.

Parameters

ParameterTypeDescription
commandstringThe echoed command string.

Returns

void


postAppCommand()

function postAppCommand(action, app): void;

Defined in: lib/app-commands.js:90

Posts an app command to the core and records it as pending.

Parameters

ParameterTypeDescription
action"install" | "remove" | "update" | "launch"The command to build.
appstringThe app name the command applies to.

Returns

void


applyServerInstalledApps()

function applyServerInstalledApps(apps): boolean;

Defined in: lib/app-commands.js:110

Adopts the installed-apps list the server reported.

A command still in flight is left alone: its optimistic update is newer than a list read before it ran.

Parameters

ParameterTypeDescription
appsstring[]App names the server reports installed; a payload that carries none at all is left to the stored list.

Returns

boolean

Whether the stored list changed.


readInstalledApps()

function readInstalledApps(): string[];

Defined in: lib/app-commands.js:135

Reads the stored installed-apps list.

Returns

string[]

The app names, empty when nothing valid is stored.


writeInstalledApps()

function writeInstalledApps(apps): void;

Defined in: lib/app-commands.js:150

Parameters

ParameterTypeDescription
appsstring[]The installed-apps list to store.

Returns

void


resolveFailedAppCommand()

function resolveFailedAppCommand(errMsg): boolean;

Defined in: lib/app-commands.js:165

Settles a failed-command notification against the pending map.

A matched launch command older than the failure window is application lifecycle (the app ran, then exited nonzero), so it is suppressed. A matched install or remove rolls back the stored installed-apps list and notifies mounted lists through INSTALLED_APPS_ROLLBACK_EVENT; an unmatched failure is someone else's command and passes through untouched.

Parameters

ParameterTypeDescription
errMsgstringThe command_error message.

Returns

boolean

Whether the notice should be shown.

On this page

Edit on GitHub