mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
Design feedback
This commit is contained in:
parent
ae4d5f16f6
commit
8701c9489a
|
@ -2,7 +2,7 @@
|
||||||
import { useFileDialog } from '@vueuse/core';
|
import { useFileDialog } from '@vueuse/core';
|
||||||
import IconFilePlus from 'virtual:icons/mdi/filePlus';
|
import IconFilePlus from 'virtual:icons/mdi/filePlus';
|
||||||
import IconSend from 'virtual:icons/mdi/send';
|
import IconSend from 'virtual:icons/mdi/send';
|
||||||
import { computed, onMounted, onUnmounted, ref, unref } from 'vue';
|
import { computed, onMounted, onUnmounted, ref, unref, watch } from 'vue';
|
||||||
|
|
||||||
import { useI18n, useChat, useOptions } from '@n8n/chat/composables';
|
import { useI18n, useChat, useOptions } from '@n8n/chat/composables';
|
||||||
import { chatEventBus } from '@n8n/chat/event-buses';
|
import { chatEventBus } from '@n8n/chat/event-buses';
|
||||||
|
@ -26,6 +26,7 @@ const files = ref<FileList | null>(null);
|
||||||
const chatTextArea = ref<HTMLTextAreaElement | null>(null);
|
const chatTextArea = ref<HTMLTextAreaElement | null>(null);
|
||||||
const input = ref('');
|
const input = ref('');
|
||||||
const isSubmitting = ref(false);
|
const isSubmitting = ref(false);
|
||||||
|
const resizeObserver = ref<ResizeObserver | null>(null);
|
||||||
|
|
||||||
const isSubmitDisabled = computed(() => {
|
const isSubmitDisabled = computed(() => {
|
||||||
return input.value === '' || waitingForResponse.value || options.disabled?.value === true;
|
return input.value === '' || waitingForResponse.value || options.disabled?.value === true;
|
||||||
|
@ -76,14 +77,28 @@ onMounted(() => {
|
||||||
chatEventBus.on('setInputValue', setInputValue);
|
chatEventBus.on('setInputValue', setInputValue);
|
||||||
|
|
||||||
if (chatTextArea.value) {
|
if (chatTextArea.value) {
|
||||||
|
resizeObserver.value = new ResizeObserver((entries) => {
|
||||||
|
for (const entry of entries) {
|
||||||
|
if (entry.target === chatTextArea.value) {
|
||||||
adjustHeight({ target: chatTextArea.value } as unknown as Event);
|
adjustHeight({ target: chatTextArea.value } as unknown as Event);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Start observing the textarea
|
||||||
|
resizeObserver.value.observe(chatTextArea.value);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
chatEventBus.off('focusInput', focusChatInput);
|
chatEventBus.off('focusInput', focusChatInput);
|
||||||
chatEventBus.off('blurInput', blurChatInput);
|
chatEventBus.off('blurInput', blurChatInput);
|
||||||
chatEventBus.off('setInputValue', setInputValue);
|
chatEventBus.off('setInputValue', setInputValue);
|
||||||
|
|
||||||
|
if (resizeObserver.value) {
|
||||||
|
resizeObserver.value.disconnect();
|
||||||
|
resizeObserver.value = null;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function blurChatInput() {
|
function blurChatInput() {
|
||||||
|
@ -253,7 +268,7 @@ function adjustHeight(event: Event) {
|
||||||
display: flex;
|
display: flex;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 0.5rem;
|
right: 0.5rem;
|
||||||
top: 0;
|
bottom: 0;
|
||||||
}
|
}
|
||||||
.chat-input-send-button {
|
.chat-input-send-button {
|
||||||
height: var(--chat--textarea--height);
|
height: var(--chat--textarea--height);
|
||||||
|
|
|
@ -100,6 +100,11 @@ function toggleChat() {
|
||||||
function toggleLogs() {
|
function toggleLogs() {
|
||||||
canvasStore.setPanelOpen('logs', !isLogsOpen.value);
|
canvasStore.setPanelOpen('logs', !isLogsOpen.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function closeLogs() {
|
||||||
|
canvasStore.setPanelOpen('logs', false);
|
||||||
|
}
|
||||||
|
|
||||||
provide(ChatSymbol, chatConfig);
|
provide(ChatSymbol, chatConfig);
|
||||||
provide(ChatOptionsSymbol, chatOptions);
|
provide(ChatOptionsSymbol, chatOptions);
|
||||||
|
|
||||||
|
@ -170,33 +175,9 @@ watchEffect(() => {
|
||||||
</div>
|
</div>
|
||||||
</n8n-resize-wrapper>
|
</n8n-resize-wrapper>
|
||||||
<div v-if="isLogsOpen && connectedNode" :class="$style.logs">
|
<div v-if="isLogsOpen && connectedNode" :class="$style.logs">
|
||||||
<ChatLogsPanel :key="messages.length" :node="connectedNode" />
|
<ChatLogsPanel :key="messages.length" :node="connectedNode" @close="closeLogs" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div :class="$style.footer">
|
|
||||||
<n8n-button
|
|
||||||
type="secondary"
|
|
||||||
:active="isChatOpen"
|
|
||||||
outline
|
|
||||||
size="mini"
|
|
||||||
icon="comment"
|
|
||||||
@click="toggleChat"
|
|
||||||
>
|
|
||||||
Chat
|
|
||||||
</n8n-button>
|
|
||||||
<n8n-button
|
|
||||||
v-if="connectedNode"
|
|
||||||
type="tertiary"
|
|
||||||
:active="isLogsOpen"
|
|
||||||
outline
|
|
||||||
size="mini"
|
|
||||||
icon="tasks"
|
|
||||||
@click="toggleLogs"
|
|
||||||
>
|
|
||||||
Execution Logs
|
|
||||||
</n8n-button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</n8n-resize-wrapper>
|
</n8n-resize-wrapper>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -4,6 +4,10 @@ import { computed } from 'vue';
|
||||||
import RunDataAi from '@/components/RunDataAi/RunDataAi.vue';
|
import RunDataAi from '@/components/RunDataAi/RunDataAi.vue';
|
||||||
import { useWorkflowsStore } from '@/stores/workflows.store';
|
import { useWorkflowsStore } from '@/stores/workflows.store';
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
close: [];
|
||||||
|
}>();
|
||||||
|
|
||||||
const workflowsStore = useWorkflowsStore();
|
const workflowsStore = useWorkflowsStore();
|
||||||
|
|
||||||
const workflow = computed(() => workflowsStore.getCurrentWorkflow());
|
const workflow = computed(() => workflowsStore.getCurrentWorkflow());
|
||||||
|
@ -15,7 +19,17 @@ defineProps<{
|
||||||
<template>
|
<template>
|
||||||
<div :class="$style.logsWrapper" data-test-id="lm-chat-logs">
|
<div :class="$style.logsWrapper" data-test-id="lm-chat-logs">
|
||||||
<header :class="$style.logsHeader">
|
<header :class="$style.logsHeader">
|
||||||
|
<div class="meta">
|
||||||
Latest Logs <span v-if="node">from {{ node?.name }} node</span>
|
Latest Logs <span v-if="node">from {{ node?.name }} node</span>
|
||||||
|
</div>
|
||||||
|
<n8n-icon-button
|
||||||
|
:class="$style.close"
|
||||||
|
outline
|
||||||
|
icon="times"
|
||||||
|
type="secondary"
|
||||||
|
size="mini"
|
||||||
|
@click="emit('close')"
|
||||||
|
/>
|
||||||
</header>
|
</header>
|
||||||
<div :class="$style.logs">
|
<div :class="$style.logs">
|
||||||
<RunDataAi
|
<RunDataAi
|
||||||
|
@ -34,11 +48,19 @@ defineProps<{
|
||||||
.logsHeader {
|
.logsHeader {
|
||||||
font-size: var(--font-size-m);
|
font-size: var(--font-size-m);
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
|
height: 2.6875rem;
|
||||||
line-height: 18px;
|
line-height: 18px;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
border-bottom: 1px solid var(--color-foreground-base);
|
border-bottom: 1px solid var(--color-foreground-base);
|
||||||
padding: var(--spacing-xs);
|
padding: var(--spacing-xs);
|
||||||
background-color: var(--color-foreground-xlight);
|
background-color: var(--color-foreground-xlight);
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
.close {
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
> span {
|
> span {
|
||||||
font-size: var(--font-size-s);
|
font-size: var(--font-size-s);
|
||||||
|
|
|
@ -168,7 +168,7 @@ function copySessionId() {
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<div :class="$style.messagesInput">
|
<div :class="$style.messagesInput">
|
||||||
<div :class="$style.messagesHistory">
|
<div :class="$style.messagesHistory" v-if="pastChatMessages.length > 0">
|
||||||
<n8n-button
|
<n8n-button
|
||||||
title="Navigate to previous message"
|
title="Navigate to previous message"
|
||||||
icon="chevron-up"
|
icon="chevron-up"
|
||||||
|
@ -260,13 +260,14 @@ function copySessionId() {
|
||||||
}
|
}
|
||||||
|
|
||||||
.messagesInput {
|
.messagesInput {
|
||||||
--input-border-color: #4538a3;
|
--input-border-color: transparent;
|
||||||
--chat--input--border: none;
|
--chat--input--border: none;
|
||||||
|
|
||||||
--chat--input--border-radius: 1rem;
|
--chat--input--border-radius: 2rem;
|
||||||
--chat--input--send--button--background: transparent;
|
--chat--input--send--button--background: transparent;
|
||||||
--chat--input--send--button--color: var(--color-button-secondary-font);
|
--chat--input--send--button--color: var(--color-button-secondary-font);
|
||||||
--chat--input--send--button--color-hover: var(--color-primary);
|
// --chat--input--send--button--color-hover: var(--color-primary);
|
||||||
|
--chat--input--send--button--color: var(--color-primary);
|
||||||
--chat--input--border-active: var(--input-focus-border-color, var(--color-secondary));
|
--chat--input--border-active: var(--input-focus-border-color, var(--color-secondary));
|
||||||
--chat--files-spacing: var(--spacing-2xs) 0;
|
--chat--files-spacing: var(--spacing-2xs) 0;
|
||||||
--chat--input--background: transparent;
|
--chat--input--background: transparent;
|
||||||
|
@ -284,14 +285,25 @@ function copySessionId() {
|
||||||
display: flex;
|
display: flex;
|
||||||
background: var(--color-lm-chat-bot-background);
|
background: var(--color-lm-chat-bot-background);
|
||||||
border-radius: var(--chat--input--border-radius);
|
border-radius: var(--chat--input--border-radius);
|
||||||
|
transition: border-color 200ms ease-in-out;
|
||||||
border: var(--input-border-color, var(--border-color-base))
|
border: var(--input-border-color, var(--border-color-base))
|
||||||
var(--input-border-style, var(--border-style-base))
|
var(--input-border-style, var(--border-style-base))
|
||||||
var(--input-border-width, var(--border-width-base));
|
var(--input-border-width, var(--border-width-base));
|
||||||
|
|
||||||
|
&:focus-within {
|
||||||
|
--input-border-color: #4538a3;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.messagesHistory {
|
.messagesHistory {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
margin-top: var(--spacing-3xs);
|
justify-content: flex-end;
|
||||||
|
margin-bottom: var(--spacing-3xs);
|
||||||
|
|
||||||
|
button:first-child {
|
||||||
|
margin-top: var(--spacing-4xs);
|
||||||
|
margin-bottom: calc(-1 * var(--spacing-4xs));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -1,9 +1,17 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
export interface Props {
|
||||||
|
outline?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
defineProps<Props>();
|
||||||
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<N8nButton
|
<N8nButton
|
||||||
label="Chat"
|
label="Chat"
|
||||||
size="large"
|
size="large"
|
||||||
icon="comment"
|
icon="comment"
|
||||||
type="primary"
|
type="primary"
|
||||||
|
:outline="outline"
|
||||||
data-test-id="workflow-chat-button"
|
data-test-id="workflow-chat-button"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -329,7 +329,9 @@ export const useCanvasStore = defineStore('canvas', () => {
|
||||||
function setPanelOpen(panel: 'chat' | 'logs', isOpen: boolean) {
|
function setPanelOpen(panel: 'chat' | 'logs', isOpen: boolean) {
|
||||||
if (panel === 'chat') {
|
if (panel === 'chat') {
|
||||||
isChatPanelOpen.value = isOpen;
|
isChatPanelOpen.value = isOpen;
|
||||||
|
isLogsPanelOpen.value = isOpen;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (panel === 'logs') {
|
if (panel === 'logs') {
|
||||||
isLogsPanelOpen.value = isOpen;
|
isLogsPanelOpen.value = isOpen;
|
||||||
}
|
}
|
||||||
|
|
|
@ -248,6 +248,8 @@ const keyBindingsEnabled = computed(() => {
|
||||||
return !ndvStore.activeNode && uiStore.activeModals.length === 0;
|
return !ndvStore.activeNode && uiStore.activeModals.length === 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const isChatOpen = computed(() => canvasStore.isChatPanelOpen);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialization
|
* Initialization
|
||||||
*/
|
*/
|
||||||
|
@ -1203,7 +1205,7 @@ const chatTriggerNodePinnedData = computed(() => {
|
||||||
});
|
});
|
||||||
|
|
||||||
async function onOpenChat() {
|
async function onOpenChat() {
|
||||||
canvasStore.setPanelOpen('chat', true);
|
canvasStore.setPanelOpen('chat', !canvasStore.isChatPanelOpen);
|
||||||
|
|
||||||
const payload = {
|
const payload = {
|
||||||
workflow_id: workflowId.value,
|
workflow_id: workflowId.value,
|
||||||
|
@ -1624,7 +1626,11 @@ onBeforeUnmount(() => {
|
||||||
@mouseleave="onRunWorkflowButtonMouseLeave"
|
@mouseleave="onRunWorkflowButtonMouseLeave"
|
||||||
@click="onRunWorkflow"
|
@click="onRunWorkflow"
|
||||||
/>
|
/>
|
||||||
<CanvasChatButton v-if="containsChatTriggerNodes" @click="onOpenChat" />
|
<CanvasChatButton
|
||||||
|
v-if="containsChatTriggerNodes"
|
||||||
|
:outline="isChatOpen === false"
|
||||||
|
@click="onOpenChat"
|
||||||
|
/>
|
||||||
<CanvasStopCurrentExecutionButton
|
<CanvasStopCurrentExecutionButton
|
||||||
v-if="isStopExecutionButtonVisible"
|
v-if="isStopExecutionButtonVisible"
|
||||||
:stopping="isStoppingExecution"
|
:stopping="isStoppingExecution"
|
||||||
|
|
|
@ -512,6 +512,9 @@ export default defineComponent({
|
||||||
: (this.projectsStore.currentProject ?? this.projectsStore.personalProject);
|
: (this.projectsStore.currentProject ?? this.projectsStore.personalProject);
|
||||||
return getResourcePermissions(project?.scopes);
|
return getResourcePermissions(project?.scopes);
|
||||||
},
|
},
|
||||||
|
isChatOpen() {
|
||||||
|
return this.canvasStore.isChatPanelOpen;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
// Listen to route changes and load the workflow accordingly
|
// Listen to route changes and load the workflow accordingly
|
||||||
|
@ -4650,6 +4653,7 @@ export default defineComponent({
|
||||||
size="large"
|
size="large"
|
||||||
icon="comment"
|
icon="comment"
|
||||||
type="primary"
|
type="primary"
|
||||||
|
:outline="isChatOpen === false"
|
||||||
data-test-id="workflow-chat-button"
|
data-test-id="workflow-chat-button"
|
||||||
@click.stop="onOpenChat"
|
@click.stop="onOpenChat"
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Reference in a new issue