diff --git a/plugins/minimax-ai/minimax-pet/.minimax-plugin/plugin.json b/plugins/minimax-ai/minimax-pet/.minimax-plugin/plugin.json index 7df6138b..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.0", + "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 f1ce6fb5..16922ca5 100644 --- a/plugins/minimax-ai/minimax-pet/README.md +++ b/plugins/minimax-ai/minimax-pet/README.md @@ -20,6 +20,8 @@ Version **0.9.0** adds two settings. **Task notifications** sets how many second Version **0.9.0** also gives the desktop window one fixed size, tall enough for the open card. Earlier versions grew the window when a card opened, which moved it on screen and made the pet jump for a frame; now opening or closing a card only shows or hides it. The area above the pet is transparent and passes clicks through to whatever is behind it. +Version **0.9.3** keeps the pet reachable when you choose **放到桌面**. It tries the saved position first, then fits the window to the usable area of the screen it actually lands on. A valid position on another display stays put; when the window is taller than the available area, the pet stays at the bottom rather than being hidden below the screen. + 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. @@ -47,6 +49,7 @@ Earlier local prototypes use a different plugin ID. The Host gives `minimax-pet` - An earlier UI version was exercised on macOS in a MiniMax Code development build: three tabs, wide/narrow layouts, task reading, real session/ask activity, import/delete, and desktop round trips. Version 0.6.0 has Node/DOM tests (including the open and theme paths against a simulated Host), an isolated HTTP smoke test, and a browser check of the panel layout outside the Host. - 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.3 was checked in MiniMax Code **3.1.19.232** on Windows 11 x64 (build 26200, 150% display scaling). The old saved position clipped the pet at the top of the screen; the patched app brought it fully inside the work area and saved the corrected position. Secondary and disconnected displays were exercised in automated tests, not on physical displays. - 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 939c0231..1b0b6bcd 100644 --- a/plugins/minimax-ai/minimax-pet/README.zh-CN.md +++ b/plugins/minimax-ai/minimax-pet/README.zh-CN.md @@ -22,6 +22,8 @@ **0.9.0** 把桌面窗口固定成一个尺寸,本来就放得下展开的卡片。之前点开卡片会把窗口撑高,窗口在屏幕上跟着移动,桌宠会跳一下;现在开合卡片只显示或隐藏,不动窗口。桌宠上方是透明区域,点击会穿透到底下的窗口。 +**0.9.3** 修复点击“放到桌面”后宠物可能落到屏幕外的问题。先尝试恢复上次的位置,再按窗口实际落在哪块屏幕校正;副屏上的合法位置不会被移回主屏。如果窗口比可用区域更高,优先让窗口底部的宠物留在屏幕上。 + **0.8.1** 修复桌面卡片:标题单行截断,只有回复区滚动,底部操作固定在卡片内;长标题或长回复不再把「返回任务 / 打开对话」顶出卡片。展开卡片时窗口同步变高,回复不会被压成一行。 **0.8.0** 按 MiniMax Code 的设计语言对齐面板:24px 页边距与区块间距、14px/22px 正文与 12px/18px 辅助文字、控件最小高度 32px、卡片 12px 与控件 8px 圆角、桌面浮层 0.5px 描边,并补齐按下与焦点状态。桌面宠物保持 280px 布局,沿用同一套 token。 @@ -40,6 +42,8 @@ 更早的 UI 版本已在 macOS 开发版验收三页签、窄宽布局、真实任务与 ask、导入删除和桌面切换;0.6.0 运行 Node/DOM 测试(含模拟 Host 下的打开对话与主题路径)、隔离 HTTP smoke,并在 Host 之外用浏览器检查了面板布局。默认图集通过 PNG 解码、动画帧覆盖与确定性重建检查;独立的章鱼图标通过 PNG 解码和视觉检查。2026-10-26,已用 macOS 开发版中的真实 Agent 调用随包 Skill,完成自定义 v2 宠物的生成、校验、预览和导入,并检查九种动作预览与鼠标上/右/下/左四向注视。0.6.0 尚未在真实的 MiniMax Code 3.1.11+ 窗口(面板或桌面宠物)中验收打开对话和主题跟随,也未验收 Windows GUI、正式客户端安装或 3.1.6 正式版 GUI;合成数据测试不能证明这些路径。 +0.9.3 已在 Windows 11 x64(构建 26200,屏幕缩放 150%)的 MiniMax Code **3.1.19.232** 中测试。旧保存位置会让宠物在屏幕上沿被裁切,修复版把宠物完整移进工作区并保存校正位置。副屏及屏幕断开场景只做了自动化测试,未连接实际副屏测试。 + ## 数据与能力边界 只申请 `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 24c255f6..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.0

