Skip to content

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

Hide a question card's letter hints while another card owns the keys

klarkxy7d6dfc7d7316
diff --git a/ds-bot/client.js b/ds-bot/client.js
index 7a636e62..041c8d7e 100644
--- a/ds-bot/client.js
+++ b/ds-bot/client.js
@@ -3601,7 +3601,7 @@ function QuestionView({ question, onAnswer, onDismiss, onInteract, busy = false,
onInteract?.();
onAnswer({ selected: multi ? picked : [], ...custom ? { custom } : {} });
};
- useOptionKeys(busy ? 0 : options.length, (index) => choose(options[index].label), ownRef);
+ const hints = useOptionKeys(busy ? 0 : options.length, (index) => choose(options[index].label), ownRef);
const ownLetter = options.length > 0 ? keyLetter(options.length) : void 0;
const field = ownAnswer ? (0, import_react5.createElement)("textarea", {
ref: ownRef,
@@ -3613,7 +3613,7 @@ function QuestionView({ question, onAnswer, onDismiss, onInteract, busy = false,
className: "bt-q-input",
"aria-label": t("Your own answer"),
placeholder: t("Type your own answer"),
- "aria-keyshortcuts": ownLetter?.toLowerCase(),
+ "aria-keyshortcuts": hints ? ownLetter?.toLowerCase() : void 0,
onChange: (event) => {
if (!busy) {
onInteract?.();
@@ -3636,10 +3636,10 @@ function QuestionView({ question, onAnswer, onDismiss, onInteract, busy = false,
className: "bt-q-opt",
disabled: busy,
"aria-pressed": multi ? selected : void 0,
- "aria-keyshortcuts": keyLetter(optionIndex).toLowerCase(),
+ "aria-keyshortcuts": hints ? keyLetter(optionIndex).toLowerCase() : void 0,
onClick: () => choose(option.label)
},
- (0, import_react5.createElement)("span", { className: "bt-key", "aria-hidden": true }, keyLetter(optionIndex)),
+ hints ? (0, import_react5.createElement)("span", { className: "bt-key", "aria-hidden": true }, keyLetter(optionIndex)) : null,
(0, import_react5.createElement)(
"span",
{ className: "bt-q-body" },
@@ -3653,7 +3653,7 @@ function QuestionView({ question, onAnswer, onDismiss, onInteract, busy = false,
rows.push((0, import_react5.createElement)(
"label",
{ key: "own", className: "bt-q-opt bt-q-ownrow", "data-filled": custom !== "" ? "" : void 0 },
- ownLetter ? (0, import_react5.createElement)("span", { className: "bt-key", "aria-hidden": true }, ownLetter) : null,
+ hints && ownLetter ? (0, import_react5.createElement)("span", { className: "bt-key", "aria-hidden": true }, ownLetter) : null,
(0, import_react5.createElement)("span", { className: "bt-q-body" }, field)
));
}
diff --git a/ds-bot/src/client/questions.js b/ds-bot/src/client/questions.js
index 54718bff..3bcfb983 100644
--- a/ds-bot/src/client/questions.js
+++ b/ds-bot/src/client/questions.js
@@ -77,12 +77,12 @@ function QuestionView({ question, onAnswer, onDismiss, onInteract, busy = false,
onInteract?.()
onAnswer({ selected: multi ? picked : [], ...(custom ? { custom } : {}) })
}
- useOptionKeys(busy ? 0 : options.length, index => choose(options[index].label), ownRef)
+ const hints = useOptionKeys(busy ? 0 : options.length, index => choose(options[index].label), ownRef)
const ownLetter = options.length > 0 ? keyLetter(options.length) : undefined
const field = ownAnswer ? h('textarea', {
ref: ownRef, rows: 1, value: own, readOnly: busy, autoComplete: 'off', spellCheck: false, className: 'bt-q-input',
'aria-label': t('Your own answer'), placeholder: t('Type your own answer'),
- 'aria-keyshortcuts': ownLetter?.toLowerCase(),
+ 'aria-keyshortcuts': hints ? ownLetter?.toLowerCase() : undefined,
onChange: (event) => { if (!busy) { onInteract?.(); setOwn(event.target.value) } },
onKeyDown: (event) => {
if (event.key !== 'Enter' || event.shiftKey || event.nativeEvent.isComposing) return
@@ -95,10 +95,10 @@ function QuestionView({ question, onAnswer, onDismiss, onInteract, busy = false,
return h('button', {
key: option.label, type: 'button', className: 'bt-q-opt', disabled: busy,
'aria-pressed': multi ? selected : undefined,
- 'aria-keyshortcuts': keyLetter(optionIndex).toLowerCase(),
+ 'aria-keyshortcuts': hints ? keyLetter(optionIndex).toLowerCase() : undefined,
onClick: () => choose(option.label),
},
- h('span', { className: 'bt-key', 'aria-hidden': true }, keyLetter(optionIndex)),
+ hints ? h('span', { className: 'bt-key', 'aria-hidden': true }, keyLetter(optionIndex)) : null,
h('span', { className: 'bt-q-body' },
h('span', { className: 'bt-q-label' }, option.label),
option.description ? h('span', { className: 'bt-q-desc' }, option.description) : null),
@@ -107,7 +107,7 @@ function QuestionView({ question, onAnswer, onDismiss, onInteract, busy = false,
// Raised cards keep the custom answer as one more keyed row; bubbles put it below the list.
if (raised && field) {
rows.push(h('label', { key: 'own', className: 'bt-q-opt bt-q-ownrow', 'data-filled': custom !== '' ? '' : undefined },
- ownLetter ? h('span', { className: 'bt-key', 'aria-hidden': true }, ownLetter) : null,
+ hints && ownLetter ? h('span', { className: 'bt-key', 'aria-hidden': true }, ownLetter) : null,
h('span', { className: 'bt-q-body' }, field)))
}
let foot = null
diff --git a/ds-bot/test/card-hold.test.js b/ds-bot/test/card-hold.test.js
index 9b9c17ab..b9196cb3 100644
--- a/ds-bot/test/card-hold.test.js
+++ b/ds-bot/test/card-hold.test.js
@@ -308,8 +308,16 @@ test('letter keys answer a card only while it is the sole open card with keys',
const firstView = mount(firstCard.type, firstCard.props)
const secondView = mount(secondCard.type, secondCard.props)
firstView.render()
+ // A lone card advertises its keys: both options and the own-answer row.
+ assert.equal(all(firstView.render(), node => node.props.className === 'bt-key').length, 3)
secondView.render()
assert.equal(keys.size, 2)
+ // With two cards open neither shows letters for keys it will not answer.
+ assert.equal(all(firstView.render(), node => node.props.className === 'bt-key').length, 0)
+ const both = secondView.render()
+ assert.equal(all(both, node => node.props.className === 'bt-key').length, 0)
+ assert.ok(options(both).every(option => option.props['aria-keyshortcuts'] === undefined))
+ assert.equal(field(both).props['aria-keyshortcuts'], undefined)
const key = () => ({ key: 'a', target: null, preventDefault() { this.defaultPrevented = true } })
const shared = key()
for (const listener of [...keys]) listener(shared)
@@ -318,6 +326,11 @@ test('letter keys answer a card only while it is the sole open card with keys',
assert.equal(answers.length, 0)
firstView.unmount()
assert.equal(keys.size, 1)
+ // Alone again, the surviving card brings its letters back.
+ const alone = secondView.render()
+ assert.equal(all(alone, node => node.props.className === 'bt-key').length, 3)
+ assert.ok(options(alone).every(option => option.props['aria-keyshortcuts'] !== undefined))
+ assert.equal(field(alone).props['aria-keyshortcuts'], 'c')
for (const listener of [...keys]) listener(key())
await tick()
assert.deepEqual(answers, [['chief', 'second', { selected: ['Short'], custom: '' }]])