2026-07-21 14:43:14 +08:00
|
|
|
|
import { invoke } from "@tauri-apps/api/core";
|
2026-07-20 20:50:27 +08:00
|
|
|
|
import { listen } from "@tauri-apps/api/event";
|
2026-07-21 14:43:14 +08:00
|
|
|
|
import { getCurrentWindow } from "@tauri-apps/api/window";
|
2026-07-22 00:27:06 +08:00
|
|
|
|
import {
|
|
|
|
|
|
lazy,
|
|
|
|
|
|
Suspense,
|
|
|
|
|
|
useCallback,
|
|
|
|
|
|
useEffect,
|
|
|
|
|
|
useRef,
|
|
|
|
|
|
useState,
|
|
|
|
|
|
} from "react";
|
2026-07-18 20:34:47 +08:00
|
|
|
|
|
2026-07-26 22:31:16 +08:00
|
|
|
|
import { errorMessage } from "./lib/errorMessage";
|
fix(pet): read stored preferences and stop the pet from stealing focus
An audit of the destroy→hide change across four lenses raised 17
findings; 14 survived adversarial verification. Two of them were
regressions that change introduced, and both had the same shape: code
that only worked because the pet window used to not exist.
show_pet_context_menu picked the pet window and fell back to main.
While the pet rendered inside the app its window had been destroyed at
startup, so the fallback happened to select the visible main window.
Now that the window merely hides, the menu was being anchored to a
hidden HWND, which Win32 cannot bring to the foreground. The
visibility test is explicit now rather than incidental.
DesktopPetView read the connection state in a mount effect and nothing
emitted connection events, so destroy-and-rebuild was what re-read it.
Without a remount the floating pet showed whatever was true at startup
for the rest of the session. reveal_pet_window now emits
pet-window-revealed and the view re-reads on it.
The rest were already there. Every pet setting was decorative: the
preferences were applied and then dropped, so reveal_pet_window had to
invent an answer and hard-coded the first monitor, the safe edge and
always-on-top — reverting the user's choices on every show. The pet view
re-sent a fully hard-coded payload whenever game mode toggled, and the
settings page initialised its controls from literals, so returning to
the page and changing one thing pushed three stale defaults back onto
the window. There is a session-scoped store now, a command to read it,
and both frontends read before they write. Persisting it across restarts
is F-75.
Always-on-top is off by default, which is what the Q6 acceptance
criterion asked for (F-35), and the window no longer takes focus when
shown — it was activating on show and swallowing keystrokes meant for
the main window. focusable is left alone on purpose: clearing it adds
WS_EX_NOACTIVATE, which would re-break the context menu now anchored to
that window. That is F-79.
The pet also painted a solid dark rectangle before its assets arrived.
The transparency rule is gated on a class that an effect inside the
5.2 MB lazy chunk added, so until that chunk ran the app's opaque
background won. This is why the earlier hunt for "the rule that beats
!important" found nothing: the class was not applied yet, so specificity
was never the question. The pet now has its own entry document carrying
the class statically. An inline script would not do — tauri-utils only
nonces script[src^='http'], so it would pass in dev and be blocked by
script-src 'self' in a release build.
Rust tests 92 → 97, frontend 30 → 35. All 11 mutations of the new
assertions were confirmed to fail.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 05:25:27 +08:00
|
|
|
|
import {
|
|
|
|
|
|
petPositionModeSchema,
|
|
|
|
|
|
petWindowPreferencesSchema,
|
|
|
|
|
|
type PetPositionMode,
|
|
|
|
|
|
} from "./features/pet/types";
|
2026-07-20 11:31:41 +08:00
|
|
|
|
import { ChatPanel } from "./features/chat/ChatPanel";
|
|
|
|
|
|
import { StatusBubble } from "./features/chat/StatusBubble";
|
2026-07-22 00:27:06 +08:00
|
|
|
|
const ProfileManager = lazy(() =>
|
|
|
|
|
|
import("./features/profiles/ProfileManager").then(({ ProfileManager }) => ({
|
|
|
|
|
|
default: ProfileManager,
|
|
|
|
|
|
})),
|
|
|
|
|
|
);
|
|
|
|
|
|
const PetPackImporter = lazy(() =>
|
|
|
|
|
|
import("./features/pet/PetPackImporter").then(({ PetPackImporter }) => ({
|
|
|
|
|
|
default: PetPackImporter,
|
|
|
|
|
|
})),
|
|
|
|
|
|
);
|
|
|
|
|
|
const DesktopBehaviorPage = lazy(() =>
|
|
|
|
|
|
import("./pages/SettingsPages").then(({ DesktopBehaviorPage }) => ({
|
|
|
|
|
|
default: DesktopBehaviorPage,
|
|
|
|
|
|
})),
|
|
|
|
|
|
);
|
|
|
|
|
|
const DesktopPetView = lazy(() =>
|
|
|
|
|
|
import("./features/pet/DesktopPetView").then(({ DesktopPetView }) => ({
|
|
|
|
|
|
default: DesktopPetView,
|
|
|
|
|
|
})),
|
|
|
|
|
|
);
|
|
|
|
|
|
const DiagnosticsPage = lazy(() =>
|
|
|
|
|
|
import("./pages/SettingsPages").then(({ DiagnosticsPage }) => ({
|
|
|
|
|
|
default: DiagnosticsPage,
|
|
|
|
|
|
})),
|
|
|
|
|
|
);
|
2026-07-18 22:17:29 +08:00
|
|
|
|
import { bootstrapStatusSchema, type BootstrapStatus } from "./types/bootstrap";
|
2026-07-18 20:34:47 +08:00
|
|
|
|
|
feat(chat): give the conversation the height the header was using
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 <noreply@anthropic.com>
2026-07-27 03:59:29 +08:00
|
|
|
|
/// Shared with `ChatPanel`, which portals its slot tabs into this element.
|
|
|
|
|
|
export const WINDOW_CHROME_MOUNT_ID = "window-chrome-mount";
|
|
|
|
|
|
|
2026-07-20 12:58:42 +08:00
|
|
|
|
type PageKey = "chat" | "connections" | "desktop" | "pet" | "diagnostics";
|
|
|
|
|
|
type ChatSlot = "companion" | "operations";
|
2026-07-20 20:50:27 +08:00
|
|
|
|
type PetDisplayMode = "app-ui" | "desktop-floating";
|
2026-07-21 14:43:14 +08:00
|
|
|
|
type ThemeMode = "dark" | "light";
|
2026-07-20 12:58:42 +08:00
|
|
|
|
|
2026-07-18 20:34:47 +08:00
|
|
|
|
const initialStatus: BootstrapStatus = {
|
|
|
|
|
|
appVersion: "unknown",
|
|
|
|
|
|
platform: "unknown",
|
|
|
|
|
|
rustCore: "pending",
|
|
|
|
|
|
protocolVersion: "desktop-v1alpha1",
|
2026-07-20 11:31:41 +08:00
|
|
|
|
databaseSchemaVersion: 4,
|
2026-07-18 20:34:47 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
2026-07-20 12:58:42 +08:00
|
|
|
|
const navigation: Array<{ key: PageKey; label: string; description: string }> =
|
|
|
|
|
|
[
|
|
|
|
|
|
{ key: "chat", label: "聊天", description: "陪伴与运维对话" },
|
|
|
|
|
|
{ key: "connections", label: "连接", description: "实例与槽位管理" },
|
|
|
|
|
|
{ key: "desktop", label: "桌面行为", description: "快速聊天与状态气泡" },
|
|
|
|
|
|
{ key: "pet", label: "桌宠", description: "形象与活动范围" },
|
|
|
|
|
|
{
|
|
|
|
|
|
key: "diagnostics",
|
|
|
|
|
|
label: "诊断与设置",
|
|
|
|
|
|
description: "运行状态与安全边界",
|
|
|
|
|
|
},
|
|
|
|
|
|
];
|
|
|
|
|
|
|
2026-07-18 20:34:47 +08:00
|
|
|
|
export function App() {
|
2026-07-20 12:58:42 +08:00
|
|
|
|
const params = new URLSearchParams(window.location.search);
|
|
|
|
|
|
const view = params.get("view");
|
2026-07-20 11:31:41 +08:00
|
|
|
|
const isQuickView = view === "quick";
|
|
|
|
|
|
const isBubbleView = view === "bubble";
|
2026-07-21 14:43:14 +08:00
|
|
|
|
const isPetView =
|
|
|
|
|
|
view === "pet" ||
|
|
|
|
|
|
window.location.hash === "#pet" ||
|
|
|
|
|
|
document.documentElement.dataset.astrbotPet === "true";
|
2026-07-20 12:58:42 +08:00
|
|
|
|
const quickSlot = params.get("slot");
|
|
|
|
|
|
const [page, setPage] = useState<PageKey>("chat");
|
2026-07-21 14:43:14 +08:00
|
|
|
|
const [theme, setTheme] = useState<ThemeMode>(() =>
|
|
|
|
|
|
localStorage.getItem("astrbot.theme") === "light" ? "light" : "dark",
|
|
|
|
|
|
);
|
2026-07-18 20:34:47 +08:00
|
|
|
|
const [status, setStatus] = useState(initialStatus);
|
|
|
|
|
|
const [error, setError] = useState<string | null>(null);
|
2026-07-20 12:58:42 +08:00
|
|
|
|
const [quickTarget, setQuickTarget] = useState<ChatSlot>(() =>
|
|
|
|
|
|
localStorage.getItem("astrbot.quickTarget") === "operations"
|
|
|
|
|
|
? "operations"
|
|
|
|
|
|
: "companion",
|
2026-07-20 12:34:56 +08:00
|
|
|
|
);
|
|
|
|
|
|
const [bubbleTarget, setBubbleTarget] = useState<"main" | "quick">(() =>
|
|
|
|
|
|
localStorage.getItem("astrbot.bubbleTarget") === "quick" ? "quick" : "main",
|
|
|
|
|
|
);
|
2026-07-20 20:50:27 +08:00
|
|
|
|
const [petDisplayMode, setPetDisplayMode] = useState<PetDisplayMode>(() =>
|
|
|
|
|
|
localStorage.getItem("astrbot.petDisplayMode") === "desktop-floating"
|
|
|
|
|
|
? "desktop-floating"
|
|
|
|
|
|
: "app-ui",
|
|
|
|
|
|
);
|
2026-07-18 20:34:47 +08:00
|
|
|
|
|
|
|
|
|
|
const refreshStatus = useCallback(async () => {
|
|
|
|
|
|
try {
|
2026-07-18 22:17:29 +08:00
|
|
|
|
const result = await invoke<unknown>("bootstrap_status");
|
|
|
|
|
|
setStatus(bootstrapStatusSchema.parse(result));
|
2026-07-18 20:34:47 +08:00
|
|
|
|
setError(null);
|
|
|
|
|
|
} catch (reason) {
|
2026-07-26 22:31:16 +08:00
|
|
|
|
setError(errorMessage(reason));
|
2026-07-18 20:34:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
2026-07-21 14:43:14 +08:00
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
document.documentElement.dataset.theme = theme;
|
|
|
|
|
|
localStorage.setItem("astrbot.theme", theme);
|
|
|
|
|
|
}, [theme]);
|
|
|
|
|
|
|
2026-07-18 20:34:47 +08:00
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
void refreshStatus();
|
|
|
|
|
|
}, [refreshStatus]);
|
|
|
|
|
|
|
2026-07-20 20:50:27 +08:00
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
if (isBubbleView || isPetView || isQuickView) return;
|
2026-07-21 14:43:14 +08:00
|
|
|
|
const command =
|
|
|
|
|
|
petDisplayMode === "desktop-floating"
|
|
|
|
|
|
? "open_pet_window"
|
|
|
|
|
|
: "close_pet_window";
|
2026-07-20 20:50:27 +08:00
|
|
|
|
void invoke(command).catch((reason) => {
|
2026-07-26 22:31:16 +08:00
|
|
|
|
setError(errorMessage(reason));
|
2026-07-20 20:50:27 +08:00
|
|
|
|
});
|
|
|
|
|
|
}, [isBubbleView, isPetView, isQuickView, petDisplayMode]);
|
|
|
|
|
|
|
2026-07-20 11:31:41 +08:00
|
|
|
|
if (isBubbleView) return <StatusBubble />;
|
feat(pet): log where the floating pet window actually ended up
The floating pet still does not appear, and the two explanations offered
so far are not sufficient. The rebuild path genuinely never called
show(), which is fixed and correct on its own reading of the code, but it
did not resolve the symptom. A missing Suspense boundary around the lazy
pet view looked like a second cause and is not one: removing the wrapper
still renders the pet, so React 19 tolerates it. That claim is retracted
in the comment rather than left standing.
The window is transparent and undecorated, so "did not appear" covers a
window placed off-screen, a window that reports hidden, and a window
present with nothing painted in it. Log the monitor work area, the
position and size after placement, and the visibility the window
reports, at default level so no filter is needed to read it.
The Suspense wrapper stays. Relying on React tolerating a lazy component
with no boundary is not a contract, and the bubble and quick views
already have their own.
Refs: N-11, F-61.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 04:25:37 +08:00
|
|
|
|
// `DesktopPetView` is lazy and this branch returns before the shell's own
|
|
|
|
|
|
// boundary, so it had none. React 19 turned out to tolerate that — removing
|
|
|
|
|
|
// this wrapper still rendered the pet — so it is not the reason the floating
|
|
|
|
|
|
// pet does not appear. Kept because relying on that tolerance is not a
|
|
|
|
|
|
// contract, and the bubble and quick views already have their own.
|
|
|
|
|
|
if (isPetView) {
|
|
|
|
|
|
return (
|
|
|
|
|
|
<Suspense fallback={null}>
|
|
|
|
|
|
<DesktopPetView />
|
|
|
|
|
|
</Suspense>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
2026-07-20 12:58:42 +08:00
|
|
|
|
if (isQuickView) {
|
2026-07-20 11:31:41 +08:00
|
|
|
|
return (
|
|
|
|
|
|
<main className="quick-app-shell">
|
2026-07-20 12:34:56 +08:00
|
|
|
|
<ChatPanel
|
|
|
|
|
|
fixedSlot={
|
|
|
|
|
|
quickSlot === "operations"
|
|
|
|
|
|
? "operations"
|
|
|
|
|
|
: quickSlot === "companion"
|
|
|
|
|
|
? "companion"
|
|
|
|
|
|
: undefined
|
|
|
|
|
|
}
|
|
|
|
|
|
/>
|
2026-07-20 11:31:41 +08:00
|
|
|
|
</main>
|
|
|
|
|
|
);
|
2026-07-20 12:58:42 +08:00
|
|
|
|
}
|
2026-07-20 11:31:41 +08:00
|
|
|
|
|
2026-07-18 20:34:47 +08:00
|
|
|
|
return (
|
|
|
|
|
|
<main className="app-shell">
|
2026-07-21 14:43:14 +08:00
|
|
|
|
<WindowChrome
|
|
|
|
|
|
theme={theme}
|
|
|
|
|
|
onToggleTheme={() =>
|
|
|
|
|
|
setTheme((current) => (current === "dark" ? "light" : "dark"))
|
|
|
|
|
|
}
|
fix(tauri): grant the window controls the permissions they call
The minimize, maximize and close buttons did nothing. They were wired
correctly; the ACL rejected them. core:default resolves to
core:window:default, which grants only read-only queries — is-maximized
is in it, which is why the maximize icon tracked state correctly, but
minimize, toggle-maximize, close and start-dragging are not. Both
windows are decorations: false, so with close denied the main window
could not be closed at all except through the tray.
Add two capabilities rather than widening the shared one: the main
window gets the four controls it draws, and the pet window gets dragging
alone, since it is moved by dragging its body and must not be able to
close or resize itself.
Every one of these calls was a bare void expression, so the rejection
was swallowed and looked identical to an unwired button. Route them
through a helper that reports the failure in the shell error banner.
This is the second time a missing capability has surfaced as a silent
no-op — the pet window previously had no entry at all. Add tests that
read the shipped capability files and assert each permission the UI
calls is granted to the window that calls it.
Also translate the TypeError the Tauri shim throws outside the
application into a sentence a user can act on. The dev server is
reachable at 127.0.0.1:1420, so opening it in a browser and hitting save
produced "Cannot read properties of undefined (reading 'invoke')".
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 01:19:42 +08:00
|
|
|
|
onError={setError}
|
2026-07-21 14:43:14 +08:00
|
|
|
|
/>
|
|
|
|
|
|
<div className="app-shell-body">
|
|
|
|
|
|
<aside className="app-sidebar">
|
|
|
|
|
|
<div className="brand-lockup">
|
|
|
|
|
|
<div className="brand-mark">A</div>
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<strong>AstrBot Desktop</strong>
|
|
|
|
|
|
<span>Companion workspace</span>
|
|
|
|
|
|
</div>
|
2026-07-20 12:58:42 +08:00
|
|
|
|
</div>
|
2026-07-21 14:43:14 +08:00
|
|
|
|
<nav className="primary-nav" aria-label="主导航">
|
|
|
|
|
|
{navigation.map((item) => (
|
|
|
|
|
|
<button
|
|
|
|
|
|
key={item.key}
|
|
|
|
|
|
type="button"
|
|
|
|
|
|
className={page === item.key ? "nav-item active" : "nav-item"}
|
|
|
|
|
|
onClick={() => setPage(item.key)}
|
|
|
|
|
|
>
|
|
|
|
|
|
<span className="nav-item-icon">{navIcon(item.key)}</span>
|
|
|
|
|
|
<span>
|
|
|
|
|
|
<strong>{item.label}</strong>
|
|
|
|
|
|
<small>{item.description}</small>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</button>
|
|
|
|
|
|
))}
|
|
|
|
|
|
</nav>
|
|
|
|
|
|
<div className="sidebar-footer">
|
|
|
|
|
|
<span className="connection-dot" />
|
|
|
|
|
|
<span>本地客户端已启动</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</aside>
|
|
|
|
|
|
|
|
|
|
|
|
<section
|
|
|
|
|
|
className={
|
|
|
|
|
|
page === "chat" ? "app-content app-content-chat" : "app-content"
|
|
|
|
|
|
}
|
|
|
|
|
|
>
|
|
|
|
|
|
{page === "chat" ? null : <PageHeader page={page} />}
|
2026-07-22 00:27:06 +08:00
|
|
|
|
{error ? (
|
|
|
|
|
|
<p className="error-banner" role="alert">
|
|
|
|
|
|
IPC 暂不可用:{error}
|
|
|
|
|
|
</p>
|
2026-07-21 14:43:14 +08:00
|
|
|
|
) : null}
|
2026-07-22 00:27:06 +08:00
|
|
|
|
<Suspense fallback={<PageLoading />}>
|
|
|
|
|
|
{page === "chat" ? <ChatPage /> : null}
|
|
|
|
|
|
{page === "connections" ? <ProfileManager /> : null}
|
|
|
|
|
|
{page === "desktop" ? (
|
|
|
|
|
|
<DesktopBehaviorPage
|
|
|
|
|
|
bubbleTarget={bubbleTarget}
|
|
|
|
|
|
quickTarget={quickTarget}
|
|
|
|
|
|
onBubbleTargetChange={(value) => {
|
|
|
|
|
|
setBubbleTarget(value);
|
|
|
|
|
|
localStorage.setItem("astrbot.bubbleTarget", value);
|
|
|
|
|
|
}}
|
|
|
|
|
|
onQuickTargetChange={(value) => {
|
|
|
|
|
|
setQuickTarget(value);
|
|
|
|
|
|
localStorage.setItem("astrbot.quickTarget", value);
|
|
|
|
|
|
}}
|
|
|
|
|
|
onOpenQuickChat={() =>
|
|
|
|
|
|
void invoke("open_quick_chat_window", { slot: quickTarget })
|
|
|
|
|
|
}
|
|
|
|
|
|
/>
|
|
|
|
|
|
) : null}
|
|
|
|
|
|
{page === "pet" ? (
|
|
|
|
|
|
<PetPage
|
|
|
|
|
|
displayMode={petDisplayMode}
|
|
|
|
|
|
onDisplayModeChange={(value) => {
|
|
|
|
|
|
setPetDisplayMode(value);
|
|
|
|
|
|
localStorage.setItem("astrbot.petDisplayMode", value);
|
|
|
|
|
|
}}
|
|
|
|
|
|
/>
|
|
|
|
|
|
) : null}
|
|
|
|
|
|
{page === "diagnostics" ? (
|
|
|
|
|
|
<DiagnosticsPage
|
|
|
|
|
|
status={status}
|
|
|
|
|
|
onRefresh={() => void refreshStatus()}
|
|
|
|
|
|
/>
|
|
|
|
|
|
) : null}
|
|
|
|
|
|
</Suspense>
|
2026-07-21 14:43:14 +08:00
|
|
|
|
</section>
|
|
|
|
|
|
</div>
|
2026-07-22 00:27:06 +08:00
|
|
|
|
{petDisplayMode === "app-ui" ? (
|
|
|
|
|
|
<Suspense fallback={null}>
|
|
|
|
|
|
<InAppPetOverlay />
|
|
|
|
|
|
</Suspense>
|
|
|
|
|
|
) : null}
|
2026-07-20 12:58:42 +08:00
|
|
|
|
</main>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
2026-07-18 20:34:47 +08:00
|
|
|
|
|
2026-07-21 14:43:14 +08:00
|
|
|
|
function WindowChrome({
|
|
|
|
|
|
theme,
|
|
|
|
|
|
onToggleTheme,
|
fix(tauri): grant the window controls the permissions they call
The minimize, maximize and close buttons did nothing. They were wired
correctly; the ACL rejected them. core:default resolves to
core:window:default, which grants only read-only queries — is-maximized
is in it, which is why the maximize icon tracked state correctly, but
minimize, toggle-maximize, close and start-dragging are not. Both
windows are decorations: false, so with close denied the main window
could not be closed at all except through the tray.
Add two capabilities rather than widening the shared one: the main
window gets the four controls it draws, and the pet window gets dragging
alone, since it is moved by dragging its body and must not be able to
close or resize itself.
Every one of these calls was a bare void expression, so the rejection
was swallowed and looked identical to an unwired button. Route them
through a helper that reports the failure in the shell error banner.
This is the second time a missing capability has surfaced as a silent
no-op — the pet window previously had no entry at all. Add tests that
read the shipped capability files and assert each permission the UI
calls is granted to the window that calls it.
Also translate the TypeError the Tauri shim throws outside the
application into a sentence a user can act on. The dev server is
reachable at 127.0.0.1:1420, so opening it in a browser and hitting save
produced "Cannot read properties of undefined (reading 'invoke')".
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 01:19:42 +08:00
|
|
|
|
onError,
|
2026-07-21 14:43:14 +08:00
|
|
|
|
}: {
|
|
|
|
|
|
theme: ThemeMode;
|
|
|
|
|
|
onToggleTheme: () => void;
|
fix(tauri): grant the window controls the permissions they call
The minimize, maximize and close buttons did nothing. They were wired
correctly; the ACL rejected them. core:default resolves to
core:window:default, which grants only read-only queries — is-maximized
is in it, which is why the maximize icon tracked state correctly, but
minimize, toggle-maximize, close and start-dragging are not. Both
windows are decorations: false, so with close denied the main window
could not be closed at all except through the tray.
Add two capabilities rather than widening the shared one: the main
window gets the four controls it draws, and the pet window gets dragging
alone, since it is moved by dragging its body and must not be able to
close or resize itself.
Every one of these calls was a bare void expression, so the rejection
was swallowed and looked identical to an unwired button. Route them
through a helper that reports the failure in the shell error banner.
This is the second time a missing capability has surfaced as a silent
no-op — the pet window previously had no entry at all. Add tests that
read the shipped capability files and assert each permission the UI
calls is granted to the window that calls it.
Also translate the TypeError the Tauri shim throws outside the
application into a sentence a user can act on. The dev server is
reachable at 127.0.0.1:1420, so opening it in a browser and hitting save
produced "Cannot read properties of undefined (reading 'invoke')".
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 01:19:42 +08:00
|
|
|
|
onError: (message: string) => void;
|
2026-07-21 14:43:14 +08:00
|
|
|
|
}) {
|
|
|
|
|
|
const [currentWindow, setCurrentWindow] = useState<ReturnType<
|
|
|
|
|
|
typeof getCurrentWindow
|
|
|
|
|
|
> | null>(null);
|
|
|
|
|
|
const [maximized, setMaximized] = useState(false);
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
try {
|
|
|
|
|
|
const windowHandle = getCurrentWindow();
|
|
|
|
|
|
setCurrentWindow(windowHandle);
|
|
|
|
|
|
void windowHandle.isMaximized().then(setMaximized);
|
|
|
|
|
|
} catch {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
fix(tauri): grant the window controls the permissions they call
The minimize, maximize and close buttons did nothing. They were wired
correctly; the ACL rejected them. core:default resolves to
core:window:default, which grants only read-only queries — is-maximized
is in it, which is why the maximize icon tracked state correctly, but
minimize, toggle-maximize, close and start-dragging are not. Both
windows are decorations: false, so with close denied the main window
could not be closed at all except through the tray.
Add two capabilities rather than widening the shared one: the main
window gets the four controls it draws, and the pet window gets dragging
alone, since it is moved by dragging its body and must not be able to
close or resize itself.
Every one of these calls was a bare void expression, so the rejection
was swallowed and looked identical to an unwired button. Route them
through a helper that reports the failure in the shell error banner.
This is the second time a missing capability has surfaced as a silent
no-op — the pet window previously had no entry at all. Add tests that
read the shipped capability files and assert each permission the UI
calls is granted to the window that calls it.
Also translate the TypeError the Tauri shim throws outside the
application into a sentence a user can act on. The dev server is
reachable at 127.0.0.1:1420, so opening it in a browser and hitting save
produced "Cannot read properties of undefined (reading 'invoke')".
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 01:19:42 +08:00
|
|
|
|
/// Every one of these is an ACL-gated IPC call. They used to be bare
|
|
|
|
|
|
/// `void ...()` expressions, so when the capability set was missing the
|
|
|
|
|
|
/// window permissions the rejection was swallowed and the buttons simply did
|
|
|
|
|
|
/// nothing, with no way to tell that from an unwired handler.
|
|
|
|
|
|
const runWindowAction = async (action: () => Promise<void>) => {
|
2026-07-21 14:43:14 +08:00
|
|
|
|
if (!currentWindow) return;
|
fix(tauri): grant the window controls the permissions they call
The minimize, maximize and close buttons did nothing. They were wired
correctly; the ACL rejected them. core:default resolves to
core:window:default, which grants only read-only queries — is-maximized
is in it, which is why the maximize icon tracked state correctly, but
minimize, toggle-maximize, close and start-dragging are not. Both
windows are decorations: false, so with close denied the main window
could not be closed at all except through the tray.
Add two capabilities rather than widening the shared one: the main
window gets the four controls it draws, and the pet window gets dragging
alone, since it is moved by dragging its body and must not be able to
close or resize itself.
Every one of these calls was a bare void expression, so the rejection
was swallowed and looked identical to an unwired button. Route them
through a helper that reports the failure in the shell error banner.
This is the second time a missing capability has surfaced as a silent
no-op — the pet window previously had no entry at all. Add tests that
read the shipped capability files and assert each permission the UI
calls is granted to the window that calls it.
Also translate the TypeError the Tauri shim throws outside the
application into a sentence a user can act on. The dev server is
reachable at 127.0.0.1:1420, so opening it in a browser and hitting save
produced "Cannot read properties of undefined (reading 'invoke')".
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 01:19:42 +08:00
|
|
|
|
try {
|
|
|
|
|
|
await action();
|
|
|
|
|
|
} catch (reason) {
|
|
|
|
|
|
onError(errorMessage(reason));
|
|
|
|
|
|
}
|
2026-07-21 14:43:14 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
fix(tauri): grant the window controls the permissions they call
The minimize, maximize and close buttons did nothing. They were wired
correctly; the ACL rejected them. core:default resolves to
core:window:default, which grants only read-only queries — is-maximized
is in it, which is why the maximize icon tracked state correctly, but
minimize, toggle-maximize, close and start-dragging are not. Both
windows are decorations: false, so with close denied the main window
could not be closed at all except through the tray.
Add two capabilities rather than widening the shared one: the main
window gets the four controls it draws, and the pet window gets dragging
alone, since it is moved by dragging its body and must not be able to
close or resize itself.
Every one of these calls was a bare void expression, so the rejection
was swallowed and looked identical to an unwired button. Route them
through a helper that reports the failure in the shell error banner.
This is the second time a missing capability has surfaced as a silent
no-op — the pet window previously had no entry at all. Add tests that
read the shipped capability files and assert each permission the UI
calls is granted to the window that calls it.
Also translate the TypeError the Tauri shim throws outside the
application into a sentence a user can act on. The dev server is
reachable at 127.0.0.1:1420, so opening it in a browser and hitting save
produced "Cannot read properties of undefined (reading 'invoke')".
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 01:19:42 +08:00
|
|
|
|
const toggleMaximize = () =>
|
|
|
|
|
|
runWindowAction(async () => {
|
|
|
|
|
|
await currentWindow!.toggleMaximize();
|
|
|
|
|
|
setMaximized(await currentWindow!.isMaximized());
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2026-07-21 14:43:14 +08:00
|
|
|
|
return (
|
|
|
|
|
|
<header
|
|
|
|
|
|
className="window-chrome"
|
|
|
|
|
|
data-tauri-drag-region
|
|
|
|
|
|
onDoubleClick={() => void toggleMaximize()}
|
|
|
|
|
|
onMouseDown={(event) => {
|
2026-07-22 02:52:31 +08:00
|
|
|
|
if (
|
|
|
|
|
|
event.button === 0 &&
|
|
|
|
|
|
!(event.target as HTMLElement).closest(
|
|
|
|
|
|
'[data-tauri-drag-region="false"]',
|
|
|
|
|
|
)
|
|
|
|
|
|
) {
|
fix(tauri): grant the window controls the permissions they call
The minimize, maximize and close buttons did nothing. They were wired
correctly; the ACL rejected them. core:default resolves to
core:window:default, which grants only read-only queries — is-maximized
is in it, which is why the maximize icon tracked state correctly, but
minimize, toggle-maximize, close and start-dragging are not. Both
windows are decorations: false, so with close denied the main window
could not be closed at all except through the tray.
Add two capabilities rather than widening the shared one: the main
window gets the four controls it draws, and the pet window gets dragging
alone, since it is moved by dragging its body and must not be able to
close or resize itself.
Every one of these calls was a bare void expression, so the rejection
was swallowed and looked identical to an unwired button. Route them
through a helper that reports the failure in the shell error banner.
This is the second time a missing capability has surfaced as a silent
no-op — the pet window previously had no entry at all. Add tests that
read the shipped capability files and assert each permission the UI
calls is granted to the window that calls it.
Also translate the TypeError the Tauri shim throws outside the
application into a sentence a user can act on. The dev server is
reachable at 127.0.0.1:1420, so opening it in a browser and hitting save
produced "Cannot read properties of undefined (reading 'invoke')".
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 01:19:42 +08:00
|
|
|
|
void runWindowAction(() => currentWindow!.startDragging());
|
2026-07-22 02:52:31 +08:00
|
|
|
|
}
|
2026-07-21 14:43:14 +08:00
|
|
|
|
}}
|
|
|
|
|
|
>
|
|
|
|
|
|
<span className="window-chrome-title">AstrBot Desktop</span>
|
feat(chat): give the conversation the height the header was using
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 <noreply@anthropic.com>
2026-07-27 03:59:29 +08:00
|
|
|
|
{/* 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. */}
|
|
|
|
|
|
<div
|
|
|
|
|
|
className="window-chrome-mount"
|
|
|
|
|
|
id={WINDOW_CHROME_MOUNT_ID}
|
|
|
|
|
|
data-tauri-drag-region="false"
|
|
|
|
|
|
/>
|
2026-07-21 14:43:14 +08:00
|
|
|
|
<div className="window-chrome-actions" data-tauri-drag-region="false">
|
|
|
|
|
|
<button
|
|
|
|
|
|
aria-label={
|
|
|
|
|
|
theme === "dark" ? "Switch to light theme" : "Switch to dark theme"
|
|
|
|
|
|
}
|
|
|
|
|
|
className="window-theme-toggle"
|
|
|
|
|
|
onClick={onToggleTheme}
|
|
|
|
|
|
onMouseDown={(event) => event.stopPropagation()}
|
|
|
|
|
|
type="button"
|
|
|
|
|
|
>
|
|
|
|
|
|
{theme === "dark" ? "Light" : "Dark"}
|
|
|
|
|
|
</button>
|
|
|
|
|
|
<div className="window-controls" data-tauri-drag-region="false">
|
|
|
|
|
|
<button
|
|
|
|
|
|
aria-label="Minimize window"
|
|
|
|
|
|
className="window-control"
|
fix(tauri): grant the window controls the permissions they call
The minimize, maximize and close buttons did nothing. They were wired
correctly; the ACL rejected them. core:default resolves to
core:window:default, which grants only read-only queries — is-maximized
is in it, which is why the maximize icon tracked state correctly, but
minimize, toggle-maximize, close and start-dragging are not. Both
windows are decorations: false, so with close denied the main window
could not be closed at all except through the tray.
Add two capabilities rather than widening the shared one: the main
window gets the four controls it draws, and the pet window gets dragging
alone, since it is moved by dragging its body and must not be able to
close or resize itself.
Every one of these calls was a bare void expression, so the rejection
was swallowed and looked identical to an unwired button. Route them
through a helper that reports the failure in the shell error banner.
This is the second time a missing capability has surfaced as a silent
no-op — the pet window previously had no entry at all. Add tests that
read the shipped capability files and assert each permission the UI
calls is granted to the window that calls it.
Also translate the TypeError the Tauri shim throws outside the
application into a sentence a user can act on. The dev server is
reachable at 127.0.0.1:1420, so opening it in a browser and hitting save
produced "Cannot read properties of undefined (reading 'invoke')".
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 01:19:42 +08:00
|
|
|
|
onClick={() =>
|
|
|
|
|
|
void runWindowAction(() => currentWindow!.minimize())
|
|
|
|
|
|
}
|
2026-07-21 14:43:14 +08:00
|
|
|
|
onMouseDown={(event) => event.stopPropagation()}
|
|
|
|
|
|
type="button"
|
|
|
|
|
|
>
|
|
|
|
|
|
<span
|
|
|
|
|
|
className="window-glyph window-glyph-minimize"
|
|
|
|
|
|
aria-hidden="true"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</button>
|
|
|
|
|
|
<button
|
|
|
|
|
|
aria-label={maximized ? "Restore window" : "Maximize window"}
|
|
|
|
|
|
className="window-control"
|
|
|
|
|
|
onClick={() => void toggleMaximize()}
|
|
|
|
|
|
onMouseDown={(event) => event.stopPropagation()}
|
|
|
|
|
|
type="button"
|
|
|
|
|
|
>
|
|
|
|
|
|
<span
|
|
|
|
|
|
className={`window-glyph window-glyph-maximize${maximized ? " is-restored" : ""}`}
|
|
|
|
|
|
aria-hidden="true"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</button>
|
|
|
|
|
|
<button
|
|
|
|
|
|
aria-label="Close window"
|
|
|
|
|
|
className="window-control window-control-close"
|
fix(tauri): grant the window controls the permissions they call
The minimize, maximize and close buttons did nothing. They were wired
correctly; the ACL rejected them. core:default resolves to
core:window:default, which grants only read-only queries — is-maximized
is in it, which is why the maximize icon tracked state correctly, but
minimize, toggle-maximize, close and start-dragging are not. Both
windows are decorations: false, so with close denied the main window
could not be closed at all except through the tray.
Add two capabilities rather than widening the shared one: the main
window gets the four controls it draws, and the pet window gets dragging
alone, since it is moved by dragging its body and must not be able to
close or resize itself.
Every one of these calls was a bare void expression, so the rejection
was swallowed and looked identical to an unwired button. Route them
through a helper that reports the failure in the shell error banner.
This is the second time a missing capability has surfaced as a silent
no-op — the pet window previously had no entry at all. Add tests that
read the shipped capability files and assert each permission the UI
calls is granted to the window that calls it.
Also translate the TypeError the Tauri shim throws outside the
application into a sentence a user can act on. The dev server is
reachable at 127.0.0.1:1420, so opening it in a browser and hitting save
produced "Cannot read properties of undefined (reading 'invoke')".
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 01:19:42 +08:00
|
|
|
|
onClick={() => void runWindowAction(() => currentWindow!.close())}
|
2026-07-21 14:43:14 +08:00
|
|
|
|
onMouseDown={(event) => event.stopPropagation()}
|
|
|
|
|
|
type="button"
|
|
|
|
|
|
>
|
|
|
|
|
|
<span
|
|
|
|
|
|
className="window-glyph window-glyph-close"
|
|
|
|
|
|
aria-hidden="true"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</header>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-07-20 20:50:27 +08:00
|
|
|
|
function InAppPetOverlay() {
|
|
|
|
|
|
const [visible, setVisible] = useState(true);
|
|
|
|
|
|
const [position, setPosition] = useState(() => {
|
|
|
|
|
|
try {
|
2026-07-21 14:43:14 +08:00
|
|
|
|
const saved = JSON.parse(
|
|
|
|
|
|
localStorage.getItem("astrbot.petPosition") ?? "null",
|
|
|
|
|
|
);
|
2026-07-20 20:50:27 +08:00
|
|
|
|
return saved && typeof saved.x === "number" && typeof saved.y === "number"
|
|
|
|
|
|
? saved
|
2026-07-22 00:27:06 +08:00
|
|
|
|
: { x: window.innerWidth >= 720 ? 280 : 24, y: 96 };
|
2026-07-20 20:50:27 +08:00
|
|
|
|
} catch {
|
2026-07-22 00:27:06 +08:00
|
|
|
|
return { x: window.innerWidth >= 720 ? 280 : 24, y: 96 };
|
2026-07-20 20:50:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
2026-07-21 14:43:14 +08:00
|
|
|
|
const dragRef = useRef<{
|
|
|
|
|
|
pointerId: number;
|
|
|
|
|
|
offsetX: number;
|
|
|
|
|
|
offsetY: number;
|
|
|
|
|
|
} | null>(null);
|
2026-07-20 20:50:27 +08:00
|
|
|
|
|
2026-07-22 00:27:06 +08:00
|
|
|
|
const clampPosition = useCallback((x: number, y: number) => {
|
|
|
|
|
|
const safeLeft = window.innerWidth >= 720 ? 248 : 0;
|
|
|
|
|
|
const maxX = Math.max(safeLeft, window.innerWidth - 188);
|
|
|
|
|
|
return {
|
|
|
|
|
|
x: Math.max(safeLeft, Math.min(x, maxX)),
|
2026-07-20 20:50:27 +08:00
|
|
|
|
y: Math.max(0, Math.min(y, window.innerHeight - 226)),
|
|
|
|
|
|
};
|
2026-07-22 00:27:06 +08:00
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
|
|
const savePosition = (x: number, y: number) => {
|
|
|
|
|
|
const next = clampPosition(x, y);
|
2026-07-20 20:50:27 +08:00
|
|
|
|
setPosition(next);
|
|
|
|
|
|
localStorage.setItem("astrbot.petPosition", JSON.stringify(next));
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2026-07-22 00:27:06 +08:00
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
const normalizePosition = () => {
|
|
|
|
|
|
const next = clampPosition(position.x, position.y);
|
|
|
|
|
|
if (next.x === position.x && next.y === position.y) return;
|
|
|
|
|
|
setPosition(next);
|
|
|
|
|
|
localStorage.setItem("astrbot.petPosition", JSON.stringify(next));
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
normalizePosition();
|
|
|
|
|
|
window.addEventListener("resize", normalizePosition);
|
|
|
|
|
|
return () => window.removeEventListener("resize", normalizePosition);
|
|
|
|
|
|
}, [clampPosition, position.x, position.y]);
|
|
|
|
|
|
|
2026-07-20 20:50:27 +08:00
|
|
|
|
useEffect(() => {
|
fix(ui): release tauri event listeners on unmount
All four listen() call sites assigned the resolved unregister function
unconditionally. When the effect was cleaned up before the promise
settled, that assignment landed on a dead closure and the listener was
never unregistered. React StrictMode mounts, cleans up and mounts again,
so the first listener leaked on every development mount. In ChatPanel
that meant applyRuntimeEvents ran twice per event and, because a delta
is appended to the existing content, every character of a streamed reply
was doubled.
Track whether the effect is still live and unregister immediately when
the promise settles late. Each site also gains a catch, since these were
all bare void listen(...).then(...) chains — a rejected listen, such as
the missing desktop-pet capability, became an unhandled rejection rather
than anything observable.
The listener mock in src/test/setup.ts resolved eagerly, which made the
race impossible to express. Replace it with a controllable double in
src/test/tauriEvent.ts that defers resolution until the test asks for
it, tracks each registration separately, and only dispatches to handlers
that have not been unregistered. The registry is plain module state, so
setup.ts resets it after each test.
ChatPanel had no test file; this adds one. Both new tests were checked
against a mutation restoring the old assignment, and both fail under it.
Refs: F-15 (audit P1-10).
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 00:23:42 +08:00
|
|
|
|
let active = true;
|
2026-07-20 20:50:27 +08:00
|
|
|
|
let unlisten: (() => void) | undefined;
|
fix(ui): release tauri event listeners on unmount
All four listen() call sites assigned the resolved unregister function
unconditionally. When the effect was cleaned up before the promise
settled, that assignment landed on a dead closure and the listener was
never unregistered. React StrictMode mounts, cleans up and mounts again,
so the first listener leaked on every development mount. In ChatPanel
that meant applyRuntimeEvents ran twice per event and, because a delta
is appended to the existing content, every character of a streamed reply
was doubled.
Track whether the effect is still live and unregister immediately when
the promise settles late. Each site also gains a catch, since these were
all bare void listen(...).then(...) chains — a rejected listen, such as
the missing desktop-pet capability, became an unhandled rejection rather
than anything observable.
The listener mock in src/test/setup.ts resolved eagerly, which made the
race impossible to express. Replace it with a controllable double in
src/test/tauriEvent.ts that defers resolution until the test asks for
it, tracks each registration separately, and only dispatches to handlers
that have not been unregistered. The registry is plain module state, so
setup.ts resets it after each test.
ChatPanel had no test file; this adds one. Both new tests were checked
against a mutation restoring the old assignment, and both fail under it.
Refs: F-15 (audit P1-10).
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 00:23:42 +08:00
|
|
|
|
void listen("pet-hide-requested", () => setVisible(false))
|
|
|
|
|
|
.then((cleanup) => {
|
|
|
|
|
|
if (active) {
|
|
|
|
|
|
unlisten = cleanup;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
cleanup();
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
.catch(() => undefined);
|
|
|
|
|
|
return () => {
|
|
|
|
|
|
active = false;
|
|
|
|
|
|
unlisten?.();
|
|
|
|
|
|
unlisten = undefined;
|
|
|
|
|
|
};
|
2026-07-20 20:50:27 +08:00
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
|
|
return visible ? (
|
|
|
|
|
|
<div
|
|
|
|
|
|
className="app-pet-overlay"
|
|
|
|
|
|
style={{ left: position.x, top: position.y }}
|
|
|
|
|
|
onContextMenu={(event) => {
|
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
|
void invoke("show_pet_context_menu");
|
|
|
|
|
|
}}
|
|
|
|
|
|
onPointerDown={(event) => {
|
|
|
|
|
|
if (event.button !== 0) return;
|
|
|
|
|
|
event.currentTarget.setPointerCapture(event.pointerId);
|
|
|
|
|
|
dragRef.current = {
|
|
|
|
|
|
pointerId: event.pointerId,
|
|
|
|
|
|
offsetX: event.clientX - position.x,
|
|
|
|
|
|
offsetY: event.clientY - position.y,
|
|
|
|
|
|
};
|
|
|
|
|
|
}}
|
|
|
|
|
|
onPointerMove={(event) => {
|
|
|
|
|
|
if (dragRef.current?.pointerId !== event.pointerId) return;
|
|
|
|
|
|
savePosition(
|
|
|
|
|
|
event.clientX - dragRef.current.offsetX,
|
|
|
|
|
|
event.clientY - dragRef.current.offsetY,
|
|
|
|
|
|
);
|
|
|
|
|
|
}}
|
|
|
|
|
|
onPointerUp={(event) => {
|
2026-07-21 14:43:14 +08:00
|
|
|
|
if (dragRef.current?.pointerId === event.pointerId)
|
|
|
|
|
|
dragRef.current = null;
|
2026-07-20 20:50:27 +08:00
|
|
|
|
}}
|
|
|
|
|
|
onPointerCancel={() => {
|
|
|
|
|
|
dragRef.current = null;
|
|
|
|
|
|
}}
|
|
|
|
|
|
>
|
|
|
|
|
|
<DesktopPetView embedded />
|
|
|
|
|
|
</div>
|
|
|
|
|
|
) : null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-07-20 12:58:42 +08:00
|
|
|
|
function navIcon(page: PageKey) {
|
|
|
|
|
|
return {
|
|
|
|
|
|
chat: "⌁",
|
|
|
|
|
|
connections: "◎",
|
|
|
|
|
|
desktop: "◈",
|
|
|
|
|
|
pet: "✦",
|
|
|
|
|
|
diagnostics: "⚙",
|
|
|
|
|
|
}[page];
|
|
|
|
|
|
}
|
2026-07-18 20:34:47 +08:00
|
|
|
|
|
2026-07-22 00:27:06 +08:00
|
|
|
|
function PageLoading() {
|
|
|
|
|
|
return (
|
|
|
|
|
|
<p className="loading-state" role="status" aria-live="polite">
|
2026-07-26 22:31:44 +08:00
|
|
|
|
加载中…
|
2026-07-22 00:27:06 +08:00
|
|
|
|
</p>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-07-20 12:58:42 +08:00
|
|
|
|
function PageHeader({ page }: { page: PageKey }) {
|
|
|
|
|
|
const current = navigation.find((item) => item.key === page) ?? navigation[0];
|
|
|
|
|
|
return (
|
|
|
|
|
|
<header className="page-header">
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<p className="eyebrow">AstrBot Desktop</p>
|
|
|
|
|
|
<h1>{current.label}</h1>
|
|
|
|
|
|
<p className="subtitle">
|
|
|
|
|
|
{current.description},所有本机能力都经过客户端权限边界。
|
|
|
|
|
|
</p>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div className="header-status-pill">
|
|
|
|
|
|
<span className="connection-dot" />
|
|
|
|
|
|
双槽位架构
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</header>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-07-21 14:43:14 +08:00
|
|
|
|
function ChatPage() {
|
2026-07-20 12:58:42 +08:00
|
|
|
|
return (
|
2026-07-21 14:43:14 +08:00
|
|
|
|
<div className="chat-page">
|
|
|
|
|
|
<ChatPanel />
|
2026-07-20 12:58:42 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-07-20 20:50:27 +08:00
|
|
|
|
function PetPage({
|
|
|
|
|
|
displayMode,
|
|
|
|
|
|
onDisplayModeChange,
|
|
|
|
|
|
}: {
|
|
|
|
|
|
displayMode: PetDisplayMode;
|
|
|
|
|
|
onDisplayModeChange: (value: PetDisplayMode) => void;
|
|
|
|
|
|
}) {
|
2026-07-21 14:43:14 +08:00
|
|
|
|
const [monitors, setMonitors] = useState<
|
|
|
|
|
|
Array<{
|
|
|
|
|
|
name?: string;
|
|
|
|
|
|
width: number;
|
|
|
|
|
|
height: number;
|
|
|
|
|
|
scaleFactor: number;
|
|
|
|
|
|
isPrimary: boolean;
|
|
|
|
|
|
}>
|
|
|
|
|
|
>([]);
|
|
|
|
|
|
const [monitorIndex, setMonitorIndex] = useState(0);
|
fix(pet): read stored preferences and stop the pet from stealing focus
An audit of the destroy→hide change across four lenses raised 17
findings; 14 survived adversarial verification. Two of them were
regressions that change introduced, and both had the same shape: code
that only worked because the pet window used to not exist.
show_pet_context_menu picked the pet window and fell back to main.
While the pet rendered inside the app its window had been destroyed at
startup, so the fallback happened to select the visible main window.
Now that the window merely hides, the menu was being anchored to a
hidden HWND, which Win32 cannot bring to the foreground. The
visibility test is explicit now rather than incidental.
DesktopPetView read the connection state in a mount effect and nothing
emitted connection events, so destroy-and-rebuild was what re-read it.
Without a remount the floating pet showed whatever was true at startup
for the rest of the session. reveal_pet_window now emits
pet-window-revealed and the view re-reads on it.
The rest were already there. Every pet setting was decorative: the
preferences were applied and then dropped, so reveal_pet_window had to
invent an answer and hard-coded the first monitor, the safe edge and
always-on-top — reverting the user's choices on every show. The pet view
re-sent a fully hard-coded payload whenever game mode toggled, and the
settings page initialised its controls from literals, so returning to
the page and changing one thing pushed three stale defaults back onto
the window. There is a session-scoped store now, a command to read it,
and both frontends read before they write. Persisting it across restarts
is F-75.
Always-on-top is off by default, which is what the Q6 acceptance
criterion asked for (F-35), and the window no longer takes focus when
shown — it was activating on show and swallowing keystrokes meant for
the main window. focusable is left alone on purpose: clearing it adds
WS_EX_NOACTIVATE, which would re-break the context menu now anchored to
that window. That is F-79.
The pet also painted a solid dark rectangle before its assets arrived.
The transparency rule is gated on a class that an effect inside the
5.2 MB lazy chunk added, so until that chunk ran the app's opaque
background won. This is why the earlier hunt for "the rule that beats
!important" found nothing: the class was not applied yet, so specificity
was never the question. The pet now has its own entry document carrying
the class statically. An inline script would not do — tauri-utils only
nonces script[src^='http'], so it would pass in dev and be blocked by
script-src 'self' in a release build.
Rust tests 92 → 97, frontend 30 → 35. All 11 mutations of the new
assertions were confirmed to fail.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 05:25:27 +08:00
|
|
|
|
const [positionMode, setPositionMode] = useState<PetPositionMode>("edge");
|
|
|
|
|
|
const [alwaysOnTop, setAlwaysOnTop] = useState(false);
|
2026-07-21 14:43:14 +08:00
|
|
|
|
const [gameMode, setGameMode] = useState(false);
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
void invoke<unknown>("list_monitor_geometries")
|
|
|
|
|
|
.then((value) => setMonitors(value as typeof monitors))
|
|
|
|
|
|
.catch(() => setMonitors([]));
|
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
fix(pet): read stored preferences and stop the pet from stealing focus
An audit of the destroy→hide change across four lenses raised 17
findings; 14 survived adversarial verification. Two of them were
regressions that change introduced, and both had the same shape: code
that only worked because the pet window used to not exist.
show_pet_context_menu picked the pet window and fell back to main.
While the pet rendered inside the app its window had been destroyed at
startup, so the fallback happened to select the visible main window.
Now that the window merely hides, the menu was being anchored to a
hidden HWND, which Win32 cannot bring to the foreground. The
visibility test is explicit now rather than incidental.
DesktopPetView read the connection state in a mount effect and nothing
emitted connection events, so destroy-and-rebuild was what re-read it.
Without a remount the floating pet showed whatever was true at startup
for the rest of the session. reveal_pet_window now emits
pet-window-revealed and the view re-reads on it.
The rest were already there. Every pet setting was decorative: the
preferences were applied and then dropped, so reveal_pet_window had to
invent an answer and hard-coded the first monitor, the safe edge and
always-on-top — reverting the user's choices on every show. The pet view
re-sent a fully hard-coded payload whenever game mode toggled, and the
settings page initialised its controls from literals, so returning to
the page and changing one thing pushed three stale defaults back onto
the window. There is a session-scoped store now, a command to read it,
and both frontends read before they write. Persisting it across restarts
is F-75.
Always-on-top is off by default, which is what the Q6 acceptance
criterion asked for (F-35), and the window no longer takes focus when
shown — it was activating on show and swallowing keystrokes meant for
the main window. focusable is left alone on purpose: clearing it adds
WS_EX_NOACTIVATE, which would re-break the context menu now anchored to
that window. That is F-79.
The pet also painted a solid dark rectangle before its assets arrived.
The transparency rule is gated on a class that an effect inside the
5.2 MB lazy chunk added, so until that chunk ran the app's opaque
background won. This is why the earlier hunt for "the rule that beats
!important" found nothing: the class was not applied yet, so specificity
was never the question. The pet now has its own entry document carrying
the class statically. An inline script would not do — tauri-utils only
nonces script[src^='http'], so it would pass in dev and be blocked by
script-src 'self' in a release build.
Rust tests 92 → 97, frontend 30 → 35. All 11 mutations of the new
assertions were confirmed to fail.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 05:25:27 +08:00
|
|
|
|
// Adopt what the window is actually doing. These controls used to start from
|
|
|
|
|
|
// literals, so leaving the page and coming back showed monitor 1 / safe edge
|
|
|
|
|
|
// / always-on-top regardless of the truth — and because every edit re-sends
|
|
|
|
|
|
// the whole payload, the next single change pushed those wrong values back
|
|
|
|
|
|
// onto the window as if the user had chosen them.
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
let cancelled = false;
|
|
|
|
|
|
void invoke<unknown>("pet_window_preferences")
|
|
|
|
|
|
.then((value) => {
|
|
|
|
|
|
if (cancelled) return;
|
|
|
|
|
|
const preferences = petWindowPreferencesSchema.parse(value);
|
|
|
|
|
|
setMonitorIndex(preferences.monitorIndex ?? 0);
|
|
|
|
|
|
setPositionMode(preferences.positionMode);
|
|
|
|
|
|
setAlwaysOnTop(preferences.alwaysOnTop);
|
|
|
|
|
|
setGameMode(preferences.gameMode);
|
|
|
|
|
|
})
|
|
|
|
|
|
.catch(() => undefined);
|
|
|
|
|
|
return () => {
|
|
|
|
|
|
cancelled = true;
|
|
|
|
|
|
};
|
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
2026-07-21 14:43:14 +08:00
|
|
|
|
const applyPetPreferences = (
|
|
|
|
|
|
next: Partial<{
|
fix(pet): read stored preferences and stop the pet from stealing focus
An audit of the destroy→hide change across four lenses raised 17
findings; 14 survived adversarial verification. Two of them were
regressions that change introduced, and both had the same shape: code
that only worked because the pet window used to not exist.
show_pet_context_menu picked the pet window and fell back to main.
While the pet rendered inside the app its window had been destroyed at
startup, so the fallback happened to select the visible main window.
Now that the window merely hides, the menu was being anchored to a
hidden HWND, which Win32 cannot bring to the foreground. The
visibility test is explicit now rather than incidental.
DesktopPetView read the connection state in a mount effect and nothing
emitted connection events, so destroy-and-rebuild was what re-read it.
Without a remount the floating pet showed whatever was true at startup
for the rest of the session. reveal_pet_window now emits
pet-window-revealed and the view re-reads on it.
The rest were already there. Every pet setting was decorative: the
preferences were applied and then dropped, so reveal_pet_window had to
invent an answer and hard-coded the first monitor, the safe edge and
always-on-top — reverting the user's choices on every show. The pet view
re-sent a fully hard-coded payload whenever game mode toggled, and the
settings page initialised its controls from literals, so returning to
the page and changing one thing pushed three stale defaults back onto
the window. There is a session-scoped store now, a command to read it,
and both frontends read before they write. Persisting it across restarts
is F-75.
Always-on-top is off by default, which is what the Q6 acceptance
criterion asked for (F-35), and the window no longer takes focus when
shown — it was activating on show and swallowing keystrokes meant for
the main window. focusable is left alone on purpose: clearing it adds
WS_EX_NOACTIVATE, which would re-break the context menu now anchored to
that window. That is F-79.
The pet also painted a solid dark rectangle before its assets arrived.
The transparency rule is gated on a class that an effect inside the
5.2 MB lazy chunk added, so until that chunk ran the app's opaque
background won. This is why the earlier hunt for "the rule that beats
!important" found nothing: the class was not applied yet, so specificity
was never the question. The pet now has its own entry document carrying
the class statically. An inline script would not do — tauri-utils only
nonces script[src^='http'], so it would pass in dev and be blocked by
script-src 'self' in a release build.
Rust tests 92 → 97, frontend 30 → 35. All 11 mutations of the new
assertions were confirmed to fail.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 05:25:27 +08:00
|
|
|
|
positionMode: PetPositionMode;
|
2026-07-21 14:43:14 +08:00
|
|
|
|
monitorIndex: number;
|
|
|
|
|
|
alwaysOnTop: boolean;
|
|
|
|
|
|
gameMode: boolean;
|
|
|
|
|
|
}> = {},
|
|
|
|
|
|
) => {
|
|
|
|
|
|
const preferences = {
|
|
|
|
|
|
positionMode: next.positionMode ?? positionMode,
|
|
|
|
|
|
monitorIndex: next.monitorIndex ?? monitorIndex,
|
|
|
|
|
|
alwaysOnTop: next.alwaysOnTop ?? alwaysOnTop,
|
|
|
|
|
|
gameMode: next.gameMode ?? gameMode,
|
|
|
|
|
|
};
|
|
|
|
|
|
void invoke("set_pet_window_preferences", { preferences }).catch(
|
|
|
|
|
|
() => undefined,
|
|
|
|
|
|
);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2026-07-20 12:58:42 +08:00
|
|
|
|
return (
|
|
|
|
|
|
<div className="page-stack">
|
2026-07-20 12:36:20 +08:00
|
|
|
|
<PetPackImporter />
|
2026-07-20 20:50:27 +08:00
|
|
|
|
{displayMode === "app-ui" ? (
|
|
|
|
|
|
<section className="pet-inline-preview" aria-label="应用内桌宠预览">
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<span className="section-kicker">App UI</span>
|
|
|
|
|
|
<h2>应用内活动桌宠</h2>
|
|
|
|
|
|
<p>桌宠已叠加在主界面上,可直接拖动;关闭后可重新打开应用。</p>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</section>
|
|
|
|
|
|
) : null}
|
2026-07-20 12:58:42 +08:00
|
|
|
|
<section className="settings-grid">
|
|
|
|
|
|
<SettingCard
|
|
|
|
|
|
title="显示范围"
|
2026-07-20 20:50:27 +08:00
|
|
|
|
description="应用内活动桌宠不创建桌面浮窗,避免透明窗口白框。"
|
2026-07-20 12:58:42 +08:00
|
|
|
|
>
|
2026-07-20 20:50:27 +08:00
|
|
|
|
<select
|
|
|
|
|
|
value={displayMode}
|
2026-07-21 14:43:14 +08:00
|
|
|
|
onChange={(event) =>
|
|
|
|
|
|
onDisplayModeChange(event.target.value as PetDisplayMode)
|
|
|
|
|
|
}
|
2026-07-20 20:50:27 +08:00
|
|
|
|
>
|
|
|
|
|
|
<option value="app-ui">仅应用 UI 内</option>
|
2026-07-26 22:31:44 +08:00
|
|
|
|
<option value="desktop-floating">桌面浮动</option>
|
2026-07-20 12:58:42 +08:00
|
|
|
|
</select>
|
|
|
|
|
|
</SettingCard>
|
|
|
|
|
|
<SettingCard
|
|
|
|
|
|
title="活动策略"
|
2026-07-20 20:50:27 +08:00
|
|
|
|
description="为后续游戏模式和多显示器行为预留配置入口。"
|
2026-07-20 12:58:42 +08:00
|
|
|
|
>
|
|
|
|
|
|
<select defaultValue="smart">
|
|
|
|
|
|
<option value="smart">智能选择显示器</option>
|
|
|
|
|
|
<option value="primary">固定主屏</option>
|
|
|
|
|
|
<option value="secondary">优先副屏</option>
|
|
|
|
|
|
</select>
|
|
|
|
|
|
</SettingCard>
|
2026-07-20 16:28:42 +08:00
|
|
|
|
<SettingCard
|
|
|
|
|
|
title="运行桌宠"
|
2026-07-20 20:50:27 +08:00
|
|
|
|
description="应用内桌宠可在主界面中自由移动,不再创建白色桌面浮窗。"
|
2026-07-20 16:28:42 +08:00
|
|
|
|
>
|
2026-07-20 20:50:27 +08:00
|
|
|
|
{displayMode === "desktop-floating" ? (
|
|
|
|
|
|
<button type="button" onClick={() => onDisplayModeChange("app-ui")}>
|
|
|
|
|
|
改用应用内活动桌宠
|
|
|
|
|
|
</button>
|
|
|
|
|
|
) : (
|
|
|
|
|
|
<span className="form-note">应用内活动桌宠已显示,可直接拖动</span>
|
|
|
|
|
|
)}
|
2026-07-20 16:28:42 +08:00
|
|
|
|
</SettingCard>
|
2026-07-21 14:43:14 +08:00
|
|
|
|
<SettingCard
|
|
|
|
|
|
title="显示器与位置"
|
|
|
|
|
|
description="桌面版只会把桌宠放在屏幕安全边缘,不会覆盖游戏中心区域。"
|
|
|
|
|
|
>
|
|
|
|
|
|
<select
|
|
|
|
|
|
value={monitorIndex}
|
|
|
|
|
|
onChange={(event) => {
|
|
|
|
|
|
const next = Number(event.target.value);
|
|
|
|
|
|
setMonitorIndex(next);
|
|
|
|
|
|
applyPetPreferences({ monitorIndex: next });
|
|
|
|
|
|
}}
|
|
|
|
|
|
disabled={monitors.length === 0}
|
|
|
|
|
|
>
|
|
|
|
|
|
{monitors.map((monitor, index) => (
|
|
|
|
|
|
<option
|
|
|
|
|
|
value={index}
|
|
|
|
|
|
key={`${monitor.name ?? "monitor"}-${index}`}
|
|
|
|
|
|
>
|
|
|
|
|
|
{monitor.name ?? `显示器 ${index + 1}`}{" "}
|
|
|
|
|
|
{monitor.isPrimary ? "(主屏)" : ""}
|
|
|
|
|
|
</option>
|
|
|
|
|
|
))}
|
|
|
|
|
|
</select>
|
|
|
|
|
|
<select
|
|
|
|
|
|
value={positionMode}
|
|
|
|
|
|
onChange={(event) => {
|
fix(pet): read stored preferences and stop the pet from stealing focus
An audit of the destroy→hide change across four lenses raised 17
findings; 14 survived adversarial verification. Two of them were
regressions that change introduced, and both had the same shape: code
that only worked because the pet window used to not exist.
show_pet_context_menu picked the pet window and fell back to main.
While the pet rendered inside the app its window had been destroyed at
startup, so the fallback happened to select the visible main window.
Now that the window merely hides, the menu was being anchored to a
hidden HWND, which Win32 cannot bring to the foreground. The
visibility test is explicit now rather than incidental.
DesktopPetView read the connection state in a mount effect and nothing
emitted connection events, so destroy-and-rebuild was what re-read it.
Without a remount the floating pet showed whatever was true at startup
for the rest of the session. reveal_pet_window now emits
pet-window-revealed and the view re-reads on it.
The rest were already there. Every pet setting was decorative: the
preferences were applied and then dropped, so reveal_pet_window had to
invent an answer and hard-coded the first monitor, the safe edge and
always-on-top — reverting the user's choices on every show. The pet view
re-sent a fully hard-coded payload whenever game mode toggled, and the
settings page initialised its controls from literals, so returning to
the page and changing one thing pushed three stale defaults back onto
the window. There is a session-scoped store now, a command to read it,
and both frontends read before they write. Persisting it across restarts
is F-75.
Always-on-top is off by default, which is what the Q6 acceptance
criterion asked for (F-35), and the window no longer takes focus when
shown — it was activating on show and swallowing keystrokes meant for
the main window. focusable is left alone on purpose: clearing it adds
WS_EX_NOACTIVATE, which would re-break the context menu now anchored to
that window. That is F-79.
The pet also painted a solid dark rectangle before its assets arrived.
The transparency rule is gated on a class that an effect inside the
5.2 MB lazy chunk added, so until that chunk ran the app's opaque
background won. This is why the earlier hunt for "the rule that beats
!important" found nothing: the class was not applied yet, so specificity
was never the question. The pet now has its own entry document carrying
the class statically. An inline script would not do — tauri-utils only
nonces script[src^='http'], so it would pass in dev and be blocked by
script-src 'self' in a release build.
Rust tests 92 → 97, frontend 30 → 35. All 11 mutations of the new
assertions were confirmed to fail.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 05:25:27 +08:00
|
|
|
|
const next = petPositionModeSchema.parse(event.target.value);
|
2026-07-21 14:43:14 +08:00
|
|
|
|
setPositionMode(next);
|
|
|
|
|
|
applyPetPreferences({ positionMode: next });
|
|
|
|
|
|
}}
|
|
|
|
|
|
>
|
|
|
|
|
|
<option value="free">自由位置</option>
|
|
|
|
|
|
<option value="edge">安全边缘</option>
|
|
|
|
|
|
<option value="monitor">指定显示器</option>
|
|
|
|
|
|
</select>
|
|
|
|
|
|
</SettingCard>
|
|
|
|
|
|
<SettingCard
|
|
|
|
|
|
title="桌面行为"
|
|
|
|
|
|
description="置顶和游戏模式都可以随时关闭;权限或显示器不可用时自动回退。"
|
|
|
|
|
|
>
|
|
|
|
|
|
<label className="toggle-row">
|
|
|
|
|
|
<input
|
|
|
|
|
|
type="checkbox"
|
|
|
|
|
|
checked={alwaysOnTop}
|
|
|
|
|
|
onChange={(event) => {
|
|
|
|
|
|
const next = event.target.checked;
|
|
|
|
|
|
setAlwaysOnTop(next);
|
|
|
|
|
|
applyPetPreferences({ alwaysOnTop: next });
|
|
|
|
|
|
}}
|
|
|
|
|
|
/>
|
|
|
|
|
|
始终置顶
|
|
|
|
|
|
</label>
|
|
|
|
|
|
<label className="toggle-row">
|
|
|
|
|
|
<input
|
|
|
|
|
|
type="checkbox"
|
|
|
|
|
|
checked={gameMode}
|
|
|
|
|
|
onChange={(event) => {
|
|
|
|
|
|
const next = event.target.checked;
|
|
|
|
|
|
setGameMode(next);
|
|
|
|
|
|
applyPetPreferences({ gameMode: next });
|
|
|
|
|
|
}}
|
|
|
|
|
|
/>
|
|
|
|
|
|
游戏模式(安全边缘)
|
|
|
|
|
|
</label>
|
|
|
|
|
|
</SettingCard>
|
2026-07-20 12:58:42 +08:00
|
|
|
|
</section>
|
|
|
|
|
|
</div>
|
2026-07-20 16:28:42 +08:00
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-07-20 12:58:42 +08:00
|
|
|
|
function SettingCard({
|
|
|
|
|
|
title,
|
|
|
|
|
|
description,
|
|
|
|
|
|
children,
|
|
|
|
|
|
}: {
|
|
|
|
|
|
title: string;
|
|
|
|
|
|
description: string;
|
|
|
|
|
|
children: React.ReactNode;
|
|
|
|
|
|
}) {
|
|
|
|
|
|
return (
|
|
|
|
|
|
<section className="setting-card">
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<span className="section-kicker">Settings</span>
|
|
|
|
|
|
<h2>{title}</h2>
|
|
|
|
|
|
<p>{description}</p>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div className="setting-card-controls">{children}</div>
|
|
|
|
|
|
</section>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|