Skip to content

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

Show a card in the dock when its call is not drawn

Fei2411ddf0c04d4c0c
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6a3e00cd..332fecfa 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,7 @@ All notable changes to DS Bot are listed here. The format follows [Keep a Change
### Fixed
- With the `ptc` agent preset, the chat shows the tools a Bot runs from its code again: group replies, question and key cards, and the lines for messages, Bots, groups and memory.
+- A question or key card whose call is not on screen, such as one asked in an earlier part of the chat or in a Bot-to-Bot turn, waits above the message box. A card shows in one place only.
## [0.1.4] - 2026-10-13
diff --git a/ds-bot/client.js b/ds-bot/client.js
index 9661c796..c8b32678 100644
--- a/ds-bot/client.js
+++ b/ds-bot/client.js
@@ -1263,6 +1263,15 @@ function isAgentSession(roster, cache, sessionId) {
if (roster.ready) return roster.agentOf[sessionId] !== void 0;
return cache.has(sessionId);
}
+function countCards(state, sessionId, callIds, delta) {
+ const own = { ...state[sessionId] };
+ for (const callId of callIds) {
+ const count = (own[callId] ?? 0) + delta;
+ if (count > 0) own[callId] = count;
+ else delete own[callId];
+ }
+ return { ...state, [sessionId]: own };
+}
// src/client/themes.js
var THEME_KEYS = ["bg", "sidebar", "bubble", "card", "text", "user", "userText", "accent"];
@@ -1498,6 +1507,7 @@ function isHiddenTurn(roster, sessionId, turn) {
return (roster.exchangeTurns[sessionId] ?? []).includes(turn);
}
var toolName = (root) => root.name || root.call?.name;
+var historyLoading = (snapshot) => snapshot?.openState === "cold" || snapshot?.openState === "loading";
function toolArgs(root) {
if (typeof root.args?.text === "function") {
return { text: (key) => root.args.text(key) ?? void 0, value: (key) => typeof root.args.value === "function" ? root.args.value(key) : void 0 };
@@ -3288,9 +3298,11 @@ function PendingQuestion({ sessionId, question, actions, inline }) {
(0, import_react4.createElement)(QuestionView, { key: question.id, question, onAnswer, onDismiss, ownAnswer: question.allowCustom === true, raised: !inline })
);
}
-function QuestionDock({ sessionId, useRoster, actions }) {
+function QuestionDock({ sessionId, useRoster, useCards, useSession, actions }) {
const question = useRoster((value) => value.questions?.[sessionId]);
- if (question === void 0 || question.callId) return null;
+ const drawn = useCards?.((state) => state[sessionId]?.[question?.callId] > 0) === true;
+ const loading = useSession?.(historyLoading) === true;
+ if (question === void 0 || question.callId && (drawn || loading)) return null;
return (0, import_react4.createElement)(PendingQuestion, { sessionId, question, actions, inline: false });
}
function AnsweredCell({ node }) {
@@ -3310,6 +3322,7 @@ function AnsweredCell({ node }) {
// src/client/secret-card.js
var import_react5 = require("react");
var MIN_VALUE = 4;
+var NONE = {};
var KeyIcon = () => (0, import_react5.createElement)(
"svg",
{ width: 15, height: 15, viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.5, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true },
@@ -3476,18 +3489,21 @@ function RequestView({ bot, request, roster, actions }) {
function SecretToolCell({ sessionId, callId, name, done, content, roster, actions }) {
const bot = roster.byId[sessionId];
if (!bot) return null;
- const request = (roster.secretRequests?.[bot.id] ?? []).find((entry) => entry.callId === callId);
+ const request = (roster.secretRequests?.[bot.id] ?? []).find((entry) => entry.callId === callId && (entry.sessionId ?? sessionId) === sessionId);
if (request) return (0, import_react5.createElement)("div", { className: "bt-q-inline" }, (0, import_react5.createElement)(RequestView, { bot, request, roster, actions }));
if (done && /already saved/.test(contentText(content))) {
return (0, import_react5.createElement)("div", { className: "bt-event" }, (0, import_react5.createElement)("span", { className: "bt-secret-event" }, (0, import_react5.createElement)(KeyIcon), t("{bot} is using {name}", { bot: bot.name, name: name ?? t("a saved key") })));
}
return null;
}
-function SecretDock({ sessionId, useRoster, actions }) {
+function SecretDock({ sessionId, useRoster, useCards, useSession, actions }) {
const roster = useRoster((value) => value);
+ const shown = useCards?.((state) => state[sessionId]) ?? NONE;
+ const loading = useSession?.(historyLoading) === true;
const bot = roster.byId[sessionId];
if (!bot || currentPart(bot) !== sessionId) return null;
- const waiting = (roster.secretRequests?.[bot.id] ?? []).filter((entry) => entry.status === "pending" && (!entry.callId || entry.sessionId !== sessionId));
+ const drawn = (entry) => entry.callId && entry.sessionId === sessionId && (loading || shown[entry.callId] > 0);
+ const waiting = (roster.secretRequests?.[bot.id] ?? []).filter((entry) => entry.status === "pending" && !drawn(entry));
if (waiting.length === 0) return null;
return (0, import_react5.createElement)("div", { className: "bt-q-dock bt-secret-dock" }, waiting.map((request) => (0, import_react5.createElement)(SecretCard, { key: `${request.id}:${request.kind}`, bot, request, roster, actions })));
}
@@ -4377,6 +4393,7 @@ function GroupReplies({ sessionId, callId, done, content, roster, actions, useUi
);
}
var DRAWN = /* @__PURE__ */ new Set(["message_bot", "stop_bot", "create_bot", "update_bot", "group_relay", "create_group", "update_group", "delete_group", "post_to_group", "ask_user", "request_secret", "ask_user_question", "read_group_chat", "remember", "forget"]);
+var CARDS = /* @__PURE__ */ new Set(["ask_user", "request_secret"]);
function callTree(root) {
const calls = [];
const seen = /* @__PURE__ */ new Set();
@@ -4390,6 +4407,15 @@ function callTree(root) {
visit(root);
return calls;
}
+function useShownCards(actions, sessionId, callIds) {
+ const key = JSON.stringify(callIds);
+ (0, import_react6.useLayoutEffect)(() => {
+ const ids = JSON.parse(key);
+ if (ids.length === 0 || !actions.noteCards) return void 0;
+ actions.noteCards(sessionId, ids, 1);
+ return () => actions.noteCards(sessionId, ids, -1);
+ }, [sessionId, key]);
+}
function renderCall(call2, { sessionId, roster, actions, useUi, useWork, findBot }) {
const tool = toolName(call2);
const done = call2.kind === "tool-result";
@@ -4478,6 +4504,7 @@ function ToolCell({ node, sessionId, useRoster, useUi, useWork, actions }) {
const running = root.kind === "tool-result" ? void 0 : calls.findLast((call2) => call2.kind !== "tool-result");
const note = running ? toolActivity(toolName(running), toolArgs(running).text, findBot, roster.byId[sessionId]) : null;
useLiveNote(actions, sessionId, `tool:${root.callId ?? node.key}`, note);
+ useShownCards(actions, sessionId, drawn.filter((call2) => CARDS.has(toolName(call2)) && call2.callId).map((call2) => call2.callId));
if (drawn.length === 0) return null;
const env = { sessionId, roster, actions, useUi, useWork, findBot };
return (0, import_react6.createElement)(import_react6.Fragment, null, drawn.map((call2, index) => (0, import_react6.createElement)(import_react6.Fragment, { key: call2.callId ?? index }, renderCall(call2, env))));
@@ -13041,6 +13068,7 @@ function apply(ctx) {
const work = createSource({ bots: {}, approvals: [] });
let workKey = "";
const live = createSource({});
+ const cards = createSource({});
const turnClock = createSource({});
let activityKey = "{}";
const memoryNews = createSource({});
@@ -13700,6 +13728,9 @@ function apply(ctx) {
return { ...state, [sessionId]: next };
});
};
+ actions.noteCards = (sessionId, callIds, delta) => {
+ if (sessionId !== void 0) cards.set((state) => countCards(state, sessionId, callIds, delta));
+ };
actions.clearLive = (sessionId) => live.set((state) => {
if (!state[sessionId]) return state;
const next = { ...state };
@@ -13708,7 +13739,7 @@ function apply(ctx) {
});
const browserPages = browsers?.pages ?? createSource({});
const browserTabs = browsers?.tabs ?? createSource({});
- const face = () => ({ actions, hooks: { roster, ui: ui2, activity, work, memoryNews, registry, turnClock, live, browserPages, browserTabs, surface, update } });
+ const face = () => ({ actions, hooks: { roster, ui: ui2, activity, work, memoryNews, registry, turnClock, live, cards, browserPages, browserTabs, surface, update } });
ctx.effect(() => noticeApprovals({
work,
roster,
diff --git a/ds-bot/src/client/cells.js b/ds-bot/src/client/cells.js
index 74de98f2..63d7ec6e 100644
--- a/ds-bot/src/client/cells.js
+++ b/ds-bot/src/client/cells.js
@@ -596,6 +596,9 @@ function GroupReplies({ sessionId, callId, done, content, roster, actions, useUi
// The calls ToolCell draws. A PTC program (`run_code`) dispatches the real tools as
// its sub-calls, so a call draws by its own name wherever it sits in the tree.
const DRAWN = new Set(['message_bot', 'stop_bot', 'create_bot', 'update_bot', 'group_relay', 'create_group', 'update_group', 'delete_group', 'post_to_group', 'ask_user', 'request_secret', 'ask_user_question', 'read_group_chat', 'remember', 'forget'])
+// Calls whose card a dock above the composer carries when the call is not drawn.
+const CARDS = new Set(['ask_user', 'request_secret'])
+
// The root and its sub-calls in dispatch order, each call once.
export function callTree(root) {
const calls = []
@@ -611,6 +614,18 @@ export function callTree(root) {
return calls
}
+// Tells the docks which card calls the transcript draws, so a card shows in one place.
+// A layout effect: the dock drops its copy of the card before the first paint.
+function useShownCards(actions, sessionId, callIds) {
+ const key = JSON.stringify(callIds)
+ useLayoutEffect(() => {
+ const ids = JSON.parse(key)
+ if (ids.length === 0 || !actions.noteCards) return undefined
+ actions.noteCards(sessionId, ids, 1)
+ return () => actions.noteCards(sessionId, ids, -1)
+ }, [sessionId, key])
+}
+
function renderCall(call, { sessionId, roster, actions, useUi, useWork, findBot }) {
const tool = toolName(call)
const done = call.kind === 'tool-result'
@@ -700,6 +715,7 @@ export function ToolCell({ node, sessionId, useRoster, useUi, useWork, actions }
const note = running ? toolActivity(toolName(running), toolArgs(running).text, findBot, roster.byId[sessionId]) : null
// A running tool shows only as the activity row's phrase.
useLiveNote(actions, sessionId, `tool:${root.callId ?? node.key}`, note)
+ useShownCards(actions, sessionId, drawn.filter(call => CARDS.has(toolName(call)) && call.callId).map(call => call.callId))
if (drawn.length === 0) return null
const env = { sessionId, roster, actions, useUi, useWork, findBot }
return h(Fragment, null, drawn.map((call, index) => h(Fragment, { key: call.callId ?? index }, renderCall(call, env))))
diff --git a/ds-bot/src/client/index.js b/ds-bot/src/client/index.js
index e14e7191..ee9dbac8 100644
--- a/ds-bot/src/client/index.js
+++ b/ds-bot/src/client/index.js
@@ -1,7 +1,7 @@
import { call } from './api.js'
import { isHex, inkText, paintCss } from './inks.js'
import { DEFAULT_MASK, SHAPES, markupCache, maskOf } from './characters.js'
-import { createSource, EMPTY_ROSTER, indexRoster, isAgentSession } from './sources.js'
+import { countCards, createSource, EMPTY_ROSTER, indexRoster, isAgentSession } from './sources.js'
import { themeCss, shellTokens, conversationTokens, registry, registerShape, registerTheme, allThemes } from './themes.js'
import { MENTION_ORIGIN, currentPart } from './text.js'
import { SHELL_CSS, CONVERSATION_CSS, installStyles, installCompiledStyles } from './styles.js'
@@ -95,6 +95,9 @@ export function apply(ctx) {
let workKey = ''
// Per Session, what its transcript has in flight (running tools, a streaming reply).
const live = createSource({})
+ // Per Session, the ask_user and request_secret calls its transcript draws; the
+ // docks carry the cards of the other calls.
+ const cards = createSource({})
// Per Session, the first visible time and the end time of each turn the transcript
// has rendered; time separators compare one turn's end with the next turn's start.
const turnClock = createSource({})
@@ -692,6 +695,9 @@ export function apply(ctx) {
return { ...state, [sessionId]: next }
})
}
+ actions.noteCards = (sessionId, callIds, delta) => {
+ if (sessionId !== undefined) cards.set(state => countCards(state, sessionId, callIds, delta))
+ }
actions.clearLive = sessionId => live.set((state) => {
if (!state[sessionId]) return state
const next = { ...state }
@@ -700,7 +706,7 @@ export function apply(ctx) {
})
const browserPages = browsers?.pages ?? createSource({})
const browserTabs = browsers?.tabs ?? createSource({})
- const face = () => ({ actions, hooks: { roster, ui, activity, work, memoryNews, registry, turnClock, live, browserPages, browserTabs, surface, update } })
+ const face = () => ({ actions, hooks: { roster, ui, activity, work, memoryNews, registry, turnClock, live, cards, browserPages, browserTabs, surface, update } })
ctx.effect(() => noticeApprovals({
work,
roster,
diff --git a/ds-bot/src/client/questions.js b/ds-bot/src/client/questions.js
index 41175f89..4c3db483 100644
--- a/ds-bot/src/client/questions.js
+++ b/ds-bot/src/client/questions.js
@@ -1,6 +1,7 @@
import { createElement as h, useEffect, useId, useRef, useState } from 'react'
import { CloseIcon, CheckIcon } from './icons.js'
import { t } from './i18n.js'
+import { historyLoading } from './text.js'
// -------------------------------------------------------------------------
// Question cards. `ask_user` cards sit in the transcript and never block the Bot;
@@ -174,10 +175,12 @@ export function PendingQuestion({ sessionId, question, actions, inline }) {
}
// Questions asked by a tool call render inline at that call (see ToolCell); the dock
-// only carries questions that have no call to anchor to.
-export function QuestionDock({ sessionId, useRoster, actions }) {
+// carries the ones whose call the transcript does not draw.
+export function QuestionDock({ sessionId, useRoster, useCards, useSession, actions }) {
const question = useRoster(value => value.questions?.[sessionId])
- if (question === undefined || question.callId) return null
+ const drawn = useCards?.(state => state[sessionId]?.[question?.callId] > 0) === true
+ const loading = useSession?.(historyLoading) === true
+ if (question === undefined || (question.callId && (drawn || loading))) return null
return h(PendingQuestion, { sessionId, question, actions, inline: false })
}
diff --git a/ds-bot/src/client/secret-card.js b/ds-bot/src/client/secret-card.js
index 49313aab..56671dff 100644
--- a/ds-bot/src/client/secret-card.js
+++ b/ds-bot/src/client/secret-card.js
@@ -5,11 +5,12 @@
import { createElement as h, useEffect, useId, useState } from 'react'
import { CheckIcon, CloseIcon, TrashIcon } from './icons.js'
import { BotAvatar, BotMark } from './mark.js'
-import { contentText, currentPart } from './text.js'
+import { contentText, currentPart, historyLoading } from './text.js'
import { dateLocale, t } from './i18n.js'
import { SPRING_POP, SPRING_SHAPE, spring } from './motion.js'
const MIN_VALUE = 4
+const NONE = {}
export const KeyIcon = () => h('svg', { width: 15, height: 15, viewBox: '0 0 20 20', fill: 'none', stroke: 'currentColor', strokeWidth: 1.5, strokeLinecap: 'round', strokeLinejoin: 'round', 'aria-hidden': true },
h('path', { d: 'M7 9.5a3.5 3.5 0 1 1 0 .01z' }), h('path', { d: 'M10.4 10.6L17 10.6M14.5 10.6v2.4M16.6 10.6v1.8' }))
@@ -143,7 +144,8 @@ function RequestView({ bot, request, roster, actions }) {
export function SecretToolCell({ sessionId, callId, name, done, content, roster, actions }) {
const bot = roster.byId[sessionId]
if (!bot) return null
- const request = (roster.secretRequests?.[bot.id] ?? []).find(entry => entry.callId === callId)
+ // Call ids repeat across a Bot's chat parts.
+ const request = (roster.secretRequests?.[bot.id] ?? []).find(entry => entry.callId === callId && (entry.sessionId ?? sessionId) === sessionId)
if (request) return h('div', { className: 'bt-q-inline' }, h(RequestView, { bot, request, roster, actions }))
if (done && /already saved/.test(contentText(content))) {
return h('div', { className: 'bt-event' }, h('span', { className: 'bt-secret-event' }, h(KeyIcon), t('{bot} is using {name}', { bot: bot.name, name: name ?? t('a saved key') })))
@@ -151,13 +153,16 @@ export function SecretToolCell({ sessionId, callId, name, done, content, roster,
return null
}
-// A card asked in an earlier part of the chat has no call in the part shown now, so
-// it waits above the composer instead.
-export function SecretDock({ sessionId, useRoster, actions }) {
+// A card whose call the transcript does not draw (an earlier part of the chat, a
+// hidden turn, a call outside the loaded history) waits above the composer instead.
+export function SecretDock({ sessionId, useRoster, useCards, useSession, actions }) {
const roster = useRoster(value => value)
+ const shown = useCards?.(state => state[sessionId]) ?? NONE
+ const loading = useSession?.(historyLoading) === true
const bot = roster.byId[sessionId]
if (!bot || currentPart(bot) !== sessionId) return null
- const waiting = (roster.secretRequests?.[bot.id] ?? []).filter(entry => entry.status === 'pending' && (!entry.callId || entry.sessionId !== sessionId))
+ const drawn = entry => entry.callId && entry.sessionId === sessionId && (loading || shown[entry.callId] > 0)
+ const waiting = (roster.secretRequests?.[bot.id] ?? []).filter(entry => entry.status === 'pending' && !drawn(entry))
if (waiting.length === 0) return null
return h('div', { className: 'bt-q-dock bt-secret-dock' }, waiting.map(request => h(SecretCard, { key: `${request.id}:${request.kind}`, bot, request, roster, actions })))
}
diff --git a/ds-bot/src/client/sources.js b/ds-bot/src/client/sources.js
index b2ea20c0..7ff33227 100644
--- a/ds-bot/src/client/sources.js
+++ b/ds-bot/src/client/sources.js
@@ -48,3 +48,14 @@ export function isAgentSession(roster, cache, sessionId) {
if (roster.ready) return roster.agentOf[sessionId] !== undefined
return cache.has(sessionId)
}
+
+// Per Session, how many mounted cells draw each card call; a count of 0 drops the call.
+export function countCards(state, sessionId, callIds, delta) {
+ const own = { ...state[sessionId] }
+ for (const callId of callIds) {
+ const count = (own[callId] ?? 0) + delta
+ if (count > 0) own[callId] = count
+ else delete own[callId]
+ }
+ return { ...state, [sessionId]: own }
+}
diff --git a/ds-bot/src/client/text.js b/ds-bot/src/client/text.js
index 9fedd6f5..d21f4034 100644
--- a/ds-bot/src/client/text.js
+++ b/ds-bot/src/client/text.js
@@ -102,6 +102,10 @@ export function isHiddenTurn(roster, sessionId, turn) {
export const toolName = root => root.name || root.call?.name
+// While a Session's history loads, a card asked in it may yet be drawn at its call,
+// so the docks hold it back until then.
+export const historyLoading = snapshot => snapshot?.openState === 'cold' || snapshot?.openState === 'loading'
+
export function toolArgs(root) {
if (typeof root.args?.text === 'function') {
return { text: key => root.args.text(key) ?? undefined, value: key => (typeof root.args.value === 'function' ? root.args.value(key) : undefined) }
diff --git a/ds-bot/test/tool-cells.test.js b/ds-bot/test/tool-cells.test.js
index 47d27eac..f708555b 100644
--- a/ds-bot/test/tool-cells.test.js
+++ b/ds-bot/test/tool-cells.test.js
@@ -4,12 +4,15 @@ import { fileURLToPath } from 'node:url'
import { runInNewContext } from 'node:vm'
import { build } from 'esbuild'
-// The tool cells, bundled once and rendered with a minimal React:
+// The tool cells and the card docks, bundled once and rendered with a minimal React:
// components run as plain functions, effects are collected and run on demand.
const { outputFiles } = await build({
stdin: {
contents: [
"export { ToolCell, callTree } from './src/client/cells.js'",
+ "export { QuestionDock } from './src/client/questions.js'",
+ "export { SecretDock } from './src/client/secret-card.js'",
+ "export { countCards } from './src/client/sources.js'",
].join('\n'),
resolveDir: fileURLToPath(new URL('..', import.meta.url)),
},
@@ -41,7 +44,7 @@ runInNewContext(outputFiles[0].text, {
throw new Error(`Unexpected platform module ${name}`)
},
})
-const { ToolCell, callTree } = module.exports
+const { ToolCell, callTree, QuestionDock, SecretDock, countCards } = module.exports
// Runs the effects collected since the last render; returns the cleanups.
const mount = () => {
@@ -219,6 +222,91 @@ test('the live note follows the running sub-call of a program', () => {
assert.equal(notes(call('message_bot', 'direct', { args: { to: 'Writer' }, running: true }))[0].entry.label, 'Asking Writer')
})
+// A minimal cards store, as index.js keeps it.
+const cardStore = () => {
+ const store = { state: {} }
+ store.noteCards = (sessionId, ids, delta) => { store.state = countCards(store.state, sessionId, ids, delta) }
+ return store
+}
+const draw = (root, store, options = {}) => {
+ effects = []
+ ToolCell(props(root, { ...options, actions: { noteCards: store.noteCards } }))
+ const unmount = mount()
+ return { out: show(root, options), unmount }
+}
+
+test('a cell tells the docks which card calls it draws, until it unmounts', () => {
+ const store = cardStore()
+ const root = program([call('ask_user', 'program:ptc:1'), call('request_secret', 'program:ptc:2'), call('message_bot', 'program:ptc:3')])
+ ToolCell(props(root, { actions: { noteCards: store.noteCards } }))
+ const unmount = mount()
+ assert.deepEqual(JSON.parse(JSON.stringify(store.state)), { chief: { 'program:ptc:1': 1, 'program:ptc:2': 1 } })
+ ToolCell(props(root, { actions: { noteCards: store.noteCards } }))
+ const second = mount()
+ assert.equal(store.state.chief['program:ptc:1'], 2)
+ second()
+ unmount()
+ assert.deepEqual(JSON.parse(JSON.stringify(store.state)), { chief: {} })
+ ToolCell(props(root, { actions: { noteCards: store.noteCards }, roster: team({ exchangeTurns: { chief: [1] } }) }))
+ mount()
+ assert.deepEqual(JSON.parse(JSON.stringify(store.state)), { chief: {} })
+})
+
+const dockProps = (store, roster, { sessionId = chief.id, openState = 'open', actions = {} } = {}) => ({
+ sessionId, actions,
+ useRoster: select => select(roster),
+ useCards: select => select(store.state),
+ useSession: select => select({ openState }),
+})
+const docks = (store, roster, options) => {
+ const out = text(expand([QuestionDock(dockProps(store, roster, options)), SecretDock(dockProps(store, roster, options))]))
+ effects = []
+ return out
+}
+
+test('a card whose call is not drawn waits in the dock; a drawn one shows only at its call', () => {
+ const store = cardStore()
+ const roster = team({ questions: { chief: question('program:ptc:1') }, secretRequests: { chief: [request('program:ptc:2')] } })
+ const root = program([call('ask_user', 'program:ptc:1'), call('request_secret', 'program:ptc:2', { args: { name: 'DEMO_TOKEN' } })])
+ assert.match(docks(store, roster), /Which draft\?.*Chief needs a key/)
+ const { out, unmount } = draw(root, store, { roster })
+ const inline = text(out)
+ assert.equal(docks(store, roster), '')
+ assert.equal(count(inline, 'Which draft?'), 1)
+ assert.equal(count(inline, 'needs a key'), 1)
+ unmount()
+ assert.match(docks(store, roster), /Which draft\?.*Chief needs a key/)
+})
+
+test('the docks hold a card back while the history loads, and keep cards without a call', () => {
+ const store = cardStore()
+ const roster = team({ questions: { chief: question('program:ptc:1') }, secretRequests: { chief: [request('program:ptc:2')] } })
+ assert.equal(docks(store, roster, { openState: 'loading' }), '')
+ assert.equal(docks(store, roster, { openState: 'cold' }), '')
+ assert.match(docks(store, roster, { openState: 'error' }), /Which draft\?.*Chief needs a key/)
+ const free = team({ questions: { chief: question(undefined) }, secretRequests: { chief: [request(undefined)] } })
+ assert.match(docks(store, free, { openState: 'loading' }), /Which draft\?.*Chief needs a key/)
+})
+
+test('a card from an earlier part waits in the dock even when a call here has the same id', () => {
+ const store = cardStore()
+ const current = { ...chief, sessionId: 'chief-2', parts: ['chief', 'chief-2'] }
+ const roster = team({ bots: [writer, current], byId: { writer, chief: current, 'chief-2': current }, secretRequests: { chief: [request('call-1', { sessionId: 'chief' })] } })
+ const { out, unmount } = draw(call('request_secret', 'call-1', { args: { name: 'DEMO_TOKEN' } }), store, { roster, sessionId: 'chief-2' })
+ assert.doesNotMatch(text(out), /needs a key/)
+ assert.match(docks(store, roster, { sessionId: 'chief-2' }), /Chief needs a key/)
+ unmount()
+})
+
+test('a secret in a hidden turn shows in the dock instead of nowhere', () => {
+ const store = cardStore()
+ const roster = team({ exchangeTurns: { chief: [1] }, secretRequests: { chief: [request('program:ptc:1')] } })
+ const { out, unmount } = draw(program([call('request_secret', 'program:ptc:1', { args: { name: 'DEMO_TOKEN' } })]), store, { roster })
+ assert.equal(text(out), '')
+ assert.match(docks(store, roster), /Chief needs a key/)
+ unmount()
+})
+
// #38: a PTC group round's replies vanished once the round ended.
test('a PTC group relay shows its replies from the sub-call, live and after reload', async () => {
const replies = [{ botId: 'writer', text: 'Hello from Writer.' }, { botId: 'chief', text: 'Hello from Chief.' }]