From 1255de68f5223602b4411a8256387c3a612140d9 Mon Sep 17 00:00:00 2001 From: July-X Date: Fri, 27 Nov 2026 11:47:17 +0800 Subject: [PATCH] fix(minimax-pet): stabilize desktop window dragging Use the Host-confirmed window origin and discard samples taken while a move is pending. Retain the configured window size and cover pointer movement and release before and after native bounds change. --- .../minimax-pet/.minimax-plugin/plugin.json | 2 +- plugins/minimax-ai/minimax-pet/README.md | 3 + .../minimax-ai/minimax-pet/README.zh-CN.md | 4 + .../minimax-pet/miniapp/client/index.html | 2 +- .../minimax-pet/miniapp/client/pet-app.js | 41 +++--- .../minimax-pet/.minimax-plugin/plugin.json | 2 +- sources/minimax-ai/minimax-pet/DEVELOPMENT.md | 1 + sources/minimax-ai/minimax-pet/README.md | 3 + .../minimax-ai/minimax-pet/README.zh-CN.md | 4 + .../dev/desk-interactivity.test.mjs | 118 +++++++++++++++--- .../minimax-pet/miniapp/client/index.html | 2 +- .../minimax-pet/miniapp/client/pet-app.js | 41 +++--- .../minimax-ai/minimax-pet/package-lock.json | 4 +- sources/minimax-ai/minimax-pet/package.json | 2 +- 14 files changed, 174 insertions(+), 55 deletions(-) diff --git a/plugins/minimax-ai/minimax-pet/.minimax-plugin/plugin.json b/plugins/minimax-ai/minimax-pet/.minimax-plugin/plugin.json index 272979d6..34667e81 100644 --- a/plugins/minimax-ai/minimax-pet/.minimax-plugin/plugin.json +++ b/plugins/minimax-ai/minimax-pet/.minimax-plugin/plugin.json @@ -2,7 +2,7 @@ "schemaVersion": 1, "name": "minimax-pet", "displayName": "MiniMax Pet", - "version": "0.9.2", + "version": "0.9.3", "description": "轻量桌宠,聚合主窗口可见会话的任务状态、需要回答的提醒和最新结果,支持外观切换及图集导入。", "author": "MiniMax", "icon": "icon.png", diff --git a/plugins/minimax-ai/minimax-pet/README.md b/plugins/minimax-ai/minimax-pet/README.md index 70eff556..732affc0 100644 --- a/plugins/minimax-ai/minimax-pet/README.md +++ b/plugins/minimax-ai/minimax-pet/README.md @@ -22,6 +22,8 @@ Version **0.9.0** also gives the desktop window one fixed size, tall enough for Version **0.9.2** keeps the desktop window at its intended size while dragging by sending the configured size with each move, rather than carrying forward unexpected native bounds. The desktop task card is centered and capped at 264 CSS pixels; it can still fit narrower windows with the existing 8-pixel side gutters. Permissions and dependencies are unchanged. +Version **0.9.3** moves the desktop pet using the Host-confirmed window position and the pointer's offset from the grab point. The page waits for each move to finish before using another pointer sample. If you release while a move is pending, the window stays at the last position accepted by the Host. + Version **0.8.1** fixes the desktop card: the title truncates to one line, only the reply scrolls, and the actions stay pinned, so a long title or reply no longer pushes 返回任务 / 打开对话 out of the card. Expanding the card also grows the window instead of squeezing the reply into one line. Version **0.8.0** aligns the panel with the MiniMax Code design language: 24px page margins and section gaps, 14px/22px body copy with 12px/18px supporting text, 32px minimum control height, 12px cards and 8px controls, 0.5px borders on desktop overlays, and press/focus states. The desktop pet keeps its 280px layout with the same tokens. @@ -50,6 +52,7 @@ Earlier local prototypes use a different plugin ID. The Host gives `minimax-pet` - The default atlas is checked by actual PNG decoding, frame coverage and deterministic rebuild tests. The separate octopus icon is checked by PNG decoding and visual review. On 2026-10-26, the packaged Skill was exercised with a real Agent in the macOS development build to create, validate, preview and import a custom v2 pet; all nine animation previews and the four cardinal mouse-look directions were checked. This does not replace released-client acceptance. - Version 0.9.0 has Node/DOM tests for the card timer, the preference round trip and the copy of both languages (every key the page uses must exist in both), plus a browser check of the panel and desktop window in both languages against a simulated Host. Not verified for 0.9.0: the language the real client reports on any given install, and both languages inside a real MiniMax Code window. - Version 0.9.2 was checked in MiniMax Code **3.1.19.232** on Windows 11 x64 (build 26200, 150% display scaling). With the task card open, four automated pointer drags moved the real window without cumulative width or height growth. A physical mouse and other display configurations were not tested for this fix. +- The drag behavior was exercised with a physical mouse in a local comparison build on MiniMax Inside Code **3.1.19.169**, Windows 11 (build 26300), and a 4K display. Version 0.9.3 has regression tests for input before and after the Host applies a pending move. Desktop testing of the final 0.9.3 package remains open. - Not verified for 0.6.0: opening a conversation or following the theme inside a real MiniMax Code 3.1.11+ window (panel or desktop pet), any Windows GUI, and released-client installation or GUI acceptance on 3.1.6. Automated tests use synthetic data and do not prove those paths. ## Data & access diff --git a/plugins/minimax-ai/minimax-pet/README.zh-CN.md b/plugins/minimax-ai/minimax-pet/README.zh-CN.md index bd2f7870..f2a9e43d 100644 --- a/plugins/minimax-ai/minimax-pet/README.zh-CN.md +++ b/plugins/minimax-ai/minimax-pet/README.zh-CN.md @@ -24,6 +24,8 @@ **0.9.2** 拖拽时同时发送坐标与当前缩放对应的窗口尺寸,不再沿用宿主异常放大的尺寸。桌面任务卡居中,宽度上限为 264 CSS 像素;窗口较窄时仍会缩小并保留两侧各 8 像素的留白。权限和依赖不变。 +**0.9.3** 根据宿主确认的窗口位置和指针相对抓取点的偏移移动桌宠。每次移动结束后,才使用新的指针事件。如果在宿主应答前松手,窗口停在宿主最后接受的位置。 + **0.8.1** 修复桌面卡片:标题单行截断,只有回复区滚动,底部操作固定在卡片内;长标题或长回复不再把「返回任务 / 打开对话」顶出卡片。展开卡片时窗口同步变高,回复不会被压成一行。 **0.8.0** 按 MiniMax Code 的设计语言对齐面板:24px 页边距与区块间距、14px/22px 正文与 12px/18px 辅助文字、控件最小高度 32px、卡片 12px 与控件 8px 圆角、桌面浮层 0.5px 描边,并补齐按下与焦点状态。桌面宠物保持 280px 布局,沿用同一套 token。 @@ -44,6 +46,8 @@ 0.9.2 已在 Windows 11 x64(构建 26200,屏幕缩放 150%)的 MiniMax Code **3.1.19.232** 中测试。任务卡展开时通过自动化指针连续拖拽四次,真实窗口发生位移,宽高未逐次累加。此修复未测试物理鼠标及其他显示配置。 +本地对照构建已在 Windows 11(构建 26300)、4K 显示器和 MiniMax Inside Code **3.1.19.169** 下用物理鼠标测试。0.9.3 的回归测试覆盖宿主应用窗口移动前后到达的指针事件。0.9.3 正式打包版本仍待桌面验收。 + ## 数据与能力边界 只申请 `session.read`,读取 Host 对本插件可见的用户会话状态和所选会话最新回复,不直接读取 Host 数据库、日志、配置或凭据。状态和提醒只在页面内存中,关闭或静音不修改 Host 的任务或未读事实。 diff --git a/plugins/minimax-ai/minimax-pet/miniapp/client/index.html b/plugins/minimax-ai/minimax-pet/miniapp/client/index.html index 2c04aaf8..7c3e94bb 100644 --- a/plugins/minimax-ai/minimax-pet/miniapp/client/index.html +++ b/plugins/minimax-ai/minimax-pet/miniapp/client/index.html @@ -181,7 +181,7 @@