+

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 81b26a28..b3da5c01 100644 --- a/plugins/minimax-ai/minimax-pet/miniapp/client/pet-app.js +++ b/plugins/minimax-ai/minimax-pet/miniapp/client/pet-app.js @@ -588,11 +588,25 @@ function onWindowState(state) { void restoreWindowPosition(win, saved, { isCurrent }).then(async (result) => { if (disposed || token !== app.positionRestoreToken || app.mode !== 'window') return; let restoredState = result.state; - const height = deskHeight(prefs.scale); - if (result.interactive && restoredState?.window && (restoredState.window.width !== DESK_WIDTH || restoredState.window.height !== height)) { - try { restoredState = await win.update({ width: DESK_WIDTH, height }); } - catch (error) { if (!isCurrent()) return; result.error = errCode(error); } + const size = { width: DESK_WIDTH, height: deskHeight(prefs.scale) }; + if (result.interactive && restoredState?.window) { + // Restore first: the saved position may be on a different display. Check the work + // area only after the Host settles there, including when the saved move was refused. + const fitted = await fitWindowToScreen(win, { + isCurrent, size, keepPetVisible: true, + screenRect: () => ({ x: screen.availLeft, y: screen.availTop, width: screen.availWidth, height: screen.availHeight }), + }); if (!isCurrent()) return; + if (fitted.cancelled) { applyMode('inline'); return; } + if (fitted.state) restoredState = fitted.state; + if (fitted.error) result.error = fitted.error; + else if (result.error === 'not_permitted') result.error = null; + // Older clients can lack usable work-area data. Preserve their existing size repair. + if (fitted.error === 'screen_unavailable' && (restoredState.window.width !== size.width || restoredState.window.height !== size.height)) { + try { restoredState = await win.update(size); } + catch (error) { if (!isCurrent()) return; result.error = errCode(error); } + if (!isCurrent()) return; + } } if (restoredState) onWindowState(restoredState); if (!isCurrent()) return; @@ -601,7 +615,7 @@ function onWindowState(state) { if (result.error) showTransient(result.interactive ? t('mode.positionFailed', { code: result.error }) : t('mode.interactionUnknown', { code: result.error }), 'error'); - rememberPosition(); + else rememberPosition(); }); return; } diff --git a/plugins/minimax-ai/minimax-pet/miniapp/client/window-position.mjs b/plugins/minimax-ai/minimax-pet/miniapp/client/window-position.mjs index c259e09c..4561b45a 100644 --- a/plugins/minimax-ai/minimax-pet/miniapp/client/window-position.mjs +++ b/plugins/minimax-ai/minimax-pet/miniapp/client/window-position.mjs @@ -20,8 +20,8 @@ export async function restoreWindowPosition(handle, position, { isCurrent = () = } } -/** Fit the complete transparent content area, not only the Host's minimum overlap. */ -export async function fitWindowToScreen(handle, { screenRect, isCurrent = () => true } = {}) { +/** Fit the complete transparent content area; on pop-out keep the bottom-centered pet visible even when it cannot all fit. */ +export async function fitWindowToScreen(handle, { screenRect, isCurrent = () => true, size, keepPetVisible = false } = {}) { const cancelled = () => ({ cancelled: true, error: null, state: null }); if (!isCurrent()) return cancelled(); try { @@ -34,11 +34,18 @@ export async function fitWindowToScreen(handle, { screenRect, isCurrent = () => || bounds.width <= 0 || bounds.height <= 0) return { error: 'invalid_state' }; if (!rect || ![rect.x, rect.y, rect.width, rect.height].every(finite) || rect.width <= 0 || rect.height <= 0) return { error: 'screen_unavailable' }; - if (bounds.width > rect.width || bounds.height > rect.height) return { error: 'screen_too_small' }; - const x = Math.ceil(Math.max(rect.x, Math.min(bounds.x, rect.x + rect.width - bounds.width))); - const y = Math.ceil(Math.max(rect.y, Math.min(bounds.y, rect.y + rect.height - bounds.height))); - if (x === bounds.x && y === bounds.y) return { state, error: null }; - const updated = await handle.update({ x, y }); + const { width, height } = size ?? bounds; + const spareX = rect.width - width; + const spareY = rect.height - height; + if (!keepPetVisible && (spareX < 0 || spareY < 0)) return { error: 'screen_too_small' }; + // The sprite is centered at the bottom of the window. On small work areas, keep that + // edge on-screen instead of clamping the top and pushing the sprite below the display. + const x = spareX < 0 ? Math.round(rect.x + spareX / 2) : Math.ceil(Math.max(rect.x, Math.min(bounds.x, rect.x + spareX))); + const y = spareY < 0 ? Math.floor(rect.y + spareY) : Math.ceil(Math.max(rect.y, Math.min(bounds.y, rect.y + spareY))); + if (x === bounds.x && y === bounds.y && width === bounds.width && height === bounds.height) return { state, error: null }; + // Pop-out has a known design size. Include it with the move instead of relying on + // a position-only update to preserve the pre-correction dimensions. + const updated = await handle.update(size ? { x, y, width, height } : { x, y }); if (!isCurrent() || updated?.mode !== 'window') return cancelled(); return { state: updated, error: null }; } catch (error) { diff --git a/sources/minimax-ai/minimax-pet/.minimax-plugin/plugin.json b/sources/minimax-ai/minimax-pet/.minimax-plugin/plugin.json index 7df6138b..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.0", + "version": "0.9.3", "description": "轻量桌宠,聚合主窗口可见会话的任务状态、需要回答的提醒和最新结果,支持外观切换及图集导入。", "author": "MiniMax", "icon": "icon.png", diff --git a/sources/minimax-ai/minimax-pet/README.md b/sources/minimax-ai/minimax-pet/README.md index f1ce6fb5..16922ca5 100644 --- a/sources/minimax-ai/minimax-pet/README.md +++ b/sources/minimax-ai/minimax-pet/README.md @@ -20,6 +20,8 @@ Version **0.9.0** adds two settings. **Task notifications** sets how many second Version **0.9.0** also gives the desktop window one fixed size, tall enough for the open card. Earlier versions grew the window when a card opened, which moved it on screen and made the pet jump for a frame; now opening or closing a card only shows or hides it. The area above the pet is transparent and passes clicks through to whatever is behind it. +Version **0.9.3** keeps the pet reachable when you choose **放到桌面**. It tries the saved position first, then fits the window to the usable area of the screen it actually lands on. A valid position on another display stays put; when the window is taller than the available area, the pet stays at the bottom rather than being hidden below the screen. + 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. @@ -47,6 +49,7 @@ Earlier local prototypes use a different plugin ID. The Host gives `minimax-pet` - An earlier UI version was exercised on macOS in a MiniMax Code development build: three tabs, wide/narrow layouts, task reading, real session/ask activity, import/delete, and desktop round trips. Version 0.6.0 has Node/DOM tests (including the open and theme paths against a simulated Host), an isolated HTTP smoke test, and a browser check of the panel layout outside the Host. - 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.3 was checked in MiniMax Code **3.1.19.232** on Windows 11 x64 (build 26200, 150% display scaling). The old saved position clipped the pet at the top of the screen; the patched app brought it fully inside the work area and saved the corrected position. Secondary and disconnected displays were exercised in automated tests, not on physical displays. - 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 939c0231..1b0b6bcd 100644 --- a/sources/minimax-ai/minimax-pet/README.zh-CN.md +++ b/sources/minimax-ai/minimax-pet/README.zh-CN.md @@ -22,6 +22,8 @@ **0.9.0** 把桌面窗口固定成一个尺寸,本来就放得下展开的卡片。之前点开卡片会把窗口撑高,窗口在屏幕上跟着移动,桌宠会跳一下;现在开合卡片只显示或隐藏,不动窗口。桌宠上方是透明区域,点击会穿透到底下的窗口。 +**0.9.3** 修复点击“放到桌面”后宠物可能落到屏幕外的问题。先尝试恢复上次的位置,再按窗口实际落在哪块屏幕校正;副屏上的合法位置不会被移回主屏。如果窗口比可用区域更高,优先让窗口底部的宠物留在屏幕上。 + **0.8.1** 修复桌面卡片:标题单行截断,只有回复区滚动,底部操作固定在卡片内;长标题或长回复不再把「返回任务 / 打开对话」顶出卡片。展开卡片时窗口同步变高,回复不会被压成一行。 **0.8.0** 按 MiniMax Code 的设计语言对齐面板:24px 页边距与区块间距、14px/22px 正文与 12px/18px 辅助文字、控件最小高度 32px、卡片 12px 与控件 8px 圆角、桌面浮层 0.5px 描边,并补齐按下与焦点状态。桌面宠物保持 280px 布局,沿用同一套 token。 @@ -40,6 +42,8 @@ 更早的 UI 版本已在 macOS 开发版验收三页签、窄宽布局、真实任务与 ask、导入删除和桌面切换;0.6.0 运行 Node/DOM 测试(含模拟 Host 下的打开对话与主题路径)、隔离 HTTP smoke,并在 Host 之外用浏览器检查了面板布局。默认图集通过 PNG 解码、动画帧覆盖与确定性重建检查;独立的章鱼图标通过 PNG 解码和视觉检查。2026-10-26,已用 macOS 开发版中的真实 Agent 调用随包 Skill,完成自定义 v2 宠物的生成、校验、预览和导入,并检查九种动作预览与鼠标上/右/下/左四向注视。0.6.0 尚未在真实的 MiniMax Code 3.1.11+ 窗口(面板或桌面宠物)中验收打开对话和主题跟随,也未验收 Windows GUI、正式客户端安装或 3.1.6 正式版 GUI;合成数据测试不能证明这些路径。 +0.9.3 已在 Windows 11 x64(构建 26200,屏幕缩放 150%)的 MiniMax Code **3.1.19.232** 中测试。旧保存位置会让宠物在屏幕上沿被裁切,修复版把宠物完整移进工作区并保存校正位置。副屏及屏幕断开场景只做了自动化测试,未连接实际副屏测试。 + ## 数据与能力边界 只申请 `session.read`,读取 Host 对本插件可见的用户会话状态和所选会话最新回复,不直接读取 Host 数据库、日志、配置或凭据。状态和提醒只在页面内存中,关闭或静音不修改 Host 的任务或未读事实。 diff --git a/sources/minimax-ai/minimax-pet/dev/window-position.test.mjs b/sources/minimax-ai/minimax-pet/dev/window-position.test.mjs index 2fdbea1e..61008d80 100644 --- a/sources/minimax-ai/minimax-pet/dev/window-position.test.mjs +++ b/sources/minimax-ai/minimax-pet/dev/window-position.test.mjs @@ -1,5 +1,7 @@ import assert from 'node:assert/strict'; +import { readFile } from 'node:fs/promises'; import test from 'node:test'; +import vm from 'node:vm'; import { restoreWindowPosition, fitWindowToScreen } from '../miniapp/client/window-position.mjs'; function frameBridge() { @@ -120,3 +122,75 @@ test('closing during resize preparation never sends geometry to a different surf live = false; resolve({ mode: 'window', window: { x: 1864, y: 100, width: 280, height: 340 } }); assert.equal((await operation).cancelled, true); }); + +// Run the page's real window-entry handler with a controlled bridge. The fake Host permits +// partial overlap, like the desktop Host; it deliberately does not keep the sprite on-screen. +const page = await readFile(new URL('../miniapp/client/pet-app.js', import.meta.url), 'utf8'); +const sizing = page.slice(page.indexOf('const DESK_WIDTH'), page.indexOf('let notificationPreviews')); +const windowEntry = page.slice(page.indexOf('function onWindowState('), page.indexOf('function applyMode(')); + +async function popOut({ origin, saved = null, workArea = { availLeft: 0, availTop: 0, availWidth: 1707, availHeight: 1019 } }) { + const calls = [], notices = [], savedPositions = []; + const prefs = { scale: 0.5, windowPosition: saved }; + const app = { mode: 'inline', positionRestoreToken: 0 }; + const bounds = { x: origin.x, y: origin.y, width: 280, height: 436, clickThrough: true }; + const state = () => ({ mode: 'window', window: { ...bounds } }); + const win = { + getState: async () => state(), + update: async (patch) => { + calls.push({ ...patch }); + if (patch.x === 50000) throw new Error('not_permitted'); + Object.assign(bounds, patch); + return state(); + }, + }; + const screen = typeof workArea === 'function' ? workArea(bounds) : workArea; + const context = vm.createContext({ + app, prefs, win, screen, start: state(), disposed: false, restoreWindowPosition, fitWindowToScreen, + applyMode: (mode) => { app.mode = mode; }, showTransient: (message) => notices.push(message), + t: (key) => key, errCode: (error) => error.message, + clearTimeout() {}, setTimeout: (fn) => { fn(); return 1; }, + savePreferences: (patch) => { savedPositions.push({ ...patch.windowPosition }); }, + }); + vm.runInContext(`${sizing}\n${windowEntry}\nonWindowState(start);`, context); + await new Promise((resolve) => setImmediate(resolve)); + return { app, calls, notices, savedPositions }; +} + +test('pop-out fits an off-screen Host default even without a saved position', async () => { + const h = await popOut({ origin: { x: 1090, y: 846 } }); + // 1019 is the reproduced work-area bottom; 436 is the small pet's designed height. + assert.deepEqual(h.calls, [{ clickThrough: false }, { x: 1090, y: 583, width: 280, height: 436 }]); + assert.equal(h.app.restoringPosition, false); + assert.deepEqual(h.savedPositions, [{ x: 1090, y: 679 }], 'persist only the corrected bottom anchor'); +}); + +test('pop-out fits a partially visible saved position above the display', async () => { + const h = await popOut({ origin: { x: 200, y: 200 }, saved: { x: 1093, y: -322 } }); + assert.equal(h.calls[1].y, -418, 'the stored bottom anchor resolves to the old off-screen origin'); + assert.deepEqual(h.calls.at(-1), { x: 1093, y: 0, width: 280, height: 436 }); + assert.deepEqual(h.savedPositions, [{ x: 1093, y: 96 }]); +}); + +test('pop-out keeps a valid saved position on a display left of the primary one', async () => { + const h = await popOut({ origin: { x: 200, y: 200 }, saved: { x: -1000, y: 146 }, workArea: (bounds) => ({ + get availLeft() { return bounds.x < 0 ? -1920 : 0; }, availTop: 0, availWidth: 1920, availHeight: 1080, + }) }); + assert.equal(h.calls.length, 2, 'a valid position should not be moved again'); + assert.equal(h.app.winBounds.x, -1000); + assert.equal(h.app.winBounds.y, 50); + assert.deepEqual(h.savedPositions, []); +}); + +test('pop-out recovers from a rejected position on a disconnected display', async () => { + const h = await popOut({ origin: { x: 1090, y: 846 }, saved: { x: 50000, y: 100 } }); + assert.deepEqual(h.calls.at(-1), { x: 1090, y: 583, width: 280, height: 436 }); + assert.deepEqual(h.notices, [], 'the fallback fit succeeded'); +}); + +test('pop-out keeps the sprite at the bottom on a display shorter than the window', async () => { + const h = await popOut({ origin: { x: 30, y: 50 }, workArea: { availLeft: 0, availTop: 0, availWidth: 260, availHeight: 400 } }); + assert.deepEqual(h.calls.at(-1), { x: -10, y: -36, width: 280, height: 436 }); + assert.equal(h.app.winBounds.y + h.app.winBounds.height, 400); + assert.deepEqual(h.notices, []); +}); diff --git a/sources/minimax-ai/minimax-pet/miniapp/client/index.html b/sources/minimax-ai/minimax-pet/miniapp/client/index.html index 24c255f6..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.0

+

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 81b26a28..b3da5c01 100644 --- a/sources/minimax-ai/minimax-pet/miniapp/client/pet-app.js +++ b/sources/minimax-ai/minimax-pet/miniapp/client/pet-app.js @@ -588,11 +588,25 @@ function onWindowState(state) { void restoreWindowPosition(win, saved, { isCurrent }).then(async (result) => { if (disposed || token !== app.positionRestoreToken || app.mode !== 'window') return; let restoredState = result.state; - const height = deskHeight(prefs.scale); - if (result.interactive && restoredState?.window && (restoredState.window.width !== DESK_WIDTH || restoredState.window.height !== height)) { - try { restoredState = await win.update({ width: DESK_WIDTH, height }); } - catch (error) { if (!isCurrent()) return; result.error = errCode(error); } + const size = { width: DESK_WIDTH, height: deskHeight(prefs.scale) }; + if (result.interactive && restoredState?.window) { + // Restore first: the saved position may be on a different display. Check the work + // area only after the Host settles there, including when the saved move was refused. + const fitted = await fitWindowToScreen(win, { + isCurrent, size, keepPetVisible: true, + screenRect: () => ({ x: screen.availLeft, y: screen.availTop, width: screen.availWidth, height: screen.availHeight }), + }); if (!isCurrent()) return; + if (fitted.cancelled) { applyMode('inline'); return; } + if (fitted.state) restoredState = fitted.state; + if (fitted.error) result.error = fitted.error; + else if (result.error === 'not_permitted') result.error = null; + // Older clients can lack usable work-area data. Preserve their existing size repair. + if (fitted.error === 'screen_unavailable' && (restoredState.window.width !== size.width || restoredState.window.height !== size.height)) { + try { restoredState = await win.update(size); } + catch (error) { if (!isCurrent()) return; result.error = errCode(error); } + if (!isCurrent()) return; + } } if (restoredState) onWindowState(restoredState); if (!isCurrent()) return; @@ -601,7 +615,7 @@ function onWindowState(state) { if (result.error) showTransient(result.interactive ? t('mode.positionFailed', { code: result.error }) : t('mode.interactionUnknown', { code: result.error }), 'error'); - rememberPosition(); + else rememberPosition(); }); return; } diff --git a/sources/minimax-ai/minimax-pet/miniapp/client/window-position.mjs b/sources/minimax-ai/minimax-pet/miniapp/client/window-position.mjs index c259e09c..4561b45a 100644 --- a/sources/minimax-ai/minimax-pet/miniapp/client/window-position.mjs +++ b/sources/minimax-ai/minimax-pet/miniapp/client/window-position.mjs @@ -20,8 +20,8 @@ export async function restoreWindowPosition(handle, position, { isCurrent = () = } } -/** Fit the complete transparent content area, not only the Host's minimum overlap. */ -export async function fitWindowToScreen(handle, { screenRect, isCurrent = () => true } = {}) { +/** Fit the complete transparent content area; on pop-out keep the bottom-centered pet visible even when it cannot all fit. */ +export async function fitWindowToScreen(handle, { screenRect, isCurrent = () => true, size, keepPetVisible = false } = {}) { const cancelled = () => ({ cancelled: true, error: null, state: null }); if (!isCurrent()) return cancelled(); try { @@ -34,11 +34,18 @@ export async function fitWindowToScreen(handle, { screenRect, isCurrent = () => || bounds.width <= 0 || bounds.height <= 0) return { error: 'invalid_state' }; if (!rect || ![rect.x, rect.y, rect.width, rect.height].every(finite) || rect.width <= 0 || rect.height <= 0) return { error: 'screen_unavailable' }; - if (bounds.width > rect.width || bounds.height > rect.height) return { error: 'screen_too_small' }; - const x = Math.ceil(Math.max(rect.x, Math.min(bounds.x, rect.x + rect.width - bounds.width))); - const y = Math.ceil(Math.max(rect.y, Math.min(bounds.y, rect.y + rect.height - bounds.height))); - if (x === bounds.x && y === bounds.y) return { state, error: null }; - const updated = await handle.update({ x, y }); + const { width, height } = size ?? bounds; + const spareX = rect.width - width; + const spareY = rect.height - height; + if (!keepPetVisible && (spareX < 0 || spareY < 0)) return { error: 'screen_too_small' }; + // The sprite is centered at the bottom of the window. On small work areas, keep that + // edge on-screen instead of clamping the top and pushing the sprite below the display. + const x = spareX < 0 ? Math.round(rect.x + spareX / 2) : Math.ceil(Math.max(rect.x, Math.min(bounds.x, rect.x + spareX))); + const y = spareY < 0 ? Math.floor(rect.y + spareY) : Math.ceil(Math.max(rect.y, Math.min(bounds.y, rect.y + spareY))); + if (x === bounds.x && y === bounds.y && width === bounds.width && height === bounds.height) return { state, error: null }; + // Pop-out has a known design size. Include it with the move instead of relying on + // a position-only update to preserve the pre-correction dimensions. + const updated = await handle.update(size ? { x, y, width, height } : { x, y }); if (!isCurrent() || updated?.mode !== 'window') return cancelled(); return { state: updated, error: null }; } catch (error) { diff --git a/sources/minimax-ai/minimax-pet/package-lock.json b/sources/minimax-ai/minimax-pet/package-lock.json index 1cb0ddb9..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.0", + "version": "0.9.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "minimax-pet-source", - "version": "0.9.0", + "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 34fc08d5..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.0", + "version": "0.9.3", "private": true, "type": "module", "description": "桌宠插件的开发与验证工具,不进入分发包。",