Make Terminal a native feature
- Move the Terminal plugin into src/lib/features/terminal/ on the host Svelte runtime, with xterm 6.0.0 and addon-fit 0.11.0. - Buttons, shortcuts, Help rows, and the close guard follow the Terminal switch. The first use loads the module. - Add Settings → Terminal and the terminal settings section. The first start copies the old runestone.terminal key. - The 16 ANSI colors come from the --rs-ansi-* tokens. - Off asks first when a shell runs in any window (pty_running). - Rust: no pty-data or pty-exit events, an owner check for write, resize, and close, output joined up to 64 KiB or 8 ms, and the sessions of a reloaded page close. - Remove api.pty, the terminal contribution, TerminalSlot, and the plugin loader of the smoke harness. - Check only the tested switches in the Background smoke test. - Update the tests, the menu inventory, the docs, and UI-058.
This commit is contained in:
@@ -15,8 +15,7 @@ import type { ActionMenuItem as HostMenuItem } from "../../../src/lib/ui/actionM
|
||||
import type { MenuOptions as HostMenuOptions } from "../../../src/lib/ui/managedActionMenu.ts";
|
||||
import type { ActionMenuItem, ActionMenuOptions } from "../../../packages/plugin-sdk/src/index.ts";
|
||||
|
||||
// The host menu files must match the copies in the Terminal plugin (scripts/menuSurfaceAudit.mjs), so they keep
|
||||
// their own menu types. `pnpm check` fails when those types and the SDK types differ.
|
||||
// The host menu files keep their own menu types. `pnpm check` fails when those types and the SDK types differ.
|
||||
type Same<A, B> = [A] extends [B] ? ([B] extends [A] ? true : false) : false;
|
||||
const sameMenuTypes: [Same<HostMenuItem, ActionMenuItem>, Same<HostMenuOptions, ActionMenuOptions>] = [true, true];
|
||||
|
||||
@@ -40,15 +39,17 @@ test("feature checks find optional members, and missing members give an update m
|
||||
assert.equal(hasFeature(api, "workspace.readBytes"), true);
|
||||
assert.equal(hasFeature(api, "services"), true);
|
||||
assert.equal(hasFeature(api, "workspace.subscribe"), false);
|
||||
assert.equal(hasFeature(api, "pty"), false);
|
||||
assert.deepEqual(missingFeatures(api, ["pty", "workspace.readBytes", "settings.subscribe"]), ["pty", "settings.subscribe"]);
|
||||
assert.equal(hasFeature(api, "files"), false);
|
||||
assert.deepEqual(missingFeatures(api, ["files", "workspace.readBytes", "settings.subscribe"]), ["files", "settings.subscribe"]);
|
||||
assert.equal(requireFeature(api, "services"), (api as unknown as { services: unknown }).services);
|
||||
assert.throws(() => requireFeature(api, "pty"), (error: unknown) => error instanceof MissingFeatureError
|
||||
&& error.name === "MissingFeatureError" && error.features.length === 1 && error.features[0] === "pty"
|
||||
&& error.message === "This plugin needs the terminal API (api.pty). Update RuneStone to a version that has this feature.");
|
||||
assert.throws(() => requireFeatures(api, ["pty", "files", "workspace.readBytes"]), {
|
||||
message: "This plugin needs the terminal API (api.pty) and the folder grant API (api.files). Update RuneStone to a version that has these features.",
|
||||
assert.throws(() => requireFeature(api, "files"), (error: unknown) => error instanceof MissingFeatureError
|
||||
&& error.name === "MissingFeatureError" && error.features.length === 1 && error.features[0] === "files"
|
||||
&& error.message === "This plugin needs the folder grant API (api.files). Update RuneStone to a version that has this feature.");
|
||||
assert.throws(() => requireFeatures(api, ["files", "backgrounds", "workspace.readBytes"]), {
|
||||
message: "This plugin needs the folder grant API (api.files) and the background API (api.backgrounds). Update RuneStone to a version that has these features.",
|
||||
});
|
||||
// The terminal API (api.pty) left the SDK when Terminal became a native feature.
|
||||
assert.throws(() => hasFeature(api, "pty" as never), TypeError);
|
||||
assert.doesNotThrow(() => requireFeatures(api, ["services", "workspace.readBytes"]));
|
||||
assert.throws(() => hasFeature(api, "workspace.read" as never), TypeError);
|
||||
assert.equal(describeFeature("ui.showActionMenu"), "the shared action menu (api.ui.showActionMenu)");
|
||||
@@ -63,10 +64,9 @@ test("a required function stays bound to its parent object", async () => {
|
||||
});
|
||||
|
||||
test("the current host gives every SDK feature when all services are present", async () => {
|
||||
const pty = { open: async () => {}, write: async () => {}, resize: async () => {}, close: async () => {}, profiles: async () => [], openWindow: async () => {}, dictation: async () => {} };
|
||||
const files = { chooseFolder: async () => null, pictureFolder: async () => ({ id: "g", path: "p", name: "n" }), grants: async () => [], revoke: async () => false, list: async () => [], readBytes: async () => new Uint8Array(), readSidecar: async () => null, writeSidecar: async () => {} };
|
||||
const { api, session } = await hostApi({
|
||||
pty, files, backgrounds: true, serviceHub: new ServiceHub(), openFile: async () => {}, completionTransport: async () => {},
|
||||
files, backgrounds: true, serviceHub: new ServiceHub(), openFile: async () => {}, completionTransport: async () => {},
|
||||
workspace: { ...base.workspace, listMarkdown: async () => [], readMany: async () => [], readBytes: async () => new Uint8Array(), readOptional: async () => null, create: async () => {}, subscribe: () => () => {} },
|
||||
settings: { ...base.settings, subscribe: () => () => {} },
|
||||
}, true);
|
||||
@@ -78,7 +78,7 @@ test("the host without optional services lacks only the features that depend on
|
||||
const { api, session } = await hostApi({});
|
||||
assert.deepEqual(missingFeatures(api, pluginFeatures).sort(), [
|
||||
"backgrounds", "closeView", "completion.transport", "files",
|
||||
"openFile", "pty", "renameDocument", "replaceDocumentWithView", "replaceView", "settings.subscribe",
|
||||
"openFile", "renameDocument", "replaceDocumentWithView", "replaceView", "settings.subscribe",
|
||||
"workspace.create", "workspace.listMarkdown", "workspace.readBytes", "workspace.readMany", "workspace.readOptional", "workspace.subscribe",
|
||||
]);
|
||||
await session.stop();
|
||||
|
||||
Reference in New Issue
Block a user