From 1eba70d292c24e362269122b2a707996f057a41c Mon Sep 17 00:00:00 2001 From: YokiiroBW Date: Mon, 27 Jul 2026 03:59:29 +0800 Subject: [PATCH] feat(chat): give the conversation the height the header was using MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The chat panel opened with three stacked blocks above the messages: a title and subtitle naming the panel, a strip repeating the profile id, session id and connection state, and the session pills. Only the last carried anything the reader needed. Move the slot tabs into the window title bar and delete the rest. The tabs go there through a portal rather than by lifting state into the shell, which keeps the slot selection and its status polling in the panel that owns them; the quick chat and bubble windows have no title bar, and they are slot-fixed already, so the tabs simply do not render there. The connection actions move onto the session row, which costs no height because that row already exists. 刷新 is dropped: the status refreshes on a 500ms poll, so the button did nothing the panel was not already doing. 重连, 断开 and 新对话 stay, since losing them would leave no way to recover a dropped connection or start a conversation. The panel now puts 82px above the messages instead of three blocks. The title-bar rules carry [role="tab"] on purpose — the panel's own .chat-slot[role=tab] rule sets a 2.75rem minimum and sits later in the sheet, so an unqualified selector loses to it and the tabs overflow a 44px bar. Verified against the real stylesheet: tabs 33px inside a 44px bar, vertically centred, clear of both the title text and the window controls; the removed blocks are absent from the DOM. Co-Authored-By: Claude Opus 5 --- src/App.tsx | 12 ++ src/features/chat/ChatPanel.test.tsx | 10 +- src/features/chat/ChatPanel.tsx | 223 ++++++++++++++------------- src/styles.css | 67 +++++++- tests/e2e/bootstrap.spec.ts | 8 +- 5 files changed, 209 insertions(+), 111 deletions(-) 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();