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:
Knotty Wyvern
2026-10-29 19:02:58 -07:00
parent 53b9cea7f0
commit 833f793244
78 changed files with 2971 additions and 659 deletions
+15 -14
View File
@@ -5,9 +5,9 @@ import { ExternalSession } from "../../../src/lib/plugins/externalSession.ts";
import type { PluginApi } from "../../../src/lib/plugins/sdk.ts";
import type { Contributions } from "../../../src/lib/plugins/contracts.ts";
// A small test-only package. It contributes a feature, as the optional plugins do.
const terminal: Contributions["terminal"] = { mount: () => ({ update() {}, command() {}, dispose() {} }), shortcut: () => null };
const activate = (api: PluginApi) => { api.contribute("terminal", terminal); };
// A small test-only package. It contributes the browser, as the built-in browser module does.
const browser: Contributions["browser"] = { mountSettings: () => () => {}, mountBookmarks: () => () => {}, open: async () => false };
const activate = (api: PluginApi) => { api.contribute("browser", browser); };
const services = {
workspace: { list: async () => [], read: async () => "", write: async () => {} },
@@ -37,23 +37,24 @@ test("optional workspace creation and reads stop when the plugin is disabled", a
assert.equal(files.size, 1);
});
test("core starts without optional features and package contributions end with their session", async () => {
assert.equal(pluginHost.get("terminal"), undefined);
assert.equal(pluginHost.get("browser"), undefined);
const registry = new ContributionRegistry();
const session = new ExternalSession("org.test.feature", services, () => {}, () => {}, registry);
await session.start({ activate });
assert.equal(registry.get("terminal"), terminal);
assert.equal(registry.get("browser"), browser);
await session.stop();
assert.equal(registry.get("terminal"), undefined);
assert.equal(registry.get("browser"), undefined);
const next = new ExternalSession("org.test.feature", services, () => {}, () => {}, registry);
await next.start({ activate });
assert.equal(registry.get("terminal"), terminal);
assert.equal(registry.get("browser"), browser);
await next.stop();
assert.equal(registry.get("terminal"), undefined);
assert.equal(registry.get("browser"), undefined);
});
test("unknown contribution keys are rejected", () => {
const registry = new ContributionRegistry();
for (const key of ["tableFormulas", "git"]) assert.throws(() => registry.register("old", key as keyof Contributions, terminal as never), /Unknown plugin contribution/);
// `terminal` was a contribution until the Terminal feature became native.
for (const key of ["tableFormulas", "git", "terminal"]) assert.throws(() => registry.register("old", key as keyof Contributions, browser as never), /Unknown plugin contribution/);
});
test("package contribution conflicts preserve the first owner and revoke access before cleanup", async () => {
@@ -62,13 +63,13 @@ test("package contribution conflicts preserve the first owner and revoke access
const second = new ExternalSession("second", services, () => {}, () => {}, registry);
let api!: PluginApi;
await first.start({ activate(value) { api = value; activate(api); } });
const contribution = registry.get("terminal");
const contribution = registry.get("browser");
await assert.rejects(second.start({ activate }), /already registered/);
await second.stop();
assert.equal(registry.get("terminal"), contribution);
assert.equal(registry.get("browser"), contribution);
api.onDispose(() => {
assert.equal(registry.get("terminal"), undefined);
assert.throws(() => api.contribute("terminal", contribution!), /disabled/);
assert.equal(registry.get("browser"), undefined);
assert.throws(() => api.contribute("browser", contribution!), /disabled/);
});
await first.stop();
});
@@ -82,5 +83,5 @@ test("partial activation and failed cleanup cannot retain feature contributions"
throw new Error("Activation failed");
} }), /Activation failed/);
await assert.rejects(session.stop(), /Cleanup failed/);
assert.equal(registry.get("terminal"), undefined);
assert.equal(registry.get("browser"), undefined);
});