dsh-ws-recency 0.23.0 → 0.23.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 CHANGED
@@ -133,7 +133,7 @@ DSH 原生的置顶只把会话顶到**它所属工作区分组的第一行**,
133
133
 
134
134
  细节想改不用在这里改——新会话的输入框里直接调更顺手。轮询最多 5 分钟自动收起。
135
135
 
136
- 自动发送是模拟 Enter:草稿面板渲染慢时会在 14 秒内重试;如果始终没送出去,文本仍留在输入框里,手动回车即可。
136
+ 两处发送都是模拟 Enter:当前会话里先写入、等 250ms 再按回车,并按需再补两次(共 3 次);草稿会话在 14 秒内重试。始终送不出去时文本仍留在输入框,手动回车即可。
137
137
 
138
138
  ## 设置
139
139
 
@@ -171,7 +171,7 @@ dsh plugin --profile <profile> add github:chyxhtc/dsh-ws-recency
171
171
  或固定版本的预构建包:
172
172
 
173
173
  ```powershell
174
- dsh plugin --profile <profile> add https://github.com/chyxhtc/dsh-ws-recency/releases/download/v0.23.0/dsh-ws-recency-0.23.0.tgz
174
+ dsh plugin --profile <profile> add https://github.com/chyxhtc/dsh-ws-recency/releases/download/v0.23.1/dsh-ws-recency-0.23.1.tgz
175
175
  ```
176
176
 
177
177
  装完把 `dsh-ws-recency` 加进 `~/.hypers-work/profiles/<profile>/package.json` 的 `dsh.profile.bundles`,重启应用。
package/client.js CHANGED
@@ -2034,42 +2034,60 @@
2034
2034
  window.setTimeout(step, 400);
2035
2035
  }
2036
2036
 
2037
- /** Write text into the composer and send it, if the editor is reachable. */
2038
- function sendToSession(text) {
2039
- if (typeof document === "undefined" || typeof text !== "string" || text === "") return false;
2040
- var seat = typeof document.querySelector === "function" ? document.querySelector("[data-composer-seat]") : null;
2041
- if (seat === null || seat === undefined) return false;
2042
- var editor = null;
2043
- try { editor = seat.querySelector('[contenteditable="true"]'); } catch (error) { editor = null; }
2044
- if (editor === null || editor === undefined) {
2045
- try { editor = seat.querySelector("textarea"); } catch (error) { editor = null; }
2046
- }
2047
- if (editor === null || editor === undefined) return false;
2037
+ /** Put text into an editor without losing the framework's own input event. */
2038
+ function writeIntoEditor(editor, text) {
2048
2039
  try {
2049
2040
  if (typeof editor.focus === "function") editor.focus();
2050
2041
  if (editor.tagName === "TEXTAREA" || editor.tagName === "INPUT") {
2051
2042
  editor.value = text;
2052
2043
  editor.dispatchEvent(new window.Event("input", { bubbles: true }));
2053
- } else {
2054
- var selection = typeof window.getSelection === "function" ? window.getSelection() : null;
2055
- if (selection !== null && typeof document.createRange === "function") {
2056
- var range = document.createRange();
2057
- range.selectNodeContents(editor);
2058
- range.collapse(false);
2059
- selection.removeAllRanges();
2060
- selection.addRange(range);
2061
- }
2062
- if (typeof document.execCommand !== "function" || !document.execCommand("insertText", false, text)) {
2063
- editor.textContent = text;
2064
- editor.dispatchEvent(new window.Event("input", { bubbles: true }));
2065
- }
2044
+ return true;
2045
+ }
2046
+ var selection = typeof window.getSelection === "function" ? window.getSelection() : null;
2047
+ if (selection !== null && typeof document.createRange === "function") {
2048
+ var range = document.createRange();
2049
+ range.selectNodeContents(editor);
2050
+ range.collapse(false);
2051
+ selection.removeAllRanges();
2052
+ selection.addRange(range);
2066
2053
  }
2067
- return pressEnter(editor);
2054
+ if (typeof document.execCommand === "function" && document.execCommand("insertText", false, text)) return true;
2055
+ editor.textContent = text;
2056
+ editor.dispatchEvent(new window.Event("input", { bubbles: true }));
2057
+ return true;
2068
2058
  } catch (error) {
2069
2059
  return false;
2070
2060
  }
2071
2061
  }
2072
2062
 
2063
+ /**
2064
+ * Press Enter until the text actually leaves the composer.
2065
+ *
2066
+ * The editor commits an inserted text and a synthetic Enter in different
2067
+ * frames: pressing Enter in the same tick as the insert is swallowed, which
2068
+ * is why the instruction used to sit in the box until the user pressed it.
2069
+ * Wait a beat, then press again only while the text is still there.
2070
+ */
2071
+ function armEnter(editor, attempt) {
2072
+ if (typeof window === "undefined") return;
2073
+ window.setTimeout(function () {
2074
+ if (composerEditor() !== editor) return;
2075
+ if (editorText(editor).trim() === "") return;
2076
+ pressEnter(editor);
2077
+ if (attempt < 2) armEnter(editor, attempt + 1);
2078
+ }, attempt === 0 ? 250 : 800);
2079
+ }
2080
+
2081
+ /** Write text into the composer and send it, if the editor is reachable. */
2082
+ function sendToSession(text) {
2083
+ if (typeof document === "undefined" || typeof text !== "string" || text === "") return false;
2084
+ var editor = composerEditor();
2085
+ if (editor === null || editor === undefined) return false;
2086
+ if (!writeIntoEditor(editor, text)) return false;
2087
+ armEnter(editor, 0);
2088
+ return true;
2089
+ }
2090
+
2073
2091
  function stopHandoffPolling() {
2074
2092
  if (handoffTimer !== null && typeof window.clearTimeout === "function") window.clearTimeout(handoffTimer);
2075
2093
  handoffTimer = null;
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.23.0";
35
+ export const HOST_VERSION = "0.23.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.23.0",
3
+ "version": "0.23.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",