diff --git a/docs/content.en/docs/release-notes/_index.md b/docs/content.en/docs/release-notes/_index.md index 5e3540d0..8d64aac1 100644 --- a/docs/content.en/docs/release-notes/_index.md +++ b/docs/content.en/docs/release-notes/_index.md @@ -25,6 +25,7 @@ Information about release notes of Coco App is provided here. - chore: write panic message to stdout in panic hook #989 - refactor: error handling in install_extension interfaces #995 +- chore: adjust the position of the compact mode window #997 ## 0.9.0 (2025-11-19) diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 06a898e3..9b724410 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -63,7 +63,10 @@ async fn change_window_height(handle: AppHandle, height: u32) { let monitor_position = monitor.position(); let monitor_size = monitor.size(); - let window_width = window.outer_size().unwrap().width as i32; + let outer_size = window.outer_size().unwrap(); + let window_width = outer_size.width as i32; + let window_height = outer_size.height as i32; + let x = monitor_position.x + (monitor_size.width as i32 - window_width) / 2; let y = diff --git a/src/components/SearchChat/index.tsx b/src/components/SearchChat/index.tsx index 5495b2a8..e0d4e197 100644 --- a/src/components/SearchChat/index.tsx +++ b/src/components/SearchChat/index.tsx @@ -35,7 +35,7 @@ import { visibleSearchBar, } from "@/utils"; import { useTauriFocus } from "@/hooks/useTauriFocus"; -import { POPOVER_PANEL_SELECTOR } from "@/constants"; +import { POPOVER_PANEL_SELECTOR, WINDOW_CENTER_BASELINE_HEIGHT } from "@/constants"; import { useChatStore } from "@/stores/chatStore"; import { useSearchStore } from "@/stores/searchStore"; @@ -112,7 +112,7 @@ function SearchChat({ } const width = 680; - let height = 590; + let height = WINDOW_CENTER_BASELINE_HEIGHT; const updateAppDialog = document.querySelector("#update-app-dialog"); const popoverPanelEl = document.querySelector(POPOVER_PANEL_SELECTOR); @@ -136,7 +136,7 @@ function SearchChat({ } } - if (height < 590) { + if (height < WINDOW_CENTER_BASELINE_HEIGHT) { const { compactModeAutoCollapseDelay } = useConnectStore.getState(); collapseWindowTimer.current = setTimeout(() => { diff --git a/src/constants/index.ts b/src/constants/index.ts index 2f8f3105..f34637ec 100644 --- a/src/constants/index.ts +++ b/src/constants/index.ts @@ -13,3 +13,5 @@ export const SETTINGS_WINDOW_LABEL = "settings"; export const CHECK_WINDOW_LABEL = "check"; export const CHAT_WINDOW_LABEL = "chat"; + +export const WINDOW_CENTER_BASELINE_HEIGHT = 590; diff --git a/src/pages/web/index.tsx b/src/pages/web/index.tsx index 2af77a23..cf18d09c 100644 --- a/src/pages/web/index.tsx +++ b/src/pages/web/index.tsx @@ -3,6 +3,7 @@ import { useTranslation } from "react-i18next"; import { isPlainObject } from "lodash-es"; import SearchChat from "@/components/SearchChat"; +import { WINDOW_CENTER_BASELINE_HEIGHT } from "@/constants"; import { useAppStore } from "@/stores/appStore"; import { useShortcutsStore } from "@/stores/shortcutsStore"; import { useIsMobile } from "@/hooks/useIsMobile"; @@ -41,7 +42,7 @@ interface WebAppProps { function WebApp({ width = 680, - height = 590, + height = WINDOW_CENTER_BASELINE_HEIGHT, headers = { "X-API-TOKEN": "", "APP-INTEGRATION-ID": "", diff --git a/src/utils/wrappers/tauriWrappers.ts b/src/utils/wrappers/tauriWrappers.ts index 11940ef5..15875505 100644 --- a/src/utils/wrappers/tauriWrappers.ts +++ b/src/utils/wrappers/tauriWrappers.ts @@ -1,4 +1,5 @@ import * as commands from "@/commands"; +import { WINDOW_CENTER_BASELINE_HEIGHT } from "@/constants"; // Window operations export const windowWrapper = { @@ -14,6 +15,9 @@ export const windowWrapper = { const window = await this.getCurrentWebviewWindow(); if (window) { await window.setSize(new LogicalSize(width, height)); + if (height < WINDOW_CENTER_BASELINE_HEIGHT) { + await window.center(); + } } }, };