diff --git a/src/App.tsx b/src/App.tsx
index 4230742..a8d68e9 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -40,6 +40,9 @@ const DiagnosticsPage = lazy(() =>
);
import { bootstrapStatusSchema, type BootstrapStatus } from "./types/bootstrap";
+/// Shared with `ChatPanel`, which portals its slot tabs into this element.
+export const WINDOW_CHROME_MOUNT_ID = "window-chrome-mount";
+
type PageKey = "chat" | "connections" | "desktop" | "pet" | "diagnostics";
type ChatSlot = "companion" | "operations";
type PetDisplayMode = "app-ui" | "desktop-floating";
@@ -302,6 +305,15 @@ function WindowChrome({
}}
>
AstrBot Desktop
+ {/* Mount point for controls that belong to the active page but should sit
+ in the title bar. ChatPanel portals its slot tabs here, which keeps the
+ slot state and its status polling where they already live instead of
+ lifting both into the shell. */}
+
);
await flushListen();
await screen.findByRole("tab", { name: /陪伴/ });
diff --git a/src/features/chat/ChatPanel.tsx b/src/features/chat/ChatPanel.tsx
index 09ffc3b..571ebb9 100644
--- a/src/features/chat/ChatPanel.tsx
+++ b/src/features/chat/ChatPanel.tsx
@@ -1,7 +1,9 @@
import { invoke } from "@tauri-apps/api/core";
import { listen } from "@tauri-apps/api/event";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
+import { createPortal } from "react-dom";
+import { WINDOW_CHROME_MOUNT_ID } from "../../App";
import { errorMessage } from "../../lib/errorMessage";
import { MessageContent } from "./MessageContent";
@@ -102,6 +104,16 @@ export function ChatPanel({ fixedSlot }: ChatPanelProps) {
companion: false,
operations: false,
});
+ // Resolved in an effect because the title bar mounts with the shell, which
+ // is not guaranteed to have rendered when this panel first runs. The quick
+ // chat and bubble windows have no title bar at all, so it stays null there
+ // and the tabs simply do not render — those views are already slot-fixed.
+ const [slotTabsMount, setSlotTabsMount] = useState(null);
+ useEffect(() => {
+ if (fixedSlot) return;
+ setSlotTabsMount(document.getElementById(WINDOW_CHROME_MOUNT_ID));
+ }, [fixedSlot]);
+
const messageListRef = useRef(null);
/// Whether the view should follow new content.
///
@@ -592,10 +604,6 @@ export function ChatPanel({ fixedSlot }: ChatPanelProps) {
}
};
- const refreshConnection = async () => {
- await refresh();
- };
-
const reconnectConnection = async () => {
const slot = selectedSlot;
const profileId = status[slot].profileId;
@@ -677,82 +685,52 @@ export function ChatPanel({ fixedSlot }: ChatPanelProps) {
return (
-
-
-
共享聊天运行时
-
统一聊天运行时
-
- 主界面、快速聊天和气泡共享同一套消息状态。
-
-
-
- {(["companion", "operations"] as const).map((slot) => (
-
- {displaySessions.map((session, index) => (
-
- ))}
+ {/* Connection actions ride along the session row rather than a strip of
+ their own, so removing that strip cost the chat no controls and gave
+ it the height back. `刷新` is gone: the status already refreshes on a
+ 500ms poll, so the button did nothing the panel was not doing. */}
+
.chat-runtime-actions {
+ flex: 0 0 auto;
+ display: flex;
+ gap: 0.3rem;
+}
+
+.chat-session-bar > .chat-session-list {
+ flex: 1 1 auto;
+ min-width: 0;
+}
+
/* Everything the AstrBot connection does not need in order to work. Collapsed
by default so the common path is four fields. */
.profile-advanced {
@@ -1667,8 +1687,53 @@ body {
-webkit-app-region: drag;
}
+/* Holds controls the active page portals into the title bar. Not a drag
+ region, so clicking a tab does not start moving the window. */
+.window-chrome-mount {
+ display: flex;
+ flex: 0 0 auto;
+ align-items: center;
+ gap: 0.4rem;
+ min-width: 0;
+ margin-inline: auto 0.75rem;
+ -webkit-app-region: no-drag;
+}
+
+/* Compact enough to sit in a 44px bar: the label and its connection state on
+ one line instead of stacked.
+ `[role="tab"]` is carried on purpose — the panel's own `.chat-slot[role=tab]`
+ rule sets a 2.75rem minimum and appears later in the sheet, so an unqualified
+ selector here loses to it and the tabs overflow the bar. */
+.window-chrome-mount .chat-slot-tabs {
+ flex-wrap: nowrap;
+ align-items: center;
+ gap: 0.3rem;
+ width: auto;
+ padding: 0;
+}
+
+.window-chrome-mount .chat-slot[role="tab"] {
+ display: flex;
+ flex: 0 0 auto;
+ align-items: baseline;
+ gap: 0.35rem;
+ min-width: 0;
+ /* Both zeroed: the panel's rules set a 3.25rem and a 2.75rem minimum, and a
+ stretch alignment would otherwise size the button to the row anyway. */
+ min-height: 0;
+ height: 2rem;
+ padding: 0.2rem 0.6rem;
+ font-size: 0.85rem;
+ white-space: nowrap;
+}
+
+.window-chrome-mount .chat-slot[role="tab"] > span {
+ font-size: 0.72rem;
+ opacity: 0.75;
+}
+
.window-chrome-title {
- flex: 1 1 auto;
+ flex: 0 0 auto;
min-width: 0;
overflow: hidden;
color: #9fb9e3;
diff --git a/tests/e2e/bootstrap.spec.ts b/tests/e2e/bootstrap.spec.ts
index fccdc69..0c59f6d 100644
--- a/tests/e2e/bootstrap.spec.ts
+++ b/tests/e2e/bootstrap.spec.ts
@@ -8,9 +8,11 @@ test("renders the bootstrap shell and safe browser fallback", async ({
await expect(
page.getByText("AstrBot Desktop", { exact: true }).first(),
).toBeVisible();
- await expect(
- page.getByRole("heading", { name: "统一聊天运行时" }),
- ).toBeVisible();
+ // The chat panel's own heading is gone; the slot tabs it portals into the
+ // title bar are what proves the panel rendered and that the portal found its
+ // mount point.
+ await expect(page.getByRole("tab", { name: /陪伴/ })).toBeVisible();
+ await expect(page.getByRole("tab", { name: /运维/ })).toBeVisible();
await expect(
page.getByText("IPC 暂不可用:", { exact: false }),
).toBeVisible();