Skip to content

Commit b445a8f

Browse files
fix editing promt not updating the promt
1 parent 27a4c74 commit b445a8f

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

src/client/components/ChatV2/ChatV2.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ export const ChatV2 = () => {
158158

159159
const handleSubmit = async (message: string, ignoreTokenUsageWarning: boolean) => {
160160
if (!userStatus) return
161-
// chatScroll.shouldScroll.current = true
162161
// chatScroll.autoScroll()
163162
const { usage, limit } = userStatus
164163
const tokenUsageExceeded = usage >= limit
@@ -197,6 +196,7 @@ export const ChatV2 = () => {
197196
setIsStreaming(true)
198197

199198
try {
199+
console.log('instructions are: ' + assistantInstructions)
200200
const { tokenUsageAnalysis, stream } = await getCompletionStream({
201201
assistantInstructions: assistantInstructions,
202202
messages: newMessages,

src/client/components/ChatV2/SettingsModal.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,20 @@ export const SettingsModal: React.FC<SettingsModalProps> = ({
125125
handleChangePrompt(urlPrompt)
126126
}
127127
}, [mandatoryPrompt, urlPrompt])
128-
128+
const handleClose = async () => {
129+
//handles if the user wants to update current promts
130+
if (activePrompt) {
131+
console.log('updating active promt')
132+
await promptSaveMutation.mutateAsync({ name: activePrompt.name, promptToSave: activePrompt })
133+
}
134+
//default promt is not a saved promt so this handles the change to it
135+
else if (instructionsInputFieldRef.current) {
136+
setAssistantInstructions(instructionsInputFieldRef.current.value)
137+
}
138+
setOpen(false)
139+
}
129140
return (
130-
<Modal open={open} onClose={() => setOpen(false)}>
141+
<Modal open={open} onClose={handleClose}>
131142
<Box
132143
sx={{
133144
position: 'absolute',
@@ -149,7 +160,7 @@ export const SettingsModal: React.FC<SettingsModalProps> = ({
149160
}}
150161
>
151162
<IconButton
152-
onClick={() => setOpen(false)}
163+
onClick={handleClose}
153164
sx={{ position: 'absolute', top: 10, right: 20, color: 'grey.500', background: '#FFF', opacity: 0.9, zIndex: 1 }}
154165
id="close-settings"
155166
>
@@ -238,7 +249,7 @@ export const SettingsModal: React.FC<SettingsModalProps> = ({
238249
>
239250
{t('settings:resetDefault')}
240251
</OutlineButtonBlack>{' '}
241-
<BlueButton onClick={() => setOpen(false)}>OK</BlueButton>
252+
<BlueButton onClick={handleClose}>OK</BlueButton>
242253
</Box>
243254
<SaveMyPromptModal
244255
isOpen={myPromptModalOpen}

0 commit comments

Comments
 (0)