Improve space toggles and email warmup

This commit is contained in:
pewdiepie-archdaemon
2026-06-01 14:35:38 +09:00
parent cb8a0b268d
commit e846269d61
3 changed files with 110 additions and 9 deletions
+24 -1
View File
@@ -28,7 +28,7 @@
import { previewZoneAt, clearPreview, snapModalToZone } from './tileManager.js';
import { suspendDock, resumeDock, clearRightDock, applyEdgeDock } from './modalSnap.js';
const _state = new Map(); // id -> { restoreFn, closeFn, railBtnId, isMinimized }
const _state = new Map(); // id -> { restoreFn, closeFn, railBtnId, isMinimized, restoreMinHeight }
const _rememberedDockKey = (id) => `odysseus-modal-remembered-dock-${id}`;
function _rememberDock(id, side) {
@@ -73,6 +73,26 @@ function _emitModalOpened(id, modal) {
} catch (_) {}
}
function _captureRestoreHeight(modal, state) {
if (!modal || !state) return;
const content = modal.querySelector('.modal-content');
if (!content) return;
const rect = content.getBoundingClientRect();
if (!rect || rect.height < 120) return;
const maxHeight = Math.max(180, window.innerHeight - 24);
state.restoreMinHeight = `${Math.round(Math.min(rect.height, maxHeight))}px`;
}
function _applyRestoreHeight(modal, state) {
if (!modal || !state?.restoreMinHeight) return;
const content = modal.querySelector('.modal-content');
if (!content) return;
const maxHeight = Math.max(180, window.innerHeight - 24);
const requested = parseInt(state.restoreMinHeight, 10);
const height = Number.isFinite(requested) ? Math.min(requested, maxHeight) : null;
if (height) content.style.minHeight = `${height}px`;
}
function _setBadge(btnIds, on) {
if (!btnIds) return;
const ids = Array.isArray(btnIds) ? btnIds : [btnIds];
@@ -1109,6 +1129,7 @@ export function register(id, { restoreFn, closeFn, railBtnId, sidebarBtnId, labe
closeFn: closeFn || (() => {}),
btnIds,
isMinimized: false,
restoreMinHeight: '',
});
// Auto-stack: whichever modal becomes visible last sits on top of any
// already-open modals. The various tool open() functions (gallery,
@@ -1188,6 +1209,7 @@ export function minimize(id) {
// and let the chip drive restore/close via the registered functions.
const modal = document.getElementById(id);
if (modal) {
_captureRestoreHeight(modal, s);
// If this window is edge-docked (right/left), SUSPEND the dock: release
// the body push so the chat returns to full width while the window is
// minimized, but keep the dock so restoring the chip snaps it back in.
@@ -1218,6 +1240,7 @@ export function restore(id) {
if (modal) {
modal.classList.remove('hidden', 'modal-minimized');
modal.style.display = '';
_applyRestoreHeight(modal, s);
// Surface above any already-open tool window — restoring from the dock
// should bring this tool to the front, not leave it stuck behind one with
// a higher static z-index.