@adminforth/agent 2.3.3 → 2.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -25,6 +25,7 @@
25
25
  ]"
26
26
  :placeholder="placeholderText"
27
27
  @keydown.enter.exact.prevent="sendMessage"
28
+ @keydown.esc="onEscape"
28
29
  />
29
30
  <div class="flex items-center justify-between px-2 py-1">
30
31
  <div
@@ -74,30 +75,16 @@
74
75
  </div>
75
76
  </Transition>
76
77
  </div>
77
- <MicrophoneButton
78
- v-if="props.meta.hasAudioAdapter"
79
- v-show="!agentStore.isEditingMessage"
80
- />
78
+ <div v-if="props.meta.hasAudioAdapter" v-show="!agentStore.isEditingMessage" class="contents">
79
+ <MicrophoneButton />
80
+ </div>
81
81
  <template v-if="!agentStore.isAudioChatMode">
82
82
  <template v-if="agentStore.isEditingMessage">
83
- <div class="flex items-center gap-3">
84
- <Button
85
- variant="secondary"
86
- class="!p-0 h-7 w-7 mr-1 bg-red-600 text-white hover:bg-red-700 dark:bg-red-700 dark:hover:bg-red-800"
87
- title="Cancel edit"
88
- @click="cancelEdit"
89
- >
90
- <IconCloseOutline class="w-5 h-5" />
91
- </Button>
92
- <Button
93
- class="!p-0 h-7 w-7"
94
- title="Send edited message"
95
- @click="sendMessage"
96
- :disabled="!agentStore.trimmedUserMessage"
97
- >
98
- <IconCheckOutline class="w-6 h-6 text-white" />
99
- </Button>
100
- </div>
83
+ <EditActionButtons
84
+ :confirm-disabled="!agentStore.trimmedUserMessage"
85
+ @cancel="cancelEdit"
86
+ @confirm="sendMessage"
87
+ />
101
88
  </template>
102
89
  <template v-else>
103
90
  <Button
@@ -128,7 +115,7 @@
128
115
  </template>
129
116
 
130
117
  <script setup lang="ts">
131
- import { IconArrowUpOutline, IconAngleDownOutline, IconCloseOutline, IconCheckOutline } from '@iconify-prerendered/vue-flowbite';
118
+ import { IconArrowUpOutline, IconAngleDownOutline } from '@iconify-prerendered/vue-flowbite';
132
119
  import { useTemplateRef, onMounted, ref, onUnmounted, watch, computed } from 'vue';
133
120
  import { onClickOutside } from '@vueuse/core'
134
121
  import { useAgentStore } from './composables/useAgentStore';
@@ -139,6 +126,7 @@ import { remToPx } from './utils';
139
126
  import MicrophoneButton from './speech_recognition_frontend/MicrophoneButon.vue';
140
127
  import SteerQueue from './SteerQueue.vue';
141
128
  import SteerDebugPanel from './SteerDebugPanel.vue';
129
+ import EditActionButtons from './EditActionButtons.vue';
142
130
 
143
131
  const props = defineProps<{
144
132
  meta: {
@@ -234,6 +222,16 @@ function cancelEdit() {
234
222
  autoResize();
235
223
  }
236
224
 
225
+ // Esc discards an in-progress message edit; when not editing it does nothing so the
226
+ // keystroke keeps its default textarea behaviour.
227
+ function onEscape(event: KeyboardEvent) {
228
+ if (!agentStore.isEditingMessage) {
229
+ return;
230
+ }
231
+ event.preventDefault();
232
+ cancelEdit();
233
+ }
234
+
237
235
  function stopCurrentRequest() {
238
236
  agentStore.abortCurrentChatRequestAndAddSystemMessage();
239
237
  }
@@ -0,0 +1,34 @@
1
+ <template>
2
+ <div class="flex items-center gap-3">
3
+ <Button
4
+ variant="secondary"
5
+ class="!p-0 h-7 w-7 mr-1 bg-red-600 text-white hover:bg-red-700 dark:bg-red-700 dark:hover:bg-red-800"
6
+ title="Cancel edit"
7
+ @click="emit('cancel')"
8
+ >
9
+ <IconCloseOutline class="w-5 h-5" />
10
+ </Button>
11
+ <Button
12
+ class="!p-0 h-7 w-7"
13
+ title="Send edited message"
14
+ :disabled="confirmDisabled"
15
+ @click="emit('confirm')"
16
+ >
17
+ <IconCheckOutline class="w-6 h-6 text-white" />
18
+ </Button>
19
+ </div>
20
+ </template>
21
+
22
+ <script setup lang="ts">
23
+ import { IconCloseOutline, IconCheckOutline } from '@iconify-prerendered/vue-flowbite';
24
+ import { Button } from '@/afcl';
25
+
26
+ defineProps<{
27
+ confirmDisabled?: boolean;
28
+ }>();
29
+
30
+ const emit = defineEmits<{
31
+ (e: 'cancel'): void;
32
+ (e: 'confirm'): void;
33
+ }>();
34
+ </script>
@@ -4,14 +4,14 @@
4
4
  @click="handleMarkdownLinkClick"
5
5
  :class="[
6
6
  hasVegaLite ? 'w-full my-2' : 'm-2',
7
- props.role === 'user' ? 'bg-lightListTableHeading dark:bg-darkListTableHeading self-end max-w-[80%] mr-4'
7
+ props.role === 'user' ? 'bg-lightListTableHeading dark:bg-darkListTableHeading self-end max-w-[80%] mr-4'
8
8
  : 'border-none self-start max-w-full',
9
- props.editMode ? 'ring-2 ring-lightPrimary dark:ring-darkPrimary w-full max-w-[calc(100%-2rem)]' : ''
9
+ props.editMode ? 'ring-2 ring-lightPrimary dark:ring-darkPrimary w-full max-w-[calc(100%-2rem)] flex-col items-stretch py-3' : ''
10
10
  ]"
11
11
  >
12
12
  <IncremarkContent
13
13
  class="text-wrap break-words w-full max-w-full"
14
- v-if="content"
14
+ v-if="content && !props.editMode"
15
15
  :key="renderNonce"
16
16
  :content="content"
17
17
  :is-finished="isFinished"
@@ -21,6 +21,19 @@
21
21
  <!-- <p v-else class="text-red-500 py-2">
22
22
  {{ $t('No content to render') }}
23
23
  </p> -->
24
+ <template v-if="props.editMode">
25
+ <textarea
26
+ v-model="agentStore.userMessageInput"
27
+ class="w-full min-h-24 resize-y bg-transparent text-sm text-gray-900 dark:text-gray-100 border-none focus:outline-none focus:ring-0 p-0"
28
+ @keydown.esc.prevent="agentStore.cancelEditMessage"
29
+ />
30
+ <EditActionButtons
31
+ class="mt-2 self-end"
32
+ :confirm-disabled="!agentStore.trimmedUserMessage"
33
+ @cancel="agentStore.cancelEditMessage"
34
+ @confirm="agentStore.submitEditMessage"
35
+ />
36
+ </template>
24
37
  </div>
25
38
  </template>
26
39
 
@@ -31,6 +44,7 @@
31
44
  import { useAgentStore } from '../composables/useAgentStore';
32
45
  import { useCoreStore } from '@/stores/core';
33
46
  import type { IMessage } from '../types';
47
+ import EditActionButtons from '../EditActionButtons.vue';
34
48
 
35
49
  const props = defineProps<{
36
50
  message: string | undefined,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/agent",
3
- "version": "2.3.3",
3
+ "version": "2.4.1",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",