dsh-ws-recency 0.19.3 → 0.20.1
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 -165
- 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.1/dsh-ws-recency-0.20.1.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}",
|
|
@@ -1870,17 +1874,55 @@
|
|
|
1870
1874
|
|
|
1871
1875
|
/* ------------------------------ handoff ------------------------------ */
|
|
1872
1876
|
|
|
1877
|
+
/* A plain observable, not a slot store: the turn card and the turn action are
|
|
1878
|
+
different slot instances, and a store handle would hand each its own copy. */
|
|
1879
|
+
var handoffState = { sessionId: "", phase: "idle", block: "", needsEnter: false };
|
|
1880
|
+
var handoffListeners = [];
|
|
1881
|
+
|
|
1882
|
+
function currentHandoffState() {
|
|
1883
|
+
return handoffState;
|
|
1884
|
+
}
|
|
1885
|
+
|
|
1886
|
+
function setHandoffState(patch) {
|
|
1887
|
+
handoffState = Object.assign({}, handoffState, patch);
|
|
1888
|
+
var listeners = handoffListeners.slice();
|
|
1889
|
+
for (var i = 0; i < listeners.length; i += 1) {
|
|
1890
|
+
try { listeners[i](handoffState); } catch (error) { /* a dead component */ }
|
|
1891
|
+
}
|
|
1892
|
+
}
|
|
1893
|
+
|
|
1894
|
+
function subscribeHandoff(listener) {
|
|
1895
|
+
handoffListeners.push(listener);
|
|
1896
|
+
return function () {
|
|
1897
|
+
var at = handoffListeners.indexOf(listener);
|
|
1898
|
+
if (at !== -1) handoffListeners.splice(at, 1);
|
|
1899
|
+
};
|
|
1900
|
+
}
|
|
1901
|
+
|
|
1873
1902
|
var handoffTimer = null;
|
|
1874
|
-
var
|
|
1903
|
+
var handoffBaseline = 0;
|
|
1904
|
+
var handoffTries = 0;
|
|
1905
|
+
var handoffSession = null;
|
|
1875
1906
|
|
|
1876
1907
|
/** The instruction the user sends to the current Session. */
|
|
1877
1908
|
function handoffInstruction() {
|
|
1878
1909
|
return t("handoff.instruction");
|
|
1879
1910
|
}
|
|
1880
1911
|
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1912
|
+
function handoffPost(payload) {
|
|
1913
|
+
return fetch("/ws-recency/handoff", {
|
|
1914
|
+
method: "POST",
|
|
1915
|
+
headers: { "content-type": "application/json" },
|
|
1916
|
+
body: JSON.stringify(payload),
|
|
1917
|
+
}).then(function (response) {
|
|
1918
|
+
return response.json().catch(function () { return null; });
|
|
1919
|
+
});
|
|
1920
|
+
}
|
|
1921
|
+
|
|
1922
|
+
/** Write text into the composer and send it, if the editor is reachable. */
|
|
1923
|
+
function sendInstruction(sessionId) {
|
|
1924
|
+
var text = handoffInstruction();
|
|
1925
|
+
if (typeof document === "undefined") return false;
|
|
1884
1926
|
var seat = typeof document.querySelector === "function" ? document.querySelector("[data-composer-seat]") : null;
|
|
1885
1927
|
if (seat === null || seat === undefined) return false;
|
|
1886
1928
|
var editor = null;
|
|
@@ -1894,38 +1936,56 @@
|
|
|
1894
1936
|
if (editor.tagName === "TEXTAREA" || editor.tagName === "INPUT") {
|
|
1895
1937
|
editor.value = text;
|
|
1896
1938
|
editor.dispatchEvent(new window.Event("input", { bubbles: true }));
|
|
1897
|
-
|
|
1939
|
+
} else {
|
|
1940
|
+
var selection = typeof window.getSelection === "function" ? window.getSelection() : null;
|
|
1941
|
+
if (selection !== null && typeof document.createRange === "function") {
|
|
1942
|
+
var range = document.createRange();
|
|
1943
|
+
range.selectNodeContents(editor);
|
|
1944
|
+
range.collapse(false);
|
|
1945
|
+
selection.removeAllRanges();
|
|
1946
|
+
selection.addRange(range);
|
|
1947
|
+
}
|
|
1948
|
+
if (typeof document.execCommand !== "function" || !document.execCommand("insertText", false, text)) {
|
|
1949
|
+
editor.textContent = text;
|
|
1950
|
+
editor.dispatchEvent(new window.Event("input", { bubbles: true }));
|
|
1951
|
+
}
|
|
1898
1952
|
}
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1953
|
+
/* Enter is the only submit path the composer exposes to a plugin. If it
|
|
1954
|
+
does not take, the card says so and the user presses it themselves. */
|
|
1955
|
+
var sent = false;
|
|
1956
|
+
try {
|
|
1957
|
+
var event = new window.KeyboardEvent("keydown", {
|
|
1958
|
+
key: "Enter",
|
|
1959
|
+
code: "Enter",
|
|
1960
|
+
keyCode: 13,
|
|
1961
|
+
which: 13,
|
|
1962
|
+
bubbles: true,
|
|
1963
|
+
cancelable: true,
|
|
1964
|
+
});
|
|
1965
|
+
editor.dispatchEvent(event);
|
|
1966
|
+
sent = true;
|
|
1967
|
+
} catch (error) {
|
|
1968
|
+
sent = false;
|
|
1906
1969
|
}
|
|
1907
|
-
|
|
1908
|
-
editor.textContent = text;
|
|
1909
|
-
editor.dispatchEvent(new window.Event("input", { bubbles: true }));
|
|
1910
|
-
return true;
|
|
1970
|
+
return sent;
|
|
1911
1971
|
} catch (error) {
|
|
1912
1972
|
return false;
|
|
1913
1973
|
}
|
|
1914
1974
|
}
|
|
1915
1975
|
|
|
1916
|
-
function
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1976
|
+
function stopHandoffPolling() {
|
|
1977
|
+
if (handoffTimer !== null && typeof window.clearTimeout === "function") window.clearTimeout(handoffTimer);
|
|
1978
|
+
handoffTimer = null;
|
|
1979
|
+
}
|
|
1980
|
+
|
|
1981
|
+
function resetHandoff() {
|
|
1982
|
+
stopHandoffPolling();
|
|
1983
|
+
handoffSession = null;
|
|
1984
|
+
handoffBaseline = 0;
|
|
1985
|
+
handoffTries = 0;
|
|
1986
|
+
setHandoffState({ sessionId: "", phase: "idle", block: "", needsEnter: false });
|
|
1926
1987
|
}
|
|
1927
1988
|
|
|
1928
|
-
/** Pull the fenced block out of an assistant reply. */
|
|
1929
1989
|
function handoffBlockOf(text) {
|
|
1930
1990
|
if (typeof text !== "string") return "";
|
|
1931
1991
|
var match = /```handoff[ \t]*\r?\n([\s\S]*?)```/i.exec(text);
|
|
@@ -1935,151 +1995,133 @@
|
|
|
1935
1995
|
return "";
|
|
1936
1996
|
}
|
|
1937
1997
|
|
|
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 */
|
|
1998
|
+
/** Start the watch: the next reply that carries a handoff block becomes the card. */
|
|
1999
|
+
function watchHandoff(sessionId) {
|
|
2000
|
+
handoffSession = sessionId;
|
|
2001
|
+
handoffTries = 0;
|
|
2002
|
+
stopHandoffPolling();
|
|
2003
|
+
if (typeof window === "undefined") return;
|
|
2004
|
+
function tick() {
|
|
2005
|
+
if (handoffSession !== sessionId) return;
|
|
2006
|
+
handoffTries += 1;
|
|
2007
|
+
handoffPost({ action: "tail", sessionId: sessionId }).then(function (answer) {
|
|
2008
|
+
if (handoffSession !== sessionId) return;
|
|
2009
|
+
if (answer !== null && answer.ok === true) {
|
|
2010
|
+
var replies = typeof answer.replies === "number" ? answer.replies : 0;
|
|
2011
|
+
if (replies > handoffBaseline) {
|
|
2012
|
+
var found = handoffBlockOf(answer.text);
|
|
2013
|
+
if (found !== "") {
|
|
2014
|
+
setHandoffState({ sessionId: sessionId, phase: "ready", block: found, needsEnter: false });
|
|
2015
|
+
return;
|
|
2016
|
+
}
|
|
2017
|
+
handoffBaseline = replies;
|
|
2029
2018
|
}
|
|
2030
2019
|
}
|
|
2031
|
-
|
|
2032
|
-
|
|
2020
|
+
if (handoffTries > 150) {
|
|
2021
|
+
setHandoffState({ sessionId: "", phase: "idle", block: "", needsEnter: false });
|
|
2022
|
+
handoffSession = null;
|
|
2023
|
+
return;
|
|
2024
|
+
}
|
|
2025
|
+
handoffTimer = window.setTimeout(tick, 2000);
|
|
2026
|
+
}).catch(function () {
|
|
2027
|
+
handoffTimer = window.setTimeout(tick, 4000);
|
|
2033
2028
|
});
|
|
2029
|
+
}
|
|
2030
|
+
/* The baseline is the reply count before the instruction is answered. */
|
|
2031
|
+
handoffPost({ action: "tail", sessionId: sessionId }).then(function (answer) {
|
|
2032
|
+
if (handoffSession !== sessionId) return;
|
|
2033
|
+
handoffBaseline = answer !== null && answer.ok === true && typeof answer.replies === "number" ? answer.replies : 0;
|
|
2034
|
+
handoffTimer = window.setTimeout(tick, 1500);
|
|
2035
|
+
}).catch(function () {
|
|
2036
|
+
handoffTimer = window.setTimeout(tick, 3000);
|
|
2034
2037
|
});
|
|
2035
|
-
|
|
2036
|
-
body.appendChild(actions);
|
|
2038
|
+
}
|
|
2037
2039
|
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
+
/** The turn action: send the instruction and wait for the block. */
|
|
2041
|
+
function startHandoff(sessionId) {
|
|
2042
|
+
if (typeof sessionId !== "string" || sessionId === "") return;
|
|
2043
|
+
var sent = sendInstruction(sessionId);
|
|
2044
|
+
setHandoffState({ sessionId: sessionId, phase: "running", block: "", needsEnter: sent !== true });
|
|
2045
|
+
watchHandoff(sessionId);
|
|
2046
|
+
}
|
|
2040
2047
|
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2048
|
+
/** The card carries it over: open a fresh Session in the same workspace. */
|
|
2049
|
+
function carryHandoff(sessionId, block) {
|
|
2050
|
+
var text = typeof block === "string" ? block.trim() : "";
|
|
2051
|
+
if (text === "") return;
|
|
2052
|
+
handoffPost({ action: "save", sessionId: sessionId, text: text }).catch(function () { return null; }).then(function () {
|
|
2053
|
+
var owner = workspaceOfSession(sessionId);
|
|
2054
|
+
var workspaceId = owner === null ? undefined : owner.workspaceId;
|
|
2055
|
+
var service = data.service;
|
|
2056
|
+
var prompt = t("handoff.preamble") + "\n\n" + text;
|
|
2057
|
+
if (service !== null && service !== undefined && typeof service.startSession === "function") {
|
|
2058
|
+
try {
|
|
2059
|
+
service.startSession(workspaceId, { prompt: prompt, whenDraftExists: "replace" });
|
|
2060
|
+
resetHandoff();
|
|
2061
|
+
return;
|
|
2062
|
+
} catch (error) {
|
|
2063
|
+
/* fall through */
|
|
2064
|
+
}
|
|
2065
|
+
}
|
|
2066
|
+
try {
|
|
2067
|
+
if (navigator !== undefined && navigator.clipboard !== undefined) navigator.clipboard.writeText(prompt);
|
|
2068
|
+
} catch (error) {
|
|
2069
|
+
/* clipboard unavailable */
|
|
2070
|
+
}
|
|
2071
|
+
resetHandoff();
|
|
2072
|
+
});
|
|
2073
|
+
}
|
|
2047
2074
|
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
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);
|
|
2075
|
+
/**
|
|
2076
|
+
* The handoff card, rendered in the turn tail: it appears only for the
|
|
2077
|
+
* Session that started the flow, and only once a block has been produced.
|
|
2078
|
+
*/
|
|
2079
|
+
function HandoffTailCard(props) {
|
|
2080
|
+
var sessionId = props !== undefined && props !== null && typeof props.sessionId === "string" ? props.sessionId : "";
|
|
2081
|
+
var pair = react.useState(currentHandoffState());
|
|
2082
|
+
var live = pair[0];
|
|
2083
|
+
var setLive = pair[1];
|
|
2084
|
+
react.useEffect(function () {
|
|
2085
|
+
return subscribeHandoff(function (next) { setLive(next); });
|
|
2086
|
+
}, []);
|
|
2087
|
+
var state = live;
|
|
2088
|
+
if (state === null || state === undefined || state.sessionId !== sessionId) return null;
|
|
2089
|
+
if (state.phase === "running") {
|
|
2090
|
+
return h("div", { className: "wsr-handoff-live" }, state.needsEnter === true ? t("handoff.pressEnter") : t("handoff.preparing"));
|
|
2081
2091
|
}
|
|
2082
|
-
|
|
2092
|
+
if (state.phase !== "ready") return null;
|
|
2093
|
+
var body = [
|
|
2094
|
+
h("div", { className: "wsr-handoff-head" }, t("handoff.found")),
|
|
2095
|
+
h("textarea", {
|
|
2096
|
+
className: "wsr-handoff-text",
|
|
2097
|
+
value: state.block,
|
|
2098
|
+
onChange: function (event) { setHandoffState({ block: event.target.value }); },
|
|
2099
|
+
}),
|
|
2100
|
+
h("div", { className: "wsr-handoff-actions" },
|
|
2101
|
+
h("button", {
|
|
2102
|
+
type: "button",
|
|
2103
|
+
className: "wsr-btn",
|
|
2104
|
+
onClick: function () { carryHandoff(sessionId, state.block); },
|
|
2105
|
+
}, t("handoff.confirm")),
|
|
2106
|
+
h("button", {
|
|
2107
|
+
type: "button",
|
|
2108
|
+
className: "wsr-btn",
|
|
2109
|
+
onClick: function () {
|
|
2110
|
+
setHandoffState({ sessionId: sessionId, phase: "running", block: "", needsEnter: false });
|
|
2111
|
+
handoffBaseline = 0;
|
|
2112
|
+
handoffTries = 0;
|
|
2113
|
+
handoffSession = sessionId;
|
|
2114
|
+
watchHandoff(sessionId);
|
|
2115
|
+
},
|
|
2116
|
+
}, t("handoff.more")),
|
|
2117
|
+
h("button", {
|
|
2118
|
+
type: "button",
|
|
2119
|
+
className: "wsr-btn",
|
|
2120
|
+
onClick: function () { resetHandoff(); },
|
|
2121
|
+
}, t("handoff.cancel")),
|
|
2122
|
+
),
|
|
2123
|
+
];
|
|
2124
|
+
return h.apply(null, ["div", { className: "wsr-handoff-card" }].concat(body));
|
|
2083
2125
|
}
|
|
2084
2126
|
|
|
2085
2127
|
/**
|
|
@@ -2097,7 +2139,7 @@
|
|
|
2097
2139
|
"data-wsr-handoff-action": "true",
|
|
2098
2140
|
onClick: function () {
|
|
2099
2141
|
var sessionId = props !== undefined && props !== null && typeof props.sessionId === "string" ? props.sessionId : null;
|
|
2100
|
-
if (sessionId !== null)
|
|
2142
|
+
if (sessionId !== null) startHandoff(sessionId);
|
|
2101
2143
|
},
|
|
2102
2144
|
}, typeof Icon === "function" ? h(Icon, { size: 16 }) : null);
|
|
2103
2145
|
return typeof Tooltip === "function" ? h(Tooltip, { label: label, side: "bottom" }, button) : button;
|
|
@@ -2817,6 +2859,7 @@
|
|
|
2817
2859
|
|
|
2818
2860
|
/* The statistics renderer is plain DOM, not a slot component: keep the
|
|
2819
2861
|
store handle so it can read the argument-mode preference live. */
|
|
2862
|
+
|
|
2820
2863
|
prefsStore = prefs;
|
|
2821
2864
|
|
|
2822
2865
|
if (typeof MutationObserver === "function" && top() !== null) {
|
|
@@ -2907,6 +2950,16 @@
|
|
|
2907
2950
|
}, HandoffTurnAction);
|
|
2908
2951
|
});
|
|
2909
2952
|
|
|
2953
|
+
ctx.slots.inject("conversation.chat.turnTail", function () {
|
|
2954
|
+
return ctx.slots.register({
|
|
2955
|
+
name: "conversation.chat.turnTail",
|
|
2956
|
+
id: "ws-recency-handoff-card",
|
|
2957
|
+
order: 30,
|
|
2958
|
+
locale: NS,
|
|
2959
|
+
inject: function (sessionId) { return { sessionId: sessionId }; },
|
|
2960
|
+
}, HandoffTailCard);
|
|
2961
|
+
});
|
|
2962
|
+
|
|
2910
2963
|
ctx.slots.inject("sidebar.workspaces.session.menu.item", function () {
|
|
2911
2964
|
return ctx.slots.register({
|
|
2912
2965
|
name: "sidebar.workspaces.session.menu.item",
|
|
@@ -2975,6 +3028,9 @@
|
|
|
2975
3028
|
schedule();
|
|
2976
3029
|
}
|
|
2977
3030
|
|
|
3031
|
+
/* Test hook: the card state is a module observable, invisible from outside. */
|
|
3032
|
+
exports.__handoff = { current: currentHandoffState, set: setHandoffState };
|
|
3033
|
+
|
|
2978
3034
|
exports.name = "dsh-ws-recency";
|
|
2979
3035
|
exports.inject = inject;
|
|
2980
3036
|
exports.apply = apply_;
|
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.1";
|
|
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.1",
|
|
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",
|