Skip to content

Commit 41b60fc

Browse files
authored
chore: show success toast when system prompt is updated (#7131)
Signed-off-by: shohidulbari <shohidulbari18@gmail.com>
1 parent cb81869 commit 41b60fc

File tree

1 file changed

+51
-34
lines changed

1 file changed

+51
-34
lines changed

core/http/views/chat.html

Lines changed: 51 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@
4242
<!-- Main container with sidebar toggle -->
4343
<div class="flex flex-1 overflow-hidden relative">
4444
<!-- Sidebar -->
45-
<div
45+
<div
4646
class="sidebar bg-[#1E293B] fixed top-16 bottom-0 left-0 w-64 transform transition-transform duration-300 ease-in-out z-30 border-r border-[#101827] overflow-y-auto"
4747
:class="sidebarOpen ? 'translate-x-0' : '-translate-x-full'">
48-
48+
4949
<div class="p-4 flex justify-between items-center border-b border-[#101827]">
5050
<h2 class="text-lg font-semibold text-[#E5E7EB]">Chat Settings</h2>
51-
<button
51+
<button
5252
@click="sidebarOpen = false"
5353
class="text-[#94A3B8] hover:text-[#E5E7EB] focus:outline-none">
5454
<i class="fa-solid fa-times"></i>
@@ -66,7 +66,7 @@ <h2 class="text-lg font-semibold text-[#E5E7EB]">Chat Settings</h2>
6666
onchange="window.location = this.value"
6767
>
6868
<option value="" disabled class="text-[#94A3B8]">Select a model</option>
69-
69+
7070
{{ range .ModelsConfig }}
7171
{{ $cfg := . }}
7272
{{ range .KnownUsecaseStrings }}
@@ -113,14 +113,14 @@ <h3 class="text-md font-medium">{{ $model }}</h3>
113113
<div x-data="{ activeTab: 'actions' }" class="space-y-4">
114114
<!-- Tab navigation -->
115115
<div class="flex border-b border-[#101827]">
116-
<button
117-
@click="activeTab = 'actions'"
116+
<button
117+
@click="activeTab = 'actions'"
118118
:class="activeTab === 'actions' ? 'border-b-2 border-[#38BDF8] text-[#E5E7EB]' : 'text-[#94A3B8] hover:text-[#E5E7EB]'"
119119
class="py-2 px-4 text-sm font-medium">
120120
Actions
121121
</button>
122-
<button
123-
@click="activeTab = 'settings'"
122+
<button
123+
@click="activeTab = 'settings'"
124124
:class="activeTab === 'settings' ? 'border-b-2 border-[#38BDF8] text-[#E5E7EB]' : 'text-[#94A3B8] hover:text-[#E5E7EB]'"
125125
class="py-2 px-4 text-sm font-medium">
126126
Settings
@@ -137,25 +137,25 @@ <h3 class="text-md font-medium">{{ $model }}</h3>
137137
>
138138
<i class="fa-solid fa-trash-can mr-2"></i> Clear chat
139139
</button>
140-
141-
<a
142-
href="https://localai.io/features/text-generation/"
140+
141+
<a
142+
href="https://localai.io/features/text-generation/"
143143
target="_blank"
144144
class="w-full flex items-center px-3 py-2 text-sm rounded text-white bg-gray-700 hover:bg-gray-600 transition-colors"
145145
>
146146
<i class="fas fa-book mr-2"></i> Documentation
147147
</a>
148-
149-
<a
150-
href="browse?term={{.Model}}"
148+
149+
<a
150+
href="browse?term={{.Model}}"
151151
class="w-full flex items-center px-3 py-2 text-sm rounded text-white bg-gray-700 hover:bg-gray-600 transition-colors"
152152
>
153153
<i class="fas fa-brain mr-2"></i> Browse Model
154154
</a>
155155
</div>
156156

157157
<!-- Settings tab -->
158-
<div x-show="activeTab === 'settings'" x-data="{ showPromptForm: false }" class="space-y-3">
158+
<div x-show="activeTab === 'settings'" x-data="{ showPromptForm: false }" class="space-y-3">
159159
{{ if $model }}
160160
{{ $galleryConfig:= index $allGalleryConfigs $model}}
161161
{{ if $galleryConfig }}
@@ -174,7 +174,7 @@ <h3 class="text-md font-medium">{{ $model }}</h3>
174174
<div class="w-11 h-6 bg-gray-600 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-blue-600"></div>
175175
</label>
176176
</div>
177-
177+
178178
<!-- MCP Mode Notification -->
179179
<div x-show="$store.chat.mcpMode" class="p-3 bg-blue-900/20 border border-blue-700/50 rounded text-blue-100 text-xs">
180180
<div class="flex items-start space-x-2">
@@ -188,17 +188,27 @@ <h3 class="text-md font-medium">{{ $model }}</h3>
188188
{{ end }}
189189
{{ end }}
190190
{{ end }}
191-
192-
<button
193-
@click="showPromptForm = !showPromptForm"
191+
192+
<button
193+
@click="showPromptForm = !showPromptForm"
194194
class="w-full flex items-center justify-between px-3 py-2 text-sm rounded text-white bg-gray-700 hover:bg-gray-600 transition-colors"
195195
>
196196
<span><i class="fa-solid fa-message mr-2"></i> System Prompt</span>
197197
<i :class="showPromptForm ? 'fa-chevron-up' : 'fa-chevron-down'" class="fa-solid"></i>
198198
</button>
199-
200-
<div x-show="showPromptForm" class="p-3 bg-gray-700 rounded">
201-
<form id="system_prompt" class="flex flex-col space-y-2">
199+
200+
<div x-show="showPromptForm" x-data="{
201+
showToast: false,
202+
previousPrompt: $store.chat.systemPrompt,
203+
isUpdated() {
204+
if (this.previousPrompt !== $store.chat.systemPrompt) {
205+
this.showToast = true;
206+
this.previousPrompt = $store.chat.systemPrompt;
207+
setTimeout(() => {this.showToast = false;}, 2000);
208+
}
209+
}
210+
}" class="p-3 bg-gray-700 rounded">
211+
<form id="system_prompt" @submit.prevent="isUpdated" class="flex flex-col space-y-2">
202212
<textarea
203213
type="text"
204214
id="systemPrompt"
@@ -207,6 +217,13 @@ <h3 class="text-md font-medium">{{ $model }}</h3>
207217
placeholder="System prompt"
208218
x-model.lazy="$store.chat.systemPrompt"
209219
></textarea>
220+
<div
221+
x-show="showToast"
222+
x-transition
223+
class="mb-2 text-green-500 px-4 py-2 text-sm text-center"
224+
>
225+
System prompt updated!
226+
</div>
210227
<button
211228
type="submit"
212229
class="px-3 py-2 text-sm rounded text-white bg-blue-600 hover:bg-blue-700 transition-colors"
@@ -221,21 +238,21 @@ <h3 class="text-md font-medium">{{ $model }}</h3>
221238
</div>
222239

