Skip to content

Commit ec928a2

Browse files
committed
feat: dublicate text input on message itstelf on message edit
AdminForth/1786/ability-to-edit-agent-prompt-a
1 parent 47058be commit ec928a2

3 files changed

Lines changed: 57 additions & 22 deletions

File tree

custom/ChatFooter.vue

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -80,24 +80,11 @@
8080
/>
8181
<template v-if="!agentStore.isAudioChatMode">
8282
<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+
/>
10188
</template>
10289
<template v-else>
10390
<Button
@@ -128,7 +115,7 @@
128115
</template>
129116

130117
<script setup lang="ts">
131-
import { IconArrowUpOutline, IconAngleDownOutline, IconCloseOutline, IconCheckOutline } from '@iconify-prerendered/vue-flowbite';
118+
import { IconArrowUpOutline, IconAngleDownOutline } from '@iconify-prerendered/vue-flowbite';
132119
import { useTemplateRef, onMounted, ref, onUnmounted, watch, computed } from 'vue';
133120
import { onClickOutside } from '@vueuse/core'
134121
import { useAgentStore } from './composables/useAgentStore';
@@ -139,6 +126,7 @@ import { remToPx } from './utils';
139126
import MicrophoneButton from './speech_recognition_frontend/MicrophoneButon.vue';
140127
import SteerQueue from './SteerQueue.vue';
141128
import SteerDebugPanel from './SteerDebugPanel.vue';
129+
import EditActionButtons from './EditActionButtons.vue';
142130
143131
const props = defineProps<{
144132
meta: {

custom/EditActionButtons.vue

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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>

custom/conversation_area/TextRenderer.vue

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
@click="handleMarkdownLinkClick"
55
:class="[
66
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'
88
: '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' : ''
1010
]"
1111
>
1212
<IncremarkContent
1313
class="text-wrap break-words w-full max-w-full"
14-
v-if="content"
14+
v-if="content && !props.editMode"
1515
:key="renderNonce"
1616
:content="content"
1717
:is-finished="isFinished"
@@ -21,6 +21,18 @@
2121
<!-- <p v-else class="text-red-500 py-2">
2222
{{ $t('No content to render') }}
2323
</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+
/>
29+
<EditActionButtons
30+
class="mt-2 self-end"
31+
:confirm-disabled="!agentStore.trimmedUserMessage"
32+
@cancel="agentStore.cancelEditMessage"
33+
@confirm="agentStore.submitEditMessage"
34+
/>
35+
</template>
2436
</div>
2537
</template>
2638

@@ -31,6 +43,7 @@
3143
import { useAgentStore } from '../composables/useAgentStore';
3244
import { useCoreStore } from '@/stores/core';
3345
import type { IMessage } from '../types';
46+
import EditActionButtons from '../EditActionButtons.vue';
3447
3548
const props = defineProps<{
3649
message: string | undefined,

0 commit comments

Comments
 (0)