Skip to content

Commit 0c97b99

Browse files
committed
Add HTML error handling in AgentAIPromptSection and adjust styling in AIRulesSection
1 parent 84ab396 commit 0c97b99

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

src/pages/settings/Profile/AgentAIPromptSection.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ function AgentAIPromptSection({accountID, parentScrollViewRef}: AgentAIPromptSec
5656
const [isLoadingApp] = useOnyx(ONYXKEYS.IS_LOADING_APP);
5757
const [draftPrompt, setDraftPrompt] = useState('');
5858
const [showEmptyError, setShowEmptyError] = useState(false);
59+
const [showHtmlError, setShowHtmlError] = useState(false);
5960
const [showSavedConfirmation, setShowSavedConfirmation] = useState(false);
6061
const [isUserInitiatedSave, setIsUserInitiatedSave] = useState(false);
6162
const inputRef = useRef<BaseTextInputRef>(null);
@@ -70,7 +71,7 @@ function AgentAIPromptSection({accountID, parentScrollViewRef}: AgentAIPromptSec
7071
let errorText = '';
7172
if (showEmptyError) {
7273
errorText = translate('profilePage.aiPromptSection.promptCannotBeEmpty');
73-
} else if (hasHtmlTag) {
74+
} else if (showHtmlError && hasHtmlTag) {
7475
errorText = translate('common.error.invalidCharacter');
7576
}
7677
const storedPrompt = Str.htmlDecode(agentPrompt?.prompt ?? '');
@@ -166,6 +167,7 @@ function AgentAIPromptSection({accountID, parentScrollViewRef}: AgentAIPromptSec
166167
return;
167168
}
168169
if (containsHtmlTag(trimmed)) {
170+
setShowHtmlError(true);
169171
inputRef.current?.focus();
170172
return;
171173
}
@@ -186,6 +188,9 @@ function AgentAIPromptSection({accountID, parentScrollViewRef}: AgentAIPromptSec
186188
if (showEmptyError && text.trim()) {
187189
setShowEmptyError(false);
188190
}
191+
if (showHtmlError && !containsHtmlTag(text)) {
192+
setShowHtmlError(false);
193+
}
189194
};
190195

191196
const handleKeyPress = (e: TextInputKeyPressEvent) => {
@@ -227,7 +232,7 @@ function AgentAIPromptSection({accountID, parentScrollViewRef}: AgentAIPromptSec
227232
icon={showSavedConfirmation ? icons.Checkmark : undefined}
228233
onPress={handleSave}
229234
isLoading={isSaving && isUserInitiatedSave}
230-
isDisabled={hasHtmlTag || (isSaving && isUserInitiatedSave)}
235+
isDisabled={isSaving && isUserInitiatedSave}
231236
style={[styles.alignSelfStart]}
232237
testID="save-prompt-button"
233238
/>

src/pages/workspace/rules/AIRulesSection.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ function AIRulesSection({policyID, canWriteRules, showReadOnlyModal}: AIRulesSec
8080
<MenuItemWithTopDescription
8181
title={(rule.title ?? rule.prompt).replaceAll(/\s+/g, ' ').trim()}
8282
numberOfLinesTitle={1}
83-
wrapperStyle={[styles.borderedContentCard, styles.ph4, styles.pv4]}
83+
wrapperStyle={[styles.borderedContentCard, styles.ph4, styles.pv2]}
8484
shouldShowRightIcon
8585
onPress={() => {
8686
if (!canWriteRules) {

0 commit comments

Comments
 (0)