223240
<!-- Main chat container (shifts with sidebar) -->
224-
<div
241+
<div
225242
class="flex-1 flex flex-col transition-all duration-300 ease-in-out"
226243
:class="sidebarOpen ? 'ml-64' : 'ml-0'">
227-
244+
228245
<!-- Chat header with toggle button -->
229246
<div class="border-b border-gray-700 p-4 flex items-center">
230247
<!-- Sidebar toggle button moved to be the first element in the header and with clear styling -->
231-
<button
232-
@click="sidebarOpen = !sidebarOpen"
248+
<button
249+
@click="sidebarOpen = !sidebarOpen"
233250
class="mr-4 text-gray-300 hover:text-white focus:outline-none bg-gray-800 hover:bg-gray-700 p-2 rounded"
234251
style="min-width: 36px;"
235252
title="Toggle settings">
236253
<i class="fa-solid" :class="sidebarOpen ? 'fa-times' : 'fa-bars'"></i>
237254
</button>
238-
255+
239256
<div class="flex items-center">
240257
<i class="fa-solid fa-comments mr-2"></i>
241258
{{ if $model }}
@@ -384,7 +401,7 @@ <h1 class="text-lg font-semibold">
384401
class="fa-solid fa-file text-gray-400 absolute right-28 top-4 text-lg p-2 hover:text-blue-400 transition-colors duration-200"
385402
title="Upload text, markdown or PDF file"
386403
></button>
387-
404+
388405
<!-- Send button and loader in the same position -->
389406
<div class="absolute right-3 top-4">
390407
<!-- Loader (hidden by default) -->
@@ -394,7 +411,7 @@ <h1 class="text-lg font-semibold">
394411
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
395412
</svg>
396413
</div>
397-
414+
398415
<!-- Send button -->
399416
<button
400417
id="send-button"
@@ -437,7 +454,7 @@ <h1 class="text-lg font-semibold">
437454
</div>
438455
</div>
439456
</div>
440-
457+
441458
<!-- Modal moved outside of sidebar to appear in center of page -->
442459
{{ if $model }}
443460
{{ $galleryConfig:= index $allGalleryConfigs $model}}
@@ -455,7 +472,7 @@ <h3 class="text-xl font-semibold text-gray-900 dark:text-white">{{ $model }}</h3
455472
<span class="sr-only">Close modal</span>
456473
</button>
457474
</div>
458-
475+
459476
<!-- Body -->
460477
<div class="p-4 md:p-5 space-y-4">
461478
<div class="flex justify-center items-center">
@@ -468,9 +485,9 @@ <h3 class="text-xl font-semibold text-gray-900 dark:text-white">{{ $model }}</h3
468485
{{range $galleryConfig.URLs}}
469486
<li><a href="{{ . }}" target="_blank">{{ . }}</a></li>
470487
{{end}}
471-
</ul>
488+
</ul>
472489
</div>
473-
490+
474491
<!-- Footer -->
475492
<div class="flex items-center p-4 md:p-5 border-t border-gray-200 rounded-b dark:border-gray-600">
476493
<button data-modal-hide="model-info-modal" class="py-2.5 px-5 ms-3 text-sm font-medium text-gray-900 focus:outline-none bg-white rounded-lg border border-gray-200 hover:bg-gray-100 hover:text-blue-700 focus:z-10 focus:ring-4 focus:ring-gray-100 dark:focus:ring-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700">
@@ -550,4 +567,4 @@ <h3 class="text-xl font-semibold text-gray-900 dark:text-white">{{ $model }}</h3
550567
});
551568
</script>
552569
</body>
553-
</html>
570+
</html>

0 commit comments

Comments
 (0)