Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions docs/plans/2026-11-06-operator-tasks-origin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Operator Tasks, and the A · U badge

## Why

The Bot details panel listed two things: what the Bot was working on (Active Tasks) and
what waited on the user (Unresolved Tasks). Nothing said whether the Bot was working on
the user's own ask or on another Bot's work, so the panel could not answer the one
question the operator has while several Bots run at once: who is doing what I asked for.

This adds a third list, Operator Tasks, above Active Tasks, and replaces the single
unresolved count in the chat header with two numbers, `A · U`.

## What an Operator Task is

A job is the user's when it started from any of:

- a message the user sent to the Bot's own chat, including one they steered into a
running turn;
- a task the user scheduled for that Bot;
- an order relayed by a manager Bot on the user's behalf, hop by hop (Igor to a coding
Bot, and on to a Bot that coding Bot asked).

It leaves the list when the Bot's turn for that job ends, which is when the Bot sends
its reply. A job that is waiting on another Bot stays listed, through the open work it
holds (`state.works`), until the result comes back and the reply that carries it is sent.

Group chat work stays in Active Tasks. A post in a group is queued as a room message,
not a user turn, and the group already shows who was called.

## How the origin is recorded

Nothing recorded where a task came from, so the host now records it in three places:

- `src/host/turns.js`: the running turn of a Session carries `origin: 'operator'` when
it was started by the user, by a schedule, or by a relayed order. `originFrom` names
the manager Bot that passed it on, and `askText` keeps the user's words for the row.
The turn's origin is exposed on `workView`, which is what the panel reads.
- `src/host/delivery.js`: a message sent while its sender works for the operator carries
`origin: 'operator'` on its source, so each relay hop passes the origin on.
- `src/host/handoffs.js`: the work a Bot opens remembers its origin (`openWork`), so the
job keeps it across a restart, and `workOrigin` reads it back.

A relay after a restart falls back to the work it answers, so a job does not lose its
origin when the app restarts mid-job.

## The lists

`src/host/operator-tasks.js` now returns `operator`, `active` and `unresolved` per Bot:

- a running turn whose origin is the operator (kind `ask`, or `relay` with `via`);
- an order whose work carries the operator origin;
- a wait whose open work carries the operator origin, with the age of that work.

An order stands back while the Bot's running turn for the same work is shown, so a job
appears once. No item can be in both lists, since one origin decides the list.

## The badge

`OperatorBadge` in the chat header shows `A · U`: A in the accent colour, U in the
danger colour the count used before, each capped at `99+`, and nothing at all when both
are 0. The panel keeps its three section headings with their own counts.

## The three 11/5 local hotfixes are not in this branch

The installed 0.2.7 also carries three local fixes from the 11/5 DeepSeek Harness 0.2.2
session: the pre-step and seam failure capture in `parts.js`, the tools waterfall guard
in `tools.js`, and the stack on a turn failure in `turns.js`.

They exist only in the installed copy and in `patches/ds-bot@0.2.7.patch`. Adding them to
this branch was tried and reverted: under the branch's pinned DeepSeek Harness
(`0.2.1-rc.5`, also under `0.2.2-rc.1`) they break 27 tests, because they wrap DSH
services (`tools.resolve`, `systemPrompt.assemble`) that the test host does not provide
the same way, and they change the plugin's registration list that `test/install.test.js`
fixes. Porting them is a DeepSeek Harness upgrade job, not a panel change, and the repo
rules forbid patching DSH from the plugin. The regenerated patch is built from the
installed bytes, so the running app keeps all three.

## Verification

