Skip to content

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

Show seconds and minutes-and-seconds in the elapsed work timer

Fei2411f4e4d12f4a5d
diff --git a/ds-bot/client.js b/ds-bot/client.js
index 5917b3e1..46422f34 100644
--- a/ds-bot/client.js
+++ b/ds-bot/client.js
@@ -2714,7 +2714,7 @@ header[class*="_header"] .bt-head{flex:1 1 auto;width:100%}
.bt-typing-text{display:flex;align-items:center;flex:1 1 auto;min-width:0;animation:bt-typing-label .22s ease-out .2s backwards}
.bt-typing-label{display:inline-flex;align-items:center;gap:6px;min-width:0;animation:bt-typing-label .22s ease-out backwards}
.bt-typing-label>.bt-shimmer{font-size:14px;line-height:22px;font-weight:400;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
-.bt-typing-time{flex-shrink:0;font-size:12px;line-height:22px;color:var(--bt-ink-3);white-space:nowrap}
+.bt-typing-time{flex-shrink:0;font-size:12px;line-height:22px;color:var(--bt-ink-3);font-variant-numeric:tabular-nums;white-space:nowrap}
@keyframes bt-typing-in{from{opacity:0;transform:scale(.9)}}
@keyframes bt-typing-out{from{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.92);filter:blur(3px)}}
@keyframes bt-typing-label{from{opacity:0;filter:blur(5px);transform:translateY(3px)}}
@@ -4760,8 +4760,10 @@ var import_react_dom2 = require("react-dom");
var PHRASE_HOLD_MS = 800;
var drawPhrase = (pool) => t(pool[Math.min(pool.length - 1, Math.floor(Math.random() * pool.length))]);
function elapsedLabel(ms) {
- const minutes = Math.floor(ms / 6e4);
- if (minutes < 60) return `${Math.max(1, minutes)}m`;
+ const seconds = Math.max(0, Math.floor(ms / 1e3));
+ if (seconds < 60) return `${seconds}s`;
+ const minutes = Math.floor(seconds / 60);
+ if (minutes < 60) return seconds % 60 === 0 ? `${minutes}m` : `${minutes}m ${seconds % 60}s`;
const hours = Math.floor(minutes / 60);
return minutes % 60 === 0 ? `${hours}h` : `${hours}h ${minutes % 60}m`;
}
@@ -4904,12 +4906,13 @@ function ActivityIndicator({ sessionId, useRoster, useSessionStatus, useLive, us
const [now, setNow] = (0, import_react8.useState)(Date.now);
(0, import_react8.useEffect)(() => {
if (phase !== "in") return void 0;
- const timer = setInterval(() => setNow(Date.now()), 1e4);
+ setNow(Date.now());
+ const timer = setInterval(() => setNow(Date.now()), 1e3);
return () => clearInterval(timer);
}, [phase]);
const host = useRunningHost(running);
if (!host || phase === null || !shown) return null;
- const elapsed = now - shown.at >= 6e4 ? elapsedLabel(now - shown.at) : null;
+ const elapsed = now - shown.at >= 1e3 ? elapsedLabel(now - shown.at) : null;
return (0, import_react_dom2.createPortal)((0, import_react8.createElement)(
"div",
{ className: "bt-typing", "data-exiting": phase === "out" ? "" : void 0, "aria-hidden": true },
@@ -11427,12 +11430,13 @@ function useNow2(active) {
const [now, setNow] = (0, import_react32.useState)(Date.now);
(0, import_react32.useEffect)(() => {
if (!active) return void 0;
- const timer = setInterval(() => setNow(Date.now()), 3e4);
+ setNow(Date.now());
+ const timer = setInterval(() => setNow(Date.now()), 1e3);
return () => clearInterval(timer);
}, [active]);
return now;
}
-var since = (now, at) => typeof at === "number" && now - at >= 6e4 ? ` · ${elapsedLabel(now - at)}` : "";
+var since = (now, at) => typeof at === "number" && now - at >= 1e3 ? ` · ${elapsedLabel(now - at)}` : "";
function ApprovalCard({ approval, bot, actions }) {
const [busy, setBusy] = (0, import_react32.useState)(false);
const answer = (choice) => {
@@ -11520,7 +11524,7 @@ body[data-ds-dark-theme] .bt-mw-ask{color:#f0b84a}
.bt-member-line{display:flex;align-items:center;gap:6px;min-width:0}
.bt-member-name{min-width:0;font-size:14px;line-height:20px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.bt-member-line>.bt-tag{font-size:11px;line-height:15px;padding:0 5px}
-.bt-member-state{min-width:0;font-size:12px;line-height:16px;color:var(--bt-ink-3);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
+.bt-member-state{min-width:0;font-size:12px;line-height:16px;color:var(--bt-ink-3);font-variant-numeric:tabular-nums;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.bt-member-state.bt-mw-ask{color:#b7791f}
body[data-ds-dark-theme] .bt-member-state.bt-mw-ask{color:#f0b84a}
.bt-member-stop{flex:none;height:26px;padding:0 11px;border:0;border-radius:13px;background:var(--bt-main);box-shadow:inset 0 0 0 .5px var(--bt-line-2);color:var(--bt-ink-2);font:inherit;font-size:12px;cursor:pointer;transition:background-color .12s ease,color .12s ease,${spring(SPRING_TAP, "scale")}}
diff --git a/ds-bot/src/client/activity-row.js b/ds-bot/src/client/activity-row.js
index 125339b7..3827ad17 100644
--- a/ds-bot/src/client/activity-row.js
+++ b/ds-bot/src/client/activity-row.js
@@ -13,8 +13,10 @@ import { t } from './i18n.js'
const PHRASE_HOLD_MS = 800
const drawPhrase = pool => t(pool[Math.min(pool.length - 1, Math.floor(Math.random() * pool.length))])
export function elapsedLabel(ms) {
- const minutes = Math.floor(ms / 60000)
- if (minutes < 60) return `${Math.max(1, minutes)}m`
+ const seconds = Math.max(0, Math.floor(ms / 1000))
+ if (seconds < 60) return `${seconds}s`
+ const minutes = Math.floor(seconds / 60)
+ if (minutes < 60) return seconds % 60 === 0 ? `${minutes}m` : `${minutes}m ${seconds % 60}s`
const hours = Math.floor(minutes / 60)
return minutes % 60 === 0 ? `${hours}h` : `${hours}h ${minutes % 60}m`
}
@@ -154,12 +156,13 @@ export function ActivityIndicator({ sessionId, useRoster, useSessionStatus, useL
const [now, setNow] = useState(Date.now)
useEffect(() => {
if (phase !== 'in') return undefined
- const timer = setInterval(() => setNow(Date.now()), 10000)
+ setNow(Date.now())
+ const timer = setInterval(() => setNow(Date.now()), 1000)
return () => clearInterval(timer)
}, [phase])
const host = useRunningHost(running)
if (!host || phase === null || !shown) return null
- const elapsed = now - shown.at >= 60000 ? elapsedLabel(now - shown.at) : null
+ const elapsed = now - shown.at >= 1000 ? elapsedLabel(now - shown.at) : null
return createPortal(h('div', { className: 'bt-typing', 'data-exiting': phase === 'out' ? '' : undefined, 'aria-hidden': true },
bot ? h(BotMark, { bot, size: 28, state: markState.current, live: true, pokeable: true }) : h(RoomAvatar, { room, roster, size: 28 }),
h('span', { className: 'bt-typing-text' },
diff --git a/ds-bot/src/client/member-status.js b/ds-bot/src/client/member-status.js
index 86d120f1..a63d6fd1 100644
--- a/ds-bot/src/client/member-status.js
+++ b/ds-bot/src/client/member-status.js
@@ -5,6 +5,8 @@ import { elapsedLabel } from './activity-row.js'
import { SPRING_SHAPE, SPRING_TAP, spring, useLinger } from './motion.js'
import { t } from './i18n.js'
+export { elapsedLabel }
+
// -------------------------------------------------------------------------
// What a group's members are doing: above the group's composer, one capsule for the
// members at work or waiting for an approval; above a Bot's own composer, one for the
@@ -128,13 +130,14 @@ function useNow(active) {
const [now, setNow] = useState(Date.now)
useEffect(() => {
if (!active) return undefined
- const timer = setInterval(() => setNow(Date.now()), 30000)
+ setNow(Date.now())
+ const timer = setInterval(() => setNow(Date.now()), 1000)
return () => clearInterval(timer)
}, [active])
return now
}
-const since = (now, at) => (typeof at === 'number' && now - at >= 60000 ? ` · ${elapsedLabel(now - at)}` : '')
+const since = (now, at) => (typeof at === 'number' && now - at >= 1000 ? ` · ${elapsedLabel(now - at)}` : '')
function ApprovalCard({ approval, bot, actions }) {
const [busy, setBusy] = useState(false)
@@ -225,7 +228,7 @@ body[data-ds-dark-theme] .bt-mw-ask{color:#f0b84a}
.bt-member-line{display:flex;align-items:center;gap:6px;min-width:0}
.bt-member-name{min-width:0;font-size:14px;line-height:20px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.bt-member-line>.bt-tag{font-size:11px;line-height:15px;padding:0 5px}
-.bt-member-state{min-width:0;font-size:12px;line-height:16px;color:var(--bt-ink-3);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
+.bt-member-state{min-width:0;font-size:12px;line-height:16px;color:var(--bt-ink-3);font-variant-numeric:tabular-nums;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.bt-member-state.bt-mw-ask{color:#b7791f}
body[data-ds-dark-theme] .bt-member-state.bt-mw-ask{color:#f0b84a}
.bt-member-stop{flex:none;height:26px;padding:0 11px;border:0;border-radius:13px;background:var(--bt-main);box-shadow:inset 0 0 0 .5px var(--bt-line-2);color:var(--bt-ink-2);font:inherit;font-size:12px;cursor:pointer;transition:background-color .12s ease,color .12s ease,${spring(SPRING_TAP, 'scale')}}
diff --git a/ds-bot/src/client/styles.js b/ds-bot/src/client/styles.js
index 6bdeae59..e5824edd 100644
--- a/ds-bot/src/client/styles.js
+++ b/ds-bot/src/client/styles.js
@@ -873,7 +873,7 @@ header[class*="_header"] .bt-head{flex:1 1 auto;width:100%}
.bt-typing-text{display:flex;align-items:center;flex:1 1 auto;min-width:0;animation:bt-typing-label .22s ease-out .2s backwards}
.bt-typing-label{display:inline-flex;align-items:center;gap:6px;min-width:0;animation:bt-typing-label .22s ease-out backwards}
.bt-typing-label>.bt-shimmer{font-size:14px;line-height:22px;font-weight:400;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
-.bt-typing-time{flex-shrink:0;font-size:12px;line-height:22px;color:var(--bt-ink-3);white-space:nowrap}
+.bt-typing-time{flex-shrink:0;font-size:12px;line-height:22px;color:var(--bt-ink-3);font-variant-numeric:tabular-nums;white-space:nowrap}
@keyframes bt-typing-in{from{opacity:0;transform:scale(.9)}}
@keyframes bt-typing-out{from{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.92);filter:blur(3px)}}
@keyframes bt-typing-label{from{opacity:0;filter:blur(5px);transform:translateY(3px)}}
diff --git a/ds-bot/test/member-status.test.js b/ds-bot/test/member-status.test.js
index d3912be8..580d55f8 100644
--- a/ds-bot/test/member-status.test.js
+++ b/ds-bot/test/member-status.test.js
@@ -22,7 +22,7 @@ runInNewContext(bundle.outputFiles[0].text, {
return platform[name]
},
})
-const { busyMembers, summaryText, MemberDock } = module.exports
+const { busyMembers, summaryText, MemberDock, MemberState, elapsedLabel } = module.exports
// Values from the bundle's realm compare by content only.
const plain = value => JSON.parse(JSON.stringify(value))
// The dock's capsule in an element tree.
@@ -92,3 +92,19 @@ test('the capsule says what a member does in its call\'s own words, and that it
assert.equal(label({ switching: true }), 'Anvil · Moving to a fresh conversation…')
assert.equal(label({ tool: 'pwsh', said: '解压 Ghidra,顺便写脚本。', note: 'Expand-Archive' }), 'Anvil · 解压 Ghidra,顺便写脚本…')
})
+
+test('elapsedLabel counts seconds first, then minutes and seconds, then hours', () => {
+ assert.equal(elapsedLabel(0), '0s')
+ assert.equal(elapsedLabel(1_000), '1s')
+ assert.equal(elapsedLabel(59_999), '59s')
+ assert.equal(elapsedLabel(60_000), '1m')
+ assert.equal(elapsedLabel(61_000), '1m 1s')
+ assert.equal(elapsedLabel(125_000), '2m 5s')
+ assert.equal(elapsedLabel(3_599_000), '59m 59s')
+ assert.equal(elapsedLabel(3_600_000), '1h')
+ assert.equal(elapsedLabel(3_900_000), '1h 5m')
+ const stateText = (entry, now) => MemberState({ entry, bot: { id: 'a', name: 'Anvil' }, room: { id: 'r1' }, roster: team, now }).children.map(child => (typeof child === 'string' ? child : child.children.join(''))).join('')
+ assert.equal(stateText({ state: 'work', doing: { roomId: 'r1', tool: 'pwsh', since: 1_000 } }, 1_500), 'Running shell commands…')
+ assert.equal(stateText({ state: 'work', doing: { roomId: 'r1', tool: 'pwsh', since: 1_000 } }, 9_000), 'Running shell commands… · 8s')
+ assert.equal(stateText({ state: 'ask', approvals: [{ at: 1_000 }] }, 75_000), 'Waiting for your approval · 1m 14s')
+})