Skip to content

Your lightweight open-source personal agent.

fix(webui): refine mobile actions and avoid duplicate settings loads

chengyongruc370e2a5a525
diff --git a/webui/src/App.tsx b/webui/src/App.tsx
index 4a0d69224..c7fe0ff52 100644
--- a/webui/src/App.tsx
+++ b/webui/src/App.tsx
@@ -1175,6 +1175,7 @@ function Shell({
const skills = useSkills(getToken);
const pageVisible = usePageVisibility();
const [settingsSnapshot, setSettingsSnapshot] = useState<SettingsPayload | null>(null);
+ const [settingsLoading, setSettingsLoading] = useState(true);
const settingsRefreshGenerationRef = useRef(0);
const [pendingAutomationMessage, setPendingAutomationMessage] = useState<{
id: string;
@@ -1298,6 +1299,7 @@ function Shell({
useEffect(() => {
let cancelled = false;
const requestGeneration = settingsRefreshGenerationRef.current;
+ setSettingsLoading(true);
fetchSettings(getToken())
.then((payload) => {
if (!cancelled && requestGeneration === settingsRefreshGenerationRef.current) {
@@ -1308,6 +1310,9 @@ function Shell({
if (!cancelled && requestGeneration === settingsRefreshGenerationRef.current) {
setSettingsSnapshot(null);
}
+ })
+ .finally(() => {
+ if (!cancelled) setSettingsLoading(false);
});
return () => {
cancelled = true;
@@ -2906,6 +2911,7 @@ function Shell({
workspaceError={workspaceError}
onWorkspaceScopeChange={applyWorkspaceScope}
settingsSnapshot={settingsSnapshot}
+ settingsLoading={settingsLoading}
onOpenModelSettings={onOpenModelSettings}
skills={skills}
/>
@@ -2968,6 +2974,7 @@ function Shell({
client.setWorkspaceScope(paneSession.chatId, next);
}}
settingsSnapshot={settingsSnapshot}
+ settingsLoading={settingsLoading}
onOpenModelSettings={onOpenModelSettings}
skills={skills}
/>
diff --git a/webui/src/components/MessageBubble.tsx b/webui/src/components/MessageBubble.tsx
index b47c2dbcf..28b5cef74 100644
--- a/webui/src/components/MessageBubble.tsx
+++ b/webui/src/components/MessageBubble.tsx
@@ -249,7 +249,7 @@ export function MessageBlockMenuActions({
"text-start text-[11px] leading-4",
"text-muted-foreground transition-colors hover:text-foreground",
"focus-visible:outline-none",
- sheet && "w-full rounded-control text-sm hover:bg-muted/70",
+ sheet && "w-full gap-2 rounded-control px-2 text-sm hover:bg-muted/70",
)}
>
<span
@@ -260,6 +260,7 @@ export function MessageBlockMenuActions({
"group-hover:bg-muted/70 group-active:scale-[0.96]",
"group-focus-visible:ring-2 group-focus-visible:ring-ring",
"motion-reduce:transform-none",
+ sheet && "w-3.5",
)}
>
<Activity className="h-3.5 w-3.5" strokeWidth={1.5} aria-hidden />
@@ -281,7 +282,7 @@ export function MessageBlockMenuActions({
{timestampLabel || automationSourceLabel ? (
<div
data-message-block-metadata
- className={cn("mt-0.5 w-full border-t border-border/45 px-1.5 pt-1 leading-4", sheet ? "text-xs text-muted-foreground" : "text-[10px] text-muted-foreground/45")}
+ className={cn("mt-0.5 w-full border-t border-border/45 px-1.5 pt-1 leading-4", sheet ? "px-2 text-xs text-muted-foreground" : "text-[10px] text-muted-foreground/45")}
>
{timestampLabel ? (
<time
diff --git a/webui/src/components/thread/ThreadMessages.tsx b/webui/src/components/thread/ThreadMessages.tsx
index e5af2d508..b71856d57 100644
--- a/webui/src/components/thread/ThreadMessages.tsx
+++ b/webui/src/components/thread/ThreadMessages.tsx
@@ -432,12 +432,12 @@ function MessageBlockMenu({
onViewLinks={links.length > 0 ? () => setLinksShown(true) : undefined}
/>;
if (mobileActions) {
- return <div data-message-mobile-actions className={cn("mt-1 flex items-center gap-0.5", message.role === "user" && "justify-end")}>
- <MessageCopyButton message={message} className="h-11 w-11" />
+ return <div data-message-mobile-actions className={cn("mt-1 flex items-center", message.role === "user" ? "me-2 justify-end" : "-ms-2")}>
+ <MessageCopyButton message={message} className="h-11 w-8 [&_svg]:h-4 [&_svg]:w-4" />
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogTrigger asChild>
<button ref={triggerRef} type="button" data-message-block-menu-trigger aria-label={label}
- className="inline-flex h-11 w-11 items-center justify-center rounded-control text-muted-foreground transition-colors hover:bg-muted/70 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">
+ className="inline-flex h-11 w-8 items-center justify-center rounded-control text-muted-foreground transition-colors hover:bg-muted/70 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">
<MoreHorizontal className="h-4 w-4" strokeWidth={1.75} aria-hidden />
</button>
</DialogTrigger>
diff --git a/webui/src/components/thread/ThreadShell.tsx b/webui/src/components/thread/ThreadShell.tsx
index 36c3e5548..91b9c552f 100644
--- a/webui/src/components/thread/ThreadShell.tsx
+++ b/webui/src/components/thread/ThreadShell.tsx
@@ -447,6 +447,7 @@ interface ThreadShellProps {
workspaceError?: string | null;
onWorkspaceScopeChange?: (scope: WorkspaceScopePayload) => void;
settingsSnapshot?: SettingsPayload | null;
+ settingsLoading?: boolean;
onOpenModelSettings?: () => void;
skills?: SkillSummary[];
}
@@ -657,6 +658,7 @@ export function ThreadShell({
workspaceError = null,
onWorkspaceScopeChange,
settingsSnapshot = null,
+ settingsLoading = false,
onOpenModelSettings,
skills = [],
}: ThreadShellProps) {
@@ -1094,8 +1096,8 @@ export function ThreadShell({
setSettings(settingsSnapshot);
return;
}
- void refreshModelSettings();
- }, [refreshModelSettings, settingsSnapshot]);
+ if (!settingsLoading) void refreshModelSettings();
+ }, [refreshModelSettings, settingsLoading, settingsSnapshot]);
useEffect(() => {
return client.onRuntimeModelUpdate(() => {
diff --git a/webui/src/components/thread/WorkspaceControls.tsx b/webui/src/components/thread/WorkspaceControls.tsx
index a98ee6e53..7c666bfbc 100644
--- a/webui/src/components/thread/WorkspaceControls.tsx
+++ b/webui/src/components/thread/WorkspaceControls.tsx
@@ -312,6 +312,7 @@ export function WorkspaceAccessMenu({
onChange?: (scope: WorkspaceScopePayload) => void;
}) {
const { t } = useTranslation();
+ const dismissedByPointerRef = useRef(false);
const mode = scope.access_mode;
const isFull = mode === "full";
const accessLabel = t(
@@ -358,7 +359,15 @@ export function WorkspaceAccessMenu({
<ChevronDown className={cn("thread-composer-access-chevron ml-1.5 shrink-0", isHero ? "h-3 w-3" : "h-3 w-3")} />
</Button>
</DropdownMenuTrigger>
- <DropdownMenuContent align="start" className="w-56">
+ <DropdownMenuContent
+ align="start"
+ className="w-56"
+ onPointerDownOutside={() => { dismissedByPointerRef.current = true; }}
+ onCloseAutoFocus={(event) => {
+ if (dismissedByPointerRef.current) event.preventDefault();
+ dismissedByPointerRef.current = false;
+ }}
+ >
<AccessMenuItem
icon={<Hand className="h-4 w-4" />}
label={t("thread.composer.workspace.default")}
diff --git a/webui/src/tests/thread-shell.test.tsx b/webui/src/tests/thread-shell.test.tsx
index 157d52259..2a141b552 100644
--- a/webui/src/tests/thread-shell.test.tsx
+++ b/webui/src/tests/thread-shell.test.tsx
@@ -935,6 +935,29 @@ describe("ThreadShell", () => {
expect(onGoHome).not.toHaveBeenCalled();
});
+ it.each([true, false])("waits for parent settings and retries only on failure (success: %s)", async (success) => {
+ const client = makeClient();
+ const settings = modelSettings("deepseek-v4-pro", "deepseek");
+ const settingsRequest = vi.fn(() => Promise.resolve(httpJson(settings)));
+ vi.stubGlobal("fetch", vi.fn((input: RequestInfo | URL) => (
+ String(input).endsWith("/api/settings")
+ ? settingsRequest()
+ : Promise.resolve(httpJson({}))
+ )));
+ const view = (loading: boolean, snapshot: SettingsPayload | null) => wrap(
+ client,
+ <ThreadShell session={null} title="New topic" onToggleSidebar={() => {}}
+ settingsLoading={loading} settingsSnapshot={snapshot} />,
+ );
+ const { rerender } = render(view(true, null));
+ await act(async () => {});
+ expect(settingsRequest).not.toHaveBeenCalled();
+
+ rerender(view(false, success ? settings : null));
+ expect(await screen.findByTestId("composer-model-logo-deepseek")).toBeInTheDocument();
+ expect(settingsRequest).toHaveBeenCalledTimes(success ? 0 : 1);
+ });
+
it("updates the composer model logo when settings snapshot changes", async () => {
const client = makeClient();
const { rerender } = render(