dsh-ws-recency 0.19.2 → 0.20.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 +7 -6
- package/client.js +221 -166
- package/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -120,16 +120,17 @@ DSH 原生的置顶只把会话顶到**它所属工作区分组的第一行**,
|
|
|
120
120
|
|
|
121
121
|
## 八、交接到新会话
|
|
122
122
|
|
|
123
|
-
长期会话的上下文迟早会满,被动压缩往往比"换个新会话、带上交接"
|
|
123
|
+
长期会话的上下文迟早会满,被动压缩往往比"换个新会话、带上交接"更差。交接全程在**对话里**完成,不会弹窗:
|
|
124
124
|
|
|
125
|
-
1.
|
|
125
|
+
1. 每轮回复底部的动作行(复制 / 点赞 / 分支那一排)里点 **交接到新会话**:插件把一段固定指令放进输入框并尝试直接发送(发不出去就在卡片上提示你按回车);
|
|
126
126
|
2. 当前会话的 AI 按指令输出一个 ```handoff 代码块——**只写文档路径和要点,不粘贴文档内容**;
|
|
127
|
-
3. 插件每 2
|
|
128
|
-
4.
|
|
127
|
+
3. 插件每 2 秒读一次这个会话的最新回复,抓到代码块后,**在该轮回复下方**出现一张卡片:可编辑预览 + 三个按钮;
|
|
128
|
+
4. **交接到新会话**:在当前工作区开一个新会话,把"开场要求 + 交接块"预填进输入框,你按回车开始;**继续补充**回到输入框接着打磨(新一轮回复会刷新卡片);**放弃交接**收起卡片。
|
|
129
|
+
5. 轮询最多 5 分钟后自动收起,避免一直挂着。
|
|
129
130
|
|
|
130
131
|
- 交接内容另存一份到 `~/.hypers-work/.wsr/handoff/<sessionId>-<时间>.md`;
|
|
131
132
|
- 新会话是草稿形态:侧栏显示为「新会话」,发出第一条消息后才转正;
|
|
132
|
-
-
|
|
133
|
+
- 「…」菜单里的同名入口保留。
|
|
133
134
|
|
|
134
135
|
## 设置
|
|
135
136
|
|
|
@@ -167,7 +168,7 @@ dsh plugin --profile <profile> add github:chyxhtc/dsh-ws-recency
|
|
|
167
168
|
或固定版本的预构建包:
|
|
168
169
|
|
|
169
170
|
```powershell
|
|
170
|
-
dsh plugin --profile <profile> add https://github.com/chyxhtc/dsh-ws-recency/releases/download/v0.
|
|
171
|
+
dsh plugin --profile <profile> add https://github.com/chyxhtc/dsh-ws-recency/releases/download/v0.20.0/dsh-ws-recency-0.20.0.tgz
|
|
171
172
|
```
|
|
172
173
|
|
|
173
174
|
装完把 `dsh-ws-recency` 加进 `~/.hypers-work/profiles/<profile>/package.json` 的 `dsh.profile.bundles`,重启应用。
|
package/client.js
CHANGED
|
@@ -140,6 +140,10 @@
|
|
|
140
140
|
".wsr-footer-action{display:flex;box-sizing:border-box;flex:none;align-items:center;justify-content:flex-start;gap:8px;width:calc(100% + 4px);min-width:0;height:42px;margin:4px -2px;padding:0 10px 0 8px;border:0;border-radius:12px;background:transparent;color:var(--dsw-alias-label-primary);font-family:inherit;font-size:14px;line-height:22px;text-align:left;cursor:pointer}",
|
|
141
141
|
".wsr-footer-action:hover{background:var(--dsw-alias-interactive-bg-hover)}",
|
|
142
142
|
".wsr-page{display:flex;flex-direction:column;gap:10px;padding:16px 18px;min-width:0;box-sizing:border-box;height:100%;overflow:auto}",
|
|
143
|
+
".wsr-handoff-card{display:flex;flex-direction:column;gap:8px;margin:8px 0;padding:12px 14px;border:.5px solid var(--dsw-alias-border-l2,rgba(255,255,255,.16));border-radius:10px;background:var(--dsw-alias-bg-layer-2,rgba(255,255,255,.04))}",
|
|
144
|
+
".wsr-handoff-head{font-size:12px;color:var(--dsw-alias-label-secondary)}",
|
|
145
|
+
".wsr-handoff-actions{display:flex;gap:6px;align-items:center;white-space:nowrap}",
|
|
146
|
+
".wsr-handoff-live{margin:8px 0;font-size:12px;color:var(--dsw-alias-label-tertiary)}",
|
|
143
147
|
".wsr-msg-btn{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;padding:0;border:none;border-radius:4px;background:transparent;color:var(--dsw-alias-label-tertiary);cursor:pointer}",
|
|
144
148
|
".wsr-msg-btn:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(255,255,255,.08));color:var(--dsw-alias-label-primary)}",
|
|
145
149
|
".wsr-handoff-status{font-size:12px;color:var(--dsw-alias-label-tertiary);line-height:1.6}",
|
|
@@ -264,7 +268,7 @@
|
|
|
264
268
|
"stats.diagnose.unmounted": "\n\n(宿主半已加载,但统计路由没挂上——重启应用再试)",
|
|
265
269
|
"stats.diagnose.noHost": "\n\n(宿主半未加载:需要重启应用加载新版本)",
|
|
266
270
|
"menu.move": "移动到工作区…",
|
|
267
|
-
"menu.handoff": "
|
|
271
|
+
"menu.handoff": "交接到新会话",
|
|
268
272
|
"handoff.title": "会话交接",
|
|
269
273
|
"handoff.note": "交接指令已经放进输入框(或点「复制指令」自己粘),发送后我在这里等 AI 写出交接块;抓到以后可以直接开到新会话。",
|
|
270
274
|
"handoff.instruction": "我要把这个会话交接给一个新会话继续推进。请按下面的要求输出一份交接说明,写进一个 ```handoff 代码块里,我会原样交给新会话:\n\n1. 只给文档路径和一句话说明「读它为什么」,不要粘贴文档内容;\n2. 文档按重要性排序,标注哪些必读、哪些按需;\n3. 包含:目标、当前进度、尚未完成与下一步、关键决策与约束、踩过的坑、验证方式;\n4. 交接正文控制在 400 字以内(文档引用除外)。",
|
|
@@ -384,7 +388,7 @@
|
|
|
384
388
|
"stats.diagnose.unmounted": "\n\n(the host half is loaded but the statistics route did not mount - restart the app and retry)",
|
|
385
389
|
"stats.diagnose.noHost": "\n\n(the host half is not loaded: restart the app to pick up the new version)",
|
|
386
390
|
"menu.move": "Move to workspace\u2026",
|
|
387
|
-
"menu.handoff": "
|
|
391
|
+
"menu.handoff": "Hand off to a new session",
|
|
388
392
|
"handoff.title": "Session handoff",
|
|
389
393
|
"handoff.note": "The instruction is in the composer (or copy it yourself). Once you send it I watch for the handoff block and can carry it into a fresh Session.",
|
|
390
394
|
"handoff.instruction": "I am handing this session over to a new one. Please answer with a handoff note inside a ```handoff code block, which I will pass on verbatim:\n\n1. Reference documents by path with one line on why to read them; never paste document contents.\n2. Order them by importance and mark which are required and which are optional.\n3. Cover: goal, current progress, remaining work and next step, key decisions and constraints, pitfalls, and how to verify.\n4. Keep the note under 400 words (references excluded).",
|
|
@@ -1870,17 +1874,31 @@
|
|
|
1870
1874
|
|
|
1871
1875
|
/* ------------------------------ handoff ------------------------------ */
|
|
1872
1876
|
|
|
1877
|
+
var handoffStore = null;
|
|
1873
1878
|
var handoffTimer = null;
|
|
1874
|
-
var
|
|
1879
|
+
var handoffBaseline = 0;
|
|
1880
|
+
var handoffTries = 0;
|
|
1881
|
+
var handoffSession = null;
|
|
1875
1882
|
|
|
1876
1883
|
/** The instruction the user sends to the current Session. */
|
|
1877
1884
|
function handoffInstruction() {
|
|
1878
1885
|
return t("handoff.instruction");
|
|
1879
1886
|
}
|
|
1880
1887
|
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1888
|
+
function handoffPost(payload) {
|
|
1889
|
+
return fetch("/ws-recency/handoff", {
|
|
1890
|
+
method: "POST",
|
|
1891
|
+
headers: { "content-type": "application/json" },
|
|
1892
|
+
body: JSON.stringify(payload),
|
|
1893
|
+
}).then(function (response) {
|
|
1894
|
+
return response.json().catch(function () { return null; });
|
|
1895
|
+
});
|
|
1896
|
+
}
|
|
1897
|
+
|
|
1898
|
+
/** Write text into the composer and send it, if the editor is reachable. */
|
|
1899
|
+
function sendInstruction(sessionId) {
|
|
1900
|
+
var text = handoffInstruction();
|
|
1901
|
+
if (typeof document === "undefined") return false;
|
|
1884
1902
|
var seat = typeof document.querySelector === "function" ? document.querySelector("[data-composer-seat]") : null;
|
|
1885
1903
|
if (seat === null || seat === undefined) return false;
|
|
1886
1904
|
var editor = null;
|
|
@@ -1894,38 +1912,58 @@
|
|
|
1894
1912
|
if (editor.tagName === "TEXTAREA" || editor.tagName === "INPUT") {
|
|
1895
1913
|
editor.value = text;
|
|
1896
1914
|
editor.dispatchEvent(new window.Event("input", { bubbles: true }));
|
|
1897
|
-
|
|
1915
|
+
} else {
|
|
1916
|
+
var selection = typeof window.getSelection === "function" ? window.getSelection() : null;
|
|
1917
|
+
if (selection !== null && typeof document.createRange === "function") {
|
|
1918
|
+
var range = document.createRange();
|
|
1919
|
+
range.selectNodeContents(editor);
|
|
1920
|
+
range.collapse(false);
|
|
1921
|
+
selection.removeAllRanges();
|
|
1922
|
+
selection.addRange(range);
|
|
1923
|
+
}
|
|
1924
|
+
if (typeof document.execCommand !== "function" || !document.execCommand("insertText", false, text)) {
|
|
1925
|
+
editor.textContent = text;
|
|
1926
|
+
editor.dispatchEvent(new window.Event("input", { bubbles: true }));
|
|
1927
|
+
}
|
|
1898
1928
|
}
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1929
|
+
/* Enter is the only submit path the composer exposes to a plugin. If it
|
|
1930
|
+
does not take, the card says so and the user presses it themselves. */
|
|
1931
|
+
var sent = false;
|
|
1932
|
+
try {
|
|
1933
|
+
var event = new window.KeyboardEvent("keydown", {
|
|
1934
|
+
key: "Enter",
|
|
1935
|
+
code: "Enter",
|
|
1936
|
+
keyCode: 13,
|
|
1937
|
+
which: 13,
|
|
1938
|
+
bubbles: true,
|
|
1939
|
+
cancelable: true,
|
|
1940
|
+
});
|
|
1941
|
+
editor.dispatchEvent(event);
|
|
1942
|
+
sent = true;
|
|
1943
|
+
} catch (error) {
|
|
1944
|
+
sent = false;
|
|
1906
1945
|
}
|
|
1907
|
-
|
|
1908
|
-
editor.textContent = text;
|
|
1909
|
-
editor.dispatchEvent(new window.Event("input", { bubbles: true }));
|
|
1910
|
-
return true;
|
|
1946
|
+
return sent;
|
|
1911
1947
|
} catch (error) {
|
|
1912
1948
|
return false;
|
|
1913
1949
|
}
|
|
1914
1950
|
}
|
|
1915
1951
|
|
|
1916
|
-
function
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1952
|
+
function stopHandoffPolling() {
|
|
1953
|
+
if (handoffTimer !== null && typeof window.clearTimeout === "function") window.clearTimeout(handoffTimer);
|
|
1954
|
+
handoffTimer = null;
|
|
1955
|
+
}
|
|
1956
|
+
|
|
1957
|
+
function resetHandoff() {
|
|
1958
|
+
stopHandoffPolling();
|
|
1959
|
+
handoffSession = null;
|
|
1960
|
+
handoffBaseline = 0;
|
|
1961
|
+
handoffTries = 0;
|
|
1962
|
+
if (handoffStore !== null && handoffStore !== undefined) {
|
|
1963
|
+
try { handoffStore.actions.setIdle(); } catch (error) { /* store gone */ }
|
|
1924
1964
|
}
|
|
1925
|
-
return false;
|
|
1926
1965
|
}
|
|
1927
1966
|
|
|
1928
|
-
/** Pull the fenced block out of an assistant reply. */
|
|
1929
1967
|
function handoffBlockOf(text) {
|
|
1930
1968
|
if (typeof text !== "string") return "";
|
|
1931
1969
|
var match = /```handoff[ \t]*\r?\n([\s\S]*?)```/i.exec(text);
|
|
@@ -1935,151 +1973,128 @@
|
|
|
1935
1973
|
return "";
|
|
1936
1974
|
}
|
|
1937
1975
|
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
head.appendChild(statsDiv("wsr-modal-title", t("handoff.title")));
|
|
1959
|
-
var close = document.createElement("button");
|
|
1960
|
-
close.type = "button";
|
|
1961
|
-
close.className = "wsr-modal-close";
|
|
1962
|
-
close.textContent = "\u00d7";
|
|
1963
|
-
close.addEventListener("click", closeHandoffPanel);
|
|
1964
|
-
head.appendChild(close);
|
|
1965
|
-
panel.appendChild(head);
|
|
1966
|
-
|
|
1967
|
-
var body = statsDiv("wsr-modal-body");
|
|
1968
|
-
panel.appendChild(body);
|
|
1969
|
-
body.appendChild(statsDiv("wsr-stats-note", t("handoff.note")));
|
|
1970
|
-
|
|
1971
|
-
var status = statsDiv("wsr-handoff-status", t("handoff.waiting", { n: 0 }));
|
|
1972
|
-
body.appendChild(status);
|
|
1973
|
-
|
|
1974
|
-
var preview = document.createElement("textarea");
|
|
1975
|
-
preview.className = "wsr-handoff-text";
|
|
1976
|
-
preview.setAttribute("data-wsr-handoff-text", "true");
|
|
1977
|
-
preview.style.display = "none";
|
|
1978
|
-
body.appendChild(preview);
|
|
1979
|
-
|
|
1980
|
-
var actions = statsDiv("wsr-trash-actions");
|
|
1981
|
-
var copy = document.createElement("button");
|
|
1982
|
-
copy.type = "button";
|
|
1983
|
-
copy.className = "wsr-btn";
|
|
1984
|
-
copy.textContent = t("handoff.copy");
|
|
1985
|
-
copy.addEventListener("click", function () {
|
|
1986
|
-
if (copyText(handoffInstruction())) status.textContent = t("handoff.inserted");
|
|
1987
|
-
});
|
|
1988
|
-
actions.appendChild(copy);
|
|
1989
|
-
|
|
1990
|
-
var more = document.createElement("button");
|
|
1991
|
-
more.type = "button";
|
|
1992
|
-
more.className = "wsr-btn";
|
|
1993
|
-
more.textContent = t("handoff.more");
|
|
1994
|
-
more.addEventListener("click", function () {
|
|
1995
|
-
preview.style.display = "none";
|
|
1996
|
-
baseline = replies;
|
|
1997
|
-
status.textContent = t("handoff.waiting", { n: 0 });
|
|
1998
|
-
insertIntoComposer(handoffInstruction());
|
|
1999
|
-
poll(0);
|
|
2000
|
-
});
|
|
2001
|
-
actions.appendChild(more);
|
|
2002
|
-
|
|
2003
|
-
var confirm = document.createElement("button");
|
|
2004
|
-
confirm.type = "button";
|
|
2005
|
-
confirm.className = "wsr-btn";
|
|
2006
|
-
confirm.disabled = true;
|
|
2007
|
-
confirm.style.display = "none";
|
|
2008
|
-
confirm.textContent = t("handoff.confirm");
|
|
2009
|
-
confirm.addEventListener("click", function () {
|
|
2010
|
-
var text = preview.value.trim();
|
|
2011
|
-
if (text === "") return;
|
|
2012
|
-
confirm.disabled = true;
|
|
2013
|
-
fetch("/ws-recency/handoff", {
|
|
2014
|
-
method: "POST",
|
|
2015
|
-
headers: { "content-type": "application/json" },
|
|
2016
|
-
body: JSON.stringify({ action: "save", sessionId: sessionId, text: text }),
|
|
2017
|
-
}).catch(function () { return null; }).then(function () {
|
|
2018
|
-
var owner = workspaceOfSession(sessionId);
|
|
2019
|
-
var workspaceId = owner === null ? undefined : owner.workspaceId;
|
|
2020
|
-
var service = data.service;
|
|
2021
|
-
var prompt = t("handoff.preamble") + "\n\n" + text;
|
|
2022
|
-
if (service !== null && service !== undefined && typeof service.startSession === "function") {
|
|
2023
|
-
try {
|
|
2024
|
-
service.startSession(workspaceId, { prompt: prompt, whenDraftExists: "replace" });
|
|
2025
|
-
closeHandoffPanel();
|
|
2026
|
-
return;
|
|
2027
|
-
} catch (error) {
|
|
2028
|
-
/* fall through to the clipboard */
|
|
1976
|
+
/** Start the watch: the next reply that carries a handoff block becomes the card. */
|
|
1977
|
+
function watchHandoff(sessionId) {
|
|
1978
|
+
handoffSession = sessionId;
|
|
1979
|
+
handoffTries = 0;
|
|
1980
|
+
stopHandoffPolling();
|
|
1981
|
+
if (typeof window === "undefined") return;
|
|
1982
|
+
function tick() {
|
|
1983
|
+
if (handoffSession !== sessionId) return;
|
|
1984
|
+
handoffTries += 1;
|
|
1985
|
+
handoffPost({ action: "tail", sessionId: sessionId }).then(function (answer) {
|
|
1986
|
+
if (handoffSession !== sessionId) return;
|
|
1987
|
+
if (answer !== null && answer.ok === true) {
|
|
1988
|
+
var replies = typeof answer.replies === "number" ? answer.replies : 0;
|
|
1989
|
+
if (replies > handoffBaseline) {
|
|
1990
|
+
var found = handoffBlockOf(answer.text);
|
|
1991
|
+
if (found !== "") {
|
|
1992
|
+
handoffStore.actions.setReady(found);
|
|
1993
|
+
return;
|
|
1994
|
+
}
|
|
1995
|
+
handoffBaseline = replies;
|
|
2029
1996
|
}
|
|
2030
1997
|
}
|
|
2031
|
-
|
|
2032
|
-
|
|
1998
|
+
if (handoffTries > 150) {
|
|
1999
|
+
handoffStore.actions.setIdle();
|
|
2000
|
+
handoffSession = null;
|
|
2001
|
+
return;
|
|
2002
|
+
}
|
|
2003
|
+
handoffTimer = window.setTimeout(tick, 2000);
|
|
2004
|
+
}).catch(function () {
|
|
2005
|
+
handoffTimer = window.setTimeout(tick, 4000);
|
|
2033
2006
|
});
|
|
2007
|
+
}
|
|
2008
|
+
/* The baseline is the reply count before the instruction is answered. */
|
|
2009
|
+
handoffPost({ action: "tail", sessionId: sessionId }).then(function (answer) {
|
|
2010
|
+
if (handoffSession !== sessionId) return;
|
|
2011
|
+
handoffBaseline = answer !== null && answer.ok === true && typeof answer.replies === "number" ? answer.replies : 0;
|
|
2012
|
+
handoffTimer = window.setTimeout(tick, 1500);
|
|
2013
|
+
}).catch(function () {
|
|
2014
|
+
handoffTimer = window.setTimeout(tick, 3000);
|
|
2034
2015
|
});
|
|
2035
|
-
|
|
2036
|
-
body.appendChild(actions);
|
|
2016
|
+
}
|
|
2037
2017
|
|
|
2038
|
-
|
|
2039
|
-
|
|
2018
|
+
/** The turn action: send the instruction and wait for the block. */
|
|
2019
|
+
function startHandoff(sessionId) {
|
|
2020
|
+
if (handoffStore === null || handoffStore === undefined) return;
|
|
2021
|
+
if (typeof sessionId !== "string" || sessionId === "") return;
|
|
2022
|
+
var sent = sendInstruction(sessionId);
|
|
2023
|
+
handoffStore.actions.setRunning(sessionId, sent);
|
|
2024
|
+
watchHandoff(sessionId);
|
|
2025
|
+
}
|
|
2040
2026
|
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2027
|
+
/** The card carries it over: open a fresh Session in the same workspace. */
|
|
2028
|
+
function carryHandoff(sessionId, block) {
|
|
2029
|
+
var text = typeof block === "string" ? block.trim() : "";
|
|
2030
|
+
if (text === "") return;
|
|
2031
|
+
handoffPost({ action: "save", sessionId: sessionId, text: text }).catch(function () { return null; }).then(function () {
|
|
2032
|
+
var owner = workspaceOfSession(sessionId);
|
|
2033
|
+
var workspaceId = owner === null ? undefined : owner.workspaceId;
|
|
2034
|
+
var service = data.service;
|
|
2035
|
+
var prompt = t("handoff.preamble") + "\n\n" + text;
|
|
2036
|
+
if (service !== null && service !== undefined && typeof service.startSession === "function") {
|
|
2037
|
+
try {
|
|
2038
|
+
service.startSession(workspaceId, { prompt: prompt, whenDraftExists: "replace" });
|
|
2039
|
+
resetHandoff();
|
|
2040
|
+
return;
|
|
2041
|
+
} catch (error) {
|
|
2042
|
+
/* fall through */
|
|
2043
|
+
}
|
|
2044
|
+
}
|
|
2045
|
+
try {
|
|
2046
|
+
if (navigator !== undefined && navigator.clipboard !== undefined) navigator.clipboard.writeText(prompt);
|
|
2047
|
+
} catch (error) {
|
|
2048
|
+
/* clipboard unavailable */
|
|
2049
|
+
}
|
|
2050
|
+
resetHandoff();
|
|
2051
|
+
});
|
|
2052
|
+
}
|
|
2047
2053
|
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
body: JSON.stringify({ action: "tail", sessionId: sessionId }),
|
|
2059
|
-
}).then(function (response) {
|
|
2060
|
-
return response.json().catch(function () { return null; });
|
|
2061
|
-
}).then(function (answer) {
|
|
2062
|
-
if (answer === null || answer.ok !== true) return;
|
|
2063
|
-
replies = typeof answer.replies === "number" ? answer.replies : 0;
|
|
2064
|
-
if (baseline === 0) baseline = replies > 0 ? replies - 1 : 0;
|
|
2065
|
-
tries += 1;
|
|
2066
|
-
var block = replies > baseline ? handoffBlockOf(answer.text) : "";
|
|
2067
|
-
if (block !== "") {
|
|
2068
|
-
preview.value = block;
|
|
2069
|
-
preview.style.display = "";
|
|
2070
|
-
confirm.style.display = "";
|
|
2071
|
-
confirm.disabled = false;
|
|
2072
|
-
status.textContent = t("handoff.found");
|
|
2073
|
-
return;
|
|
2074
|
-
}
|
|
2075
|
-
status.textContent = t("handoff.waiting", { n: tries * 2 });
|
|
2076
|
-
poll(2000);
|
|
2077
|
-
}).catch(function () {
|
|
2078
|
-
poll(4000);
|
|
2079
|
-
});
|
|
2080
|
-
}, delay);
|
|
2054
|
+
/**
|
|
2055
|
+
* The handoff card, rendered in the turn tail: it appears only for the
|
|
2056
|
+
* Session that started the flow, and only once a block has been produced.
|
|
2057
|
+
*/
|
|
2058
|
+
function HandoffTailCard(props) {
|
|
2059
|
+
var sessionId = props !== undefined && props !== null && typeof props.sessionId === "string" ? props.sessionId : "";
|
|
2060
|
+
var state = typeof props.useStore === "function" ? props.useStore(function (value) { return value; }) : null;
|
|
2061
|
+
if (state === null || state === undefined || state.sessionId !== sessionId) return null;
|
|
2062
|
+
if (state.phase === "running") {
|
|
2063
|
+
return h("div", { className: "wsr-handoff-live" }, state.needsEnter === true ? t("handoff.pressEnter") : t("handoff.preparing"));
|
|
2081
2064
|
}
|
|
2082
|
-
|
|
2065
|
+
if (state.phase !== "ready") return null;
|
|
2066
|
+
var body = [
|
|
2067
|
+
h("div", { className: "wsr-handoff-head" }, t("handoff.found")),
|
|
2068
|
+
h("textarea", {
|
|
2069
|
+
className: "wsr-handoff-text",
|
|
2070
|
+
value: state.block,
|
|
2071
|
+
onChange: function (event) { props.actions.setBlock(event.target.value); },
|
|
2072
|
+
}),
|
|
2073
|
+
h("div", { className: "wsr-handoff-actions" },
|
|
2074
|
+
h("button", {
|
|
2075
|
+
type: "button",
|
|
2076
|
+
className: "wsr-btn",
|
|
2077
|
+
onClick: function () { carryHandoff(sessionId, state.block); },
|
|
2078
|
+
}, t("handoff.confirm")),
|
|
2079
|
+
h("button", {
|
|
2080
|
+
type: "button",
|
|
2081
|
+
className: "wsr-btn",
|
|
2082
|
+
onClick: function () {
|
|
2083
|
+
props.actions.setRunning(sessionId, false);
|
|
2084
|
+
handoffBaseline = 0;
|
|
2085
|
+
handoffTries = 0;
|
|
2086
|
+
handoffSession = sessionId;
|
|
2087
|
+
watchHandoff(sessionId);
|
|
2088
|
+
},
|
|
2089
|
+
}, t("handoff.more")),
|
|
2090
|
+
h("button", {
|
|
2091
|
+
type: "button",
|
|
2092
|
+
className: "wsr-btn",
|
|
2093
|
+
onClick: function () { resetHandoff(); },
|
|
2094
|
+
}, t("handoff.cancel")),
|
|
2095
|
+
),
|
|
2096
|
+
];
|
|
2097
|
+
return h.apply(null, ["div", { className: "wsr-handoff-card" }].concat(body));
|
|
2083
2098
|
}
|
|
2084
2099
|
|
|
2085
2100
|
/**
|
|
@@ -2097,7 +2112,7 @@
|
|
|
2097
2112
|
"data-wsr-handoff-action": "true",
|
|
2098
2113
|
onClick: function () {
|
|
2099
2114
|
var sessionId = props !== undefined && props !== null && typeof props.sessionId === "string" ? props.sessionId : null;
|
|
2100
|
-
if (sessionId !== null)
|
|
2115
|
+
if (sessionId !== null) startHandoff(sessionId);
|
|
2101
2116
|
},
|
|
2102
2117
|
}, typeof Icon === "function" ? h(Icon, { size: 16 }) : null);
|
|
2103
2118
|
return typeof Tooltip === "function" ? h(Tooltip, { label: label, side: "bottom" }, button) : button;
|
|
@@ -2817,6 +2832,35 @@
|
|
|
2817
2832
|
|
|
2818
2833
|
/* The statistics renderer is plain DOM, not a slot component: keep the
|
|
2819
2834
|
store handle so it can read the argument-mode preference live. */
|
|
2835
|
+
/* Handoff progress lives in a store so the turn card re-renders with it. */
|
|
2836
|
+
var handoff = clientStore.defineStore({
|
|
2837
|
+
init: function () {
|
|
2838
|
+
return { sessionId: "", phase: "idle", block: "", needsEnter: false };
|
|
2839
|
+
},
|
|
2840
|
+
actions: {
|
|
2841
|
+
setRunning: function (draft, sessionId, needsEnter) {
|
|
2842
|
+
draft.sessionId = sessionId;
|
|
2843
|
+
draft.phase = "running";
|
|
2844
|
+
draft.block = "";
|
|
2845
|
+
draft.needsEnter = needsEnter === true;
|
|
2846
|
+
},
|
|
2847
|
+
setReady: function (draft, block) {
|
|
2848
|
+
draft.phase = "ready";
|
|
2849
|
+
draft.block = typeof block === "string" ? block : "";
|
|
2850
|
+
},
|
|
2851
|
+
setBlock: function (draft, block) {
|
|
2852
|
+
draft.block = typeof block === "string" ? block : "";
|
|
2853
|
+
},
|
|
2854
|
+
setIdle: function (draft) {
|
|
2855
|
+
draft.phase = "idle";
|
|
2856
|
+
draft.block = "";
|
|
2857
|
+
draft.sessionId = "";
|
|
2858
|
+
draft.needsEnter = false;
|
|
2859
|
+
},
|
|
2860
|
+
},
|
|
2861
|
+
});
|
|
2862
|
+
handoffStore = handoff;
|
|
2863
|
+
|
|
2820
2864
|
prefsStore = prefs;
|
|
2821
2865
|
|
|
2822
2866
|
if (typeof MutationObserver === "function" && top() !== null) {
|
|
@@ -2907,6 +2951,17 @@
|
|
|
2907
2951
|
}, HandoffTurnAction);
|
|
2908
2952
|
});
|
|
2909
2953
|
|
|
2954
|
+
ctx.slots.inject("conversation.chat.turnTail", function () {
|
|
2955
|
+
return ctx.slots.register({
|
|
2956
|
+
name: "conversation.chat.turnTail",
|
|
2957
|
+
id: "ws-recency-handoff-card",
|
|
2958
|
+
order: 30,
|
|
2959
|
+
store: handoff,
|
|
2960
|
+
locale: NS,
|
|
2961
|
+
inject: function (sessionId) { return { sessionId: sessionId }; },
|
|
2962
|
+
}, HandoffTailCard);
|
|
2963
|
+
});
|
|
2964
|
+
|
|
2910
2965
|
ctx.slots.inject("sidebar.workspaces.session.menu.item", function () {
|
|
2911
2966
|
return ctx.slots.register({
|
|
2912
2967
|
name: "sidebar.workspaces.session.menu.item",
|
package/index.js
CHANGED
|
@@ -32,7 +32,7 @@ import { dirname, join } from "node:path";
|
|
|
32
32
|
export const name = "ws-recency";
|
|
33
33
|
|
|
34
34
|
/** Version marker reported by the health route. */
|
|
35
|
-
export const HOST_VERSION = "0.
|
|
35
|
+
export const HOST_VERSION = "0.20.0";
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
38
|
* Exact routes the client half calls. Registered on the bare web server, so they
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-ws-recency",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "Sidebar session management for DeepSeek Harness: workspace groups sorted by latest activity, stale history folded, a global pinned section, follow-up marks, session delete into a recoverable trash, archived sessions managed from that same trash panel, per-session token statistics with an argument/result split and an option to count tool arguments as the agent's writing, and moving a session to another workspace.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "chyxhtc",
|