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:
+14
-10
@@ -64,7 +64,7 @@ Windows is the primary platform. macOS and Linux builds are experimental.
|
||||
| `plugin_sources.rs` | Plugin downloads from Gitea releases |
|
||||
| `git.rs` | The Git service of the Git feature. It runs the `git` program. |
|
||||
| `features.rs` | Reads the old plugin packages of the native features one time, for the first-start migration. It changes no plugin file. |
|
||||
| `pty.rs`, `terminal_platform.rs` | Pseudo-terminals for the Terminal plugin |
|
||||
| `pty.rs`, `terminal_platform.rs` | The shell sessions of the Terminal feature, the shell search, and terminal windows. A session belongs to the window and the page that opened it. |
|
||||
| `browser.rs` | The process of the built-in browser engine |
|
||||
| `backgrounds.rs` | The image folder of the Background feature: the folder dialog, the kept folder (`background-folder.json` in the app data folder), the image list and reads, the sidecar file, and the folder migration from the Background Slideshow plugin |
|
||||
| `spelling.rs` | Spelling suggestions from the operating system (Windows) |
|
||||
@@ -88,7 +88,7 @@ A new command needs an entry in `generate_handler!` in `lib.rs`, in the command
|
||||
| `settings/` | The settings store (`store.ts`), and the code that moves the old browser values to the settings file (`migration.ts`) |
|
||||
| `plugins/` | The plugin runtime, the host types (`sdk.ts`, which also exports the SDK types), and Settings → Plug-ins |
|
||||
| `browser/` | The interface of the built-in browser |
|
||||
| `features/` | The native features with an off switch: the catalog (`catalog.ts`), the switches (`state.ts`), the first-start migration, the loader, the launch rules, the Background settings (`backgroundSettings.ts`), and one folder for each feature (`git/`, `background/`). See [Native features](#native-features). |
|
||||
| `features/` | The native features with an off switch: the catalog (`catalog.ts`), the switches (`state.ts`), the first-start migration, the loader, the launch rules, the Background settings (`backgroundSettings.ts`), and one folder for each feature (`git/`, `background/`, `terminal/`). The main-bundle files of Terminal are `terminalKeys.ts`, `terminalSettings.ts`, `terminalHost.ts`, `TerminalHost.svelte`, and `TerminalSettings.svelte`. See [Native features](#native-features). |
|
||||
| `completion/` | Contracts and services that plugins use |
|
||||
| `git/` | The Git service and its types, for the Git feature and the line history in the status bar |
|
||||
| `theme/` | Appearance settings, palettes, and the theme tokens (`tokens.css`) |
|
||||
@@ -116,7 +116,7 @@ A new command needs an entry in `generate_handler!` in `lib.rs`, in the command
|
||||
| Documents | Ordinary files in the workspace folder |
|
||||
| Workspace state: tab order, pins, bookmarks, templates, Project Management boards | `.runestone/` in the workspace |
|
||||
| Installed plugins and their settings | The app data folder. See [plugin storage](plugin-host.md#storage-and-recovery). |
|
||||
| Preferences: general settings, appearance, custom themes, display language, feature switches, Background | `settings.json` in the app config folder |
|
||||
| Preferences: general settings, appearance, custom themes, display language, feature switches, Background, Terminal | `settings.json` in the app config folder |
|
||||
| The image folder of Background | `background-folder.json` in the app data folder. The image of the image source stays in the WebView storage (IndexedDB). |
|
||||
| Browser profiles, bookmarks, history, browser settings, and Chromium caches | `browser/` in the local app data folder. On Windows, this is `%LOCALAPPDATA%\com.runestone.app\browser\`. See [Built-in browser runtime](#built-in-browser-runtime). |
|
||||
| Window layout and the open tabs of each workspace | The WebView storage (`localStorage`) of the app. RuneStone can lose these values without harm. |
|
||||
@@ -136,14 +136,15 @@ On macOS, it is `~/Library/Application Support/<identifier>/`. On Linux, it is `
|
||||
"customThemes": [],
|
||||
"customThemesLegacy": [],
|
||||
"language": "en",
|
||||
"features": { "git": true, "background": true },
|
||||
"background": { "source": "folder", "seconds": 60, "order": "name", "paused": false, "targets": ["app"], "overlay": 0, "position": "center", "size": "cover" }
|
||||
"features": { "git": true, "background": true, "terminal": true },
|
||||
"background": { "source": "folder", "seconds": 60, "order": "name", "paused": false, "targets": ["app"], "overlay": 0, "position": "center", "size": "cover" },
|
||||
"terminal": { "defaultProfile": "", "fontSize": 13, "scrollback": 10000, "cursorBlink": true }
|
||||
}
|
||||
```
|
||||
|
||||
| Rule | Detail |
|
||||
| --- | --- |
|
||||
| Sections | `general`, `appearance`, `customThemes`, `customThemesLegacy` (the original version 1 themes), `language`, `features` (the switches of the native features), and `background` (the source, the timing, the targets, and the folder layout of Background). The host does not interpret their values. The frontend normalizes each section. |
|
||||
| Sections | `general`, `appearance`, `customThemes`, `customThemesLegacy` (the original version 1 themes), `language`, `features` (the switches of the native features), `background` (the source, the timing, the targets, and the folder layout of Background), and `terminal` (the default profile, the font size, the scrollback, and the cursor of Terminal). The host does not interpret their values. The frontend normalizes each section. |
|
||||
| Size | At most 8 MiB in total. The appearance can hold an image data URL of up to 3,000,000 characters. |
|
||||
| Writes | `settings_write` replaces one section. The host writes a complete temporary file and renames it. Then it sends `settings-changed` to all windows with the section, the revision, and the value. |
|
||||
| Damaged file | The host moves the file to `settings.corrupt-<seconds>.json` and writes a new file with the defaults. The first window that reads the settings shows a message one time. |
|
||||
@@ -208,7 +209,7 @@ Errors of the plugin API stay in English, because they are for plugin developers
|
||||
|
||||
## Native features
|
||||
|
||||
Git and Background are native features: host code with an off switch in **Settings → Features**. They do not use the plugin API.
|
||||
Git, Background, and Terminal are native features: host code with an off switch in **Settings → Features**. They do not use the plugin API.
|
||||
|
||||
| Part | File |
|
||||
| --- | --- |
|
||||
@@ -224,6 +225,10 @@ Git and Background are native features: host code with an off switch in **Settin
|
||||
- A command without a view loads the feature and calls `FeatureInstance.run`. A launch rule starts the instance at once when it wants it, and again after each change of its settings.
|
||||
- Background has a launch rule: it loads when the `background` section selects a folder, or an image that exists. Its settings section and its "has a source" test are in `src/lib/features/backgroundSettings.ts`, in the main bundle. It also runs in browser windows. In the settings window, only its settings component loads (`mountSettings`).
|
||||
- The first start makes the `background` section from the kept settings of the Background Slideshow plugin and from the old background image. `background_migrate` copies the folder of the old plugin grant to the host only when the host has no folder.
|
||||
- Terminal has no view and no launch rule. `TerminalHost.svelte` puts the panel in the workbench and in the terminal window, and the first use loads the module. `terminalKeys.ts` holds the shortcuts and the Help rows. Settings → Terminal (`TerminalSettings.svelte`) loads no xterm.
|
||||
- `@xterm/xterm` and `@xterm/addon-fit` are host dependencies. `pnpm check:features` keeps them out of the start chunks.
|
||||
- The first start makes the `terminal` section from the `runestone.terminal` key of `localStorage`, which the Terminal plugin wrote. The old key stays.
|
||||
- Before Terminal goes off, Settings asks `pty_running` for the shells of all windows. Off closes the sessions of each window.
|
||||
- Host code never imports a feature folder statically. `pnpm check:features` builds the app. It fails when a feature module, or a library that only a feature needs, is in a chunk that loads at start.
|
||||
- Saved tabs and tab transfers keep the ID of the old plugin package as the owner ID, for example `runestone.git`. `builtInPackages` in `external.ts` lists the old package, so it never loads.
|
||||
- Off stops the feature at once in each window and closes its views. The loaded module stays in memory until the window reloads.
|
||||
@@ -270,7 +275,6 @@ A test states what it needs near its top. The runner skips the test, with the re
|
||||
|
||||
| Line | Requirement |
|
||||
| --- | --- |
|
||||
| `// @requires plugin:terminal` | The compiled Terminal plugin |
|
||||
| `// @requires repo:RuneStone_Local_Autocomplete/src` | A file or folder in a sibling plugin checkout |
|
||||
| `// @requires electron` | The browser engine dependencies. Run `npm ci --prefix browser-runtime`. |
|
||||
| `// @known-issue <defect>` | The test fails because of a known app defect. The run reports it as `known`. If the test passes, the run fails, so that someone removes the line. |
|
||||
@@ -279,14 +283,14 @@ A test states what it needs near its top. The runner skips the test, with the re
|
||||
| --- | --- |
|
||||
| `SMOKE_URL` | The frontend address. The default is `http://127.0.0.1:1420`. When the runner starts Vite, it uses the port of this address, so two checkouts can run tests at the same time. |
|
||||
| `RUNESTONE_PLUGIN_REPOS` | The folder of the sibling plugin checkouts. The default is the parent folder of this repository. |
|
||||
| `RUNESTONE_TERMINAL_DIST` | The compiled Terminal plugin. The default is `RuneStone_Terminal/dist` in that folder. |
|
||||
| `RUNESTONE_CSP` | `1` sends and checks the content security policy. `--csp` sets it. |
|
||||
| `CHROME_PATH` | A Chromium browser for Playwright |
|
||||
| `PLAYWRIGHT_MODULE` | A different Playwright package |
|
||||
|
||||
To write a smoke test, start from an existing test in the same area. The harness in `tests/smoke/_harness/index.mjs` starts the browser, mocks the Tauri commands, and gives an in-memory workspace.
|
||||
|
||||
The harness also has default handlers for the settings file and for tab transfers. All pages of one browser context share them.
|
||||
The harness also has default handlers for the settings file, for tab transfers, and for the `pty_*` shells of Terminal. All pages of one browser context share them.
|
||||
The mock shell sends its output through the channel of `pty_open`. To send more, use `window.__TEST__.pty.output(id, text)` and `window.__TEST__.pty.exit(id, code)`.
|
||||
To seed preferences, set the old `localStorage` keys before the first load. The app then migrates them.
|
||||
To read or change a section later, use `window.__TEST__.settings(section)` and `window.__TEST__.writeSettings(section, value)`.
|
||||
A failed test saves `failure.png` in its output folder and prints the page console errors and warnings.
|
||||
|
||||
Reference in New Issue
Block a user