fix(v0.3.3): 分栏引擎双版本锚点(0.1.1-rc.2/0.1.2-rc.1) + 数据目录解析循环修复 + 发布流水线加防(锚点8场景/数据目录3场景) + 公告/文档同步
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "dsh-worktable",
|
||||
"description": "工作台:DSH 侧边栏的 agent 级项目容器,收纳如 TravelAtlas 等自装项目",
|
||||
"version": "0.3.2",
|
||||
"version": "0.3.3",
|
||||
"entry": {
|
||||
"name": "dsh-worktable",
|
||||
"inject": []
|
||||
|
||||
+123
-33
@@ -8896,10 +8896,22 @@ function basenameOf(p) {
|
||||
var import_react = require("react");
|
||||
|
||||
// src/client/changelog.ts
|
||||
var CHANGELOG_V030 = `\u66F4\u65B0\u516C\u544A \xB7 v0.3.2
|
||||
var CHANGELOG_V030 = `\u66F4\u65B0\u516C\u544A \xB7 v0.3.3
|
||||
|
||||
\u{1F6E0}\uFE0F \u672C\u7248\u672C\u66F4\u65B0
|
||||
|
||||
\u3010\u517C\u5BB9\u65B0\u7248 DeepSeek Harness\u3011\u9002\u914D\u5DF2\u6D4B\u7248\u672C DSH 0.1.2-rc.1 \u4E0E 0.1.1-rc.2\uFF1A\u70B9\u51FB\u9879\u76EE\u5361\u7247\u4E0D\u518D\u65E0\u53CD\u5E94\u2014\u2014\u5206\u680F\u5DE5\u4F5C\u533A\u5728\u65E0\u4F1A\u8BDD / \u7A7A\u4F1A\u8BDD / \u6709\u6D88\u606F\u4F1A\u8BDD\u4E0B\u90FD\u80FD\u6B63\u5E38\u6253\u5F00\uFF080.1.1-rc.2 \u5B9E\u6D4B\u672A\u53D1\u73B0\u56DE\u5F52\uFF09\uFF1B\u9009\u62E9\u9879\u76EE\u6587\u4EF6\u5939\u7684\u7A97\u53E3\u5728 0.1.2-rc.1 \u4E0A\u6062\u590D\u6B63\u5E38\u53EF\u7528\uFF1B\u5DE5\u4F5C\u53F0\u6570\u636E\u8BFB\u53D6\u4E0D\u518D\u4F9D\u8D56\u9ED8\u8BA4\u5B89\u88C5\u8DEF\u5F84\uFF0C\u81EA\u5B9A\u4E49\u5B89\u88C5\u4F4D\u7F6E\uFF08DSH_HOME\uFF09\u4E5F\u80FD\u6B63\u786E\u8BFB\u53D6\u9879\u76EE\u4E0E\u5206\u7EC4\u6570\u636E\u3002
|
||||
|
||||
\u3010\u5173\u4E8E\u9009\u62E9\u6587\u4EF6\u5939\u7A97\u53E3\u7684\u5DF2\u77E5\u95EE\u9898\uFF08DeepSeek Harness \u5BBF\u4E3B\u81EA\u8EAB\u95EE\u9898\uFF0C\u4E0D\u662F\u672C\u63D2\u4EF6\u7684\u95EE\u9898\uFF09\u3011\u5728\u90E8\u5206\u7CFB\u7EDF\u4E0A\uFF0C\u70B9\u51FB\u300C\u9009\u62E9\u4F4D\u7F6E\u2026\u300D\u4E4B\u540E\u6587\u4EF6\u5939\u9009\u62E9\u7A97\u53E3\u53EF\u80FD\u4E0D\u4F1A\u81EA\u52A8\u8DF3\u5230\u6700\u524D\u9762\uFF0C\u800C\u662F\u85CF\u5728\u4EFB\u52A1\u680F\u6216\u5176\u4ED6\u7A97\u53E3\u540E\u9762\u3002\u8FD9\u662F DeepSeek Harness \u5BBF\u4E3B\u9009\u62E9\u5668\u7684\u5DF2\u77E5\u7F3A\u9677\uFF0C\u4E0E\u5DE5\u4F5C\u53F0\u65E0\u5173\uFF0C\u7B49\u5F85\u5B98\u65B9\u4FEE\u590D\u3002\u9047\u5230\u65F6\u70B9\u4E00\u4E0B\u4EFB\u52A1\u680F\u91CC\u7684 DSH \u56FE\u6807\u5373\u53EF\u5207\u51FA\u7A97\u53E3\uFF1B\u82E5\u4E0D\u60F3\u7B49\uFF0C\u76F4\u63A5\u7528\u300C\u624B\u52A8\u8F93\u5165\u300D\u7C98\u8D34\u6587\u4EF6\u5939\u7EDD\u5BF9\u8DEF\u5F84\uFF0C\u529F\u80FD\u5B8C\u5168\u4E0D\u53D7\u5F71\u54CD\u3002
|
||||
|
||||
\u3010\u8C01\u9700\u8981\u5347\u7EA7\u3011\u4ECD\u5728\u7528\u8001\u7248\u672C DSH \u4E14\u5DE5\u4F5C\u53F0\u4E00\u5207\u6B63\u5E38\u7684\u7528\u6237\uFF0C\u53EF\u4EE5\u6682\u4E0D\u5347\u7EA7\uFF1B\u5347\u7EA7\u5230 0.1.2 \u7CFB\u5217\u3001\u6216\u9047\u5230\u300C\u70B9\u51FB\u9879\u76EE\u5361\u7247\u6CA1\u6709\u53CD\u5E94\u300D\u7684\u7528\u6237\uFF0C\u5EFA\u8BAE\u5347\u7EA7\u672C\u7248\u672C\u3002
|
||||
|
||||
\u3010\u5347\u7EA7\u8BF4\u660E\u3011\u5347\u7EA7\u5B89\u88C5\u540E\u8BF7\u5B8C\u6574\u9000\u51FA\u5E76\u91CD\u542F DSH \u518D\u5237\u65B0\u9875\u9762\uFF1B\u82E5\u91CD\u542F\u540E\u4ECD\u663E\u793A\u52A0\u8F7D\u5931\u8D25\uFF0C\u8BF7\u4FDD\u7559\u5B8C\u6574\u9519\u8BEF\u4FE1\u606F\u53CD\u9988\u3002
|
||||
|
||||
\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
||||
|
||||
\u6B64\u524D\u7248\u672C\u8BF4\u660E\uFF08v0.3.2\uFF09
|
||||
|
||||
\u3010\u6587\u4EF6\u5939\u9009\u62E9\u4F53\u9A8C\u3011\u9009\u62E9\u9879\u76EE\u6587\u4EF6\u5939\u65F6\uFF1A\u7B49\u5F85\u671F\u95F4\u6309\u94AE\u663E\u793A\u300C\u7B49\u5F85\u9009\u62E9\u2026\u300D\u5E76\u63D0\u793A\u300C\u82E5\u672A\u770B\u5230\u9009\u62E9\u7A97\u53E3\uFF0C\u53EF\u68C0\u67E5\u4EFB\u52A1\u680F\uFF0C\u6216\u4F7F\u7528\u624B\u52A8\u8F93\u5165\u300D\uFF1B\u65B0\u589E\u300C\u624B\u52A8\u8F93\u5165\u300D\u5165\u53E3\uFF0C\u53EF\u76F4\u63A5\u7C98\u8D34\u6587\u4EF6\u5939\u7EDD\u5BF9\u8DEF\u5F84\uFF08\u76F8\u5BF9\u8DEF\u5F84\u4F1A\u88AB\u62D2\u7EDD\u5E76\u63D0\u793A\uFF09\uFF1B\u9009\u62E9\u5931\u8D25\u65F6\u663E\u793A\u5177\u4F53\u9519\u8BEF\uFF0C\u4E0D\u518D\u9759\u9ED8\u65E0\u53CD\u5E94\uFF1B\u4FEE\u590D\u4E86\u65E7\u9009\u62E9\u7A97\u53E3\u8FD4\u56DE\u540E\u8986\u76D6\u624B\u5DE5\u8F93\u5165\u3001\u5F39\u7A97\u5173\u95ED/\u5207\u6362\u540E\u72B6\u6001\u6B8B\u7559\u7B49\u95EE\u9898\u3002
|
||||
|
||||
\u3010\u53D1\u5E03\u6D41\u7A0B\u52A0\u56FA\u3011\u53D1\u5E03\u5305\u65B0\u589E\u7ED3\u6784\u4E0E\u8EAB\u4EFD\u6821\u9A8C\u3001\u5BA2\u6237\u7AEF\u5DE5\u5382\u6C42\u503C\u95E8\u7981\u3001\u53CC\u8D44\u4EA7\u540C\u6E90\u6838\u5BF9\u4E0E\u8FDC\u7AEF SHA \u6BD4\u5BF9\uFF08\u5F00\u53D1\u8005\u4FA7\u6539\u8FDB\uFF0C\u4E0D\u5F71\u54CD\u63D2\u4EF6\u529F\u80FD\uFF09\u3002
|
||||
@@ -8936,7 +8948,7 @@ var CHANGELOG_V030 = `\u66F4\u65B0\u516C\u544A \xB7 v0.3.2
|
||||
\u30103.1 \u6587\u5B57\u4E0E\u7EC6\u8282\u6253\u78E8\u3011\u5168\u5C40\u5B57\u4F53\u4E0E\u5B57\u53F7\u7EDF\u4E00\u4F18\u5316\u3001\u4E0B\u62C9\u9762\u677F\u73BB\u7483\u5316\u4E0E\u5BF9\u9F50\u3001\u83DC\u5355\u70B9\u9009\u540E\u4FDD\u6301\u6253\u5F00\u4FBF\u4E8E\u8FDE\u7EED\u9884\u89C8\u3001\u6309\u94AE\u63CF\u8FB9\u4E0E\u60AC\u505C\u53CD\u9988\u7B49\u4EA4\u4E92\u7EC6\u8282\uFF1B\u540C\u65F6\u4FEE\u590D\u4E86\u591A\u9879\u4F53\u9A8C\u95EE\u9898\uFF08\u7167\u7247\u4E0A\u4F20\u6E05\u6670\u5EA6\u3001\u80CC\u666F\u7F51\u683C\u7EBF\u5728\u7167\u7247\u6A21\u5F0F\u4E0B\u4E0D\u751F\u6548\u3001\u6D45\u8272\u4E3B\u9898\u4E0B\u5DE5\u4F5C\u72B6\u6001\u5149\u6548\u4E0D\u53EF\u89C1\u7B49\uFF09\u3002`;
|
||||
|
||||
// src/client/updateCheck.ts
|
||||
var LOCAL_VERSION = false ? "dev" : "0.3.2";
|
||||
var LOCAL_VERSION = false ? "dev" : "0.3.3";
|
||||
var UPDATE_REPO = "Aisland-SJL/dsh-worktable";
|
||||
var K_UPDATE_CHECK = "dsh.worktable.updateCheck.v1";
|
||||
var K_LAST_CHECK = "dsh.worktable.lastUpdateCheck.v1";
|
||||
@@ -17266,8 +17278,33 @@ function AnnotationOverlay() {
|
||||
}
|
||||
function findConversationRoot() {
|
||||
const candidates = Array.from(document.querySelectorAll("[data-phase]"));
|
||||
const ok = (el) => el.tagName !== "TEXTAREA" && el.tagName !== "INPUT" && el.children.length >= 2;
|
||||
return candidates.find((el) => ok(el) && el.dataset.phase === "active") ?? candidates.find(ok) ?? null;
|
||||
const ok = (el) => el.tagName !== "TEXTAREA" && el.tagName !== "INPUT" && el.children.length >= 1 && !/input/i.test(String(el.className));
|
||||
const rank = (el) => el.dataset.phase === "active" ? 0 : el.dataset.phase === "hero" ? 1 : 2;
|
||||
let best = null;
|
||||
let bestRank = Infinity;
|
||||
for (const el of candidates) {
|
||||
if (!ok(el)) continue;
|
||||
const r = rank(el);
|
||||
if (r < bestRank) {
|
||||
bestRank = r;
|
||||
best = el;
|
||||
}
|
||||
}
|
||||
return best;
|
||||
}
|
||||
function visibleHeaderIn(first) {
|
||||
if (first.getBoundingClientRect().height > 0) return first;
|
||||
for (const el of Array.from(first.querySelectorAll("*"))) {
|
||||
const r = el.getBoundingClientRect();
|
||||
if (r.height > 0 && r.width > 0) return el;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function resolveAnchor(root) {
|
||||
const first = root.children[0];
|
||||
const second = root.children[1];
|
||||
const header = !!second && !!first ? visibleHeaderIn(first) : null;
|
||||
return { header, viewArea: second ?? first };
|
||||
}
|
||||
function loadSaved(layoutId) {
|
||||
try {
|
||||
@@ -17316,6 +17353,7 @@ var splitStore = {
|
||||
savedMarginLeft: "",
|
||||
savedMarginRight: "",
|
||||
savedMarginTop: "",
|
||||
savedWidthVar: "",
|
||||
observer: null,
|
||||
fallback: null,
|
||||
yieldObserver: null,
|
||||
@@ -17343,9 +17381,7 @@ var splitStore = {
|
||||
}
|
||||
const root = findConversationRoot();
|
||||
if (!root) return false;
|
||||
const header = root.children[0];
|
||||
const viewArea = root.children[1];
|
||||
if (!header || !viewArea) return false;
|
||||
const { header, viewArea } = resolveAnchor(root);
|
||||
this.spec = { ...spec, chatSide: spec.chatSide === "left" ? "left" : "right" };
|
||||
const normalize2 = (p) => {
|
||||
if (p.tabs && p.tabs.length > 0) return p;
|
||||
@@ -17376,6 +17412,7 @@ var splitStore = {
|
||||
this.root = root;
|
||||
this.header = header;
|
||||
this.viewArea = viewArea;
|
||||
this.savedWidthVar = root.style.getPropertyValue("--dsh-chat-user-width");
|
||||
this.savedMarginLeft = viewArea.style.marginLeft;
|
||||
this.savedMarginRight = viewArea.style.marginRight;
|
||||
this.savedMarginTop = viewArea.style.marginTop;
|
||||
@@ -17420,7 +17457,12 @@ var splitStore = {
|
||||
this.applyMargin();
|
||||
this.observer = new ResizeObserver(() => {
|
||||
const r = this.root;
|
||||
if (!(r && r.isConnected && r.dataset.phase === "active")) {
|
||||
if (!(r && r.isConnected)) {
|
||||
this.syncAnchor();
|
||||
return;
|
||||
}
|
||||
const anchor = resolveAnchor(r);
|
||||
if (anchor.header !== this.header || anchor.viewArea !== this.viewArea) {
|
||||
this.syncAnchor();
|
||||
return;
|
||||
}
|
||||
@@ -17431,8 +17473,12 @@ var splitStore = {
|
||||
this.observer.observe(root);
|
||||
this.fallback = new MutationObserver(() => {
|
||||
const r = this.root;
|
||||
if (r && r.isConnected && r.dataset.phase === "active") return;
|
||||
this.syncAnchor();
|
||||
if (!(r && r.isConnected)) {
|
||||
this.syncAnchor();
|
||||
return;
|
||||
}
|
||||
const anchor = resolveAnchor(r);
|
||||
if (anchor.header !== this.header || anchor.viewArea !== this.viewArea) this.syncAnchor();
|
||||
});
|
||||
this.fallback.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ["data-phase"] });
|
||||
this.yieldObserver = new MutationObserver(() => {
|
||||
@@ -17446,7 +17492,7 @@ var splitStore = {
|
||||
this.notify();
|
||||
return true;
|
||||
},
|
||||
/** 会话根失效(切换会话)时重新锚定:左侧内容保持不关闭;无会话才关闭 */
|
||||
/** 会话根失效(切换会话 / hero↔active 结构变化)时重新锚定:左侧内容保持不关闭;无会话根才关闭 */
|
||||
syncAnchor() {
|
||||
if (!this.active) return;
|
||||
const next = findConversationRoot();
|
||||
@@ -17454,30 +17500,38 @@ var splitStore = {
|
||||
this.close();
|
||||
return;
|
||||
}
|
||||
if (next.dataset.phase !== "active") return;
|
||||
if (next === this.root) {
|
||||
const ph = next.dataset.phase;
|
||||
if (ph !== "active" && ph !== "hero") return;
|
||||
const anchor = resolveAnchor(next);
|
||||
if (next === this.root && anchor.header === this.header && anchor.viewArea === this.viewArea) {
|
||||
this.refreshGeom();
|
||||
this.applyMargin();
|
||||
this.notify();
|
||||
return;
|
||||
}
|
||||
const header = next.children[0];
|
||||
const viewArea = next.children[1];
|
||||
if (!header || !viewArea) {
|
||||
this.close();
|
||||
return;
|
||||
const viewArea = anchor.viewArea;
|
||||
const oldRoot = this.root;
|
||||
const oldViewArea = this.viewArea;
|
||||
if (oldViewArea && oldViewArea.isConnected && oldViewArea !== viewArea) {
|
||||
oldViewArea.style.marginLeft = this.savedMarginLeft;
|
||||
oldViewArea.style.marginRight = this.savedMarginRight;
|
||||
oldViewArea.style.marginTop = this.savedMarginTop;
|
||||
}
|
||||
if (this.viewArea && this.viewArea.isConnected && this.viewArea !== viewArea) {
|
||||
this.viewArea.style.marginLeft = this.savedMarginLeft;
|
||||
this.viewArea.style.marginRight = this.savedMarginRight;
|
||||
this.viewArea.style.marginTop = this.savedMarginTop;
|
||||
if (oldRoot && oldRoot.isConnected && oldRoot !== next) {
|
||||
if (this.savedWidthVar) oldRoot.style.setProperty("--dsh-chat-user-width", this.savedWidthVar);
|
||||
else oldRoot.style.removeProperty("--dsh-chat-user-width");
|
||||
}
|
||||
this.root = next;
|
||||
this.header = header;
|
||||
this.header = anchor.header;
|
||||
this.viewArea = viewArea;
|
||||
this.savedMarginLeft = viewArea.style.marginLeft;
|
||||
this.savedMarginRight = viewArea.style.marginRight;
|
||||
this.savedMarginTop = viewArea.style.marginTop;
|
||||
if (oldRoot !== next) {
|
||||
this.savedWidthVar = next.style.getPropertyValue("--dsh-chat-user-width");
|
||||
}
|
||||
if (oldViewArea !== viewArea) {
|
||||
this.savedMarginLeft = viewArea.style.marginLeft;
|
||||
this.savedMarginRight = viewArea.style.marginRight;
|
||||
this.savedMarginTop = viewArea.style.marginTop;
|
||||
}
|
||||
this.observer?.disconnect();
|
||||
this.observer.observe(next);
|
||||
this.refreshGeom();
|
||||
@@ -17486,11 +17540,11 @@ var splitStore = {
|
||||
},
|
||||
refreshGeom() {
|
||||
const root = this.root;
|
||||
const header = this.header;
|
||||
if (!root || !header) return;
|
||||
if (!root) return;
|
||||
const rr = root.getBoundingClientRect();
|
||||
const hr2 = header.getBoundingClientRect();
|
||||
this.geom = { left: rr.left, top: hr2.bottom, right: rr.right, bottom: rr.bottom };
|
||||
const hr2 = this.header ? this.header.getBoundingClientRect() : null;
|
||||
const top = hr2 && hr2.height > 0 ? hr2.bottom : rr.top;
|
||||
this.geom = { left: rr.left, top, right: rr.right, bottom: rr.bottom };
|
||||
},
|
||||
applyMargin() {
|
||||
const viewArea = this.viewArea;
|
||||
@@ -17502,6 +17556,9 @@ var splitStore = {
|
||||
const hasLeft = !!spec.left;
|
||||
const hasTop = !!(spec.top && spec.top.length > 0);
|
||||
const chatW = clamp(this.chatW, spec.chatWidth.min, Math.max(spec.chatWidth.min, colW - 60));
|
||||
if (this.root && this.root.isConnected) {
|
||||
this.root.style.setProperty("--dsh-chat-user-width", Math.round(chatW) + "px");
|
||||
}
|
||||
const topH = hasTop ? clamp(this.topH, spec.topHeight?.min ?? 80, Math.max(spec.topHeight?.min ?? 80, rowH - BAR_H - 80)) : 0;
|
||||
const leftW = hasLeft ? clamp(this.leftW, spec.leftWidth?.min ?? 160, Math.max(spec.leftWidth?.min ?? 160, colW - 260)) : 0;
|
||||
const chatFull = spec.chatFullHeight === true;
|
||||
@@ -17826,6 +17883,10 @@ var splitStore = {
|
||||
persistSaved(this.spec.id, { chatW: this.chatW, topH: this.topH, leftW: this.leftW, paneWs: this.paneWs, topWs: this.topWs, leftWs: this.leftWs });
|
||||
},
|
||||
close() {
|
||||
if (this.root && this.root.isConnected) {
|
||||
if (this.savedWidthVar) this.root.style.setProperty("--dsh-chat-user-width", this.savedWidthVar);
|
||||
else this.root.style.removeProperty("--dsh-chat-user-width");
|
||||
}
|
||||
if (this.viewArea) {
|
||||
this.viewArea.style.marginLeft = this.savedMarginLeft;
|
||||
this.viewArea.style.marginRight = this.savedMarginRight;
|
||||
@@ -17840,6 +17901,7 @@ var splitStore = {
|
||||
this.root = null;
|
||||
this.header = null;
|
||||
this.viewArea = null;
|
||||
this.savedWidthVar = "";
|
||||
this.geom = null;
|
||||
this.spec = null;
|
||||
this.active = false;
|
||||
@@ -20042,7 +20104,7 @@ var WAVE_BG_B64 = "/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAYEBQUFBAYFBQUHBgYHCQ8KCQgIC
|
||||
|
||||
// src/client/index.tsx
|
||||
var import_jsx_runtime2 = require("react/jsx-runtime");
|
||||
var LOCAL_VERSION2 = false ? "dev" : "0.3.2";
|
||||
var LOCAL_VERSION2 = false ? "dev" : "0.3.3";
|
||||
var UPDATE_REPO2 = "Aisland-SJL/dsh-worktable";
|
||||
var UPGRADE_CMD2 = 'dsh plugin --profile web add "https://github.com/Aisland-SJL/dsh-worktable/releases/latest/download/dsh-worktable.tgz"';
|
||||
var UPGRADE_AI2 = "\u5E2E\u6211\u5347\u7EA7 dsh-worktable\uFF1A\u6267\u884C " + UPGRADE_CMD2 + "\uFF0C\u5B8C\u6210\u540E\u63D0\u9192\u6211\u91CD\u542F dsh web \u5E76\u5237\u65B0\u9875\u9762";
|
||||
@@ -20326,6 +20388,7 @@ function findSidebar(start) {
|
||||
}
|
||||
var registryStore = { ids: [], listeners: /* @__PURE__ */ new Set() };
|
||||
var sessionBridge = null;
|
||||
var clientCtx = null;
|
||||
var hostApi = null;
|
||||
async function ensureSessionPreset(sessionId) {
|
||||
const api = hostApi?.agentPresets;
|
||||
@@ -21756,7 +21819,21 @@ function WorktableSection(props) {
|
||||
const pickFolder = async (target, apply2) => {
|
||||
if (pickBusyRef.current) return;
|
||||
const ws = sessionBridge?.workspaces;
|
||||
if (!ws || typeof ws.pickDirectory !== "function") {
|
||||
const legacy = ws && typeof ws.pickDirectory === "function" ? () => ws.pickDirectory() : null;
|
||||
let remotePicker = null;
|
||||
try {
|
||||
const rp = clientCtx?.get?.("remote.directoryPicker");
|
||||
if (rp && typeof rp.pick === "function") remotePicker = () => rp.pick();
|
||||
} catch {
|
||||
}
|
||||
if (!remotePicker) {
|
||||
try {
|
||||
const dp = clientCtx?.directoryPicker;
|
||||
if (dp && typeof dp.pick === "function") remotePicker = () => dp.pick();
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
if (!legacy && !remotePicker) {
|
||||
setPickErr((prev) => ({ ...prev, [target]: t("add.folderPickerUnavailable") }));
|
||||
return;
|
||||
}
|
||||
@@ -21765,7 +21842,19 @@ function WorktableSection(props) {
|
||||
setPickErr((prev) => ({ ...prev, [target]: "" }));
|
||||
const seq = ++pickSeqRef.current;
|
||||
try {
|
||||
const p = await ws.pickDirectory();
|
||||
let p = null;
|
||||
if (legacy) {
|
||||
p = await legacy();
|
||||
} else {
|
||||
const r = await remotePicker();
|
||||
if (r && typeof r === "object" && "ok" in r) {
|
||||
if (!r.ok) throw new Error(r?.error?.message ?? "directory picker failed");
|
||||
const v = r.value;
|
||||
p = typeof v === "string" ? v : v && typeof v === "object" && typeof v.path === "string" ? v.path : null;
|
||||
} else {
|
||||
p = typeof r === "string" ? r : null;
|
||||
}
|
||||
}
|
||||
if (seq !== pickSeqRef.current) return;
|
||||
if (!mountedRef.current) return;
|
||||
if (p && typeof p === "string") apply2(p);
|
||||
@@ -23293,6 +23382,7 @@ function WorktableSection(props) {
|
||||
var inject = ["slots", "locale", "sessions", "conversation", "workspaces"];
|
||||
function apply(ctx) {
|
||||
sessionBridge = { sessions: ctx.sessions ?? null, conversation: ctx.conversation ?? null, list: ctx.sessions?.list ?? null, workspaces: ctx.workspaces ?? null };
|
||||
clientCtx = ctx;
|
||||
try {
|
||||
hostApi = ctx.get?.("connection")?.api ?? null;
|
||||
} catch {
|
||||
|
||||
+73
-3
@@ -88,7 +88,34 @@ body {
|
||||
var dshell_default2 = '<!doctype html>\n<!-- dsh-worktable \u539F\u751F\u76AE\u80A4\u6A21\u677F\uFF1A\u65B0\u9875\u9762\u4EE5\u6B64\u4E3A\u57FA\u7840\uFF0C\u66FF\u6362\u4E0B\u9762\u793A\u4F8B\u5185\u5BB9\u5373\u53EF\u3002\n \u6837\u5F0F\u8868\u7531\u63D2\u4EF6\u63D0\u4F9B\uFF08\u968F\u4E3B\u9898\u81EA\u52A8\u9002\u914D\uFF09\uFF0C\u4E0D\u8981\u590D\u5236\u6216\u6539\u5199\u5B83\u3002 -->\n<html lang="zh-CN">\n<head>\n <meta charset="utf-8" />\n <meta name="viewport" content="width=device-width, initial-scale=1" />\n <title>\u6211\u7684\u7A97\u53E3</title>\n <link rel="stylesheet" href="/api/worktable/template/dshell.css" />\n</head>\n<body>\n <div class="dshell">\n <!-- \u6807\u9898\u533A -->\n <h1 class="dshell-title">\u7A97\u53E3\u6807\u9898</h1>\n <p class="dshell-sub">\u4E00\u53E5\u8BDD\u8BF4\u660E\u8FD9\u4E2A\u7A97\u53E3\u505A\u4EC0\u4E48\u3002</p>\n\n <!-- \u72B6\u6001\u5FBD\u6807\uFF1A\u5DF2\u5B8C\u6210 dshell-badgeDone / \u8FDB\u884C\u4E2D dshell-badgeWait / \u9ED8\u8BA4 -->\n <div>\n <span class="dshell-badge dshell-badgeDone">\u5DF2\u5B8C\u6210</span>\n <span class="dshell-badge dshell-badgeWait">\u8FDB\u884C\u4E2D</span>\n <span class="dshell-badge">\u672A\u5F00\u59CB</span>\n </div>\n\n <!-- \u6807\u7B7E\u9875 -->\n <div class="dshell-tabs">\n <button class="dshell-tab dshell-tabOn">\u6982\u89C8</button>\n <button class="dshell-tab">\u8BE6\u60C5</button>\n <button class="dshell-tab">\u8BBE\u7F6E</button>\n </div>\n\n <!-- \u7EDF\u8BA1\u5361\u7247\u7F51\u683C -->\n <div class="dshell-grid">\n <div class="dshell-stat">\n <div class="dshell-statLabel">\u603B\u6570</div>\n <div class="dshell-statValue">128</div>\n <div class="dshell-statDelta">+12.4%</div>\n </div>\n <div class="dshell-stat">\n <div class="dshell-statLabel">\u8FDB\u884C\u4E2D</div>\n <div class="dshell-statValue">7</div>\n </div>\n <div class="dshell-stat">\n <div class="dshell-statLabel">\u5DF2\u5B8C\u6210</div>\n <div class="dshell-statValue">121</div>\n </div>\n </div>\n\n <!-- \u5217\u8868 -->\n <div class="dshell-list">\n <div class="dshell-listItem">\n <span class="dshell-listItemTitle">\u6761\u76EE\u4E00\uFF1A\u793A\u4F8B\u5185\u5BB9\u6807\u9898</span>\n <span class="dshell-listItemMeta">\u6628\u5929</span>\n </div>\n <div class="dshell-listItem">\n <span class="dshell-listItemTitle">\u6761\u76EE\u4E8C\uFF1A\u793A\u4F8B\u5185\u5BB9\u6807\u9898</span>\n <span class="dshell-badge dshell-badgeDone">\u5DF2\u53D1\u5E03</span>\n </div>\n </div>\n\n <!-- \u5361\u7247 + \u952E\u503C\u5BF9 -->\n <div class="dshell-card">\n <h2 class="dshell-sub" style="margin:0 0 8px">\u8BE6\u60C5</h2>\n <div class="dshell-kv">\n <div class="dshell-kvRow"><span class="dshell-kvKey">\u5B57\u6BB5 A</span><span class="dshell-kvValue">\u503C A</span></div>\n <div class="dshell-kvRow"><span class="dshell-kvKey">\u5B57\u6BB5 B</span><span class="dshell-kvValue">\u503C B</span></div>\n </div>\n <div class="dshell-divider"></div>\n <div class="dshell-progress"><div class="dshell-progressBar" style="width:72%"></div></div>\n </div>\n\n <!-- \u64CD\u4F5C\u533A -->\n <div style="display:flex;gap:8px">\n <button class="dshell-btn">\u4E3B\u8981\u64CD\u4F5C</button>\n <button class="dshell-btn dshell-btnGhost">\u6B21\u8981\u64CD\u4F5C</button>\n </div>\n </div>\n</body>\n</html>\n';
|
||||
|
||||
// src/index.ts
|
||||
var PLUGIN_VERSION = false ? "dev" : "0.3.2";
|
||||
function baseDshHome() {
|
||||
const env = process.env.DSH_HOME;
|
||||
const value = env !== void 0 && env.trim().length > 0 ? env : pathResolve(homedir(), ".dsh");
|
||||
if (value === "~") return homedir();
|
||||
if (value.startsWith("~/") || value.startsWith("~\\")) return pathResolve(homedir(), value.slice(2));
|
||||
return pathResolve(value);
|
||||
}
|
||||
var cachedDshHome = null;
|
||||
var dshHomeSource = "fallback";
|
||||
function resolveDshHomeSafe() {
|
||||
if (cachedDshHome) return cachedDshHome;
|
||||
try {
|
||||
const pkg = loadPkg("@deepseek-ai/dsh-home-paths");
|
||||
if (pkg && typeof pkg.resolveDshHome === "function") {
|
||||
const home = pkg.resolveDshHome(void 0, process.env);
|
||||
if (typeof home === "string" && home.trim() !== "") {
|
||||
dshHomeSource = "official";
|
||||
cachedDshHome = home;
|
||||
return cachedDshHome;
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
}
|
||||
dshHomeSource = "fallback";
|
||||
cachedDshHome = baseDshHome();
|
||||
return cachedDshHome;
|
||||
}
|
||||
var PLUGIN_VERSION = false ? "dev" : "0.3.3";
|
||||
var name = "dsh-worktable";
|
||||
var inject = ["webServer", "sessions"];
|
||||
var HEALTH_PATH = "/api/worktable/health";
|
||||
@@ -126,6 +153,7 @@ var FILE_TYPES = {
|
||||
};
|
||||
var SITE_PREFIX = "/api/worktable/site";
|
||||
var TEMPLATE_PREFIX = "/api/worktable/template";
|
||||
var loadProbeAttempts = 0;
|
||||
function loadPkg(pkg) {
|
||||
const starts = /* @__PURE__ */ new Set();
|
||||
try {
|
||||
@@ -139,6 +167,7 @@ function loadPkg(pkg) {
|
||||
for (const start of starts) {
|
||||
let dir = start;
|
||||
while (dir && dir !== pathResolve(dir, "..")) {
|
||||
loadProbeAttempts++;
|
||||
try {
|
||||
const req = createRequire(pathToFileURL(pathResolve(dir, "__wt_probe__.js")).href);
|
||||
return req(pkg);
|
||||
@@ -148,10 +177,11 @@ function loadPkg(pkg) {
|
||||
}
|
||||
}
|
||||
try {
|
||||
const profilesDir = pathResolve(homedir(), ".dsh", "profiles");
|
||||
const profilesDir = pathResolve(baseDshHome(), "profiles");
|
||||
for (const profile of readdirSync(profilesDir, { withFileTypes: true })) {
|
||||
if (!profile.isDirectory() && !profile.isSymbolicLink()) continue;
|
||||
const nm = pathResolve(profilesDir, profile.name, "node_modules");
|
||||
loadProbeAttempts++;
|
||||
try {
|
||||
const req = createRequire(pathToFileURL(pathResolve(nm, "__wt_probe__.js")).href);
|
||||
return req(pkg);
|
||||
@@ -162,6 +192,9 @@ function loadPkg(pkg) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function __wtLoadProbeStats() {
|
||||
return { attempts: loadProbeAttempts, homeSource: dshHomeSource };
|
||||
}
|
||||
function serverCwd(ctx, sessionId, clientCwd) {
|
||||
if (sessionId) {
|
||||
try {
|
||||
@@ -447,7 +480,43 @@ function apply(ctx) {
|
||||
path: "/api/worktable/workspaces",
|
||||
handler: async (_req, res) => {
|
||||
try {
|
||||
const file = pathResolve(homedir(), ".dsh", "storages", "workspace.json");
|
||||
let registry = null;
|
||||
try {
|
||||
registry = ctx.workspaceRegistry ?? null;
|
||||
} catch {
|
||||
}
|
||||
if (!registry) {
|
||||
try {
|
||||
registry = ctx.get?.("workspaceRegistry") ?? null;
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
if (registry && typeof registry.list === "function") {
|
||||
const list = registry.list() ?? [];
|
||||
const workspaceIds = [];
|
||||
const tables = {};
|
||||
for (const ws of list) {
|
||||
const id = String(ws?.id ?? "");
|
||||
if (!id) continue;
|
||||
workspaceIds.push(id);
|
||||
tables[id] = {
|
||||
title: typeof ws?.title === "string" ? ws.title : void 0,
|
||||
sessionIds: Array.isArray(ws?.sessionIds) ? ws.sessionIds.map(String) : []
|
||||
};
|
||||
}
|
||||
let archived = [];
|
||||
try {
|
||||
archived = (registry.archivedSessionIds ?? []).map(String);
|
||||
} catch {
|
||||
}
|
||||
json(res, 200, {
|
||||
unit: { name: "workspace", version: 2 },
|
||||
global: { initialized: true, workspaceIds, archivedSessionIds: archived },
|
||||
tables: { workspaces: tables }
|
||||
});
|
||||
return;
|
||||
}
|
||||
const file = pathResolve(resolveDshHomeSafe(), "storages", "workspace.json");
|
||||
const raw = await readFile(file, "utf8");
|
||||
json(res, 200, JSON.parse(raw.charCodeAt(0) === 65279 ? raw.slice(1) : raw));
|
||||
} catch (err) {
|
||||
@@ -529,6 +598,7 @@ function apply(ctx) {
|
||||
}
|
||||
export {
|
||||
HEALTH_PATH,
|
||||
__wtLoadProbeStats,
|
||||
apply,
|
||||
inject,
|
||||
name
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "dsh-worktable",
|
||||
"description": "工作台 Worktable:DeepSeek Harness 侧边栏的 agent 级项目容器(应用抽屉)",
|
||||
"version": "0.3.2",
|
||||
"version": "0.3.3",
|
||||
"license": "MIT",
|
||||
"type": "module",
|
||||
"main": "lib/index.js",
|
||||
|
||||
@@ -173,6 +173,37 @@ try {
|
||||
}
|
||||
console.log('[release-prep] client factory gate passed (ModuleLoader id + factory evaluation + inject)')
|
||||
|
||||
// ---------- 5c. 分栏引擎 DOM 锚点回归(0.1.1/0.1.2 双会话根结构 + 过渡重锚 + 关闭还原) ----------
|
||||
// 评估「安装目录中的最终产物」lib/client.js(与 5b 同一文件),用假 DOM 驱动 splitStore 全路径
|
||||
const anchorTest = join(HERE, '..', '04_test', 'anchor-dom.test.mjs')
|
||||
if (!existsSync(anchorTest)) {
|
||||
console.error('[release-prep] FAIL: anchor-dom.test.mjs missing')
|
||||
process.exit(1)
|
||||
}
|
||||
const anchorRun = spawnSync(process.execPath, [anchorTest, join(inst, 'node_modules', 'dsh-worktable', 'lib', 'client.js')], { cwd: HERE, stdio: 'pipe', encoding: 'utf8' })
|
||||
if (anchorRun.status !== 0) {
|
||||
console.error('[release-prep] FAIL: anchor-dom.test.mjs')
|
||||
console.error(anchorRun.stderr || anchorRun.stdout)
|
||||
process.exit(1)
|
||||
}
|
||||
console.log('[release-prep] split anchor dom tests passed (8 scenarios, on installed artifact)')
|
||||
|
||||
// ---------- 5d. 服务端数据目录解析回归(loadPkg ↔ resolveDshHomeSafe 循环调用修复) ----------
|
||||
// 评估「安装目录中的最终产物」lib/index.js;官方路径 / 包不可解析兜底 / ~ 与相对路径展开
|
||||
const serverHomeTest = join(HERE, '..', '04_test', 'server-home.test.mjs')
|
||||
const serverSrc = join(inst, 'node_modules', 'dsh-worktable', 'lib', 'index.js')
|
||||
if (!existsSync(serverHomeTest) || !existsSync(serverSrc)) {
|
||||
console.error('[release-prep] FAIL: server-home.test.mjs or installed lib/index.js missing')
|
||||
process.exit(1)
|
||||
}
|
||||
const serverRun = spawnSync(process.execPath, [serverHomeTest, serverSrc], { cwd: HERE, stdio: 'pipe', encoding: 'utf8' })
|
||||
if (serverRun.status !== 0) {
|
||||
console.error('[release-prep] FAIL: server-home.test.mjs')
|
||||
console.error(serverRun.stderr || serverRun.stdout)
|
||||
process.exit(1)
|
||||
}
|
||||
console.log('[release-prep] server home resolution tests passed (3 scenarios, on installed artifact)')
|
||||
|
||||
// ---------- 6. 双资产从同一已验证包复制 + SHA-256 ----------
|
||||
const outDir = join(HERE, 'dist', 'v' + VERSION)
|
||||
mkdirSync(outDir, { recursive: true })
|
||||
|
||||
@@ -1,9 +1,21 @@
|
||||
/** 更新公告正文(v0.3.2:文件夹选择体验 + 发布流程加固;呈现时按纯文本保留换行,不做 md 渲染) */
|
||||
export const CHANGELOG_VERSION = 'v0.3.2'
|
||||
export const CHANGELOG_V030 = `更新公告 · v0.3.2
|
||||
/** 更新公告正文(v0.3.3:DSH 0.1.2 兼容 + 数据路径修复;呈现时按纯文本保留换行,不做 md 渲染) */
|
||||
export const CHANGELOG_VERSION = 'v0.3.3'
|
||||
export const CHANGELOG_V030 = `更新公告 · v0.3.3
|
||||
|
||||
🛠️ 本版本更新
|
||||
|
||||
【兼容新版 DeepSeek Harness】适配已测版本 DSH 0.1.2-rc.1 与 0.1.1-rc.2:点击项目卡片不再无反应——分栏工作区在无会话 / 空会话 / 有消息会话下都能正常打开(0.1.1-rc.2 实测未发现回归);选择项目文件夹的窗口在 0.1.2-rc.1 上恢复正常可用;工作台数据读取不再依赖默认安装路径,自定义安装位置(DSH_HOME)也能正确读取项目与分组数据。
|
||||
|
||||
【关于选择文件夹窗口的已知问题(DeepSeek Harness 宿主自身问题,不是本插件的问题)】在部分系统上,点击「选择位置…」之后文件夹选择窗口可能不会自动跳到最前面,而是藏在任务栏或其他窗口后面。这是 DeepSeek Harness 宿主选择器的已知缺陷,与工作台无关,等待官方修复。遇到时点一下任务栏里的 DSH 图标即可切出窗口;若不想等,直接用「手动输入」粘贴文件夹绝对路径,功能完全不受影响。
|
||||
|
||||
【谁需要升级】仍在用老版本 DSH 且工作台一切正常的用户,可以暂不升级;升级到 0.1.2 系列、或遇到「点击项目卡片没有反应」的用户,建议升级本版本。
|
||||
|
||||
【升级说明】升级安装后请完整退出并重启 DSH 再刷新页面;若重启后仍显示加载失败,请保留完整错误信息反馈。
|
||||
|
||||
───────
|
||||
|
||||
此前版本说明(v0.3.2)
|
||||
|
||||
【文件夹选择体验】选择项目文件夹时:等待期间按钮显示「等待选择…」并提示「若未看到选择窗口,可检查任务栏,或使用手动输入」;新增「手动输入」入口,可直接粘贴文件夹绝对路径(相对路径会被拒绝并提示);选择失败时显示具体错误,不再静默无反应;修复了旧选择窗口返回后覆盖手工输入、弹窗关闭/切换后状态残留等问题。
|
||||
|
||||
【发布流程加固】发布包新增结构与身份校验、客户端工厂求值门禁、双资产同源核对与远端 SHA 比对(开发者侧改进,不影响插件功能)。
|
||||
|
||||
@@ -412,6 +412,8 @@ const registryStore: { ids: string[]; listeners: Set<() => void> } = { ids: [],
|
||||
|
||||
/** 自定义窗口 → 宿主会话桥(apply 时注入;不可用时 CustomPane 降级提示) */
|
||||
let sessionBridge: { sessions: any; conversation: any; list: any; workspaces: any } | null = null
|
||||
/** 客户端根 ctx(apply 时保存;用于运行时探测 0.1.2 的 remote.directoryPicker 等新服务,不硬写 inject) */
|
||||
let clientCtx: any = null
|
||||
|
||||
/** 宿主 API 客户端(apply 时从 connection 服务取;agentPresets/sessions 用于修复新会话继承失效模型的 bug) */
|
||||
let hostApi: { agentPresets?: any; sessions?: any } | null = null
|
||||
@@ -1845,11 +1847,29 @@ function buildCustomLayoutPrompt(req: string): string {
|
||||
* - useRef 在途锁 + 请求序号:真实防重入;手工确认/新请求会使旧请求失效,旧弹窗返回后丢弃
|
||||
* - 返回 null = 用户取消:不报错
|
||||
* - 抛异常 = 显示真实错误信息,不再静默吞掉
|
||||
* - 宿主能力不可用 = 提示改用「手动输入」 */
|
||||
* - 宿主能力三级探测(运行时,不硬写 inject):
|
||||
* ① 0.1.1-rc.2:ctx.workspaces.pickDirectory() → string | null
|
||||
* ② 0.1.2-rc.1:ctx remote.directoryPicker.pick() → { ok, value, error }(value 即路径或 null)
|
||||
* ③ 0.1.2 新能力不可用 → 提示改用「手动输入」 */
|
||||
const pickFolder = async (target: 'add' | 'bind', apply: (p: string) => void) => {
|
||||
if (pickBusyRef.current) return
|
||||
// 解析本次选择器调用路径
|
||||
const ws = sessionBridge?.workspaces as any
|
||||
if (!ws || typeof ws.pickDirectory !== 'function') {
|
||||
const legacy = ws && typeof ws.pickDirectory === 'function'
|
||||
? () => ws.pickDirectory()
|
||||
: null
|
||||
let remotePicker: (() => Promise<any>) | null = null
|
||||
try {
|
||||
const rp = clientCtx?.get?.('remote.directoryPicker')
|
||||
if (rp && typeof rp.pick === 'function') remotePicker = () => rp.pick()
|
||||
} catch {}
|
||||
if (!remotePicker) {
|
||||
try {
|
||||
const dp = (clientCtx as any)?.directoryPicker
|
||||
if (dp && typeof dp.pick === 'function') remotePicker = () => dp.pick()
|
||||
} catch {}
|
||||
}
|
||||
if (!legacy && !remotePicker) {
|
||||
setPickErr((prev) => ({ ...prev, [target]: t('add.folderPickerUnavailable') }))
|
||||
return
|
||||
}
|
||||
@@ -1858,7 +1878,19 @@ function buildCustomLayoutPrompt(req: string): string {
|
||||
setPickErr((prev) => ({ ...prev, [target]: '' }))
|
||||
const seq = ++pickSeqRef.current
|
||||
try {
|
||||
const p = await ws.pickDirectory()
|
||||
let p: string | null = null
|
||||
if (legacy) {
|
||||
p = await legacy()
|
||||
} else {
|
||||
const r = await remotePicker!()
|
||||
if (r && typeof r === 'object' && 'ok' in r) {
|
||||
if (!r.ok) throw new Error(r?.error?.message ?? 'directory picker failed')
|
||||
const v = r.value
|
||||
p = typeof v === 'string' ? v : (v && typeof v === 'object' && typeof v.path === 'string' ? v.path : null)
|
||||
} else {
|
||||
p = typeof r === 'string' ? r : null
|
||||
}
|
||||
}
|
||||
if (seq !== pickSeqRef.current) return // 已被手工确认/新请求/弹窗关闭失效:丢弃旧弹窗结果
|
||||
if (!mountedRef.current) return // 组件已卸载:不再应用
|
||||
if (p && typeof p === 'string') apply(p)
|
||||
@@ -3273,6 +3305,7 @@ export const inject = ['slots', 'locale', 'sessions', 'conversation', 'workspace
|
||||
export function apply(ctx: any) {
|
||||
// 自定义窗口 → 宿主会话桥:保存 sessions/conversation/list 服务引用(模块级)
|
||||
sessionBridge = { sessions: ctx.sessions ?? null, conversation: ctx.conversation ?? null, list: ctx.sessions?.list ?? null, workspaces: ctx.workspaces ?? null }
|
||||
clientCtx = ctx
|
||||
try { hostApi = ctx.get?.('connection')?.api ?? null } catch { hostApi = null }
|
||||
try { (window as any).__dshHostApi = hostApi } catch {}
|
||||
try { (window as any).__dshOpenSession = (id: string) => ctx.sessions?.open?.(id); (window as any).__dshSessions = ctx.sessions; (window as any).__dshPromptIntoSession = (id: string, text: string) => promptIntoSession(id, text); (window as any).__dshWorkspaces = ctx.workspaces; (window as any).__dshBuildWindowTaskText = buildWindowTaskText; (window as any).__dshSyncSessionScope = () => syncSessionScope(sessionBridge?.list) } catch {}
|
||||
|
||||
@@ -90,6 +90,8 @@ type SplitState = {
|
||||
savedMarginLeft: string
|
||||
savedMarginRight: string
|
||||
savedMarginTop: string
|
||||
/** 打开前会话根上 --dsh-chat-user-width 的内联值(关闭时原样恢复;0.1.1 上该变量闲置无害) */
|
||||
savedWidthVar: string
|
||||
observer: ResizeObserver | null
|
||||
fallback: MutationObserver | null
|
||||
yieldObserver: MutationObserver | null
|
||||
@@ -671,13 +673,48 @@ function AnnotationOverlay() {
|
||||
)
|
||||
}
|
||||
|
||||
/** 找到会话根容器:data-phase 元素中排除输入框、取含子元素者;优先 phase=active;无活动会话返回 null */
|
||||
/** 找到会话根容器:data-phase 元素中排除输入框、取含子元素者。
|
||||
* DSH 0.1.1-rc.2 与 0.1.2-rc.1 的会话阶段一致:active(有消息)/ hero(无会话或空会话)/ settling(过渡)。
|
||||
* 优先 active,其次 hero(空会话/无会话时也能打开分栏),settling 兜底(锚定后由观察器修正)。 */
|
||||
function findConversationRoot(): HTMLElement | null {
|
||||
const candidates = Array.from(document.querySelectorAll<HTMLElement>('[data-phase]'))
|
||||
const ok = (el: HTMLElement) => el.tagName !== 'TEXTAREA' && el.tagName !== 'INPUT' && el.children.length >= 2
|
||||
return candidates.find((el) => ok(el) && el.dataset.phase === 'active')
|
||||
?? candidates.find(ok)
|
||||
?? null
|
||||
const ok = (el: HTMLElement) => el.tagName !== 'TEXTAREA' && el.tagName !== 'INPUT'
|
||||
&& el.children.length >= 1 && !/input/i.test(String(el.className))
|
||||
const rank = (el: HTMLElement) => (el.dataset.phase === 'active' ? 0 : el.dataset.phase === 'hero' ? 1 : 2)
|
||||
let best: HTMLElement | null = null
|
||||
let bestRank = Infinity
|
||||
for (const el of candidates) {
|
||||
if (!ok(el)) continue
|
||||
const r = rank(el)
|
||||
if (r < bestRank) { bestRank = r; best = el }
|
||||
}
|
||||
return best
|
||||
}
|
||||
|
||||
/** 从首个槽位元素里解析「可见头部」:
|
||||
* - 0.1.1:children[0] 就是 <header> 本身(可见时自身有高度)。
|
||||
* - 0.1.2:children[0] 是零高的槽位包装(display:contents 式),真实头部渲染在其内部——
|
||||
* 此时向内找第一个可见后代(文档序 = 头部自身,先于其子元素)。
|
||||
* - 空会话(headerHidden,整棵子树 display:none):找不到任何可见元素 → null(顶部 = 根顶部)。 */
|
||||
function visibleHeaderIn(first: HTMLElement): HTMLElement | null {
|
||||
if (first.getBoundingClientRect().height > 0) return first
|
||||
for (const el of Array.from(first.querySelectorAll<HTMLElement>('*'))) {
|
||||
const r = el.getBoundingClientRect()
|
||||
if (r.height > 0 && r.width > 0) return el
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
/** 从会话根解析分栏锚点(兼容 0.1.1 与 0.1.2 两种 DOM 结构):
|
||||
* - 0.1.1 与 0.1.2 会话打开:root.children = [头部(或头部包装), 内容滚动区](0.1.2 多一层 body 包装,不影响取 children[1])。
|
||||
* - 0.1.2 无会话:root.children = [body](无头部元素)。
|
||||
* - 空会话(blank):头部带 headerHidden 样式(高度为 0),按「无头部」处理(顶部 = 根顶部)。
|
||||
* header 仅当存在第二个子元素且能解析出可见头部时生效;viewArea = 第二个子元素,只有一个时 = 第一个。 */
|
||||
function resolveAnchor(root: HTMLElement): { header: HTMLElement | null; viewArea: HTMLElement } {
|
||||
const first = root.children[0] as HTMLElement | undefined
|
||||
const second = root.children[1] as HTMLElement | undefined
|
||||
const header = !!second && !!first ? visibleHeaderIn(first) : null
|
||||
return { header, viewArea: second ?? first! }
|
||||
}
|
||||
|
||||
function loadSaved(layoutId: string): { chatW: number; topH: number; leftW: number; paneWs: number[]; topWs: number[]; leftWs: number[] } | null {
|
||||
@@ -730,6 +767,7 @@ export const splitStore: SplitState = {
|
||||
savedMarginLeft: '',
|
||||
savedMarginRight: '',
|
||||
savedMarginTop: '',
|
||||
savedWidthVar: '',
|
||||
observer: null,
|
||||
fallback: null,
|
||||
yieldObserver: null,
|
||||
@@ -759,9 +797,7 @@ export const splitStore: SplitState = {
|
||||
} catch {}
|
||||
const root = findConversationRoot()
|
||||
if (!root) return false
|
||||
const header = root.children[0] as HTMLElement | undefined
|
||||
const viewArea = root.children[1] as HTMLElement | undefined
|
||||
if (!header || !viewArea) return false
|
||||
const { header, viewArea } = resolveAnchor(root)
|
||||
this.spec = { ...spec, chatSide: spec.chatSide === 'left' ? 'left' : 'right' }
|
||||
// 向后兼容归一化:单内容声明 → 一个标签页
|
||||
const normalize = (p: SplitPane): SplitPane => {
|
||||
@@ -793,6 +829,7 @@ export const splitStore: SplitState = {
|
||||
this.root = root
|
||||
this.header = header
|
||||
this.viewArea = viewArea
|
||||
this.savedWidthVar = root.style.getPropertyValue('--dsh-chat-user-width')
|
||||
this.savedMarginLeft = viewArea.style.marginLeft
|
||||
this.savedMarginRight = viewArea.style.marginRight
|
||||
this.savedMarginTop = viewArea.style.marginTop
|
||||
@@ -841,20 +878,21 @@ export const splitStore: SplitState = {
|
||||
this.applyMargin()
|
||||
this.observer = new ResizeObserver(() => {
|
||||
const r = this.root
|
||||
if (!(r && r.isConnected && r.dataset.phase === 'active')) {
|
||||
this.syncAnchor()
|
||||
return
|
||||
}
|
||||
if (!(r && r.isConnected)) { this.syncAnchor(); return }
|
||||
const anchor = resolveAnchor(r)
|
||||
if (anchor.header !== this.header || anchor.viewArea !== this.viewArea) { this.syncAnchor(); return }
|
||||
this.refreshGeom()
|
||||
this.applyMargin()
|
||||
this.notify()
|
||||
})
|
||||
this.observer.observe(root)
|
||||
// 兜底:会话根被替换/phase 变化时 RO 可能不再回调,用 body 级 MutationObserver 驱动重锚定
|
||||
// 兜底:会话根被替换/子结构变化(如 hero→active 头部出现)时 RO 可能不再回调,
|
||||
// 用 body 级 MutationObserver 驱动重锚定;锚点未变时静默(避免流式消息期间高频刷新)
|
||||
this.fallback = new MutationObserver(() => {
|
||||
const r = this.root
|
||||
if (r && r.isConnected && r.dataset.phase === 'active') return
|
||||
this.syncAnchor()
|
||||
if (!(r && r.isConnected)) { this.syncAnchor(); return }
|
||||
const anchor = resolveAnchor(r)
|
||||
if (anchor.header !== this.header || anchor.viewArea !== this.viewArea) this.syncAnchor()
|
||||
})
|
||||
this.fallback.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['data-phase'] })
|
||||
// 让位观察器:会话视图区 margin 被外部改写(其他未接入协议的分栏引擎接管)时关闭自身
|
||||
@@ -872,7 +910,7 @@ export const splitStore: SplitState = {
|
||||
return true
|
||||
},
|
||||
|
||||
/** 会话根失效(切换会话)时重新锚定:左侧内容保持不关闭;无会话才关闭 */
|
||||
/** 会话根失效(切换会话 / hero↔active 结构变化)时重新锚定:左侧内容保持不关闭;无会话根才关闭 */
|
||||
syncAnchor() {
|
||||
if (!this.active) return
|
||||
const next = findConversationRoot()
|
||||
@@ -880,31 +918,42 @@ export const splitStore: SplitState = {
|
||||
this.close()
|
||||
return
|
||||
}
|
||||
if (next.dataset.phase !== 'active') return // 过渡态:保持等待(phase 变化会再次触发)
|
||||
if (next === this.root) {
|
||||
const ph = next.dataset.phase
|
||||
if (ph !== 'active' && ph !== 'hero') return // settling 等过渡态:保持等待(phase 变化会再次触发)
|
||||
const anchor = resolveAnchor(next)
|
||||
if (next === this.root && anchor.header === this.header && anchor.viewArea === this.viewArea) {
|
||||
// 同锚点:头部可能由隐藏变可见(hero→active),刷新几何与挤位
|
||||
this.refreshGeom()
|
||||
this.applyMargin()
|
||||
this.notify()
|
||||
return
|
||||
}
|
||||
const header = next.children[0] as HTMLElement | undefined
|
||||
const viewArea = next.children[1] as HTMLElement | undefined
|
||||
if (!header || !viewArea) {
|
||||
this.close()
|
||||
return
|
||||
const viewArea = anchor.viewArea
|
||||
const oldRoot = this.root
|
||||
const oldViewArea = this.viewArea
|
||||
// 恢复旧锚点(若仍连接),锚定到新会话根
|
||||
if (oldViewArea && oldViewArea.isConnected && oldViewArea !== viewArea) {
|
||||
oldViewArea.style.marginLeft = this.savedMarginLeft
|
||||
oldViewArea.style.marginRight = this.savedMarginRight
|
||||
oldViewArea.style.marginTop = this.savedMarginTop
|
||||
}
|
||||
// 恢复旧视图区 margin(若仍连接),锚定到新会话根
|
||||
if (this.viewArea && this.viewArea.isConnected && this.viewArea !== viewArea) {
|
||||
this.viewArea.style.marginLeft = this.savedMarginLeft
|
||||
this.viewArea.style.marginRight = this.savedMarginRight
|
||||
this.viewArea.style.marginTop = this.savedMarginTop
|
||||
if (oldRoot && oldRoot.isConnected && oldRoot !== next) {
|
||||
if (this.savedWidthVar) oldRoot.style.setProperty('--dsh-chat-user-width', this.savedWidthVar)
|
||||
else oldRoot.style.removeProperty('--dsh-chat-user-width')
|
||||
}
|
||||
this.root = next
|
||||
this.header = header
|
||||
this.header = anchor.header
|
||||
this.viewArea = viewArea
|
||||
this.savedMarginLeft = viewArea.style.marginLeft
|
||||
this.savedMarginRight = viewArea.style.marginRight
|
||||
this.savedMarginTop = viewArea.style.marginTop
|
||||
// 仅锚点元素真正更换时才记录「打开前」原值——同元素重锚(hero→active 头部出现)
|
||||
// 必须保留最初存档,否则关闭时会把已应用的 margin/变量误还原成「新原值」
|
||||
if (oldRoot !== next) {
|
||||
this.savedWidthVar = next.style.getPropertyValue('--dsh-chat-user-width')
|
||||
}
|
||||
if (oldViewArea !== viewArea) {
|
||||
this.savedMarginLeft = viewArea.style.marginLeft
|
||||
this.savedMarginRight = viewArea.style.marginRight
|
||||
this.savedMarginTop = viewArea.style.marginTop
|
||||
}
|
||||
this.observer?.disconnect()
|
||||
this.observer.observe(next)
|
||||
this.refreshGeom()
|
||||
@@ -914,11 +963,12 @@ export const splitStore: SplitState = {
|
||||
|
||||
refreshGeom() {
|
||||
const root = this.root
|
||||
const header = this.header
|
||||
if (!root || !header) return
|
||||
if (!root) return
|
||||
const rr = root.getBoundingClientRect()
|
||||
const hr = header.getBoundingClientRect()
|
||||
this.geom = { left: rr.left, top: hr.bottom, right: rr.right, bottom: rr.bottom }
|
||||
const hr = this.header ? this.header.getBoundingClientRect() : null
|
||||
// 头部隐藏(blank 会话)或无头部(0.1.2 无会话)时以根顶部为分栏上沿
|
||||
const top = hr && hr.height > 0 ? hr.bottom : rr.top
|
||||
this.geom = { left: rr.left, top, right: rr.right, bottom: rr.bottom }
|
||||
},
|
||||
|
||||
applyMargin() {
|
||||
@@ -931,6 +981,11 @@ export const splitStore: SplitState = {
|
||||
const hasLeft = !!spec.left
|
||||
const hasTop = !!(spec.top && spec.top.length > 0)
|
||||
const chatW = clamp(this.chatW, spec.chatWidth.min, Math.max(spec.chatWidth.min, colW - 60))
|
||||
// 会话内容宽 clamp(680px, …, 920px) 不随挤出的聊天列收缩 → 显式钉到挤出的列宽
|
||||
// (close/重锚定时原样恢复;0.1.1 上该 CSS 变量闲置,设置无害)
|
||||
if (this.root && this.root.isConnected) {
|
||||
this.root.style.setProperty('--dsh-chat-user-width', Math.round(chatW) + 'px')
|
||||
}
|
||||
const topH = hasTop
|
||||
? clamp(this.topH, spec.topHeight?.min ?? 80, Math.max(spec.topHeight?.min ?? 80, rowH - BAR_H - 80))
|
||||
: 0
|
||||
@@ -1261,6 +1316,10 @@ export const splitStore: SplitState = {
|
||||
},
|
||||
|
||||
close() {
|
||||
if (this.root && this.root.isConnected) {
|
||||
if (this.savedWidthVar) this.root.style.setProperty('--dsh-chat-user-width', this.savedWidthVar)
|
||||
else this.root.style.removeProperty('--dsh-chat-user-width')
|
||||
}
|
||||
if (this.viewArea) {
|
||||
this.viewArea.style.marginLeft = this.savedMarginLeft
|
||||
this.viewArea.style.marginRight = this.savedMarginRight
|
||||
@@ -1275,6 +1334,7 @@ export const splitStore: SplitState = {
|
||||
this.root = null
|
||||
this.header = null
|
||||
this.viewArea = null
|
||||
this.savedWidthVar = ''
|
||||
this.geom = null
|
||||
this.spec = null
|
||||
this.active = false
|
||||
|
||||
+83
-4
@@ -7,6 +7,45 @@ import { createRequire } from 'node:module'
|
||||
import { homedir } from 'node:os'
|
||||
import { fileURLToPath, pathToFileURL } from 'node:url'
|
||||
|
||||
/**
|
||||
* 基础数据目录解析:不加载任何官方包(loadPkg 的兜底只能用它,禁止反向调用包加载函数——否则成环)。
|
||||
* 规则与官方 @deepseek-ai/dsh-home-paths 的 resolveDshHome 一致:
|
||||
* DSH_HOME 环境变量优先(空/纯空白视为未设置),否则 ~/.dsh;
|
||||
* 支持 ~、~/、~\ 前缀展开;相对路径按进程 cwd 解析;结果归一为绝对路径。
|
||||
* 禁止任何业务代码直接拼 homedir()/.dsh —— 自定义 DSH_HOME(Desktop/隔离测试)会读错数据。
|
||||
*/
|
||||
function baseDshHome(): string {
|
||||
const env = process.env.DSH_HOME
|
||||
// 与官方一致:trim 只用于判断是否全空白,实际路径保留原字符串(两端空格有含义)
|
||||
const value = env !== undefined && env.trim().length > 0 ? env : pathResolve(homedir(), '.dsh')
|
||||
if (value === '~') return homedir()
|
||||
if (value.startsWith('~/') || value.startsWith('~\\')) return pathResolve(homedir(), value.slice(2))
|
||||
return pathResolve(value)
|
||||
}
|
||||
|
||||
/** 解析 DSH 数据根目录:优先官方 @deepseek-ai/dsh-home-paths(显式配置/DSH_HOME/默认),
|
||||
* 不可用或返回非法值时回退 baseDshHome()(同官方规则)。带缓存。 */
|
||||
let cachedDshHome: string | null = null
|
||||
/** 本次解析实际走了哪条路径(供测试断言官方包是否真的被使用) */
|
||||
let dshHomeSource: 'official' | 'fallback' = 'fallback'
|
||||
function resolveDshHomeSafe(): string {
|
||||
if (cachedDshHome) return cachedDshHome
|
||||
try {
|
||||
const pkg = loadPkg('@deepseek-ai/dsh-home-paths') as any
|
||||
if (pkg && typeof pkg.resolveDshHome === 'function') {
|
||||
const home = pkg.resolveDshHome(undefined, process.env)
|
||||
if (typeof home === 'string' && home.trim() !== '') {
|
||||
dshHomeSource = 'official'
|
||||
cachedDshHome = home
|
||||
return cachedDshHome
|
||||
}
|
||||
}
|
||||
} catch {}
|
||||
dshHomeSource = 'fallback'
|
||||
cachedDshHome = baseDshHome()
|
||||
return cachedDshHome
|
||||
}
|
||||
|
||||
/**
|
||||
* dsh-worktable 服务端:健康路由 + 工作区内容窗的数据路由。
|
||||
* 参考 dsh-better-sidebar 的架构——内容窗能力由本插件自己的服务端路由提供:
|
||||
@@ -53,6 +92,8 @@ const TEMPLATE_PREFIX = '/api/worktable/template'
|
||||
* 本包经 junction 链接进 profile,普通 import 可能解析不到 profile 级依赖;
|
||||
* 同时尝试 junction 路径与 realpath 两条祖先链。
|
||||
*/
|
||||
/** 依赖探测尝试计数(供测试断言「有界探测、无循环重入」) */
|
||||
let loadProbeAttempts = 0
|
||||
function loadPkg(pkg: string): any | null {
|
||||
const starts = new Set<string>()
|
||||
try { starts.add(dirname(fileURLToPath(import.meta.url))) } catch {}
|
||||
@@ -60,6 +101,7 @@ function loadPkg(pkg: string): any | null {
|
||||
for (const start of starts) {
|
||||
let dir: string | null = start
|
||||
while (dir && dir !== pathResolve(dir, '..')) {
|
||||
loadProbeAttempts++
|
||||
try {
|
||||
const req = createRequire(pathToFileURL(pathResolve(dir, '__wt_probe__.js')).href)
|
||||
return req(pkg)
|
||||
@@ -67,12 +109,13 @@ function loadPkg(pkg: string): any | null {
|
||||
dir = pathResolve(dir, '..')
|
||||
}
|
||||
}
|
||||
// 兜底:DSH 标准目录 ~/.dsh/profiles/*/node_modules(宿主按 realpath 加载时前两条链都找不到)
|
||||
// 兜底:DSH profiles/*/node_modules(按 baseDshHome 解析根目录——不能用 resolveDshHomeSafe,否则与本函数成环)
|
||||
try {
|
||||
const profilesDir = pathResolve(homedir(), '.dsh', 'profiles')
|
||||
const profilesDir = pathResolve(baseDshHome(), 'profiles')
|
||||
for (const profile of readdirSync(profilesDir, { withFileTypes: true })) {
|
||||
if (!profile.isDirectory() && !profile.isSymbolicLink()) continue
|
||||
const nm = pathResolve(profilesDir, profile.name, 'node_modules')
|
||||
loadProbeAttempts++
|
||||
try {
|
||||
const req = createRequire(pathToFileURL(pathResolve(nm, '__wt_probe__.js')).href)
|
||||
return req(pkg)
|
||||
@@ -82,6 +125,11 @@ function loadPkg(pkg: string): any | null {
|
||||
return null
|
||||
}
|
||||
|
||||
/** 测试钩子:依赖探测尝试次数 + 数据目录解析路径(循环回归与官方路径断言用) */
|
||||
export function __wtLoadProbeStats(): { attempts: number; homeSource: 'official' | 'fallback' } {
|
||||
return { attempts: loadProbeAttempts, homeSource: dshHomeSource }
|
||||
}
|
||||
|
||||
/** 解析会话工作目录:服务端 header.cwd 优先,其次客户端传入 cwd,最后进程 cwd */
|
||||
function serverCwd(ctx: any, sessionId?: string, clientCwd?: string): string {
|
||||
if (sessionId) {
|
||||
@@ -316,13 +364,44 @@ export function apply(ctx: Context) {
|
||||
},
|
||||
})
|
||||
|
||||
// 工作区列表(自定义窗口会话分组用):读宿主 ~/.dsh/storages/workspace.json(只读)
|
||||
// 工作区列表(自定义窗口会话分组用):
|
||||
// 优先走宿主正式服务 ctx.workspaceRegistry(0.1.1/0.1.2 均有,正确感知 DSH_HOME 与存储后端);
|
||||
// 不可用时回退按 resolveDshHomeSafe() 读 storages/workspace.json(只读)。
|
||||
// 返回结构是客户端契约,两种来源都映射成同一 shape。
|
||||
webServer.register({
|
||||
kind: 'exact',
|
||||
path: '/api/worktable/workspaces',
|
||||
handler: async (_req: any, res: any) => {
|
||||
try {
|
||||
const file = pathResolve(homedir(), '.dsh', 'storages', 'workspace.json')
|
||||
// cordis 对未 inject 服务的属性访问会直接 throw(不返回 undefined),必须 try-catch 探测
|
||||
let registry: any = null
|
||||
try { registry = (ctx as any).workspaceRegistry ?? null } catch {}
|
||||
if (!registry) {
|
||||
try { registry = ctx.get?.('workspaceRegistry') ?? null } catch {}
|
||||
}
|
||||
if (registry && typeof registry.list === 'function') {
|
||||
const list = registry.list() ?? []
|
||||
const workspaceIds: string[] = []
|
||||
const tables: Record<string, { title?: string; sessionIds?: string[] }> = {}
|
||||
for (const ws of list) {
|
||||
const id = String(ws?.id ?? '')
|
||||
if (!id) continue
|
||||
workspaceIds.push(id)
|
||||
tables[id] = {
|
||||
title: typeof ws?.title === 'string' ? ws.title : undefined,
|
||||
sessionIds: Array.isArray(ws?.sessionIds) ? ws.sessionIds.map(String) : [],
|
||||
}
|
||||
}
|
||||
let archived: string[] = []
|
||||
try { archived = (registry.archivedSessionIds ?? []).map(String) } catch {}
|
||||
json(res, 200, {
|
||||
unit: { name: 'workspace', version: 2 },
|
||||
global: { initialized: true, workspaceIds, archivedSessionIds: archived },
|
||||
tables: { workspaces: tables },
|
||||
})
|
||||
return
|
||||
}
|
||||
const file = pathResolve(resolveDshHomeSafe(), 'storages', 'workspace.json')
|
||||
const raw = await readFile(file, 'utf8')
|
||||
// 容忍 BOM(外部工具改写可能带 EF BB BF,JSON.parse 会抛错)
|
||||
json(res, 200, JSON.parse(raw.charCodeAt(0) === 0xFEFF ? raw.slice(1) : raw))
|
||||
|
||||
Reference in New Issue
Block a user