dsh-composer-send-key 1.0.0 → 1.1.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 CHANGED
@@ -1,16 +1,21 @@
1
1
  # Composer send key
2
2
 
3
- Switch the DeepSeek Harness message box send shortcut between two modes:
3
+ [English](README.md) | [中文](README.zh.md)
4
4
 
5
- | Mode | Enter | Shift+Enter |
5
+ Choose how the DeepSeek Harness message composer sends.
6
+
7
+ | Mode | Enter | Send with |
6
8
  |---|---|---|
7
- | Default | Send | New line |
8
- | Edit-friendly | New line | Send |
9
+ | Default | Sends | `Enter` |
10
+ | Edit-friendly | Inserts a new line | `Shift + Enter` or `Ctrl + Enter` |
9
11
 
10
12
  ## Install
11
13
 
12
- In DeepSeek Harness, open **Plugins → Add plugin** and install
13
- `dsh-composer-send-key`. You can also install it from the command line:
14
+ 1. Open **Plugins** in DeepSeek Harness.
15
+ 2. Choose **Add plugin**.
16
+ 3. Enter `dsh-composer-send-key` and confirm.
17
+
18
+ The package installs from npm, so no local path is needed. From a terminal:
14
19
 
15
20
  ```sh
16
21
  dsh plugin --profile <profile> add dsh-composer-send-key
@@ -18,44 +23,41 @@ dsh plugin --profile <profile> add dsh-composer-send-key
18
23
 
19
24
  ## Usage
20
25
 
21
- Open **Settings → General → Send shortcut** and pick a mode. The change
22
- applies immediately (no restart) and persists in your profile's settings
23
- document through the volatile `mode` field of the `composer-send-key` entry.
26
+ Open **Settings → Send shortcut**. The page has two choices:
24
27
 
25
- You can also set it directly in the profile patch:
28
+ - **Default** — `Enter` sends and `Shift + Enter` starts a new line.
29
+ - **Edit-friendly** — `Enter` starts a new line. The shortcut row underneath chooses whether `Shift + Enter` or `Ctrl + Enter` sends.
30
+
31
+ The change applies immediately and is stored in your profile. You can also set it in the profile patch:
26
32
 
27
33
  ```yaml
28
34
  - id: composer-send-key
29
35
  name: 'dsh-composer-send-key'
30
36
  config:
31
37
  mode: edit-friendly # or: default
