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 e75e7c8b..f65d3d74 100644
--- a/plugins/minimax-ai/minimax-pet/miniapp/client/pet-app.js
+++ b/plugins/minimax-ai/minimax-pet/miniapp/client/pet-app.js
@@ -590,11 +590,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;
@@ -603,7 +617,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 34667e81..5689a1f0 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.3",
+ "version": "0.9.4",
"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 732affc0..1298cdbe 100644
--- a/sources/minimax-ai/minimax-pet/README.md
+++ b/sources/minimax-ai/minimax-pet/README.md
@@ -24,6 +24,8 @@ Version **0.9.2** keeps the desktop window at its intended size while dragging b
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.9.4** keeps the pet reachable when you choose **放到桌面**. It tries the saved position, 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.
@@ -53,6 +55,7 @@ Earlier local prototypes use a different plugin ID. The Host gives `minimax-pet`
- 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.
+- A pre-rebase build of the pop-out fix 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 f2a9e43d..21e0b336 100644
--- a/sources/minimax-ai/minimax-pet/README.zh-CN.md
+++ b/sources/minimax-ai/minimax-pet/README.zh-CN.md
@@ -26,6 +26,8 @@
**0.9.3** 根据宿主确认的窗口位置和指针相对抓取点的偏移移动桌宠。每次移动结束后,才使用新的指针事件。如果在宿主应答前松手,窗口停在宿主最后接受的位置。
+**0.9.4** 修复点击“放到桌面”后宠物可能落到屏幕外的问题。先尝试恢复上次的位置,再按窗口实际落在哪块屏幕校正;副屏上的合法位置不会被移回主屏。如果窗口比可用区域更高,优先让窗口底部的宠物留在屏幕上。
+
**0.8.1** 修复桌面卡片:标题单行截断,只有回复区滚动,底部操作固定在卡片内;长标题或长回复不再把「返回任务 / 打开对话」顶出卡片。展开卡片时窗口同步变高,回复不会被压成一行。
**0.8.0** 按 MiniMax Code 的设计语言对齐面板:24px 页边距与区块间距、14px/22px 正文与 12px/18px 辅助文字、控件最小高度 32px、卡片 12px 与控件 8px 圆角、桌面浮层 0.5px 描边,并补齐按下与焦点状态。桌面宠物保持 280px 布局,沿用同一套 token。
@@ -48,6 +50,8 @@
本地对照构建已在 Windows 11(构建 26300)、4K 显示器和 MiniMax Inside Code **3.1.19.169** 下用物理鼠标测试。0.9.3 的回归测试覆盖宿主应用窗口移动前后到达的指针事件。0.9.3 正式打包版本仍待桌面验收。
+弹出修复在本次 rebase 前已用 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 7c3e94bb..416c7f92 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.3
+
MiniMax Pet 0.9.4
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 e75e7c8b..f65d3d74 100644
--- a/sources/minimax-ai/minimax-pet/miniapp/client/pet-app.js
+++ b/sources/minimax-ai/minimax-pet/miniapp/client/pet-app.js
@@ -590,11 +590,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;
@@ -603,7 +617,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 810999d0..7ebab531 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.3",
+ "version": "0.9.4",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "minimax-pet-source",
- "version": "0.9.3",
+ "version": "0.9.4",
"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 58e29c0e..93e92967 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.3",
+ "version": "0.9.4",
"private": true,
"type": "module",
"description": "桌宠插件的开发与验证工具,不进入分发包。",