Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

refactor(web): name width flags after breakpoints and presentations (#45602)

yyh04e679c9e76c
diff --git a/oxlint-suppressions.json b/oxlint-suppressions.json
index b8f58764fe4..44c2ccb6638 100644
--- a/oxlint-suppressions.json
+++ b/oxlint-suppressions.json
@@ -489,11 +489,6 @@
"count": 4
}
},
- "web/app/components/app/configuration/configuration-view/index.tsx": {
- "better-tailwindcss/enforce-logical-properties": {
- "count": 4
- }
- },
"web/app/components/app/configuration/dataset-config/context-var/index.tsx": {
"better-tailwindcss/enforce-logical-properties": {
"count": 3
@@ -995,11 +990,6 @@
"count": 3
}
},
- "web/app/components/base/chat/chat-with-history/sidebar/index.tsx": {
- "better-tailwindcss/enforce-logical-properties": {
- "count": 1
- }
- },
"web/app/components/base/chat/chat-with-history/sidebar/item.tsx": {
"better-tailwindcss/enforce-logical-properties": {
"count": 3
@@ -1446,11 +1436,6 @@
"count": 1
}
},
- "web/app/components/base/linked-apps-panel/index.tsx": {
- "better-tailwindcss/enforce-logical-properties": {
- "count": 1
- }
- },
"web/app/components/base/list-empty/index.tsx": {
"better-tailwindcss/enforce-logical-properties": {
"count": 4
@@ -2141,11 +2126,6 @@
"count": 1
}
},
- "web/app/components/datasets/create/step-two/components/preview-panel.tsx": {
- "better-tailwindcss/enforce-logical-properties": {
- "count": 1
- }
- },
"web/app/components/datasets/create/step-two/components/step-two-footer.tsx": {
"better-tailwindcss/enforce-logical-properties": {
"count": 2
@@ -3713,9 +3693,6 @@
}
},
"web/app/components/share/text-generation/text-generation-result-panel.tsx": {
- "better-tailwindcss/enforce-logical-properties": {
- "count": 1
- },
"jsx-a11y/click-events-have-key-events": {
"count": 1
},
@@ -3723,11 +3700,6 @@
"count": 1
}
},
- "web/app/components/share/text-generation/text-generation-sidebar.tsx": {
- "better-tailwindcss/enforce-logical-properties": {
- "count": 6
- }
- },
"web/app/components/signin/countdown.tsx": {
"better-tailwindcss/enforce-logical-properties": {
"count": 1
diff --git a/web/app/components/app-sidebar/dataset-detail-sidebar.tsx b/web/app/components/app-sidebar/dataset-detail-sidebar.tsx
index a791b5f0ee0..c2bf43f6d5e 100644
--- a/web/app/components/app-sidebar/dataset-detail-sidebar.tsx
+++ b/web/app/components/app-sidebar/dataset-detail-sidebar.tsx
@@ -7,12 +7,12 @@ import DatasetDetailSection from './dataset-detail-section'
import { DatasetDetailTop } from './dataset-detail-top'
export function DatasetDetailSidebar() {
- const isMobile = useMediaQuery('(width < 40rem)', {})
+ const isBelowSm = useMediaQuery('(width < 40rem)', {})
const pathname = usePathname()
return (
<DetailSidebarFrame
- compact={isMobile && pathname.endsWith('/settings')}
+ compact={isBelowSm && pathname.endsWith('/settings')}
renderTop={({ expand, onToggle }) => <DatasetDetailTop expand={expand} onToggle={onToggle} />}
renderSection={({ expand }) => <DatasetDetailSection expand={expand} />}
/>
diff --git a/web/app/components/app/configuration/configuration-view/index.tsx b/web/app/components/app/configuration/configuration-view/index.tsx
index 127369815f5..ea91af984aa 100644
--- a/web/app/components/app/configuration/configuration-view/index.tsx
+++ b/web/app/components/app/configuration/configuration-view/index.tsx
@@ -51,7 +51,7 @@ const ConfigurationView: FC<ConfigurationViewModel> = ({
featuresData,
isAgent,
isAdvancedMode,
- isMobile,
+ isBelowSm,
isShowDebugPanel,
isShowHistoryModal,
isShowSelectDataSet,
@@ -116,7 +116,7 @@ const ConfigurationView: FC<ConfigurationViewModel> = ({
<>
<div className="flex h-full flex-col">
<div className="relative flex h-50 grow pt-14">
- <div className="absolute top-0 left-0 h-14 w-full">
+ <div className="absolute inset-s-0 top-0 h-14 w-full">
<div className="flex h-14 items-center justify-between px-6">
<div className="flex items-center gap-2">
<h1 className="system-xl-semibold text-text-primary">
@@ -156,9 +156,9 @@ const ConfigurationView: FC<ConfigurationViewModel> = ({
<Separator decorative orientation="vertical" className="mx-2 h-3.5" />
</>
)}
- {isMobile && (
+ {isBelowSm && (
<Button
- className="mr-2 h-8! text-[13px]! font-medium"
+ className="me-2 h-8! text-[13px]! font-medium"
onClick={onOpenDebugPanel}
>
<span>{t(($) => $['operation.debugConfig'], { ns: 'appDebug' })}</span>
@@ -174,12 +174,12 @@ const ConfigurationView: FC<ConfigurationViewModel> = ({
>
<Config />
</div>
- {!isMobile && (
+ {!isBelowSm && (
<div
className="relative flex h-full w-1/2 grow flex-col overflow-y-auto"
style={{ borderColor: 'rgba(0, 0, 0, 0.02)' }}
>
- <div className="flex grow flex-col rounded-tl-2xl border-t-[0.5px] border-l-[0.5px] border-components-panel-border bg-chatbot-bg">
+ <div className="flex grow flex-col rounded-ss-2xl border-s-[0.5px] border-t-[0.5px] border-components-panel-border bg-chatbot-bg">
<Debug
onSetting={onOpenAccountSettings}
inputs={contextValue.inputs}
@@ -238,7 +238,7 @@ const ConfigurationView: FC<ConfigurationViewModel> = ({
/>
)}
- {isMobile && (
+ {isBelowSm && (
<Drawer
open={isShowDebugPanel}
modal
diff --git a/web/app/components/app/configuration/hooks/configuration-view-model.ts b/web/app/components/app/configuration/hooks/configuration-view-model.ts
index 9760bed5ccb..e787a9a0915 100644
--- a/web/app/components/app/configuration/hooks/configuration-view-model.ts
+++ b/web/app/components/app/configuration/hooks/configuration-view-model.ts
@@ -19,7 +19,7 @@ export type ConfigurationViewModel = {
featuresData: FeaturesData
isAgent: boolean
isAdvancedMode: boolean
- isMobile: boolean
+ isBelowSm: boolean
isShowDebugPanel: boolean
isShowHistoryModal: boolean
isShowSelectDataSet: boolean
diff --git a/web/app/components/app/configuration/hooks/use-configuration.ts b/web/app/components/app/configuration/hooks/use-configuration.ts
index 97c393de2d8..44eef434367 100644
--- a/web/app/components/app/configuration/hooks/use-configuration.ts
+++ b/web/app/components/app/configuration/hooks/use-configuration.ts
@@ -68,7 +68,7 @@ export const useConfiguration = (): ConfigurationViewModel => {
const [publishedConfig, setPublishedConfig] = useState<ConfigurationPublishConfig | null>(null)
const [conversationId, setConversationId] = useState<string | null>('')
- const isMobile = useMediaQuery('(width < 40rem)', {})
+ const isBelowSm = useMediaQuery('(width < 40rem)', {})
const [isShowDebugPanel, { setTrue: showDebugPanel, setFalse: hideDebugPanel }] =
useBoolean(false)
@@ -413,7 +413,7 @@ export const useConfiguration = (): ConfigurationViewModel => {
featuresData,
isAgent,
isAdvancedMode,
- isMobile,
+ isBelowSm,
isShowDebugPanel,
isShowHistoryModal,
isShowSelectDataSet,
diff --git a/web/app/components/app/text-generate/item/index.tsx b/web/app/components/app/text-generate/item/index.tsx
index 2985ffbb0e5..4537abda272 100644
--- a/web/app/components/app/text-generate/item/index.tsx
+++ b/web/app/components/app/text-generate/item/index.tsx
@@ -52,7 +52,7 @@ type IGenerationItemProps = {
feedback?: FeedbackType
onFeedback?: (feedback: FeedbackType) => void
onSave?: (messageId: string) => void
- isMobile?: boolean
+ isBelowMd?: boolean
appSourceType: AppSourceType
installedAppId?: string
taskId?: string
@@ -82,7 +82,7 @@ const GenerationItem: FC<IGenerationItemProps> = ({
onFeedback,
onSave,
depth = 1,
- isMobile,
+ isBelowMd,
appSourceType,
installedAppId,
taskId,
@@ -127,7 +127,7 @@ const GenerationItem: FC<IGenerationItemProps> = ({
feedback: childFeedback,
onSave,
isShowTextToSpeech,
- isMobile,
+ isBelowMd,
appSourceType,
installedAppId,
controlClearMoreLikeThis,
@@ -270,7 +270,7 @@ const GenerationItem: FC<IGenerationItemProps> = ({
<div
className={cn(
'relative mt-1 h-4 px-4 system-xs-regular text-text-quaternary',
- isMobile &&
+ isBelowMd &&
(childMessageId || isQuerying) &&
depth < MAX_GENERATION_DEPTH &&
'ps-10',
@@ -312,14 +312,14 @@ const GenerationItem: FC<IGenerationItemProps> = ({
<div
className={cn(
'absolute -top-8 flex h-8.25 w-4 justify-center',
- isMobile ? 'inset-s-4.25' : 'inset-s-[50%] translate-x-[-50%]',
+ isBelowMd ? 'inset-s-4.25' : 'inset-s-[50%] translate-x-[-50%]',
)}
>
<div className="h-full w-0.5 bg-divider-regular"></div>
<div
className={cn(
'absolute inset-s-0 flex h-4 w-4 items-center justify-center rounded-2xl border-[0.5px] border-divider-subtle bg-util-colors-blue-blue-500 shadow-xs',
- isMobile ? 'top-[3.5px]' : 'top-2',
+ isBelowMd ? 'top-[3.5px]' : 'top-2',
)}
>
<RiSparklingFill className="size-3 text-text-primary-on-surface" />
diff --git a/web/app/components/base/chat/chat-with-history/__tests__/chat-history-test-env.tsx b/web/app/components/base/chat/chat-with-history/__tests__/chat-history-test-env.tsx
index a28d461e29f..c091b6b4bd8 100644
--- a/web/app/components/base/chat/chat-with-history/__tests__/chat-history-test-env.tsx
+++ b/web/app/components/base/chat/chat-with-history/__tests__/chat-history-test-env.tsx
@@ -41,7 +41,7 @@ export function renderChatHistory(
appParams?: ChatConfig
sidebarCollapsed?: boolean
// These are caller-owned display inputs; all conversation commands come from the real owner.
- ownerProps?: Pick<Partial<ChatWithHistoryContextValue>, 'isMobile' | 'isResponding'>
+ ownerProps?: Pick<Partial<ChatWithHistoryContextValue>, 'isBelowSm' | 'isResponding'>
} = {},
) {
window.history.replaceState({}, '', '/')
@@ -69,7 +69,7 @@ export function renderChatHistory(
function Owner() {
const value = useChatWithHistory()
return (
- <ChatWithHistoryContext.Provider value={{ ...value, isMobile: false, ...ownerProps }}>
+ <ChatWithHistoryContext.Provider value={{ ...value, isBelowSm: false, ...ownerProps }}>
{ui}
</ChatWithHistoryContext.Provider>
)
diff --git a/web/app/components/base/chat/chat-with-history/__tests__/chat-wrapper.hitl-v2.spec.tsx b/web/app/components/base/chat/chat-with-history/__tests__/chat-wrapper.hitl-v2.spec.tsx
index aa8b31fe387..fd08268ae15 100644
--- a/web/app/components/base/chat/chat-with-history/__tests__/chat-wrapper.hitl-v2.spec.tsx
+++ b/web/app/components/base/chat/chat-with-history/__tests__/chat-wrapper.hitl-v2.spec.tsx
@@ -121,7 +121,7 @@ const createContext = (
handleFeedback: vi.fn().mockResolvedValue(undefined),
pinnedConversationList: [],
chatShouldReloadKey: '',
- isMobile: false,
+ isBelowSm: false,
currentConversationInputs: {},
setCurrentConversationInputs: vi.fn(),
allInputsHidden: false,
diff --git a/web/app/components/base/chat/chat-with-history/__tests__/chat-wrapper.spec.tsx b/web/app/components/base/chat/chat-with-history/__tests__/chat-wrapper.spec.tsx
index 77ba38aba2a..b20939260c9 100644
--- a/web/app/components/base/chat/chat-with-history/__tests__/chat-wrapper.spec.tsx
+++ b/web/app/components/base/chat/chat-with-history/__tests__/chat-wrapper.spec.tsx
@@ -105,7 +105,7 @@ const createHistoryContextValue = (
handleFeedback: vi.fn().mockResolvedValue(undefined),
pinnedConversationList: [],
chatShouldReloadKey: '',
- isMobile: false,
+ isBelowSm: false,
currentConversationInputs: {},
setCurrentConversationInputs: vi.fn(),
allInputsHidden: false,
@@ -701,11 +701,11 @@ it('does not submit human input when the workflow event connection fails before
it.each([false, true])(
'shows inputs before the welcome and reveals it after starting chat (mobile=%s)',
- async (isMobile) => {
+ async (isBelowSm) => {
const user = userEvent.setup()
renderChat({
currentConversationId: '',
- isMobile,
+ isBelowSm,
appParams: createChatConfigFixture({ opening_statement: 'Welcome' }),
inputsForms: [
{ variable: 'test', label: 'Test', type: InputVarType.textInput, required: false },
@@ -721,7 +721,7 @@ it.each([false, true])(
it('hides the mobile variable form after entering an existing conversation', () => {
const { updateContext } = renderChat({
currentConversationId: '',
- isMobile: true,
+ isBelowSm: true,
inputsForms: [
{ variable: 'test', label: 'Test', type: InputVarType.textInput, required: false },
],
diff --git a/web/app/components/base/chat/chat-with-history/__tests__/header-in-mobile.spec.tsx b/web/app/components/base/chat/chat-with-history/__tests__/header-in-mobile.spec.tsx
index 0c922219fd2..ec0e52f473a 100644
--- a/web/app/components/base/chat/chat-with-history/__tests__/header-in-mobile.spec.tsx
+++ b/web/app/components/base/chat/chat-with-history/__tests__/header-in-mobile.spec.tsx
@@ -32,7 +32,7 @@ vi.mock('@/service/share', async (importOriginal) => ({
}))
const setup = (options: Parameters<typeof renderChatHistory>[1] = {}) =>
- renderChatHistory(<HeaderInMobile />, { ...options, ownerProps: { isMobile: true } })
+ renderChatHistory(<HeaderInMobile />, { ...options, ownerProps: { isBelowSm: true } })
beforeEach(() => {
vi.mocked(fetchChatList).mockResolvedValue({ data: [] })
diff --git a/web/app/components/base/chat/chat-with-history/chat-wrapper.tsx b/web/app/components/base/chat/chat-with-history/chat-wrapper.tsx
index b10147d155a..f7a67a3b7dc 100644
--- a/web/app/components/base/chat/chat-with-history/chat-wrapper.tsx
+++ b/web/app/components/base/chat/chat-with-history/chat-wrapper.tsx
@@ -43,7 +43,7 @@ const ChatWrapper = () => {
newConversationInputs,
newConversationInputsRef,
handleNewConversationCompleted,
- isMobile,
+ isBelowSm,
isInstalledApp,
appId,
appMeta,
@@ -310,9 +310,9 @@ const ChatWrapper = () => {
const descriptionNode = useMemo(() => {
if (!description || currentConversationId || hasSent) return null
return (
- <div className={cn('flex flex-col items-center px-4 pt-6', isMobile && 'pt-4')}>
+ <div className={cn('flex flex-col items-center px-4 pt-6', isBelowSm && 'pt-4')}>
<div className="w-full max-w-2xl rounded-2xl border-[0.5px] border-components-panel-border bg-components-panel-bg shadow-md">
- <div className={cn('p-6', isMobile && 'p-4')}>
+ <div className={cn('p-6', isBelowSm && 'p-4')}>
<div
ref={handleDescRef}
className={cn(
@@ -349,18 +349,18 @@ const ChatWrapper = () => {
</div>
</div>
)
- }, [description, isMobile, currentConversationId, hasSent, descExpanded, showDescToggle, t])
+ }, [description, isBelowSm, currentConversationId, hasSent, descExpanded, showDescToggle, t])
const chatNode = useMemo(() => {
if (allInputsHidden || !inputsForms.length) return null
- if (isMobile) {
+ if (isBelowSm) {
if (!currentConversationId)
return <InputsForm collapsed={collapsed} setCollapsed={setCollapsed} />
return null
} else {
return <InputsForm collapsed={collapsed} setCollapsed={setCollapsed} />
}
- }, [inputsForms.length, isMobile, currentConversationId, collapsed, allInputsHidden])
+ }, [inputsForms.length, isBelowSm, currentConversationId, collapsed, allInputsHidden])
const welcome = useMemo(() => {
const welcomeMessage = chatList.find((item) => item.isOpeningStatement)
@@ -431,9 +431,9 @@ const ChatWrapper = () => {
speechToTextTarget={speechToTextTarget}
chatList={messageList}
isResponding={respondingState}
- chatContainerInnerClassName={`mx-auto pt-6 w-full max-w-[768px] ${isMobile && 'px-4'}`}
+ chatContainerInnerClassName={`mx-auto pt-6 w-full max-w-[768px] ${isBelowSm && 'px-4'}`}
chatFooterClassName="pb-4"
- chatFooterInnerClassName={`mx-auto w-full max-w-[768px] ${isMobile ? 'px-2' : 'px-4'}`}
+ chatFooterInnerClassName={`mx-auto w-full max-w-[768px] ${isBelowSm ? 'px-2' : 'px-4'}`}
onSend={doSend}
inputs={currentConversationId ? (currentConversationInputs as any) : newConversationInputs}
inputsForm={inputsForms}
diff --git a/web/app/components/base/chat/chat-with-history/context.ts b/web/app/components/base/chat/chat-with-history/context.ts
index 869687bb9f4..a88c32dde7a 100644
--- a/web/app/components/base/chat/chat-with-history/context.ts
+++ b/web/app/components/base/chat/chat-with-history/context.ts
@@ -32,7 +32,7 @@ export type ChatWithHistoryContextValue = {
handleRenameConversation: (conversationId: string, newName: string, callback: Callback) => void
handleNewConversationCompleted: (newConversationId: string) => void
chatShouldReloadKey: string
- isMobile: boolean
+ isBelowSm: boolean
isInstalledApp: boolean
appId?: string
handleFeedback: OnFeedback
@@ -74,7 +74,7 @@ export const ChatWithHistoryContext = createContext<ChatWithHistoryContextValue>
handleRenameConversation: noop,
handleNewConversationCompleted: noop,
chatShouldReloadKey: '',
- isMobile: false,
+ isBelowSm: false,
isInstalledApp: false,
handleFeedback: () => Promise.resolve(),
currentChatInstanceRef: { current: { handleStop: noop } },
diff --git a/web/app/components/base/chat/chat-with-history/index.tsx b/web/app/components/base/chat/chat-with-history/index.tsx
index b19ed3a427a..c3c588fd644 100644
--- a/web/app/components/base/chat/chat-with-history/index.tsx
+++ b/web/app/components/base/chat/chat-with-history/index.tsx
@@ -19,7 +19,7 @@ type ChatWithHistoryProps = {
className?: string
}
const ChatWithHistory: FC<ChatWithHistoryProps> = ({ className }) => {
- const { appData, appChatListDataLoading, chatShouldReloadKey, isMobile, sidebarCollapseState } =
+ const { appData, appChatListDataLoading, chatShouldReloadKey, isBelowSm, sidebarCollapseState } =
useChatWithHistoryContext()
const isSidebarCollapsed = sidebarCollapseState
const site = appData?.site
@@ -39,21 +39,21 @@ const ChatWithHistory: FC<ChatWithHistoryProps> = ({ className }) => {
}, [isSidebarCollapsed])
useEffect(() => {
- if (!isSidebarCollapsed || isMobile) {
+ if (!isSidebarCollapsed || isBelowSm) {
setShowSidePanel(false)
sidePanelHasFocusRef.current = false
sidePanelHoveredRef.current = false
}
return () => clearTimeout(sidePanelBlurTimeoutRef.current)
- }, [isSidebarCollapsed, isMobile])
+ }, [isSidebarCollapsed, isBelowSm])
useDocumentTitle(site?.title || 'Chat')
return (
<div
- className={cn('flex h-full bg-background-default-burn', isMobile && 'flex-col', className)}
+ className={cn('flex h-full bg-background-default-burn', isBelowSm && 'flex-col', className)}
>
- {!isMobile && (
+ {!isBelowSm && (
<div
inert={isSidebarCollapsed}
className={cn(
@@ -64,9 +64,9 @@ const ChatWithHistory: FC<ChatWithHistoryProps> = ({ className }) => {
<Sidebar toggleButtonRef={!isSidebarCollapsed ? sidebarToggleRef : undefined} />
</div>
)}
- {isMobile && <HeaderInMobile />}
- <div className={cn('relative grow p-2', isMobile && 'h-[calc(100%-56px)] p-0')}>
- {!isMobile && isSidebarCollapsed && (
+ {isBelowSm && <HeaderInMobile />}
+ <div className={cn('relative grow p-2', isBelowSm && 'h-[calc(100%-56px)] p-0')}>
+ {!isBelowSm && isSidebarCollapsed && (
<div
className={cn(
'absolute top-0 z-20 flex h-full w-[256px] flex-col p-2 transition-all duration-500 ease-in-out',
@@ -104,10 +104,10 @@ const ChatWithHistory: FC<ChatWithHistoryProps> = ({ className }) => {
<div
className={cn(
'flex h-full flex-col overflow-hidden border-[0,5px] border-components-panel-border-subtle bg-chatbot-bg',
- isMobile ? 'rounded-t-2xl' : 'rounded-2xl',
+ isBelowSm ? 'rounded-t-2xl' : 'rounded-2xl',
)}
>
- {!isMobile && (
+ {!isBelowSm && (
<Header toggleButtonRef={isSidebarCollapsed ? sidebarToggleRef : undefined} />
)}
{appChatListDataLoading && <LoadingPlaceholder className="h-full" />}
@@ -130,7 +130,7 @@ const ChatWithHistoryWrap: FC<ChatWithHistoryWrapProps> = ({
isNewAgent = false,
renderAgentContent,
}) => {
- const isMobile = useMediaQuery('(width < 40rem)', {})
+ const isBelowSm = useMediaQuery('(width < 40rem)', {})
const {
appData,
@@ -202,7 +202,7 @@ const ChatWithHistoryWrap: FC<ChatWithHistoryWrapProps> = ({
handleRenameConversation,
handleNewConversationCompleted,
chatShouldReloadKey,
- isMobile,
+ isBelowSm,
isInstalledApp,
appId,
handleFeedback,
diff --git a/web/app/components/base/chat/chat-with-history/inputs-form/index.tsx b/web/app/components/base/chat/chat-with-history/inputs-form/index.tsx
index 40eaf6b3c01..23773b43da9 100644
--- a/web/app/components/base/chat/chat-with-history/inputs-form/index.tsx
+++ b/web/app/components/base/chat/chat-with-history/inputs-form/index.tsx
@@ -13,13 +13,13 @@ type Props = Readonly<{
const InputsFormNode = ({ collapsed, setCollapsed }: Props) => {
const { t } = useTranslation(['common', 'share'])
- const { isMobile, currentConversationId, handleStartChat, allInputsHidden, theme, inputsForms } =
+ const { isBelowSm, currentConversationId, handleStartChat, allInputsHidden, theme, inputsForms } =
useChatWithHistoryContext()
if (allInputsHidden || inputsForms.length === 0) return null
return (
- <div className={cn('flex flex-col items-center px-4 pt-6', isMobile && 'pt-4')}>
+ <div className={cn('flex flex-col items-center px-4 pt-6', isBelowSm && 'pt-4')}>
<div
className={cn(
'w-full max-w-2xl rounded-2xl border-[0.5px] border-components-panel-border bg-components-panel-bg shadow-md',
@@ -30,7 +30,7 @@ const InputsFormNode = ({ collapsed, setCollapsed }: Props) => {
className={cn(
'flex items-center gap-3 rounded-t-2xl px-6 py-4',
!collapsed && 'border-b border-divider-subtle',
- isMobile && 'px-4 py-3',
+ isBelowSm && 'px-4 py-3',
)}
>
<span aria-hidden className="i-custom-public-other-message-3-fill size-6 shrink-0" />
@@ -59,12 +59,12 @@ const InputsFormNode = ({ collapsed, setCollapsed }: Props) => {
)}
</div>
{!collapsed && (
- <div className={cn('p-6', isMobile && 'p-4')}>
+ <div className={cn('p-6', isBelowSm && 'p-4')}>
<InputsFormContent />
</div>
)}
{!collapsed && !currentConversationId && (
- <div className={cn('p-6', isMobile && 'p-4')}>
+ <div className={cn('p-6', isBelowSm && 'p-4')}>
<Button
variant="primary"
className="w-full"
diff --git a/web/app/components/base/chat/chat-with-history/sidebar/__tests__/index.spec.tsx b/web/app/components/base/chat/chat-with-history/sidebar/__tests__/index.spec.tsx
index f48a1ddcf40..caf36145d5a 100644
--- a/web/app/components/base/chat/chat-with-history/sidebar/__tests__/index.spec.tsx
+++ b/web/app/components/base/chat/chat-with-history/sidebar/__tests__/index.spec.tsx
@@ -193,7 +193,7 @@ describe('Conversation sidebar', () => {
})
it('keeps desktop collapse actions out of the mobile sidebar', () => {
- renderSidebar({ ownerProps: { isMobile: true } })
+ renderSidebar({ ownerProps: { isBelowSm: true } })
expect(
screen.queryByRole('button', { name: /layout.sidebar.(expand|collapse)Sidebar/ }),
).not.toBeInTheDocument()
diff --git a/web/app/components/base/chat/chat-with-history/sidebar/index.tsx b/web/app/components/base/chat/chat-with-history/sidebar/index.tsx
index b60506dc524..cc65c747a8f 100644
--- a/web/app/components/base/chat/chat-with-history/sidebar/index.tsx
+++ b/web/app/components/base/chat/chat-with-history/sidebar/index.tsx
@@ -47,7 +47,7 @@ const Sidebar = ({ isPanel, toggleButtonRef }: Props) => {
handleDeleteConversation,
sidebarCollapseState,
handleSidebarCollapse,
- isMobile,
+ isBelowSm,
isResponding,
} = useChatWithHistoryContext()
const isSidebarCollapsed = sidebarCollapseState
@@ -94,14 +94,14 @@ const Sidebar = ({ isPanel, toggleButtonRef }: Props) => {
'rounded-xl border-[0.5px] border-components-panel-border-subtle bg-components-panel-bg shadow-lg',
)}
>
- <div className={cn('flex shrink-0 items-center gap-3 p-3 pr-2')}>
+ <div className={cn('flex shrink-0 items-center gap-3 p-3 pe-2')}>
<div className="shrink-0">
<AppIcon size="large" icon={appData?.site} />
</div>
<div className={cn('grow truncate system-md-semibold text-text-secondary')}>
{appData?.site.title}
</div>
- {!isMobile && isSidebarCollapsed && (
+ {!isBelowSm && isSidebarCollapsed && (
<IconButton
aria-label={t(($) => $['sidebar.expandSidebar'], { ns: 'layout' })}
size="lg"
@@ -110,7 +110,7 @@ const Sidebar = ({ isPanel, toggleButtonRef }: Props) => {
<span aria-hidden className="i-ri-expand-right-line h-4.5 w-4.5" />
</IconButton>
)}
- {!isMobile && !isSidebarCollapsed && (
+ {!isBelowSm && !isSidebarCollapsed && (
<IconButton
ref={toggleButtonRef}
aria-label={t(($) => $['sidebar.collapseSidebar'], { ns: 'layout' })}
diff --git a/web/app/components/base/chat/embedded-chatbot/chat-wrapper.tsx b/web/app/components/base/chat/embedded-chatbot/chat-wrapper.tsx
index 0cbdbb77085..8c82cd10573 100644
--- a/web/app/components/base/chat/embedded-chatbot/chat-wrapper.tsx
+++ b/web/app/components/base/chat/embedded-chatbot/chat-wrapper.tsx
@@ -44,7 +44,7 @@ const ChatWrapper = () => {
newConversationInputs,
newConversationInputsRef,
handleNewConversationCompleted,
- isMobile,
+ isBelowSm,
isInstalledApp,
appId,
appMeta,
@@ -314,9 +314,9 @@ const ChatWrapper = () => {
const descriptionNode = useMemo(() => {
if (!description || currentConversationId || hasSent) return null
return (
- <div className={cn('flex flex-col items-center px-4 pt-6', isMobile && 'pt-4')}>
+ <div className={cn('flex flex-col items-center px-4 pt-6', isBelowSm && 'pt-4')}>
<div className="w-full max-w-2xl rounded-2xl border-[0.5px] border-components-panel-border bg-components-panel-bg shadow-md">
- <div className={cn('p-6', isMobile && 'p-4')}>
+ <div className={cn('p-6', isBelowSm && 'p-4')}>
<div
ref={descRef}
className={cn(
@@ -353,18 +353,18 @@ const ChatWrapper = () => {
</div>
</div>
)
- }, [description, isMobile, currentConversationId, hasSent, descExpanded, showDescToggle, t])
+ }, [description, isBelowSm, currentConversationId, hasSent, descExpanded, showDescToggle, t])
const chatNode = useMemo(() => {
if (allInputsHidden || !inputsForms.length) return null
- if (isMobile) {
+ if (isBelowSm) {
if (!currentConversationId)
return <InputsForm collapsed={collapsed} setCollapsed={setCollapsed} />
return <div className="mb-4"></div>
} else {
return <InputsForm collapsed={collapsed} setCollapsed={setCollapsed} />
}
- }, [inputsForms.length, isMobile, currentConversationId, collapsed, allInputsHidden])
+ }, [inputsForms.length, isBelowSm, currentConversationId, collapsed, allInputsHidden])
const handleSubmitHumanInputForm = useCallback(
async (formToken: string, formData: HumanInputFormSubmitData) => {
@@ -388,7 +388,7 @@ const ChatWrapper = () => {
<div
className={cn(
'flex items-center justify-center px-4 py-12',
- isMobile ? 'min-h-[30vh] py-0' : 'h-[50vh]',
+ isBelowSm ? 'min-h-[30vh] py-0' : 'h-[50vh]',
)}
>
<div className="flex max-w-180 grow gap-4">
@@ -405,7 +405,7 @@ const ChatWrapper = () => {
<div
className={cn(
'flex min-h-[50vh] flex-col items-center justify-center gap-3 py-12',
- isMobile ? 'min-h-[30vh] py-0' : 'h-[50vh]',
+ isBelowSm ? 'min-h-[30vh] py-0' : 'h-[50vh]',
)}
>
<AppIcon size="xl" icon={appData?.site} />
@@ -425,7 +425,7 @@ const ChatWrapper = () => {
inputsForms.length,
allInputsHidden,
appData?.site,
- isMobile,
+ isBelowSm,
])
const answerIcon = isDify() ? (
@@ -457,8 +457,8 @@ const ChatWrapper = () => {
'mx-auto w-full max-w-full px-4',
messageList.length && 'pt-4',
)}
- chatFooterClassName={cn('pb-4', !isMobile && 'rounded-b-2xl')}
- chatFooterInnerClassName={cn('mx-auto w-full max-w-full px-4', isMobile && 'px-2')}
+ chatFooterClassName={cn('pb-4', !isBelowSm && 'rounded-b-2xl')}
+ chatFooterInnerClassName={cn('mx-auto w-full max-w-full px-4', isBelowSm && 'px-2')}
onSend={doSend}
inputs={currentConversationId ? (currentConversationInputs as any) : newConversationInputs}
inputsForm={inputsForms}
diff --git a/web/app/components/base/chat/embedded-chatbot/context.ts b/web/app/components/base/chat/embedded-chatbot/context.ts
index 9e28276c2d7..4a1a09de9fa 100644
--- a/web/app/components/base/chat/embedded-chatbot/context.ts
+++ b/web/app/components/base/chat/embedded-chatbot/context.ts
@@ -27,7 +27,7 @@ export type EmbeddedChatbotContextValue = {
handleChangeConversation: (conversationId: string) => void
handleNewConversationCompleted: (newConversationId: string) => void
chatShouldReloadKey: string
- isMobile: boolean
+ isBelowSm: boolean
isInstalledApp: boolean
appSourceType: AppSourceType
allowResetChat: boolean
@@ -67,7 +67,7 @@ export const EmbeddedChatbotContext = createContext<EmbeddedChatbotContextValue>
handleChangeConversation: noop,
handleNewConversationCompleted: noop,
chatShouldReloadKey: '',
- isMobile: false,
+ isBelowSm: false,
appSourceType: AppSourceType.webApp,
isInstalledApp: false,
allowResetChat: true,
diff --git a/web/app/components/base/chat/embedded-chatbot/header/__tests__/index.spec.tsx b/web/app/components/base/chat/embedded-chatbot/header/__tests__/index.spec.tsx
index e7034fd4a8f..3edcff1d4f0 100644
--- a/web/app/components/base/chat/embedded-chatbot/header/__tests__/index.spec.tsx
+++ b/web/app/components/base/chat/embedded-chatbot/header/__tests__/index.spec.tsx
@@ -212,7 +212,7 @@ describe('EmbeddedChatbot Header', () => {
...defaultContext,
currentConversationId: '',
})
- render(<Header title="Mobile Chatbot" isMobile allowResetChat />)
+ render(<Header title="Mobile Chatbot" isBelowSm allowResetChat />)
expect(screen.queryByRole('button', { name: 'share.chat.resetChat' })).not.toBeInTheDocument()
})
@@ -220,7 +220,7 @@ describe('EmbeddedChatbot Header', () => {
it('should handle mobile expand button', async () => {
const user = userEvent.setup()
const mockPostMessage = setupIframe()
- render(<Header title="Mobile Chatbot" isMobile />)
+ render(<Header title="Mobile Chatbot" isBelowSm />)
await dispatchChatbotConfigMessage('https://parent.com', {
isToggledByButton: true,
diff --git a/web/app/components/base/chat/embedded-chatbot/header/index.tsx b/web/app/components/base/chat/embedded-chatbot/header/index.tsx
index 5b7fd8a66f2..07141b46e40 100644
--- a/web/app/components/base/chat/embedded-chatbot/header/index.tsx
+++ b/web/app/components/base/chat/embedded-chatbot/header/index.tsx
@@ -16,7 +16,7 @@ import { useEmbeddedChatbotContext } from '../context'
import { CssTransform } from '../theme/utils'
type IHeaderProps = {
- isMobile?: boolean
+ isBelowSm?: boolean
allowResetChat?: boolean
customerIcon?: React.ReactNode
title: string
@@ -24,7 +24,7 @@ type IHeaderProps = {
onCreateNewChat?: () => void
}
const Header: FC<IHeaderProps> = ({
- isMobile,
+ isBelowSm,
allowResetChat,
customerIcon,
title,
@@ -88,7 +88,7 @@ const Header: FC<IHeaderProps> = ({
)
}, [isIframe, parentOrigin, showToggleExpandButton, expanded])
- if (!isMobile) {
+ if (!isBelowSm) {
return (
<div className="flex h-14 shrink-0 items-center justify-end p-3">
<div className="flex items-center gap-1">
diff --git a/web/app/components/base/chat/embedded-chatbot/index.tsx b/web/app/components/base/chat/embedded-chatbot/index.tsx
index 3d0453dece0..aa04133fe2d 100644
--- a/web/app/components/base/chat/embedded-chatbot/index.tsx
+++ b/web/app/components/base/chat/embedded-chatbot/index.tsx
@@ -20,7 +20,7 @@ import { isDify } from './utils'
const Chatbot = () => {
const {
- isMobile,
+ isBelowSm,
allowResetChat,
appData,
appChatListDataLoading,
@@ -42,14 +42,14 @@ const Chatbot = () => {
<div
className={cn(
'flex flex-col rounded-2xl',
- isMobile ? 'h-[calc(100vh-60px)] shadow-xs' : 'h-screen bg-chatbot-bg',
+ isBelowSm ? 'h-[calc(100vh-60px)] shadow-xs' : 'h-screen bg-chatbot-bg',
)}
style={
- isMobile ? Object.assign({}, CssTransform(theme?.backgroundHeaderColorStyle ?? '')) : {}
+ isBelowSm ? Object.assign({}, CssTransform(theme?.backgroundHeaderColorStyle ?? '')) : {}
}
>
<Header
- isMobile={isMobile}
+ isBelowSm={isBelowSm}
allowResetChat={allowResetChat}
title={site?.title || ''}
customerIcon={isDify() ? difyIcon : ''}
@@ -59,7 +59,7 @@ const Chatbot = () => {
<div
className={cn(
'flex grow flex-col overflow-y-auto',
- isMobile && 'm-[0.5px] h-[calc(100vh-3rem)]! rounded-2xl bg-chatbot-bg',
+ isBelowSm && 'm-[0.5px] h-[calc(100vh-3rem)]! rounded-2xl bg-chatbot-bg',
)}
>
{appChatListDataLoading && <LoadingPlaceholder className="h-full" />}
@@ -67,7 +67,7 @@ const Chatbot = () => {
</div>
</div>
{/* powered by */}
- {isMobile && (
+ {isBelowSm && (
<div className="flex h-15 shrink-0 items-center ps-2">
{!appData?.custom_config?.remove_webapp_brand && (
<div className={cn('flex shrink-0 items-center gap-1.5 px-2')}>
@@ -98,7 +98,7 @@ const Chatbot = () => {
}
const EmbeddedChatbotWrapper = () => {
- const isMobile = useMediaQuery('(width < 40rem)', {})
+ const isBelowSm = useMediaQuery('(width < 40rem)', {})
const {
appData,
@@ -160,7 +160,7 @@ const EmbeddedChatbotWrapper = () => {
handleChangeConversation,
handleNewConversationCompleted,
chatShouldReloadKey,
- isMobile,
+ isBelowSm,
isInstalledApp,
allowResetChat,
appId,
diff --git a/web/app/components/base/chat/embedded-chatbot/inputs-form/__tests__/index.spec.tsx b/web/app/components/base/chat/embedded-chatbot/inputs-form/__tests__/index.spec.tsx
index 361c323027b..33dd5fa814d 100644
--- a/web/app/components/base/chat/embedded-chatbot/inputs-form/__tests__/index.spec.tsx
+++ b/web/app/components/base/chat/embedded-chatbot/inputs-form/__tests__/index.spec.tsx
@@ -37,7 +37,7 @@ function FormOwner({ initiallyCollapsed = false }: { initiallyCollapsed?: boolea
const contextValue: EmbeddedChatbotContextValue = {
...owner,
appData: (owner.appData as AppData | undefined) ?? null,
- isMobile: false,
+ isBelowSm: false,
}
return (
diff --git a/web/app/components/base/chat/embedded-chatbot/inputs-form/index.tsx b/web/app/components/base/chat/embedded-chatbot/inputs-form/index.tsx
index a3739672912..efbf73bb591 100644
--- a/web/app/components/base/chat/embedded-chatbot/inputs-form/index.tsx
+++ b/web/app/components/base/chat/embedded-chatbot/inputs-form/index.tsx
@@ -16,7 +16,7 @@ const InputsFormNode = ({ collapsed, setCollapsed }: Props) => {
const { t } = useTranslation(['common', 'share'])
const {
appSourceType,
- isMobile,
+ isBelowSm,
currentConversationId,
theme,
handleStartChat,
@@ -32,7 +32,7 @@ const InputsFormNode = ({ collapsed, setCollapsed }: Props) => {
data-testid="inputs-form-node"
className={cn(
'mb-6 flex flex-col items-center px-4 pt-6',
- isMobile && 'mb-4 pt-4',
+ isBelowSm && 'mb-4 pt-4',
isTryApp && 'mb-0 px-0',
)}
>
@@ -47,7 +47,7 @@ const InputsFormNode = ({ collapsed, setCollapsed }: Props) => {
className={cn(
'flex items-center gap-3 rounded-t-2xl px-6 py-4',
!collapsed && 'border-b border-divider-subtle',
- isMobile && 'px-4 py-3',
+ isBelowSm && 'px-4 py-3',
)}
>
<div className="i-custom-public-other-message-3-fill size-6 shrink-0" />
@@ -76,12 +76,12 @@ const InputsFormNode = ({ collapsed, setCollapsed }: Props) => {
)}
</div>
{!collapsed && (
- <div className={cn('p-6', isMobile && 'p-4')}>
+ <div className={cn('p-6', isBelowSm && 'p-4')}>
<InputsFormContent />
</div>
)}
{!collapsed && !currentConversationId && (
- <div className={cn('p-6', isMobile && 'p-4')}>
+ <div className={cn('p-6', isBelowSm && 'p-4')}>
<Button
variant="primary"
className="w-full"
diff --git a/web/app/components/base/float-right-container/__tests__/index.spec.tsx b/web/app/components/base/float-right-container/__tests__/index.spec.tsx
index f0d318c1bc5..796225b7620 100644
--- a/web/app/components/base/float-right-container/__tests__/index.spec.tsx
+++ b/web/app/components/base/float-right-container/__tests__/index.spec.tsx
@@ -14,7 +14,7 @@ it('opens mobile content in a named drawer and closes it through the supplied ac
Open panel
</button>
<FloatRightContainer
- isMobile
+ presentation="drawer"
isOpen={open}
title="Mobile panel"
showClose
@@ -39,7 +39,7 @@ it('opens mobile content in a named drawer and closes it through the supplied ac
it('shows desktop content inline only while open', () => {
const { rerender } = render(
- <FloatRightContainer isMobile={false} isOpen onClose={vi.fn()} title="Drawer title">
+ <FloatRightContainer presentation="inline" isOpen onClose={vi.fn()} title="Drawer title">
Desktop content
</FloatRightContainer>,
)
@@ -47,7 +47,7 @@ it('shows desktop content inline only while open', () => {
expect(screen.queryByRole('dialog')).not.toBeInTheDocument()
expect(screen.queryByText('Drawer title')).not.toBeInTheDocument()
rerender(
- <FloatRightContainer isMobile={false} isOpen={false} onClose={vi.fn()}>
+ <FloatRightContainer presentation="inline" isOpen={false} onClose={vi.fn()}>
Desktop content
</FloatRightContainer>,
)
diff --git a/web/app/components/base/float-right-container/index.stories.tsx b/web/app/components/base/float-right-container/index.stories.tsx
index 42efae18d86..93a5a6edf7d 100644
--- a/web/app/components/base/float-right-container/index.stories.tsx
+++ b/web/app/components/base/float-right-container/index.stories.tsx
@@ -23,7 +23,7 @@ type Story = StoryObj<typeof meta>
const ContainerDemo = () => {
const [open, setOpen] = useState(false)
- const [isMobile, setIsMobile] = useState(false)
+ const [isDrawer, setIsDrawer] = useState(false)
return (
<div className="flex h-90 flex-col gap-4 bg-background-default-subtle p-6">
@@ -38,15 +38,15 @@ const ContainerDemo = () => {
<label className="flex items-center gap-1 text-xs text-text-secondary">
<input
type="checkbox"
- checked={isMobile}
- onChange={(e) => setIsMobile(e.target.checked)}
+ checked={isDrawer}
+ onChange={(e) => setIsDrawer(e.target.checked)}
/>
- Simulate mobile
+ Drawer presentation
</label>
</div>
<FloatRightContainer
- isMobile={isMobile}
+ presentation={isDrawer ? 'drawer' : 'inline'}
isOpen={open}
onClose={() => setOpen(false)}
title="Responsive panel"
@@ -55,8 +55,8 @@ const ContainerDemo = () => {
<div className="rounded-xl border border-divider-subtle bg-components-panel-bg p-4 text-xs text-text-secondary">
<p className="mb-2 text-sm text-text-primary">Panel Content</p>
<p>
- On desktop, this block renders inline when `isOpen` is true. On mobile it appears inside
- the drawer wrapper.
+ With the inline presentation, this block renders in place when `isOpen` is true. With
+ the drawer presentation it appears inside the drawer wrapper.
</p>
</div>
</FloatRightContainer>
@@ -67,7 +67,7 @@ const ContainerDemo = () => {
export const Playground: Story = {
render: () => <ContainerDemo />,
args: {
- isMobile: false,
+ presentation: 'inline',
isOpen: false,
onClose: fn(),
children: null,
diff --git a/web/app/components/base/float-right-container/index.tsx b/web/app/components/base/float-right-container/index.tsx
index 214f5632be8..79e8eb73f71 100644
--- a/web/app/components/base/float-right-container/index.tsx
+++ b/web/app/components/base/float-right-container/index.tsx
@@ -15,7 +15,7 @@ import { IconButton } from '@langgenius/dify-ui/icon-button'
import { useTranslation } from 'react-i18next'
type IFloatRightContainerProps = Pick<DrawerPopupProps, 'finalFocus'> & {
- isMobile: boolean
+ presentation: 'drawer' | 'inline'
isOpen: boolean
onClose: () => void
children?: React.ReactNode
@@ -26,7 +26,7 @@ type IFloatRightContainerProps = Pick<DrawerPopupProps, 'finalFocus'> & {
}
const FloatRightContainer = ({
- isMobile,
+ presentation,
children,
isOpen,
onClose,
@@ -40,7 +40,7 @@ const FloatRightContainer = ({
return (
<>
- {isMobile && (
+ {presentation === 'drawer' && (
<Drawer
open={isOpen}
modal
@@ -88,7 +88,7 @@ const FloatRightContainer = ({
</DrawerPortal>
</Drawer>
)}
- {!isMobile && isOpen && <>{children}</>}
+ {presentation === 'inline' && isOpen && <>{children}</>}
</>
)
}
diff --git a/web/app/components/base/linked-apps-panel/__tests__/index.spec.tsx b/web/app/components/base/linked-apps-panel/__tests__/index.spec.tsx
index f5b56257481..ce79ec8e530 100644
--- a/web/app/components/base/linked-apps-panel/__tests__/index.spec.tsx
+++ b/web/app/components/base/linked-apps-panel/__tests__/index.spec.tsx
@@ -36,7 +36,7 @@ describe('LinkedAppsPanel Component', () => {
]
it('links each related application to its overview with its name and mode', () => {
- render(<LinkedAppsPanel relatedApps={mockRelatedApps} isMobile={false} />)
+ render(<LinkedAppsPanel relatedApps={mockRelatedApps} compact={false} />)
for (const [name, mode, id] of [
['Chatbot App', 'Chatbot', 'app-1'],
['Workflow App', 'Workflow', 'app-2'],
diff --git a/web/app/components/base/linked-apps-panel/index.stories.tsx b/web/app/components/base/linked-apps-panel/index.stories.tsx
index 6154fdf0a62..4124f564100 100644
--- a/web/app/components/base/linked-apps-panel/index.stories.tsx
+++ b/web/app/components/base/linked-apps-panel/index.stories.tsx
@@ -49,10 +49,10 @@ const meta = {
},
args: {
relatedApps: mockRelatedApps,
- isMobile: false,
+ compact: false,
},
argTypes: {
- isMobile: {
+ compact: {
control: 'boolean',
},
},
@@ -62,11 +62,11 @@ const meta = {
export default meta
type Story = StoryObj<typeof meta>
-export const Desktop: Story = {}
+export const Default: Story = {}
-export const Mobile: Story = {
+export const Compact: Story = {
args: {
- isMobile: true,
+ compact: true,
},
parameters: {
viewport: {
diff --git a/web/app/components/base/linked-apps-panel/index.tsx b/web/app/components/base/linked-apps-panel/index.tsx
index f93b42ff2d5..2ff61efb176 100644
--- a/web/app/components/base/linked-apps-panel/index.tsx
+++ b/web/app/components/base/linked-apps-panel/index.tsx
@@ -11,7 +11,7 @@ import Link from '@/next/link'
type ILikedItemProps = Readonly<{
appStatus?: boolean
detail: RelatedAppResponse
- isMobile: boolean
+ compact: boolean
}>
const appTypeMap: Partial<Record<RelatedAppResponse['mode'], string>> = {
@@ -22,12 +22,12 @@ const appTypeMap: Partial<Record<RelatedAppResponse['mode'], string>> = {
workflow: 'Workflow',
}
-const LikedItem = ({ detail, isMobile }: ILikedItemProps) => {
+const LikedItem = ({ detail, compact }: ILikedItemProps) => {
return (
<Link
className={cn(
'group/link-item flex h-8 w-full cursor-pointer items-center justify-between rounded-lg px-2 hover:bg-state-base-hover',
- isMobile && 'justify-center',
+ compact && 'justify-center',
)}
href={`/app/${detail?.id}/overview`}
>
@@ -35,8 +35,8 @@ const LikedItem = ({ detail, isMobile }: ILikedItemProps) => {
<div className={cn('relative size-6 rounded-md')}>
<AppIcon size="tiny" icon={detail} />
</div>
- {!isMobile && (
- <div className={cn('ml-2 truncate system-sm-medium text-text-primary')}>
+ {!compact && (
+ <div className={cn('ms-2 truncate system-sm-medium text-text-primary')}>
{detail?.name || '--'}
</div>
)}
@@ -51,14 +51,14 @@ const LikedItem = ({ detail, isMobile }: ILikedItemProps) => {
type Props = Readonly<{
relatedApps: RelatedAppResponse[]
- isMobile: boolean
+ compact: boolean
}>
-const LinkedAppsPanel: FC<Props> = ({ relatedApps, isMobile }) => {
+const LinkedAppsPanel: FC<Props> = ({ relatedApps, compact }) => {
return (
<div className="w-[320px] rounded-xl border-[0.5px] border-components-panel-border bg-components-panel-bg-blur p-1 shadow-lg backdrop-blur-[5px]">
{relatedApps.map((item, index) => (
- <LikedItem key={index} detail={item} isMobile={isMobile} />
+ <LikedItem key={index} detail={item} compact={compact} />
))}
</div>
)
diff --git a/web/app/components/datasets/create/step-two/components/__tests__/preview-panel.spec.tsx b/web/app/components/datasets/create/step-two/components/__tests__/preview-panel.spec.tsx
index dd66e17894d..ade52f774a3 100644
--- a/web/app/components/datasets/create/step-two/components/__tests__/preview-panel.spec.tsx
+++ b/web/app/components/datasets/create/step-two/components/__tests__/preview-panel.spec.tsx
@@ -16,7 +16,7 @@ const estimateBase: IndexingEstimateResponse = {
describe('PreviewPanel', () => {
const defaultProps = {
- isMobile: false,
+ isBelowSm: false,
isOpen: false,
onClose: vi.fn(),
dataSourceType: DataSourceType.FILE,
@@ -59,7 +59,7 @@ describe('PreviewPanel', () => {
</button>
<PreviewPanel
{...defaultProps}
- isMobile
+ isBelowSm
isOpen={isOpen}
onClose={() => setIsOpen(false)}
finalFocus={triggerRef}
diff --git a/web/app/components/datasets/create/step-two/components/preview-panel.tsx b/web/app/components/datasets/create/step-two/components/preview-panel.tsx
index fa8fd37cd4c..63f0d854beb 100644
--- a/web/app/components/datasets/create/step-two/components/preview-panel.tsx
+++ b/web/app/components/datasets/create/step-two/components/preview-panel.tsx
@@ -26,7 +26,7 @@ import PreviewContainer from '../../../preview/container'
type PreviewPanelProps = {
// State
- isMobile: boolean
+ isBelowSm: boolean
isOpen: boolean
onClose: () => void
finalFocus?: ComponentProps<typeof FloatRightContainer>['finalFocus']
@@ -46,7 +46,7 @@ type PreviewPanelProps = {
}
export const PreviewPanel: FC<PreviewPanelProps> = ({
- isMobile,
+ isBelowSm,
isOpen,
onClose,
finalFocus,
@@ -65,8 +65,8 @@ export const PreviewPanel: FC<PreviewPanelProps> = ({
return (
<FloatRightContainer
- isMobile={isMobile}
- isOpen={!isMobile || isOpen}
+ presentation={isBelowSm ? 'drawer' : 'inline'}
+ isOpen={!isBelowSm || isOpen}
onClose={onClose}
showClose
title={t(($) => $['stepTwo.preview'], { ns: 'datasetCreation' })}
@@ -85,7 +85,7 @@ export const PreviewPanel: FC<PreviewPanelProps> = ({
<PreviewContainer
header={
<div>
- {!isMobile && (
+ {!isBelowSm && (
<h2 className="mb-1 px-1 system-2xs-semibold-uppercase text-text-accent uppercase">
{t(($) => $['stepTwo.preview'], { ns: 'datasetCreation' })}
</h2>
@@ -111,7 +111,7 @@ export const PreviewPanel: FC<PreviewPanelProps> = ({
}
className={cn(
'relative flex min-w-0 shrink-0 p-4',
- isMobile ? 'min-h-0 w-full flex-1' : 'h-full w-1/2 pr-0',
+ isBelowSm ? 'min-h-0 w-full flex-1' : 'h-full w-1/2 pe-0',
)}
mainClassName="space-y-6 wrap-break-word"
>
diff --git a/web/app/components/datasets/create/step-two/index.module.css b/web/app/components/datasets/create/step-two/index.module.css
index 5ebc3230b58..c5145d1ce24 100644
--- a/web/app/components/datasets/create/step-two/index.module.css
+++ b/web/app/components/datasets/create/step-two/index.module.css
@@ -384,15 +384,6 @@
color: #344054;
}
-.previewWrap {
- flex-shrink: 0;
- width: 524px;
-}
-
-.previewWrap.isMobile {
- max-width: 524px;
-}
-
/*
* `fixed` must under `previewHeader` because of style override would not work
*/
diff --git a/web/app/components/datasets/create/step-two/index.tsx b/web/app/components/datasets/create/step-two/index.tsx
index 708d12a775c..1497866c4d3 100644
--- a/web/app/components/datasets/create/step-two/index.tsx
+++ b/web/app/components/datasets/create/step-two/index.tsx
@@ -386,7 +386,7 @@ const StepTwo: FC<StepTwoProps> = ({
/>
</div>
<PreviewPanel
- isMobile={isBelowSm}
+ isBelowSm={isBelowSm}
isOpen={isPreviewOpen}
onClose={() => setIsPreviewOpen(false)}
finalFocus={previewTriggerRef}
diff --git a/web/app/components/datasets/documents/detail/index.tsx b/web/app/components/datasets/documents/detail/index.tsx
index 506d5b88f9e..e51db923305 100644
--- a/web/app/components/datasets/documents/detail/index.tsx
+++ b/web/app/components/datasets/documents/detail/index.tsx
@@ -444,7 +444,7 @@ const DocumentDetail: FC<DocumentDetailProps> = ({ datasetId, documentId }) => {
showClose
isOpen={showMetadata}
onClose={() => setShowMetadata(false)}
- isMobile={isBelowSm}
+ presentation={isBelowSm ? 'drawer' : 'inline'}
panelClassName="justify-start!"
>
{metadataPanel &&
diff --git a/web/app/components/datasets/extra-info/statistics.tsx b/web/app/components/datasets/extra-info/statistics.tsx
index c3273dc6a74..8d17bcf7baf 100644
--- a/web/app/components/datasets/extra-info/statistics.tsx
+++ b/web/app/components/datasets/extra-info/statistics.tsx
@@ -57,7 +57,7 @@ const Statistics = ({ expand, documentCount, relatedApps }: StatisticsProps) =>
className="border-0 bg-transparent p-0 shadow-none"
>
{hasRelatedApps ? (
- <LinkedAppsPanel relatedApps={relatedApps.data} isMobile={!expand} />
+ <LinkedAppsPanel relatedApps={relatedApps.data} compact={!expand} />
) : (
<NoLinkedAppsPanel />
)}
diff --git a/web/app/components/datasets/hit-testing/index.tsx b/web/app/components/datasets/hit-testing/index.tsx
index fff85e2ee9a..d7717cc7f3d 100644
--- a/web/app/components/datasets/hit-testing/index.tsx
+++ b/web/app/components/datasets/hit-testing/index.tsx
@@ -251,7 +251,7 @@ const HitTestingPage: FC<Props> = ({ datasetId }: Props) => {
<FloatRightContainer
panelClassName="justify-start! overflow-y-auto!"
showClose
- isMobile={isBelowSm}
+ presentation={isBelowSm ? 'drawer' : 'inline'}
isOpen={!isBelowSm || isResultDrawerOpen}
onClose={closeResultDrawer}
title={panelTitle}
diff --git a/web/app/components/explore/try-app/app/chat.tsx b/web/app/components/explore/try-app/app/chat.tsx
index c3f3b23782e..9cc9c6f47e6 100644
--- a/web/app/components/explore/try-app/app/chat.tsx
+++ b/web/app/components/explore/try-app/app/chat.tsx
@@ -28,7 +28,7 @@ type Props = Readonly<{
const TryApp: FC<Props> = ({ appId, appDetail, className }) => {
const { t } = useTranslation(['explore', 'share', 'common'])
- const isMobile = useMediaQuery('(width < 40rem)', {})
+ const isBelowSm = useMediaQuery('(width < 40rem)', {})
const { removeConversationIdInfo, ...chatData } = useEmbeddedChatbot(AppSourceType.tryApp, appId)
const theme = createTheme(
chatData.appData?.site?.chat_color_theme ?? null,
@@ -51,7 +51,7 @@ const TryApp: FC<Props> = ({ appId, appDetail, className }) => {
{
...chatData,
disableFeedback: true,
- isMobile,
+ isBelowSm,
theme,
} as EmbeddedChatbotContextValue
}
diff --git a/web/app/components/explore/try-app/app/text-generation.tsx b/web/app/components/explore/try-app/app/text-generation.tsx
index 4c4dec9f80e..bf98ec61647 100644
--- a/web/app/components/explore/try-app/app/text-generation.tsx
+++ b/web/app/components/explore/try-app/app/text-generation.tsx
@@ -39,7 +39,7 @@ const TextGeneration: FC<Props> = ({ appId, className, isWorkflow, appData }) =>
const handleDescRef = useCallback((node: HTMLDivElement | null) => {
setShowDescToggle(!!node && node.scrollHeight > node.clientHeight)
}, [])
- const isPC = !useMediaQuery('(width < 48rem)', {})
+ const isBelowMd = useMediaQuery('(width < 48rem)', {})
const [inputs, doSetInputs] = useState<Record<string, InputValueTypes>>({})
const inputsRef = useRef<Record<string, InputValueTypes>>(inputs)
@@ -133,8 +133,7 @@ const TextGeneration: FC<Props> = ({ appId, className, isWorkflow, appData }) =>
key={task?.id}
isWorkflow={!!isWorkflow}
isCallBatchAPI={false}
- isPC={isPC}
- isMobile={!isPC}
+ isBelowMd={isBelowMd}
appSourceType={AppSourceType.tryApp}
appId={appId}
isError={task?.status === TaskStatus.failed}
@@ -183,8 +182,7 @@ const TextGeneration: FC<Props> = ({ appId, className, isWorkflow, appData }) =>
<div
className={cn(
'rounded-2xl border border-components-panel-border bg-background-section-burn',
- isPC && 'flex',
- !isPC && 'flex-col',
+ isBelowMd ? 'flex-col' : 'flex',
'h-full rounded-2xl shadow-md',
className,
)}
@@ -193,16 +191,16 @@ const TextGeneration: FC<Props> = ({ appId, className, isWorkflow, appData }) =>
<div
className={cn(
'relative flex h-full shrink-0 flex-col',
- isPC && 'w-150 max-w-[50%]',
+ !isBelowMd && 'w-150 max-w-[50%]',
'rounded-s-2xl bg-components-panel-bg',
)}
>
{/* Header */}
- <div className={cn('shrink-0 space-y-4 pb-2', isPC ? 'p-8 pb-0' : 'p-4 pb-0')}>
+ <div className={cn('shrink-0 space-y-4 pb-2', isBelowMd ? 'p-4 pb-0' : 'p-8 pb-0')}>
<div className="flex items-center gap-3">
<AppIcon
fallback={{ content: '🤖', background: appDefaultIconBackground }}
- size={isPC ? 'large' : 'small'}
+ size={isBelowMd ? 'small' : 'large'}
icon={siteInfo}
/>
<div className="grow truncate system-md-semibold text-text-secondary">
@@ -250,8 +248,8 @@ const TextGeneration: FC<Props> = ({ appId, className, isWorkflow, appData }) =>
<div
className={cn(
'h-0 grow overflow-y-auto',
- isPC ? 'px-8' : 'px-4',
- !isPC &&
+ isBelowMd ? 'px-4' : 'px-8',
+ isBelowMd &&
resultExisted &&
customConfig?.remove_webapp_brand &&
'rounded-b-2xl border-b-[0.5px] border-divider-regular',
@@ -272,7 +270,7 @@ const TextGeneration: FC<Props> = ({ appId, className, isWorkflow, appData }) =>
{/* Result */}
<div className={cn('h-full w-0 grow')}>
- {!isPC && (
+ {isBelowMd && (
<div
className={cn(
isShowResultPanel
diff --git a/web/app/components/explore/try-app/preview/basic-app-preview.tsx b/web/app/components/explore/try-app/preview/basic-app-preview.tsx
index 270cd0abaab..4317f59ffdb 100644
--- a/web/app/components/explore/try-app/preview/basic-app-preview.tsx
+++ b/web/app/components/explore/try-app/preview/basic-app-preview.tsx
@@ -330,7 +330,7 @@ const normalizeAgentTool = (
}
const BasicAppPreview: FC<Props> = ({ appId, appDetail }) => {
- const isMobile = useMediaQuery('(width < 40rem)', {})
+ const isBelowSm = useMediaQuery('(width < 40rem)', {})
const { data: collectionListFromServer, isLoading: isLoadingToolProviders } = useQuery(
consoleQuery.workspaces.current.toolProviders.get.queryOptions({
@@ -616,7 +616,7 @@ const BasicAppPreview: FC<Props> = ({ appId, appDetail }) => {
<div className="flex size-full shrink-0 flex-col sm:w-1/2">
<Config />
</div>
- {!isMobile && (
+ {!isBelowSm && (
<div
className="relative flex h-full w-1/2 grow flex-col overflow-y-auto"
style={{ borderColor: 'rgba(0, 0, 0, 0.02)' }}
diff --git a/web/app/components/plugins/marketplace/home/__tests__/home-trending.spec.tsx b/web/app/components/plugins/marketplace/home/__tests__/home-trending.spec.tsx
index ac11bf30f17..1d9579b738c 100644
--- a/web/app/components/plugins/marketplace/home/__tests__/home-trending.spec.tsx
+++ b/web/app/components/plugins/marketplace/home/__tests__/home-trending.spec.tsx
@@ -845,11 +845,11 @@ describe('HomeTrending', () => {
})
describe('mobile swipe', () => {
- const stubViewport = (isMobile: boolean) =>
+ const stubViewport = (isNarrow: boolean) =>
vi.spyOn(window, 'matchMedia').mockImplementation(
(query) =>
({
- matches: isMobile && query === '(max-width: 879px)',
+ matches: isNarrow && query === '(max-width: 879px)',
media: query,
onchange: null,
addEventListener: vi.fn(),
@@ -939,10 +939,18 @@ describe('HomeTrending', () => {
})
it.each([
- { name: 'a vertical gesture on mobile', isMobile: true, end: [270, 300] as [number, number] },
- { name: 'touch input on desktop', isMobile: false, end: [80, 160] as [number, number] },
- ])('stays on the current slide for $name', ({ isMobile, end }) => {
- stubViewport(isMobile)
+ {
+ name: 'a vertical gesture on a narrow viewport',
+ isNarrow: true,
+ end: [270, 300] as [number, number],
+ },
+ {
+ name: 'touch input on a wide viewport',
+ isNarrow: false,
+ end: [80, 160] as [number, number],
+ },
+ ])('stays on the current slide for $name', ({ isNarrow, end }) => {
+ stubViewport(isNarrow)
renderCarousel()
swipe(screen.getByRole('group', { name: 'Trending' }), [[300, 120], end])
diff --git a/web/app/components/share/text-generation/__tests__/text-generation-result-panel.spec.tsx b/web/app/components/share/text-generation/__tests__/text-generation-result-panel.spec.tsx
index 40c5eaeeefc..e6631556616 100644
--- a/web/app/components/share/text-generation/__tests__/text-generation-result-panel.spec.tsx
+++ b/web/app/components/share/text-generation/__tests__/text-generation-result-panel.spec.tsx
@@ -73,7 +73,7 @@ const baseProps = {
handleSaveMessage: vi.fn(async () => {}),
inputs: { name: 'Alice' },
isCallBatchAPI: false,
- isPC: true,
+ isBelowMd: false,
isShowResultPanel: true,
isWorkflow: false,
moreLikeThisEnabled: true,
diff --git a/web/app/components/share/text-generation/__tests__/text-generation-sidebar.spec.tsx b/web/app/components/share/text-generation/__tests__/text-generation-sidebar.spec.tsx
index 92eb2040b15..d796d29b883 100644
--- a/web/app/components/share/text-generation/__tests__/text-generation-sidebar.spec.tsx
+++ b/web/app/components/share/text-generation/__tests__/text-generation-sidebar.spec.tsx
@@ -55,7 +55,7 @@ const baseProps: ComponentProps<typeof TextGenerationSidebar> = {
inputs: { name: 'Alice' },
inputsRef: { current: { name: 'Alice' } },
isInstalledApp: false,
- isPC: true,
+ isBelowMd: false,
isWorkflow: false,
onBatchSend: vi.fn(),
onInputsChange: vi.fn(),
diff --git a/web/app/components/share/text-generation/index.tsx b/web/app/components/share/text-generation/index.tsx
index 82821a2e973..050fe4c06e0 100644
--- a/web/app/components/share/text-generation/index.tsx
+++ b/web/app/components/share/text-generation/index.tsx
@@ -22,7 +22,7 @@ type IMainProps = {
}
const TextGeneration: FC<IMainProps> = ({ isInstalledApp = false, isWorkflow = false }) => {
const { t } = useTranslation(['share', 'appDebug', 'common', 'workflow'])
- const isPC = !useMediaQuery('(width < 48rem)', {})
+ const isBelowMd = useMediaQuery('(width < 48rem)', {})
const searchParams = useSearchParams()
const mode = searchParams.get('mode') || 'create'
const [currentTab, setCurrentTab] = useState<string>(
@@ -122,7 +122,7 @@ const TextGeneration: FC<IMainProps> = ({ isInstalledApp = false, isWorkflow = f
<div
className={cn(
'bg-background-default-burn',
- isPC ? 'flex' : 'flex-col',
+ isBelowMd ? 'flex-col' : 'flex',
isInstalledApp ? 'h-full rounded-2xl shadow-md' : 'h-screen',
)}
>
@@ -134,7 +134,7 @@ const TextGeneration: FC<IMainProps> = ({ isInstalledApp = false, isWorkflow = f
inputs={inputs}
inputsRef={inputsRef}
isInstalledApp={isInstalledApp}
- isPC={isPC}
+ isBelowMd={isBelowMd}
isWorkflow={isWorkflow}
onBatchSend={handleRunBatch}
onInputsChange={updateInputs}
@@ -167,7 +167,7 @@ const TextGeneration: FC<IMainProps> = ({ isInstalledApp = false, isWorkflow = f
handleSaveMessage={handleSaveMessage}
inputs={inputs}
isCallBatchAPI={isCallBatchAPI}
- isPC={isPC}
+ isBelowMd={isBelowMd}
isShowResultPanel={isShowResultPanel}
isWorkflow={isWorkflow}
moreLikeThisEnabled={!!moreLikeThisConfig?.enabled}
diff --git a/web/app/components/share/text-generation/result/__tests__/index.spec.tsx b/web/app/components/share/text-generation/result/__tests__/index.spec.tsx
index 539745c436f..0b63ee6d980 100644
--- a/web/app/components/share/text-generation/result/__tests__/index.spec.tsx
+++ b/web/app/components/share/text-generation/result/__tests__/index.spec.tsx
@@ -95,8 +95,7 @@ const baseProps = {
inputs: { name: 'Alice' },
isCallBatchAPI: false,
isError: false,
- isMobile: false,
- isPC: true,
+ isBelowMd: false,
isShowTextToSpeech: true,
isWorkflow: false,
moreLikeThisEnabled: true,
diff --git a/web/app/components/share/text-generation/result/hooks/__tests__/use-result-sender.hitl-v2.spec.ts b/web/app/components/share/text-generation/result/hooks/__tests__/use-result-sender.hitl-v2.spec.ts
index 6e3cd9ea0e7..62c05051771 100644
--- a/web/app/components/share/text-generation/result/hooks/__tests__/use-result-sender.hitl-v2.spec.ts
+++ b/web/app/components/share/text-generation/result/hooks/__tests__/use-result-sender.hitl-v2.spec.ts
@@ -134,7 +134,7 @@ type RenderSenderOptions = {
controlRetry?: number
controlSend?: number
inputs?: Record<string, ResultInputValue>
- isPC?: boolean
+ isBelowMd?: boolean
isWorkflow?: boolean
taskId?: number
}
@@ -144,7 +144,7 @@ const renderSender = ({
controlRetry = 0,
controlSend = 0,
inputs = { name: 'Alice' },
- isPC = true,
+ isBelowMd = false,
isWorkflow = true,
taskId,
}: RenderSenderOptions = {}) => {
@@ -179,7 +179,7 @@ const renderSender = ({
controlSend: props.controlSend,
inputs,
isCallBatchAPI: false,
- isPC,
+ isBelowMd,
isWorkflow,
notify,
onCompleted,
diff --git a/web/app/components/share/text-generation/result/hooks/__tests__/use-result-sender.spec.ts b/web/app/components/share/text-generation/result/hooks/__tests__/use-result-sender.spec.ts
index eb87a4e22e0..624a222062c 100644
--- a/web/app/components/share/text-generation/result/hooks/__tests__/use-result-sender.spec.ts
+++ b/web/app/components/share/text-generation/result/hooks/__tests__/use-result-sender.spec.ts
@@ -81,7 +81,7 @@ function renderSender(
controlRetry,
taskId: 7,
isCallBatchAPI: false,
- isPC: false,
+ isBelowMd: true,
completionFiles: [],
inputs: options.inputs ?? { name: 'Alice' },
promptConfig,
diff --git a/web/app/components/share/text-generation/result/hooks/use-result-sender.ts b/web/app/components/share/text-generation/result/hooks/use-result-sender.ts
index 283cc2cbd5e..6e7031f63e9 100644
--- a/web/app/components/share/text-generation/result/hooks/use-result-sender.ts
+++ b/web/app/components/share/text-generation/result/hooks/use-result-sender.ts
@@ -27,7 +27,7 @@ type UseResultSenderOptions = {
controlSend?: number
inputs: Record<string, ResultInputValue>
isCallBatchAPI: boolean
- isPC: boolean
+ isBelowMd: boolean
isWorkflow: boolean
notify: Notify
onCompleted: (completionRes: string, taskId?: number, success?: boolean) => void
@@ -53,7 +53,7 @@ export const useResultSender = ({
controlSend,
inputs,
isCallBatchAPI,
- isPC,
+ isBelowMd,
isWorkflow,
notify,
onCompleted,
@@ -105,7 +105,7 @@ export const useResultSender = ({
resetWebAppWorkflowEvents()
runState.prepareForNewRun()
- if (!isPC) {
+ if (isBelowMd) {
onShowRes()
onRunStart()
}
@@ -240,7 +240,7 @@ export const useResultSender = ({
createWebAppStreamHandlers,
inputs,
isCallBatchAPI,
- isPC,
+ isBelowMd,
isWorkflow,
notify,
onCompleted,
diff --git a/web/app/components/share/text-generation/result/index.tsx b/web/app/components/share/text-generation/result/index.tsx
index f3805d0cb4f..75ed7563185 100644
--- a/web/app/components/share/text-generation/result/index.tsx
+++ b/web/app/components/share/text-generation/result/index.tsx
@@ -19,8 +19,7 @@ import { useResultSender } from './hooks/use-result-sender'
type IResultProps = {
isWorkflow: boolean
isCallBatchAPI: boolean
- isPC: boolean
- isMobile: boolean
+ isBelowMd: boolean
appSourceType: AppSourceType
appId?: string
isError: boolean
@@ -50,8 +49,7 @@ type IResultProps = {
const Result: FC<IResultProps> = ({
isWorkflow,
isCallBatchAPI,
- isPC,
- isMobile,
+ isBelowMd,
appSourceType,
appId,
isError,
@@ -93,7 +91,7 @@ const Result: FC<IResultProps> = ({
controlSend,
inputs,
isCallBatchAPI,
- isPC,
+ isBelowMd,
isWorkflow,
notify,
onCompleted,
@@ -109,7 +107,7 @@ const Result: FC<IResultProps> = ({
const renderTextGenerationRes = () => (
<>
{!hideInlineStopButton && runState.isResponding && runState.currentTaskId && (
- <div className={`mb-3 flex ${isPC ? 'justify-end' : 'justify-center'}`}>
+ <div className={`mb-3 flex ${isBelowMd ? 'justify-center' : 'justify-end'}`}>
<Button variant="secondary" disabled={runState.isStopping} onClick={runState.handleStop}>
{runState.isStopping ? (
<span aria-hidden className="i-ri-loader-2-line h-3.5 w-3.5 animate-spin" />
@@ -135,7 +133,7 @@ const Result: FC<IResultProps> = ({
onFeedback={runState.handleFeedback}
feedback={runState.feedback}
onSave={handleSaveMessage}
- isMobile={isMobile}
+ isBelowMd={isBelowMd}
appSourceType={appSourceType}
installedAppId={appId}
// isLoading={isCallBatchAPI ? (!completionRes && isResponding) : false}
diff --git a/web/app/components/share/text-generation/run-batch/res-download/__tests__/index.spec.tsx b/web/app/components/share/text-generation/run-batch/res-download/__tests__/index.spec.tsx
index ed69e289bb0..23aaf3b64c7 100644
--- a/web/app/components/share/text-generation/run-batch/res-download/__tests__/index.spec.tsx
+++ b/web/app/components/share/text-generation/run-batch/res-download/__tests__/index.spec.tsx
@@ -8,7 +8,7 @@ afterEach(() => vi.restoreAllMocks())
it('downloads generated results with commas, quotes, and newlines preserved', async () => {
const user = userEvent.setup()
const downloads = captureDownloads()
- render(<ResDownload isMobile={false} values={[{ text: 'Hello, "world"\nNext line' }]} />)
+ render(<ResDownload compact={false} values={[{ text: 'Hello, "world"\nNext line' }]} />)
await user.click(screen.getByRole('button', { name: 'common.operation.download' }))
diff --git a/web/app/components/share/text-generation/run-batch/res-download/index.tsx b/web/app/components/share/text-generation/run-batch/res-download/index.tsx
index bbfa02da1f0..8d1f48b0281 100644
--- a/web/app/components/share/text-generation/run-batch/res-download/index.tsx
+++ b/web/app/components/share/text-generation/run-batch/res-download/index.tsx
@@ -8,11 +8,11 @@ import { useTranslation } from 'react-i18next'
import { useCSVDownloader } from 'react-papaparse'
type IResDownloadProps = {
- isMobile: boolean
+ compact: boolean
values: Record<string, string>[]
}
-const ResDownload: FC<IResDownloadProps> = ({ isMobile, values }) => {
+const ResDownload: FC<IResDownloadProps> = ({ compact, values }) => {
const { t } = useTranslation(['common'])
const { CSVDownloader, Type } = useCSVDownloader()
@@ -27,12 +27,12 @@ const ResDownload: FC<IResDownloadProps> = ({ isMobile, values }) => {
}}
data={values}
>
- {isMobile && (
+ {compact && (
<IconButton aria-label={t(($) => $['operation.download'], { ns: 'common' })}>
<RiDownloadLine aria-hidden="true" className="size-4" />
</IconButton>
)}
- {!isMobile && (
+ {!compact && (
<Button>
<RiDownloadLine className="size-4" />
<span>{t(($) => $['operation.download'], { ns: 'common' })}</span>
diff --git a/web/app/components/share/text-generation/text-generation-result-panel.tsx b/web/app/components/share/text-generation/text-generation-result-panel.tsx
index 4955a5d94d1..7a4449d6615 100644
--- a/web/app/components/share/text-generation/text-generation-result-panel.tsx
+++ b/web/app/components/share/text-generation/text-generation-result-panel.tsx
@@ -29,7 +29,7 @@ type TextGenerationResultPanelProps = {
handleSaveMessage: (messageId: string) => Promise<void>
inputs: Record<string, InputValueTypes>
isCallBatchAPI: boolean
- isPC: boolean
+ isBelowMd: boolean
isShowResultPanel: boolean
isWorkflow: boolean
moreLikeThisEnabled: boolean
@@ -62,7 +62,7 @@ const TextGenerationResultPanel: FC<TextGenerationResultPanelProps> = ({
handleSaveMessage,
inputs,
isCallBatchAPI,
- isPC,
+ isBelowMd,
isShowResultPanel,
isWorkflow,
moreLikeThisEnabled,
@@ -85,8 +85,7 @@ const TextGenerationResultPanel: FC<TextGenerationResultPanelProps> = ({
key={task?.id}
isWorkflow={isWorkflow}
isCallBatchAPI={isCallBatchAPI}
- isPC={isPC}
- isMobile={!isPC}
+ isBelowMd={isBelowMd}
appSourceType={appSourceType}
appId={appId}
isError={task?.status === TaskStatus.failed}
@@ -113,21 +112,21 @@ const TextGenerationResultPanel: FC<TextGenerationResultPanelProps> = ({
return (
<div
className={cn(
- isPC
- ? 'h-full w-0 grow'
- : isShowResultPanel
+ isBelowMd
+ ? isShowResultPanel
? 'fixed inset-0 z-50 bg-background-overlay backdrop-blur-xs'
: resultExisted
? 'relative h-16 shrink-0 overflow-hidden bg-background-default-burn pt-2.5'
- : '',
+ : ''
+ : 'h-full w-0 grow',
)}
>
- {!isPC && (
+ {isBelowMd && (
<div
className={cn(
isShowResultPanel
? 'flex items-center justify-center p-2 pt-6'
- : 'absolute top-0 left-0 z-10 flex w-full items-center justify-center px-2 pt-0.75 pb-14.25',
+ : 'absolute inset-s-0 top-0 z-10 flex w-full items-center justify-center px-2 pt-0.75 pb-14.25',
)}
onClick={() => {
if (isShowResultPanel) onHideResultPanel()
@@ -140,8 +139,8 @@ const TextGenerationResultPanel: FC<TextGenerationResultPanelProps> = ({
<div
className={cn(
'relative flex h-full flex-col',
- !isPC && 'h-[calc(100vh-36px)] rounded-t-2xl shadow-lg backdrop-blur-xs',
- !isPC
+ isBelowMd && 'h-[calc(100vh-36px)] rounded-t-2xl shadow-lg backdrop-blur-xs',
+ isBelowMd
? isShowResultPanel
? 'bg-background-default-burn'
: 'border-t-[0.5px] border-divider-regular bg-components-panel-bg'
@@ -152,21 +151,22 @@ const TextGenerationResultPanel: FC<TextGenerationResultPanelProps> = ({
<div
className={cn(
'flex shrink-0 items-center justify-between px-14 pt-9 pb-2',
- !isPC && 'px-4 pt-3 pb-1',
+ isBelowMd && 'px-4 pt-3 pb-1',
)}
>
<div className="system-md-semibold-uppercase text-text-primary">
{t(($) => $['generation.executions'], { ns: 'share', num: allTaskList.length })}
</div>
- {allSuccessTaskList.length > 0 && <ResDownload isMobile={!isPC} values={exportRes} />}
+ {allSuccessTaskList.length > 0 && (
+ <ResDownload compact={isBelowMd} values={exportRes} />
+ )}
</div>
)}
<div
className={cn(
'flex h-0 grow flex-col overflow-y-auto',
- isPC && 'px-14 py-8',
- isPC && isCallBatchAPI && 'pt-0',
- !isPC && 'p-0 pb-2',
+ isBelowMd ? 'p-0 pb-2' : 'px-14 py-8',
+ !isBelowMd && isCallBatchAPI && 'pt-0',
)}
>
{isCallBatchAPI ? showTaskList.map((task) => renderResult(task)) : renderResult()}
diff --git a/web/app/components/share/text-generation/text-generation-sidebar.tsx b/web/app/components/share/text-generation/text-generation-sidebar.tsx
index e4c68397a0d..3a22c0c354f 100644
--- a/web/app/components/share/text-generation/text-generation-sidebar.tsx
+++ b/web/app/components/share/text-generation/text-generation-sidebar.tsx
@@ -27,7 +27,7 @@ type TextGenerationSidebarProps = {
inputs: Record<string, InputValueTypes>
inputsRef: RefObject<Record<string, InputValueTypes>>
isInstalledApp: boolean
- isPC: boolean
+ isBelowMd: boolean
isWorkflow: boolean
onBatchSend: (data: string[][]) => void
onInputsChange: (inputs: Record<string, InputValueTypes>) => void
@@ -53,7 +53,7 @@ const TextGenerationSidebar: FC<TextGenerationSidebarProps> = ({
inputs,
inputsRef,
isInstalledApp,
- isPC,
+ isBelowMd,
isWorkflow,
onBatchSend,
onInputsChange,
@@ -83,20 +83,20 @@ const TextGenerationSidebar: FC<TextGenerationSidebarProps> = ({
onValueChange={onTabChange}
className={cn(
'relative flex h-full shrink-0 flex-col',
- isPC ? 'w-150 max-w-[50%]' : resultExisted ? 'h-[calc(100%-64px)]' : '',
- isInstalledApp && 'rounded-l-2xl',
+ isBelowMd ? (resultExisted ? 'h-[calc(100%-64px)]' : '') : 'w-150 max-w-[50%]',
+ isInstalledApp && 'rounded-s-2xl',
)}
>
<div
className={cn(
'shrink-0 space-y-4 border-b border-divider-subtle',
- isPC ? 'bg-components-panel-bg p-8 pb-0' : 'p-4 pb-0',
+ isBelowMd ? 'p-4 pb-0' : 'bg-components-panel-bg p-8 pb-0',
)}
>
<div className="flex items-center gap-3">
<AppIcon
fallback={{ content: '🤖', background: appDefaultIconBackground }}
- size={isPC ? 'large' : 'small'}
+ size={isBelowMd ? 'small' : 'large'}
icon={siteInfo}
/>
<div className="grow truncate system-md-semibold text-text-secondary">
@@ -145,16 +145,16 @@ const TextGenerationSidebar: FC<TextGenerationSidebarProps> = ({
)}
<TabsList className="w-full">
<TabsTab value="create">
- <span className="ml-2">{t(($) => $['generation.tabs.create'], { ns: 'share' })}</span>
+ <span className="ms-2">{t(($) => $['generation.tabs.create'], { ns: 'share' })}</span>
</TabsTab>
<TabsTab value="batch">
- <span className="ml-2">{t(($) => $['generation.tabs.batch'], { ns: 'share' })}</span>
+ <span className="ms-2">{t(($) => $['generation.tabs.batch'], { ns: 'share' })}</span>
</TabsTab>
{!isWorkflow && (
- <TabsTab value="saved" className="ml-auto">
+ <TabsTab value="saved" className="ms-auto">
<span aria-hidden className="i-ri-bookmark-3-line size-4" />
- <span className="ml-2">{t(($) => $['generation.tabs.saved'], { ns: 'share' })}</span>
- {savedMessages.length > 0 && <Badge className="ml-1">{savedMessages.length}</Badge>}
+ <span className="ms-2">{t(($) => $['generation.tabs.saved'], { ns: 'share' })}</span>
+ {savedMessages.length > 0 && <Badge className="ms-1">{savedMessages.length}</Badge>}
</TabsTab>
)}
</TabsList>
@@ -162,8 +162,8 @@ const TextGenerationSidebar: FC<TextGenerationSidebarProps> = ({
<div
className={cn(
'h-0 grow overflow-y-auto bg-components-panel-bg',
- isPC ? 'px-8' : 'px-4',
- !isPC &&
+ isBelowMd ? 'px-4' : 'px-8',
+ isBelowMd &&
resultExisted &&
customConfig?.remove_webapp_brand &&
'rounded-b-2xl border-b-[0.5px] border-divider-regular',
@@ -192,7 +192,7 @@ const TextGenerationSidebar: FC<TextGenerationSidebarProps> = ({
{!isWorkflow && (
<TabsPanel value="saved">
<SavedItems
- className={cn(isPC ? 'mt-6' : 'mt-4')}
+ className={cn(isBelowMd ? 'mt-4' : 'mt-6')}
isShowTextToSpeech={textToSpeechConfig?.enabled}
list={savedMessages}
onRemove={onRemoveSavedMessage}
@@ -205,8 +205,8 @@ const TextGenerationSidebar: FC<TextGenerationSidebarProps> = ({
<div
className={cn(
'flex shrink-0 items-center gap-1.5 bg-components-panel-bg py-3',
- isPC ? 'px-8' : 'px-4',
- !isPC && resultExisted && 'rounded-b-2xl border-b-[0.5px] border-divider-regular',
+ isBelowMd ? 'px-4' : 'px-8',
+ isBelowMd && resultExisted && 'rounded-b-2xl border-b-[0.5px] border-divider-regular',
)}
>
<div className="system-2xs-medium-uppercase text-text-tertiary">
diff --git a/web/test/fixtures/embedded-chatbot.ts b/web/test/fixtures/embedded-chatbot.ts
index bc419cfd2ab..f2349d2f7f4 100644
--- a/web/test/fixtures/embedded-chatbot.ts
+++ b/web/test/fixtures/embedded-chatbot.ts
@@ -21,7 +21,7 @@ export const createEmbeddedChatbotContextFixture = (
handleChangeConversation: noop,
handleNewConversationCompleted: noop,
chatShouldReloadKey: '',
- isMobile: false,
+ isBelowSm: false,
appSourceType: AppSourceType.webApp,
isInstalledApp: false,
allowResetChat: true,