任务连接

版本与帮助
-

MiniMax Pet 0.9.2

+

MiniMax Pet 0.9.3

diff --git a/plugins/minimax-ai/minimax-pet/miniapp/client/pet-app.js b/plugins/minimax-ai/minimax-pet/miniapp/client/pet-app.js index cd9596a4..e75e7c8b 100644 --- a/plugins/minimax-ai/minimax-pet/miniapp/client/pet-app.js +++ b/plugins/minimax-ai/minimax-pet/miniapp/client/pet-app.js @@ -144,6 +144,7 @@ const app = { ctFailures: 0, pointer: null, drag: null, + dragMove: null, dragging: false, menuOpen: false, menuView: 'root', @@ -897,22 +898,26 @@ function onSpritePointerDown(e) { } catch (error) { console.warn('[pet] pointer_capture_failed:', errCode(error), error); } + const startX = app.winPos?.x ?? e.clientX; app.drag = { pointerId: e.pointerId, - startX: e.screenX, - startY: e.screenY, - win: app.winPos ? { ...app.winPos } : null, + grabX: e.clientX, + grabY: e.clientY, + startX, active: false, dir: null, - extreme: e.screenX, + extreme: startX, }; } function onSpritePointerMove(e) { const d = app.drag; - if (!d || e.pointerId !== d.pointerId || app.scaleChanging) return; - const dx = e.screenX - d.startX; - const dy = e.screenY - d.startY; + // While the Host is moving the window, client coordinates may be relative to either origin. + // Resume from the next pointer event after the Host confirms the new bounds. + if (!d || e.pointerId !== d.pointerId || app.scaleChanging || app.dragMove) return; + const origin = app.winPos; + const dx = e.clientX - d.grabX; + const dy = e.clientY - d.grabY; if (!d.active) { if (Math.hypot(dx, dy) <= DRAG_THRESHOLD) return; d.active = true; @@ -923,20 +928,22 @@ function onSpritePointerMove(e) { hideQuickbar(); els.sprite.classList.add('is-dragging'); refreshInteractivity(); - if (!d.win) console.warn('[pet] drag_without_window_position: no window position yet, animation only'); + if (!origin) console.warn('[pet] drag_without_window_position: no window position yet, animation only'); } - updateDragDirection(d, e.screenX); - if (!d.win) return; + const x = origin ? Math.round(origin.x + dx) : e.clientX; + updateDragDirection(d, x); + if (!origin) return; + const y = Math.round(origin.y + dy); + if (x === origin.x && y === origin.y) return; // On Windows a position-only update can return enlarged native bounds. Send the // design size with the move, rather than carrying the enlarged bounds into the next one. - callBridge(() => win.update({ - x: Math.round(d.win.x + dx), y: Math.round(d.win.y + dy), - width: DESK_WIDTH, height: deskHeight(prefs.scale), - })).catch((error) => { + app.dragMove = callBridge(() => win.update({ x, y, width: DESK_WIDTH, height: deskHeight(prefs.scale) })).then((state) => { + if (app.mode === 'window') onWindowState(state); + }).catch((error) => { const code = errCode(error); if (code === 'not_permitted') console.debug('[pet] drag_move_rejected: not_permitted (target is off every display)'); else console.warn('[pet] drag_move_failed:', code, error); - }); + }).finally(() => { app.dragMove = null; }); } function updateDragDirection(d, sx) { @@ -965,6 +972,7 @@ function updateDragDirection(d, sx) { function finishDrag(e, cancelled) { const d = app.drag; if (!d || e.pointerId !== d.pointerId) return; + if (!cancelled && d.active) onSpritePointerMove(e); app.drag = null; try { if (els.sprite.hasPointerCapture(e.pointerId)) els.sprite.releasePointerCapture(e.pointerId); @@ -978,7 +986,7 @@ function finishDrag(e, cancelled) { // Hover already owns the same three-cycle jump; release must not queue it twice. animationGate?.invalidate(); applyActivity(); } else playOneShot('jumping'); - callBridge(() => win.getState()).then(onWindowState, logError('get_state_after_drag')); + if (!app.dragMove) callBridge(() => win.getState()).then(onWindowState, logError('get_state_after_drag')); } else if (!cancelled) { void openWorkbench('tasks'); } @@ -1515,6 +1523,7 @@ function setScale(value) { cancelDrag(); const current = () => !disposed && intent === scaleIntent; scaleUpdates = scaleUpdates.then(async () => { + if (app.dragMove) await app.dragMove; if (!current()) return; if (app.workbenchOpen) await closeWorkbench(); if (!current()) return; diff --git a/sources/minimax-ai/minimax-pet/.minimax-plugin/plugin.json b/sources/minimax-ai/minimax-pet/.minimax-plugin/plugin.json index 272979d6..34667e81 100644 --- a/sources/minimax-ai/minimax-pet/.minimax-plugin/plugin.json +++ b/sources/minimax-ai/minimax-pet/.minimax-plugin/plugin.json @@ -2,7 +2,7 @@ "schemaVersion": 1, "name": "minimax-pet", "displayName": "MiniMax Pet", - "version": "0.9.2", + "version": "0.9.3", "description": "轻量桌宠,聚合主窗口可见会话的任务状态、需要回答的提醒和最新结果,支持外观切换及图集导入。", "author": "MiniMax", "icon": "icon.png", diff --git a/sources/minimax-ai/minimax-pet/DEVELOPMENT.md b/sources/minimax-ai/minimax-pet/DEVELOPMENT.md index b3c4c20e..287923ba 100644 --- a/sources/minimax-ai/minimax-pet/DEVELOPMENT.md +++ b/sources/minimax-ai/minimax-pet/DEVELOPMENT.md @@ -29,6 +29,7 @@ npm run check:package - Resizing the desktop pet first brings the transparent window inside the available screen area so smaller sprites remain reachable. - Click-through follows the pixels, never a whole mode: the same rule covers the pet, the bubble, the notification stack, the quick bar, the menu and the open card. An expanded card window is 300x488 around a 284x147 card, so treating "card open" as "window interactive" swallows every click in the margin. Only a drag or an open menu justify the whole window, and a card opened from the keyboard (no pointer sample yet) stays interactive. - Opening or closing the card must never change the window geometry. The window is one fixed 280 x `deskHeight(scale)` size that already fits the open card; resizing on click moves the native origin, and the previous layout is repainted at the new top-left for a frame, so the pet visibly jumps up (and left, while the card was wider). `dev/desk-interactivity.test.mjs` fails if `openWorkbench` or `closeWorkbench` touches geometry, and checks the fixed height still leaves room for the card at every pet scale. The area above the pet is transparent and forwards clicks, so a permanently tall window costs no desktop clicks. +- A drag sends at most one window move at a time. Pointer events received before its reply may use either window origin. The next event after the reply uses the confirmed bounds. The drag tests cover move and release on both sides of the native bounds change. - Opening the card must not change the running sprite animation. Hover runs the `jumping` row; reverting to the base state on open restarts it at frame 0, which reads as a flicker on every click. The menu still takes the pet back to its base animation, because the menu is a deliberate choice. - Every user-visible string comes from `miniapp/client/i18n.mjs` through `t()`; static markup carries `data-i18n` / `data-i18n-attr`. Keys are `..`, interpolation is `{{name}}`, a missing key renders as the key itself, and `dev/i18n.test.mjs` fails when a key the client uses is missing from either language. Conversation titles, replies and error text from the Host are data and stay in the language the Agent wrote them. - Text created once when a view is built (segmented labels, compact-view buttons) must be re-applied on a language change, or it keeps the language of the moment it was built. diff --git a/sources/minimax-ai/minimax-pet/README.md b/sources/minimax-ai/minimax-pet/README.md index 70eff556..732affc0 100644 --- a/sources/minimax-ai/minimax-pet/README.md +++ b/sources/minimax-ai/minimax-pet/README.md @@ -22,6 +22,8 @@ Version **0.9.0** also gives the desktop window one fixed size, tall enough for Version **0.9.2** keeps the desktop window at its intended size while dragging by sending the configured size with each move, rather than carrying forward unexpected native bounds. The desktop task card is centered and capped at 264 CSS pixels; it can still fit narrower windows with the existing 8-pixel side gutters. Permissions and dependencies are unchanged. +Version **0.9.3** moves the desktop pet using the Host-confirmed window position and the pointer's offset from the grab point. The page waits for each move to finish before using another pointer sample. If you release while a move is pending, the window stays at the last position accepted by the Host. + Version **0.8.1** fixes the desktop card: the title truncates to one line, only the reply scrolls, and the actions stay pinned, so a long title or reply no longer pushes 返回任务 / 打开对话 out of the card. Expanding the card also grows the window instead of squeezing the reply into one line. Version **0.8.0** aligns the panel with the MiniMax Code design language: 24px page margins and section gaps, 14px/22px body copy with 12px/18px supporting text, 32px minimum control height, 12px cards and 8px controls, 0.5px borders on desktop overlays, and press/focus states. The desktop pet keeps its 280px layout with the same tokens. @@ -50,6 +52,7 @@ Earlier local prototypes use a different plugin ID. The Host gives `minimax-pet` - The default atlas is checked by actual PNG decoding, frame coverage and deterministic rebuild tests. The separate octopus icon is checked by PNG decoding and visual review. On 2026-10-26, the packaged Skill was exercised with a real Agent in the macOS development build to create, validate, preview and import a custom v2 pet; all nine animation previews and the four cardinal mouse-look directions were checked. This does not replace released-client acceptance. - Version 0.9.0 has Node/DOM tests for the card timer, the preference round trip and the copy of both languages (every key the page uses must exist in both), plus a browser check of the panel and desktop window in both languages against a simulated Host. Not verified for 0.9.0: the language the real client reports on any given install, and both languages inside a real MiniMax Code window. - Version 0.9.2 was checked in MiniMax Code **3.1.19.232** on Windows 11 x64 (build 26200, 150% display scaling). With the task card open, four automated pointer drags moved the real window without cumulative width or height growth. A physical mouse and other display configurations were not tested for this fix. +- The drag behavior was exercised with a physical mouse in a local comparison build on MiniMax Inside Code **3.1.19.169**, Windows 11 (build 26300), and a 4K display. Version 0.9.3 has regression tests for input before and after the Host applies a pending move. Desktop testing of the final 0.9.3 package remains open. - Not verified for 0.6.0: opening a conversation or following the theme inside a real MiniMax Code 3.1.11+ window (panel or desktop pet), any Windows GUI, and released-client installation or GUI acceptance on 3.1.6. Automated tests use synthetic data and do not prove those paths. ## Data & access diff --git a/sources/minimax-ai/minimax-pet/README.zh-CN.md b/sources/minimax-ai/minimax-pet/README.zh-CN.md index bd2f7870..f2a9e43d 100644 --- a/sources/minimax-ai/minimax-pet/README.zh-CN.md +++ b/sources/minimax-ai/minimax-pet/README.zh-CN.md @@ -24,6 +24,8 @@ **0.9.2** 拖拽时同时发送坐标与当前缩放对应的窗口尺寸,不再沿用宿主异常放大的尺寸。桌面任务卡居中,宽度上限为 264 CSS 像素;窗口较窄时仍会缩小并保留两侧各 8 像素的留白。权限和依赖不变。 +**0.9.3** 根据宿主确认的窗口位置和指针相对抓取点的偏移移动桌宠。每次移动结束后,才使用新的指针事件。如果在宿主应答前松手,窗口停在宿主最后接受的位置。 + **0.8.1** 修复桌面卡片:标题单行截断,只有回复区滚动,底部操作固定在卡片内;长标题或长回复不再把「返回任务 / 打开对话」顶出卡片。展开卡片时窗口同步变高,回复不会被压成一行。 **0.8.0** 按 MiniMax Code 的设计语言对齐面板:24px 页边距与区块间距、14px/22px 正文与 12px/18px 辅助文字、控件最小高度 32px、卡片 12px 与控件 8px 圆角、桌面浮层 0.5px 描边,并补齐按下与焦点状态。桌面宠物保持 280px 布局,沿用同一套 token。 @@ -44,6 +46,8 @@ 0.9.2 已在 Windows 11 x64(构建 26200,屏幕缩放 150%)的 MiniMax Code **3.1.19.232** 中测试。任务卡展开时通过自动化指针连续拖拽四次,真实窗口发生位移,宽高未逐次累加。此修复未测试物理鼠标及其他显示配置。 +本地对照构建已在 Windows 11(构建 26300)、4K 显示器和 MiniMax Inside Code **3.1.19.169** 下用物理鼠标测试。0.9.3 的回归测试覆盖宿主应用窗口移动前后到达的指针事件。0.9.3 正式打包版本仍待桌面验收。 + ## 数据与能力边界 只申请 `session.read`,读取 Host 对本插件可见的用户会话状态和所选会话最新回复,不直接读取 Host 数据库、日志、配置或凭据。状态和提醒只在页面内存中,关闭或静音不修改 Host 的任务或未读事实。 diff --git a/sources/minimax-ai/minimax-pet/dev/desk-interactivity.test.mjs b/sources/minimax-ai/minimax-pet/dev/desk-interactivity.test.mjs index 3fc3334f..4fc96555 100644 --- a/sources/minimax-ai/minimax-pet/dev/desk-interactivity.test.mjs +++ b/sources/minimax-ai/minimax-pet/dev/desk-interactivity.test.mjs @@ -122,32 +122,68 @@ test('the card never resizes the window, and the fixed height always fits it', a } }); -function dragHarness(scale, overrides = {}) { +function dragHarness(scale, screenMode = 'local') { const updates = []; - const app = { mode: 'window', workbenchOpen: true, pet: {}, winPos: { x: -100, y: 160 }, oneShotToken: 0, ...overrides }; + const directions = []; + let nativeBounds = { x: -100, y: 160 }; + let pending; + const app = { mode: 'window', workbenchOpen: true, pet: {}, winPos: nativeBounds, oneShotToken: 0 }; + const state = () => ({ mode: 'window', window: nativeBounds }); const context = vm.createContext({ - app, prefs: { scale }, DRAG_THRESHOLD: 4, - els: { sprite: { setPointerCapture() {}, classList: { add() {} } } }, - win: { update: async (patch) => updates.push({ ...patch }) }, + app, prefs: { scale }, DRAG_THRESHOLD: 4, DIRECTION_HYSTERESIS: 12, + els: { sprite: { setPointerCapture() {}, hasPointerCapture: () => false, classList: { add() {}, remove() {} } } }, + win: { + getState: async () => state(), + update: (patch) => { + assert.equal(pending, undefined, 'only one move reaches the Host at a time'); + updates.push({ ...patch }); + return new Promise((resolve, reject) => { pending = { patch, resolve, reject }; }); + }, + }, + console: { warn() {}, debug() {} }, errCode: (error) => error.message, logError: () => () => {}, callBridge: (run) => Promise.resolve(run()), - noteInteraction() {}, stopLook() {}, hideQuickbar() {}, refreshInteractivity() {}, updateDragDirection() {}, + onWindowState: ({ window }) => { app.winPos = { x: window.x, y: window.y }; }, + player: { play: async (direction) => { directions.push(direction); } }, + noteInteraction() {}, stopLook() {}, hideQuickbar() {}, refreshInteractivity() {}, + desiredAnimation: () => ({ state: 'idle' }), playOneShot() {}, openWorkbench() {}, }); - vm.runInContext(`${slice('const DESK_WIDTH', '// Saved positions')}\n${slice('function onSpritePointerDown(', 'function updateDragDirection(')} - globalThis.api = { onSpritePointerDown, onSpritePointerMove };`, context); - const pointer = { pointerId: 1, button: 0, screenX: 50, screenY: 70, preventDefault() {} }; - context.api.onSpritePointerDown(pointer); - return { app, updates, move: (x, y) => context.api.onSpritePointerMove({ ...pointer, screenX: x, screenY: y }) }; + vm.runInContext(`${slice('const DESK_WIDTH', '// Saved positions')}\n${slice('function onSpritePointerDown(', 'function cancelDrag(')} + globalThis.api = { onSpritePointerDown, onSpritePointerMove, finishDrag };`, context); + const pointer = (dx, dy) => { + const x = -50 + dx; + const y = 230 + dy; + const clientX = x - nativeBounds.x; + const clientY = y - nativeBounds.y; + return { pointerId: 1, button: 0, preventDefault() {}, clientX, clientY, + screenX: screenMode === 'local' ? clientX : x, screenY: screenMode === 'local' ? clientY : y }; + }; + context.api.onSpritePointerDown(pointer(0, 0)); + const apply = () => { nativeBounds = { ...pending.patch }; }; + async function settle(reject = false) { + const request = pending; + if (!reject) apply(); + pending = undefined; + if (reject) request.reject(new Error('not_permitted')); + else request.resolve(state()); + await app.dragMove; + } + return { app, updates, directions, apply, settle, + move: (dx, dy) => context.api.onSpritePointerMove(pointer(dx, dy)), + release: (dx, dy) => context.api.finishDrag(pointer(dx, dy), false) }; } -test('desktop drag gives the Host absolute position and the same size on every move', () => { +test('desktop drag gives the Host absolute position and the same size on every move', async () => { // A position-only request was followed by growing native bounds on Windows. The page must // keep requesting the designed size, not feed back whatever bounds the Host last reported. for (const [scale, height] of [[0.5, 436], [0.75, 488], [1, 540]]) { const h = dragHarness(scale); - h.move(51, 71); // Below the click/drag threshold. - h.move(85, 88); + h.move(1, 1); // Below the click/drag threshold. + assert.deepEqual(h.updates, []); + h.move(35, 18); + await h.settle(); h.app.winBounds = { width: 975, height: 1090 }; - h.move(28, 60); + h.move(-22, -10); + await h.settle(); assert.deepEqual(h.updates, [ { x: -65, y: 178, width: 280, height }, { x: -122, y: 150, width: 280, height }, @@ -159,6 +195,56 @@ test('desktop drag gives the Host absolute position and the same size on every m test('a drag cannot send its size while an intentional scale change owns the window', () => { const h = dragHarness(0.5); h.app.scaleChanging = true; - h.move(85, 88); + h.move(35, 18); assert.deepEqual(h.updates, []); }); + +for (const screenMode of ['local', 'absolute']) { + test(`a held pointer does not resend the same position (${screenMode} screenX)`, async () => { + const h = dragHarness(0.75, screenMode); + h.move(30, 20); + await h.settle(); + h.move(30, 20); + h.move(30, 20); + assert.deepEqual(h.updates, [{ x: -70, y: 180, width: 280, height: 488 }]); + assert.deepEqual(h.directions, ['running-right']); + }); +} + +for (const applied of [false, true]) { + const phase = applied ? 'after the Host moves but before its reply' : 'before the Host moves'; + test(`a pointer move ${phase} is not replayed against a different origin`, async () => { + const h = dragHarness(0.75); + h.move(30, 0); + if (applied) h.apply(); + h.move(60, 0); + await h.settle(); + assert.deepEqual(h.updates.map(({ x }) => x), [-70]); + h.move(60, 0); + await h.settle(); + assert.deepEqual(h.updates.map(({ x }) => x), [-70, -40]); + }); + + test(`releasing ${phase} keeps the last Host-confirmed target`, async () => { + const h = dragHarness(0.75); + h.move(30, 0); + if (applied) h.apply(); + h.release(60, 0); + await h.settle(); + assert.deepEqual(h.updates.map(({ x }) => x), [-70]); + assert.deepEqual(h.app.winPos, { x: -70, y: 160 }); + assert.equal(h.app.drag, null); + }); +} + +test('a rejected move keeps the confirmed origin for the final release', async () => { + const h = dragHarness(0.75); + h.move(30, 0); + await h.settle(); + h.move(60, 0); + await h.settle(true); + h.release(10, 0); + await h.settle(); + assert.deepEqual(h.updates.map(({ x }) => x), [-70, -40, -90]); + assert.deepEqual(h.directions, ['running-right', 'running-left']); +}); diff --git a/sources/minimax-ai/minimax-pet/miniapp/client/index.html b/sources/minimax-ai/minimax-pet/miniapp/client/index.html index 2c04aaf8..7c3e94bb 100644 --- a/sources/minimax-ai/minimax-pet/miniapp/client/index.html +++ b/sources/minimax-ai/minimax-pet/miniapp/client/index.html @@ -181,7 +181,7 @@

任务连接

版本与帮助
-

MiniMax Pet 0.9.2

+

MiniMax Pet 0.9.3

diff --git a/sources/minimax-ai/minimax-pet/miniapp/client/pet-app.js b/sources/minimax-ai/minimax-pet/miniapp/client/pet-app.js index cd9596a4..e75e7c8b 100644 --- a/sources/minimax-ai/minimax-pet/miniapp/client/pet-app.js +++ b/sources/minimax-ai/minimax-pet/miniapp/client/pet-app.js @@ -144,6 +144,7 @@ const app = { ctFailures: 0, pointer: null, drag: null, + dragMove: null, dragging: false, menuOpen: false, menuView: 'root', @@ -897,22 +898,26 @@ function onSpritePointerDown(e) { } catch (error) { console.warn('[pet] pointer_capture_failed:', errCode(error), error); } + const startX = app.winPos?.x ?? e.clientX; app.drag = { pointerId: e.pointerId, - startX: e.screenX, - startY: e.screenY, - win: app.winPos ? { ...app.winPos } : null, + grabX: e.clientX, + grabY: e.clientY, + startX, active: false, dir: null, - extreme: e.screenX, + extreme: startX, }; } function onSpritePointerMove(e) { const d = app.drag; - if (!d || e.pointerId !== d.pointerId || app.scaleChanging) return; - const dx = e.screenX - d.startX; - const dy = e.screenY - d.startY; + // While the Host is moving the window, client coordinates may be relative to either origin. + // Resume from the next pointer event after the Host confirms the new bounds. + if (!d || e.pointerId !== d.pointerId || app.scaleChanging || app.dragMove) return; + const origin = app.winPos; + const dx = e.clientX - d.grabX; + const dy = e.clientY - d.grabY; if (!d.active) { if (Math.hypot(dx, dy) <= DRAG_THRESHOLD) return; d.active = true; @@ -923,20 +928,22 @@ function onSpritePointerMove(e) { hideQuickbar(); els.sprite.classList.add('is-dragging'); refreshInteractivity(); - if (!d.win) console.warn('[pet] drag_without_window_position: no window position yet, animation only'); + if (!origin) console.warn('[pet] drag_without_window_position: no window position yet, animation only'); } - updateDragDirection(d, e.screenX); - if (!d.win) return; + const x = origin ? Math.round(origin.x + dx) : e.clientX; + updateDragDirection(d, x); + if (!origin) return; + const y = Math.round(origin.y + dy); + if (x === origin.x && y === origin.y) return; // On Windows a position-only update can return enlarged native bounds. Send the // design size with the move, rather than carrying the enlarged bounds into the next one. - callBridge(() => win.update({ - x: Math.round(d.win.x + dx), y: Math.round(d.win.y + dy), - width: DESK_WIDTH, height: deskHeight(prefs.scale), - })).catch((error) => { + app.dragMove = callBridge(() => win.update({ x, y, width: DESK_WIDTH, height: deskHeight(prefs.scale) })).then((state) => { + if (app.mode === 'window') onWindowState(state); + }).catch((error) => { const code = errCode(error); if (code === 'not_permitted') console.debug('[pet] drag_move_rejected: not_permitted (target is off every display)'); else console.warn('[pet] drag_move_failed:', code, error); - }); + }).finally(() => { app.dragMove = null; }); } function updateDragDirection(d, sx) { @@ -965,6 +972,7 @@ function updateDragDirection(d, sx) { function finishDrag(e, cancelled) { const d = app.drag; if (!d || e.pointerId !== d.pointerId) return; + if (!cancelled && d.active) onSpritePointerMove(e); app.drag = null; try { if (els.sprite.hasPointerCapture(e.pointerId)) els.sprite.releasePointerCapture(e.pointerId); @@ -978,7 +986,7 @@ function finishDrag(e, cancelled) { // Hover already owns the same three-cycle jump; release must not queue it twice. animationGate?.invalidate(); applyActivity(); } else playOneShot('jumping'); - callBridge(() => win.getState()).then(onWindowState, logError('get_state_after_drag')); + if (!app.dragMove) callBridge(() => win.getState()).then(onWindowState, logError('get_state_after_drag')); } else if (!cancelled) { void openWorkbench('tasks'); } @@ -1515,6 +1523,7 @@ function setScale(value) { cancelDrag(); const current = () => !disposed && intent === scaleIntent; scaleUpdates = scaleUpdates.then(async () => { + if (app.dragMove) await app.dragMove; if (!current()) return; if (app.workbenchOpen) await closeWorkbench(); if (!current()) return; diff --git a/sources/minimax-ai/minimax-pet/package-lock.json b/sources/minimax-ai/minimax-pet/package-lock.json index ce90b61c..810999d0 100644 --- a/sources/minimax-ai/minimax-pet/package-lock.json +++ b/sources/minimax-ai/minimax-pet/package-lock.json @@ -1,12 +1,12 @@ { "name": "minimax-pet-source", - "version": "0.9.2", + "version": "0.9.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "minimax-pet-source", - "version": "0.9.2", + "version": "0.9.3", "devDependencies": { "esbuild": "0.25.12", "jsdom": "24.1.3", diff --git a/sources/minimax-ai/minimax-pet/package.json b/sources/minimax-ai/minimax-pet/package.json index 343e3be9..58e29c0e 100644 --- a/sources/minimax-ai/minimax-pet/package.json +++ b/sources/minimax-ai/minimax-pet/package.json @@ -1,6 +1,6 @@ { "name": "minimax-pet-source", - "version": "0.9.2", + "version": "0.9.3", "private": true, "type": "module", "description": "桌宠插件的开发与验证工具,不进入分发包。",