@eum-agent/web-shell 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +68 -12
- package/dist/schema.js +55 -1
- package/package.json +4 -4
- package/ui/ui.js +345 -81
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Changed, CloseParams, CreateParams, ListResult, OperationResult,
|
|
1
|
+
import { Changed, CloseParams, CloseTerminalsParams, CloseTerminalsResult, CreateParams, ListResult, OperationResult, OperationStatusesParams, OperationStatusesResult, RenameParams, RestartParams, RootsResult, TerminalInput, TerminalOpen, TerminalOutput, TerminalReady, TerminalSummary, WorkspaceId } from "./schema.js";
|
|
2
2
|
import { existsSync } from "node:fs";
|
|
3
3
|
import { userInfo } from "node:os";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
@@ -635,7 +635,7 @@ function createWebShell(options) {
|
|
|
635
635
|
return terminal.flow.open(input, context);
|
|
636
636
|
},
|
|
637
637
|
/** Removes a terminal after confirmed PTY/group cleanup, retaining operation facts and failures. */
|
|
638
|
-
closeTerminal(raw) {
|
|
638
|
+
closeTerminal(raw, changed = () => notify(raw.workspaceId)) {
|
|
639
639
|
const input = CloseParams.parse(raw);
|
|
640
640
|
return operation(input.operationId, JSON.stringify(["close", input]), async () => {
|
|
641
641
|
if (input.instanceId !== identity.instanceId) throw new TerminalError("context-mismatch");
|
|
@@ -645,12 +645,12 @@ function createWebShell(options) {
|
|
|
645
645
|
if (input.endedRunId !== void 0) {
|
|
646
646
|
if (terminal.summary.status !== "ended" || terminal.summary.runId !== input.endedRunId) throw new TerminalError("terminal-run-changed");
|
|
647
647
|
terminals.delete(terminal.summary.id);
|
|
648
|
-
|
|
648
|
+
changed();
|
|
649
649
|
return terminal.summary;
|
|
650
650
|
}
|
|
651
651
|
await finish(terminal);
|
|
652
652
|
terminals.delete(terminal.summary.id);
|
|
653
|
-
|
|
653
|
+
changed();
|
|
654
654
|
return terminal.summary;
|
|
655
655
|
});
|
|
656
656
|
},
|
|
@@ -680,6 +680,41 @@ function createWebShell(options) {
|
|
|
680
680
|
};
|
|
681
681
|
}
|
|
682
682
|
//#endregion
|
|
683
|
+
//#region src/collections.ts
|
|
684
|
+
/** Bounded terminal collections preserve independent retained physical outcomes. */
|
|
685
|
+
/** Runs owner-bound members in input order; actual oversize results fail only their member. */
|
|
686
|
+
async function terminalCollection(targets, signal, work, maxItemBytes = Math.floor(8380416 / targets.length)) {
|
|
687
|
+
const results = [];
|
|
688
|
+
for (const [index, target] of targets.entries()) {
|
|
689
|
+
signal.throwIfAborted();
|
|
690
|
+
try {
|
|
691
|
+
const value = await work(target);
|
|
692
|
+
signal.throwIfAborted();
|
|
693
|
+
const member = {
|
|
694
|
+
index,
|
|
695
|
+
target,
|
|
696
|
+
ok: true,
|
|
697
|
+
value
|
|
698
|
+
};
|
|
699
|
+
if (new TextEncoder().encode(JSON.stringify(member)).byteLength > maxItemBytes) throw new TerminalError("read-limit", 413);
|
|
700
|
+
results.push(member);
|
|
701
|
+
} catch (error) {
|
|
702
|
+
signal.throwIfAborted();
|
|
703
|
+
const code = error instanceof TerminalError ? error.code : "terminal-request-failed";
|
|
704
|
+
results.push({
|
|
705
|
+
index,
|
|
706
|
+
target,
|
|
707
|
+
ok: false,
|
|
708
|
+
error: {
|
|
709
|
+
code,
|
|
710
|
+
message: code
|
|
711
|
+
}
|
|
712
|
+
});
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
return { results };
|
|
716
|
+
}
|
|
717
|
+
//#endregion
|
|
683
718
|
//#region src/index.ts
|
|
684
719
|
/** Sessionless host-account terminals; registration exposes no Agent tools or approvals. */
|
|
685
720
|
/** Registers one activation's terminal directory and awaited shutdown drain. */
|
|
@@ -757,16 +792,37 @@ function registerWebShell(ctx) {
|
|
|
757
792
|
handle: (params) => provider.rename(params)
|
|
758
793
|
});
|
|
759
794
|
ctx.client.registerMethod({
|
|
760
|
-
name: "
|
|
761
|
-
params:
|
|
762
|
-
result:
|
|
763
|
-
handle: (params) =>
|
|
795
|
+
name: "closeTerminals",
|
|
796
|
+
params: CloseTerminalsParams,
|
|
797
|
+
result: CloseTerminalsResult,
|
|
798
|
+
handle: async (params) => {
|
|
799
|
+
let dirty = false;
|
|
800
|
+
try {
|
|
801
|
+
return await terminalCollection(params.items, ctx.signal, (item) => provider.closeTerminal({
|
|
802
|
+
instanceId: params.instanceId,
|
|
803
|
+
workspaceId: params.workspaceId,
|
|
804
|
+
...item
|
|
805
|
+
}, () => {
|
|
806
|
+
dirty = true;
|
|
807
|
+
}));
|
|
808
|
+
} finally {
|
|
809
|
+
if (dirty) try {
|
|
810
|
+
changed.emit({
|
|
811
|
+
instanceId: params.instanceId,
|
|
812
|
+
workspaceId: params.workspaceId
|
|
813
|
+
});
|
|
814
|
+
} catch {}
|
|
815
|
+
}
|
|
816
|
+
}
|
|
764
817
|
});
|
|
765
818
|
ctx.client.registerMethod({
|
|
766
|
-
name: "
|
|
767
|
-
params:
|
|
768
|
-
result:
|
|
769
|
-
handle: (params) => provider.operationStatus(
|
|
819
|
+
name: "operationStatuses",
|
|
820
|
+
params: OperationStatusesParams,
|
|
821
|
+
result: OperationStatusesResult,
|
|
822
|
+
handle: (params) => terminalCollection(params.operationIds, ctx.signal, (operationId) => provider.operationStatus({
|
|
823
|
+
instanceId: params.instanceId,
|
|
824
|
+
operationId
|
|
825
|
+
}), params.maxItemBytes)
|
|
770
826
|
});
|
|
771
827
|
ctx.client.registerStream({
|
|
772
828
|
name: "terminal",
|
package/dist/schema.js
CHANGED
|
@@ -178,5 +178,59 @@ const TerminalOutput = z.discriminatedUnion("kind", [
|
|
|
178
178
|
error: AccessError
|
|
179
179
|
}).strict()
|
|
180
180
|
]);
|
|
181
|
+
const encodedBytes = (value) => new TextEncoder().encode(JSON.stringify(value)).byteLength;
|
|
182
|
+
const CloseMember = CloseParams.omit({
|
|
183
|
+
instanceId: true,
|
|
184
|
+
workspaceId: true
|
|
185
|
+
});
|
|
186
|
+
/** Independent close intents retain their UUID and normalized input regardless of array position. */
|
|
187
|
+
const CloseTerminalsParams = z.object({
|
|
188
|
+
instanceId: z.uuid(),
|
|
189
|
+
workspaceId: WorkspaceId,
|
|
190
|
+
items: z.array(CloseMember).min(1).max(48)
|
|
191
|
+
}).strict().superRefine((input, ctx) => {
|
|
192
|
+
if (encodedBytes(input) * 2 > 8388608) ctx.addIssue({
|
|
193
|
+
code: "custom",
|
|
194
|
+
message: "Terminal input exceeds its byte budget"
|
|
195
|
+
});
|
|
196
|
+
const identities = /* @__PURE__ */ new Map();
|
|
197
|
+
for (const member of input.items) {
|
|
198
|
+
const value = JSON.stringify(member);
|
|
199
|
+
if (identities.has(member.operationId) && identities.get(member.operationId) !== value) ctx.addIssue({
|
|
200
|
+
code: "custom",
|
|
201
|
+
message: "Operation identity has conflicting members"
|
|
202
|
+
});
|
|
203
|
+
identities.set(member.operationId, value);
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
/** Read-only status collections reject declared response costs before reading any retained fact. */
|
|
207
|
+
const OperationStatusesParams = z.object({
|
|
208
|
+
instanceId: z.uuid(),
|
|
209
|
+
operationIds: z.array(z.uuid()).min(1).max(64),
|
|
210
|
+
maxItemBytes: z.number().int().min(1).max(8388608).default(262144),
|
|
211
|
+
maxTotalBytes: z.number().int().min(1).max(8388608).default(8388608)
|
|
212
|
+
}).strict().superRefine((input, ctx) => {
|
|
213
|
+
if (encodedBytes(input) * 2 > 8388608 || input.operationIds.length * input.maxItemBytes + 8192 > input.maxTotalBytes || input.operationIds.some((id) => encodedBytes(id) + 4096 > input.maxItemBytes)) ctx.addIssue({
|
|
214
|
+
code: "custom",
|
|
215
|
+
message: "Terminal collection exceeds its byte budget"
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
function collectionResult(target) {
|
|
219
|
+
return z.object({ results: z.array(z.discriminatedUnion("ok", [z.object({
|
|
220
|
+
index: z.number().int().nonnegative(),
|
|
221
|
+
target,
|
|
222
|
+
ok: z.literal(true),
|
|
223
|
+
value: OperationResult
|
|
224
|
+
}).strict(), z.object({
|
|
225
|
+
index: z.number().int().nonnegative(),
|
|
226
|
+
target,
|
|
227
|
+
ok: z.literal(false),
|
|
228
|
+
error: AccessError
|
|
229
|
+
}).strict()])).max(64) }).strict();
|
|
230
|
+
}
|
|
231
|
+
/** Ordered close outcomes preserve physical failure facts independently. */
|
|
232
|
+
const CloseTerminalsResult = collectionResult(CloseMember);
|
|
233
|
+
/** Ordered retained facts include unknown operations without replaying them. */
|
|
234
|
+
const OperationStatusesResult = collectionResult(z.uuid());
|
|
181
235
|
//#endregion
|
|
182
|
-
export { AccessError, Changed, CloseParams, CreateParams, Dimension, ListResult, OperationResult, OperationStatusParams, RelativePath, RenameParams, RestartParams, RootId, RootsResult, TerminalInput, TerminalOpen, TerminalOutput, TerminalReady, TerminalSummary, WorkspaceId };
|
|
236
|
+
export { AccessError, Changed, CloseParams, CloseTerminalsParams, CloseTerminalsResult, CreateParams, Dimension, ListResult, OperationResult, OperationStatusParams, OperationStatusesParams, OperationStatusesResult, RelativePath, RenameParams, RestartParams, RootId, RootsResult, TerminalInput, TerminalOpen, TerminalOutput, TerminalReady, TerminalSummary, WorkspaceId };
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"en-US": "Terminal",
|
|
5
5
|
"zh-CN": "终端"
|
|
6
6
|
},
|
|
7
|
-
"version": "1.
|
|
7
|
+
"version": "1.1.0",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"description": "Sessionless host-account interactive terminals",
|
|
10
10
|
"license": "MIT",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"lucide-react": "^1.40.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@eum-agent/plugin": "1.
|
|
31
|
+
"@eum-agent/plugin": "1.1.0",
|
|
32
32
|
"@eum-agent/runtime": "1.0.0",
|
|
33
33
|
"@eum-agent/protocol": "1.0.0",
|
|
34
34
|
"@types/react": "^19.2.18",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"react-dom": "^19.2.0",
|
|
38
38
|
"vite": "^8.2.2",
|
|
39
39
|
"@testing-library/react": "^16.3.3",
|
|
40
|
-
"@eum-agent/infra-local": "1.0.
|
|
40
|
+
"@eum-agent/infra-local": "1.0.1"
|
|
41
41
|
},
|
|
42
42
|
"yaoguang": {
|
|
43
43
|
"description": {
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"dependencies": {},
|
|
48
48
|
"kind": "extension",
|
|
49
49
|
"foundationDependencies": {
|
|
50
|
-
"@eum-agent/infra-local": "1.0.
|
|
50
|
+
"@eum-agent/infra-local": "1.0.1"
|
|
51
51
|
}
|
|
52
52
|
},
|
|
53
53
|
"scripts": {
|
package/ui/ui.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createContext, createElement, forwardRef, useContext, useEffect, useRef, useState, useSyncExternalStore } from "react";
|
|
2
2
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { SettingsPreview, useDeviceFonts } from "@eum-agent/host/framework";
|
|
3
4
|
//#region ../../../node_modules/.pnpm/@xterm+xterm@6.0.0/node_modules/@xterm/xterm/css/xterm.css?inline
|
|
4
5
|
var xterm_default = "/**\n * Copyright (c) 2014 The xterm.js authors. All rights reserved.\n * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)\n * https://github.com/chjj/term.js\n * @license MIT\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n *\n * Originally forked from (with the author's permission):\n * Fabrice Bellard's javascript vt100 for jslinux:\n * http://bellard.org/jslinux/\n * Copyright (c) 2011 Fabrice Bellard\n * The original design remains. The terminal itself\n * has been extended to include xterm CSI codes, among\n * other features.\n */\n\n/**\n * Default styles for xterm.js\n */\n\n.xterm {\n cursor: text;\n position: relative;\n user-select: none;\n -ms-user-select: none;\n -webkit-user-select: none;\n}\n\n.xterm.focus,\n.xterm:focus {\n outline: none;\n}\n\n.xterm .xterm-helpers {\n position: absolute;\n top: 0;\n /**\n * The z-index of the helpers must be higher than the canvases in order for\n * IMEs to appear on top.\n */\n z-index: 5;\n}\n\n.xterm .xterm-helper-textarea {\n padding: 0;\n border: 0;\n margin: 0;\n /* Move textarea out of the screen to the far left, so that the cursor is not visible */\n position: absolute;\n opacity: 0;\n left: -9999em;\n top: 0;\n width: 0;\n height: 0;\n z-index: -5;\n /** Prevent wrapping so the IME appears against the textarea at the correct position */\n white-space: nowrap;\n overflow: hidden;\n resize: none;\n}\n\n.xterm .composition-view {\n /* TODO: Composition position got messed up somewhere */\n background: #000;\n color: #FFF;\n display: none;\n position: absolute;\n white-space: nowrap;\n z-index: 1;\n}\n\n.xterm .composition-view.active {\n display: block;\n}\n\n.xterm .xterm-viewport {\n /* On OS X this is required in order for the scroll bar to appear fully opaque */\n background-color: #000;\n overflow-y: scroll;\n cursor: default;\n position: absolute;\n right: 0;\n left: 0;\n top: 0;\n bottom: 0;\n}\n\n.xterm .xterm-screen {\n position: relative;\n}\n\n.xterm .xterm-screen canvas {\n position: absolute;\n left: 0;\n top: 0;\n}\n\n.xterm-char-measure-element {\n display: inline-block;\n visibility: hidden;\n position: absolute;\n top: 0;\n left: -9999em;\n line-height: normal;\n}\n\n.xterm.enable-mouse-events {\n /* When mouse events are enabled (eg. tmux), revert to the standard pointer cursor */\n cursor: default;\n}\n\n.xterm.xterm-cursor-pointer,\n.xterm .xterm-cursor-pointer {\n cursor: pointer;\n}\n\n.xterm.column-select.focus {\n /* Column selection mode */\n cursor: crosshair;\n}\n\n.xterm .xterm-accessibility:not(.debug),\n.xterm .xterm-message {\n position: absolute;\n left: 0;\n top: 0;\n bottom: 0;\n right: 0;\n z-index: 10;\n color: transparent;\n pointer-events: none;\n}\n\n.xterm .xterm-accessibility-tree:not(.debug) *::selection {\n color: transparent;\n}\n\n.xterm .xterm-accessibility-tree {\n font-family: monospace;\n user-select: text;\n white-space: pre;\n}\n\n.xterm .xterm-accessibility-tree > div {\n transform-origin: left;\n width: fit-content;\n}\n\n.xterm .live-region {\n position: absolute;\n left: -9999px;\n width: 1px;\n height: 1px;\n overflow: hidden;\n}\n\n.xterm-dim {\n /* Dim should not apply to background, so the opacity of the foreground color is applied\n * explicitly in the generated class and reset to 1 here */\n opacity: 1 !important;\n}\n\n.xterm-underline-1 { text-decoration: underline; }\n.xterm-underline-2 { text-decoration: double underline; }\n.xterm-underline-3 { text-decoration: wavy underline; }\n.xterm-underline-4 { text-decoration: dotted underline; }\n.xterm-underline-5 { text-decoration: dashed underline; }\n\n.xterm-overline {\n text-decoration: overline;\n}\n\n.xterm-overline.xterm-underline-1 { text-decoration: overline underline; }\n.xterm-overline.xterm-underline-2 { text-decoration: overline double underline; }\n.xterm-overline.xterm-underline-3 { text-decoration: overline wavy underline; }\n.xterm-overline.xterm-underline-4 { text-decoration: overline dotted underline; }\n.xterm-overline.xterm-underline-5 { text-decoration: overline dashed underline; }\n\n.xterm-strikethrough {\n text-decoration: line-through;\n}\n\n.xterm-screen .xterm-decoration-container .xterm-decoration {\n z-index: 6;\n position: absolute;\n}\n\n.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer {\n z-index: 7;\n}\n\n.xterm-decoration-overview-ruler {\n z-index: 8;\n position: absolute;\n top: 0;\n right: 0;\n pointer-events: none;\n}\n\n.xterm-decoration-top {\n z-index: 2;\n position: relative;\n}\n\n\n\n/* Derived from vs/base/browser/ui/scrollbar/media/scrollbar.css */\n\n/* xterm.js customization: Override xterm's cursor style */\n.xterm .xterm-scrollable-element > .scrollbar {\n cursor: default;\n}\n\n/* Arrows */\n.xterm .xterm-scrollable-element > .scrollbar > .scra {\n cursor: pointer;\n font-size: 11px !important;\n}\n\n.xterm .xterm-scrollable-element > .visible {\n opacity: 1;\n\n /* Background rule added for IE9 - to allow clicks on dom node */\n background:rgba(0,0,0,0);\n\n transition: opacity 100ms linear;\n /* In front of peek view */\n z-index: 11;\n}\n.xterm .xterm-scrollable-element > .invisible {\n opacity: 0;\n pointer-events: none;\n}\n.xterm .xterm-scrollable-element > .invisible.fade {\n transition: opacity 800ms linear;\n}\n\n/* Scrollable Content Inset Shadow */\n.xterm .xterm-scrollable-element > .shadow {\n position: absolute;\n display: none;\n}\n.xterm .xterm-scrollable-element > .shadow.top {\n display: block;\n top: 0;\n left: 3px;\n height: 3px;\n width: 100%;\n box-shadow: var(--vscode-scrollbar-shadow, #000) 0 6px 6px -6px inset;\n}\n.xterm .xterm-scrollable-element > .shadow.left {\n display: block;\n top: 3px;\n left: 0;\n height: 100%;\n width: 3px;\n box-shadow: var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset;\n}\n.xterm .xterm-scrollable-element > .shadow.top-left-corner {\n display: block;\n top: 0;\n left: 0;\n height: 3px;\n width: 3px;\n}\n.xterm .xterm-scrollable-element > .shadow.top.left {\n box-shadow: var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset;\n}\n";
|
|
5
6
|
//#endregion
|
|
@@ -10,7 +11,16 @@ var CATALOGUES = {
|
|
|
10
11
|
settingsReadFailed: "Could not read settings in this browser. Defaults are in use.",
|
|
11
12
|
settingsWriteFailed: "Changes are applied but could not be saved in this browser; reloading may lose them.",
|
|
12
13
|
settingsText: "Text display",
|
|
14
|
+
settingsResetAppearance: "Reset appearance",
|
|
15
|
+
settingsPreview: "Preview",
|
|
16
|
+
settingsPreviewInfo: "Preview information",
|
|
17
|
+
settingsPreviewTerminal: "Terminal output",
|
|
18
|
+
settingsPreviewHint: "This fixed sample updates with your font, size and cursor choices, using system fallbacks for missing fonts. It sends no messages and runs no commands.",
|
|
13
19
|
settingsFontFamily: "Font Family",
|
|
20
|
+
settingsFontFamilyDefault: "Terminal default",
|
|
21
|
+
settingsFontMonospace: "System monospace",
|
|
22
|
+
settingsFontDiscoveryFailed: "Could not read device fonts",
|
|
23
|
+
settingsFontDiscoveryUnavailable: "Device fonts unavailable",
|
|
14
24
|
settingsFontFamilyError: "Enter a font family, up to 512 characters.",
|
|
15
25
|
settingsFontSize: "Font size",
|
|
16
26
|
settingsFontSizeError: "Enter a whole number from 8 to 32.",
|
|
@@ -22,6 +32,8 @@ var CATALOGUES = {
|
|
|
22
32
|
settingsCursorUnderline: "Underline",
|
|
23
33
|
settingsCursorBar: "Bar",
|
|
24
34
|
settingsCursorBlink: "Blinking cursor",
|
|
35
|
+
settingsEnabled: "On",
|
|
36
|
+
settingsDisabled: "Off",
|
|
25
37
|
settingsSessions: "Sessions",
|
|
26
38
|
settingsExitBehavior: "Session retention",
|
|
27
39
|
settingsExitKeep: "Keep all",
|
|
@@ -87,7 +99,16 @@ var CATALOGUES = {
|
|
|
87
99
|
settingsReadFailed: "无法读取此浏览器的设置,已使用默认值。",
|
|
88
100
|
settingsWriteFailed: "修改已应用,但无法保存在此浏览器;刷新后可能丢失。",
|
|
89
101
|
settingsText: "文本显示",
|
|
102
|
+
settingsResetAppearance: "恢复外观默认",
|
|
103
|
+
settingsPreview: "预览",
|
|
104
|
+
settingsPreviewInfo: "预览说明",
|
|
105
|
+
settingsPreviewTerminal: "终端输出",
|
|
106
|
+
settingsPreviewHint: "固定示例会随字体、字号和光标设置即时更新,字体缺失时使用系统回退。不会发送消息或执行命令。",
|
|
90
107
|
settingsFontFamily: "字体",
|
|
108
|
+
settingsFontFamilyDefault: "终端默认",
|
|
109
|
+
settingsFontMonospace: "系统等宽",
|
|
110
|
+
settingsFontDiscoveryFailed: "未能读取本机字体",
|
|
111
|
+
settingsFontDiscoveryUnavailable: "当前环境不支持读取字体",
|
|
91
112
|
settingsFontFamilyError: "请输入字体族,最多 512 个字符。",
|
|
92
113
|
settingsFontSize: "字号",
|
|
93
114
|
settingsFontSizeError: "请输入 8 到 32 之间的整数。",
|
|
@@ -99,6 +120,8 @@ var CATALOGUES = {
|
|
|
99
120
|
settingsCursorUnderline: "下划线",
|
|
100
121
|
settingsCursorBar: "竖线",
|
|
101
122
|
settingsCursorBlink: "光标闪烁",
|
|
123
|
+
settingsEnabled: "开启",
|
|
124
|
+
settingsDisabled: "关闭",
|
|
102
125
|
settingsSessions: "会话",
|
|
103
126
|
settingsExitBehavior: "会话保留方案",
|
|
104
127
|
settingsExitKeep: "不移除",
|
|
@@ -443,7 +466,8 @@ function SessionRow({ ctx, store, terminal, selected, online, select, onEditingC
|
|
|
443
466
|
className: "ws-row-actions",
|
|
444
467
|
children: [/* @__PURE__ */ jsx(Button, {
|
|
445
468
|
variant: "ghost",
|
|
446
|
-
|
|
469
|
+
size: "sm",
|
|
470
|
+
className: "ws-row-action ws-row-edit",
|
|
447
471
|
"aria-label": `${t("rename")} ${title}`,
|
|
448
472
|
disabled: !online || closing,
|
|
449
473
|
onClick: () => {
|
|
@@ -455,7 +479,8 @@ function SessionRow({ ctx, store, terminal, selected, online, select, onEditingC
|
|
|
455
479
|
children: /* @__PURE__ */ jsx(Icon, { name: "pencil" })
|
|
456
480
|
}), /* @__PURE__ */ jsx(Button, {
|
|
457
481
|
variant: "ghost",
|
|
458
|
-
|
|
482
|
+
size: "sm",
|
|
483
|
+
className: "ws-row-action ws-row-close",
|
|
459
484
|
"aria-label": `${t("close")} ${title}`,
|
|
460
485
|
disabled: !online || closing || terminal.status === "closing",
|
|
461
486
|
onClick: () => {
|
|
@@ -470,7 +495,7 @@ function SessionRow({ ctx, store, terminal, selected, online, select, onEditingC
|
|
|
470
495
|
children: closing || terminal.status === "closing" ? /* @__PURE__ */ jsx("span", {
|
|
471
496
|
"aria-hidden": "true",
|
|
472
497
|
children: "…"
|
|
473
|
-
}) : /* @__PURE__ */ jsx(X$1, { size:
|
|
498
|
+
}) : /* @__PURE__ */ jsx(X$1, { size: 16 })
|
|
474
499
|
})]
|
|
475
500
|
})] }), error && /* @__PURE__ */ jsx("span", {
|
|
476
501
|
role: "alert",
|
|
@@ -16908,6 +16933,7 @@ function createTerminalPreferences(signal) {
|
|
|
16908
16933
|
} catch {
|
|
16909
16934
|
problem = "read";
|
|
16910
16935
|
}
|
|
16936
|
+
let appearanceResetRevision = 0;
|
|
16911
16937
|
const listeners = /* @__PURE__ */ new Set();
|
|
16912
16938
|
let disposed = signal.aborted;
|
|
16913
16939
|
const update = (patch) => {
|
|
@@ -16956,6 +16982,7 @@ function createTerminalPreferences(signal) {
|
|
|
16956
16982
|
return {
|
|
16957
16983
|
getState: () => state,
|
|
16958
16984
|
getProblem: () => problem,
|
|
16985
|
+
getAppearanceResetRevision: () => appearanceResetRevision,
|
|
16959
16986
|
subscribe: (listener) => {
|
|
16960
16987
|
if (disposed) return () => {};
|
|
16961
16988
|
listeners.add(listener);
|
|
@@ -16964,8 +16991,19 @@ function createTerminalPreferences(signal) {
|
|
|
16964
16991
|
};
|
|
16965
16992
|
},
|
|
16966
16993
|
update,
|
|
16967
|
-
reset: () => {
|
|
16968
|
-
|
|
16994
|
+
reset: (scope) => {
|
|
16995
|
+
if (disposed) return;
|
|
16996
|
+
const { fontFamily, fontSize, cursorStyle, cursorBlink, exitBehavior } = DEFAULT_TERMINAL_PREFERENCES;
|
|
16997
|
+
update(scope === "appearance" ? {
|
|
16998
|
+
fontFamily,
|
|
16999
|
+
fontSize,
|
|
17000
|
+
cursorStyle,
|
|
17001
|
+
cursorBlink
|
|
17002
|
+
} : { exitBehavior });
|
|
17003
|
+
if (scope === "appearance") {
|
|
17004
|
+
appearanceResetRevision += 1;
|
|
17005
|
+
for (const listener of listeners) listener();
|
|
17006
|
+
}
|
|
16969
17007
|
},
|
|
16970
17008
|
dispose
|
|
16971
17009
|
};
|
|
@@ -17057,7 +17095,8 @@ object({
|
|
|
17057
17095
|
rows: Dimension,
|
|
17058
17096
|
operationId: uuid()
|
|
17059
17097
|
}).strict();
|
|
17060
|
-
|
|
17098
|
+
/** Close selection; endedRunId limits automatic removal to that already ended run. */
|
|
17099
|
+
var CloseParams = object({
|
|
17061
17100
|
instanceId: uuid(),
|
|
17062
17101
|
workspaceId: WorkspaceId,
|
|
17063
17102
|
terminalId: uuid(),
|
|
@@ -17078,7 +17117,8 @@ object({
|
|
|
17078
17117
|
cols: Dimension.optional(),
|
|
17079
17118
|
rows: Dimension.optional()
|
|
17080
17119
|
}).strict();
|
|
17081
|
-
|
|
17120
|
+
/** Read-only retained-operation query. */
|
|
17121
|
+
var OperationStatusParams = object({
|
|
17082
17122
|
instanceId: uuid(),
|
|
17083
17123
|
operationId: uuid()
|
|
17084
17124
|
}).strict();
|
|
@@ -17141,6 +17181,58 @@ discriminatedUnion("kind", [
|
|
|
17141
17181
|
error: AccessError
|
|
17142
17182
|
}).strict()
|
|
17143
17183
|
]);
|
|
17184
|
+
var encodedBytes = (value) => new TextEncoder().encode(JSON.stringify(value)).byteLength;
|
|
17185
|
+
var CloseMember = CloseParams.omit({
|
|
17186
|
+
instanceId: true,
|
|
17187
|
+
workspaceId: true
|
|
17188
|
+
});
|
|
17189
|
+
object({
|
|
17190
|
+
instanceId: uuid(),
|
|
17191
|
+
workspaceId: WorkspaceId,
|
|
17192
|
+
items: array(CloseMember).min(1).max(48)
|
|
17193
|
+
}).strict().superRefine((input, ctx) => {
|
|
17194
|
+
if (encodedBytes(input) * 2 > 8388608) ctx.addIssue({
|
|
17195
|
+
code: "custom",
|
|
17196
|
+
message: "Terminal input exceeds its byte budget"
|
|
17197
|
+
});
|
|
17198
|
+
const identities = /* @__PURE__ */ new Map();
|
|
17199
|
+
for (const member of input.items) {
|
|
17200
|
+
const value = JSON.stringify(member);
|
|
17201
|
+
if (identities.has(member.operationId) && identities.get(member.operationId) !== value) ctx.addIssue({
|
|
17202
|
+
code: "custom",
|
|
17203
|
+
message: "Operation identity has conflicting members"
|
|
17204
|
+
});
|
|
17205
|
+
identities.set(member.operationId, value);
|
|
17206
|
+
}
|
|
17207
|
+
});
|
|
17208
|
+
object({
|
|
17209
|
+
instanceId: uuid(),
|
|
17210
|
+
operationIds: array(uuid()).min(1).max(64),
|
|
17211
|
+
maxItemBytes: number().int().min(1).max(8388608).default(262144),
|
|
17212
|
+
maxTotalBytes: number().int().min(1).max(8388608).default(8388608)
|
|
17213
|
+
}).strict().superRefine((input, ctx) => {
|
|
17214
|
+
if (encodedBytes(input) * 2 > 8388608 || input.operationIds.length * input.maxItemBytes + 8192 > input.maxTotalBytes || input.operationIds.some((id) => encodedBytes(id) + 4096 > input.maxItemBytes)) ctx.addIssue({
|
|
17215
|
+
code: "custom",
|
|
17216
|
+
message: "Terminal collection exceeds its byte budget"
|
|
17217
|
+
});
|
|
17218
|
+
});
|
|
17219
|
+
function collectionResult(target) {
|
|
17220
|
+
return object({ results: array(discriminatedUnion("ok", [object({
|
|
17221
|
+
index: number().int().nonnegative(),
|
|
17222
|
+
target,
|
|
17223
|
+
ok: literal(true),
|
|
17224
|
+
value: OperationResult
|
|
17225
|
+
}).strict(), object({
|
|
17226
|
+
index: number().int().nonnegative(),
|
|
17227
|
+
target,
|
|
17228
|
+
ok: literal(false),
|
|
17229
|
+
error: AccessError
|
|
17230
|
+
}).strict()])).max(64) }).strict();
|
|
17231
|
+
}
|
|
17232
|
+
/** Ordered close outcomes preserve physical failure facts independently. */
|
|
17233
|
+
var CloseTerminalsResult = collectionResult(CloseMember);
|
|
17234
|
+
/** Ordered retained facts include unknown operations without replaying them. */
|
|
17235
|
+
var OperationStatusesResult = collectionResult(uuid());
|
|
17144
17236
|
//#endregion
|
|
17145
17237
|
//#region ui-src/terminal.ts
|
|
17146
17238
|
/** Consumes output through xterm callbacks before acknowledging it; disconnect never closes the PTY. */
|
|
@@ -17728,6 +17820,7 @@ function TerminalScreen({ ctx, store, preferences, terminal, visible, renaming,
|
|
|
17728
17820
|
onClick: () => setPaste(void 0),
|
|
17729
17821
|
children: t("cancel")
|
|
17730
17822
|
}), /* @__PURE__ */ jsx(Button, {
|
|
17823
|
+
variant: "primary",
|
|
17731
17824
|
disabled: !writer || paste.length > 32768,
|
|
17732
17825
|
onClick: () => {
|
|
17733
17826
|
display.current?.paste(paste);
|
|
@@ -17761,6 +17854,7 @@ function TerminalScreen({ ctx, store, preferences, terminal, visible, renaming,
|
|
|
17761
17854
|
onClick: () => setTakeover(false),
|
|
17762
17855
|
children: t("cancel")
|
|
17763
17856
|
}), /* @__PURE__ */ jsx(Button, {
|
|
17857
|
+
variant: "primary",
|
|
17764
17858
|
disabled: !state.online || !connection.current,
|
|
17765
17859
|
onClick: () => {
|
|
17766
17860
|
connection.current?.takeover().catch((error) => setProblem(String(error)));
|
|
@@ -18003,7 +18097,9 @@ function ShellPage({ ctx, store, preferences = store.preferences }) {
|
|
|
18003
18097
|
}
|
|
18004
18098
|
//#endregion
|
|
18005
18099
|
//#region ui-src/settings.tsx
|
|
18100
|
+
/** Terminal appearance and session behavior share one browser-local preference store. */
|
|
18006
18101
|
function FontPreference({ ctx, preferences, value }) {
|
|
18102
|
+
const device = useDeviceFonts(ctx.signal, ctx.services.get("native-device-fonts"));
|
|
18007
18103
|
const [draft, setDraft] = useState(value);
|
|
18008
18104
|
useEffect(() => setDraft(value), [value]);
|
|
18009
18105
|
const t = ctx.i18n.t;
|
|
@@ -18012,13 +18108,30 @@ function FontPreference({ ctx, preferences, value }) {
|
|
|
18012
18108
|
label: t("settingsFontFamily"),
|
|
18013
18109
|
error: valid ? void 0 : t("settingsFontFamilyError"),
|
|
18014
18110
|
inline: true,
|
|
18015
|
-
|
|
18111
|
+
className: "settings-field-row flex flex-row flex-wrap items-center justify-between [&>div:nth-child(2)]:ml-auto",
|
|
18112
|
+
children: (binding) => /* @__PURE__ */ jsx(ctx.ui.FontPicker, {
|
|
18016
18113
|
...binding,
|
|
18017
|
-
"
|
|
18114
|
+
className: "w-72 max-w-full",
|
|
18115
|
+
label: t("settingsFontFamily"),
|
|
18116
|
+
onLoadFonts: device.available ? device.load : void 0,
|
|
18117
|
+
loading: device.loading,
|
|
18118
|
+
loadError: device.failed ? t("settingsFontDiscoveryFailed") : void 0,
|
|
18119
|
+
loadUnavailable: !device.available ? t("settingsFontDiscoveryUnavailable") : void 0,
|
|
18120
|
+
options: [
|
|
18121
|
+
...device.options,
|
|
18122
|
+
{
|
|
18123
|
+
value: DEFAULT_TERMINAL_PREFERENCES.fontFamily,
|
|
18124
|
+
label: t("settingsFontFamilyDefault")
|
|
18125
|
+
},
|
|
18126
|
+
{
|
|
18127
|
+
value: "monospace",
|
|
18128
|
+
label: t("settingsFontMonospace")
|
|
18129
|
+
}
|
|
18130
|
+
],
|
|
18018
18131
|
value: draft,
|
|
18019
|
-
|
|
18020
|
-
setDraft(
|
|
18021
|
-
preferences.update({ fontFamily:
|
|
18132
|
+
onValueChange: (value) => {
|
|
18133
|
+
setDraft(value);
|
|
18134
|
+
preferences.update({ fontFamily: value });
|
|
18022
18135
|
}
|
|
18023
18136
|
})
|
|
18024
18137
|
});
|
|
@@ -18032,6 +18145,7 @@ function FontSizePreference({ ctx, preferences, value }) {
|
|
|
18032
18145
|
label: t("settingsFontSize"),
|
|
18033
18146
|
error: valid ? void 0 : t("settingsFontSizeError"),
|
|
18034
18147
|
inline: true,
|
|
18148
|
+
className: "settings-field-row flex flex-row flex-wrap items-center justify-between [&>div:nth-child(2)]:ml-auto",
|
|
18035
18149
|
children: (binding) => /* @__PURE__ */ jsx("div", {
|
|
18036
18150
|
className: "ws-settings-number",
|
|
18037
18151
|
children: /* @__PURE__ */ jsx(ctx.ui.InputNumber, {
|
|
@@ -18052,11 +18166,17 @@ function FontSizePreference({ ctx, preferences, value }) {
|
|
|
18052
18166
|
})
|
|
18053
18167
|
});
|
|
18054
18168
|
}
|
|
18055
|
-
|
|
18169
|
+
function StorageProblem({ ctx, preferences }) {
|
|
18170
|
+
const problem = useSyncExternalStore(preferences.subscribe, preferences.getProblem);
|
|
18171
|
+
return problem ? /* @__PURE__ */ jsx("p", {
|
|
18172
|
+
role: "alert",
|
|
18173
|
+
className: "ws-settings-error",
|
|
18174
|
+
children: ctx.i18n.t(problem === "read" ? "settingsReadFailed" : "settingsWriteFailed")
|
|
18175
|
+
}) : null;
|
|
18176
|
+
}
|
|
18177
|
+
/** Session-retention settings keep their existing system-settings page and storage record. */
|
|
18056
18178
|
function TerminalSettings({ ctx, preferences }) {
|
|
18057
18179
|
const value = useSyncExternalStore(preferences.subscribe, preferences.getState);
|
|
18058
|
-
const problem = useSyncExternalStore(preferences.subscribe, preferences.getProblem);
|
|
18059
|
-
const [reset, setReset] = useState(0);
|
|
18060
18180
|
const t = ctx.i18n.t;
|
|
18061
18181
|
return /* @__PURE__ */ jsxs("div", {
|
|
18062
18182
|
className: "ws-settings",
|
|
@@ -18069,35 +18189,76 @@ function TerminalSettings({ ctx, preferences }) {
|
|
|
18069
18189
|
type: "button",
|
|
18070
18190
|
variant: "text",
|
|
18071
18191
|
className: "min-w-0 text-right",
|
|
18072
|
-
onClick: () =>
|
|
18073
|
-
preferences.reset();
|
|
18074
|
-
setReset((current) => current + 1);
|
|
18075
|
-
},
|
|
18192
|
+
onClick: () => preferences.reset("behavior"),
|
|
18076
18193
|
children: t("settingsReset")
|
|
18077
18194
|
})]
|
|
18078
18195
|
}), /* @__PURE__ */ jsxs("div", {
|
|
18079
18196
|
className: "ws-settings-body @container flex min-h-0 flex-1 flex-col gap-6 px-6 pb-6 pt-1",
|
|
18080
|
-
children: [
|
|
18081
|
-
|
|
18082
|
-
|
|
18083
|
-
|
|
18084
|
-
|
|
18085
|
-
|
|
18086
|
-
|
|
18087
|
-
|
|
18088
|
-
|
|
18089
|
-
|
|
18090
|
-
|
|
18091
|
-
|
|
18092
|
-
|
|
18093
|
-
|
|
18094
|
-
|
|
18095
|
-
|
|
18096
|
-
|
|
18097
|
-
|
|
18098
|
-
|
|
18099
|
-
|
|
18100
|
-
|
|
18197
|
+
children: [/* @__PURE__ */ jsx(StorageProblem, {
|
|
18198
|
+
ctx,
|
|
18199
|
+
preferences
|
|
18200
|
+
}), /* @__PURE__ */ jsx(ctx.ui.SettingsPanel, {
|
|
18201
|
+
title: t("settingsSessions"),
|
|
18202
|
+
children: /* @__PURE__ */ jsx(ctx.ui.SettingsPanel, {
|
|
18203
|
+
title: t("settingsExitBehavior"),
|
|
18204
|
+
level: "field",
|
|
18205
|
+
inline: true,
|
|
18206
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
18207
|
+
className: "ws-settings-choice flex min-w-0 justify-end",
|
|
18208
|
+
children: /* @__PURE__ */ jsx(ctx.ui.Segmented, {
|
|
18209
|
+
label: t("settingsExitBehavior"),
|
|
18210
|
+
value: value.exitBehavior,
|
|
18211
|
+
options: [
|
|
18212
|
+
{
|
|
18213
|
+
value: "keep",
|
|
18214
|
+
label: t("settingsExitKeep")
|
|
18215
|
+
},
|
|
18216
|
+
{
|
|
18217
|
+
value: "on-success",
|
|
18218
|
+
label: t("settingsExitSuccess")
|
|
18219
|
+
},
|
|
18220
|
+
{
|
|
18221
|
+
value: "remove",
|
|
18222
|
+
label: t("settingsExitRemove")
|
|
18223
|
+
}
|
|
18224
|
+
],
|
|
18225
|
+
onSelect: (exitBehavior) => preferences.update({ exitBehavior })
|
|
18226
|
+
})
|
|
18227
|
+
})
|
|
18228
|
+
})
|
|
18229
|
+
})]
|
|
18230
|
+
})]
|
|
18231
|
+
});
|
|
18232
|
+
}
|
|
18233
|
+
/** Appearance content uses the personalization host's title, spacing and scroll container. */
|
|
18234
|
+
function TerminalPersonalization({ ctx, preferences }) {
|
|
18235
|
+
const value = useSyncExternalStore(preferences.subscribe, preferences.getState);
|
|
18236
|
+
const reset = useSyncExternalStore(preferences.subscribe, preferences.getAppearanceResetRevision);
|
|
18237
|
+
const t = ctx.i18n.t;
|
|
18238
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
18239
|
+
className: "ws-personalization @container flex min-w-0 flex-1 flex-col gap-6",
|
|
18240
|
+
children: [
|
|
18241
|
+
/* @__PURE__ */ jsx(StorageProblem, {
|
|
18242
|
+
ctx,
|
|
18243
|
+
preferences
|
|
18244
|
+
}),
|
|
18245
|
+
/* @__PURE__ */ jsxs(ctx.ui.SettingsPanel, {
|
|
18246
|
+
title: t("settingsText"),
|
|
18247
|
+
children: [/* @__PURE__ */ jsx(FontPreference, {
|
|
18248
|
+
ctx,
|
|
18249
|
+
preferences,
|
|
18250
|
+
value: value.fontFamily
|
|
18251
|
+
}, `font-${reset}`), /* @__PURE__ */ jsx(FontSizePreference, {
|
|
18252
|
+
ctx,
|
|
18253
|
+
preferences,
|
|
18254
|
+
value: value.fontSize
|
|
18255
|
+
}, `size-${reset}`)]
|
|
18256
|
+
}),
|
|
18257
|
+
/* @__PURE__ */ jsxs(ctx.ui.SettingsPanel, {
|
|
18258
|
+
title: t("settingsCursor"),
|
|
18259
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
18260
|
+
className: "[&>section]:flex-row [&>section]:flex-wrap [&>section]:items-center [&>section]:justify-between [&>section>div]:ml-auto",
|
|
18261
|
+
children: /* @__PURE__ */ jsx(ctx.ui.SettingsPanel, {
|
|
18101
18262
|
title: t("settingsCursorStyle"),
|
|
18102
18263
|
level: "field",
|
|
18103
18264
|
inline: true,
|
|
@@ -18123,55 +18284,145 @@ function TerminalSettings({ ctx, preferences }) {
|
|
|
18123
18284
|
onSelect: (cursorStyle) => preferences.update({ cursorStyle })
|
|
18124
18285
|
})
|
|
18125
18286
|
})
|
|
18126
|
-
})
|
|
18287
|
+
})
|
|
18288
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
18289
|
+
className: "[&>section]:flex-row [&>section]:flex-wrap [&>section]:items-center [&>section]:justify-between [&>section>div]:ml-auto",
|
|
18290
|
+
children: /* @__PURE__ */ jsx(ctx.ui.SettingsPanel, {
|
|
18127
18291
|
title: t("settingsCursorBlink"),
|
|
18128
18292
|
level: "field",
|
|
18129
18293
|
inline: true,
|
|
18130
18294
|
children: /* @__PURE__ */ jsx("div", {
|
|
18131
18295
|
className: "flex min-w-0 justify-end",
|
|
18132
|
-
children: /* @__PURE__ */ jsx(ctx.ui.Switch, {
|
|
18133
|
-
"aria-label": t("settingsCursorBlink"),
|
|
18134
|
-
checked: value.cursorBlink,
|
|
18135
|
-
onCheckedChange: (cursorBlink) => preferences.update({ cursorBlink })
|
|
18136
|
-
})
|
|
18137
|
-
})
|
|
18138
|
-
})]
|
|
18139
|
-
}),
|
|
18140
|
-
/* @__PURE__ */ jsx(ctx.ui.SettingsPanel, {
|
|
18141
|
-
title: t("settingsSessions"),
|
|
18142
|
-
children: /* @__PURE__ */ jsx(ctx.ui.SettingsPanel, {
|
|
18143
|
-
title: t("settingsExitBehavior"),
|
|
18144
|
-
level: "field",
|
|
18145
|
-
inline: true,
|
|
18146
|
-
children: /* @__PURE__ */ jsx("div", {
|
|
18147
|
-
className: "ws-settings-choice flex min-w-0 justify-end",
|
|
18148
18296
|
children: /* @__PURE__ */ jsx(ctx.ui.Segmented, {
|
|
18149
|
-
label: t("
|
|
18150
|
-
value: value.
|
|
18151
|
-
options: [
|
|
18152
|
-
|
|
18153
|
-
|
|
18154
|
-
|
|
18155
|
-
|
|
18156
|
-
|
|
18157
|
-
|
|
18158
|
-
|
|
18159
|
-
},
|
|
18160
|
-
{
|
|
18161
|
-
value: "remove",
|
|
18162
|
-
label: t("settingsExitRemove")
|
|
18163
|
-
}
|
|
18164
|
-
],
|
|
18165
|
-
onSelect: (exitBehavior) => preferences.update({ exitBehavior })
|
|
18297
|
+
label: t("settingsCursorBlink"),
|
|
18298
|
+
value: value.cursorBlink ? "on" : "off",
|
|
18299
|
+
options: [{
|
|
18300
|
+
value: "on",
|
|
18301
|
+
label: t("settingsEnabled")
|
|
18302
|
+
}, {
|
|
18303
|
+
value: "off",
|
|
18304
|
+
label: t("settingsDisabled")
|
|
18305
|
+
}],
|
|
18306
|
+
onSelect: (next) => preferences.update({ cursorBlink: next === "on" })
|
|
18166
18307
|
})
|
|
18167
18308
|
})
|
|
18168
18309
|
})
|
|
18169
|
-
})
|
|
18170
|
-
|
|
18171
|
-
|
|
18310
|
+
})]
|
|
18311
|
+
}),
|
|
18312
|
+
/* @__PURE__ */ jsxs(SettingsPreview, {
|
|
18313
|
+
title: t("settingsPreview"),
|
|
18314
|
+
infoLabel: t("settingsPreviewInfo"),
|
|
18315
|
+
description: t("settingsPreviewHint"),
|
|
18316
|
+
kind: t("settingsPreviewTerminal"),
|
|
18317
|
+
canvasClassName: "ws-settings-preview",
|
|
18318
|
+
canvasStyle: {
|
|
18319
|
+
fontFamily: terminalFontFamily(value.fontFamily),
|
|
18320
|
+
fontSize: value.fontSize
|
|
18321
|
+
},
|
|
18322
|
+
children: [
|
|
18323
|
+
/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("span", {
|
|
18324
|
+
className: "ws-preview-prompt",
|
|
18325
|
+
children: "➜"
|
|
18326
|
+
}), " ~/yaoguang"] }),
|
|
18327
|
+
/* @__PURE__ */ jsx("div", { children: "$ echo \"Hello, 瑶光\"" }),
|
|
18328
|
+
/* @__PURE__ */ jsx("div", { children: "Hello, 瑶光" }),
|
|
18329
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
18330
|
+
"$",
|
|
18331
|
+
" ",
|
|
18332
|
+
/* @__PURE__ */ jsx("span", {
|
|
18333
|
+
"aria-hidden": "true",
|
|
18334
|
+
className: "ws-preview-cursor",
|
|
18335
|
+
"data-cursor-style": value.cursorStyle,
|
|
18336
|
+
"data-blink": value.cursorBlink
|
|
18337
|
+
})
|
|
18338
|
+
] })
|
|
18339
|
+
]
|
|
18340
|
+
})
|
|
18341
|
+
]
|
|
18172
18342
|
});
|
|
18173
18343
|
}
|
|
18174
18344
|
//#endregion
|
|
18345
|
+
//#region ui-src/collections.ts
|
|
18346
|
+
/** Coalesces one activation and exact shared instance/workspace; mutation UUIDs remain unchanged. */
|
|
18347
|
+
function createTerminalCollections(ctx) {
|
|
18348
|
+
let groups = /* @__PURE__ */ new Map();
|
|
18349
|
+
let scheduled = false;
|
|
18350
|
+
const dispatch = async (group, intents) => {
|
|
18351
|
+
try {
|
|
18352
|
+
ctx.signal.throwIfAborted();
|
|
18353
|
+
const raw = await ctx.invoke(group.method === "close" ? "closeTerminals" : "operationStatuses", {
|
|
18354
|
+
instanceId: group.instanceId,
|
|
18355
|
+
...group.workspaceId === void 0 ? {} : { workspaceId: group.workspaceId },
|
|
18356
|
+
[group.method === "close" ? "items" : "operationIds"]: intents.map((intent) => intent.target)
|
|
18357
|
+
});
|
|
18358
|
+
ctx.signal.throwIfAborted();
|
|
18359
|
+
const result = (group.method === "close" ? CloseTerminalsResult : OperationStatusesResult).parse(raw);
|
|
18360
|
+
if (result.results.length !== intents.length || result.results.some((member, index) => member.index !== index || JSON.stringify(member.target) !== JSON.stringify(intents[index]?.target))) throw new Error("Terminal collection returned unexpected members");
|
|
18361
|
+
for (const [index, intent] of intents.entries()) {
|
|
18362
|
+
const member = result.results[index];
|
|
18363
|
+
if (member.ok) intent.resolve(member.value);
|
|
18364
|
+
else intent.reject(Object.assign(new Error(member.error.message), member.error));
|
|
18365
|
+
}
|
|
18366
|
+
} catch (error) {
|
|
18367
|
+
for (const intent of intents) intent.reject(error);
|
|
18368
|
+
}
|
|
18369
|
+
};
|
|
18370
|
+
return (method, params) => {
|
|
18371
|
+
ctx.signal.throwIfAborted();
|
|
18372
|
+
const { instanceId, workspaceId, target } = method === "close" ? (() => {
|
|
18373
|
+
const input = CloseParams.parse(params);
|
|
18374
|
+
return {
|
|
18375
|
+
instanceId: input.instanceId,
|
|
18376
|
+
workspaceId: input.workspaceId,
|
|
18377
|
+
target: {
|
|
18378
|
+
terminalId: input.terminalId,
|
|
18379
|
+
operationId: input.operationId,
|
|
18380
|
+
...input.endedRunId ? { endedRunId: input.endedRunId } : {}
|
|
18381
|
+
}
|
|
18382
|
+
};
|
|
18383
|
+
})() : (() => {
|
|
18384
|
+
const input = OperationStatusParams.parse(params);
|
|
18385
|
+
return {
|
|
18386
|
+
instanceId: input.instanceId,
|
|
18387
|
+
workspaceId: void 0,
|
|
18388
|
+
target: input.operationId
|
|
18389
|
+
};
|
|
18390
|
+
})();
|
|
18391
|
+
const key = JSON.stringify([
|
|
18392
|
+
method,
|
|
18393
|
+
instanceId,
|
|
18394
|
+
workspaceId
|
|
18395
|
+
]);
|
|
18396
|
+
const group = groups.get(key) ?? {
|
|
18397
|
+
method,
|
|
18398
|
+
instanceId,
|
|
18399
|
+
workspaceId,
|
|
18400
|
+
intents: []
|
|
18401
|
+
};
|
|
18402
|
+
groups.set(key, group);
|
|
18403
|
+
const result = new Promise((resolve, reject) => {
|
|
18404
|
+
group.intents.push({
|
|
18405
|
+
target,
|
|
18406
|
+
resolve,
|
|
18407
|
+
reject
|
|
18408
|
+
});
|
|
18409
|
+
});
|
|
18410
|
+
if (!scheduled) {
|
|
18411
|
+
scheduled = true;
|
|
18412
|
+
queueMicrotask(() => {
|
|
18413
|
+
scheduled = false;
|
|
18414
|
+
const ready = groups;
|
|
18415
|
+
groups = /* @__PURE__ */ new Map();
|
|
18416
|
+
for (const group of ready.values()) {
|
|
18417
|
+
const size = group.method === "close" ? 48 : 31;
|
|
18418
|
+
for (let offset = 0; offset < group.intents.length; offset += size) dispatch(group, group.intents.slice(offset, offset + size));
|
|
18419
|
+
}
|
|
18420
|
+
});
|
|
18421
|
+
}
|
|
18422
|
+
return result;
|
|
18423
|
+
};
|
|
18424
|
+
}
|
|
18425
|
+
//#endregion
|
|
18175
18426
|
//#region ui-src/store.ts
|
|
18176
18427
|
/**
|
|
18177
18428
|
* Follows the optional global workspace store for one browser activation.
|
|
@@ -18180,6 +18431,7 @@ function TerminalSettings({ ctx, preferences }) {
|
|
|
18180
18431
|
* Supplied preferences remain caller-owned; otherwise this store disposes its own preference store.
|
|
18181
18432
|
*/
|
|
18182
18433
|
function createShellStore(ctx, suppliedPreferences) {
|
|
18434
|
+
const collection = createTerminalCollections(ctx);
|
|
18183
18435
|
const preferences = suppliedPreferences ?? createTerminalPreferences(ctx.signal);
|
|
18184
18436
|
let state = {
|
|
18185
18437
|
online: ctx.gateway.connection.status === "online",
|
|
@@ -18435,7 +18687,7 @@ function createShellStore(ctx, suppliedPreferences) {
|
|
|
18435
18687
|
patch({ problem: void 0 });
|
|
18436
18688
|
const operationId = ctx.uuid();
|
|
18437
18689
|
try {
|
|
18438
|
-
const result = OperationResult.parse(await
|
|
18690
|
+
const result = OperationResult.parse(await collection("close", {
|
|
18439
18691
|
instanceId: terminal.instanceId,
|
|
18440
18692
|
workspaceId: terminal.workspaceId,
|
|
18441
18693
|
terminalId: terminal.id,
|
|
@@ -18499,7 +18751,7 @@ function createShellStore(ctx, suppliedPreferences) {
|
|
|
18499
18751
|
status: "pending"
|
|
18500
18752
|
} });
|
|
18501
18753
|
try {
|
|
18502
|
-
const result = OperationResult.parse(await
|
|
18754
|
+
const result = OperationResult.parse(await collection("operationStatus", {
|
|
18503
18755
|
instanceId: identity.instanceId,
|
|
18504
18756
|
operationId: operation.operationId
|
|
18505
18757
|
}));
|
|
@@ -18581,7 +18833,7 @@ function createShellStore(ctx, suppliedPreferences) {
|
|
|
18581
18833
|
if (!state.identity || !state.unknownOperation) return;
|
|
18582
18834
|
const version = generation;
|
|
18583
18835
|
try {
|
|
18584
|
-
const result = OperationResult.parse(await
|
|
18836
|
+
const result = OperationResult.parse(await collection("operationStatus", {
|
|
18585
18837
|
instanceId: state.identity.instanceId,
|
|
18586
18838
|
operationId: state.unknownOperation
|
|
18587
18839
|
}));
|
|
@@ -18673,12 +18925,13 @@ var STYLES = `
|
|
|
18673
18925
|
.ws-page .ws-terminal .xterm .xterm-decoration-overview-ruler{visibility:hidden}
|
|
18674
18926
|
.ws-settings-error{margin:0;color:var(--destructive);font-size:12px;line-height:20px}
|
|
18675
18927
|
.ws-settings{display:flex;flex-direction:column;flex:1;min-width:0;min-height:0}.ws-settings-body{overflow:auto;min-height:0}.ws-settings-choice [data-slot=segmented]{max-width:100%;width:auto;flex-wrap:wrap}
|
|
18928
|
+
.ws-settings-preview{background:#141820;color:#e8ecf2;line-height:1.7;white-space:pre}.ws-preview-prompt{color:#8cccaf}.ws-preview-cursor{display:inline-block;width:.6em;height:1.15em;vertical-align:-.15em;background:currentColor}.ws-preview-cursor[data-cursor-style=bar]{width:2px}.ws-preview-cursor[data-cursor-style=underline]{height:2px;vertical-align:-.15em}.ws-preview-cursor[data-blink=true]{animation:ws-preview-blink 1.2s step-end infinite}@keyframes ws-preview-blink{50%{opacity:0}}@media(prefers-reduced-motion:reduce){.ws-preview-cursor{animation:none!important}}
|
|
18676
18929
|
.ws-settings-number{display:flex;min-width:0;flex-direction:column;align-items:flex-end;gap:.25rem}.ws-settings-number>*{width:9rem;max-width:100%}
|
|
18677
18930
|
.ws-page{height:100%;min-height:0;min-width:0;display:grid;grid-template-columns:288px minmax(0,1fr);overflow:hidden;background:var(--background);color:var(--foreground);position:relative}
|
|
18678
18931
|
.ws-sessions{display:flex;flex-direction:column;min-width:0;min-height:0;background:var(--background);border-inline-end:1px solid var(--border)}
|
|
18679
18932
|
.ws-session-heading{display:flex;align-items:center;gap:12px;height:56px;padding:0 12px;margin-bottom:8px}.ws-session-heading h1{margin:0;flex:1;font-size:14px;font-weight:600;line-height:20px}.ws-page .ws-icon-button{height:30px;width:30px;min-width:30px;padding:0;flex-shrink:0;color:var(--muted-foreground)}.ws-icon-button svg{width:17px;height:17px}.ws-icon-button:hover{color:var(--foreground)}
|
|
18680
18933
|
.ws-session-search{display:flex;align-items:center;gap:7px;margin:0 12px 12px;padding:0 9px;height:32px;border:1px solid var(--border);border-radius:6px;background:var(--card);color:var(--muted-foreground)}.ws-session-search:focus-within{border-color:var(--primary)}.ws-session-search>svg{width:15px;height:15px;flex-shrink:0}.ws-page .ws-session-search input{border:0;box-shadow:none;background:transparent;min-width:0;height:30px;padding:0;font-size:12px}.ws-session-search input:focus-visible{outline:none;box-shadow:none}
|
|
18681
|
-
.ws-session-list{flex:1;min-height:0;overflow:auto;padding:0 12px 8px}.ws-session-row{position:relative;display:flex;align-items:center;gap:9px;min-height:45px;width:100%;margin:2px 0;padding:0 7px 0 12px;border-radius:var(--radius-control);text-align:left}.ws-session-row:hover{background:var(--muted)}.ws-session-row[aria-current=page],.ws-session-row.ws-selected{background:var(--accent-selected)}.ws-session-row svg{width:16px;height:16px;flex-shrink:0;color:var(--muted-foreground)}.ws-session-row span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:14px;line-height:20px}.ws-session-select{flex:1;min-width:0;display:flex;align-items:center;gap:9px;height:45px;text-align:left;justify-content:flex-start}.ws-session-select>span{flex:1}.ws-row-actions{display:flex;gap:1px;align-items:center;flex-shrink:0}.ws-page .ws-row-
|
|
18934
|
+
.ws-session-list{flex:1;min-height:0;overflow:auto;padding:0 12px 8px}.ws-session-row{position:relative;display:flex;align-items:center;gap:9px;min-height:45px;width:100%;margin:2px 0;padding:0 7px 0 12px;border-radius:var(--radius-control);text-align:left}.ws-session-row:hover{background:var(--muted)}.ws-session-row[aria-current=page],.ws-session-row.ws-selected{background:var(--accent-selected)}.ws-session-row svg{width:16px;height:16px;flex-shrink:0;color:var(--muted-foreground)}.ws-session-row span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:14px;line-height:20px}.ws-session-select{flex:1;min-width:0;display:flex;align-items:center;gap:9px;height:45px;text-align:left;justify-content:flex-start}.ws-session-select>span{flex:1}.ws-row-actions{display:flex;gap:1px;align-items:center;flex-shrink:0}.ws-page .ws-row-action{aspect-ratio:1;padding:0;color:var(--muted-foreground)}.ws-row-action:hover{color:var(--foreground)}.ws-row-actions svg{width:16px;height:16px}.ws-row-edit{opacity:0}.ws-session-row:hover .ws-row-edit,.ws-session-row:focus-within .ws-row-edit,.ws-selected .ws-row-edit{opacity:1}.ws-page .ws-row-close:hover{color:var(--destructive)}.ws-row-editor{display:flex;align-items:center;gap:2px;min-width:0;width:100%;min-height:45px}.ws-row-editor input{min-width:0;height:30px;font-size:13px}.ws-row-error{flex-basis:100%;color:var(--destructive);font-size:11px;padding:0 0 8px;white-space:normal!important}.ws-session-row:has(.ws-row-error){flex-wrap:wrap}
|
|
18682
18935
|
.ws-sidebar-empty{padding:28px 12px;text-align:center;color:var(--muted-foreground);font-size:12px;display:flex;flex-direction:column;gap:12px;align-items:center}.ws-workbench{position:relative;display:flex;flex-direction:column;min-width:0;min-height:0;overflow:hidden;background:#141820}.ws-screen{display:flex;flex-direction:column;flex:1;min-width:0;min-height:0;position:relative}.ws-screen[hidden]{display:none}.ws-terminal-header{min-height:64px;height:64px;flex-shrink:0;display:flex;align-items:center;justify-content:space-between;gap:12px;padding:8px 16px;background:var(--background);border-bottom:1px solid var(--border)}.ws-terminal-heading{display:flex;align-items:center;gap:8px;min-width:0}.ws-terminal-heading h2{margin:0;font-size:16px;font-weight:500;line-height:24px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ws-terminal-body{display:flex;flex-direction:column;flex:1;min-height:0;overflow:hidden}.ws-viewport{flex:1;min-height:0;min-width:0;display:flex;padding:18px 22px;overflow:hidden;background:#141820}.ws-terminal{flex:1;min-height:0;min-width:0;padding:0;background:#141820;color:#e8ecf2;overflow:hidden}.ws-terminal .xterm{height:100%}.ws-terminal.ws-disabled{filter:grayscale(1);opacity:.6}.ws-page .ws-terminal.ws-no-input .xterm .xterm-rows .xterm-cursor{animation:none!important;background-color:transparent!important;color:inherit!important;outline:none!important;box-shadow:none!important;border-bottom-color:transparent!important}.ws-page .ws-terminal.ws-no-input .xterm .xterm-rows .xterm-cursor::before,.ws-page .ws-terminal.ws-no-input .xterm .xterm-rows .xterm-cursor::after{display:none!important}
|
|
18683
18936
|
|
|
18684
18937
|
.ws-find{position:absolute;right:16px;top:74px;z-index:5;width:min(390px,calc(100% - 32px));display:flex;align-items:center;gap:4px;padding:8px;border:1px solid var(--border);border-radius:8px;background:var(--background);color:var(--foreground);box-shadow:0 8px 28px #0005}.ws-find input{min-width:0;flex:1;height:30px;font-size:12px}.ws-find-result{font-size:11px;color:var(--muted-foreground);white-space:nowrap;min-width:30px;text-align:center}.ws-page .ws-find .ws-icon-button{height:26px;width:26px;min-width:26px}.ws-find svg{height:14px;width:14px}.ws-list-toggle,.ws-scrim{display:none}.ws-paste textarea{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;min-height:120px;width:100%}.ws-paste p{font-size:13px;color:var(--muted-foreground)}
|
|
@@ -18722,6 +18975,17 @@ var register = (ctx) => {
|
|
|
18722
18975
|
preferences
|
|
18723
18976
|
})
|
|
18724
18977
|
});
|
|
18978
|
+
ctx.slots.register("shell.personalization.category", {
|
|
18979
|
+
id: "terminal-personalization",
|
|
18980
|
+
onReset: () => preferences.reset("appearance"),
|
|
18981
|
+
order: 30,
|
|
18982
|
+
label: () => ctx.i18n.t("nav"),
|
|
18983
|
+
icon: "terminal",
|
|
18984
|
+
component: () => /* @__PURE__ */ jsx(TerminalPersonalization, {
|
|
18985
|
+
ctx,
|
|
18986
|
+
preferences
|
|
18987
|
+
})
|
|
18988
|
+
});
|
|
18725
18989
|
ctx.services.provide("web-shell-launcher", store.launcher);
|
|
18726
18990
|
};
|
|
18727
18991
|
//#endregion
|