Skip to content

A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.

Respect the Enter preference in the side-chat view

klarkxy035c84215fd1
diff --git a/ds-bot/client.js b/ds-bot/client.js
index 92a28bd8..6b0b6886 100644
--- a/ds-bot/client.js
+++ b/ds-bot/client.js
@@ -2409,7 +2409,7 @@ function useLinger(value, ms) {
var SHELL_CSS = `
body{--bt-ink:#141414;--bt-danger:#e02135;--bt-ink-2:rgba(20,20,20,.6);--bt-ink-3:rgba(20,20,20,.36);--bt-bubble:#eeeeee;--bt-sidebar:#f7f7f7;--bt-main:#fcfcfc;--bt-line:rgba(20,20,20,.08);--bt-line-2:rgba(20,20,20,.15);--bt-line-weak:rgba(20,20,20,.1);--bt-hover:rgba(119,119,119,.09);--bt-active:rgba(119,119,119,.17);--bt-card:#ffffff;--bt-accent:#4d6bfe;--bt-green:#00c972;--bt-star:#ff9800;--bt-user:#070707;--bt-user-ink:#fcfcfc;--bt-tag-bg:rgba(20,20,20,.06);--bt-tag-ink:rgba(20,20,20,.56);--bt-knob:#ffffff;--bt-glass-bg:color-mix(in srgb,var(--bt-main) 78%,transparent);--bt-glass-border:rgba(255,255,255,.72);--bt-glass-rim:rgba(20,20,20,.09);--bt-glass-shadow:0 8px 28px -6px rgba(0,0,0,.08),0 2px 6px -1px rgba(0,0,0,.04),inset 0 1px 0 rgba(255,255,255,.82);-webkit-tap-highlight-color:transparent;-webkit-text-size-adjust:100%;--bt-font:var(--dsw-font-family,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif)}
/* iOS waits out a double-tap zoom on buttons; the plugin's own controls never zoom. */
-:is(.bt-tool,.bt-uaction,.bt-menu button,.bt-menu-item,.bt-icon-btn,.bt-round,.bt-pill,.bt-account,.bt-set-row,.bt-settings-item,.bt-react-strip button,.bt-palette-row,.bt-palette-clear,.bt-tab,.bt-ptab,.bt-ptab-x,.bt-bcard-x,.bt-plus,.bt-q-btn,.bt-q-x,.bt-x,.bt-nc-send,.bt-send,.bt-soft,.bt-mini,.bt-shape,.bt-swatch,.bt-color,.bt-newchat,.bt-task-day,.bt-task-remove,.bt-fb-btn){touch-action:manipulation}
+:is(.bt-tool,.bt-uaction,.bt-menu button,.bt-menu-item,.bt-icon-btn,.bt-round,.bt-pill,.bt-account,.bt-set-row,.bt-settings-item,.bt-react-strip button,.bt-palette-row,.bt-palette-clear,.bt-tab,.bt-ptab,.bt-ptab-x,.bt-bcard-x,.bt-plus,.bt-q-btn,.bt-q-x,.bt-x,.bt-nc-send,.bt-send,.bt-soft,.bt-mini,.bt-side-send,.bt-shape,.bt-swatch,.bt-color,.bt-newchat,.bt-task-day,.bt-task-remove,.bt-fb-btn){touch-action:manipulation}
:is(.bt-round,.bt-you,.bt-account,.bt-color,.bt-color span,.bt-swatch,.bt-icon-btn,.bt-avatar-trigger,.bt-avatar-pencil,.bt-plus,.bt-mic,.bt-voice){corner-shape:round}
body[data-ds-dark-theme]{--bt-ink:#f2f2f2;--bt-ink-2:rgba(242,242,242,.6);--bt-ink-3:rgba(242,242,242,.36);--bt-bubble:#262626;--bt-sidebar:#1b1b1b;--bt-main:#141414;--bt-line:rgba(255,255,255,.08);--bt-line-2:rgba(255,255,255,.15);--bt-line-weak:rgba(255,255,255,.1);--bt-hover:rgba(160,160,160,.12);--bt-active:rgba(160,160,160,.2);--bt-card:#1f1f1f;--bt-user:#f2f2f2;--bt-user-ink:#141414;--bt-tag-bg:rgba(255,255,255,.09);--bt-tag-ink:rgba(242,242,242,.62);--bt-glass-bg:color-mix(in srgb,var(--bt-main) 74%,transparent);--bt-glass-border:rgba(255,255,255,.13);--bt-glass-rim:rgba(255,255,255,.11);--bt-glass-shadow:0 12px 32px -6px rgba(0,0,0,.42),0 2px 8px -1px rgba(0,0,0,.28),inset 0 1px 0 rgba(255,255,255,.12)}
${Object.entries(INKS).map(([name, [light]]) => `body{--bt-ink-${name}:${light}}`).join("")}
@@ -11168,7 +11168,7 @@ function SideEntry({ chatId, entry, actions }) {
)
);
}
-function SideChatView({ subject, chat, actions }) {
+function SideChatView({ subject, chat, roster, actions }) {
const scroll = (0, import_react22.useRef)(null);
const [draft, setDraft] = (0, import_react22.useState)("");
const [fail2, setFail] = (0, import_react22.useState)(null);
@@ -11214,11 +11214,19 @@ function SideChatView({ subject, chat, actions }) {
if (fail2 !== null) setFail(null);
},
onKeyDown: (event) => {
- if (event.key !== "Enter" || event.shiftKey || event.nativeEvent?.isComposing) return;
+ if (event.key !== "Enter" || !sendsOnEnter(roster?.prefs) || event.shiftKey || event.nativeEvent?.isComposing) return;
event.preventDefault();
ask();
}
}),
+ // With Enter sending off this is the only way to ask; on, it sends the same.
+ (0, import_react22.createElement)("button", {
+ type: "button",
+ className: "bt-side-send",
+ "aria-label": t("Send message"),
+ disabled: busy || draft.trim() === "" || typeof actions?.askSide !== "function",
+ onClick: ask
+ }, (0, import_react22.createElement)(ArrowUpIcon)),
fail2 !== null ? (0, import_react22.createElement)("p", { className: "bt-side-fail" }, fail2) : null
)
);
@@ -11281,8 +11289,11 @@ var SIDE_CSS = `
.bt-side-a{display:flex;flex-direction:column;gap:8px;align-items:flex-start;font-size:13px;line-height:19px;color:var(--bt-ink)}
.bt-side-status{margin:0;font-size:12px;color:var(--bt-ink-3)}
.bt-side-fail{margin:0;font-size:12px;line-height:17px;color:var(--bt-danger)}
-.bt-side-form{flex:none;padding:10px 14px 14px;border-top:.5px solid var(--bt-line)}
-.bt-side-input{display:block;width:100%;box-sizing:border-box;min-height:36px;max-height:120px;padding:8px 12px;border:.5px solid var(--bt-line-2);border-radius:12px;background:var(--bt-main);color:var(--bt-ink);font:inherit;font-size:13px;line-height:19px;resize:none;outline:none;field-sizing:content}
+.bt-side-form{flex:none;padding:10px 14px 14px;border-top:.5px solid var(--bt-line);display:flex;flex-wrap:wrap;align-items:flex-end;gap:8px}
+.bt-side-form>.bt-side-fail{flex-basis:100%}
+.bt-side-send{width:36px;height:36px;border-radius:50%;border:0;background:var(--bt-accent);color:var(--bt-accent-ink,#fff);display:inline-flex;align-items:center;justify-content:center;cursor:pointer;flex:none}
+.bt-side-send:disabled{opacity:.3;cursor:default}
+.bt-side-input{display:block;flex:1;min-width:0;box-sizing:border-box;min-height:36px;max-height:120px;padding:8px 12px;border:.5px solid var(--bt-line-2);border-radius:12px;background:var(--bt-main);color:var(--bt-ink);font:inherit;font-size:13px;line-height:19px;resize:none;outline:none;field-sizing:content}
.bt-side-input::placeholder{color:var(--bt-ink-3)}
.bt-side-input:focus{border-color:var(--bt-accent)}
.bt-side-input:disabled{opacity:.6}
@@ -18937,7 +18948,7 @@ function BotPanel({ pane, leaving, room: room2, overlay, roster, actions, useSes
// pages underneath (the chat, the guest) see no pointer.
dragging ? (0, import_react_dom8.createPortal)((0, import_react49.createElement)("div", { className: "bt-drag-shield", "aria-hidden": true }), document.body) : null,
hasStrip ? (0, import_react49.createElement)(PanelStrip, { bot, subject: pane.id, view, ids: tabState.ids, active, sides: sideChats, side: pane.side, canBrowse, reading, onView: switchView, actions: panelActions, useBrowserPages }) : null,
- view === "browser" && bot ? (0, import_react49.createElement)(BrowserView, { key: `browser:${active}`, bot, tabId: active, leaving, landed: landed && !settling, actions, useBrowserPages, hold }) : view === "side" && sideChat ? (0, import_react49.createElement)("div", { key: `side:${sideChat.id}`, className: "bt-panel-view" }, (0, import_react49.createElement)(SideChatView, { subject: pane.id, chat: sideChat, actions: panelActions })) : (0, import_react49.createElement)(
+ view === "browser" && bot ? (0, import_react49.createElement)(BrowserView, { key: `browser:${active}`, bot, tabId: active, leaving, landed: landed && !settling, actions, useBrowserPages, hold }) : view === "side" && sideChat ? (0, import_react49.createElement)("div", { key: `side:${sideChat.id}`, className: "bt-panel-view" }, (0, import_react49.createElement)(SideChatView, { subject: pane.id, chat: sideChat, roster, actions: panelActions })) : (0, import_react49.createElement)(
"div",
{ key: `details:${pane.id}:${pane.renaming ? "rename" : ""}:${pane.tab ?? ""}`, className: "bt-panel-view" },
(0, import_react49.createElement)(DetailsDrawer, {
diff --git a/ds-bot/src/client/browser-pane.js b/ds-bot/src/client/browser-pane.js
index ecfc8b2a..2bebcf8d 100644
--- a/ds-bot/src/client/browser-pane.js
+++ b/ds-bot/src/client/browser-pane.js
@@ -736,7 +736,7 @@ export function BotPanel({ pane, leaving, room, overlay, roster, actions, useSes
view === 'browser' && bot
? h(BrowserView, { key: `browser:${active}`, bot, tabId: active, leaving, landed: landed && !settling, actions, useBrowserPages, hold })
: view === 'side' && sideChat
- ? h('div', { key: `side:${sideChat.id}`, className: 'bt-panel-view' }, h(SideChatView, { subject: pane.id, chat: sideChat, actions: panelActions }))
+ ? h('div', { key: `side:${sideChat.id}`, className: 'bt-panel-view' }, h(SideChatView, { subject: pane.id, chat: sideChat, roster, actions: panelActions }))
: h('div', { key: `details:${pane.id}:${pane.renaming ? 'rename' : ''}:${pane.tab ?? ''}`, className: 'bt-panel-view' },
h(DetailsDrawer, {
sessionId: pane.id, startRenaming: pane.renaming, startTab: pane.tab, hasStrip,
diff --git a/ds-bot/src/client/side-chat.js b/ds-bot/src/client/side-chat.js
index bf762a75..629b4ee1 100644
--- a/ds-bot/src/client/side-chat.js
+++ b/ds-bot/src/client/side-chat.js
@@ -6,6 +6,8 @@ import { call } from './api.js'
import { MarkdownText } from './dsh-primitives.js'
import { hostText, t } from './i18n.js'
import { failureText, mdLabels } from './btw.js'
+import { ArrowUpIcon } from './icons.js'
+import { sendsOnEnter } from './enter-key.js'
import {
SIDE_SOURCE, SIDE_TOKEN, matchSideClaim, matchSideEnter, matchSideSpace, sideQueryMatches, sideSurface, submitSide,
} from './side-model.js'
@@ -34,7 +36,7 @@ function SideEntry({ chatId, entry, actions }) {
answer !== '' ? h(MarkdownText, { text: answer, labels: mdLabels(), variant: 'compact' }) : null))
}
-export function SideChatView({ subject, chat, actions }) {
+export function SideChatView({ subject, chat, roster, actions }) {
const scroll = useRef(null)
const [draft, setDraft] = useState('')
const [fail, setFail] = useState(null)
@@ -68,11 +70,16 @@ export function SideChatView({ subject, chat, actions }) {
'aria-label': t('Ask about the work so far'),
onChange: (event) => { setDraft(event.target.value); if (fail !== null) setFail(null) },
onKeyDown: (event) => {
- if (event.key !== 'Enter' || event.shiftKey || event.nativeEvent?.isComposing) return
+ if (event.key !== 'Enter' || !sendsOnEnter(roster?.prefs) || event.shiftKey || event.nativeEvent?.isComposing) return
event.preventDefault()
ask()
},
}),
+ // With Enter sending off this is the only way to ask; on, it sends the same.
+ h('button', {
+ type: 'button', className: 'bt-side-send', 'aria-label': t('Send message'),
+ disabled: busy || draft.trim() === '' || typeof actions?.askSide !== 'function', onClick: ask,
+ }, h(ArrowUpIcon)),
fail !== null ? h('p', { className: 'bt-side-fail' }, fail) : null))
}
@@ -133,8 +140,11 @@ export const SIDE_CSS = `
.bt-side-a{display:flex;flex-direction:column;gap:8px;align-items:flex-start;font-size:13px;line-height:19px;color:var(--bt-ink)}
.bt-side-status{margin:0;font-size:12px;color:var(--bt-ink-3)}
.bt-side-fail{margin:0;font-size:12px;line-height:17px;color:var(--bt-danger)}
-.bt-side-form{flex:none;padding:10px 14px 14px;border-top:.5px solid var(--bt-line)}
-.bt-side-input{display:block;width:100%;box-sizing:border-box;min-height:36px;max-height:120px;padding:8px 12px;border:.5px solid var(--bt-line-2);border-radius:12px;background:var(--bt-main);color:var(--bt-ink);font:inherit;font-size:13px;line-height:19px;resize:none;outline:none;field-sizing:content}
+.bt-side-form{flex:none;padding:10px 14px 14px;border-top:.5px solid var(--bt-line);display:flex;flex-wrap:wrap;align-items:flex-end;gap:8px}
+.bt-side-form>.bt-side-fail{flex-basis:100%}
+.bt-side-send{width:36px;height:36px;border-radius:50%;border:0;background:var(--bt-accent);color:var(--bt-accent-ink,#fff);display:inline-flex;align-items:center;justify-content:center;cursor:pointer;flex:none}
+.bt-side-send:disabled{opacity:.3;cursor:default}
+.bt-side-input{display:block;flex:1;min-width:0;box-sizing:border-box;min-height:36px;max-height:120px;padding:8px 12px;border:.5px solid var(--bt-line-2);border-radius:12px;background:var(--bt-main);color:var(--bt-ink);font:inherit;font-size:13px;line-height:19px;resize:none;outline:none;field-sizing:content}
.bt-side-input::placeholder{color:var(--bt-ink-3)}
.bt-side-input:focus{border-color:var(--bt-accent)}
.bt-side-input:disabled{opacity:.6}
diff --git a/ds-bot/src/client/styles.js b/ds-bot/src/client/styles.js
index a3bbe26d..c9ca17ce 100644
--- a/ds-bot/src/client/styles.js
+++ b/ds-bot/src/client/styles.js
@@ -15,7 +15,7 @@ import { SPRING_SHAPE, SPRING_TAP, SPRING_STRETCH, SPRING_POP, spring } from './
export const SHELL_CSS = `
body{--bt-ink:#141414;--bt-danger:#e02135;--bt-ink-2:rgba(20,20,20,.6);--bt-ink-3:rgba(20,20,20,.36);--bt-bubble:#eeeeee;--bt-sidebar:#f7f7f7;--bt-main:#fcfcfc;--bt-line:rgba(20,20,20,.08);--bt-line-2:rgba(20,20,20,.15);--bt-line-weak:rgba(20,20,20,.1);--bt-hover:rgba(119,119,119,.09);--bt-active:rgba(119,119,119,.17);--bt-card:#ffffff;--bt-accent:#4d6bfe;--bt-green:#00c972;--bt-star:#ff9800;--bt-user:#070707;--bt-user-ink:#fcfcfc;--bt-tag-bg:rgba(20,20,20,.06);--bt-tag-ink:rgba(20,20,20,.56);--bt-knob:#ffffff;--bt-glass-bg:color-mix(in srgb,var(--bt-main) 78%,transparent);--bt-glass-border:rgba(255,255,255,.72);--bt-glass-rim:rgba(20,20,20,.09);--bt-glass-shadow:0 8px 28px -6px rgba(0,0,0,.08),0 2px 6px -1px rgba(0,0,0,.04),inset 0 1px 0 rgba(255,255,255,.82);-webkit-tap-highlight-color:transparent;-webkit-text-size-adjust:100%;--bt-font:var(--dsw-font-family,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif)}
/* iOS waits out a double-tap zoom on buttons; the plugin's own controls never zoom. */
-:is(.bt-tool,.bt-uaction,.bt-menu button,.bt-menu-item,.bt-icon-btn,.bt-round,.bt-pill,.bt-account,.bt-set-row,.bt-settings-item,.bt-react-strip button,.bt-palette-row,.bt-palette-clear,.bt-tab,.bt-ptab,.bt-ptab-x,.bt-bcard-x,.bt-plus,.bt-q-btn,.bt-q-x,.bt-x,.bt-nc-send,.bt-send,.bt-soft,.bt-mini,.bt-shape,.bt-swatch,.bt-color,.bt-newchat,.bt-task-day,.bt-task-remove,.bt-fb-btn){touch-action:manipulation}
+:is(.bt-tool,.bt-uaction,.bt-menu button,.bt-menu-item,.bt-icon-btn,.bt-round,.bt-pill,.bt-account,.bt-set-row,.bt-settings-item,.bt-react-strip button,.bt-palette-row,.bt-palette-clear,.bt-tab,.bt-ptab,.bt-ptab-x,.bt-bcard-x,.bt-plus,.bt-q-btn,.bt-q-x,.bt-x,.bt-nc-send,.bt-send,.bt-soft,.bt-mini,.bt-side-send,.bt-shape,.bt-swatch,.bt-color,.bt-newchat,.bt-task-day,.bt-task-remove,.bt-fb-btn){touch-action:manipulation}
:is(.bt-round,.bt-you,.bt-account,.bt-color,.bt-color span,.bt-swatch,.bt-icon-btn,.bt-avatar-trigger,.bt-avatar-pencil,.bt-plus,.bt-mic,.bt-voice){corner-shape:round}
body[data-ds-dark-theme]{--bt-ink:#f2f2f2;--bt-ink-2:rgba(242,242,242,.6);--bt-ink-3:rgba(242,242,242,.36);--bt-bubble:#262626;--bt-sidebar:#1b1b1b;--bt-main:#141414;--bt-line:rgba(255,255,255,.08);--bt-line-2:rgba(255,255,255,.15);--bt-line-weak:rgba(255,255,255,.1);--bt-hover:rgba(160,160,160,.12);--bt-active:rgba(160,160,160,.2);--bt-card:#1f1f1f;--bt-user:#f2f2f2;--bt-user-ink:#141414;--bt-tag-bg:rgba(255,255,255,.09);--bt-tag-ink:rgba(242,242,242,.62);--bt-glass-bg:color-mix(in srgb,var(--bt-main) 74%,transparent);--bt-glass-border:rgba(255,255,255,.13);--bt-glass-rim:rgba(255,255,255,.11);--bt-glass-shadow:0 12px 32px -6px rgba(0,0,0,.42),0 2px 8px -1px rgba(0,0,0,.28),inset 0 1px 0 rgba(255,255,255,.12)}
${Object.entries(INKS).map(([name, [light]]) => `body{--bt-ink-${name}:${light}}`).join('')}
diff --git a/ds-bot/test/side-chat-view.test.js b/ds-bot/test/side-chat-view.test.js
new file mode 100644
index 00000000..d483842b
--- /dev/null
+++ b/ds-bot/test/side-chat-view.test.js
@@ -0,0 +1,164 @@
+import assert from 'node:assert/strict'
+import { test } from 'node:test'
+import { fileURLToPath } from 'node:url'
+import { runInNewContext } from 'node:vm'
+import { build } from 'esbuild'
+
+// The side chat's follow-up field shares the composer preference: while Enter sends,
+// a plain Enter asks; off, it is the field's own newline and the send button asks.
+const { outputFiles } = await build({
+ entryPoints: [fileURLToPath(new URL('../src/client/side-chat.js', import.meta.url))],
+ bundle: true, format: 'cjs', platform: 'browser', write: false, logLevel: 'silent',
+ external: ['react', 'react-dom', '@deepseek-ai/dsh-client-ui-primitives'],
+})
+let current
+const slot = (make) => {
+ const index = current.index++
+ return current.slots[index] ??= make()
+}
+const effect = (make, deps) => {
+ const cell = slot(() => ({}))
+ if (!cell.deps || deps === undefined || deps.some((value, index) => value !== cell.deps[index])) {
+ current.effects.push(() => { cell.stop?.(); cell.stop = make(); cell.deps = deps })
+ }
+}
+const react = {
+ Fragment: 'fragment',
+ createElement: (type, props, ...children) => ({ type, props: { ...props, children } }),
+ useState: (initial) => {
+ const cell = slot(() => ({ value: typeof initial === 'function' ? initial() : initial }))
+ return [cell.value, next => { cell.value = typeof next === 'function' ? next(cell.value) : next }]
+ },
+ useRef: initial => slot(() => ({ current: initial })),
+ useEffect: effect, useLayoutEffect: effect,
+ useMemo: make => make(),
+ useCallback: fn => fn,
+}
+const module = { exports: {} }
+runInNewContext(outputFiles[0].text, {
+ module, exports: module.exports,
+ require: (name) => {
+ if (name === 'react') return react
+ if (name === 'react-dom') return { createPortal: node => node }
+ if (name === '@deepseek-ai/dsh-client-ui-primitives') return { FishLogo: 'fish', MarkdownText: () => null, writeClipboard: () => {} }
+ throw new Error(`no platform module ${name}`)
+ },
+ window: { addEventListener() {}, removeEventListener() {} },
+ document: { querySelector: () => null, documentElement: { addEventListener() {}, removeEventListener() {} } },
+ requestAnimationFrame: () => 0, cancelAnimationFrame() {}, performance: { now: () => 0 },
+ fetch: () => { throw new Error('no fetch in test') },
+})
+const { SideChatView } = module.exports
+const mount = (props) => {
+ const instance = {
+ slots: [], effects: [], props,
+ render(next = instance.props) {
+ instance.props = next
+ instance.index = 0
+ current = instance
+ const out = SideChatView(next)
+ current = undefined
+ for (const run of instance.effects.splice(0)) run()
+ return out
+ },
+ }
+ return instance
+}
+const all = (node, check) => {
+ if (Array.isArray(node)) return node.flatMap(child => all(child, check))
+ if (!node || typeof node !== 'object') return []
+ return [...(check(node) ? [node] : []), ...all(node.props.children, check)]
+}
+const textarea = node => all(node, child => child.type === 'textarea')[0]
+const sendButton = node => all(node, child => child.type === 'button' && child.props?.className === 'bt-side-send')[0]
+const enter = (extra = {}) => ({
+ key: 'Enter', shiftKey: false, nativeEvent: { isComposing: false }, prevented: false,
+ preventDefault() { this.prevented = true }, ...extra,
+})
+const tick = () => new Promise(resolve => setImmediate(resolve))
+const plain = value => JSON.parse(JSON.stringify(value))
+
+const chat = {
+ id: 'c1',
+ entries: [{ id: 'e1', question: 'What ran?', answer: 'Two reads.', status: 'answered' }],
+}
+// Mounts the view, types a follow-up, and returns the rendered tree accessor.
+const view = (prefs, ready = true) => {
+ const asked = []
+ const instance = mount({
+ subject: 'b1', chat,
+ roster: { ready, prefs },
+ actions: { askSide: async (subject, chatId, text) => { asked.push([subject, chatId, text]) } },
+ })
+ textarea(instance.render()).props.onChange({ target: { value: 'and then?' } })
+ return { asked, tree: () => instance.render() }
+}
+
+test('with Enter sending on, a plain Enter asks the follow-up and clears the draft', async () => {
+ const { asked, tree } = view({ enterToSend: true })
+ const event = enter()
+ textarea(tree()).props.onKeyDown(event)
+ await tick()
+ assert.equal(event.prevented, true)
+ assert.deepEqual(plain(asked), [['b1', 'c1', 'and then?']])
+ assert.equal(textarea(tree()).props.value, '')
+})
+
+test('with Enter sending off, a plain Enter is a newline and the send button asks', async () => {
+ const { asked, tree } = view({ enterToSend: false })
+ const event = enter()
+ textarea(tree()).props.onKeyDown(event)
+ await tick()
+ assert.equal(event.prevented, false)
+ assert.deepEqual(plain(asked), [])
+ assert.equal(textarea(tree()).props.value, 'and then?')
+ // The explicit send control carries the same ask.
+ sendButton(tree()).props.onClick()
+ await tick()
+ assert.deepEqual(plain(asked), [['b1', 'c1', 'and then?']])
+ assert.equal(textarea(tree()).props.value, '')
+})
+
+test('a roster still loading keeps a saved off and a first-time default', async () => {
+ // The pre-pull roster stays ready:false but already carries the window's saved prefs.
+ const saved = view({ enterToSend: false }, false)
+ const off = enter()
+ textarea(saved.tree()).props.onKeyDown(off)
+ await tick()
+ assert.equal(off.prevented, false)
+ assert.deepEqual(plain(saved.asked), [])
+ // A window with nothing saved keeps the default: Enter sends, it is not stuck off.
+ const fresh = view({}, false)
+ const on = enter()
+ textarea(fresh.tree()).props.onKeyDown(on)
+ await tick()
+ assert.equal(on.prevented, true)
+ assert.deepEqual(plain(fresh.asked), [['b1', 'c1', 'and then?']])
+})
+
+test('Shift+Enter and IME confirmation keep their default behavior', async () => {
+ for (const extra of [{ shiftKey: true }, { nativeEvent: { isComposing: true } }]) {
+ const { asked, tree } = view({ enterToSend: true })
+ const event = enter(extra)
+ textarea(tree()).props.onKeyDown(event)
+ await tick()
+ assert.equal(event.prevented, false)
+ assert.deepEqual(plain(asked), [])
+ }
+})
+
+test('while an answer runs, Enter and the send button stay quiet', async () => {
+ const answering = { id: 'c1', entries: [{ id: 'e1', question: 'q', status: 'answering' }] }
+ const asked = []
+ const instance = mount({
+ subject: 'b1', chat: answering,
+ roster: { ready: true, prefs: { enterToSend: true } },
+ actions: { askSide: async (...args) => { asked.push(args) } },
+ })
+ const event = enter()
+ textarea(instance.render()).props.onKeyDown(event)
+ await tick()
+ assert.equal(event.prevented, true)
+ assert.deepEqual(plain(asked), [])
+ assert.equal(sendButton(instance.render()).props.disabled, true)
+})