38
+ combo: shift # or: ctrl
32
39
  ```
33
40
 
34
- ## Behavior notes
35
-
36
- - Ctrl/⌘+Enter keeps the built-in accelerated delivery; other modifiers are
37
- never rewritten.
38
- - The busy-state Composer Enter preference (queue/steer) keeps working in
39
- both modes.
40
- - In edit-friendly mode the two keys swap completely: with the suggestion
41
- menu open, Enter inserts a newline and Shift+Enter confirms the highlighted
42
- item (exactly the other gesture's stock behavior).
43
- - IME composition is left untouched: a composition-closing Enter never
44
- submits or inserts a stray newline.
45
- - The Send button, the shortcuts reference page and its fixed Enter bindings
46
- keep their shipped appearance and wording.
41
+ ## Behavior
42
+
43
+ - Scope is the message composer only. The sidebar terminal, search fields and other inputs keep their own `Enter` behavior.
44
+ - **Default** leaves the shipped keyboard handling untouched.
45
+ - **Edit-friendly** lets exactly one shortcut send: the chosen `Shift + Enter` or `Ctrl + Enter`. Every other Enter chord inserts a new line, including `⌘ + Enter` and the shipped `Ctrl/⌘ + Enter` accelerated delivery.
46
+ - With the command or suggestion menu open, the chosen shortcut confirms the highlighted item and the other chords insert a new line.
47
+ - IME composition is untouched: a composition-closing `Enter` never submits or inserts a stray newline.
48
+ - The busy-composer queue/steer preference, the Send button and the shortcuts reference keep their shipped behavior.
47
49
  - Disabling or removing the plugin restores the default behavior.
48
50
 
49
- ## How it works
51
+ ## Development
52
+
53
+ The project is TypeScript. Host and Client sources live in `src/` and build to `lib/`:
54
+
55
+ ```sh
56
+ pnpm install
57
+ pnpm build # typecheck, then bundle lib/index.js and lib/client.js
58
+ pnpm typecheck
59
+ ```
50
60
 
51
- The shipped composer hardcodes Enter/Shift+Enter in its Lexical keymap and
52
- exposes no extension point for it. In edit-friendly mode this plugin swaps
53
- the `shiftKey` modifier of the original keydown event in the capture phase,
54
- before the composer's own handler runs, so every shipped guard (busy state,
55
- command-menu arbitration, IME window, held-key repeat) is preserved. In
56
- default mode the listener does nothing.
61
+ `src/index.ts` is the Host half (the two volatile preferences). `src/client/` holds the Settings page, the dictionaries and the composer-only key guard. The Client bundle is a single self-contained file that registers through the page's module loader.
57
62
 
58
- Because this relies on the composer's internal DOM (`[data-composer-card]`)
59
- and keyboard handling, re-verify the plugin after a DeepSeek Harness
60
- upgrade; if the internals change, the plugin falls back to the stock
61
- behavior rather than breaking the input.
63
+ This plugin relies on the composer's internal DOM (`[data-composer-card]`) and keyboard handling. Re-check it after a DeepSeek Harness upgrade; if the internals change, the plugin falls back to the shipped behavior instead of breaking input.
package/README.zh.md ADDED
@@ -0,0 +1,63 @@
1
+ # 发送快捷键
2
+
3
+ [English](README.md) | [中文](README.zh.md)
4
+
5
+ 选择 DeepSeek Harness 消息框的发送方式。
6
+
7
+ | 模式 | Enter | 发送键 |
8
+ |---|---|---|
9
+ | 默认 | 发送 | `Enter` |
10
+ | 编辑友好 | 换行 | `Shift + Enter` 或 `Ctrl + Enter` |
11
+
12
+ ## 安装
13
+
14
+ 1. 在 DeepSeek Harness 中打开 **插件**。
15
+ 2. 选择 **安装插件**。
16
+ 3. 输入 `dsh-composer-send-key` 并确认。
17
+
18
+ 包直接从 npm 安装,不需要本地路径。也可以在终端执行:
19
+
20
+ ```sh
21
+ dsh plugin --profile <profile> add dsh-composer-send-key
22
+ ```
23
+
24
+ ## 使用
25
+
26
+ 打开 **设置 → 发送快捷键**。页面只有两项:
27
+
28
+ - **默认** — `Enter` 发送,`Shift + Enter` 换行。
29
+ - **编辑友好模式** — `Enter` 换行;下方选择用 `Shift + Enter` 还是 `Ctrl + Enter` 发送。
30
+
31
+ 修改立即生效,并保存在当前配置档案中。你也可以直接写在 profile patch 里:
32
+
33
+ ```yaml
34
+ - id: composer-send-key
35
+ name: 'dsh-composer-send-key'
36
+ config:
37
+ mode: edit-friendly # 或 default
38
+ combo: shift # 或 ctrl
39
+ ```
40
+
41
+ ## 行为
42
+
43
+ - 只作用于消息发送框。右侧栏终端、搜索框和其他输入框保持各自的 `Enter` 行为。
44
+ - **默认模式**不改动内置键盘处理。
45
+ - **编辑友好模式**下只有一个快捷键会发送:你选择的 `Shift + Enter` 或 `Ctrl + Enter`。其余 Enter 组合一律换行,包括 `⌘ + Enter` 以及内置的 `Ctrl/⌘ + Enter` 加速发送。
46
+ - 命令/候选菜单打开时,选中的快捷键确认高亮项,其余组合换行。
47
+ - 输入法合成不受影响:用于结束候选的 `Enter` 不会发送,也不会多插入换行。
48
+ - 运行中消息框的排队/插话偏好、发送按钮和快捷键参考页保持原样。
49
+ - 停用或移除插件后恢复默认行为。
50
+
51
+ ## 开发
52
+
53
+ 项目使用 TypeScript。Host 与 Client 源码在 `src/`,构建产物在 `lib/`:
54
+
55
+ ```sh
56
+ pnpm install
57
+ pnpm build # 先类型检查,再打包 lib/index.js 和 lib/client.js
58
+ pnpm typecheck
59
+ ```
60
+
61
+ `src/index.ts` 是 Host 侧(两个 volatile 配置项)。`src/client/` 包含设置页、文案和仅作用于消息框的按键守卫。Client 打包为单个自包含文件,通过页面模块加载器注册。
62
+
63
+ 本插件依赖消息框内部 DOM(`[data-composer-card]`)与键盘处理。升级 DeepSeek Harness 后请重新验证;若内部结构变化,插件会退回内置行为,而不是破坏输入。
package/cordis.patch.yml CHANGED
@@ -3,3 +3,4 @@
3
3
  name: 'dsh-composer-send-key'
4
4
  config:
5
5
  mode: default
6
+ combo: shift
package/lib/client.js ADDED
@@ -0,0 +1,447 @@
1
+ "use strict";
2
+ (() => {
3
+ // src/constants.ts
4
+ var PLUGIN_ID = "dsh-composer-send-key";
5
+ var LOCALE_NS = "composer-send-key";
6
+ var MODE_FIELD = "mode";
7
+ var COMBO_FIELD = "combo";
8
+ var DEFAULT_MODE = "default";
9
+ var EDIT_FRIENDLY_MODE = "edit-friendly";
10
+ var DEFAULT_COMBO = "shift";
11
+ var CTRL_COMBO = "ctrl";
12
+ var SETTINGS_SECTION_ID = "composer-send-key";
13
+ var SETTINGS_SECTION_ORDER = 5;
14
+ var COMPOSER_CARD_SELECTOR = "[data-composer-card]";
15
+ var NON_COMPOSER_SELECTOR = ".xterm, [data-sidebar-terminal], input, textarea, select";
16
+ var MODE_RADIO_NAME = "dsh-composer-send-key-mode";
17
+ var COMBO_RADIO_NAME = "dsh-composer-send-key-combo";
18
+ var COMPOSITION_GUARD_MS = 10;
19
+
20
+ // src/settings.ts
21
+ function readSettings(value) {
22
+ const record = typeof value === "object" && value !== null ? value : {};
23
+ return {
24
+ mode: record.mode === EDIT_FRIENDLY_MODE ? EDIT_FRIENDLY_MODE : DEFAULT_MODE,
25
+ combo: record.combo === CTRL_COMBO ? CTRL_COMBO : DEFAULT_COMBO
26
+ };
27
+ }
28
+
29
+ // src/keys.ts
30
+ var NEWLINE_REWRITE = { shiftKey: true, ctrlKey: false, metaKey: false };
31
+ function resolveEnterRewrite(facts, mode, combo) {
32
+ if (mode !== EDIT_FRIENDLY_MODE) return null;
33
+ if (facts.key !== "Enter" || facts.composing || facts.altGraph || facts.altKey) return null;
34
+ const isSendChord = combo === CTRL_COMBO ? facts.ctrlKey && !facts.shiftKey && !facts.metaKey : facts.shiftKey && !facts.ctrlKey && !facts.metaKey;
35
+ if (isSendChord) return combo === CTRL_COMBO ? { ctrlKey: false } : { shiftKey: false };
36
+ if (facts.ctrlKey || facts.metaKey) return { ...NEWLINE_REWRITE };
37
+ if (facts.shiftKey) return null;
38
+ return { shiftKey: true };
39
+ }
40
+
41
+ // src/client/dom.ts
42
+ function isComposerEditable(target) {
43
+ if (!(target instanceof HTMLElement)) return false;
44
+ if (!target.isContentEditable) return false;
45
+ if (target.closest(NON_COMPOSER_SELECTOR) !== null) return false;
46
+ return target.closest(COMPOSER_CARD_SELECTOR) !== null;
47
+ }
48
+
49
+ // src/client/keyboard.ts
50
+ function keyFacts(event, composingRecently) {
51
+ return {
52
+ key: event.key,
53
+ shiftKey: event.shiftKey,
54
+ ctrlKey: event.ctrlKey,
55
+ metaKey: event.metaKey,
56
+ altKey: event.altKey,
57
+ altGraph: typeof event.getModifierState === "function" && event.getModifierState("AltGraph"),
58
+ composing: event.isComposing || event.keyCode === 229 || composingRecently
59
+ };
60
+ }
61
+ function setModifier(event, modifier, value, warned) {
62
+ try {
63
+ Object.defineProperty(event, modifier, {
64
+ configurable: true,
65
+ enumerable: true,
66
+ get: () => value
67
+ });
68
+ } catch {
69
+ if (warned.has(modifier)) return;
70
+ warned.add(modifier);
71
+ console.warn(`[composer-send-key] ${modifier} is not configurable; edit-friendly mode is inactive for this event`);
72
+ }
73
+ }
74
+ function installComposerKeyGuard(read) {
75
+ let composing = false;
76
+ let composingUntil = 0;
77
+ const warned = /* @__PURE__ */ new Set();
78
+ const recentlyComposing = () => composing || Date.now() < composingUntil;
79
+ const onCompositionStart = (event) => {
80
+ if (isComposerEditable(event.target)) composing = true;
81
+ };
82
+ const onCompositionEnd = () => {
83
+ if (!composing) return;
84
+ composing = false;
85
+ composingUntil = Date.now() + COMPOSITION_GUARD_MS;
86
+ };
87
+ const onKeyDown = (event) => {
88
+ if (!isComposerEditable(event.target)) return;
89
+ const settings = read();
90
+ const rewrite = resolveEnterRewrite(keyFacts(event, recentlyComposing()), settings.mode, settings.combo);
91
+ if (rewrite === null) return;
92
+ if (rewrite.shiftKey !== void 0) setModifier(event, "shiftKey", rewrite.shiftKey, warned);
93
+ if (rewrite.ctrlKey !== void 0) setModifier(event, "ctrlKey", rewrite.ctrlKey, warned);
94
+ if (rewrite.metaKey !== void 0) setModifier(event, "metaKey", rewrite.metaKey, warned);
95
+ };
96
+ const options = { capture: true };
97
+ document.addEventListener("keydown", onKeyDown, options);
98
+ document.addEventListener("compositionstart", onCompositionStart, options);
99
+ document.addEventListener("compositionend", onCompositionEnd, options);
100
+ return () => {
101
+ document.removeEventListener("keydown", onKeyDown, options);
102
+ document.removeEventListener("compositionstart", onCompositionStart, options);
103
+ document.removeEventListener("compositionend", onCompositionEnd, options);
104
+ };
105
+ }
106
+
107
+ // src/client/locales.ts
108
+ var en = {
109
+ nav: "Send shortcut",
110
+ "mode.default": "Default",
111
+ "mode.editFriendly": "Edit-friendly",
112
+ "mode.label": "Send mode",
113
+ "combo.label": "Shortcut key",
114
+ "action.send": "Sends",
115
+ "action.newline": "New line",
116
+ saveFailed: "Could not save; the change applies to this session only."
117
+ };
118
+ var zh = {
119
+ nav: "\u53D1\u9001\u5FEB\u6377\u952E",
120
+ "mode.default": "\u9ED8\u8BA4",
121
+ "mode.editFriendly": "\u7F16\u8F91\u53CB\u597D\u6A21\u5F0F",
122
+ "mode.label": "\u53D1\u9001\u6A21\u5F0F",
123
+ "combo.label": "\u7EC4\u5408\u952E",
124
+ "action.send": "\u53D1\u9001",
125
+ "action.newline": "\u6362\u884C",
126
+ saveFailed: "\u4FDD\u5B58\u5931\u8D25\uFF0C\u672C\u6B21\u4FEE\u6539\u4EC5\u5728\u5F53\u524D\u4F1A\u8BDD\u751F\u6548\u3002"
127
+ };
128
+ var DICTIONARIES = { en, zh };
129
+
130
+ // src/client/section-icon.ts
131
+ function createSectionIcon(h) {
132
+ return function SectionIcon({ size, active }) {
133
+ const stroke = {
134
+ fill: "none",
135
+ stroke: "currentColor",
136
+ strokeWidth: active ? 1.75 : 1.5,
137
+ strokeLinecap: "round",
138
+ strokeLinejoin: "round"
139
+ };
140
+ return h(
141
+ "svg",
142
+ {
143
+ "data-el-id": "csk-icon",
144
+ width: size,
145
+ height: size,
146
+ viewBox: "0 0 16 16",
147
+ "aria-hidden": "true",
148
+ focusable: "false"
149
+ },
150
+ h("path", {
151
+ "data-el-id": "csk-icon-corner",
152
+ d: "M13 3v5a3 3 0 0 1-3 3H4",
153
+ ...stroke
154
+ }),
155
+ h("path", {
156
+ "data-el-id": "csk-icon-arrow",
157
+ d: "M7 8 4 11l3 3",
158
+ ...stroke
159
+ })
160
+ );
161
+ };
162
+ }
163
+
164
+ // src/client/settings-page.ts
165
+ function keyCap(h, id, text) {
166
+ return h("kbd", { className: "csk-kbd", "data-el-id": id }, text);
167
+ }
168
+ function action(h, id, text) {
169
+ return h("span", { className: "csk-action", "data-el-id": id }, text);
170
+ }
171
+ function keyLine({ h, t, prefix, sendKey, newlineKey }) {
172
+ return h(
173
+ "span",
174
+ { className: "csk-keys", "data-el-id": `${prefix}-keys` },
175
+ h(
176
+ "span",
177
+ { className: "csk-pair", "data-el-id": `${prefix}-pair-send` },
178
+ keyCap(h, `${prefix}-kbd-send`, sendKey),
179
+ action(h, `${prefix}-action-send`, t("action.send"))
180
+ ),
181
+ h(
182
+ "span",
183
+ { className: "csk-pair", "data-el-id": `${prefix}-pair-newline` },
184
+ keyCap(h, `${prefix}-kbd-newline`, newlineKey),
185
+ action(h, `${prefix}-action-newline`, t("action.newline"))
186
+ )
187
+ );
188
+ }
189
+ function renderModeOption({ h, id, title, checked, keys, onSelect }) {
190
+ return h(
191
+ "label",
192
+ { className: "csk-option", "data-el-id": `csk-option-${id}` },
193
+ h("input", {
194
+ className: "csk-radio",
195
+ "data-el-id": `csk-radio-${id}`,
196
+ type: "radio",
197
+ name: MODE_RADIO_NAME,
198
+ value: id,
199
+ checked,
200
+ onChange: onSelect
201
+ }),
202
+ h("span", { className: "csk-title", "data-el-id": `csk-title-${id}` }, title),
203
+ keys
204
+ );
205
+ }
206
+ function renderComboChip({ h, id, label, checked, onSelect }) {
207
+ return h(
208
+ "label",
209
+ {
210
+ className: checked ? "csk-chip csk-chip-selected" : "csk-chip",
211
+ "data-el-id": `csk-combo-${id}`
212
+ },
213
+ h("input", {
214
+ className: "csk-radio",
215
+ "data-el-id": `csk-combo-radio-${id}`,
216
+ type: "radio",
217
+ name: COMBO_RADIO_NAME,
218
+ value: id,
219
+ checked,
220
+ onChange: onSelect
221
+ }),
222
+ keyCap(h, `csk-combo-kbd-${id}`, label)
223
+ );
224
+ }
225
+ function createSettingsPage(h) {
226
+ return function SettingsPage(props) {
227
+ const { useMode, useCombo, useSaveError, setMode, setCombo, t } = props;
228
+ const mode = useMode((value) => value);
229
+ const combo = useCombo((value) => value);
230
+ const saveError = useSaveError((value) => value);
231
+ const editFriendly = mode === EDIT_FRIENDLY_MODE;
232
+ const comboLabel = combo === CTRL_COMBO ? "Ctrl + Enter" : "Shift + Enter";
233
+ return h(
234
+ "section",
235
+ { className: "csk-section", "data-el-id": "csk-section" },
236
+ h(
237
+ "div",
238
+ { className: "csk-card", "data-el-id": "csk-card" },
239
+ h(
240
+ "div",
241
+ {
242
+ className: "csk-options",
243
+ "data-el-id": "csk-options",
244
+ role: "radiogroup",
245
+ "aria-label": t("mode.label")
246
+ },
247
+ renderModeOption({
248
+ h,
249
+ id: "default",
250
+ title: t("mode.default"),
251
+ checked: mode === DEFAULT_MODE,
252
+ keys: keyLine({
253
+ h,
254
+ t,
255
+ prefix: "csk-default",
256
+ sendKey: "Enter",
257
+ newlineKey: "Shift + Enter"
258
+ }),
259
+ onSelect: () => {
260
+ setMode(DEFAULT_MODE);
261
+ }
262
+ }),
263
+ renderModeOption({
264
+ h,
265
+ id: "edit-friendly",
266
+ title: t("mode.editFriendly"),
267
+ checked: editFriendly,
268
+ keys: keyLine({
269
+ h,
270
+ t,
271
+ prefix: "csk-edit",
272
+ sendKey: comboLabel,
273
+ newlineKey: "Enter"
274
+ }),
275
+ onSelect: () => {
276
+ setMode(EDIT_FRIENDLY_MODE);
277
+ }
278
+ })
279
+ ),
280
+ editFriendly ? h(
281
+ "div",
282
+ {
283
+ className: "csk-combo",
284
+ "data-el-id": "csk-combo",
285
+ role: "radiogroup",
286
+ "aria-label": t("combo.label")
287
+ },
288
+ renderComboChip({
289
+ h,
290
+ id: DEFAULT_COMBO,
291
+ label: "Shift + Enter",
292
+ checked: combo === DEFAULT_COMBO,
293
+ onSelect: () => {
294
+ setCombo(DEFAULT_COMBO);
295
+ }
296
+ }),
297
+ renderComboChip({
298
+ h,
299
+ id: CTRL_COMBO,
300
+ label: "Ctrl + Enter",
301
+ checked: combo === CTRL_COMBO,
302
+ onSelect: () => {
303
+ setCombo(CTRL_COMBO);
304
+ }
305
+ })
306
+ ) : null
307
+ ),
308
+ saveError === "" ? null : h("p", { className: "csk-error", "data-el-id": "csk-error", role: "status" }, saveError)
309
+ );
310
+ };
311
+ }
312
+
313
+ // src/client/store.ts
314
+ function createStore(initial) {
315
+ let value = initial;
316
+ const listeners = /* @__PURE__ */ new Set();
317
+ return {
318
+ getSnapshot: () => value,
319
+ subscribe: (listener) => {
320
+ listeners.add(listener);
321
+ return () => {
322
+ listeners.delete(listener);
323
+ };
324
+ },
325
+ set: (next) => {
326
+ if (Object.is(next, value)) return;
327
+ value = next;
328
+ for (const listener of [...listeners]) listener();
329
+ }
330
+ };
331
+ }
332
+
333
+ // src/client/styles.ts
334
+ var CSS = `
335
+ .csk-section{display:flex;flex-direction:column;gap:12px;max-width:720px;font-size:14px;line-height:22px;color:var(--dsw-alias-label-primary);}
336
+ .csk-card{display:flex;flex-direction:column;overflow:hidden;border:.5px solid var(--dsw-alias-settings-card-stroke);border-radius:var(--dsw-radius-xl);background:var(--dsw-alias-settings-card-fill);}
337
+ .csk-options{display:flex;flex-direction:column;min-width:0;}
338
+ .csk-option{display:flex;align-items:center;flex-wrap:wrap;gap:12px;padding:12px 14px;cursor:pointer;}
339
+ .csk-option+.csk-option{border-top:.5px solid var(--dsw-alias-border-l2);}
340
+ @media (hover:hover){.csk-option:hover{background:var(--dsw-alias-interactive-bg-hover);}}
341
+ .csk-radio{flex:none;width:16px;height:16px;margin:0;accent-color:var(--dsw-alias-brand-primary);cursor:inherit;}
342
+ .csk-radio:focus-visible{outline:var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:2px;}
343
+ .csk-title{font-weight:500;}
344
+ .csk-keys{display:flex;flex-wrap:wrap;align-items:center;gap:10px;margin-left:auto;color:var(--dsw-alias-label-secondary);font-size:12px;line-height:18px;}
345
+ .csk-pair{display:inline-flex;align-items:center;gap:6px;white-space:nowrap;}
346
+ .csk-kbd{font-family:var(--ds-font-family-code);font-size:11px;line-height:16px;padding:1px 5px;border:.5px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-xs);background:var(--dsw-alias-bg-module-platform);color:var(--dsw-alias-label-primary);}
347
+ .csk-combo{display:flex;flex-wrap:wrap;gap:8px;padding:12px 14px 12px 42px;border-top:.5px solid var(--dsw-alias-border-l2);}
348
+ .csk-chip{display:inline-flex;align-items:center;gap:6px;padding:6px 10px;border:.5px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-md);cursor:pointer;}
349
+ @media (hover:hover){.csk-chip:hover{background:var(--dsw-alias-interactive-bg-hover);}}
350
+ .csk-chip-selected{border-color:var(--dsw-alias-border-l3);background:var(--dsw-alias-interactive-bg-hover);}
351
+ .csk-chip .csk-radio{width:14px;height:14px;}
352
+ .csk-error{margin:0;font-size:12px;line-height:18px;color:var(--dsw-alias-state-error-primary);}
353
+ @media (max-width:600px){.csk-keys{margin-left:28px;}.csk-combo{padding-left:28px;}}
354
+ `;
355
+
356
+ // src/client/runtime.ts
357
+ function installStyle() {
358
+ const tag = document.createElement("style");
359
+ tag.dataset.plugin = "dsh-composer-send-key";
360
+ tag.textContent = CSS;
361
+ document.head.append(tag);
362
+ return () => {
363
+ tag.remove();
364
+ };
365
+ }
366
+ function createRuntime(ctx, h) {
367
+ ctx.effect(() => ctx.locale.register(LOCALE_NS, DICTIONARIES), "composer-send-key: dictionaries");
368
+ const t = ctx.locale.bind(LOCALE_NS);
369
+ ctx.effect(installStyle, "composer-send-key: stylesheet");
370
+ const form = ctx.configForms?.get(LOCALE_NS);
371
+ let settings = readSettings(form?.getSnapshot().value);
372
+ const modeStore = createStore(settings.mode);
373
+ const comboStore = createStore(settings.combo);
374
+ const errorStore = createStore("");
375
+ const adopt = () => {
376
+ const next = readSettings(form?.getSnapshot().value);
377
+ if (next.mode !== settings.mode) modeStore.set(next.mode);
378
+ if (next.combo !== settings.combo) comboStore.set(next.combo);
379
+ settings = next;
380
+ };
381
+ ctx.effect(() => {
382
+ const off = form?.subscribe(adopt);
383
+ adopt();
384
+ return off;
385
+ }, "composer-send-key: settings adoption");
386
+ const persist = (field, value) => {
387
+ if (form === void 0) {
388
+ errorStore.set(t("saveFailed"));
389
+ return;
390
+ }
391
+ void form.set(field, value).then((accepted) => {
392
+ adopt();
393
+ errorStore.set(accepted ? "" : t("saveFailed"));
394
+ }, () => {
395
+ adopt();
396
+ errorStore.set(t("saveFailed"));
397
+ });
398
+ };
399
+ const setMode = (next) => {
400
+ if (next === settings.mode) return;
401
+ settings = { ...settings, mode: next };
402
+ modeStore.set(next);
403
+ persist(MODE_FIELD, next);
404
+ };
405
+ const setCombo = (next) => {
406
+ if (next === settings.combo) return;
407
+ settings = { ...settings, combo: next };
408
+ comboStore.set(next);
409
+ persist(COMBO_FIELD, next);
410
+ };
411
+ ctx.effect(() => installComposerKeyGuard(() => settings), "composer-send-key: composer key guard");
412
+ const page = createSettingsPage(h);
413
+ ctx.slots.inject("settings.section", () => ctx.slots.register({
414
+ name: "settings.section",
415
+ id: SETTINGS_SECTION_ID,
416
+ order: SETTINGS_SECTION_ORDER,
417
+ label: () => t("nav"),
418
+ inject: () => ({
419
+ hooks: { mode: modeStore, combo: comboStore, saveError: errorStore },
420
+ setMode,
421
+ setCombo,
422
+ t
423
+ })
424
+ }, page));
425
+ const icon = createSectionIcon(h);
426
+ ctx.slots.inject("settings.section.icon", () => ctx.slots.register({
427
+ name: "settings.section.icon",
428
+ id: SETTINGS_SECTION_ID
429
+ }, icon));
430
+ }
431
+
432
+ // src/client/index.ts
433
+ var loader = globalThis.__ModuleLoader__;
434
+ loader.load({
435
+ id: PLUGIN_ID,
436
+ factory(modules) {
437
+ const react = modules("react");
438
+ const createElement = react.createElement;
439
+ return {
440
+ inject: ["slots", "locale", "configForms"],
441
+ apply(ctx) {
442
+ createRuntime(ctx, createElement);
443
+ }
444
+ };
445
+ }
446
+ });
447
+ })();
package/lib/index.js ADDED
@@ -0,0 +1,15 @@
1
+ // src/index.ts
2
+ import z from "@deepseek-ai/schemastery";
3
+ var Config = z.object({
4
+ mode: z.union(["default", "edit-friendly"]).default("default").volatile(),
5
+ combo: z.union(["shift", "ctrl"]).default("shift").volatile()
6
+ });
7
+ function apply(ctx) {
8
+ ctx.inject(["settings"], (child) => {
9
+ child.effect(() => child.settings.configure({ auto: false }, ctx.fiber));
10
+ });
11
+ }
12
+ export {
13
+ Config,
14
+ apply
15
+ };
package/locale/en.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "Composer send key",
4
- "description": "Switch the message box send shortcut between two modes. Default: Enter sends and Shift+Enter inserts a new line; Edit-friendly: Enter inserts a new line and Shift+Enter sends. Switch anytime under Settings → General → Send shortcut; the change applies immediately and persists in your profile. Ctrl/⌘+Enter keeps its built-in accelerated delivery, and the busy-state Composer Enter preference (queue/steer) is unaffected. In edit-friendly mode the two keys swap completely: with the suggestion menu open, Enter inserts a new line and Shift+Enter confirms the highlighted item. The keyboard shortcuts reference still lists the fixed Enter bindings, and the Send button keeps its current look. Disabling the plugin restores the default behavior. This plugin adapts the composer's internal keyboard handling, so re-check it after a DeepSeek Harness upgrade."
4
+ "description": "Adds a Send shortcut page to Settings with two modes: Default (Enter sends, Shift+Enter inserts a new line) and Edit-friendly (Enter inserts a new line; choose Shift+Enter or Ctrl+Enter to send). The choice applies immediately and only affects the message composer."
5
5
  }
6
6
  }
package/locale/zh.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "发送快捷键",
4
- "description": "在两种模式间切换消息框的发送快捷键。默认模式:Enter 发送,Shift+Enter 换行;编辑友好模式:Enter 换行,Shift+Enter 发送。可随时在 设置 → 通用 → 发送快捷键 中切换,即时生效并保存在你的配置档案中。Ctrl/⌘+Enter 保持内置的加速发送行为,运行中 Enter 的排队/插话偏好不受影响。编辑友好模式下两个键完全互换:候选/命令菜单打开时,Enter 换行,Shift+Enter 确认高亮项。快捷键参考页仍显示内置的固定 Enter 绑定,发送按钮外观不变。停用本插件即恢复默认行为。本插件依赖消息框的内部键盘处理,DeepSeek Harness 升级后请重新验证。"
4
+ "description": "在设置中新增「发送快捷键」页面:默认模式为 Enter 发送、Shift+Enter 换行;编辑友好模式为 Enter 换行,可选择 Shift+Enter 或 Ctrl+Enter 发送。选择即时生效,且只影响消息发送框。"
5
5
  }
6
6
  }
package/package.json CHANGED
@@ -1,15 +1,22 @@
1
1
  {
2
2
  "name": "dsh-composer-send-key",
3
- "version": "1.0.0",
4
- "description": "Switch the DeepSeek Harness message box send shortcut between default (Enter sends) and edit-friendly (Shift+Enter sends) modes.",
3
+ "version": "1.1.0",
4
+ "description": "Switch the DeepSeek Harness message composer send shortcut: Enter sends, or edit-friendly mode where Enter inserts a new line and Shift+Enter or Ctrl+Enter sends.",
5
5
  "type": "module",
6
6
  "exports": {
7
- ".": "./index.js",
8
- "./client": "./client.js",
7
+ ".": "./lib/index.js",
8
+ "./client": "./lib/client.js",
9
9
  "./locale/*.json": "./locale/*.json",
10
10
  "./icon": "./icon.svg"
11
11
  },
12
- "files": ["index.js", "client.js", "cordis.patch.yml", "locale/*.json", "README.md", "icon.svg"],
12
+ "files": ["lib", "cordis.patch.yml", "locale/*.json", "README.md", "README.zh.md", "icon.svg"],
13
+ "scripts": {
14
+ "build": "pnpm run typecheck && pnpm run build:host && pnpm run build:client",
15
+ "typecheck": "tsc --noEmit -p tsconfig.json",
16
+ "build:host": "esbuild src/index.ts --bundle --platform=node --format=esm --external:@deepseek-ai/schemastery --outfile=lib/index.js",
17
+ "build:client": "esbuild src/client/index.ts --bundle --platform=browser --format=iife --target=es2022 --outfile=lib/client.js",
18
+ "prepublishOnly": "pnpm run build"
19
+ },
13
20
  "license": "MIT",
14
21
  "author": "Licheung228",
15
22
  "repository": {
@@ -17,7 +24,9 @@
17
24
  "url": "git+https://github.com/Licheung228/dsh-composer-send-key.git"
18
25
  },
19
26
  "homepage": "https://github.com/Licheung228/dsh-composer-send-key#readme",
20
- "bugs": "https://github.com/Licheung228/dsh-composer-send-key/issues",
27
+ "bugs": {
28
+ "url": "https://github.com/Licheung228/dsh-composer-send-key/issues"
29
+ },
21
30
  "keywords": [
22
31
  "deepseek-harness",
23
32
  "dsh",
@@ -25,7 +34,8 @@
25
34
  "composer",
26
35
  "keyboard-shortcuts",
27
36
  "enter",
28
- "shift-enter"
37
+ "shift-enter",
38
+ "ctrl-enter"
29
39
  ],
30
40
  "publishConfig": {
31
41
  "access": "public"
@@ -33,6 +43,10 @@
33
43
  "dependencies": {
34
44
  "@deepseek-ai/schemastery": "3.19.0"
35
45
  },
46
+ "devDependencies": {
47
+ "esbuild": "^0.25.0",
48
+ "typescript": "^5.8.3"
49
+ },
36
50
  "dsh": {
37
51
  "bundle": { "patch": "./cordis.patch.yml" },
38
52
  "client": {
@@ -40,7 +54,8 @@
40
54
  "immediately": true,
41
55
  "inject": [
42
56
  "@deepseek-ai/dsh-client-ui-renderer",
43
- "@deepseek-ai/dsh-client-ui-settings"
57
+ "@deepseek-ai/dsh-client-ui-settings",
58
+ "@deepseek-ai/dsh-client-ui-settings-general"
44
59
  ]
45
60
  }
46
61
  }
package/client.js DELETED
@@ -1,212 +0,0 @@
1
- /**
2
- * Client half of composer-send-key.
3
- *
4
- * Two contributions:
5
- * 1. A Settings → General preference row (`settings.general.item`) switching
6
- * between `default` (Enter sends, Shift+Enter newlines) and
7
- * `edit-friendly` (Enter newlines, Shift+Enter sends). The value lives in
8
- * the volatile `mode` field of this entry's settings namespace, so writes
9
- * persist in the profile and apply live.
10
- * 2. A capture-phase keydown listener that, only in edit-friendly mode and
11
- * only inside the composer's contenteditable, swaps the Shift modifier of
12
- * plain Enter / Shift+Enter before the composer's own Lexical keymap sees
13
- * the event. Every downstream guard (busy state, command-menu arbitration,
14
- * IME composition, held-key repeat) keeps its shipped behavior because the
15
- * original event continues unchanged otherwise; in default mode the
16
- * listener never touches anything.
17
- */
18
- window.__ModuleLoader__.load({
19
- id: 'dsh-composer-send-key',
20
- factory(require) {
21
- const React = require('react')
22
- const h = React.createElement
23
-
24
- const NS = 'composer-send-key'
25
- const MODE_FIELD = 'mode'
26
- const DEFAULT_MODE = 'default'
27
- const EDIT_FRIENDLY_MODE = 'edit-friendly'
28
-
29
- const dictionaries = {
30
- en: {
31
- 'row.title': 'Send shortcut',
32
- 'mode.default': 'Default (Enter sends)',
33
- 'mode.editFriendly': 'Edit-friendly (Shift+Enter sends)',
34
- 'row.saveFailed': 'Could not save; the change applies to this session only.',
35
- },
36
- zh: {
37
- 'row.title': '发送快捷键',
38
- 'mode.default': '默认模式(Enter 发送)',
39
- 'mode.editFriendly': '编辑友好模式(Shift+Enter 发送)',
40
- 'row.saveFailed': '保存失败,本次修改仅在当前会话生效。',
41
- },
42
- }
43
-
44
- const CSS = `
45
- .dsh-csk-row{display:flex;align-items:center;gap:8px;padding:16px 0;border-bottom:.5px solid var(--dsw-alias-border-l2);}
46
- .dsh-csk-text{flex:1;min-width:0;display:flex;flex-direction:column;gap:4px;padding-right:48px;}
47
- @media (max-width:767px){html:not([data-windows-titlebar]):not([data-platform='darwin']) .dsh-csk-text{padding-right:16px;}}
48
- .dsh-csk-title{font-size:14px;font-weight:400;line-height:22px;color:var(--dsw-alias-label-primary);}
49
- .dsh-csk-select{flex:none;height:36px;max-width:260px;padding:0 10px;border:none;border-radius:var(--dsw-radius-md);background:var(--dsw-alias-bg-module-platform);font:inherit;font-size:14px;line-height:22px;color:var(--dsw-alias-label-primary);cursor:pointer;}
50
- @media (hover:hover){.dsh-csk-select:hover{background:var(--dsw-alias-interactive-bg-hover);}}
51
- .dsh-csk-error{font-size:12px;font-weight:400;line-height:18px;color:var(--dsw-alias-state-error-primary);}
52
- `
53
-
54
- /** Translation fallback when the slot does not project a `t` prop. */
55
- let fallbackTranslate = (key) => key
56
-
57
- function SendKeyModeRow(props) {
58
- const useMode = props.useMode
59
- const useSaveError = props.useSaveError
60
- const setMode = props.setMode
61
- const t = props.t ?? fallbackTranslate
62
- const mode = useMode((value) => value)
63
- const saveError = useSaveError((value) => value)
64
- return h(React.Fragment, null,
65
- h('style', null, CSS),
66
- h('div', { className: 'dsh-csk-row' },
67
- h('div', { className: 'dsh-csk-text' },
68
- h('div', { className: 'dsh-csk-title' }, t('row.title')),
69
- saveError ? h('div', { className: 'dsh-csk-error', role: 'status' }, saveError) : null),
70
- h('select', {
71
- className: 'dsh-csk-select',
72
- value: mode,
73
- 'aria-label': t('row.title'),
74
- onChange: (event) => setMode(event.target.value),
75
- },
76
- h('option', { value: DEFAULT_MODE }, t('mode.default')),
77
- h('option', { value: EDIT_FRIENDLY_MODE }, t('mode.editFriendly')))))
78
- }
79
-
80
- /** The composer's contenteditable root, identified without reading any other plugin's DOM. */
81
- function isComposerEditable(target) {
82
- if (!(target instanceof HTMLElement)) return false
83
- if (!target.isContentEditable) return false
84
- return target.closest('[data-composer-card]') !== null
85
- }
86
-
87
- return {
88
- inject: ['slots', 'locale', 'configForms'],
89
- apply(ctx) {
90
- ctx.effect(() => ctx.locale.register(NS, dictionaries), 'composer-send-key: dictionaries')
91
- const t = ctx.locale.bind(NS)
92
- fallbackTranslate = t
93
-
94
- // Live `mode` snapshot over the Host settings document; browser-local
95
- // default when the namespace is not exposed to this client.
96
- const form = typeof ctx.configForms?.get === 'function' ? ctx.configForms.get(NS) : undefined
97
- let mode = DEFAULT_MODE
98
- const listeners = new Set()
99
- const publish = () => { for (const listener of [...listeners]) listener() }
100
- const store = {
101
- getSnapshot: () => mode,
102
- subscribe: (listener) => {
103
- listeners.add(listener)
104
- return () => { listeners.delete(listener) }
105
- },
106
- }
107
- const adopt = () => {
108
- const value = form?.getSnapshot().value
109
- const next = value !== undefined && value !== null && value.mode === EDIT_FRIENDLY_MODE
110
- ? EDIT_FRIENDLY_MODE
111
- : DEFAULT_MODE
112
- if (next !== mode) {
113
- mode = next
114
- publish()
115
- }
116
- }
117
- ctx.effect(() => {
118
- const unsubscribe = form?.subscribe(adopt)
119
- adopt()
120
- return unsubscribe
121
- }, 'composer-send-key: mode adoption')
122
- let saveError = ''
123
- const errorListeners = new Set()
124
- const publishError = () => { for (const listener of [...errorListeners]) listener() }
125
- const setSaveError = (text) => { if (text !== saveError) { saveError = text; publishError() } }
126
- const errorStore = {
127
- getSnapshot: () => saveError,
128
- subscribe: (listener) => {
129
- errorListeners.add(listener)
130
- return () => { errorListeners.delete(listener) }
131
- },
132
- }
133
- const setMode = (next) => {
134
- if (next !== DEFAULT_MODE && next !== EDIT_FRIENDLY_MODE) return
135
- if (next === mode) return
136
- mode = next
137
- publish()
138
- if (form === undefined) {
139
- setSaveError(t('row.saveFailed'))
140
- return
141
- }
142
- void form.set(MODE_FIELD, next).then((accepted) => {
143
- adopt()
144
- setSaveError(accepted ? '' : t('row.saveFailed'))
145
- }, () => {
146
- adopt()
147
- setSaveError(t('row.saveFailed'))
148
- })
149
- }
150
-
151
- // Capture-phase modifier swap; see the module doc for why this is the
152
- // only interception point the shipped composer leaves a plugin.
153
- let composing = false
154
- let composingUntil = 0
155
- const isComposing = (event) =>
156
- event.isComposing || event.keyCode === 229 || composing || Date.now() < composingUntil
157
- let warnedShiftSwap = false
158
- const setShift = (event, value) => {
159
- try {
160
- Object.defineProperty(event, 'shiftKey', { configurable: true, enumerable: true, get: () => value })
161
- } catch {
162
- // An exotic event without a configurable shiftKey would leave the
163
- // stock behavior in place; surface that once instead of silently
164
- // keeping Enter = send in edit-friendly mode.
165
- if (!warnedShiftSwap) {
166
- warnedShiftSwap = true
167
- console.warn('[composer-send-key] shiftKey is not configurable; edit-friendly mode is inactive for this event')
168
- }
169
- }
170
- }
171
- const onCompositionStart = (event) => { if (isComposerEditable(event.target)) composing = true }
172
- const onCompositionEnd = () => {
173
- if (!composing) return
174
- composing = false
175
- // Safari delivers the composition-closing keydown just after
176
- // compositionend; hold the guard for one tick, mirroring the
177
- // composer's own IME window.
178
- composingUntil = Date.now() + 10
179
- }
180
- const onKeyDown = (event) => {
181
- if (mode !== EDIT_FRIENDLY_MODE) return
182
- if (event.key !== 'Enter') return
183
- if (!isComposerEditable(event.target)) return
184
- if (event.ctrlKey || event.metaKey || event.altKey) return
185
- if (typeof event.getModifierState === 'function' && event.getModifierState('AltGraph')) return
186
- // An IME-closing Enter must reach the candidate window unchanged.
187
- if (isComposing(event)) return
188
- setShift(event, !event.shiftKey)
189
- }
190
- ctx.effect(() => {
191
- const options = { capture: true }
192
- document.addEventListener('keydown', onKeyDown, options)
193
- document.addEventListener('compositionstart', onCompositionStart, options)
194
- document.addEventListener('compositionend', onCompositionEnd, options)
195
- return () => {
196
- document.removeEventListener('keydown', onKeyDown, options)
197
- document.removeEventListener('compositionstart', onCompositionStart, options)
198
- document.removeEventListener('compositionend', onCompositionEnd, options)
199
- }
200
- }, 'composer-send-key: modifier swap')
201
-
202
- ctx.slots.inject('settings.general.item', () => ctx.slots.register({
203
- name: 'settings.general.item',
204
- id: 'composer-send-key-mode',
205
- order: 21,
206
- locale: NS,
207
- inject: () => ({ hooks: { mode: store, saveError: errorStore }, setMode }),
208
- }, SendKeyModeRow))
209
- },
210
- }
211
- },
212
- })
package/index.js DELETED
@@ -1,21 +0,0 @@
1
- /**
2
- * Host half of composer-send-key.
3
- *
4
- * Declares one volatile preference, `mode`, persisted through the profile's
5
- * settings document (the same mechanism the built-in Composer Enter row uses).
6
- * The Client half reads and writes it through `ctx.configForms` under this
7
- * entry's profile id, `composer-send-key`; volatile writes apply live without
8
- * restarting the plugin.
9
- */
10
- import z from '@deepseek-ai/schemastery'
11
-
12
- export const Config = z.object({
13
- mode: z.union(['default', 'edit-friendly']).default('default').volatile(),
14
- })
15
-
16
- /** Register the settings persistence policy; run without Settings when absent. */
17
- export function apply(ctx) {
18
- ctx.inject(['settings'], (child) => {
19
- child.effect(() => child.settings.configure({ auto: false }, ctx.fiber))
20
- })
21
- }