dsh-plugin-wsl-env 0.26.4 → 0.27.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/CHANGELOG.md +61 -0
- package/CONTRIBUTING.md +7 -4
- package/CONTRIBUTING.zh.md +3 -2
- package/README.md +1 -1
- package/SECURITY.md +21 -7
- package/SECURITY.zh.md +18 -5
- package/client.js +351 -48
- package/cordis.patch.yml +26 -10
- package/docs/API.md +2 -1
- package/docs/API.zh.md +2 -1
- package/docs/ARCHITECTURE.md +22 -4
- package/docs/ARCHITECTURE.zh.md +18 -4
- package/docs/CONFIGURATION.md +96 -12
- package/docs/CONFIGURATION.zh.md +80 -8
- package/docs/DIAGNOSTICS.md +22 -11
- package/docs/DIAGNOSTICS.zh.md +17 -9
- package/docs/LIMITATIONS.md +27 -4
- package/docs/LIMITATIONS.zh.md +20 -3
- package/docs/MIGRATION.md +2 -2
- package/docs/MIGRATION.zh.md +2 -2
- package/docs/QUICKSTART.md +31 -20
- package/docs/QUICKSTART.zh.md +16 -9
- package/docs/README.zh.md +1 -1
- package/docs/REQUIREMENTS.zh.md +3 -2
- package/lib/agent-confined.d.ts +9 -1
- package/lib/agent-confined.js +3 -3
- package/lib/bwrap.d.ts +16 -0
- package/lib/bwrap.js +9 -0
- package/lib/fs-routing.d.ts +3 -0
- package/lib/fs-routing.js +2 -0
- package/lib/messages.js +2 -2
- package/lib/plugin-update.d.ts +212 -0
- package/lib/plugin-update.js +283 -0
- package/lib/sandbox-core.d.ts +2 -0
- package/lib/sandbox-core.js +5 -3
- package/lib/session-runtime.d.ts +10 -1
- package/lib/session-runtime.js +3 -1
- package/lib/shell-env.js +1 -1
- package/lib/socket-isolation.d.ts +103 -0
- package/lib/socket-isolation.js +166 -0
- package/lib/status.d.ts +21 -8
- package/lib/status.js +53 -18
- package/lib/update-check.d.ts +49 -9
- package/lib/update-check.js +81 -28
- package/lib/wsl-doctor-tool.js +2 -0
- package/lib/wsl-filesystem.d.ts +39 -1
- package/lib/wsl-filesystem.js +51 -4
- package/lib/wsl-shell.d.ts +67 -3
- package/lib/wsl-shell.js +75 -12
- package/package.json +8 -3
- package/scripts/doctor.mjs +199 -3
- package/scripts/profile-preset.mjs +10 -2
package/client.js
CHANGED
|
@@ -11,12 +11,21 @@
|
|
|
11
11
|
* can reach it without a generated client Remote. Checks run only when asked:
|
|
12
12
|
* probing a stopped distro boots it, so a page load lists without probing.
|
|
13
13
|
*
|
|
14
|
-
* A
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
14
|
+
* A separate **插件版本** card answers the plugin's own version question over
|
|
15
|
+
* `GET /api/wsl-env/plugin-update`: the installed and running versions, the
|
|
16
|
+
* newest installable stable release, and whether the host plugin manager can
|
|
17
|
+
* perform the update. A newer release raises a visible reminder, and
|
|
18
|
+
* **一键升级** posts to the same route; the route calls the host's
|
|
19
|
+
* `updateBundle` only for that explicit click and the card reports the host's
|
|
20
|
+
* applied/restart-required/rollback outcome.
|
|
21
|
+
*
|
|
22
|
+
* Every distro row offers two check actions: **快速检查** (the scoped quick
|
|
23
|
+
* doctor, `GET` on the status route) and **完整检查** (the full doctor with
|
|
24
|
+
* `--fix-owned`, `POST` on the same route). Both run again on every click —
|
|
25
|
+
* there is no persistent "recheck" label. The full run also repairs plugin-owned
|
|
26
|
+
* state (a stale session scope or a broken agent cache) and answers with its
|
|
27
|
+
* `fix.*` before → after rows; it never installs packages or rewrites
|
|
28
|
+
* Windows-owned configuration. Every other warning stays manual.
|
|
20
29
|
*
|
|
21
30
|
* The last result is persisted Host-side, so a page reload (or an app restart)
|
|
22
31
|
* still shows the last guidance and when it ran. On load, a stored result for
|
|
@@ -24,6 +33,12 @@
|
|
|
24
33
|
* stopped one: a probe boots it); the result is labeled with its source, and
|
|
25
34
|
* a failed background run overwrites the stored result truthfully.
|
|
26
35
|
*
|
|
36
|
+
* A checked row offers **清除** and the card offers **清除全部**: they `DELETE`
|
|
37
|
+
* the same route (with and without `?distro=`), which drops the stored verdict
|
|
38
|
+
* so the next load shows "not checked" again. Clearing is local housekeeping —
|
|
39
|
+
* it lists and probes nothing — and the panel disables it while a check is in
|
|
40
|
+
* flight so an answer cannot arrive after the clear and restore the row.
|
|
41
|
+
*
|
|
27
42
|
* The panel opens no workspace and runs no session: adding a workspace still
|
|
28
43
|
* happens where it always did. The only other surface is the access-mode
|
|
29
44
|
* prompt, which asks once how a newly added distro workspace is opened. Its
|
|
@@ -46,8 +61,10 @@ window.__ModuleLoader__.load({
|
|
|
46
61
|
const useState = React.useState;
|
|
47
62
|
const useEffect = React.useEffect;
|
|
48
63
|
|
|
49
|
-
/** The plugin's status route (checks on GET,
|
|
64
|
+
/** The plugin's status route (checks on GET, the full check on POST, clear on DELETE); the row registers this exact path. */
|
|
50
65
|
const STATUS_PATH = "/api/wsl-env/status";
|
|
66
|
+
/** The plugin version/upgrade route: GET reads, POST performs the confirmed upgrade. */
|
|
67
|
+
const PLUGIN_UPDATE_PATH = "/api/wsl-env/plugin-update";
|
|
51
68
|
/** The launch route for opening a distro workspace in VS Code through Remote-WSL. */
|
|
52
69
|
const OPEN_IN_APP_PATH = "/api/wsl-env/open-in-app";
|
|
53
70
|
/** Sidebar panel id and order: below the shipped plugin/schedule entries. */
|
|
@@ -75,19 +92,39 @@ window.__ModuleLoader__.load({
|
|
|
75
92
|
const samePath = (a, b) => typeof a === "string" && typeof b === "string" && normalize(a) === normalize(b);
|
|
76
93
|
|
|
77
94
|
/**
|
|
78
|
-
* Fetch
|
|
95
|
+
* Fetch one exact route and decode its JSON answer.
|
|
96
|
+
* @param path - the route's absolute path.
|
|
79
97
|
* @param query - the query string, including `?`, or empty.
|
|
80
|
-
* @param method - `GET`
|
|
98
|
+
* @param method - `GET` to read, `POST` to act, `DELETE` to clear.
|
|
81
99
|
* @returns the decoded body.
|
|
82
100
|
* @throws with the route's own error message.
|
|
83
101
|
*/
|
|
84
|
-
const
|
|
85
|
-
const answer = await fetch(
|
|
102
|
+
const jsonRequest = async (path, query, method = "GET") => {
|
|
103
|
+
const answer = await fetch(path + (query ?? ""), { method });
|
|
86
104
|
const body = await answer.json().catch(() => ({}));
|
|
87
|
-
if (!answer.ok) throw new Error(body.error ??
|
|
105
|
+
if (!answer.ok) throw new Error(body.error ?? `接口返回 ${answer.status}`);
|
|
88
106
|
return body;
|
|
89
107
|
};
|
|
90
108
|
|
|
109
|
+
/**
|
|
110
|
+
* The doctor route: list/quick check on GET, the full check (which also
|
|
111
|
+
* repairs plugin-owned state) on POST, and clearing stored results on
|
|
112
|
+
* DELETE.
|
|
113
|
+
* @param query - the query string, including `?`, or empty.
|
|
114
|
+
* @param method - `GET` for a check, `POST` for the full-check action,
|
|
115
|
+
* `DELETE` to clear one distro's result (named by `distro`) or all.
|
|
116
|
+
* @returns the decoded body.
|
|
117
|
+
*/
|
|
118
|
+
const statusRequest = (query, method = "GET") => jsonRequest(STATUS_PATH, query, method);
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* The plugin version route: read on GET, confirmed one-click upgrade on POST.
|
|
122
|
+
* @param query - the query string, including `?`, or empty.
|
|
123
|
+
* @param method - `GET` for a check, `POST` for the upgrade.
|
|
124
|
+
* @returns the decoded body.
|
|
125
|
+
*/
|
|
126
|
+
const pluginRequest = (query, method = "GET") => jsonRequest(PLUGIN_UPDATE_PATH, query, method);
|
|
127
|
+
|
|
91
128
|
// ── Access-mode records ────────────────────────────────────────────────
|
|
92
129
|
// The choice lives in the auto-preset row so the host can honor it without
|
|
93
130
|
// a plugin-specific client Remote (the Client Remote assembly fixes its
|
|
@@ -476,7 +513,23 @@ window.__ModuleLoader__.load({
|
|
|
476
513
|
gap: 18,
|
|
477
514
|
},
|
|
478
515
|
title: { fontSize: 20, fontWeight: 600, letterSpacing: 0.2 },
|
|
516
|
+
titleRow: { display: "flex", alignItems: "center", gap: 8, flexWrap: "wrap" },
|
|
479
517
|
subtitle: { fontSize: 12, opacity: 0.6, marginTop: 2 },
|
|
518
|
+
updateBanner: {
|
|
519
|
+
display: "flex",
|
|
520
|
+
alignItems: "center",
|
|
521
|
+
gap: 12,
|
|
522
|
+
padding: "10px 14px",
|
|
523
|
+
borderRadius: 10,
|
|
524
|
+
border: "1px solid rgba(224, 176, 74, 0.55)",
|
|
525
|
+
background: "rgba(224, 176, 74, 0.12)",
|
|
526
|
+
fontSize: 12,
|
|
527
|
+
lineHeight: 1.45,
|
|
528
|
+
},
|
|
529
|
+
updateBannerBody: { flex: 1, minWidth: 0, display: "flex", flexDirection: "column", gap: 2 },
|
|
530
|
+
updateBannerTitle: { fontWeight: 600, fontSize: 12.5 },
|
|
531
|
+
updateBannerText: { opacity: 0.82, wordBreak: "break-word" },
|
|
532
|
+
versionValue: { fontFamily: "var(--dsh-font-family-code, ui-monospace, monospace)", fontWeight: 600 },
|
|
480
533
|
card: {
|
|
481
534
|
border: "1px solid rgba(128, 128, 128, 0.28)",
|
|
482
535
|
borderRadius: 10,
|
|
@@ -501,8 +554,10 @@ window.__ModuleLoader__.load({
|
|
|
501
554
|
borderRadius: 6,
|
|
502
555
|
border: "1px solid rgba(128, 128, 128, 0.16)",
|
|
503
556
|
},
|
|
504
|
-
|
|
505
|
-
|
|
557
|
+
// Three actions can share the row with the distro name and its pill; let
|
|
558
|
+
// them wrap instead of overflowing a narrow sidebar.
|
|
559
|
+
rowHead: { display: "flex", alignItems: "center", gap: 10, flexWrap: "wrap" },
|
|
560
|
+
rowName: { flex: "1 1 120px", minWidth: 0, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" },
|
|
506
561
|
empty: { fontSize: 12, opacity: 0.55, padding: "4px 2px" },
|
|
507
562
|
notice: { fontSize: 12, color: "#ff8f6b" },
|
|
508
563
|
noticeOk: { fontSize: 12, color: "#5ecf86" },
|
|
@@ -686,12 +741,12 @@ window.__ModuleLoader__.load({
|
|
|
686
741
|
*/
|
|
687
742
|
function CheckPill({ state }) {
|
|
688
743
|
if (state === undefined || state.phase === undefined) return h(Pill, { label: "未检查", tone: "idle" });
|
|
689
|
-
if (state.phase === "checking") return h(Pill, { label: "
|
|
690
|
-
if (state.phase === "
|
|
744
|
+
if (state.phase === "checking") return h(Pill, { label: "快速检查中…", tone: "idle" });
|
|
745
|
+
if (state.phase === "fullChecking") {
|
|
691
746
|
return h(Pill, {
|
|
692
|
-
label:
|
|
747
|
+
label: "完整检查中…",
|
|
693
748
|
tone: "idle",
|
|
694
|
-
title:
|
|
749
|
+
title: "正在运行完整检查并修复插件自有状态",
|
|
695
750
|
});
|
|
696
751
|
}
|
|
697
752
|
if (state.phase === "refreshing") return h(Pill, { label: "复核中…", tone: "idle", title: "面板正在后台复核上次结果" });
|
|
@@ -708,7 +763,7 @@ window.__ModuleLoader__.load({
|
|
|
708
763
|
/**
|
|
709
764
|
* A numbered list of doctor findings.
|
|
710
765
|
* @param props - heading, findings, whether they block, and the ids the
|
|
711
|
-
*
|
|
766
|
+
* full check can repair.
|
|
712
767
|
* @returns the list, or null when there is nothing to show.
|
|
713
768
|
*/
|
|
714
769
|
function IssueList({ heading, items, severity, repairable }) {
|
|
@@ -736,8 +791,8 @@ window.__ModuleLoader__.load({
|
|
|
736
791
|
}
|
|
737
792
|
|
|
738
793
|
/**
|
|
739
|
-
* The
|
|
740
|
-
* @param props - the `fix.*` rows the
|
|
794
|
+
* The full check's repair rows: what the doctor did, with its status mark.
|
|
795
|
+
* @param props - the `fix.*` rows the full run answered with.
|
|
741
796
|
* @returns the list, or null when the run has no repair rows.
|
|
742
797
|
*/
|
|
743
798
|
function RepairList({ items }) {
|
|
@@ -913,6 +968,7 @@ window.__ModuleLoader__.load({
|
|
|
913
968
|
const [checks, setChecks] = useState({});
|
|
914
969
|
const [notice, setNotice] = useState(null);
|
|
915
970
|
const [accessPaths, setAccessPaths] = useState(null);
|
|
971
|
+
const [plugin, setPlugin] = useState({ phase: "loading" });
|
|
916
972
|
|
|
917
973
|
/** Re-read the Windows-access record (best effort; the panel still works without it). */
|
|
918
974
|
const loadAccessPaths = async () => {
|
|
@@ -924,6 +980,85 @@ window.__ModuleLoader__.load({
|
|
|
924
980
|
}
|
|
925
981
|
};
|
|
926
982
|
|
|
983
|
+
/**
|
|
984
|
+
* Read the plugin version route. The first load and any load after the
|
|
985
|
+
* host's cache TTL ask the host's plugin-manager for a fresh answer; a
|
|
986
|
+
* click forces one. The installed version stays visible while a later
|
|
987
|
+
* check fails, so the card never turns into a bare error.
|
|
988
|
+
* @param refresh - whether to bypass the host's version cache.
|
|
989
|
+
*/
|
|
990
|
+
const loadPlugin = async (refresh = false) => {
|
|
991
|
+
setPlugin((previous) => ({
|
|
992
|
+
...previous,
|
|
993
|
+
phase: previous.phase === "ready" || previous.phase === "error" ? "refreshing" : "loading",
|
|
994
|
+
}));
|
|
995
|
+
try {
|
|
996
|
+
const answer = await pluginRequest(refresh ? "?refresh=1" : "");
|
|
997
|
+
setPlugin({ phase: "ready", ...answer });
|
|
998
|
+
} catch (error) {
|
|
999
|
+
setPlugin((previous) => ({ ...previous, phase: "error", error: messageOf(error) }));
|
|
1000
|
+
}
|
|
1001
|
+
};
|
|
1002
|
+
|
|
1003
|
+
/**
|
|
1004
|
+
* Perform the confirmed one-click upgrade. The host decides whether the
|
|
1005
|
+
* latest release can replace the installed one and reports every step;
|
|
1006
|
+
* a lost response means the plugin may already be restarting, so the
|
|
1007
|
+
* panel says so instead of claiming failure.
|
|
1008
|
+
*/
|
|
1009
|
+
const upgrade = async () => {
|
|
1010
|
+
setNotice(null);
|
|
1011
|
+
setPlugin((previous) => ({ ...previous, phase: "updating" }));
|
|
1012
|
+
try {
|
|
1013
|
+
const answer = await pluginRequest("", "POST");
|
|
1014
|
+
if (answer.updated === true) {
|
|
1015
|
+
setPlugin((previous) => ({
|
|
1016
|
+
...previous,
|
|
1017
|
+
phase: "ready",
|
|
1018
|
+
status: "current",
|
|
1019
|
+
installed: typeof answer.installed === "string" ? answer.installed : previous.installed,
|
|
1020
|
+
running: typeof answer.running === "string" ? answer.running : previous.running,
|
|
1021
|
+
checkedAt: typeof answer.checkedAt === "number" ? answer.checkedAt : Date.now(),
|
|
1022
|
+
cached: false,
|
|
1023
|
+
canUpdate: false,
|
|
1024
|
+
latest: undefined,
|
|
1025
|
+
upgrade: answer,
|
|
1026
|
+
}));
|
|
1027
|
+
const target = typeof answer.to === "string" ? answer.to : "新版本";
|
|
1028
|
+
const running = typeof answer.running === "string" ? answer.running : "";
|
|
1029
|
+
setNotice({
|
|
1030
|
+
kind: answer.application === "applied" ? "ok" : "info",
|
|
1031
|
+
text: answer.application === "restart-required"
|
|
1032
|
+
? `已安装 ${target};当前仍运行 ${running || "旧版本"},重启 DSH 后生效。`
|
|
1033
|
+
: answer.application === "overridden"
|
|
1034
|
+
? `已安装 ${target};profile 中更高优先级的配置覆盖了 bundle 选择,请检查配置后重启 DSH。`
|
|
1035
|
+
: `已升级到 ${target};刷新页面后加载新版本的面板。`,
|
|
1036
|
+
});
|
|
1037
|
+
} else {
|
|
1038
|
+
const reason = answer.error?.diagnostic ?? answer.error?.code ?? "宿主未完成升级";
|
|
1039
|
+
const restoreFailure = answer.restoreError?.diagnostic ?? answer.restoreError?.code;
|
|
1040
|
+
const tail = answer.restored === true
|
|
1041
|
+
? "已回滚到原版本。"
|
|
1042
|
+
: restoreFailure !== undefined
|
|
1043
|
+
? `回滚也失败:${restoreFailure};请在 Plugins 页确认当前状态。`
|
|
1044
|
+
: answer.step === "remove"
|
|
1045
|
+
? "移除旧版本失败;请在 Plugins 页确认当前状态。"
|
|
1046
|
+
: "未安装目标版本。";
|
|
1047
|
+
const builds = Array.isArray(answer.pendingBuilds) && answer.pendingBuilds.length > 0
|
|
1048
|
+
? ` 需在 Plugins 页批准依赖脚本:${answer.pendingBuilds.join("、")}。`
|
|
1049
|
+
: "";
|
|
1050
|
+
setPlugin((previous) => ({ ...previous, phase: "ready", upgrade: answer }));
|
|
1051
|
+
setNotice({ kind: "error", text: `升级到 ${answer.to ?? "新版本"} 失败:${reason}。${tail}${builds}` });
|
|
1052
|
+
}
|
|
1053
|
+
} catch (error) {
|
|
1054
|
+
setPlugin((previous) => ({ ...previous, phase: "ready" }));
|
|
1055
|
+
setNotice({
|
|
1056
|
+
kind: "info",
|
|
1057
|
+
text: `升级请求未完成:${messageOf(error)}。插件可能正在重启;请刷新页面后确认版本。`,
|
|
1058
|
+
});
|
|
1059
|
+
}
|
|
1060
|
+
};
|
|
1061
|
+
|
|
927
1062
|
/**
|
|
928
1063
|
* Re-check one already-running distro without the user asking. The row
|
|
929
1064
|
* keeps its previous summary until the answer arrives; a doctor failure
|
|
@@ -981,9 +1116,12 @@ window.__ModuleLoader__.load({
|
|
|
981
1116
|
|
|
982
1117
|
useEffect(() => {
|
|
983
1118
|
// The first load may refresh stored results for running distros; the
|
|
984
|
-
// manual 刷新 button only re-reads the list.
|
|
1119
|
+
// manual 刷新 button only re-reads the list. The version read is
|
|
1120
|
+
// separate: it may consult the registry once, while the distro list
|
|
1121
|
+
// starts nothing.
|
|
985
1122
|
void loadDistros(true);
|
|
986
1123
|
void loadAccessPaths();
|
|
1124
|
+
void loadPlugin();
|
|
987
1125
|
}, []);
|
|
988
1126
|
|
|
989
1127
|
const check = async (distro) => {
|
|
@@ -998,14 +1136,15 @@ window.__ModuleLoader__.load({
|
|
|
998
1136
|
};
|
|
999
1137
|
|
|
1000
1138
|
/**
|
|
1001
|
-
* Run the full doctor with `--fix-owned
|
|
1002
|
-
*
|
|
1003
|
-
*
|
|
1139
|
+
* Run the full doctor with `--fix-owned`. The button is always
|
|
1140
|
+
* **完整检查**: the run may repair plugin-owned state on the way, but the
|
|
1141
|
+
* row does not relabel itself as a separate repair action. Only the
|
|
1142
|
+
* plugin's own state is touched.
|
|
1004
1143
|
* @param distro - the distro to run against.
|
|
1005
1144
|
*/
|
|
1006
|
-
const
|
|
1145
|
+
const fullCheck = async (distro) => {
|
|
1007
1146
|
setNotice(null);
|
|
1008
|
-
setChecks((previous) => ({ ...previous, [distro]: { ...previous[distro], phase: "
|
|
1147
|
+
setChecks((previous) => ({ ...previous, [distro]: { ...previous[distro], phase: "fullChecking" } }));
|
|
1009
1148
|
try {
|
|
1010
1149
|
const answer = await statusRequest(`?distro=${encodeURIComponent(distro)}`, "POST");
|
|
1011
1150
|
setChecks((previous) => ({ ...previous, [distro]: { phase: "done", ...answer } }));
|
|
@@ -1016,11 +1155,11 @@ window.__ModuleLoader__.load({
|
|
|
1016
1155
|
setNotice({
|
|
1017
1156
|
kind: fixed > 0 || remaining === 0 ? "ok" : "info",
|
|
1018
1157
|
text: fixed > 0 && remaining > 0
|
|
1019
|
-
?
|
|
1158
|
+
? `完整检查完成:已在 ${distro} 修复 ${String(fixed)} 项;仍有 ${String(remaining)} 项需按下方处理办法手动处理。`
|
|
1020
1159
|
: fixed > 0
|
|
1021
|
-
?
|
|
1160
|
+
? `完整检查完成:已在 ${distro} 修复 ${String(fixed)} 项;复检通过。`
|
|
1022
1161
|
: rows.length > 0
|
|
1023
|
-
?
|
|
1162
|
+
? `完整检查完成:尝试修复 ${String(rows.length)} 项但未通过复检;请按下方处理办法手动处理。`
|
|
1024
1163
|
: remaining > 0
|
|
1025
1164
|
? `完整检查完成;没有可自动修复项,${String(remaining)} 项需按下方处理办法手动处理。`
|
|
1026
1165
|
: `已在 ${distro} 完成完整检查,未发现待修项。`,
|
|
@@ -1030,6 +1169,94 @@ window.__ModuleLoader__.load({
|
|
|
1030
1169
|
}
|
|
1031
1170
|
};
|
|
1032
1171
|
|
|
1172
|
+
/**
|
|
1173
|
+
* Drop stored detection results through the status route. Clearing is
|
|
1174
|
+
* host-local housekeeping: it lists and probes nothing, so it works even
|
|
1175
|
+
* when `wsl.exe` or the doctor is unavailable. The rows are removed only
|
|
1176
|
+
* after the route confirms, so a failed request leaves the last result
|
|
1177
|
+
* visible with the reason.
|
|
1178
|
+
* @param distro - the distro whose result is cleared, or null for all.
|
|
1179
|
+
*/
|
|
1180
|
+
const clearResults = async (distro) => {
|
|
1181
|
+
setNotice(null);
|
|
1182
|
+
const query = distro === null ? "" : `?distro=${encodeURIComponent(distro)}`;
|
|
1183
|
+
try {
|
|
1184
|
+
const answer = await statusRequest(query, "DELETE");
|
|
1185
|
+
const cleared = typeof answer.cleared === "number" ? answer.cleared : 0;
|
|
1186
|
+
setChecks((previous) => {
|
|
1187
|
+
if (distro === null) return {};
|
|
1188
|
+
if (previous[distro] === undefined) return previous;
|
|
1189
|
+
const next = { ...previous };
|
|
1190
|
+
delete next[distro];
|
|
1191
|
+
return next;
|
|
1192
|
+
});
|
|
1193
|
+
setNotice({
|
|
1194
|
+
kind: "ok",
|
|
1195
|
+
text: distro === null
|
|
1196
|
+
? cleared > 0
|
|
1197
|
+
? `已清除全部检测结果(${String(cleared)} 项);发行版需要再次检查。`
|
|
1198
|
+
: "没有已保存的检测结果。"
|
|
1199
|
+
: cleared > 0
|
|
1200
|
+
? `已清除 ${distro} 的检测结果;需要时可再次检查。`
|
|
1201
|
+
: `没有找到 ${distro} 已保存的检测结果。`,
|
|
1202
|
+
});
|
|
1203
|
+
} catch (error) {
|
|
1204
|
+
setNotice({ kind: "error", text: `清除检测结果失败:${messageOf(error)}` });
|
|
1205
|
+
}
|
|
1206
|
+
};
|
|
1207
|
+
|
|
1208
|
+
const latest = plugin.latest !== null && typeof plugin.latest === "object" ? plugin.latest : undefined;
|
|
1209
|
+
const pluginAvailable = plugin.status === "available" && latest !== undefined && typeof latest.version === "string";
|
|
1210
|
+
const pluginBusy = plugin.phase === "loading" || plugin.phase === "refreshing" || plugin.phase === "updating";
|
|
1211
|
+
const runningDiffers = typeof plugin.installed === "string"
|
|
1212
|
+
&& typeof plugin.running === "string"
|
|
1213
|
+
&& plugin.installed !== plugin.running;
|
|
1214
|
+
const published = latest !== undefined && typeof latest.publishedAt === "string"
|
|
1215
|
+
&& !Number.isNaN(new Date(latest.publishedAt).getTime())
|
|
1216
|
+
? new Date(latest.publishedAt).toLocaleDateString()
|
|
1217
|
+
: undefined;
|
|
1218
|
+
let pluginStatusLine;
|
|
1219
|
+
if (plugin.phase === "loading") {
|
|
1220
|
+
pluginStatusLine = "正在读取版本信息…";
|
|
1221
|
+
} else if (plugin.phase === "updating") {
|
|
1222
|
+
pluginStatusLine = "正在通过宿主插件管理器升级…";
|
|
1223
|
+
} else if (plugin.phase === "refreshing") {
|
|
1224
|
+
pluginStatusLine = "正在检查更新…";
|
|
1225
|
+
} else if (plugin.phase === "error") {
|
|
1226
|
+
pluginStatusLine = `版本接口不可用:${plugin.error ?? "未响应"}`;
|
|
1227
|
+
} else if (pluginAvailable && latest !== undefined) {
|
|
1228
|
+
const parts = [`最新稳定版 ${latest.version}`];
|
|
1229
|
+
if (published !== undefined) parts.push(`发布于 ${published}`);
|
|
1230
|
+
if (latest.incompatible !== undefined) parts.push("需要更高的 DSH 版本");
|
|
1231
|
+
if (typeof latest.deprecated === "string") parts.push(`已弃用:${latest.deprecated}`);
|
|
1232
|
+
pluginStatusLine = parts.join(";");
|
|
1233
|
+
} else if (plugin.status === "current") {
|
|
1234
|
+
pluginStatusLine = typeof plugin.checkedAt === "number" ? `已是最新(检查于 ${checkedLabel(plugin.checkedAt)})` : "已是最新";
|
|
1235
|
+
} else if (plugin.status === "unavailable") {
|
|
1236
|
+
pluginStatusLine = `无法检查更新:${plugin.reason ?? "宿主未提供原因"}`;
|
|
1237
|
+
} else {
|
|
1238
|
+
pluginStatusLine = "尚未检查更新";
|
|
1239
|
+
}
|
|
1240
|
+
const updateText = latest === undefined ? "" : [
|
|
1241
|
+
`当前安装 ${plugin.installed ?? "未知"}${runningDiffers ? `(运行中 ${plugin.running})` : ""}。`,
|
|
1242
|
+
latest.incompatible !== undefined
|
|
1243
|
+
? "该版本要求更高的 DSH,请先升级 DeepSeek Harness。"
|
|
1244
|
+
: typeof latest.deprecated === "string"
|
|
1245
|
+
? `该版本已被标记为弃用:${latest.deprecated}。`
|
|
1246
|
+
: plugin.updateSupported !== true
|
|
1247
|
+
? "当前宿主的插件管理器不支持一键升级;请在 Plugins 页升级。"
|
|
1248
|
+
: "升级通过宿主插件管理器安装并启用;完成后按提示刷新页面或重启 DSH。",
|
|
1249
|
+
].join("");
|
|
1250
|
+
// A clear must not race an in-flight check: the late answer would put
|
|
1251
|
+
// the row back. Any busy row therefore blocks "clear all", and each
|
|
1252
|
+
// row's own clear is disabled while that row is busy.
|
|
1253
|
+
const busyAny = distros.some((distro) => {
|
|
1254
|
+
const state = checks[distro];
|
|
1255
|
+
return state !== undefined
|
|
1256
|
+
&& (state.phase === "checking" || state.phase === "fullChecking" || state.phase === "refreshing");
|
|
1257
|
+
});
|
|
1258
|
+
const hasAnyResult = distros.some((distro) => checks[distro] !== undefined);
|
|
1259
|
+
|
|
1033
1260
|
return h(
|
|
1034
1261
|
"div",
|
|
1035
1262
|
{ style: styles.panel },
|
|
@@ -1039,24 +1266,95 @@ window.__ModuleLoader__.load({
|
|
|
1039
1266
|
h(
|
|
1040
1267
|
"header",
|
|
1041
1268
|
null,
|
|
1042
|
-
h(
|
|
1043
|
-
|
|
1269
|
+
h(
|
|
1270
|
+
"div",
|
|
1271
|
+
{ style: styles.titleRow },
|
|
1272
|
+
h("div", { style: styles.title }, "WSL 环境"),
|
|
1273
|
+
typeof plugin.installed === "string" ? h(Pill, { label: `v${plugin.installed}`, tone: "idle", title: "已安装的插件版本" }) : null,
|
|
1274
|
+
pluginAvailable ? h(Pill, { label: `可升级 ${latest.version}`, tone: "blocked", title: "发现新的插件版本" }) : null,
|
|
1275
|
+
),
|
|
1276
|
+
h("div", { style: styles.subtitle }, "诊断、版本与安全修复:已安装的发行版、快速检查、插件升级,以及插件自有状态的修复。"),
|
|
1044
1277
|
),
|
|
1278
|
+
pluginAvailable ? h(
|
|
1279
|
+
"div",
|
|
1280
|
+
{ style: styles.updateBanner },
|
|
1281
|
+
h(
|
|
1282
|
+
"div",
|
|
1283
|
+
{ style: styles.updateBannerBody },
|
|
1284
|
+
h("div", { style: styles.updateBannerTitle }, `插件新版本 ${latest.version} 可用`),
|
|
1285
|
+
h("div", { style: styles.updateBannerText }, updateText),
|
|
1286
|
+
),
|
|
1287
|
+
plugin.canUpdate === true
|
|
1288
|
+
? h(Btn, {
|
|
1289
|
+
label: plugin.phase === "updating" ? "升级中…" : "一键升级",
|
|
1290
|
+
primary: true,
|
|
1291
|
+
disabled: pluginBusy,
|
|
1292
|
+
onClick: () => { void upgrade(); },
|
|
1293
|
+
})
|
|
1294
|
+
: null,
|
|
1295
|
+
) : null,
|
|
1045
1296
|
notice === null ? null : h("div", { style: notice.kind === "ok" ? styles.noticeOk : notice.kind === "info" ? styles.noticeInfo : styles.notice }, notice.text),
|
|
1046
1297
|
h(
|
|
1047
1298
|
Card,
|
|
1048
1299
|
{
|
|
1049
|
-
title: "
|
|
1300
|
+
title: "插件版本",
|
|
1050
1301
|
actions: h(Btn, {
|
|
1051
|
-
label: "
|
|
1302
|
+
label: plugin.phase === "updating" ? "升级中…" : plugin.phase === "refreshing" ? "检查中…" : "检查更新",
|
|
1052
1303
|
small: true,
|
|
1053
|
-
|
|
1304
|
+
disabled: pluginBusy,
|
|
1305
|
+
onClick: () => { void loadPlugin(true); },
|
|
1054
1306
|
}),
|
|
1055
1307
|
},
|
|
1308
|
+
h(
|
|
1309
|
+
"div",
|
|
1310
|
+
{ style: styles.row },
|
|
1311
|
+
h(
|
|
1312
|
+
"div",
|
|
1313
|
+
{ style: styles.rowHead },
|
|
1314
|
+
h("span", { style: styles.rowName, title: "dsh-plugin-wsl-env" }, "dsh-plugin-wsl-env"),
|
|
1315
|
+
typeof plugin.installed === "string" ? h("span", { style: styles.versionValue }, `已安装 ${plugin.installed}`) : null,
|
|
1316
|
+
runningDiffers ? h(Pill, { label: `运行中 ${plugin.running}`, tone: "blocked", title: "重启 DSH 后运行新版本" }) : null,
|
|
1317
|
+
pluginAvailable ? h(Pill, { label: "有更新", tone: "blocked" }) : null,
|
|
1318
|
+
plugin.status === "current" ? h(Pill, { label: "已是最新", tone: "ready" }) : null,
|
|
1319
|
+
plugin.status === "unavailable" ? h(Pill, { label: "无法检查", tone: "idle" }) : null,
|
|
1320
|
+
),
|
|
1321
|
+
h("div", { style: styles.detail }, h("span", { style: { wordBreak: "break-word" } }, pluginStatusLine)),
|
|
1322
|
+
),
|
|
1323
|
+
plugin.status === "unavailable" && plugin.problem === "not-updatable"
|
|
1324
|
+
? h("div", { style: styles.hint }, "当前安装不是可由 registry 替换的 profile 依赖(例如链接安装或本地镜像);请改用 Plugins 页的安装路径,或同步本地副本后重启 DSH。")
|
|
1325
|
+
: pluginAvailable && plugin.updateSupported !== true
|
|
1326
|
+
? h("div", { style: styles.hint }, "当前宿主的插件管理器不支持一键升级;请在 Plugins 页升级。")
|
|
1327
|
+
: null,
|
|
1328
|
+
h(
|
|
1329
|
+
"div",
|
|
1330
|
+
{ style: styles.hint },
|
|
1331
|
+
"版本检查委托给宿主的插件管理器(与 Plugins 页同源):读取 registry、弃用标记与 DSH/peer 兼容性。一键升级只在点击后执行,不会自动安装;完成后按提示刷新页面或重启 DSH。无法自动升级时,请在 Plugins 页手动安装新版本。",
|
|
1332
|
+
),
|
|
1333
|
+
),
|
|
1334
|
+
h(
|
|
1335
|
+
Card,
|
|
1336
|
+
{
|
|
1337
|
+
title: "发行版与环境状态",
|
|
1338
|
+
actions: h(
|
|
1339
|
+
"div",
|
|
1340
|
+
{ style: styles.titleRow },
|
|
1341
|
+
h(Btn, {
|
|
1342
|
+
label: "清除全部",
|
|
1343
|
+
small: true,
|
|
1344
|
+
disabled: phase !== "ready" || !hasAnyResult || busyAny,
|
|
1345
|
+
onClick: () => { void clearResults(null); },
|
|
1346
|
+
}),
|
|
1347
|
+
h(Btn, {
|
|
1348
|
+
label: "刷新",
|
|
1349
|
+
small: true,
|
|
1350
|
+
onClick: () => { void loadDistros(false); void loadAccessPaths(); },
|
|
1351
|
+
}),
|
|
1352
|
+
),
|
|
1353
|
+
},
|
|
1056
1354
|
h(
|
|
1057
1355
|
"div",
|
|
1058
1356
|
{ style: styles.hint },
|
|
1059
|
-
"
|
|
1357
|
+
"“快速检查”运行一次 doctor 的快速检查(与 /wsl-doctor 同源):验证该发行版的 bwrap、systemd 与 Linger 等前置项。“完整检查”运行完整 doctor,并只修复插件自有状态(残留 session scope、损坏的 agent 缓存)后复检、显示 before→after。两个按钮都可在结果出现后再次点击,每次都重新执行。自动修复不安装软件包、不改写 Windows 配置;其余告警按各自处理办法手动处理。检查会让停止的发行版启动,所以只在点击时执行;页面加载的后台复核只针对正在运行的发行版,失败会按实际观测覆盖并标为“后台”来源。“清除”删除该发行版本机保存的检测结果,“清除全部”清空所有结果;两者都不探测、不修改发行版,但清除后需再次检查。",
|
|
1060
1358
|
),
|
|
1061
1359
|
phase === "loading"
|
|
1062
1360
|
? h("div", { style: styles.empty }, "加载中…")
|
|
@@ -1068,9 +1366,10 @@ window.__ModuleLoader__.load({
|
|
|
1068
1366
|
const state = checks[distro];
|
|
1069
1367
|
const done = state !== undefined && state.phase === "done";
|
|
1070
1368
|
const checking = state !== undefined && state.phase === "checking";
|
|
1071
|
-
const
|
|
1369
|
+
const fullChecking = state !== undefined && state.phase === "fullChecking";
|
|
1072
1370
|
const refreshing = state !== undefined && state.phase === "refreshing";
|
|
1073
|
-
const busy = checking ||
|
|
1371
|
+
const busy = checking || fullChecking || refreshing;
|
|
1372
|
+
const hasResult = state !== undefined && (state.phase === "done" || state.phase === "error");
|
|
1074
1373
|
const repairable = Array.isArray(state?.repairable) ? state.repairable : [];
|
|
1075
1374
|
const canRepair = done && repairable.length > 0;
|
|
1076
1375
|
const findings = done
|
|
@@ -1086,29 +1385,33 @@ window.__ModuleLoader__.load({
|
|
|
1086
1385
|
h("span", { style: styles.rowName, title: distro }, distro),
|
|
1087
1386
|
h(CheckPill, { state }),
|
|
1088
1387
|
h(Btn, {
|
|
1089
|
-
label: checking ? "
|
|
1388
|
+
label: checking ? "快速检查中…" : refreshing ? "后台检查中…" : "快速检查",
|
|
1090
1389
|
small: true,
|
|
1091
1390
|
primary: state === undefined,
|
|
1092
1391
|
disabled: busy,
|
|
1093
1392
|
onClick: () => { void check(distro); },
|
|
1094
1393
|
}),
|
|
1095
|
-
|
|
1394
|
+
h(Btn, {
|
|
1395
|
+
label: fullChecking ? "完整检查中…" : "完整检查",
|
|
1396
|
+
small: true,
|
|
1397
|
+
disabled: busy,
|
|
1398
|
+
onClick: () => { void fullCheck(distro); },
|
|
1399
|
+
}),
|
|
1400
|
+
hasResult
|
|
1096
1401
|
? h(Btn, {
|
|
1097
|
-
label:
|
|
1402
|
+
label: "清除",
|
|
1098
1403
|
small: true,
|
|
1099
1404
|
disabled: busy,
|
|
1100
|
-
onClick: () => { void
|
|
1405
|
+
onClick: () => { void clearResults(distro); },
|
|
1101
1406
|
})
|
|
1102
1407
|
: null,
|
|
1103
1408
|
),
|
|
1104
1409
|
state === undefined
|
|
1105
|
-
? h("div", { style: styles.hint }, "
|
|
1410
|
+
? h("div", { style: styles.hint }, "尚未检查:点击“快速检查”(约 10 秒)或“完整检查”;两者都会启动停止的发行版。")
|
|
1106
1411
|
: state.phase === "checking"
|
|
1107
1412
|
? h("div", { style: styles.hint }, "正在运行快速检查…(会启动停止的发行版)")
|
|
1108
|
-
: state.phase === "
|
|
1109
|
-
? h("div", { style: styles.hint },
|
|
1110
|
-
? "正在运行完整检查(按上次结果没有可自动修复项)…"
|
|
1111
|
-
: "正在运行完整检查并修复插件自有状态…")
|
|
1413
|
+
: state.phase === "fullChecking"
|
|
1414
|
+
? h("div", { style: styles.hint }, "正在运行完整检查,并修复插件自有状态(残留 session scope、损坏的 agent 缓存)…")
|
|
1112
1415
|
: state.phase === "error"
|
|
1113
1416
|
? h("div", { style: styles.detail }, h("span", { style: styles.failure }, state.error))
|
|
1114
1417
|
: h(
|
|
@@ -1133,7 +1436,7 @@ window.__ModuleLoader__.load({
|
|
|
1133
1436
|
}),
|
|
1134
1437
|
findings > 0
|
|
1135
1438
|
? h("div", { style: styles.hint }, canRepair
|
|
1136
|
-
? "
|
|
1439
|
+
? "标有“可自动修复”的项会由“完整检查”处理;其余项目需按处理办法手动处理。"
|
|
1137
1440
|
: "以上项目没有可自动修复项,需按各自处理办法手动处理。自动修复只覆盖残留 session scope 与损坏的 agent 缓存。")
|
|
1138
1441
|
: null,
|
|
1139
1442
|
h(CheckDetails, { state }),
|
package/cordis.patch.yml
CHANGED
|
@@ -167,11 +167,13 @@
|
|
|
167
167
|
# installed distros and, for one named distro, runs the quick doctor CLI
|
|
168
168
|
# and returns its digested verdict; `POST` on the same route runs the full
|
|
169
169
|
# doctor with `--fix-owned` (stale scopes and a broken agent cache only,
|
|
170
|
-
# both re-verified) and answers with the fix rows.
|
|
171
|
-
#
|
|
172
|
-
#
|
|
173
|
-
#
|
|
174
|
-
#
|
|
170
|
+
# both re-verified) and answers with the fix rows. `DELETE` clears one
|
|
171
|
+
# named distro's stored verdict, or every stored verdict when no distro is
|
|
172
|
+
# named; clearing is local and never lists or probes distros. The route
|
|
173
|
+
# rides the authenticated /api channel (`ctx.connection.fetch`), so only
|
|
174
|
+
# the owner browser reads it; a composition without the Web connection
|
|
175
|
+
# leaves this row inert. Probing a stopped distro boots it, so a check or
|
|
176
|
+
# repair only ever starts from an explicit click — never from listing.
|
|
175
177
|
- id: wsl-status
|
|
176
178
|
name: 'dsh-plugin-wsl-env/status'
|
|
177
179
|
config:
|
|
@@ -179,6 +181,19 @@
|
|
|
179
181
|
timeoutMs: 90000
|
|
180
182
|
wslPath: wsl.exe
|
|
181
183
|
|
|
184
|
+
# Version information and one-click upgrade for the same sidebar panel.
|
|
185
|
+
# The route answers with the installed/running plugin versions, the latest
|
|
186
|
+
# stable release that can replace them, and the last check's outcome; the
|
|
187
|
+
# host's plugin-manager owns the registry lookup (`listVersions`) and the
|
|
188
|
+
# install (`updateBundle`). A click in the panel is the only thing that
|
|
189
|
+
# starts an update — the row never upgrades on its own. The update installs
|
|
190
|
+
# the new package and lets the host's HMR/restart policy decide when it
|
|
191
|
+
# takes effect; the panel reports restart-required and rollback outcomes.
|
|
192
|
+
- id: wsl-plugin-update
|
|
193
|
+
name: 'dsh-plugin-wsl-env/plugin-update'
|
|
194
|
+
config:
|
|
195
|
+
cacheMs: 600000
|
|
196
|
+
|
|
182
197
|
# The human-facing `/wsl-doctor` command (the composer button's target):
|
|
183
198
|
# registered globally so any session can run the diagnosis, not only WSL
|
|
184
199
|
# preset agents. The handler spawns the standalone doctor CLI — no model
|
|
@@ -256,11 +271,12 @@
|
|
|
256
271
|
# Update check: on a slow timer (first check 2-10 minutes after boot, then
|
|
257
272
|
# once a day) ask the host's plugin-manager whether a newer stable release
|
|
258
273
|
# of this package exists, and publish one fact the shell-env row serves as
|
|
259
|
-
# DSH_WSL_PLUGIN_UPDATE.
|
|
260
|
-
# its own (the host's plugin-manager does the registry work)
|
|
261
|
-
#
|
|
262
|
-
#
|
|
263
|
-
#
|
|
274
|
+
# DSH_WSL_PLUGIN_UPDATE. Delegated only: it never fetches the registry on
|
|
275
|
+
# its own (the host's plugin-manager does the registry work) and never
|
|
276
|
+
# installs; the one-click upgrade is the separate wsl-plugin-update row's
|
|
277
|
+
# explicit POST. A host without the service — or a bundle loaded from a
|
|
278
|
+
# linked checkout — skips the check quietly. A fresh version takes effect
|
|
279
|
+
# after HMR or the next DSH restart, as the host reports.
|
|
264
280
|
- id: wsl-update-check
|
|
265
281
|
name: 'dsh-plugin-wsl-env/update-check'
|
|
266
282
|
config:
|