From bb451bb110afbf67f025aee2f7da0d6137248e02 Mon Sep 17 00:00:00 2001 From: hjlarry Date: Fri, 26 Jun 2026 17:15:53 +0800 Subject: [PATCH] fix: inputPlaceholderValue of frontend --- .../settings/__tests__/index.spec.tsx | 19 ++++++++++++++++--- .../app/overview/settings/index.tsx | 13 +++++++------ 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/web/app/components/app/overview/settings/__tests__/index.spec.tsx b/web/app/components/app/overview/settings/__tests__/index.spec.tsx index 48e536b1956..280b35c5437 100644 --- a/web/app/components/app/overview/settings/__tests__/index.spec.tsx +++ b/web/app/components/app/overview/settings/__tests__/index.spec.tsx @@ -309,7 +309,8 @@ describe('SettingsModal', () => { expect(screen.getByRole('textbox', { name: inputPlaceholderName })).toHaveValue('Updated prompt') }) - it('should disable the input placeholder for Cloud sandbox plans', () => { + it('should display paid webapp settings as defaults for Cloud sandbox plans', async () => { + mockOnSave.mockResolvedValueOnce(undefined) mockUseProviderContext.mockReturnValue({ ...baseProviderContextValue, enableBilling: true, @@ -317,14 +318,26 @@ describe('SettingsModal', () => { ...baseProviderContextValue.plan, type: Plan.sandbox, }, - webappCopyrightEnabled: false, + webappCopyrightEnabled: true, }) renderSettingsModal() fireEvent.click(screen.getByText('appOverview.overview.appInfo.settings.more.entry')) - expect(screen.getByRole('textbox', { name: inputPlaceholderName })).toBeDisabled() + const inputPlaceholder = screen.getByRole('textbox', { name: inputPlaceholderName }) + expect(inputPlaceholder).toBeDisabled() + expect(inputPlaceholder).toHaveValue('') + expect(screen.queryByPlaceholderText('appOverview.overview.appInfo.settings.more.copyRightPlaceholder')).not.toBeInTheDocument() + + fireEvent.click(screen.getByText('common.operation.save')) + + await waitFor(() => { + expect(mockOnSave).toHaveBeenCalledWith(expect.objectContaining({ + copyright: '', + input_placeholder: '', + })) + }) }) it('should keep the input placeholder editable when billing is disabled', async () => { diff --git a/web/app/components/app/overview/settings/index.tsx b/web/app/components/app/overview/settings/index.tsx index ca93ddd54b1..5c1a52304ef 100644 --- a/web/app/components/app/overview/settings/index.tsx +++ b/web/app/components/app/overview/settings/index.tsx @@ -157,7 +157,8 @@ const SettingsModal: FC = ({ const inputPlaceholderLabelId = React.useId() const inputPlaceholderDescriptionId = React.useId() - const inputPlaceholderValue = inputInfo.inputPlaceholder ?? '' + const inputPlaceholderValue = isCloudSandboxPlan ? '' : (inputInfo.inputPlaceholder ?? '') + const copyrightSwitchValue = isCloudSandboxPlan ? false : inputInfo.copyrightSwitchValue // Editable + has value + blurred -> preview as gray placeholder text (matches how it'll render in chat). const showInputPlaceholderPreview = !isCloudSandboxPlan && inputPlaceholderValue.trim().length > 0 && !inputPlaceholderFocused const inputPlaceholderField = ( @@ -263,9 +264,9 @@ const SettingsModal: FC = ({ chat_color_theme: inputInfo.chatColorTheme, chat_color_theme_inverted: inputInfo.chatColorThemeInverted, prompt_public: false, - copyright: !webappCopyrightEnabled + copyright: (!webappCopyrightEnabled || isCloudSandboxPlan) ? '' - : inputInfo.copyrightSwitchValue + : copyrightSwitchValue ? inputInfo.copyright : '', privacy_policy: inputInfo.privacyPolicy, @@ -501,7 +502,7 @@ const SettingsModal: FC = ({ {webappCopyrightEnabled ? ( setInputInfo({ ...inputInfo, copyrightSwitchValue: v })} /> ) @@ -512,7 +513,7 @@ const SettingsModal: FC = ({
setInputInfo({ ...inputInfo, copyrightSwitchValue: v })} />
@@ -525,7 +526,7 @@ const SettingsModal: FC = ({ )}

{t(`${prefixSettings}.more.copyrightTip`, { ns: 'appOverview' })}

- {inputInfo.copyrightSwitchValue && ( + {copyrightSwitchValue && (