A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.
Hand the whale over to the team page instead of growing the start window
AdamPlatin123a558c85e1022
diff --git a/app/src/main.mjs b/app/src/main.mjsindex 172a96a3..3689bb85 100644--- a/app/src/main.mjs+++ b/app/src/main.mjs@@ -27,7 +27,7 @@ import { CAPTION_HEIGHT, cssColor, micaAvailable, nativeThemeSource } from './wiconst IPC = {caption: 'ds-bot:caption-colors', nativeTheme: 'ds-bot:native-theme', fullscreen: 'ds-bot:fullscreen',dataLocation: 'ds-bot:data-location', moveData: 'ds-bot:move-data', teamWorkspace: 'ds-bot:team-workspace',- ready: 'ds-bot:ready', motion: 'ds-bot:motion',+ ready: 'ds-bot:ready', handoffReady: 'ds-bot:handoff-ready', motion: 'ds-bot:motion',card: 'ds-bot:app-card', cardShown: 'ds-bot:app-card-shown', cardAnswer: 'ds-bot:app-card-answer',browserAcquire: 'ds-bot:browser-acquire', browserRelease: 'ds-bot:browser-release', browserForget: 'ds-bot:browser-forget',browserViewChanged: 'ds-bot:browser-view-changed', browserViewCreate: 'ds-bot:browser-view-create',@@ -701,6 +701,8 @@ function handleIpc() {const fixed = Boolean(process.env.DS_BOT_HOME)// The team view has mounted (ds-bot calls dsBotApp.ready()): the start window hands over.ipcMain.on(IPC.ready, (event, report) => { if (fromWindow(event)) startWindow.ready(report) })+ // It has drawn the whale the start window hands over: the windows cross-fade.+ ipcMain.on(IPC.handoffReady, (event) => { if (fromWindow(event)) startWindow.teamReady() })ipcMain.on(IPC.cardShown, (event, id) => { if (fromWindow(event)) cards.get(id)?.shown() })ipcMain.on(IPC.cardAnswer, (event, id, index) => { if (fromWindow(event)) cards.get(id)?.settle(Number.isInteger(index) ? index : -1) })// The start window takes the app's theme and the Bot animation tier at the next start, beforediff --git a/app/src/preload.cjs b/app/src/preload.cjsindex 0daf4aa5..ec59a7eb 100644--- a/app/src/preload.cjs+++ b/app/src/preload.cjs@@ -25,6 +25,18 @@ if (startPage !== undefined) {ready = trueipcRenderer.send('ds-bot:ready', placeOf(place))},+ // The start window hands its whale over at the top of its jump (start-window.mjs): `run`+ // draws it where it is on this page, and once that is painted the main process cross-fades+ // the two windows.+ onHandoff: (run) => {+ if (typeof run !== 'function') return+ ipcRenderer.removeAllListeners('ds-bot:handoff')+ ipcRenderer.on('ds-bot:handoff', (_event, value) => {+ const from = handoffOf(value)+ if (from === undefined) return+ try { run(from) } finally { requestAnimationFrame(() => { requestAnimationFrame(() => { ipcRenderer.send('ds-bot:handoff-ready') }) }) }+ })+ },// DS Bot's settings show and move the app's data location through this.dataLocation: () => ipcRenderer.invoke('ds-bot:data-location'),moveData: (workspace) => ipcRenderer.invoke('ds-bot:move-data', typeof workspace === 'string' ? workspace : undefined),@@ -46,6 +58,16 @@ if (startPage !== undefined) {}return place}+ const handoffOf = (value) => {+ if (value === null || typeof value !== 'object') return undefined+ const from = {}+ for (const key of ['x', 'y', 'size', 'hold']) {+ const number = Number(value[key])+ if (!Number.isFinite(number)) return undefined+ from[key] = number+ }+ return from+ }// A preload runs before the document root exists.const loaded = (run) => {if (document.readyState === 'loading') window.addEventListener('DOMContentLoaded', run, { once: true })diff --git a/app/src/start-window.mjs b/app/src/start-window.mjsindex c0e7d7e1..c4b4e032 100644--- a/app/src/start-window.mjs+++ b/app/src/start-window.mjs@@ -19,14 +19,16 @@ export const PHASES = ['data', 'engine', 'team']export const START_KINDS = ['first', 'later', 'moving']export const WATCHDOG_MS = 180_000export const TEAM_VIEW_MS = 20_000-// handoffShow + 40 ms: the growth, 260 ms in steps of about 14 ms (§8). The page's content has-// faded by handoffShow, so the growth starts at once. The whale lands after the window has grown-// (whale.js GROWN_AFTER, LAND_AFTER); the reveal waits for that, LANDING_WAIT at most.-export const GROWTH = { delay: 40, duration: 260, step: 14 }-export const LANDING_WAIT = 300export const DESTROY_AFTER_MS = 300-// At the end of a growth the start window fades out over the team window under it.-export const FADE = { duration: 180, step: 16 }+// The hand-off (§8): the start window does not resize (stepped setBounds repaints only now and+// then, and the whale in it stutters). The team window, already under it, fades in while the+// start window fades out; window opacity is the compositor's. The team page gets the whale at the+// top of its jump and holds it there through the fade, then glides it onto the avatar.+export const CROSSFADE = { duration: 220, step: 16 }+export const HOLD_MS = CROSSFADE.duration + 40+// How long the team page may take to draw the whale it is handed before the fade starts anyway.+export const TEAM_WAIT_MS = 150+export const TEAM_HANDOFF = 'ds-bot:handoff'export const FAILURE_LINES = 200// 〔保存日志…〕 saves this many of the latest log lines, after the same header as the copied details.export const SAVED_LINES = 5000@@ -135,15 +137,6 @@ export function cubicBezier(x1, y1, x2, y2) {return y((low + high) / 2)}}-// Ease in and out over the whole growth: a quick start with a long tail looks done early and-// leaves the whale waiting in an empty window.-export const GROWTH_EASING = cubicBezier(0.45, 0, 0.25, 1)--export function rectAt(from, to, progress) {- const at = key => Math.round(from[key] + (to[key] - from[key]) * progress)- return { x: at('x'), y: at('y'), width: at('width'), height: at('height') }-}-/*** Where the start page's whale lands at the hand-off (start-window §8): the Main Bot's avatar as* the team view reported it, in CSS px of that page, turned into DIP and then into the start@@ -164,14 +157,20 @@ export function landingOf(report, { team, start }) {return { x: round(team.x + x * scale - start.x), y: round(team.y + y * scale - start.y), size: round(((width + height) / 2) * scale) }}-/** The rects of the growth, one per step; the last one is the target at the full duration. */-export function growthSteps(from, to, { duration, step } = GROWTH) {- const steps = []- for (let at = step; ; at += step) {- const time = Math.min(at, duration)- steps.push({ at: time, rect: rectAt(from, to, GROWTH_EASING(time / duration)) })- if (time >= duration) return steps- }+/**+ * The whale the start page hands over, in CSS px of the team page: the start page's own box+ * ({ x, y, size } in its CSS px, which are DIP) through both windows' content origins and the+ * team page's zoom. Undefined unless it is a plausible box.+ * @param {unknown} whale { x, y, size }+ * @param {{ start: { x: number, y: number }, team: { x: number, y: number, width: number }, viewportWidth: number }} windows+ */+export function handoffBox(whale, { start, team, viewportWidth }) {+ if (whale === null || typeof whale !== 'object') return undefined+ const [x, y, size] = ['x', 'y', 'size'].map(key => Number(whale[key]))+ if (![x, y, size, viewportWidth].every(Number.isFinite) || size < 16 || viewportWidth <= 0) return undefined+ const zoom = team.width / viewportWidth+ const round = value => Math.round(value * 2) / 2+ return { x: round((start.x + x - team.x) / zoom), y: round((start.y + y - team.y) / zoom), size: round(size / zoom) }}// When the page never sends handoffShow, the main process shows the team window itself. The page@@ -278,11 +277,8 @@ export class StartWindow {#phaseAt = 0#readyAt = 0#showAt = 0- #from#handing = false#under = false- #grown = false- #landed = false#revealed = false// Whether the engine of this attempt is up; the stages done say where the whale is, which a// retry never moves back.@@ -722,7 +718,7 @@ export class StartWindow {return false}if (name === 'handoffShow') this.#handoffShow(payload)- else if (name === 'handoffDone') this.#handoffDone()+ else if (name === 'handoffDone') note(`handoffDone at handoffShow + ${String(Date.now() - this.#showAt)} ms`)else if (name === 'retry') this.#retry()else if (name === 'wait') this.#wait()else if (name === 'reloadView') this.#reload()@@ -785,6 +781,7 @@ export class StartWindow {}}+ // The page's content has faded; with a landing it is at the top of its jump and says where.#handoffShow(payload) {if (this.#handing || this.#state.view !== 'handoff') returnconst main = this.#o.mainWindow()@@ -793,21 +790,36 @@ export class StartWindow {this.#clear('fallback')this.#showAt = Date.now()note(`handoffShow at ready + ${String(this.#showAt - this.#readyAt)} ms`)- const win = this.#window- this.#from = win.getBounds()// The start window may have been dragged since the team window was placed.- const target = this.placeMain(main)- const grow = !(payload !== null && typeof payload === 'object' && payload.grow === false) && !win.isMinimized() && !this.#reducedMotion()- if (!grow) { this.#reveal(); return }- this.#grown = false- this.#landed = false- this.#later('grow', GROWTH.delay, () => { this.#grow(this.#from, target) })+ this.placeMain(main)+ const box = this.#state.landing === undefined || this.#readyReport === undefined ? undefined : this.#teamBox(main, payload)+ if (box === undefined || !this.#under) { this.#reveal(); return }+ main.webContents.send(TEAM_HANDOFF, { ...box, hold: HOLD_MS })+ this.#later('teamWait', TEAM_WAIT_MS, () => { note('the team page did not say it drew the whale'); this.#reveal() })+ }++ /** The team page has drawn the whale it was handed: the windows cross-fade. */+ teamReady() {+ if (!this.#handing || this.#revealed || this.#timers.teamWait === undefined) return+ note(`the team page drew the whale at handoffShow + ${String(Date.now() - this.#showAt)} ms`)+ this.#reveal()+ }++ #teamBox(main, payload) {+ try {+ const whale = payload !== null && typeof payload === 'object' ? payload.whale : undefined+ const start = this.#window.getContentBounds()+ const team = main.getContentBounds()+ return handoffBox(whale, { start, team, viewportWidth: Number(this.#readyReport.viewportWidth) })+ } catch (error) {+ note(`no whale to hand over (${error instanceof Error ? error.message : String(error)})`)+ return undefined+ }}// At ready() the team window shows, see-through, out of the taskbar and under the start window,// so that Windows' own opening transition has run by the reveal (shown at the reveal, it dims- // the page and doubles the whale over the start window for a few frames), and so that showing- // a window this large does not hold up the growth's first step.+ // the page for a few frames) and the team page is drawn and can take the whale.#underlay(main) {try {main.setSkipTaskbar(true)@@ -829,30 +841,6 @@ export class StartWindow {main.setSkipTaskbar(false)}- // Electron ignores setBounds' animate flag on Windows, so the growth is stepped here; each step- // eases from the time it really runs at, so a busy machine skips steps rather than stretching.- #grow(from, to) {- const began = Date.now()- note(`growing at handoffShow + ${String(began - this.#showAt)} ms`)- const step = () => {- if (!this.#open()) return- const time = Math.min(1, (Date.now() - began) / GROWTH.duration)- this.#window.setBounds(rectAt(from, to, GROWTH_EASING(time)))- if (time < 1) { this.#later('grow', GROWTH.step, step); return }- this.#grown = true- if (this.#landed) this.#reveal()- else this.#later('land', LANDING_WAIT, () => { note('the whale did not land in time'); this.#reveal() })- }- this.#later('grow', GROWTH.step, step)- }-- // The whale has landed on the avatar (or dived): the team window shows once the growth is done.- #handoffDone() {- note(`handoffDone at handoffShow + ${String(Date.now() - this.#showAt)} ms`)- this.#landed = true- if (this.#handing && this.#grown) this.#reveal()- }-// The team window shows on its rect: with the focus when the start window had it; otherwise// behind nothing new, flashing its taskbar button; minimized when the start window was.#reveal() {@@ -862,8 +850,7 @@ export class StartWindow {this.#revealed = truethis.#showTeam()this.#clear('fallback')- this.#clear('grow')- this.#clear('land')+ this.#clear('teamWait')const win = this.#windowconst how = win.isMinimized() ? 'minimized' : win.isFocused() ? 'focused' : 'behind'if (this.#under && how !== 'minimized') { this.#crossfade(main, win, how); return }@@ -887,20 +874,21 @@ export class StartWindow {this.#later('destroy', DESTROY_AFTER_MS, () => { this.#destroy() })}- // The team window, already drawn and the size of the start window, turns opaque under it, and- // the start window fades out over it: the whale on the start page dissolves into the avatar- // it landed on. Layered opacity is the compositor's, so the fade costs no layout.+ // The team window, on its rect around and under the start window, fades in while the start+ // window fades out over it. With a whale handed over, the team page holds it where the start+ // page's whale is through this fade, so the two stay on each other.#crossfade(main, win, how) {- main.setOpacity(1)main.setSkipTaskbar(false)win.setSkipTaskbar(true)- note(`team window under the start window at ready + ${String(Date.now() - this.#readyAt)} ms`)+ note(`cross-fade at ready + ${String(Date.now() - this.#readyAt)} ms`)const began = Date.now()const step = () => {- if (!this.#open()) return- const time = Math.min(1, (Date.now() - began) / FADE.duration)- win.setOpacity(1 - time * time * (3 - 2 * time))- if (time < 1) { this.#later('fade', FADE.step, step); return }+ if (!this.#open() || main.isDestroyed()) return+ const time = Math.min(1, (Date.now() - began) / CROSSFADE.duration)+ const eased = time * time * (3 - 2 * time)+ main.setOpacity(eased)+ win.setOpacity(1 - eased)+ if (time < 1) { this.#later('fade', CROSSFADE.step, step); return }if (how === 'focused') main.focus()else {main.flashFrame(true)@@ -909,17 +897,15 @@ export class StartWindow {note(`team window shown (${how}) at ready + ${String(Date.now() - this.#readyAt)} ms`)this.#destroy()}- this.#later('fade', FADE.step, step)+ step()}#cancelHandoff() {const main = this.#o.mainWindow()if (this.#under && !this.#revealed && main !== undefined) this.#unlay(main)if (!this.#handing || this.#revealed) return- this.#clear('grow')- this.#clear('land')+ this.#clear('teamWait')this.#handing = false- if (this.#from !== undefined && this.#open()) this.#window.setBounds(this.#from)}#destroy() {@@ -927,14 +913,6 @@ export class StartWindow {if (win !== undefined && !win.isDestroyed()) win.destroy()}- #reducedMotion() {- try {- return this.#o.electron.systemPreferences.getAnimationSettings().prefersReducedMotion === true- } catch {- return false- }- }-#later(name, ms, run) {this.#clear(name)this.#timers[name] = setTimeout(() => {diff --git a/app/src/start/whale.js b/app/src/start/whale.jsindex e6da942e..573392e2 100644--- a/app/src/start/whale.js+++ b/app/src/start/whale.js@@ -363,7 +363,7 @@ export function createDirector({ start, resume, act, label, announce, onCheck, oconst per = big ? 3 : 2for (const side of [-1, 1]) for (let i = 0; i < per; i += 1) fallDrop(side * 18 * k, -31 * k, { dx: side * (4 + i * 5 + rnd() * 3), fall: 70 + i * 10 + rnd() * 10, delay: 330 + i * 70, size: 5 + rnd() * 1.5 })fallDrop(0, -38 * k, { dx: (rnd() - 0.5) * 6, fall: 80, delay: 400, size: 6 })- // At the hand-off the dive sends the ripple; this one would land as the window grows.+ // At the hand-off the dive sends the ripple; this one would land as the window fades.if (!D.handed) setTimeout(sendRipple, 760)}setTimeout(() => shape.remove(), 900)@@ -709,18 +709,20 @@ export function createDirector({ start, resume, act, label, announce, onCheck, oif (reduced()) return stillHandoff(at)release(pose, { duration: 200, easing: 'ease-out' })if (want.celebrate) return spoutHandoff(at)- // A beat for the ring to close, then the dive or the jump: handoffShow at 220 ms.+ // A beat for the ring to close, then the jump (handoffShow at its top, 100 + RISE_MS) or the+ // dive (handoffShow at 220 ms).await at(100)root.dataset.exit = 'caption all'- const flight = want.landing ? leap(want.landing, 220 + GROWN_AFTER + LAND_AFTER - 100) : 0- if (!flight) dive(12, DEEP(), 18, spring('tap'))+ if (want.landing) return jump(at, 100)+ dive(12, DEEP(), 18, spring('tap'))await at(220)act('handoffShow')- await at(flight ? 100 + flight : 390)+ await at(390)act('handoffDone')}// A celebrating hand-off (a first start, or the first success after a failure) spouts as the- // ring closes and jumps (or dives) once the column has opened: handoffShow at 720 ms.+ // ring closes and jumps (or dives) once the column has opened: handoffShow at the top of the+ // jump (560 + RISE_MS), or at 720 ms with the dive.async function spoutHandoff(at) {drop(body)play(body, kf([{ scale: '1' }, { scale: '1.12 .88', offset: 240 / 460 }, { scale: '.93 1.09' }], OUT), { duration: 460 })@@ -730,13 +732,13 @@ export function createDirector({ start, resume, act, label, announce, onCheck, oroot.dataset.exit = 'caption'await at(560)root.dataset.exit = 'caption all'- const flight = want.landing ? leap(want.landing, 720 + GROWN_AFTER + LAND_AFTER - 560) : 0- if (!flight) dive(18, DEEP(), 24, spring('shape'))+ if (want.landing) return jump(at, 560)+ dive(18, DEEP(), 24, spring('shape'))await at(660)- if (!flight) sendRipple()+ sendRipple()await at(720)act('handoffShow')- await at(flight ? 560 + flight : 980)+ await at(980)act('handoffDone')}// Reduced motion: the arcs' .12 s fill and the closed ring are seen before the content fades;@@ -750,54 +752,39 @@ export function createDirector({ start, resume, act, label, announce, onCheck, oawait at(440)act('handoffDone')}- // The jump to the Main Bot (start-window §8). The team view said where the Main Bot's avatar is- // drawn, and the main process turned that into this page's coordinates once the window has- // grown onto the team window's rect. The whale leaves the lane (its clip would cut it at the- // waterline) for the window-wide .flight layer, rises out of the water and glides down onto the- // avatar, shrinking to its size. The window grows from handoffShow + 40 ms for 260 ms (GROWTH in- // start-window.mjs) while the whale rises and starts over, and the whale lands LAND_AFTER later,- // in a window that no longer moves; handoffDone then lets the team window show under it, and- // the start window fades out over it. Returns how long the flight takes.- function leap(landing, ms) {- // It arrives as the avatar sits: upright, unstretched (the celebration's squash, a failure's- // pose before a late or held hand-off) and looking ahead.- const settleIn = { duration: Math.round(ms * 0.4), easing: OUT }+ // The jump to the Main Bot (start-window §8). The whale leaves the lane (its clip would cut it+ // at the waterline) for the window-wide .flight layer and rises out of the water, upright and+ // looking ahead as the avatar sits, and stops at the top. handoffShow says where it is: the+ // team page draws the same whale there and holds it while the two windows cross-fade, then+ // glides it onto the Main Bot's avatar. The start window never resizes under it.+ async function jump(at, from) {+ const settleIn = { duration: Math.round(RISE_MS * 0.6), easing: OUT }to(body, { scale: '1' }, settleIn)to(move, { transform: 'none' }, settleIn)setBase(0, 0)const box = x.getBoundingClientRect()- const flight = $('.flight')for (const a of scripted(x)) a.cancel()- flight.append(x)+ $('.flight').append(x)x.style.left = `${box.left}px`x.style.top = `${box.top}px`x.style.transformOrigin = '0 0'- // The pond may still be shrunk for a card that has just gone: start at the size it shows.- const from = box.width / x.offsetWidth- const scale = landing.size / x.offsetWidth- const dx = landing.x - box.left- const dy = landing.y - box.top- // Up first, then over: the high point is above both ends.- const rise = `translate(${(dx * 0.22).toFixed(1)}px, ${(Math.min(0, dy) * 0.78 - 18).toFixed(1)}px) scale(${(from + (scale - from) * 0.45).toFixed(3)})`- play(x, [- { transform: `translate(0px, 0px) scale(${from.toFixed(3)})`, easing: 'cubic-bezier(.2,.7,.4,1)' },- { transform: rise, offset: 0.4, easing: 'cubic-bezier(.45,0,.25,1)' },- { transform: `translate(${dx.toFixed(1)}px, ${dy.toFixed(1)}px) scale(${scale.toFixed(3)})` },- ], { duration: ms, fill: 'forwards' })+ // The pond may still be shrunk for a card that has just gone: it rises at the size it shows.+ const scale = (box.width / x.offsetWidth).toFixed(3)+ play(x, [{ transform: `translate(0px, 0px) scale(${scale})` }, { transform: `translate(0px, ${String(-LIFT)}px) scale(${scale})` }], { duration: RISE_MS, easing: 'cubic-bezier(.2,.7,.4,1)', fill: 'forwards' })if (playful()) {const strokes = play(tail, [{ transform: 'none' }, { transform: 'rotate(12deg)' }, { transform: 'rotate(-12deg)' }, { transform: 'none' }], { duration: 240, iterations: 2, easing: 'ease-in-out', fill: 'none' })strokes.done.then(() => strokes.cancel())}- // It lands with the avatar's open eyes (the celebration gave it ^ ^ ones).- if (want.celebrate && playful()) setTimeout(() => happyEyes(false), Math.round(ms * 0.7))- return ms- }- // From handoffShow to the end of the growth (GROWTH.delay + GROWTH.duration), and how long after- // it the whale lands: the end of the glide is seen in a still window.- const GROWN_AFTER = 300- const LAND_AFTER = 60- // 1.25 x the whale's height: fully under the waterline within about 200 ms, so the window- // can grow around an empty sheet.+ // It reaches the top with the avatar's open eyes (the celebration gave it ^ ^ ones).+ if (want.celebrate && playful()) setTimeout(() => happyEyes(false), Math.round(RISE_MS * 0.6))+ await at(from + RISE_MS)+ act('handoffShow', { whale: { x: box.left, y: box.top - LIFT, size: box.width } })+ await at(from + RISE_MS + 260)+ act('handoffDone')+ }+ const RISE_MS = 300+ const LIFT = 40+ // 1.25 x the whale's height: fully under the waterline within about 200 ms.const DEEP = () => Math.round(125 * u)function dive(dx, dy, deg, curve) {to(body, { scale: '1' }, curve)diff --git a/app/test/start-page.test.mjs b/app/test/start-page.test.mjsindex fa8bb1ae..75393ad7 100644--- a/app/test/start-page.test.mjs+++ b/app/test/start-page.test.mjs@@ -3,7 +3,7 @@ import { spawnSync } from 'node:child_process'import { existsSync, readFileSync } from 'node:fs'import { test } from 'node:test'import { fileURLToPath } from 'node:url'-import { GROWTH, START_ACTS } from '../src/start-window.mjs'+import { START_ACTS } from '../src/start-window.mjs'import { langOf, TEXT, t } from '../src/start/text.mjs'const dir = new URL('../src/start/', import.meta.url)@@ -94,9 +94,9 @@ test('the start page draws the progress as a ring of three arcs and a closing ciassert.match(html, /<div class="pond">\r?\n<svg class="ring"[\s\S]*?<div class="water"[\s\S]*?<div class="lane">[\s\S]*?<span class="spout"><svg class="plume"[^>]*\shidden>[\s\S]*?<div class="whale-hit"[\s\S]*?<div class="fx" aria-hidden="true"><span class="ripple"><\/span><\/div>\r?\n<\/div>/u)assert.doesNotMatch(html, /class="(?:trace|elapsed)"/u)// The layer the whale flies in to the Main Bot's avatar at the hand-off (whale.js leap), and- // the flight tied to the end of the main process's growth.+ // the whale's box at the top of its jump, which the team page takes over.assert.match(html, /<\/main>\r?\n<div class="flight" aria-hidden="true"><\/div>/u)- assert.match(code['whale.js'], new RegExp(`const GROWN_AFTER = ${String(GROWTH.delay + GROWTH.duration)}\\b`, 'u'))+ assert.match(code['whale.js'], /act\('handoffShow', \{ whale: \{ x: box\.left, y: box\.top - LIFT, size: box\.width \} \}\)/u)assert.doesNotMatch(read('start.css'), /\.(?:trace|elapsed)\b/u)})diff --git a/app/test/start-window.test.mjs b/app/test/start-window.test.mjsindex 9e3cb68b..083a07d4 100644--- a/app/test/start-window.test.mjs+++ b/app/test/start-window.test.mjs@@ -6,8 +6,8 @@ import { join } from 'node:path'import { test } from 'node:test'import { readStartFrame, writeStartFrame } from '../src/start-frame.mjs'import {- acceptsAct, centred, clampInto, clockMs, cubicBezier, detailsText, explainOf, failureReason, fallbackMs, FADE, GROWTH, GROWTH_EASING, LANDING_WAIT,- growthSteps, isStartPage, landingOf, MAIN_SIZE, mainRect, START_ACT, START_ACTS, START_STATE, startSize, startSnapshot, startUrl, StartWindow,+ acceptsAct, centred, clampInto, clockMs, cubicBezier, detailsText, explainOf, failureReason, fallbackMs, CROSSFADE, handoffBox, HOLD_MS, TEAM_HANDOFF, TEAM_WAIT_MS,+ isStartPage, landingOf, MAIN_SIZE, mainRect, START_ACT, START_ACTS, START_STATE, startSize, startSnapshot, startUrl, StartWindow,TEAM_VIEW_MS, WATCHDOG_MS,} from '../src/start-window.mjs'@@ -39,43 +39,8 @@ test('the team window is centred on the start window and stays inside the work atest('the easing is CSS cubic-bezier()', () => {const ease = cubicBezier(0.25, 0.1, 0.25, 1)assert.ok(Math.abs(ease(0.5) - 0.8024) < 1e-3)- assert.equal(GROWTH_EASING(0), 0)- assert.equal(GROWTH_EASING(1), 1)- let previous = 0- for (let step = 1; step <= 100; step += 1) {- const value = GROWTH_EASING(step / 100)- assert.ok(value >= previous && value <= 1, `at ${String(step)}%`)- previous = value- }- // cubic-bezier(.45, 0, .25, 1) eases in and out: slow at both ends, not done early.- assert.ok(GROWTH_EASING(0.2) < 0.15)- assert.ok(GROWTH_EASING(0.5) > 0.6 && GROWTH_EASING(0.5) < 0.8)- assert.ok(GROWTH_EASING(0.8) > 0.95)-})--test('the start window grows into the team window in about 14 ms steps over 260 ms', () => {- const from = centred(startSize(AREA), AREA)- const to = mainRect(from, AREA)- const steps = growthSteps(from, to)- assert.equal(GROWTH.duration, 260)- assert.equal(GROWTH.delay, 40)- assert.equal(steps.length, 19)- assert.deepEqual(steps.at(-1), { at: 260, rect: to })- assert.ok(steps.every((step, index) => index === 0 || step.at > steps[index - 1].at))- assert.ok(steps.slice(0, -1).every(step => step.at % 14 === 0))- for (const key of ['x', 'y', 'width', 'height']) {- const toward = Math.sign(to[key] - from[key])- let previous = from[key]- for (const { rect } of steps) {- assert.ok((rect[key] - previous) * toward >= 0, `${key} turns back`)- previous = rect[key]- }- }- // At least one size between the two: a growth, not a jump.- assert.ok(steps.some(({ rect }) => rect.width > from.width && rect.width < to.width))- // The same rects from wherever the start window was dragged to.- const dragged = { x: 40, y: 30, width: 720, height: 540 }- assert.deepEqual(growthSteps(dragged, mainRect(dragged, AREA)).at(-1).rect, { x: 0, y: 0, ...MAIN_SIZE })+ assert.equal(ease(0), 0)+ assert.equal(ease(1), 1)})test('the team window shows by itself after 2.5 s on a first start or a celebration, else 0.8 s', () => {@@ -268,7 +233,8 @@ function fakeElectron() {sent = []reloads = 0mainFrame = { url: '' }- send(channel, state) { if (channel === START_STATE) this.sent.push(state) }+ other = []+ send(channel, state) { if (channel === START_STATE) this.sent.push(state); else this.other.push([channel, state]) }setWindowOpenHandler() {}toggleDevTools() {}reload() { this.reloads += 1; this.emit('dom-ready') }@@ -476,12 +442,13 @@ for (const [kind, wait] of [['first', 2500], ['later', 800]]) {s.tick(wait - 1)assert.equal(s.main.calls.includes('opacity 1'), false)s.tick(1)- // It waited see-through under the start window, which fades out over it without growing.- assert.deepEqual(s.main.calls.slice(-2), ['opacity 1', 'skipTaskbar false'])+ // It waited see-through under the start window; the two cross-fade.+ assert.ok(s.main.calls.includes('skipTaskbar false'))assert.ok(s.win().calls.includes('skipTaskbar true'))await s.start.teamShownconst start = s.win()- for (let ms = 0; ms <= FADE.duration; ms += FADE.step) s.tick(FADE.step)+ for (let ms = 0; ms <= CROSSFADE.duration; ms += CROSSFADE.step) s.tick(CROSSFADE.step)+ assert.equal(s.main.opacity, 1)assert.equal(start.destroyed, true)assert.equal(s.main.calls.at(-1), 'focus')// Gone after the hand-off, the start window does not quit the app.@@ -489,79 +456,85 @@ for (const [kind, wait] of [['first', 2500], ['later', 800]]) {})}-test('after handoffShow the start window grows into the team window\'s rect, and the team window shows on it', (t) => {- const s = startWindow(t)- s.start.open('later')- s.start.done('data')- s.start.done('engine')- s.start.ready()- const from = s.win().getBounds()- assert.equal(s.act('handoffShow'), true)- const target = mainRect(from, AREA)- assert.deepEqual(s.main.bounds, target)- s.tick(GROWTH.delay - 1)- assert.deepEqual(s.win().bounds, from)- s.tick(1)- const widths = []- for (let step = 0; step < 40 && !s.main.calls.includes('opacity 1'); step += 1) {- s.tick(GROWTH.step)- widths.push(s.win().bounds.width)- }- assert.equal(s.main.visible, true)- assert.deepEqual(s.win().bounds, target)- assert.ok(widths.some(width => width > from.width && width < target.width), 'the start window jumps instead of growing')- // A second handoffShow does nothing.- assert.equal(s.act('handoffShow'), true)- assert.equal(s.main.calls.filter(call => call === 'showInactive').length, 1)-})--test('the team window shows once the whale has landed and the window has grown, or a while after', (t) => {- for (const landed of [true, false]) {- const s = startWindow(t)- s.start.open('later')- s.start.done('data')- s.start.done('engine')- s.start.ready()- s.act('handoffShow')- for (let ms = 0; ms <= GROWTH.delay + GROWTH.duration + GROWTH.step; ms += GROWTH.step) s.tick(GROWTH.step)- assert.deepEqual(s.win().bounds, s.main.bounds)- assert.equal(s.main.calls.includes('opacity 1'), false, 'it shows before the whale has landed')- if (landed) {- assert.equal(s.act('handoffDone'), true)- assert.equal(s.main.calls.includes('opacity 1'), true)- } else {- for (let ms = 0; ms < LANDING_WAIT; ms += GROWTH.step) s.tick(GROWTH.step)- assert.equal(s.main.calls.includes('opacity 1'), true)- }- t.mock.timers.reset()+test('the whale the start page hands over is put in the team page\'s own coordinates', () => {+ const team = { x: 300, y: 90, width: 1280, height: 860 }+ const start = { x: 580, y: 250 }+ assert.deepEqual(handoffBox({ x: 304, y: 147, size: 112 }, { start, team, viewportWidth: 1280 }), { x: 584, y: 307, size: 112 })+ // A team page zoomed to 125 %: its CSS px are larger than DIP.+ assert.deepEqual(handoffBox({ x: 304, y: 147, size: 112 }, { start, team, viewportWidth: 1024 }), { x: 467, y: 245.5, size: 89.5 })+ for (const whale of [undefined, null, 'whale', { x: 1 }, { x: 1, y: 1, size: 4 }, { x: Number.NaN, y: 1, size: 112 }]) {+ assert.equal(handoffBox(whale, { start, team, viewportWidth: 1280 }), undefined, JSON.stringify(whale))}})-test('the team window waits see-through under the growing start window, which then fades out over it', (t) => {+// The start window never resizes: the team window, see-through under it since ready(), takes the+// whale, and the two windows cross-fade.+function handingOver(t, { focused = true } = {}) {const s = startWindow(t)s.start.open('later')- s.win().focused = true+ s.win().focused = focused+ s.start.placeMain()s.start.done('data')s.start.done('engine')- s.start.ready()- // Shown at ready(), so that Windows' opening transition runs before the reveal, but not seen.+ s.start.ready(AVATAR)+ return s+}++test('the team window waits see-through under the start window from ready() on', (t) => {+ const s = handingOver(t)assert.deepEqual(s.main.calls.slice(-3), ['skipTaskbar true', 'opacity 0', 'showInactive'])assert.equal(s.win().calls.at(-1), 'moveTop')- s.act('handoffShow')- for (let step = 0; step < 60 && !s.main.calls.includes('opacity 1'); step += 1) s.tick(GROWTH.step)- assert.deepEqual(s.main.calls.slice(-2), ['opacity 1', 'skipTaskbar false'])- assert.deepEqual(s.win().bounds, s.main.bounds)+ assert.equal(s.main.visible, true)+})++test('at handoffShow the team page gets the whale, and the windows cross-fade once it has drawn it', (t) => {+ const s = handingOver(t)+ const from = s.win().getBounds()+ assert.equal(s.act('handoffShow', { whale: { x: 304, y: 147, size: 112 } }), true)+ const [[channel, box]] = s.main.webContents.other+ assert.equal(channel, TEAM_HANDOFF)+ assert.equal(box.hold, HOLD_MS)+ assert.deepEqual({ x: box.x, y: box.y, size: box.size }, handoffBox({ x: 304, y: 147, size: 112 }, { start: from, team: s.main.bounds, viewportWidth: AVATAR.viewportWidth }))+ assert.equal(s.main.calls.includes('skipTaskbar false'), false, 'it shows before the team page has the whale')+ s.start.teamReady()+ assert.ok(s.main.calls.includes('skipTaskbar false'))const start = s.win()- s.tick(FADE.duration / 2)+ s.tick(CROSSFADE.duration / 2)assert.ok(start.opacity > 0 && start.opacity < 1, 'the start window does not fade')+ assert.ok(s.main.opacity > 0 && s.main.opacity < 1, 'the team window does not fade in')assert.equal(s.main.calls.includes('focus'), false)- s.tick(FADE.duration)+ s.tick(CROSSFADE.duration)assert.equal(start.opacity, 0)+ assert.equal(s.main.opacity, 1)assert.equal(start.destroyed, true)assert.equal(s.main.calls.at(-1), 'focus')+ // It never resized.+ assert.equal(start.calls.includes('setBounds'), false)assert.equal(s.calls.close, 0)})+test('the cross-fade starts anyway when the team page does not say it drew the whale', (t) => {+ const s = handingOver(t)+ s.act('handoffShow', { whale: { x: 304, y: 147, size: 112 } })+ s.tick(TEAM_WAIT_MS - 1)+ assert.equal(s.main.calls.includes('skipTaskbar false'), false)+ s.tick(1)+ assert.ok(s.main.calls.includes('skipTaskbar false'))+})++test('without a whale to hand over (a dive, or no box) the windows cross-fade at once', (t) => {+ for (const payload of [undefined, { whale: { x: 1 } }]) {+ const s = handingOver(t)+ s.act('handoffShow', payload)+ assert.deepEqual(s.main.webContents.other, [])+ assert.ok(s.main.calls.includes('skipTaskbar false'))+ // A second handoffShow does nothing.+ assert.equal(s.act('handoffShow'), true)+ assert.equal(s.main.calls.filter(call => call === 'showInactive').length, 1)+ t.mock.timers.reset()+ }+})+for (const how of ['behind', 'minimized']) {test(`the team window comes up ${how} when the start window is`, (t) => {const s = startWindow(t)@@ -572,9 +545,9 @@ for (const how of ['behind', 'minimized']) {s.start.done('engine')s.start.ready()s.act('handoffShow')- for (let step = 0; step < 60 && !s.main.calls.includes('flash true'); step += 1) s.tick(GROWTH.step)- // Behind: it waited under the start window and is uncovered by the fade; minimized: no growth.- assert.deepEqual(s.main.calls.slice(-2), how === 'behind' ? ['skipTaskbar false', 'flash true'] : ['minimize', 'flash true'])+ for (let step = 0; step < 60 && !s.main.calls.includes('flash true'); step += 1) s.tick(CROSSFADE.step)+ // Behind: it waited under the start window and fades in; minimized: it comes up minimized.+ assert.deepEqual(s.main.calls.slice(-2), how === 'behind' ? ['opacity 1', 'flash true'] : ['minimize', 'flash true'])assert.equal(s.main.calls.includes('focus'), false)})}@@ -656,13 +629,14 @@ test('a failure during the hand-off draws the failure page on a fresh page', (t)s.start.done('data')s.start.done('engine')s.start.ready()- s.act('handoffShow')- s.tick(GROWTH.delay + GROWTH.step)+ s.tick(300)s.start.fail(new Error('The DSH Host stopped (exit 1)'))assert.equal(s.state().view, 'failed')assert.equal(s.win().webContents.reloads, 1)- // The growth is undone, and the team window stays hidden.+ // The team window that waited under the start window is hidden again.assert.deepEqual(s.win().bounds, centred(startSize(AREA), AREA))+ assert.equal(s.main.visible, false)+ assert.equal(s.main.opacity, 1)s.tick(5000)assert.equal(s.main.visible, false)assert.equal(s.act('handoffShow'), false)diff --git a/ds-bot/client.js b/ds-bot/client.jsindex 1b9115a9..c6292802 100644--- a/ds-bot/client.js+++ b/ds-bot/client.js@@ -10144,30 +10144,75 @@ function useReportReady(drawn, roster) {if (!drawn || readyReported) return;readyReported = true;void Promise.resolve().then(() => {- const ready = globalThis.dsBotApp?.ready;- if (typeof ready !== "function") return void 0;+ const app = globalThis.dsBotApp;+ if (typeof app?.ready !== "function") return void 0;let place;try {place = mainAvatarPlace(roster);} catch {place = void 0;}- return place === void 0 ? ready() : ready(place);+ if (place === void 0) return app.ready();+ const mainId = roster.mainBotId;+ app.onHandoff?.((from) => {+ try {+ glideOnto(mainMarkOf(mainId), from);+ } catch (error) {+ quietly("handoff")(error);+ }+ });+ return app.ready(place);}).catch(quietly("app ready"));}, [drawn]);}+function mainMarkOf(id) {+ if (typeof document === "undefined") return null;+ const key = typeof CSS !== "undefined" && CSS.escape ? CSS.escape(id) : id;+ return document.querySelector(`.bt-side [data-bot-id="${key}"] .bt-mark`);+}function mainAvatarPlace(roster) {const main = roster?.byId?.[roster.mainBotId];if (main === void 0 || main.avatar?.image || typeof document === "undefined") return void 0;const look = lookOf(main);if (look.shape !== MAIN_LOOK.shape || look.color !== MAIN_LOOK.color) return void 0;- const id = typeof CSS !== "undefined" && CSS.escape ? CSS.escape(main.id) : main.id;- const mark = document.querySelector(`.bt-side [data-bot-id="${id}"] .bt-mark`);+ const mark = mainMarkOf(main.id);if (!mark || mark.checkVisibility?.({ visibilityProperty: true }) === false) return void 0;const box = mark.getBoundingClientRect();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 };}+var GLIDE_MS = 460;+function glideOnto(mark, from) {+ if (!mark || reducedMotion()) return;+ const box = mark.getBoundingClientRect();+ if (!box.width) return;+ const outer = document.createElement("div");+ const inner = document.createElement("div");+ const copy2 = mark.cloneNode(true);+ copy2.removeAttribute("data-live");+ Object.assign(outer.style, { position: "fixed", left: `${box.left}px`, top: `${box.top}px`, width: `${box.width}px`, height: `${box.height}px`, zIndex: "2147483647", pointerEvents: "none" });+ Object.assign(inner.style, { width: "100%", height: "100%", transformOrigin: "0 0" });+ Object.assign(copy2.style, { width: "100%", height: "100%" });+ copy2.style.setProperty("--bt-ink-deepseek", getComputedStyle(mark).getPropertyValue("--bt-ink-deepseek"));+ inner.append(copy2);+ outer.append(inner);+ outer.setAttribute("aria-hidden", "true");+ document.body.append(outer);+ mark.style.opacity = "0";+ const timing = { delay: Math.max(0, Number(from.hold) || 0), duration: GLIDE_MS, fill: "both" };+ outer.animate([{ transform: `translateX(${from.x - box.left}px)` }, { transform: "none" }], { ...timing, easing: "cubic-bezier(.45,0,.25,1)" });+ const glide = inner.animate([{ transform: `translateY(${from.y - box.top}px) scale(${from.size / box.width})` }, { transform: "none" }], { ...timing, easing: "cubic-bezier(.2,.65,.3,1)" });+ let landed = false;+ const land = () => {+ if (landed) return;+ landed = true;+ outer.remove();+ mark.style.opacity = "";+ mark.animate([{ transform: "scale(1.08, .92)" }, { transform: "none" }], { duration: SPRING_POP.duration, easing: SPRING_POP.easing });+ };+ glide.finished.then(land, land);+ setTimeout(land, timing.delay + GLIDE_MS + 500);+}function useLandOnMainBot(roster, useSessions, actions) {const mainView = useSessions((list) => {const row = Object.values(list.byId).find((session) => (session?.retainedBy?.mainView ?? 0) > 0);diff --git a/ds-bot/src/client/sidebar.js b/ds-bot/src/client/sidebar.jsindex 66b31856..ac5eb8be 100644--- a/ds-bot/src/client/sidebar.js+++ b/ds-bot/src/client/sidebar.js@@ -8,7 +8,7 @@ import { lookOf, MAIN_LOOK } from './characters.js'import { botState, BotMark, BotAvatar, RoomAvatar } from './mark.js'import { reducedMotion } from './activity-row.js'import { Shimmer, workPhrase } from './cells.js'-import { springEasing, SPRING_SHAPE, useViewport, viewBottom } from './motion.js'+import { springEasing, SPRING_POP, SPRING_SHAPE, useViewport, viewBottom } from './motion.js'import { hostText, t } from './i18n.js'import { showsDshRow } from './dsh-offer.js'import { quietly } from './diagnostics.js'@@ -816,23 +816,33 @@ export function AccountLauncher({ seat = true, settingsOpen, openSettings, openO// The desktop app keeps its main window hidden until the team interface has drawn// the first state, and shows its failure page when that never comes. The report// says where the Main Bot's avatar is when it wears the start window's whale: the-// whale there jumps onto it as the team window takes over.+// start window hands that whale over at the top of its jump, and it glides onto+// the avatar here.let readyReported = falsefunction useReportReady(drawn, roster) {useEffect(() => {if (!drawn || readyReported) returnreadyReported = truevoid Promise.resolve().then(() => {- const ready = globalThis.dsBotApp?.ready- if (typeof ready !== 'function') return undefined+ const app = globalThis.dsBotApp+ if (typeof app?.ready !== 'function') return undefined// The place is a nicety: whatever goes wrong measuring it, the report still goes.let placetry { place = mainAvatarPlace(roster) } catch { place = undefined }- return place === undefined ? ready() : ready(place)+ if (place === undefined) return app.ready()+ const mainId = roster.mainBotId+ app.onHandoff?.((from) => { try { glideOnto(mainMarkOf(mainId), from) } catch (error) { quietly('handoff')(error) } })+ return app.ready(place)}).catch(quietly('app ready'))}, [drawn])}+function mainMarkOf(id) {+ if (typeof document === 'undefined') return null+ const key = typeof CSS !== 'undefined' && CSS.escape ? CSS.escape(id) : id+ return document.querySelector(`.bt-side [data-bot-id="${key}"] .bt-mark`)+}+// The Main Bot's avatar in the team column, in CSS px of the page, with the page's size.// Only the default look: a photo or another character would not match the start window's whale.function mainAvatarPlace(roster) {@@ -840,8 +850,7 @@ function mainAvatarPlace(roster) {if (main === undefined || main.avatar?.image || typeof document === 'undefined') return undefinedconst look = lookOf(main)if (look.shape !== MAIN_LOOK.shape || look.color !== MAIN_LOOK.color) return undefined- const id = typeof CSS !== 'undefined' && CSS.escape ? CSS.escape(main.id) : main.id- const mark = document.querySelector(`.bt-side [data-bot-id="${id}"] .bt-mark`)+ 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 undefinedconst box = mark.getBoundingClientRect()@@ -849,6 +858,47 @@ function mainAvatarPlace(roster) {return { x: box.left, y: box.top, width: box.width, height: box.height, viewportWidth: globalThis.innerWidth ?? view.clientWidth, viewportHeight: globalThis.innerHeight ?? view.clientHeight }}+// 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+// not stutter the way a window that resizes under it would. x and y ease differently, so the path+// bows upward; the avatar itself is hidden until the copy is on it, then gives a small bounce.+// Hidden by opacity, not visibility: the copy draws through the avatar's own masks (same ids),+// which a hidden avatar would stop drawing.+const GLIDE_MS = 460+function glideOnto(mark, from) {+ if (!mark || reducedMotion()) return+ const box = mark.getBoundingClientRect()+ if (!box.width) return+ const outer = document.createElement('div')+ const inner = document.createElement('div')+ const copy = mark.cloneNode(true)+ copy.removeAttribute('data-live')+ Object.assign(outer.style, { position: 'fixed', left: `${box.left}px`, top: `${box.top}px`, width: `${box.width}px`, height: `${box.height}px`, zIndex: '2147483647', pointerEvents: 'none' })+ Object.assign(inner.style, { width: '100%', height: '100%', transformOrigin: '0 0' })+ Object.assign(copy.style, { width: '100%', height: '100%' })+ copy.style.setProperty('--bt-ink-deepseek', getComputedStyle(mark).getPropertyValue('--bt-ink-deepseek'))+ inner.append(copy)+ outer.append(inner)+ outer.setAttribute('aria-hidden', 'true')+ document.body.append(outer)+ mark.style.opacity = '0'+ const timing = { delay: Math.max(0, Number(from.hold) || 0), duration: GLIDE_MS, fill: 'both' }+ outer.animate([{ transform: `translateX(${from.x - box.left}px)` }, { transform: 'none' }], { ...timing, easing: 'cubic-bezier(.45,0,.25,1)' })+ const glide = inner.animate([{ transform: `translateY(${from.y - box.top}px) scale(${from.size / box.width})` }, { transform: 'none' }], { ...timing, easing: 'cubic-bezier(.2,.65,.3,1)' })+ let landed = false+ const land = () => {+ if (landed) return+ landed = true+ outer.remove()+ mark.style.opacity = ''+ mark.animate([{ transform: 'scale(1.08, .92)' }, { transform: 'none' }], { duration: SPRING_POP.duration, easing: SPRING_POP.easing })+ }+ glide.finished.then(land, land)+ // A hidden page stops ticking animations: the avatar comes back regardless.+ setTimeout(land, timing.delay + GLIDE_MS + 500)+}+// Opens the Main Bot whenever the main view holds no Bot conversation, the way// The view always lands on a Bot rather than an empty New Session page.// When a Bot's chat moves on to a fresh part, the shell clears the view of the partdiff --git a/ds-bot/test/app-ready.test.js b/ds-bot/test/app-ready.test.jsindex 65765a9d..637a021d 100644--- a/ds-bot/test/app-ready.test.js+++ b/ds-bot/test/app-ready.test.js@@ -50,7 +50,7 @@ function mount(component) {}// One page load: a fresh copy of the client modules, under the app bridge it was given.-function page(dsBotApp, documentStub = {}) {+function page(dsBotApp, documentStub = {}, globals = {}) {const module = { exports: {} }runInNewContext(outputFiles[0].text, {module, exports: module.exports,@@ -59,6 +59,7 @@ function page(dsBotApp, documentStub = {}) {document: { addEventListener() {}, removeEventListener() {}, querySelector: () => null, documentElement: { setAttribute() {}, removeAttribute() {} }, ...documentStub },setTimeout: () => 0, clearTimeout() {},...(dsBotApp === undefined ? {} : { dsBotApp }),+ ...globals,})return module.exports}@@ -155,3 +156,48 @@ test('a ready() that throws is noted and the sidebar stays', async () => {assert.ok(drawsSide(tree))assert.deepEqual(Array.from(clientErrors(), entry => entry.text), ['app ready: bridge gone'])})++// The desktop app's start window hands its whale over at the top of its jump: the sidebar draws a+// copy of the avatar there, holds it while the windows cross-fade, then glides it onto the avatar.+test('a whale handed over glides from where it was handed onto the Main Bot\'s avatar', async () => {+ const made = []+ const element = () => {+ const el = { style: { setProperty() {} }, children: [], attributes: {}, animations: [], removed: false }+ el.append = child => { el.children.push(child) }+ el.setAttribute = (name, value) => { el.attributes[name] = value }+ el.removeAttribute = (name) => { delete el.attributes[name] }+ el.remove = () => { el.removed = true }+ el.animate = (frames, timing) => { const run = { frames, timing, finished: Promise.resolve() }; el.animations.push(run); return run }+ made.push(el)+ return el+ }+ const mark = { ...element(), checkVisibility: () => true, getBoundingClientRect: () => ({ left: 98, top: 70, width: 60, height: 60 }), cloneNode: () => element() }+ const body = element()+ let handoff+ const calls = []+ const app = { ready: (...args) => { calls.push(['ready', ...args]) }, onHandoff: (run) => { calls.push(['onHandoff']); handoff = run } }+ const { TeamSidebar } = page(app, {+ querySelector: selector => (selector === '.bt-side [data-bot-id="main"] .bt-mark' ? mark : null),+ documentElement: { clientWidth: 1280, clientHeight: 800, setAttribute() {}, removeAttribute() {} },+ createElement: element, body,+ }, { getComputedStyle: () => ({ getPropertyValue: () => '#4D6BFE' }) })+ mount(TeamSidebar)(sidebarProps(whaleTeam))+ await setImmediate()+ // Listening before the report goes, so a quick hand-off is not missed.+ assert.deepEqual(calls.map(call => call[0]), ['onHandoff', 'ready'])+ handoff({ x: 584, y: 307, size: 112, hold: 260 })+ const [outer] = body.children+ assert.equal(outer.style.position, 'fixed')+ assert.equal(mark.style.opacity, '0')+ const [across] = outer.animations+ assert.equal(across.frames[0].transform, 'translateX(486px)')+ assert.equal(across.timing.delay, 260)+ const [glide] = outer.children[0].animations+ assert.equal(glide.frames[0].transform, `translateY(237px) scale(${String(112 / 60)})`)+ assert.equal(glide.frames[1].transform, 'none')+ await setImmediate()+ // Landed: the copy goes, the avatar is back and gives its small bounce.+ assert.equal(outer.removed, true)+ assert.equal(mark.style.opacity, '')+ assert.equal(mark.animations.length, 1)+})