@adminforth/agent 3.1.3 → 3.1.6
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.
|
@@ -1,52 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div
|
|
3
|
-
class="relative flex flex-col w-full group/msg"
|
|
4
|
-
@mouseenter="showEditButtonOnHover"
|
|
5
|
-
@mouseleave="hideEditButtonOnHover"
|
|
6
|
-
>
|
|
7
|
-
<div
|
|
8
|
-
v-if="showActionsBar"
|
|
9
|
-
class="absolute w-full h-[calc(100%+1.5rem)] pb-8"
|
|
10
|
-
/>
|
|
11
|
-
<Transition
|
|
12
|
-
enter-active-class="transition ease-out duration-200"
|
|
13
|
-
enter-from-class="opacity-0 scale-95"
|
|
14
|
-
enter-to-class="opacity-100 scale-100"
|
|
15
|
-
leave-active-class="transition ease-in duration-150"
|
|
16
|
-
leave-from-class="opacity-100 scale-100"
|
|
17
|
-
leave-to-class="opacity-0 scale-95"
|
|
18
|
-
>
|
|
19
|
-
<div
|
|
20
|
-
v-if="showActionsBar && showEditButton"
|
|
21
|
-
class="absolute flex top-full -mt-1 p-1 z-20"
|
|
22
|
-
:class="isUserMessage ? 'right-0 self-end mr-4' : 'left-0 self-start ml-4'"
|
|
23
|
-
@mouseenter="showEditButtonOnHover"
|
|
24
|
-
@mouseleave="hideEditButtonOnHover"
|
|
25
|
-
>
|
|
26
|
-
<Button
|
|
27
|
-
v-if="canCopy"
|
|
28
|
-
variant="ghost"
|
|
29
|
-
size="sm"
|
|
30
|
-
iconOnly
|
|
31
|
-
:title="$t('Copy message')"
|
|
32
|
-
:aria-label="$t('Copy message')"
|
|
33
|
-
@click="copyMessageToClipboard"
|
|
34
|
-
>
|
|
35
|
-
<IconCopy />
|
|
36
|
-
</Button>
|
|
37
|
-
<Button
|
|
38
|
-
v-if="canEdit"
|
|
39
|
-
variant="ghost"
|
|
40
|
-
size="sm"
|
|
41
|
-
iconOnly
|
|
42
|
-
:title="$t('Edit message')"
|
|
43
|
-
:aria-label="$t('Edit message')"
|
|
44
|
-
@click="agentStore.startEditMessage(message)"
|
|
45
|
-
>
|
|
46
|
-
<IconPencil />
|
|
47
|
-
</Button>
|
|
48
|
-
</div>
|
|
49
|
-
</Transition>
|
|
2
|
+
<div class="relative flex flex-col w-full group/msg">
|
|
50
3
|
<div
|
|
51
4
|
v-if="message.role === 'user' && message.metadata?.steer && !isBeingEditedTurn"
|
|
52
5
|
class="self-end mr-4 mb-0.5 text-xs italic text-lightInputPlaceholderText dark:text-darkInputPlaceholderText"
|
|
@@ -61,8 +14,11 @@
|
|
|
61
14
|
v-for="(part, index) in getMessageParts(message)"
|
|
62
15
|
:key="part.type"
|
|
63
16
|
>
|
|
17
|
+
<!-- a text part drops the margin of its last block, so a part that follows another one (the stream
|
|
18
|
+
splits the text at every chart and tool call) brings back the gap between markdown blocks -->
|
|
64
19
|
<TextRenderer
|
|
65
20
|
v-if="part.type === 'text' && !checkIfMessageSystemMessage(part.text ?? '') && shouldBeShownWhileEditing"
|
|
21
|
+
class="[&+&]:mt-2"
|
|
66
22
|
:message="isBeingEditedMessage ? agentStore.userMessageInput : part.text"
|
|
67
23
|
:role="props.message.role"
|
|
68
24
|
:editMode="isBeingEditedMessage"
|
|
@@ -77,7 +33,34 @@
|
|
|
77
33
|
:message="part.text"
|
|
78
34
|
/>
|
|
79
35
|
</template>
|
|
80
|
-
|
|
36
|
+
<div
|
|
37
|
+
v-if="reservesActionsRow"
|
|
38
|
+
class="flex h-7 opacity-0 transition-opacity duration-200 group-hover/msg:opacity-100 group-focus-within/msg:opacity-100"
|
|
39
|
+
:class="isUserMessage ? 'self-end mr-5' : 'self-start ml-5'"
|
|
40
|
+
>
|
|
41
|
+
<Button
|
|
42
|
+
v-if="canCopy"
|
|
43
|
+
variant="ghost"
|
|
44
|
+
size="sm"
|
|
45
|
+
iconOnly
|
|
46
|
+
:title="$t('Copy message')"
|
|
47
|
+
:aria-label="$t('Copy message')"
|
|
48
|
+
@click="copyMessageToClipboard"
|
|
49
|
+
>
|
|
50
|
+
<IconCopy />
|
|
51
|
+
</Button>
|
|
52
|
+
<Button
|
|
53
|
+
v-if="canEdit"
|
|
54
|
+
variant="ghost"
|
|
55
|
+
size="sm"
|
|
56
|
+
iconOnly
|
|
57
|
+
:title="$t('Edit message')"
|
|
58
|
+
:aria-label="$t('Edit message')"
|
|
59
|
+
@click="agentStore.startEditMessage(message)"
|
|
60
|
+
>
|
|
61
|
+
<IconPencil />
|
|
62
|
+
</Button>
|
|
63
|
+
</div>
|
|
81
64
|
</div>
|
|
82
65
|
|
|
83
66
|
</template>
|
|
@@ -86,7 +69,7 @@
|
|
|
86
69
|
|
|
87
70
|
|
|
88
71
|
<script setup lang="ts">
|
|
89
|
-
import { computed
|
|
72
|
+
import { computed } from 'vue';
|
|
90
73
|
import { IconCopy, IconPencil } from '@iconify-prerendered/vue-lucide';
|
|
91
74
|
import { Button } from '@/afcl';
|
|
92
75
|
import TextRenderer from './TextRenderer.vue';
|
|
@@ -106,7 +89,6 @@
|
|
|
106
89
|
|
|
107
90
|
const agentStore = useAgentStore();
|
|
108
91
|
const { alert } = useAdminforth();
|
|
109
|
-
const showEditButton = ref(false);
|
|
110
92
|
// A user message is editable once it carries a turnId (loaded from history or stamped
|
|
111
93
|
// after its turn finished). Steer sub-messages and other roles are never editable, and
|
|
112
94
|
// we hide the affordance entirely while another edit or a live turn is in flight.
|
|
@@ -137,29 +119,26 @@
|
|
|
137
119
|
const canCopy = computed(() =>
|
|
138
120
|
Boolean(copyableText.value.trim()) && !agentStore.isEditingMessage
|
|
139
121
|
);
|
|
140
|
-
const showActionsBar = computed(() =>
|
|
141
|
-
canEdit.value || (!isUserMessage.value && canCopy.value)
|
|
142
|
-
);
|
|
143
|
-
|
|
144
122
|
// While editing, hide only the *other* user messages of the edited turn (its steer
|
|
145
123
|
// sub-messages); the edited message itself and all non-user parts stay visible.
|
|
146
124
|
const shouldBeShownWhileEditing = computed(() =>
|
|
147
125
|
!(isBeingEditedTurn.value && isUserMessage.value && !isBeingEditedMessage.value)
|
|
148
126
|
);
|
|
149
127
|
|
|
128
|
+
// The row under the message is reserved by what the message is, not by hover or transient
|
|
129
|
+
// state (a turnId stamped after the turn, an edit in progress), so the buttons appearing
|
|
130
|
+
// never shift the chat or change its scroll height.
|
|
131
|
+
const reservesActionsRow = computed(() =>
|
|
132
|
+
shouldBeShownWhileEditing.value
|
|
133
|
+
&& Boolean(copyableText.value.trim())
|
|
134
|
+
&& (!isUserMessage.value || agentStore.editingEnabled)
|
|
135
|
+
);
|
|
136
|
+
|
|
150
137
|
function checkIfMessageSystemMessage(message: IMessage): boolean {
|
|
151
138
|
const isReserved = Object.values(RESERVED_SYSTEM_MESSAGE_CONTENT).includes(message as RESERVED_SYSTEM_MESSAGE_CONTENT);
|
|
152
139
|
return isReserved;
|
|
153
140
|
}
|
|
154
141
|
|
|
155
|
-
function showEditButtonOnHover() {
|
|
156
|
-
showEditButton.value = true;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
function hideEditButtonOnHover() {
|
|
160
|
-
showEditButton.value = false;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
142
|
function copyMessageToClipboard() {
|
|
164
143
|
navigator.clipboard.writeText(copyableText.value)
|
|
165
144
|
.then(() => {
|
|
@@ -25,22 +25,27 @@
|
|
|
25
25
|
/>
|
|
26
26
|
</button>
|
|
27
27
|
<transition name="expand">
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
<
|
|
41
|
-
|
|
28
|
+
<!-- no height cap: the grid row animates between 0fr and 1fr, so the output opens to its full height -->
|
|
29
|
+
<div v-if="isInputOutputExpanded" class="grid">
|
|
30
|
+
<div class="min-h-0 overflow-hidden">
|
|
31
|
+
<div class="pt-1.5 pb-1 pl-6 space-y-2">
|
|
32
|
+
<section
|
|
33
|
+
v-for="section in toolSections"
|
|
34
|
+
:key="section.label"
|
|
35
|
+
class="overflow-hidden rounded-default border border-lightCardBorder bg-lightCardBackground dark:border-darkCardBorder dark:bg-darkCardBackground"
|
|
36
|
+
>
|
|
37
|
+
<header class="border-b border-lightCardBorder px-2.5 py-1.5 text-xs font-medium text-lightInputIconColor dark:border-darkCardBorder dark:text-darkInputIconColor">
|
|
38
|
+
{{ section.label }}
|
|
39
|
+
</header>
|
|
40
|
+
<div class="select-all grid grid-cols-[auto,1fr] gap-x-3 gap-y-0.5 px-2.5 py-2 font-mono text-xs leading-5 text-lightTableText dark:text-darkTableText">
|
|
41
|
+
<template v-for="line in section.lines" :key="`${section.label}-${line.number}`">
|
|
42
|
+
<span class="text-[0.7rem] text-lightInputPlaceholderText dark:text-darkInputPlaceholderText select-none">{{ line.number }}</span>
|
|
43
|
+
<span class="whitespace-pre-wrap break-words">{{ line.content || ' ' }}</span>
|
|
44
|
+
</template>
|
|
45
|
+
</div>
|
|
46
|
+
</section>
|
|
42
47
|
</div>
|
|
43
|
-
</
|
|
48
|
+
</div>
|
|
44
49
|
</div>
|
|
45
50
|
</transition>
|
|
46
51
|
</li>
|
|
@@ -122,19 +127,19 @@
|
|
|
122
127
|
|
|
123
128
|
.expand-enter-active,
|
|
124
129
|
.expand-leave-active {
|
|
125
|
-
transition:
|
|
130
|
+
transition: grid-template-rows 300ms ease, opacity 300ms ease;
|
|
126
131
|
}
|
|
127
132
|
|
|
128
133
|
.expand-enter-from,
|
|
129
134
|
.expand-leave-to {
|
|
130
135
|
opacity: 0;
|
|
131
|
-
|
|
136
|
+
grid-template-rows: 0fr;
|
|
132
137
|
}
|
|
133
138
|
|
|
134
139
|
.expand-enter-to,
|
|
135
140
|
.expand-leave-from {
|
|
136
141
|
opacity: 1;
|
|
137
|
-
|
|
142
|
+
grid-template-rows: 1fr;
|
|
138
143
|
}
|
|
139
144
|
|
|
140
145
|
</style>
|