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. */} +
- ))} -
-
-
-
- 配置 - {status[selectedSlot].profileId ?? "未连接"} -
-
- 会话 - {status[selectedSlot].activeSessionId ?? "新会话"} -
-
- 状态 - {connectionStateLabel(status[selectedSlot].state)} -
-
- - - - -
-
+ {(["companion", "operations"] as const).map((slot) => ( + + ))} + , + slotTabsMount, + ) + : null} {status[selectedSlot].lastError ? (

{status[selectedSlot].lastError} @@ -769,34 +747,67 @@ export function ChatPanel({ fixedSlot }: ChatPanelProps) { ) : null} - {displaySessions.length > 0 ? ( -

- {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. */} +
+
+ + +
- ) : null} + {displaySessions.length > 0 ? ( +
+ {displaySessions.map((session, index) => ( + + ))} +
+ ) : null} +
.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();