Skip to content

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

Measure the Main Bot's avatar where the team column comes to rest

AdamPlatin123288926f9aa4f
diff --git a/ds-bot/client.js b/ds-bot/client.js
index a0c80c21..ac8c5f64 100644
--- a/ds-bot/client.js
+++ b/ds-bot/client.js
@@ -11020,14 +11020,23 @@ function mainAvatarPlace(roster) {
if (look.shape !== MAIN_LOOK.shape || look.color !== MAIN_LOOK.color) return void 0;
const mark = mainMarkOf(main.id);
if (!mark || mark.checkVisibility?.({ visibilityProperty: true }) === false) return void 0;
- const box = mark.getBoundingClientRect();
+ const box = restingBox(mark);
const view = document.documentElement;
return { x: box.left, y: box.top, width: box.width, height: box.height, viewportWidth: globalThis.innerWidth ?? view.clientWidth, viewportHeight: globalThis.innerHeight ?? view.clientHeight };
}
+function restingBox(mark) {
+ const box = mark.getBoundingClientRect();
+ const column = mark.closest?.(".bt-leftcol");
+ if (!column) return box;
+ const now = column.getBoundingClientRect();
+ const dx = column.offsetLeft - now.left;
+ const dy = column.offsetTop - now.top;
+ return { left: box.left + dx, top: box.top + dy, width: box.width, height: box.height };
+}
var GLIDE_MS = 460;
function glideOnto(mark, from) {
if (!mark || reducedMotion()) return;
- const box = mark.getBoundingClientRect();
+ const box = restingBox(mark);
if (!box.width) return;
const outer = document.createElement("div");
const inner = document.createElement("div");
diff --git a/ds-bot/src/client/sidebar.js b/ds-bot/src/client/sidebar.js
index cf68855f..85e18a58 100644
--- a/ds-bot/src/client/sidebar.js
+++ b/ds-bot/src/client/sidebar.js
@@ -935,11 +935,25 @@ function mainAvatarPlace(roster) {
const mark = mainMarkOf(main.id)
// Not the opacity: the column fades in as it first draws, which is when this is measured.
if (!mark || mark.checkVisibility?.({ visibilityProperty: true }) === false) return undefined
- const box = mark.getBoundingClientRect()
+ const box = restingBox(mark)
const view = document.documentElement
return { x: box.left, y: box.top, width: box.width, height: box.height, viewportWidth: globalThis.innerWidth ?? view.clientWidth, viewportHeight: globalThis.innerHeight ?? view.clientHeight }
}
+// The avatar's box where the team column comes to rest. The column also slides in as it first
+// draws (bt-leftcol-in, from off the left edge), and measured mid-slide the avatar would be
+// outside the page and the whale would have nowhere to land; offsetLeft and offsetTop leave the
+// slide's transform out.
+function restingBox(mark) {
+ const box = mark.getBoundingClientRect()
+ const column = mark.closest?.('.bt-leftcol')
+ if (!column) return box
+ const now = column.getBoundingClientRect()
+ const dx = column.offsetLeft - now.left
+ const dy = column.offsetTop - now.top
+ return { left: box.left + dx, top: box.top + dy, width: box.width, height: box.height }
+}
+
// The whale the start window hands over (app/src/start-window.mjs): `from` is where it is on
// this page at the top of its jump. A copy of the avatar waits there for `hold` ms, while the two
// windows cross-fade, then glides onto the avatar in one compositor animation, so the jump does
@@ -950,7 +964,7 @@ function mainAvatarPlace(roster) {
const GLIDE_MS = 460
function glideOnto(mark, from) {
if (!mark || reducedMotion()) return
- const box = mark.getBoundingClientRect()
+ const box = restingBox(mark)
if (!box.width) return
const outer = document.createElement('div')
const inner = document.createElement('div')
diff --git a/ds-bot/test/app-ready.test.js b/ds-bot/test/app-ready.test.js
index 637a021d..4e5b0ef4 100644
--- a/ds-bot/test/app-ready.test.js
+++ b/ds-bot/test/app-ready.test.js
@@ -116,6 +116,20 @@ test('the report says where the Main Bot\'s whale is drawn', async () => {
assert.deepEqual(JSON.parse(JSON.stringify(calls)), [[{ x: 98, y: 70, width: 60, height: 60, viewportWidth: 1280, viewportHeight: 800 }]])
})
+test('the place is where the team column comes to rest, not where its slide-in has it', async () => {
+ // Measured as the column first draws: its slide has it 270 px off to the left (and, to catch
+ // either axis, 10 px up).
+ const column = { offsetLeft: 0, offsetTop: 0, getBoundingClientRect: () => ({ left: -270, top: -10 }) }
+ const mark = { checkVisibility: () => true, closest: selector => (selector === '.bt-leftcol' ? column : null), getBoundingClientRect: () => ({ left: -172, top: 60, width: 60, height: 60 }) }
+ const { calls, app } = readyCalls()
+ mount(page(app, {
+ querySelector: selector => (selector === '.bt-side [data-bot-id="main"] .bt-mark' ? mark : null),
+ documentElement: { clientWidth: 1280, clientHeight: 800, setAttribute() {}, removeAttribute() {} },
+ }).TeamSidebar)(sidebarProps(whaleTeam))
+ await setImmediate()
+ assert.deepEqual(JSON.parse(JSON.stringify(calls)), [[{ x: 98, y: 70, width: 60, height: 60, viewportWidth: 1280, viewportHeight: 800 }]])
+})
+
test('a Main Bot in another look or a photo reports no place', async () => {
for (const avatar of [{ shape: 'star' }, { shape: 'whale', image: 'data:image/png;base64,AA' }]) {
const { calls, app } = readyCalls()
@@ -171,7 +185,9 @@ test('a whale handed over glides from where it was handed onto the Main Bot\'s a
made.push(el)
return el
}
- const mark = { ...element(), checkVisibility: () => true, getBoundingClientRect: () => ({ left: 98, top: 70, width: 60, height: 60 }), cloneNode: () => element() }
+ // The hand-off can come while the column still slides in: the copy goes where it comes to rest.
+ const column = { offsetLeft: 0, offsetTop: 0, getBoundingClientRect: () => ({ left: -40, top: 0 }) }
+ const mark = { ...element(), checkVisibility: () => true, closest: selector => (selector === '.bt-leftcol' ? column : null), getBoundingClientRect: () => ({ left: 58, top: 70, width: 60, height: 60 }), cloneNode: () => element() }
const body = element()
let handoff
const calls = []