dsh-desktop-enhance 0.9.8 → 0.10.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/README.md +6 -0
- package/lib/client.js +238 -3
- package/lib/index.d.ts +314 -172
- package/lib/index.js +852 -49
- package/package.json +14 -12
package/README.md
CHANGED
|
@@ -85,6 +85,12 @@ Web 版(浏览器里打开的那种)**不提供插件查找的默认快捷
|
|
|
85
85
|
改坏了有「恢复默认」一键还原。与出厂模板**一字不差**时会存成空串(也就是「用默认」),所以恢复默认之后配置是干净的。
|
|
86
86
|
|
|
87
87
|
|
|
88
|
+
### 压缩后恢复近期原文
|
|
89
|
+
|
|
90
|
+
在摘要旁补一份近期原话备忘录:从宿主保留尾部之前往前取最近 10 个有效轮,人类对话与工作回报合计。预算上限为 32,768 估算 tokens;上下文占用弹窗可按会话调整轮数和预算,轮数设为 0 后停止未来恢复。超预算先丢最老整轮;只有最新单轮也放不下时,才对助手答复、工作回报做明确标记的头尾摘录,人类输入与审批答案不截断。图片仅恢复名称和附件定位,不重发像素。弹窗可查看上次实际恢复的总轮数、部分轮与原文。
|
|
91
|
+
|
|
92
|
+
原文提取不额外调用模型,不把历史命令当成新的授权;预算维护仍可能调用原生摘要。Fork 沿用现有规则,不复制会话设置覆盖。Host 变更需重启 App,范围与限制见[近期原文恢复](docs/features/recent-conversation.md)。
|
|
93
|
+
|
|
88
94
|
### 图片 token 估价
|
|
89
95
|
|
|
90
96
|
默认补齐未声明图片价格的模型路由,让上下文计量与自动压缩保留预算计入图片视觉 tokens;已有适配器定价优先。没有独立界面开关,可通过插件 Config 的 `imagePricing: false` 停用。估价不改 provider usage,也不保证压后固定占比。安装此 Host 变更后需完整重启应用;规则与限制见[图片 token 估价](docs/features/image-pricing.md)。
|
package/lib/client.js
CHANGED
|
@@ -9421,6 +9421,54 @@ ABORT_ERR ETIMEDOUT ECONNREFUSED ECONNRESET EPIPE EADDRINUSE ENOSPC EACCES STORE
|
|
|
9421
9421
|
//#region \0dsh-desktop-enhance-css:/Users/lijiechengbj/projects/AI-agents/dsh-desktop-enhance/src/client/abnormal-fork/styles.css.mjs
|
|
9422
9422
|
var styles_css_default$1 = "\n:root:not([data-desktop-enhance-off-abnormal-fork]) [data-desktop-enhance-abnormal-fork-button] {\n cursor: pointer;\n opacity: 1;\n}\n:root:not([data-desktop-enhance-off-abnormal-fork]) [data-desktop-enhance-abnormal-fork-button][aria-disabled=\"true\"] {\n cursor: default;\n opacity: .45;\n}\n[data-desktop-enhance-abnormal-fork] { display: contents; }\n[data-desktop-enhance-abnormal-fork-actions] {\n display: flex;\n align-items: center;\n gap: 8px;\n height: calc(28px + var(--dsh-content-font-delta, 0px));\n}\n[data-desktop-enhance-abnormal-fork-new] {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: calc(28px + var(--dsh-content-font-delta, 0px));\n height: calc(28px + var(--dsh-content-font-delta, 0px));\n padding: 6px;\n border: none;\n border-radius: var(--dsw-radius-sm);\n background: transparent;\n color: var(--dsw-alias-label-tertiary);\n cursor: pointer;\n}\n[data-desktop-enhance-abnormal-fork-new] svg {\n width: calc(17px + var(--dsh-content-font-delta, 0px));\n height: calc(17px + var(--dsh-content-font-delta, 0px));\n}\n[data-desktop-enhance-abnormal-fork-new]:hover {\n background: var(--dsw-alias-interactive-bg-hover);\n color: var(--dsw-alias-label-primary);\n}\n[data-desktop-enhance-abnormal-fork-new]:focus-visible {\n outline: 2px solid var(--dsw-alias-state-business-primary);\n outline-offset: 2px;\n}\n[data-desktop-enhance-abnormal-fork-new]:disabled { opacity: .45; cursor: default; }\n[data-desktop-enhance-abnormal-fork-error] {\n color: var(--dsw-alias-label-primary);\n font-size: var(--dsh-content-font-size-secondary, 13px);\n}\n";
|
|
9423
9423
|
//#endregion
|
|
9424
|
+
//#region src/shared/recent-conversation.ts
|
|
9425
|
+
const DEFAULT_RECENT_CONVERSATION_MAX_TOKENS = 32768;
|
|
9426
|
+
//#endregion
|
|
9427
|
+
//#region src/client/context-manager/recent.ts
|
|
9428
|
+
function parseRecentInput(field, text) {
|
|
9429
|
+
const trimmed = text.trim();
|
|
9430
|
+
if (trimmed === "") return {
|
|
9431
|
+
ok: true,
|
|
9432
|
+
value: null
|
|
9433
|
+
};
|
|
9434
|
+
if (!/^\d+$/.test(trimmed)) return { ok: false };
|
|
9435
|
+
const value = Number(trimmed);
|
|
9436
|
+
return integerIn(value, field === "turns" ? 0 : 2048, field === "turns" ? 50 : 65536) ? {
|
|
9437
|
+
ok: true,
|
|
9438
|
+
value
|
|
9439
|
+
} : { ok: false };
|
|
9440
|
+
}
|
|
9441
|
+
function integerIn(value, min, max) {
|
|
9442
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value >= min && value <= max;
|
|
9443
|
+
}
|
|
9444
|
+
function readRecentConversation(value) {
|
|
9445
|
+
if (value === null || typeof value !== "object") return void 0;
|
|
9446
|
+
const raw = value;
|
|
9447
|
+
if (!integerIn(raw.turns, 0, 50) || !integerIn(raw.maxTokens, 2048, 65536) || typeof raw.customized !== "boolean") return void 0;
|
|
9448
|
+
let last = null;
|
|
9449
|
+
if (raw.last !== null) {
|
|
9450
|
+
if (typeof raw.last !== "object" || raw.last === void 0) return void 0;
|
|
9451
|
+
const result = raw.last;
|
|
9452
|
+
if (result.state !== "restored" && result.state !== "skipped" && result.state !== "failed") return void 0;
|
|
9453
|
+
if (result.reason !== void 0 && typeof result.reason !== "string") return void 0;
|
|
9454
|
+
if (!integerIn(result.restoredTurns, 0, Number.MAX_SAFE_INTEGER) || !integerIn(result.partialTurns, 0, Number.MAX_SAFE_INTEGER) || !integerIn(result.estimatedTokens, 0, Number.MAX_SAFE_INTEGER) || typeof result.details !== "string") return void 0;
|
|
9455
|
+
last = {
|
|
9456
|
+
state: result.state,
|
|
9457
|
+
...typeof result.reason === "string" ? { reason: result.reason } : {},
|
|
9458
|
+
restoredTurns: result.restoredTurns,
|
|
9459
|
+
partialTurns: result.partialTurns,
|
|
9460
|
+
estimatedTokens: result.estimatedTokens,
|
|
9461
|
+
details: result.details
|
|
9462
|
+
};
|
|
9463
|
+
}
|
|
9464
|
+
return {
|
|
9465
|
+
turns: raw.turns,
|
|
9466
|
+
maxTokens: raw.maxTokens,
|
|
9467
|
+
customized: raw.customized,
|
|
9468
|
+
last
|
|
9469
|
+
};
|
|
9470
|
+
}
|
|
9471
|
+
//#endregion
|
|
9424
9472
|
//#region src/client/context-manager/popover.ts
|
|
9425
9473
|
const CONTEXT_ENHANCE_ATTR = "data-desktop-enhance-context-controls";
|
|
9426
9474
|
const METER_LABEL_PREFIX = "上下文已用";
|
|
@@ -9438,7 +9486,9 @@ ABORT_ERR ETIMEDOUT ECONNREFUSED ECONNRESET EPIPE EADDRINUSE ENOSPC EACCES STORE
|
|
|
9438
9486
|
window: pressure.window
|
|
9439
9487
|
} : null;
|
|
9440
9488
|
const pruneOutcome = readOutcome(raw.pruneOutcome);
|
|
9489
|
+
const recentConversation = readRecentConversation(raw.recentConversation);
|
|
9441
9490
|
return {
|
|
9491
|
+
...recentConversation !== void 0 ? { recentConversation } : {},
|
|
9442
9492
|
pressure: parsedPressure,
|
|
9443
9493
|
nativeThreshold: typeof nativeField === "number" ? nativeField : null,
|
|
9444
9494
|
effectiveThreshold: typeof effective === "number" ? effective : null,
|
|
@@ -9501,6 +9551,14 @@ ABORT_ERR ETIMEDOUT ECONNREFUSED ECONNRESET EPIPE EADDRINUSE ENOSPC EACCES STORE
|
|
|
9501
9551
|
}, "setCap");
|
|
9502
9552
|
return body === null ? null : readSnapshot(body.snapshot);
|
|
9503
9553
|
},
|
|
9554
|
+
async saveRecentConversation(sessionId, value) {
|
|
9555
|
+
const body = await request(sessionId, {
|
|
9556
|
+
action: "setRecentConversation",
|
|
9557
|
+
sessionId,
|
|
9558
|
+
value
|
|
9559
|
+
}, "setRecentConversation");
|
|
9560
|
+
return body === null ? null : readSnapshot(body.snapshot);
|
|
9561
|
+
},
|
|
9504
9562
|
async prune(sessionId) {
|
|
9505
9563
|
const body = await request(sessionId, {
|
|
9506
9564
|
action: "prune",
|
|
@@ -9548,7 +9606,7 @@ ABORT_ERR ETIMEDOUT ECONNREFUSED ECONNRESET EPIPE EADDRINUSE ENOSPC EACCES STORE
|
|
|
9548
9606
|
if (doc === void 0 || typeof doc.querySelector !== "function") return false;
|
|
9549
9607
|
return doc.querySelector("[role=\"dialog\"]") !== null;
|
|
9550
9608
|
}
|
|
9551
|
-
function installContextEnhance(bridge, sessionId, enabled, subscribeSettings) {
|
|
9609
|
+
function installContextEnhance(bridge, sessionId, enabled, subscribeSettings, subscribePolicy) {
|
|
9552
9610
|
const doc = globalThis.document;
|
|
9553
9611
|
if (doc === void 0 || typeof doc.addEventListener !== "function" || doc.body === void 0) return () => void 0;
|
|
9554
9612
|
if (typeof globalThis.MutationObserver !== "function") return () => void 0;
|
|
@@ -9557,6 +9615,13 @@ ABORT_ERR ETIMEDOUT ECONNREFUSED ECONNRESET EPIPE EADDRINUSE ENOSPC EACCES STORE
|
|
|
9557
9615
|
let cachedSnapshot = null;
|
|
9558
9616
|
let activePanel = null;
|
|
9559
9617
|
let generation = 0;
|
|
9618
|
+
let unsubscribePolicy;
|
|
9619
|
+
let policyDirty = false;
|
|
9620
|
+
const stopPolicy = () => {
|
|
9621
|
+
unsubscribePolicy?.();
|
|
9622
|
+
unsubscribePolicy = void 0;
|
|
9623
|
+
policyDirty = false;
|
|
9624
|
+
};
|
|
9560
9625
|
let pruneRevision = -1;
|
|
9561
9626
|
let pollTimer;
|
|
9562
9627
|
let pruneDiagnostic = null;
|
|
@@ -9579,6 +9644,13 @@ ABORT_ERR ETIMEDOUT ECONNREFUSED ECONNRESET EPIPE EADDRINUSE ENOSPC EACCES STORE
|
|
|
9579
9644
|
pollTimer = void 0;
|
|
9580
9645
|
};
|
|
9581
9646
|
const isCurrent = (mine, id) => !disposed && generation === mine && enabled() && sessionId() === id && findMeterPanel()?.panel === activePanel;
|
|
9647
|
+
const flushPolicyInvalidation = () => {
|
|
9648
|
+
if (!policyDirty || state.busy) return;
|
|
9649
|
+
policyDirty = false;
|
|
9650
|
+
generation++;
|
|
9651
|
+
cancelPoll();
|
|
9652
|
+
reload();
|
|
9653
|
+
};
|
|
9582
9654
|
const schedulePoll = () => {
|
|
9583
9655
|
if (state.outcome?.state !== "queued") {
|
|
9584
9656
|
cancelPoll();
|
|
@@ -9689,6 +9761,8 @@ ABORT_ERR ETIMEDOUT ECONNREFUSED ECONNRESET EPIPE EADDRINUSE ENOSPC EACCES STORE
|
|
|
9689
9761
|
edit.textContent = effective === null ? "—" : `~${formatTokensCompact(effective)}`;
|
|
9690
9762
|
edit.addEventListener("click", () => {
|
|
9691
9763
|
state.editing = true;
|
|
9764
|
+
state.recentField = void 0;
|
|
9765
|
+
state.recentNote = "";
|
|
9692
9766
|
state.draft = formatCapInput(snapshot?.cap ?? null);
|
|
9693
9767
|
state.note = "";
|
|
9694
9768
|
render(null);
|
|
@@ -9714,6 +9788,125 @@ ABORT_ERR ETIMEDOUT ECONNREFUSED ECONNRESET EPIPE EADDRINUSE ENOSPC EACCES STORE
|
|
|
9714
9788
|
capNote.setAttribute("role", "status");
|
|
9715
9789
|
capNote.textContent = state.note !== "" ? state.note : snapshot === null ? "" : describeCap(snapshot);
|
|
9716
9790
|
if (capNote.textContent !== "") host.appendChild(capNote);
|
|
9791
|
+
const recent = snapshot?.recentConversation;
|
|
9792
|
+
for (const field of ["turns", "maxTokens"]) {
|
|
9793
|
+
const row = globalThis.document.createElement("div");
|
|
9794
|
+
row.className = "de-context-row";
|
|
9795
|
+
const label = globalThis.document.createElement("span");
|
|
9796
|
+
label.className = "de-context-label";
|
|
9797
|
+
label.textContent = field === "turns" ? "近期原文轮数" : "近期原文预算";
|
|
9798
|
+
row.appendChild(label);
|
|
9799
|
+
if (state.recentField === field && recent !== void 0) {
|
|
9800
|
+
const controls = globalThis.document.createElement("span");
|
|
9801
|
+
controls.className = "de-context-controls-inline";
|
|
9802
|
+
const input = globalThis.document.createElement("input");
|
|
9803
|
+
input.className = "de-context-input de-context-recent-input";
|
|
9804
|
+
input.value = state.recentDraft;
|
|
9805
|
+
input.disabled = state.busy;
|
|
9806
|
+
input.setAttribute("inputmode", "numeric");
|
|
9807
|
+
input.setAttribute("aria-label", field === "turns" ? "近期原文恢复轮数(0至50轮)" : "近期原文恢复预算(2048至65536 Tokens)");
|
|
9808
|
+
input.addEventListener("input", () => {
|
|
9809
|
+
state.recentDraft = input.value;
|
|
9810
|
+
});
|
|
9811
|
+
const save = globalThis.document.createElement("button");
|
|
9812
|
+
save.type = "button";
|
|
9813
|
+
save.className = "de-context-btn de-context-recent-save";
|
|
9814
|
+
save.textContent = "保存";
|
|
9815
|
+
save.disabled = state.busy;
|
|
9816
|
+
save.addEventListener("click", () => {
|
|
9817
|
+
const parsed = parseRecentInput(field, state.recentDraft);
|
|
9818
|
+
if (!parsed.ok) {
|
|
9819
|
+
state.recentNote = field === "turns" ? "请输入0至50的整数;留空恢复默认" : "请输入2048至65536的整数;留空恢复默认";
|
|
9820
|
+
render(null);
|
|
9821
|
+
return;
|
|
9822
|
+
}
|
|
9823
|
+
commitRecent({ [field]: parsed.value });
|
|
9824
|
+
});
|
|
9825
|
+
const cancel = globalThis.document.createElement("button");
|
|
9826
|
+
cancel.type = "button";
|
|
9827
|
+
cancel.className = "de-context-btn de-context-recent-cancel";
|
|
9828
|
+
cancel.textContent = "取消";
|
|
9829
|
+
cancel.disabled = state.busy;
|
|
9830
|
+
cancel.addEventListener("click", () => {
|
|
9831
|
+
state.recentField = void 0;
|
|
9832
|
+
state.recentNote = "";
|
|
9833
|
+
render(null);
|
|
9834
|
+
});
|
|
9835
|
+
controls.append(input, save, cancel);
|
|
9836
|
+
row.appendChild(controls);
|
|
9837
|
+
} else {
|
|
9838
|
+
const edit = globalThis.document.createElement("button");
|
|
9839
|
+
edit.type = "button";
|
|
9840
|
+
edit.className = `de-context-btn de-context-recent-${field}-edit`;
|
|
9841
|
+
edit.disabled = state.busy || recent === void 0 || bridge.saveRecentConversation === void 0;
|
|
9842
|
+
edit.setAttribute("aria-label", field === "turns" ? "编辑近期原文恢复轮数" : "编辑近期原文恢复预算");
|
|
9843
|
+
edit.textContent = recent === void 0 ? "不可用" : field === "turns" ? recent.turns === 0 ? "已关闭" : `${recent.turns} 轮` : `${recent.maxTokens} Tokens`;
|
|
9844
|
+
edit.addEventListener("click", () => {
|
|
9845
|
+
if (recent === void 0) return;
|
|
9846
|
+
state.editing = false;
|
|
9847
|
+
state.note = "";
|
|
9848
|
+
state.recentField = field;
|
|
9849
|
+
state.recentDraft = String(recent[field]);
|
|
9850
|
+
state.recentNote = "";
|
|
9851
|
+
render(null);
|
|
9852
|
+
globalThis.document.querySelector(".de-context-recent-input")?.focus();
|
|
9853
|
+
});
|
|
9854
|
+
const value = globalThis.document.createElement("span");
|
|
9855
|
+
value.className = "de-context-value";
|
|
9856
|
+
value.appendChild(edit);
|
|
9857
|
+
if (recent?.customized && bridge.saveRecentConversation !== void 0) {
|
|
9858
|
+
const reset = globalThis.document.createElement("button");
|
|
9859
|
+
reset.type = "button";
|
|
9860
|
+
reset.className = `de-context-btn de-context-reset de-context-recent-${field}-reset`;
|
|
9861
|
+
reset.textContent = "恢复默认";
|
|
9862
|
+
reset.setAttribute("aria-label", field === "turns" ? "恢复近期原文默认轮数" : "恢复近期原文默认预算");
|
|
9863
|
+
reset.disabled = state.busy;
|
|
9864
|
+
reset.addEventListener("click", () => {
|
|
9865
|
+
commitRecent({ [field]: null });
|
|
9866
|
+
});
|
|
9867
|
+
value.appendChild(reset);
|
|
9868
|
+
}
|
|
9869
|
+
row.appendChild(value);
|
|
9870
|
+
}
|
|
9871
|
+
host.appendChild(row);
|
|
9872
|
+
}
|
|
9873
|
+
const recentNote = globalThis.document.createElement("div");
|
|
9874
|
+
recentNote.className = "de-context-note de-context-recent-note";
|
|
9875
|
+
recentNote.setAttribute("role", "status");
|
|
9876
|
+
recentNote.textContent = state.recentNote || (recent === void 0 || bridge.saveRecentConversation === void 0 ? "近期原文恢复不可用,请重启应用后重试" : `${recent.customized ? "本会话自定义" : "跟随默认"};从宿主保留尾部之前取最近总计 ${recent.turns} 轮作为候选;0 轮关闭恢复`);
|
|
9877
|
+
host.appendChild(recentNote);
|
|
9878
|
+
if (recent !== void 0) {
|
|
9879
|
+
const result = globalThis.document.createElement("div");
|
|
9880
|
+
result.className = "de-context-note de-context-recent-result";
|
|
9881
|
+
const status = globalThis.document.createElement("div");
|
|
9882
|
+
status.className = "de-context-recent-state";
|
|
9883
|
+
status.textContent = recent.last === null ? "暂无上次恢复记录" : recent.last.state === "restored" ? "已恢复" : recent.last.state === "skipped" ? "已跳过" : "恢复失败";
|
|
9884
|
+
result.appendChild(status);
|
|
9885
|
+
if (recent.last !== null) {
|
|
9886
|
+
if (recent.last.reason) {
|
|
9887
|
+
const reason = globalThis.document.createElement("div");
|
|
9888
|
+
reason.className = "de-context-recent-reason";
|
|
9889
|
+
reason.textContent = recent.last.reason;
|
|
9890
|
+
result.appendChild(reason);
|
|
9891
|
+
}
|
|
9892
|
+
const counts = globalThis.document.createElement("div");
|
|
9893
|
+
counts.className = "de-context-recent-counts";
|
|
9894
|
+
counts.textContent = `上次恢复共 ${recent.last.restoredTurns} 轮(其中 ${recent.last.partialTurns} 部分轮)`;
|
|
9895
|
+
const cost = globalThis.document.createElement("div");
|
|
9896
|
+
cost.className = "de-context-recent-cost";
|
|
9897
|
+
cost.textContent = `估算成本 ${recent.last.estimatedTokens} Tokens`;
|
|
9898
|
+
result.append(counts, cost);
|
|
9899
|
+
const details = globalThis.document.createElement("details");
|
|
9900
|
+
const summary = globalThis.document.createElement("summary");
|
|
9901
|
+
summary.textContent = "查看恢复详情";
|
|
9902
|
+
const text = globalThis.document.createElement("pre");
|
|
9903
|
+
text.className = "de-context-recent-details";
|
|
9904
|
+
text.textContent = recent.last.details;
|
|
9905
|
+
details.append(summary, text);
|
|
9906
|
+
result.appendChild(details);
|
|
9907
|
+
}
|
|
9908
|
+
host.appendChild(result);
|
|
9909
|
+
}
|
|
9717
9910
|
const pruneRow = globalThis.document.createElement("div");
|
|
9718
9911
|
pruneRow.className = "de-context-row";
|
|
9719
9912
|
const pruneLabel = globalThis.document.createElement("span");
|
|
@@ -9742,6 +9935,7 @@ ABORT_ERR ETIMEDOUT ECONNREFUSED ECONNRESET EPIPE EADDRINUSE ENOSPC EACCES STORE
|
|
|
9742
9935
|
note.textContent = pruneNote;
|
|
9743
9936
|
host.appendChild(note);
|
|
9744
9937
|
}
|
|
9938
|
+
flushPolicyInvalidation();
|
|
9745
9939
|
schedulePoll();
|
|
9746
9940
|
};
|
|
9747
9941
|
const reload = async () => {
|
|
@@ -9787,6 +9981,34 @@ ABORT_ERR ETIMEDOUT ECONNREFUSED ECONNRESET EPIPE EADDRINUSE ENOSPC EACCES STORE
|
|
|
9787
9981
|
state.note = "";
|
|
9788
9982
|
render(snapshot);
|
|
9789
9983
|
};
|
|
9984
|
+
const commitRecent = async (value) => {
|
|
9985
|
+
const id = state.sessionId;
|
|
9986
|
+
if (!isCurrent(generation, id) || state.busy || bridge.saveRecentConversation === void 0 || cachedSnapshot?.recentConversation === void 0) return;
|
|
9987
|
+
const mine = ++generation;
|
|
9988
|
+
cancelPoll();
|
|
9989
|
+
state.busy = true;
|
|
9990
|
+
render(null);
|
|
9991
|
+
const snapshot = await bridge.saveRecentConversation(id, value);
|
|
9992
|
+
if (!isCurrent(mine, id)) return;
|
|
9993
|
+
state.busy = false;
|
|
9994
|
+
const recent = snapshot?.recentConversation;
|
|
9995
|
+
const defaults = {
|
|
9996
|
+
turns: 10,
|
|
9997
|
+
maxTokens: DEFAULT_RECENT_CONVERSATION_MAX_TOKENS
|
|
9998
|
+
};
|
|
9999
|
+
const requested = value ?? {
|
|
10000
|
+
turns: null,
|
|
10001
|
+
maxTokens: null
|
|
10002
|
+
};
|
|
10003
|
+
if (!(recent !== void 0 && ["turns", "maxTokens"].every((field) => requested[field] === void 0 || recent[field] === (requested[field] === null ? defaults[field] : requested[field])))) {
|
|
10004
|
+
state.recentNote = "保存失败,近期原文设置未确认生效";
|
|
10005
|
+
render(null);
|
|
10006
|
+
return;
|
|
10007
|
+
}
|
|
10008
|
+
state.recentField = void 0;
|
|
10009
|
+
state.recentNote = "";
|
|
10010
|
+
render(snapshot);
|
|
10011
|
+
};
|
|
9790
10012
|
const runPrune = async () => {
|
|
9791
10013
|
const id = state.sessionId;
|
|
9792
10014
|
const diagnostic = startClientDiagnostic("session", "session.client.prune", { sessionId: id });
|
|
@@ -9835,6 +10057,7 @@ ABORT_ERR ETIMEDOUT ECONNREFUSED ECONNRESET EPIPE EADDRINUSE ENOSPC EACCES STORE
|
|
|
9835
10057
|
generation++;
|
|
9836
10058
|
activePanel = null;
|
|
9837
10059
|
cachedSnapshot = null;
|
|
10060
|
+
stopPolicy();
|
|
9838
10061
|
cancelPoll();
|
|
9839
10062
|
stopPruneObservation();
|
|
9840
10063
|
remove();
|
|
@@ -9842,6 +10065,7 @@ ABORT_ERR ETIMEDOUT ECONNREFUSED ECONNRESET EPIPE EADDRINUSE ENOSPC EACCES STORE
|
|
|
9842
10065
|
return;
|
|
9843
10066
|
}
|
|
9844
10067
|
if (activePanel !== found.panel || state?.sessionId !== id) {
|
|
10068
|
+
stopPolicy();
|
|
9845
10069
|
stopPruneObservation();
|
|
9846
10070
|
generation++;
|
|
9847
10071
|
cancelPoll();
|
|
@@ -9853,11 +10077,19 @@ ABORT_ERR ETIMEDOUT ECONNREFUSED ECONNRESET EPIPE EADDRINUSE ENOSPC EACCES STORE
|
|
|
9853
10077
|
sessionId: id,
|
|
9854
10078
|
editing: false,
|
|
9855
10079
|
draft: "",
|
|
10080
|
+
recentDraft: "",
|
|
10081
|
+
recentNote: "",
|
|
9856
10082
|
busy: false,
|
|
9857
10083
|
note: ""
|
|
9858
10084
|
};
|
|
9859
10085
|
render(null);
|
|
9860
10086
|
reload();
|
|
10087
|
+
const owner = state;
|
|
10088
|
+
unsubscribePolicy = subscribePolicy?.(id, () => {
|
|
10089
|
+
if (state !== owner || !isCurrent(generation, id)) return;
|
|
10090
|
+
policyDirty = true;
|
|
10091
|
+
flushPolicyInvalidation();
|
|
10092
|
+
});
|
|
9861
10093
|
} else if (found.panel.querySelector(`[data-desktop-enhance-context-controls]`) === null) render(null);
|
|
9862
10094
|
};
|
|
9863
10095
|
const observer = new globalThis.MutationObserver(sync);
|
|
@@ -9875,6 +10107,7 @@ ABORT_ERR ETIMEDOUT ECONNREFUSED ECONNRESET EPIPE EADDRINUSE ENOSPC EACCES STORE
|
|
|
9875
10107
|
refresh();
|
|
9876
10108
|
return () => {
|
|
9877
10109
|
disposed = true;
|
|
10110
|
+
stopPolicy();
|
|
9878
10111
|
stopPruneObservation();
|
|
9879
10112
|
generation++;
|
|
9880
10113
|
cancelPoll();
|
|
@@ -10005,7 +10238,7 @@ ABORT_ERR ETIMEDOUT ECONNREFUSED ECONNRESET EPIPE EADDRINUSE ENOSPC EACCES STORE
|
|
|
10005
10238
|
}
|
|
10006
10239
|
//#endregion
|
|
10007
10240
|
//#region src/client/index.tsx
|
|
10008
|
-
const PLUGIN_STYLESHEET = enhance_css_default + "\n" + tabs_css_default + "\n" + styles_css_default$3 + "\n" + styles_css_default$2 + "\n" + styles_css_default$1 + "\n\n\n.de-context-controls {\n font: inherit;\n font-size: 12px;\n line-height: 20px;\n color: var(--dsw-alias-label-secondary);\n font-variant-numeric: tabular-nums;\n}\n\n.de-context-divider {\n height: 0;\n margin: 8px 0 6px;\n border: 0;\n border-top: 0.5px solid var(--dsw-alias-border-l3);\n}\n\n.de-context-row {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n min-height: 24px;\n padding: 2px 0;\n}\n\n.de-context-label {\n color: var(--dsw-alias-label-secondary);\n display: inline-flex;\n align-items: center;\n gap: 6px;\n min-width: 0;\n}\n\n.de-context-value {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n margin-left: auto;\n font-variant-numeric: tabular-nums;\n}\n\n.de-context-controls-inline {\n display: inline-flex;\n align-items: center;\n gap: 3px;\n margin-left: auto;\n font-variant-numeric: tabular-nums;\n}\n\n.de-context-btn {\n font: inherit;\n font-size: 12px;\n line-height: 20px;\n color: var(--dsw-alias-label-primary);\n background: none;\n border: 0;\n border-radius: var(--dsw-radius-sm, 4px);\n padding: 0 5px;\n margin-right: -5px;\n cursor: pointer;\n display: inline-flex;\n align-items: center;\n gap: 4px;\n white-space: nowrap;\n font-variant-numeric: tabular-nums;\n transition: background-color .12s, color .12s;\n}\n\n.de-context-btn:hover {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n\n.de-context-btn:disabled {\n cursor: default;\n opacity: .5;\n background: none;\n}\n\n.de-context-btn:focus-visible,\n.de-context-input:focus-visible {\n outline: 1.5px solid var(--dsw-focus-ring-color, #578cc9);\n outline-offset: 1px;\n}\n\n.de-context-reset {\n font-size: 11px;\n line-height: 18px;\n color: var(--dsw-alias-label-tertiary);\n margin-right: 0;\n padding: 0 4px;\n}\n\n.de-context-reset:hover {\n color: var(--dsw-alias-label-secondary);\n}\n\n.de-context-save {\n color: var(--dsw-alias-state-business-primary, #3979be);\n font-weight: 500;\n}\n\n.de-context-input {\n font: inherit;\n font-size: 12px;\n line-height: 18px;\n width: 50px;\n height: 22px;\n padding: 0 5px;\n text-align: right;\n border: 0.5px solid var(--dsw-alias-border-l1);\n border-radius: var(--dsw-radius-sm, 4px);\n background: var(--dsw-alias-bg-base);\n color: var(--dsw-alias-label-primary);\n font-variant-numeric: tabular-nums;\n}\n\n.de-context-unit {\n font-size: 11px;\n color: var(--dsw-alias-label-tertiary);\n margin-right: 2px;\n}\n\n.de-context-note {\n font-size: 11px;\n line-height: 16px;\n color: var(--dsw-alias-label-tertiary);\n padding-top: 2px;\n overflow-wrap: anywhere;\n}\n\n\n[data-desktop-enhance-compaction-fork] {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 2px 0 0;\n}\n\n.de-compaction-fork {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 24px;\n height: 24px;\n padding: 0;\n border: 0;\n border-radius: var(--dsw-radius-sm, 4px);\n background: none;\n color: var(--dsw-alias-label-tertiary);\n cursor: pointer;\n transition: background-color .12s, color .12s;\n}\n\n.de-compaction-fork:hover {\n background: var(--dsw-alias-interactive-bg-hover);\n color: var(--dsw-alias-label-secondary);\n}\n\n.de-compaction-fork:disabled {\n cursor: default;\n opacity: .5;\n}\n\n.de-compaction-fork:focus-visible {\n outline: 1.5px solid var(--dsw-focus-ring-color, #578cc9);\n outline-offset: 1px;\n}\n\n\n:root[data-desktop-enhance-off-context-manager] [data-desktop-enhance-context-controls] {\n display: none !important;\n}\n\n\n\n:root:not([data-desktop-enhance-off-context-manager]) [data-desktop-enhance-context-controls] {\n display: revert;\n}\n\n\n:root[data-desktop-enhance-off-skill-recovery] [data-desktop-enhance-item=\"skillRecovery\"] [data-desktop-enhance-hint] {\n opacity: 0.55;\n}\n\n:root:not([data-desktop-enhance-off-skill-recovery]) [data-desktop-enhance-item=\"skillRecovery\"] [data-desktop-enhance-hint] {\n opacity: 1;\n}\n";
|
|
10241
|
+
const PLUGIN_STYLESHEET = enhance_css_default + "\n" + tabs_css_default + "\n" + styles_css_default$3 + "\n" + styles_css_default$2 + "\n" + styles_css_default$1 + "\n\n\n.de-context-controls {\n font: inherit;\n font-size: 12px;\n line-height: 20px;\n color: var(--dsw-alias-label-secondary);\n font-variant-numeric: tabular-nums;\n}\n\n.de-context-divider {\n height: 0;\n margin: 8px 0 6px;\n border: 0;\n border-top: 0.5px solid var(--dsw-alias-border-l3);\n}\n\n.de-context-row {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n min-height: 24px;\n padding: 2px 0;\n}\n\n.de-context-label {\n color: var(--dsw-alias-label-secondary);\n display: inline-flex;\n align-items: center;\n gap: 6px;\n min-width: 0;\n}\n\n.de-context-value {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n margin-left: auto;\n font-variant-numeric: tabular-nums;\n}\n\n.de-context-controls-inline {\n display: inline-flex;\n align-items: center;\n gap: 3px;\n margin-left: auto;\n font-variant-numeric: tabular-nums;\n}\n\n.de-context-btn {\n font: inherit;\n font-size: 12px;\n line-height: 20px;\n color: var(--dsw-alias-label-primary);\n background: none;\n border: 0;\n border-radius: var(--dsw-radius-sm, 4px);\n padding: 0 5px;\n margin-right: -5px;\n cursor: pointer;\n display: inline-flex;\n align-items: center;\n gap: 4px;\n white-space: nowrap;\n font-variant-numeric: tabular-nums;\n transition: background-color .12s, color .12s;\n}\n\n.de-context-btn:hover {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n\n.de-context-btn:disabled {\n cursor: default;\n opacity: .5;\n background: none;\n}\n\n.de-context-btn:focus-visible,\n.de-context-input:focus-visible {\n outline: 1.5px solid var(--dsw-focus-ring-color, #578cc9);\n outline-offset: 1px;\n}\n\n.de-context-reset {\n font-size: 11px;\n line-height: 18px;\n color: var(--dsw-alias-label-tertiary);\n margin-right: 0;\n padding: 0 4px;\n}\n\n.de-context-reset:hover {\n color: var(--dsw-alias-label-secondary);\n}\n\n.de-context-save {\n color: var(--dsw-alias-state-business-primary, #3979be);\n font-weight: 500;\n}\n\n.de-context-input {\n font: inherit;\n font-size: 12px;\n line-height: 18px;\n width: 50px;\n height: 22px;\n padding: 0 5px;\n text-align: right;\n border: 0.5px solid var(--dsw-alias-border-l1);\n border-radius: var(--dsw-radius-sm, 4px);\n background: var(--dsw-alias-bg-base);\n color: var(--dsw-alias-label-primary);\n font-variant-numeric: tabular-nums;\n}\n\n.de-context-unit {\n font-size: 11px;\n color: var(--dsw-alias-label-tertiary);\n margin-right: 2px;\n}\n\n.de-context-note {\n font-size: 11px;\n line-height: 16px;\n color: var(--dsw-alias-label-tertiary);\n padding-top: 2px;\n overflow-wrap: anywhere;\n}\n\n.de-context-recent-result {\n padding: 4px 0;\n}\n\n.de-context-recent-result summary {\n cursor: pointer;\n color: var(--dsw-alias-label-secondary);\n}\n\n.de-context-recent-details {\n font: inherit;\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n max-height: 240px;\n max-width: 320px;\n overflow: auto;\n margin: 4px 0;\n}\n\n\n[data-desktop-enhance-compaction-fork] {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 2px 0 0;\n}\n\n.de-compaction-fork {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 24px;\n height: 24px;\n padding: 0;\n border: 0;\n border-radius: var(--dsw-radius-sm, 4px);\n background: none;\n color: var(--dsw-alias-label-tertiary);\n cursor: pointer;\n transition: background-color .12s, color .12s;\n}\n\n.de-compaction-fork:hover {\n background: var(--dsw-alias-interactive-bg-hover);\n color: var(--dsw-alias-label-secondary);\n}\n\n.de-compaction-fork:disabled {\n cursor: default;\n opacity: .5;\n}\n\n.de-compaction-fork:focus-visible {\n outline: 1.5px solid var(--dsw-focus-ring-color, #578cc9);\n outline-offset: 1px;\n}\n\n\n:root[data-desktop-enhance-off-context-manager] [data-desktop-enhance-context-controls] {\n display: none !important;\n}\n\n\n\n:root:not([data-desktop-enhance-off-context-manager]) [data-desktop-enhance-context-controls] {\n display: revert;\n}\n\n\n:root[data-desktop-enhance-off-skill-recovery] [data-desktop-enhance-item=\"skillRecovery\"] [data-desktop-enhance-hint] {\n opacity: 0.55;\n}\n\n:root:not([data-desktop-enhance-off-skill-recovery]) [data-desktop-enhance-item=\"skillRecovery\"] [data-desktop-enhance-hint] {\n opacity: 1;\n}\n";
|
|
10009
10242
|
const inject = [
|
|
10010
10243
|
"slots",
|
|
10011
10244
|
"locale",
|
|
@@ -10182,7 +10415,9 @@ ABORT_ERR ETIMEDOUT ECONNREFUSED ECONNRESET EPIPE EADDRINUSE ENOSPC EACCES STORE
|
|
|
10182
10415
|
}
|
|
10183
10416
|
};
|
|
10184
10417
|
ctx.effect(() => {
|
|
10185
|
-
return installContextEnhance(createContextBridge(globalThis.fetch), currentSessionId, () => flagOn(settings.get().value, "contextManager"), (listener) => settings.subscribe(listener))
|
|
10418
|
+
return installContextEnhance(createContextBridge(globalThis.fetch), currentSessionId, () => flagOn(settings.get().value, "contextManager"), (listener) => settings.subscribe(listener), (sessionId, listener) => sessionState.subscribe(sessionId, () => {
|
|
10419
|
+
if (sessionState.get(sessionId).phase === "ready") listener();
|
|
10420
|
+
}));
|
|
10186
10421
|
}, "desktop-enhance: context controls");
|
|
10187
10422
|
const forkAccess = new Map();
|
|
10188
10423
|
const accessListeners = new Set();
|