Skip to content

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

Revert the file-attach fallback; DSH's own input serves Bot chats

Fei2411a9c0b81e98f5
diff --git a/app/ui/src/app.css b/app/ui/src/app.css
index b1a3c8e3..85d37844 100644
--- a/app/ui/src/app.css
+++ b/app/ui/src/app.css
@@ -72,11 +72,6 @@ html[data-mac] .dsb-frame .dsb-side{padding-top:var(--dsb-band)}
[data-composer-card]:has(.dsb-send:disabled) .bt-voice{display:inline-grid}
body[data-bt-room] [data-composer-card]:has(.dsb-send:disabled) .bt-mic:not([aria-pressed=true]){background:var(--bt-accent);color:var(--bt-accent-ink,#fff)}
.dsb-composer-error{margin:0 0 6px 4px;font-size:12px;line-height:16px;color:var(--bt-danger)}
-.dsb-files{flex:0 0 100%;order:0;display:flex;flex-wrap:wrap;gap:6px;padding:2px 8px 6px}
-.dsb-file{display:inline-flex;align-items:center;gap:6px;max-width:220px;padding:3px 6px 3px 10px;border-radius:8px;background:var(--bt-hover);font-size:12px;line-height:16px;color:var(--bt-ink)}
-.dsb-file-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
-.dsb-file button{flex:none;width:16px;height:16px;border:0;border-radius:50%;padding:0;background:none;color:var(--bt-ink-2);cursor:pointer;display:inline-grid;place-items:center}
-.dsb-file button:hover{background:var(--bt-active);color:var(--bt-ink)}
/* Markdown in the bubbles (primitives.js). */
.md_markdown{overflow-wrap:anywhere}
diff --git a/app/ui/src/chat.js b/app/ui/src/chat.js
index 97951d67..09a31729 100644
--- a/app/ui/src/chat.js
+++ b/app/ui/src/chat.js
@@ -72,12 +72,12 @@ function useChat(botId, part, feed) {
}), [feed, botId, load])
// Shown at once: the message can come back on the feed before the request returns.
- const send = async (text, actions, sessionId, attachments) => {
+ const send = async (text, actions, sessionId) => {
const entry = { kind: 'user', text, time: Date.now() }
setPending(list => [...list, entry])
actions.noteSent(sessionId)
try {
- await actions.send(sessionId, text, attachments)
+ await actions.send(sessionId, text)
} catch (error) {
setPending(list => list.filter(item => item !== entry))
throw error
@@ -87,34 +87,22 @@ function useChat(botId, part, feed) {
}
// What the Bot views' voice button asks of a composer (DSH's composer in the plugin):
-// where the caret is, and text put in there. `addFiles` takes the "+" menu's picked
-// files into the attachments waiting on the draft.
-function useInput(field, setText, addFiles) {
+// where the caret is, and text put in there.
+function useInput(field, setText) {
return useMemo(() => ({
captureInsertion: () => (field.current ? { start: field.current.selectionStart, end: field.current.selectionEnd } : null),
insertText: (value, at) => setText((current) => {
const start = Math.min(at?.start ?? current.length, current.length)
return current.slice(0, start) + value + current.slice(Math.max(start, at?.end ?? start))
}),
- addFiles,
- }), [field, setText, addFiles])
-}
-
-// The api channel takes base64 attachments: images ride the prompt as image parts,
-// every other file is staged first and named by its receipt.
-const encodeFile = async (file) => {
- const bytes = new Uint8Array(await file.arrayBuffer())
- let binary = ''
- for (let at = 0; at < bytes.length; at += 0x8000) binary += String.fromCharCode(...bytes.subarray(at, at + 0x8000))
- return { name: file.name, mediaType: file.type || 'application/octet-stream', data: btoa(binary) }
+ }), [field, setText])
}
function Composer({ sessionId, placeholder, disabled, onSend, actions, useUi, useRoster }) {
const [text, setText] = useState('')
- const [files, setFiles] = useState([])
const [error, setError] = useState(null)
const field = useRef(null)
- const inputActions = useInput(field, setText, useCallback(picked => setFiles(list => [...list, ...picked]), []))
+ const inputActions = useInput(field, setText)
useLayoutEffect(() => {
const node = field.current
node.style.height = 'auto'
@@ -123,33 +111,19 @@ function Composer({ sessionId, placeholder, disabled, onSend, actions, useUi, us
useEffect(() => { if (!disabled) field.current?.focus() }, [sessionId, disabled])
const submit = async () => {
const value = text.trim()
- if ((value === '' && files.length === 0) || disabled) return
+ if (value === '' || disabled) return
setError(null)
- let uploads
- try {
- uploads = await Promise.all(files.map(encodeFile))
- } catch {
- setError(t('The file could not be read'))
- return
- }
- const sent = files
setText('')
- setFiles([])
try {
- await onSend(value, uploads)
+ await onSend(value)
} catch (failure) {
setText(current => (current === '' ? value : current))
- setFiles(sent)
setError(failure.message)
}
}
return h('div', { className: 'dsb-composer-wrap' },
error ? h('p', { className: 'dsb-composer-error', role: 'alert' }, error) : null,
- h('div', { className: 'dsb-composer', 'data-composer-card': '', 'data-multiline': text.includes('\n') || files.length > 0 || undefined },
- files.length > 0 ? h('div', { className: 'dsb-files' },
- files.map((file, index) => h('span', { className: 'dsb-file', key: `${file.name}-${index}` },
- h('span', { className: 'dsb-file-name' }, file.name),
- h('button', { type: 'button', 'aria-label': t('Remove'), title: t('Remove'), onClick: () => setFiles(list => list.filter((_, at) => at !== index)) }, '×'))))) : null,
+ h('div', { className: 'dsb-composer', 'data-composer-card': '', 'data-multiline': text.includes('\n') || undefined },
h('div', { className: 'dsb-composer-tools' }, h(ComposerPlus, { sessionId, inputActions, useRoster, actions })),
h('div', { className: 'dsb-composer-input', 'data-input-scroll': '' },
h('textarea', {
@@ -170,7 +144,7 @@ function Composer({ sessionId, placeholder, disabled, onSend, actions, useUi, us
})),
h('div', { className: 'dsb-composer-trailing' },
h(ComposerVoice, { sessionId, inputActions, actions, useUi }),
- h('button', { type: 'button', className: 'dsb-send', disabled: disabled || (text.trim() === '' && files.length === 0), 'aria-label': t('Send message'), title: t('Send message'), onClick: () => { void submit() } }, h(ArrowUpIcon)))))
+ h('button', { type: 'button', className: 'dsb-send', disabled: disabled || text.trim() === '', 'aria-label': t('Send message'), title: t('Send message'), onClick: () => { void submit() } }, h(ArrowUpIcon)))))
}
// One conversation in the main view, drawn with the Bot views' own rows, cards and docks.
@@ -219,7 +193,7 @@ export function Chat({ sessionId, team }) {
sessionId,
disabled: waiting,
placeholder: waiting ? t('Pick a model and {name} can start.', { name }) : name ? t('Message {name}', { name }) : t('Message'),
- onSend: (text, attachments) => send(text, actions, sessionId, attachments),
+ onSend: text => send(text, actions, sessionId),
actions,
useUi: hooks.useUi,
useRoster: hooks.useRoster,
diff --git a/app/ui/src/team.js b/app/ui/src/team.js
index 6c187005..7c195333 100644
--- a/app/ui/src/team.js
+++ b/app/ui/src/team.js
@@ -178,8 +178,6 @@ export function createTeam() {
providerModels: body => call('provider-models', body),
removeProvider: provider => after(call('provider-remove', { provider })),
openModels: () => actions.openSettings('models'),
- // Files picked through the "+" menu's own input wait in the composer as attachments.
- attachFiles: (sessionId, files, inputActions) => inputActions?.addFiles?.(files),
// Nothing else draws in the window: no shell panels, right sidebar, "@" menu or voice plugin.
hasRightSidebar: () => false,
canReferenceChat: () => false,
diff --git a/ds-bot/client.js b/ds-bot/client.js
index 9f6618a2..cc54a653 100644
--- a/ds-bot/client.js
+++ b/ds-bot/client.js
@@ -1690,7 +1690,7 @@ function teamActions({ call: call2, after, partFor, roster, ui: ui2, live, cards
setMain: (id, main = true, options = {}) => after(call2("set-main", { id, main, ...options })),
updateRoom: (id, patch) => after(call2("update-room", { id, ...patch })),
continueRoom: (roomId) => after(call2("room-continue", { roomId })),
- send: (sessionId, text, attachments) => after(call2("send", { sessionId: partFor(sessionId), text, ...attachments?.length ? { attachments } : {} })),
+ send: (sessionId, text) => after(call2("send", { sessionId: partFor(sessionId), text })),
answerQuestion: (sessionId, questionId, answer) => after(call2("answer-question", { sessionId: partFor(sessionId), questionId, answer })),
dismissQuestion: (sessionId) => after(call2("dismiss-question", { sessionId })),
answerView: (sessionId, viewId, action, values) => after(call2("view-reply", { sessionId: partFor(sessionId), viewId, action, values })),
@@ -10535,7 +10535,6 @@ function ComposerPlus({ sessionId, inputActions, useRoster, actions }) {
const [shown, leaving] = useLinger(open, 120);
const button = (0, import_react20.useRef)(null);
const menu = (0, import_react20.useRef)(null);
- const ownInput = (0, import_react20.useRef)(null);
const tick = useViewport();
(0, import_react20.useEffect)(() => {
if (!open) return void 0;
@@ -10557,17 +10556,18 @@ function ComposerPlus({ sessionId, inputActions, useRoster, actions }) {
}, [open]);
const target = roster.byId?.[sessionId]?.id ?? roster.roomsById?.[sessionId]?.id;
if (sessionId === void 0 || target === void 0) return null;
- const fileInput = () => button.current?.closest("[data-composer-card]")?.querySelector("input[type=file]:not([data-bot-files]):not(:disabled)") ?? ownInput.current;
- const toggle = () => setOpen(open ? null : {});
+ const fileInput = () => button.current?.closest("[data-composer-card]")?.querySelector("input[type=file]");
+ const toggle = () => {
+ if (open) {
+ setOpen(null);
+ return;
+ }
+ setOpen({ files: Boolean(fileInput()) });
+ };
const attach = () => {
setOpen(null);
fileInput()?.click();
};
- const onPick = (event) => {
- const picked = event.target.files === null ? [] : [...event.target.files];
- event.target.value = "";
- if (picked.length > 0) void actions.attachFiles?.(sessionId, picked, inputActions);
- };
const schedule = () => {
setOpen(null);
actions.openSettings("schedules", target);
@@ -10585,7 +10585,6 @@ function ComposerPlus({ sessionId, inputActions, useRoster, actions }) {
return (0, import_react20.createElement)(
import_react20.Fragment,
null,
- (0, import_react20.createElement)("input", { ref: ownInput, "data-bot-files": "", type: "file", multiple: true, hidden: true, onChange: onPick }),
(0, import_react20.createElement)("button", {
ref: button,
type: "button",
@@ -10607,7 +10606,7 @@ function ComposerPlus({ sessionId, inputActions, useRoster, actions }) {
style: place ?? {},
"data-leaving": leaving || void 0
},
- (0, import_react20.createElement)("button", { type: "button", role: "menuitem", onClick: attach }, (0, import_react20.createElement)(PaperclipIcon), (0, import_react20.createElement)("span", { className: "bt-menu-label" }, t("Add files"))),
+ shown.files ? (0, import_react20.createElement)("button", { type: "button", role: "menuitem", onClick: attach }, (0, import_react20.createElement)(PaperclipIcon), (0, import_react20.createElement)("span", { className: "bt-menu-label" }, t("Add files"))) : null,
canReference ? (0, import_react20.createElement)("button", { type: "button", role: "menuitem", onMouseDown: keepComposerFocus, onClick: reference }, (0, import_react20.createElement)(ChatsIcon), (0, import_react20.createElement)("span", { className: "bt-menu-label" }, t("Reference a chat"))) : null,
(0, import_react20.createElement)("button", { type: "button", role: "menuitem", onClick: schedule }, (0, import_react20.createElement)(ClockIcon), (0, import_react20.createElement)("span", { className: "bt-menu-label" }, t("Scheduled task")))
), document.body) : null
@@ -21036,16 +21035,6 @@ function apply(ctx) {
return () => fiber.dispose();
};
actions.canReferenceChat = () => atMenu !== null;
- actions.attachFiles = (sessionId, files, inputActions) => {
- const conversation = ctx.conversation;
- if (conversation === void 0 || typeof inputActions?.addAttachments !== "function") return false;
- const drafts = conversation.createDrafts(sessionId, files);
- if (!inputActions.addAttachments(drafts.map((draft) => draft.id))) {
- conversation.releaseDraftAttachments(drafts);
- return false;
- }
- return true;
- };
actions.referenceChat = (sessionId, span) => {
const controller = atMenu?.controllerOf(sessionId);
if (controller === void 0 || span === void 0) return;
diff --git a/ds-bot/src/client/composer.js b/ds-bot/src/client/composer.js
index f86e2250..08d3b669 100644
--- a/ds-bot/src/client/composer.js
+++ b/ds-bot/src/client/composer.js
@@ -112,7 +112,6 @@ export function ComposerPlus({ sessionId, inputActions, useRoster, actions }) {
const [shown, leaving] = useLinger(open, 120)
const button = useRef(null)
const menu = useRef(null)
- const ownInput = useRef(null)
const tick = useViewport()
useEffect(() => {
if (!open) return undefined
@@ -124,19 +123,16 @@ export function ComposerPlus({ sessionId, inputActions, useRoster, actions }) {
}, [open])
const target = roster.byId?.[sessionId]?.id ?? roster.roomsById?.[sessionId]?.id
if (sessionId === undefined || target === undefined) return null
- // The shell's own file input wins where the composer has one (its intake checks apply);
- // elsewhere — the app's own composer — the "+" keeps its own input.
- const fileInput = () => button.current?.closest('[data-composer-card]')?.querySelector('input[type=file]:not([data-bot-files]):not(:disabled)') ?? ownInput.current
- const toggle = () => setOpen(open ? null : {})
+ const fileInput = () => button.current?.closest('[data-composer-card]')?.querySelector('input[type=file]')
+ const toggle = () => {
+ if (open) { setOpen(null); return }
+ // Files go through the composer's own file input; a composer without one takes none.
+ setOpen({ files: Boolean(fileInput()) })
+ }
const attach = () => {
setOpen(null)
fileInput()?.click()
}
- const onPick = (event) => {
- const picked = event.target.files === null ? [] : [...event.target.files]
- event.target.value = ''
- if (picked.length > 0) void actions.attachFiles?.(sessionId, picked, inputActions)
- }
const schedule = () => {
setOpen(null)
actions.openSettings('schedules', target)
@@ -156,7 +152,6 @@ export function ComposerPlus({ sessionId, inputActions, useRoster, actions }) {
return { left: rect.left, bottom: viewBottom() - rect.top + 8 }
}, [shown, open, tick])
return h(Fragment, null,
- h('input', { ref: ownInput, 'data-bot-files': '', type: 'file', multiple: true, hidden: true, onChange: onPick }),
h('button', {
ref: button, type: 'button', className: 'bt-plus', 'aria-label': t('Add'), title: t('Add'),
'aria-haspopup': 'menu', 'aria-expanded': Boolean(open), onMouseDown: keepComposerFocus, onClick: toggle,
@@ -165,7 +160,7 @@ export function ComposerPlus({ sessionId, inputActions, useRoster, actions }) {
ref: menu, className: 'bt-menu bt-menu-up bt-plus-menu', role: 'menu', 'aria-label': t('Add'),
style: place ?? {}, 'data-leaving': leaving || undefined,
},
- h('button', { type: 'button', role: 'menuitem', onClick: attach }, h(PaperclipIcon), h('span', { className: 'bt-menu-label' }, t('Add files'))),
+ shown.files ? h('button', { type: 'button', role: 'menuitem', onClick: attach }, h(PaperclipIcon), h('span', { className: 'bt-menu-label' }, t('Add files'))) : null,
canReference ? h('button', { type: 'button', role: 'menuitem', onMouseDown: keepComposerFocus, onClick: reference }, h(ChatsIcon), h('span', { className: 'bt-menu-label' }, t('Reference a chat'))) : null,
h('button', { type: 'button', role: 'menuitem', onClick: schedule }, h(ClockIcon), h('span', { className: 'bt-menu-label' }, t('Scheduled task')))), document.body) : null)
}
diff --git a/ds-bot/src/client/index.js b/ds-bot/src/client/index.js
index 28dcac3b..31f66057 100644
--- a/ds-bot/src/client/index.js
+++ b/ds-bot/src/client/index.js
@@ -819,18 +819,6 @@ export function apply(ctx) {
return () => fiber.dispose()
}
actions.canReferenceChat = () => atMenu !== null
- // Where the composer's "+" picked files through its own input (the shell's input is
- // preferred when the composer has one), they land in the shell's draft rail.
- actions.attachFiles = (sessionId, files, inputActions) => {
- const conversation = ctx.conversation
- if (conversation === undefined || typeof inputActions?.addAttachments !== 'function') return false
- const drafts = conversation.createDrafts(sessionId, files)
- if (!inputActions.addAttachments(drafts.map(draft => draft.id))) {
- conversation.releaseDraftAttachments(drafts)
- return false
- }
- return true
- }
actions.referenceChat = (sessionId, span) => {
const controller = atMenu?.controllerOf(sessionId)
if (controller === undefined || span === undefined) return
diff --git a/ds-bot/src/client/team-actions.js b/ds-bot/src/client/team-actions.js
index 8f503884..47d791d4 100644
--- a/ds-bot/src/client/team-actions.js
+++ b/ds-bot/src/client/team-actions.js
@@ -105,7 +105,7 @@ export function teamActions({ call, after, partFor, roster, ui, live, cards, hel
setMain: (id, main = true, options = {}) => after(call('set-main', { id, main, ...options })),
updateRoom: (id, patch) => after(call('update-room', { id, ...patch })),
continueRoom: roomId => after(call('room-continue', { roomId })),
- send: (sessionId, text, attachments) => after(call('send', { sessionId: partFor(sessionId), text, ...(attachments?.length ? { attachments } : {}) })),
+ send: (sessionId, text) => after(call('send', { sessionId: partFor(sessionId), text })),
answerQuestion: (sessionId, questionId, answer) => after(call('answer-question', { sessionId: partFor(sessionId), questionId, answer })),
dismissQuestion: sessionId => after(call('dismiss-question', { sessionId })),
answerView: (sessionId, viewId, action, values) => after(call('view-reply', { sessionId: partFor(sessionId), viewId, action, values })),
diff --git a/ds-bot/src/host/channel.js b/ds-bot/src/host/channel.js
index 20a1cae3..3fc5c7c6 100644
--- a/ds-bot/src/host/channel.js
+++ b/ds-bot/src/host/channel.js
@@ -10,8 +10,6 @@ import { COLORS, EXTRA_COLORS, ROUTE } from './constants.js'
const LANGUAGES = { zh: 'Chinese (简体中文)', en: 'English' }
const RUN_STATS = ['sessionStats', 'tokenUsage', 'contextPressure']
-// The media types the prompt admission takes as images; every other upload goes as a file.
-const IMAGE_MEDIA_TYPES = new Set(['image/png', 'image/jpeg', 'image/webp', 'image/gif'])
const invalid = message => Object.assign(new Error(message), { code: 'bot/invalid' })
// Programming and file system errors are DS Bot's own faults, logged with their stack;
@@ -428,38 +426,17 @@ export function install(rt) {
}
case 'send': {
const text = String(body.text ?? '').trim()
- // Base64 uploads from a window's own file input (the app composer's "+"; the
- // plugin composes them through the shell's draft rail instead).
- const uploads = Array.isArray(body.attachments) ? body.attachments.slice(0, 16) : []
- if ((text === '' && uploads.length === 0) || typeof body.sessionId !== 'string') return fail('Nothing to send', 'bot/invalid')
+ if (text === '' || typeof body.sessionId !== 'string') return fail('Nothing to send', 'bot/invalid')
await rt.load()
// A Bot id or an earlier part of its own chat means the current part.
const past = rt.pastOwners.get(body.sessionId)
const sessionId = rt.botOf(body.sessionId) ? rt.chatOf(body.sessionId) : past && past.roomId === undefined ? rt.chatOf(past.botId) : body.sessionId
await rt.ensureCapabilities(sessionId)
- const content = []
- if (text !== '') content.push({ type: 'text', text })
- for (const upload of uploads) {
- const name = String(upload?.name ?? '').slice(0, 260) || 'attachment'
- const data = String(upload?.data ?? '')
- if (!/^[A-Za-z0-9+/]+={0,2}$/.test(data)) return fail('Bad attachment data', 'bot/invalid')
- const mediaType = String(upload?.mediaType ?? '')
- if (IMAGE_MEDIA_TYPES.has(mediaType)) {
- content.push({ type: 'image', mediaType, data, name })
- continue
- }
- const fileUploads = ctx.get?.('fileUploads')
- if (fileUploads === undefined) return fail('Files cannot be attached here', 'bot/unavailable')
- const bytes = Buffer.from(data, 'base64')
- async function* once() { yield new Uint8Array(bytes) }
- const { receiptId } = await fileUploads.uploadStream({ sessionId, data: once(), name })
- content.push({ type: 'file', receiptId })
- }
await ctx.sessionController.prompt({
requestId: randomUUID(),
sessionId,
mode: 'queue',
- content,
+ content: [{ type: 'text', text }],
}, AbortSignal.timeout(30_000))
return ok(true)
}