A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.
Let users choose whether Enter sends or wraps
klarkxye735dc6c1b67
diff --git a/ds-bot/client.js b/ds-bot/client.jsindex ec520f75..ae49302b 100644--- a/ds-bot/client.js+++ b/ds-bot/client.js@@ -505,6 +505,8 @@ var ZH = {"Bubble width": "气泡宽度","Text width": "正文宽度","Show thinking": "显示思考过程",+ "Enter sends message": "回车发送消息",+ "When off, Enter inserts a new line. Use the send button to send.": "关闭后,回车换行,点击发送按钮发送。","Bots · {count}": "Bot · {count}","First in the sidebar. Pick another Bot to hand it the role; {name} then stops being a Main Bot.": "排在侧栏最上面。选另一个 Bot 就会把主 Bot 交给它,{name} 随之不再是主 Bot。","Choose a Bot…": "选择一个 Bot…",@@ -10622,6 +10624,20 @@ function NewMessagePills({ sessionId, useSessions, useUi, useTurnClock }) {);}+// src/client/enter-key.js+function insertComposerNewline(event, inputActions) {+ if (event.key !== "Enter" || event.shiftKey || event.altKey || event.ctrlKey || event.metaKey || event.isComposing || event.keyCode === 229 || event.getModifierState?.("AltGraph")) return false;+ const target = event.target;+ if (typeof target?.closest !== "function" || !target.closest('[data-composer-card] [role="textbox"]')) return false;+ if (target.closest("[data-composer-composing]")) return false;+ if (target.ownerDocument?.querySelector('[role="listbox"]')) return false;+ if (typeof inputActions?.captureInsertion !== "function" || typeof inputActions?.insertText !== "function") return false;+ event.preventDefault();+ event.stopImmediatePropagation();+ inputActions.insertText("\n", inputActions.captureInsertion());+ return true;+}+// src/client/composer.jsvar import_react21 = require("react");var import_react_dom5 = require("react-dom");@@ -10682,7 +10698,16 @@ function useDictation(onText) {const stop = () => recognition.current?.stop();return { listening, note, start, stop };}-function ComposerVoice({ sessionId, inputActions, actions, useUi }) {+function ComposerVoice({ sessionId, inputActions, actions, useUi, useRoster }) {+ const enterToSend = useRoster((state) => state.prefs?.enterToSend !== false);+ const composerRoot = (0, import_react21.useRef)(null);+ (0, import_react21.useEffect)(() => {+ const root = composerRoot.current?.closest("[data-composer-card]");+ if (enterToSend || !inputActions || !root) return void 0;+ const onKey = (event) => insertComposerNewline(event, inputActions);+ root.addEventListener("keydown", onKey, true);+ return () => root.removeEventListener("keydown", onKey, true);+ }, [enterToSend, inputActions]);const dictation = useDictation((text, final) => {if (final && inputActions) inputActions.insertText(text, inputActions.captureInsertion());});@@ -10718,6 +10743,7 @@ function ComposerVoice({ sessionId, inputActions, actions, useUi }) {onClick: () => dictation.listening ? dictation.stop() : dictation.start()}, (0, import_react21.createElement)(MicIcon)),(0, import_react21.createElement)("button", {+ ref: composerRoot,type: "button",className: "bt-voice","aria-label": t("Start voice chat"),@@ -16966,6 +16992,15 @@ function GeneralPage({ roster, actions, run: run2 }) {(0, import_react45.createElement)(SetRow, { label: t("Bubble width") }, (0, import_react45.createElement)(WidthSlider, { label: t("Bubble width"), value: widthOf(prefs), save: (width) => run2(actions.setPrefs({ width })) })),(0, import_react45.createElement)(SetRow, { label: t("Show thinking") }, (0, import_react45.createElement)(Switch, { label: t("Show thinking"), on: thinkingShown(prefs), onChange: (thinking) => run2(actions.setPrefs({ thinking })) }))),+ (0, import_react45.createElement)(+ SetSection,+ { key: "input", title: t("Input") },+ (0, import_react45.createElement)(+ SetRow,+ { label: t("Enter sends message"), hint: t("When off, Enter inserts a new line. Use the send button to send.") },+ (0, import_react45.createElement)(Switch, { label: t("Enter sends message"), on: prefs.enterToSend !== false, onChange: (enterToSend) => run2(actions.setPrefs({ enterToSend })) })+ )+ ),actions.setSurface ? (0, import_react45.createElement)(SetSection,{ key: "mode", title: t("Mode") },@@ -20853,7 +20888,7 @@ function apply(ctx) {if (typeof release === "function") release();if (snapshot.ready) {try {- localStorage.setItem(PREFS_KEY, JSON.stringify({ theme: prefs.theme, accent: prefs.accent, motion: prefs.motion, layout: prefs.layout, width: prefs.width, flatWidth: prefs.flatWidth, thinking: prefs.thinking }));+ localStorage.setItem(PREFS_KEY, JSON.stringify({ theme: prefs.theme, accent: prefs.accent, motion: prefs.motion, layout: prefs.layout, width: prefs.width, flatWidth: prefs.flatWidth, thinking: prefs.thinking, enterToSend: prefs.enterToSend }));} catch {}}diff --git a/ds-bot/src/client/composer.js b/ds-bot/src/client/composer.jsindex 1ea7632d..470dffe6 100644--- a/ds-bot/src/client/composer.js+++ b/ds-bot/src/client/composer.js@@ -4,6 +4,7 @@ import { ChatsIcon, ClockIcon, MicIcon, PaperclipIcon, PeopleIcon, PlusIcon, Wavimport { BotMark } from './mark.js'import { useLinger, useViewport, viewBottom } from './motion.js'import { t } from './i18n.js'+import { insertComposerNewline } from './enter-key.js'// -------------------------------------------------------------------------// Composer: dictation mic and the voice-chat button. The shell's send@@ -53,7 +54,16 @@ export function useDictation(onText) {return { listening, note, start, stop }}-export function ComposerVoice({ sessionId, inputActions, actions, useUi }) {+export function ComposerVoice({ sessionId, inputActions, actions, useUi, useRoster }) {+ const enterToSend = useRoster(state => state.prefs?.enterToSend !== false)+ const composerRoot = useRef(null)+ useEffect(() => {+ const root = composerRoot.current?.closest('[data-composer-card]')+ if (enterToSend || !inputActions || !root) return undefined+ const onKey = event => insertComposerNewline(event, inputActions)+ root.addEventListener('keydown', onKey, true)+ return () => root.removeEventListener('keydown', onKey, true)+ }, [enterToSend, inputActions])const dictation = useDictation((text, final) => {if (final && inputActions) inputActions.insertText(text, inputActions.captureInsertion())})@@ -83,7 +93,7 @@ export function ComposerVoice({ sessionId, inputActions, actions, useUi }) {onMouseDown: keepComposerFocus, onClick: () => (dictation.listening ? dictation.stop() : dictation.start()),}, h(MicIcon)),h('button', {- type: 'button', className: 'bt-voice', 'aria-label': t('Start voice chat'), title: t('Voice chat'),+ ref: composerRoot, type: 'button', className: 'bt-voice', 'aria-label': t('Start voice chat'), title: t('Voice chat'),onMouseDown: keepComposerFocus, onClick: () => actions.openVoice(sessionId),}, h(WaveIcon, { size: 18 })),dictation.note ? h('span', { className: 'bt-mic-note', role: 'status' }, dictation.note) : null)diff --git a/ds-bot/src/client/enter-key.js b/ds-bot/src/client/enter-key.jsnew file mode 100644index 00000000..1bea9489--- /dev/null+++ b/ds-bot/src/client/enter-key.js@@ -0,0 +1,15 @@+// Plain Enter can insert a line instead of submitting. Menus, modified shortcuts,+// and IME confirmation keep the host composer's own behavior.+export function insertComposerNewline(event, inputActions) {+ if (event.key !== 'Enter' || event.shiftKey || event.altKey || event.ctrlKey || event.metaKey+ || event.isComposing || event.keyCode === 229 || event.getModifierState?.('AltGraph')) return false+ const target = event.target+ if (typeof target?.closest !== 'function' || !target.closest('[data-composer-card] [role="textbox"]')) return false+ if (target.closest('[data-composer-composing]')) return false+ if (target.ownerDocument?.querySelector('[role="listbox"]')) return false+ if (typeof inputActions?.captureInsertion !== 'function' || typeof inputActions?.insertText !== 'function') return false+ event.preventDefault()+ event.stopImmediatePropagation()+ inputActions.insertText('\n', inputActions.captureInsertion())+ return true+}diff --git a/ds-bot/src/client/i18n.js b/ds-bot/src/client/i18n.jsindex f9b02861..175b326e 100644--- a/ds-bot/src/client/i18n.js+++ b/ds-bot/src/client/i18n.js@@ -445,6 +445,8 @@ const ZH = {'Bubble width': '气泡宽度','Text width': '正文宽度','Show thinking': '显示思考过程',+ 'Enter sends message': '回车发送消息',+ 'When off, Enter inserts a new line. Use the send button to send.': '关闭后,回车换行,点击发送按钮发送。','Bots · {count}': 'Bot · {count}','First in the sidebar. Pick another Bot to hand it the role; {name} then stops being a Main Bot.': '排在侧栏最上面。选另一个 Bot 就会把主 Bot 交给它,{name} 随之不再是主 Bot。','Choose a Bot…': '选择一个 Bot…',diff --git a/ds-bot/src/client/index.js b/ds-bot/src/client/index.jsindex 9dfc0035..331e8cfd 100644--- a/ds-bot/src/client/index.js+++ b/ds-bot/src/client/index.js@@ -363,7 +363,7 @@ export function apply(ctx) {releaseTokens = ctx.theme.overrideTokens('ds-bot', shellTokens(themes[id]))if (typeof release === 'function') release()if (snapshot.ready) {- try { localStorage.setItem(PREFS_KEY, JSON.stringify({ theme: prefs.theme, accent: prefs.accent, motion: prefs.motion, layout: prefs.layout, width: prefs.width, flatWidth: prefs.flatWidth, thinking: prefs.thinking })) } catch { /* storage unavailable */ }+ try { localStorage.setItem(PREFS_KEY, JSON.stringify({ theme: prefs.theme, accent: prefs.accent, motion: prefs.motion, layout: prefs.layout, width: prefs.width, flatWidth: prefs.flatWidth, thinking: prefs.thinking, enterToSend: prefs.enterToSend })) } catch { /* storage unavailable */ }}}render()diff --git a/ds-bot/src/client/settings.js b/ds-bot/src/client/settings.jsindex 4428659d..0d59e3d8 100644--- a/ds-bot/src/client/settings.js+++ b/ds-bot/src/client/settings.js@@ -106,6 +106,9 @@ function GeneralPage({ roster, actions, run }) {layoutOf(prefs) === 'flat' ? h(SetRow, { label: t('Text width') }, h(WidthSlider, { label: t('Text width'), value: flatWidthOf(prefs), save: flatWidth => run(actions.setPrefs({ flatWidth })) })) : null,h(SetRow, { label: t('Bubble width') }, h(WidthSlider, { label: t('Bubble width'), value: widthOf(prefs), save: width => run(actions.setPrefs({ width })) })),h(SetRow, { label: t('Show thinking') }, h(Switch, { label: t('Show thinking'), on: thinkingShown(prefs), onChange: thinking => run(actions.setPrefs({ thinking })) }))),+ h(SetSection, { key: 'input', title: t('Input') },+ h(SetRow, { label: t('Enter sends message'), hint: t('When off, Enter inserts a new line. Use the send button to send.') },+ h(Switch, { label: t('Enter sends message'), on: prefs.enterToSend !== false, onChange: enterToSend => run(actions.setPrefs({ enterToSend })) }))),actions.setSurface ? h(SetSection, { key: 'mode', title: t('Mode') },h(SetRow, { label: t('Classic Agent mode') },h('button', { type: 'button', className: 'bt-soft bt-soft-sm', onClick: () => actions.setSurface('agent') }, t('Switch')))) : null,diff --git a/ds-bot/src/host/channel.js b/ds-bot/src/host/channel.jsindex 59168534..81cd2d4e 100644--- a/ds-bot/src/host/channel.js+++ b/ds-bot/src/host/channel.js@@ -152,6 +152,10 @@ export function install(rt) {if (body.thinking === true) state.prefs.thinking = trueelse if (body.thinking === false || body.thinking === null) delete state.prefs.thinking}+ if (body.enterToSend !== undefined) {+ if (body.enterToSend === false) state.prefs.enterToSend = false+ else if (body.enterToSend === true || body.enterToSend === null) delete state.prefs.enterToSend+ }return rt.save()}diff --git a/ds-bot/test/composer-enter.test.js b/ds-bot/test/composer-enter.test.jsnew file mode 100644index 00000000..c06b6a40--- /dev/null+++ b/ds-bot/test/composer-enter.test.js@@ -0,0 +1,68 @@+import assert from 'node:assert/strict'+import { test } from 'node:test'+import { insertComposerNewline } from '../src/client/enter-key.js'++function bench({ composing = false, listbox = false, actions = true } = {}) {+ const inserted = []+ const inputActions = actions ? {+ captureInsertion: () => ({ draftRev: 1 }),+ insertText: (text, span) => { inserted.push([text, span]); return true },+ } : undefined+ const target = {+ ownerDocument: { querySelector: selector => selector === '[role="listbox"]' && listbox ? {} : null },+ closest(selector) {+ if (selector === '[data-composer-card] [role="textbox"]') return this+ if (selector === '[data-composer-composing]') return composing ? this : null+ return null+ },+ }+ const event = {+ key: 'Enter', target, prevented: 0, stopped: 0,+ preventDefault() { this.prevented += 1 },+ stopImmediatePropagation() { this.stopped += 1 },+ }+ return { event, inputActions, inserted }+}++test('plain Enter inserts a newline at the captured caret and stops submission', () => {+ const { event, inputActions, inserted } = bench()+ assert.equal(insertComposerNewline(event, inputActions), true)+ assert.deepEqual(inserted, [['\n', { draftRev: 1 }]])+ assert.equal(event.prevented, 1)+ assert.equal(event.stopped, 1)+})++test('IME confirmation, an open suggestion menu, and modified Enter pass through', () => {+ for (const setup of [+ { event: { isComposing: true } },+ { event: { keyCode: 229 } },+ { event: { shiftKey: true } },+ { event: { ctrlKey: true } },+ { event: { metaKey: true } },+ { event: { altKey: true } },+ { event: { getModifierState: key => key === 'AltGraph' } },+ { composing: true },+ { listbox: true },+ ]) {+ const { event, inputActions, inserted } = bench(setup)+ Object.assign(event, setup.event)+ assert.equal(insertComposerNewline(event, inputActions), false)+ assert.deepEqual(inserted, [])+ assert.equal(event.prevented, 0)+ assert.equal(event.stopped, 0)+ }+})++test('other keys, other fields, and a missing input face stay untouched', () => {+ const otherKey = bench()+ otherKey.event.key = 'a'+ assert.equal(insertComposerNewline(otherKey.event, otherKey.inputActions), false)++ const otherField = bench()+ otherField.event.target.closest = () => null+ assert.equal(insertComposerNewline(otherField.event, otherField.inputActions), false)++ const noActions = bench({ actions: false })+ assert.equal(insertComposerNewline(noActions.event, noActions.inputActions), false)+ assert.equal(noActions.event.prevented, 0)+})diff --git a/ds-bot/test/install.test.js b/ds-bot/test/install.test.jsindex 2eb38b4d..675906a8 100644--- a/ds-bot/test/install.test.js+++ b/ds-bot/test/install.test.js@@ -157,6 +157,12 @@ test('the client channel answers from the saved state', async (t) => {assert.equal('thinking' in (await call('set-prefs', { thinking: false })).value, false)await call('set-prefs', { thinking: true })assert.equal('thinking' in (await call('set-prefs', { thinking: null })).value, false)+ // Enter sends by default; false persists until the user turns it back on.+ assert.equal((await call('set-prefs', { enterToSend: false })).value.enterToSend, false)+ assert.equal((await call('set-prefs', { enterToSend: 'no' })).value.enterToSend, false)+ assert.equal('enterToSend' in (await call('set-prefs', { enterToSend: true })).value, false)+ await call('set-prefs', { enterToSend: false })+ assert.equal('enterToSend' in (await call('set-prefs', { enterToSend: null })).value, false)// A refusal from the team code keeps its message for the user.assert.deepEqual((await call('delete-bot', { id: 'nobody' })).error, { code: 'bot/refused', message: 'Unknown Bot', details: {} })// Off the Desktop profile there are no Bot browsers.