- `npm test`, `node scripts/build-client.mjs --check` and `npm run lint` pass.
- `test/operator-tasks.test.js` drives the host: a turn the user starts is an Operator
Task until its reply, a relayed turn carries the origin (a plain team job does not),
the orders and waits land in the right list, and nothing is in both.
- `test/operator-tasks-client.test.js` renders the panel and the badge and asserts the
section order, the labels, the two colours, the `99+` cap and the empty state.
- The mock test bench (`dev/bench.sh`) cannot start on this workstation: WSL has no
distribution and Git Bash has no `setsid`. The panel was rendered from the real
components and the real stylesheet in headless Chromium instead (screenshot in the
session log), and the unit tests above cover the behaviour.
56 changes: 45 additions & 11 deletions ds-bot/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -1174,13 +1174,20 @@ var ZH = {
"New task": "新建任务",
"No scheduled tasks yet.": "还没有定时任务。",
"No scheduled tasks yet. Add one": "还没有定时任务,去添加",
"Operator Tasks": "你交给它的任务",
"Active Tasks": "进行中的任务",
"Unresolved Tasks": "待你处理的任务",
"{title} · {count}": "{title} · {count}",
"Your ask": "你的要求",
"Relayed by {name}": "由 {name} 转达",
"Nothing of yours in hand.": "你交给它的任务都完成了。",
"Nothing running right now.": "现在没有在进行的工作。",
"Nothing waiting on you.": "没有等你处理的事。",
"1 task from you": "有 1 件事来自你",
"{count} tasks from you": "有 {count} 件事来自你",
"1 task waits on you": "有 1 件事等你处理",
"{count} tasks wait on you": "有 {count} 件事等你处理",
"{yours} from you, {waiting} waiting on you": "{yours} 件来自你,{waiting} 件等你处理",
"a teammate": "一位队友",
"a group": "一个群聊",
'in group "{name}"': "在群聊「{name}」里",
Expand Down Expand Up @@ -11262,8 +11269,9 @@ var SIDEBAR_CSS = `

// src/client/operator-tasks.js
var import_react22 = require("react");
var EMPTY = { active: [], unresolved: [] };
var EMPTY = { operator: [], active: [], unresolved: [] };
var operatorTasksOf = (roster, botId) => roster.operatorTasks?.[botId] ?? EMPTY;
var operatorCount = (roster, botId) => operatorTasksOf(roster, botId).operator.length;
var unresolvedCount = (roster, botId) => operatorTasksOf(roster, botId).unresolved.length;
var nameOf = (roster, id) => roster.byId?.[id]?.name ?? roster.roomsById?.[id]?.name ?? t("a teammate");
var where = (roster, item) => item.roomId ? t('in group "{name}"', { name: roster.roomsById?.[item.roomId]?.name ?? t("a group") }) : "";
Expand All @@ -11287,12 +11295,15 @@ function unresolvedLine(item) {
return { label: "", text: item.text ?? "" };
}
}
var doingOf2 = (item) => {
if (item.switching) return t("Moving on to a fresh part");
if (item.tool === void 0) return item.text || t("Working");
return item.target ? t("Running {tool} on {target}", { tool: item.tool, target: item.target }) : t("Running {tool}", { tool: item.tool });
};
function activeLine(item, roster) {
switch (item.kind) {
case "turn": {
const doing = item.switching ? t("Moving on to a fresh part") : item.tool ? item.target ? t("Running {tool} on {target}", { tool: item.tool, target: item.target }) : t("Running {tool}", { tool: item.tool }) : item.text || t("Working");
return { label: t("Working now"), text: [doing, where(roster, item)].filter(Boolean).join(" ") };
}
case "turn":
return { label: t("Working now"), text: [doingOf2(item), where(roster, item)].filter(Boolean).join(" ") };
case "order":
return { label: t("Order"), text: t("From {name}", { name: nameOf(roster, item.from) }) };
case "waiting":
Expand All @@ -11301,6 +11312,16 @@ function activeLine(item, roster) {
return { label: "", text: item.text ?? "" };
}
}
function operatorLine(item, roster) {
switch (item.kind) {
case "ask":
return { label: t("Your ask"), text: doingOf2(item) };
case "relay":
return { label: t("Relayed by {name}", { name: item.via ?? t("a teammate") }), text: doingOf2(item) };
default:
return activeLine(item, roster);
}
}
function TaskList({ title, items, line, roster, empty }) {
return (0, import_react22.createElement)(
"div",
Expand All @@ -11326,14 +11347,24 @@ function TaskList({ title, items, line, roster, empty }) {
function OperatorTasks({ bot, roster }) {
const tasks = operatorTasksOf(roster, bot.id);
return [
(0, import_react22.createElement)(TaskList, { key: "operator", title: t("Operator Tasks"), items: tasks.operator, line: operatorLine, roster, empty: t("Nothing of yours in hand.") }),
(0, import_react22.createElement)(TaskList, { key: "active", title: t("Active Tasks"), items: tasks.active, line: activeLine, roster, empty: t("Nothing running right now.") }),
(0, import_react22.createElement)(TaskList, { key: "unresolved", title: t("Unresolved Tasks"), items: tasks.unresolved, line: unresolvedLine, roster, empty: t("Nothing waiting on you.") })
];
}
function UnresolvedBadge({ count }) {
if (!(count > 0)) return null;
const label = count === 1 ? t("1 task waits on you") : t("{count} tasks wait on you", { count });
return (0, import_react22.createElement)("span", { className: "bt-pill-tasks", title: label, "aria-label": label }, count > 99 ? "99+" : String(count));
var capped = (count) => count > 99 ? "99+" : String(count);
function OperatorBadge({ operator, unresolved }) {
const yours = operator > 0 ? operator : 0;
const waiting = unresolved > 0 ? unresolved : 0;
if (yours === 0 && waiting === 0) return null;
const label = waiting === 0 ? yours === 1 ? t("1 task from you") : t("{count} tasks from you", { count: yours }) : yours === 0 ? waiting === 1 ? t("1 task waits on you") : t("{count} tasks wait on you", { count: waiting }) : t("{yours} from you, {waiting} waiting on you", { yours, waiting });
return (0, import_react22.createElement)(
"span",
{ className: "bt-pill-tasks", title: label, "aria-label": label },
(0, import_react22.createElement)("span", { className: "bt-pill-yours" }, capped(yours)),
(0, import_react22.createElement)("span", { className: "bt-pill-dot", "aria-hidden": true }, "·"),
(0, import_react22.createElement)("span", { className: "bt-pill-waiting" }, capped(waiting))
);
}
var OPERATOR_TASKS_CSS = `
.bt-ops-empty{font-size:12px;line-height:16px;color:var(--bt-ink-3);padding:2px 0}
Expand All @@ -11344,7 +11375,10 @@ var OPERATOR_TASKS_CSS = `
.bt-ops-age{flex:none;font-size:11px;line-height:16px;color:var(--bt-ink-3);font-variant-numeric:tabular-nums;white-space:nowrap}
.bt-ops-text{font-size:12px;line-height:16px;color:var(--bt-ink-2);overflow-wrap:anywhere;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden}
.bt-ops-note{font-size:11px;line-height:15px;color:var(--bt-ink-3);margin-top:2px}
.bt-pill-tasks{flex:none;min-width:18px;height:18px;padding:0 5px;border-radius:999px;background:var(--bt-danger);color:var(--bt-main);font-size:11px;line-height:18px;font-weight:600;text-align:center;font-variant-numeric:tabular-nums}
.bt-pill-tasks{flex:none;display:inline-flex;align-items:center;gap:3px;height:18px;padding:0 6px;border-radius:999px;background:var(--bt-hover);font-size:11px;line-height:18px;font-weight:600;font-variant-numeric:tabular-nums}
.bt-pill-yours{color:var(--bt-accent)}
.bt-pill-waiting{color:var(--bt-danger)}
.bt-pill-dot{color:var(--bt-ink-3);font-weight:400}
`;

// src/client/header.js
Expand Down Expand Up @@ -11460,7 +11494,7 @@ function HeaderPill({ sessionId, useRoster, useSessions, useSessionStatus, useSe
(0, import_react23.createElement)("span", { className: "bt-pill-goal" }, (0, import_react23.createElement)("span", { className: "bt-pill-ico", "aria-hidden": true }, (0, import_react23.createElement)(GoalIcon)), (0, import_react23.createElement)("span", { className: "bt-pill-title" }, view.title)),
(0, import_react23.createElement)("span", { className: "bt-pill-name" }, name)
) : (0, import_react23.createElement)("span", { className: "bt-pill-name" }, away ? t("Back to chat") : bot?.name ?? room2?.name ?? (title || t("New chat"))),
bot && !away ? (0, import_react23.createElement)(UnresolvedBadge, { count: unresolvedCount(roster, bot.id) }) : null,
bot && !away ? (0, import_react23.createElement)(OperatorBadge, { operator: operatorCount(roster, bot.id), unresolved: unresolvedCount(roster, bot.id) }) : null,
goalShown && view?.number !== void 0 ? (0, import_react23.createElement)("span", { className: "bt-pill-count" }, `${view.number}/${view.count}`) : null,
(0, import_react23.createElement)(MemoryNotice, { shown: memoryNotice }),
(0, import_react23.createElement)("span", { className: "bt-pill-go", "aria-hidden": true }, (0, import_react23.createElement)(GoArrow))
Expand Down
4 changes: 2 additions & 2 deletions ds-bot/src/client/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { botState, BotAvatar, RoomAvatar } from './mark.js'
import { ActivityIndicator } from './activity-row.js'
import { clockLabel, openingTurn, unseenSince } from './cells.js'
import { GoalIsland, goalView } from './goal.js'
import { UnresolvedBadge, unresolvedCount } from './operator-tasks.js'
import { OperatorBadge, operatorCount, unresolvedCount } from './operator-tasks.js'
import { viewBottom } from './motion.js'
import { t } from './i18n.js'

Expand Down Expand Up @@ -128,7 +128,7 @@ export function HeaderPill({ sessionId, useRoster, useSessions, useSessionStatus
h('span', { className: 'bt-pill-goal' }, h('span', { className: 'bt-pill-ico', 'aria-hidden': true }, h(GoalIcon)), h('span', { className: 'bt-pill-title' }, view.title)),
h('span', { className: 'bt-pill-name' }, name))
: h('span', { className: 'bt-pill-name' }, away ? t('Back to chat') : bot?.name ?? room?.name ?? (title || t('New chat'))),
bot && !away ? h(UnresolvedBadge, { count: unresolvedCount(roster, bot.id) }) : null,
bot && !away ? h(OperatorBadge, { operator: operatorCount(roster, bot.id), unresolved: unresolvedCount(roster, bot.id) }) : null,
goalShown && view?.number !== undefined ? h('span', { className: 'bt-pill-count' }, `${view.number}/${view.count}`) : null,
h(MemoryNotice, { shown: memoryNotice }),
h('span', { className: 'bt-pill-go', 'aria-hidden': true }, h(GoArrow)))
Expand Down
7 changes: 7 additions & 0 deletions ds-bot/src/client/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -1127,13 +1127,20 @@ const ZH = {
'New task': '新建任务',
'No scheduled tasks yet.': '还没有定时任务。',
'No scheduled tasks yet. Add one': '还没有定时任务,去添加',
'Operator Tasks': '你交给它的任务',
'Active Tasks': '进行中的任务',
'Unresolved Tasks': '待你处理的任务',
'{title} · {count}': '{title} · {count}',
'Your ask': '你的要求',
'Relayed by {name}': '由 {name} 转达',
'Nothing of yours in hand.': '你交给它的任务都完成了。',
'Nothing running right now.': '现在没有在进行的工作。',
'Nothing waiting on you.': '没有等你处理的事。',
'1 task from you': '有 1 件事来自你',
'{count} tasks from you': '有 {count} 件事来自你',
'1 task waits on you': '有 1 件事等你处理',
'{count} tasks wait on you': '有 {count} 件事等你处理',
'{yours} from you, {waiting} waiting on you': '{yours} 件来自你,{waiting} 件等你处理',
'a teammate': '一位队友',
'a group': '一个群聊',
'in group "{name}"': '在群聊「{name}」里',
Expand Down
Loading
Loading