π OpenHands: AI-Driven Development
fix: cap conversation Skills/Hooks/Tools dialogs at 90vw (#17586)
GokayAIe0698082a6bd
diff --git a/__tests__/components/features/conversation-panel/conversation-lg-modals-viewport.test.tsx b/__tests__/components/features/conversation-panel/conversation-lg-modals-viewport.test.tsxnew file mode 100644index 0000000000..f2a251012a--- /dev/null+++ b/__tests__/components/features/conversation-panel/conversation-lg-modals-viewport.test.tsx@@ -0,0 +1,123 @@+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";+import { screen } from "@testing-library/react";+import userEvent from "@testing-library/user-event";+import { renderWithProviders } from "test-utils";+import SkillsService from "#/api/skills-service";+import AgentServerConversationService from "#/api/conversation-service/agent-server-conversation-service.api";+import { HooksModal } from "#/components/features/conversation-panel/hooks-modal";+import { SkillsModal } from "#/components/features/conversation-panel/skills-modal";+import { SystemMessageModal } from "#/components/features/conversation-panel/system-message-modal";+import {+ MODAL_MAX_WIDTH_VIEWPORT,+ MODAL_WIDTH_CLASS,+} from "#/components/shared/modals/modal-body";+import { adaptSystemMessage } from "#/utils/system-message-adapter";+import { EventState } from "#/stores/use-event-store";++const LONG_SYSTEM_PROMPT = "v1 prompt\n".repeat(80);++const systemPromptEvents: EventState["events"] = [+ {+ id: "v1-id",+ timestamp: "2025-12-30T12:00:00Z",+ source: "agent",+ system_prompt: {+ type: "text",+ text: LONG_SYSTEM_PROMPT,+ },+ tools: [+ {+ type: "function",+ function: {+ name: "bash",+ description: "Execute bash",+ parameters: {},+ },+ },+ ],+ },+];++const systemMessage = adaptSystemMessage(systemPromptEvents);++const DIALOGS = [+ {+ name: "SkillsModal",+ testId: "skills-modal",+ closeTestId: "close-skills-modal",+ renderDialog: (onClose: () => void) => <SkillsModal onClose={onClose} />,+ },+ {+ name: "HooksModal",+ testId: "hooks-modal",+ closeTestId: "close-hooks-modal",+ renderDialog: (onClose: () => void) => <HooksModal onClose={onClose} />,+ },+ {+ name: "SystemMessageModal",+ testId: "system-message-modal",+ closeTestId: "close-system-message-modal",+ renderDialog: (onClose: () => void) => (+ <SystemMessageModal+ isOpen+ onClose={onClose}+ systemMessage={systemMessage}+ />+ ),+ },+] as const;++describe("conversation lg dialogs viewport fit", () => {+ beforeEach(() => {+ vi.spyOn(SkillsService, "getSkills").mockResolvedValue([]);+ vi.spyOn(AgentServerConversationService, "getHooks").mockResolvedValue({+ hooks: [],+ });+ });++ afterEach(() => {+ vi.restoreAllMocks();+ });++ it("keeps the shared lg token at 640px so a 720px viewport still uses the desktop width", () => {+ // w-160 is 40rem/640px; 90vw at 720px is 648px, so min(640px, 90vw) remains 640px.+ expect(MODAL_WIDTH_CLASS.lg).toBe("w-160");+ expect(MODAL_MAX_WIDTH_VIEWPORT).toBe("max-w-[90vw]");+ });++ it.each(DIALOGS)(+ "$name caps the 640px body at 90vw so 320px and 390px viewports cannot overflow",+ async ({ testId, renderDialog }) => {+ renderWithProviders(renderDialog(vi.fn()));++ const body = await screen.findByTestId(testId);+ expect(body).toHaveClass(MODAL_WIDTH_CLASS.lg);+ expect(body).toHaveClass(MODAL_MAX_WIDTH_VIEWPORT);++ const scrollRegion = body.querySelector(".overflow-auto");+ expect(scrollRegion).toHaveClass("h-[60vh]");+ },+ );++ it.each(DIALOGS)(+ "$name close control is visible, focusable, clickable, and Escape dismisses",+ async ({ closeTestId, renderDialog }) => {+ const user = userEvent.setup();+ const onClose = vi.fn();+ renderWithProviders(renderDialog(onClose));++ const closeButton = await screen.findByTestId(closeTestId);+ expect(closeButton).toBeVisible();+ expect(closeButton).toBeEnabled();+ closeButton.focus();+ expect(closeButton).toHaveFocus();++ await user.click(closeButton);+ expect(onClose).toHaveBeenCalledTimes(1);++ onClose.mockClear();+ await user.keyboard("{Escape}");+ expect(onClose).toHaveBeenCalledTimes(1);+ },+ );+});diff --git a/src/components/features/conversation-panel/hooks-modal.tsx b/src/components/features/conversation-panel/hooks-modal.tsxindex 1566b27362..0f67d889e5 100644--- a/src/components/features/conversation-panel/hooks-modal.tsx+++ b/src/components/features/conversation-panel/hooks-modal.tsx@@ -1,6 +1,9 @@import { useState } from "react";import { ModalBackdrop } from "#/components/shared/modals/modal-backdrop";-import { ModalBody } from "#/components/shared/modals/modal-body";+import {+ MODAL_MAX_WIDTH_VIEWPORT,+ ModalBody,+} from "#/components/shared/modals/modal-body";import { useConversationHooks } from "#/hooks/query/use-conversation-hooks";import { AgentState } from "#/types/agent-state";import { HooksModalHeader } from "./hooks-modal-header";@@ -9,6 +12,7 @@ import { HooksEmptyState } from "./hooks-empty-state";import { HookEventItem } from "./hook-event-item";import { RuntimeWaitingState } from "./runtime-waiting-state";import { useAgentState } from "#/hooks/use-agent-state";+import { cn } from "#/utils/utils";interface HooksModalProps {onClose: () => void;@@ -42,7 +46,10 @@ export function HooksModal({ onClose }: HooksModalProps) {<ModalBackdrop onClose={onClose}><ModalBodywidth="lg"- className="relative max-h-[80vh] flex flex-col items-start border border-border"+ className={cn(+ "relative max-h-[80vh] flex flex-col items-start border border-border",+ MODAL_MAX_WIDTH_VIEWPORT,+ )}testID="hooks-modal"><HooksModalHeaderdiff --git a/src/components/features/conversation-panel/plugins-modal.tsx b/src/components/features/conversation-panel/plugins-modal.tsxindex ddace22fbe..7fafdedcd5 100644--- a/src/components/features/conversation-panel/plugins-modal.tsx+++ b/src/components/features/conversation-panel/plugins-modal.tsx@@ -1,6 +1,9 @@import { useTranslation } from "react-i18next";import { ModalBackdrop } from "#/components/shared/modals/modal-backdrop";-import { ModalBody } from "#/components/shared/modals/modal-body";+import {+ MODAL_MAX_WIDTH_VIEWPORT,+ ModalBody,+} from "#/components/shared/modals/modal-body";import { ModalCloseButton } from "#/components/shared/modals/modal-close-button";import { BaseModalTitle } from "#/components/shared/modals/confirmation-modals/base-modal";import { I18nKey } from "#/i18n/declaration";@@ -12,6 +15,7 @@ import {isLocalPluginSource,pluginReferenceKey,} from "#/utils/plugin-display";+import { cn } from "#/utils/utils";interface PluginsModalProps {onClose: () => void;@@ -32,7 +36,10 @@ export function PluginsModal({ onClose }: PluginsModalProps) {<ModalBackdrop onClose={onClose}><ModalBodywidth="lg"- className="relative flex max-h-[80vh] flex-col items-start border border-border"+ className={cn(+ "relative flex max-h-[80vh] flex-col items-start border border-border",+ MODAL_MAX_WIDTH_VIEWPORT,+ )}testID="plugins-modal"><ModalCloseButton onClose={onClose} testId="close-plugins-modal" />diff --git a/src/components/features/conversation-panel/skills-modal.tsx b/src/components/features/conversation-panel/skills-modal.tsxindex 07f9d66605..f3c0506fa2 100644--- a/src/components/features/conversation-panel/skills-modal.tsx+++ b/src/components/features/conversation-panel/skills-modal.tsx@@ -1,7 +1,10 @@import { useMemo, useState } from "react";import { useTranslation } from "react-i18next";import { ModalBackdrop } from "#/components/shared/modals/modal-backdrop";-import { ModalBody } from "#/components/shared/modals/modal-body";+import {+ MODAL_MAX_WIDTH_VIEWPORT,+ ModalBody,+} from "#/components/shared/modals/modal-body";import { I18nKey } from "#/i18n/declaration";import { getAgentServerWorkingDir } from "#/api/agent-server-config";import { useConversationSkills } from "#/hooks/query/use-conversation-skills";@@ -11,6 +14,7 @@ import {SKILL_SCOPE_ORDER,type SkillScope,} from "#/utils/skill-scope";+import { cn } from "#/utils/utils";import { SkillsModalHeader } from "./skills-modal-header";import { SkillsModalSection } from "./skills-modal-section";import { SkillsLoadingState } from "./skills-loading-state";@@ -67,7 +71,10 @@ export function SkillsModal({ onClose }: SkillsModalProps) {<ModalBackdrop onClose={onClose}><ModalBodywidth="lg"- className="relative max-h-[80vh] flex flex-col items-start border border-border"+ className={cn(+ "relative max-h-[80vh] flex flex-col items-start border border-border",+ MODAL_MAX_WIDTH_VIEWPORT,+ )}testID="skills-modal"><SkillsModalHeaderdiff --git a/src/components/features/conversation-panel/system-message-modal.tsx b/src/components/features/conversation-panel/system-message-modal.tsxindex 5ba500ba3f..a972e82352 100644--- a/src/components/features/conversation-panel/system-message-modal.tsx+++ b/src/components/features/conversation-panel/system-message-modal.tsx@@ -1,10 +1,14 @@import { useState } from "react";import { ModalBackdrop } from "#/components/shared/modals/modal-backdrop";-import { ModalBody } from "#/components/shared/modals/modal-body";+import {+ MODAL_MAX_WIDTH_VIEWPORT,+ ModalBody,+} from "#/components/shared/modals/modal-body";import { SystemMessageHeader } from "./system-message-modal/system-message-header";import { TabNavigation } from "./system-message-modal/tab-navigation";import { TabContent } from "./system-message-modal/tab-content";import { SystemMessageForModal } from "#/utils/system-message-adapter";+import { cn } from "#/utils/utils";interface SystemMessageModalProps {isOpen: boolean;@@ -38,7 +42,10 @@ export function SystemMessageModal({<ModalBackdrop onClose={onClose}><ModalBodywidth="lg"- className="relative max-h-[80vh] flex flex-col items-start border border-border"+ className={cn(+ "relative max-h-[80vh] flex flex-col items-start border border-border",+ MODAL_MAX_WIDTH_VIEWPORT,+ )}testID="system-message-modal"><SystemMessageHeader