Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/n8n-io/n8n into execution…
Browse files Browse the repository at this point in the history
…s-count-component
  • Loading branch information
michael-radency committed Nov 1, 2024
2 parents 3312f9d + b137e13 commit 29b1b25
Show file tree
Hide file tree
Showing 33 changed files with 878 additions and 332 deletions.
16 changes: 8 additions & 8 deletions cypress/e2e/233-AI-switch-to-logs-on-error.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,14 @@ function createRunDataWithError(inputMessage: string) {
routine: 'InitPostgres',
} as unknown as Error,
} as ExecutionError,
metadata: {
subRun: [
{
node: 'Postgres Chat Memory',
runIndex: 0,
},
],
},
}),
createMockNodeExecutionData(AGENT_NODE_NAME, {
executionStatus: 'error',
Expand Down Expand Up @@ -124,14 +132,6 @@ function createRunDataWithError(inputMessage: string) {
description: 'Internal error',
message: 'Internal error',
} as unknown as ExecutionError,
metadata: {
subRun: [
{
node: 'Postgres Chat Memory',
runIndex: 0,
},
],
},
}),
];
}
Expand Down
6 changes: 3 additions & 3 deletions cypress/e2e/30-langchain.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,9 @@ describe('Langchain Integration', () => {
},
},
},
metadata: {
subRun: [{ node: AI_LANGUAGE_MODEL_OPENAI_CHAT_MODEL_NODE_NAME, runIndex: 0 }],
},
inputOverride: {
ai_languageModel: [
[
Expand Down Expand Up @@ -316,9 +319,6 @@ describe('Langchain Integration', () => {
jsonData: {
main: { output: 'Hi there! How can I assist you today?' },
},
metadata: {
subRun: [{ node: AI_LANGUAGE_MODEL_OPENAI_CHAT_MODEL_NODE_NAME, runIndex: 0 }],
},
}),
],
lastNodeExecuted: AGENT_NODE_NAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ const modelField: INodeProperties = {
type: 'options',
// eslint-disable-next-line n8n-nodes-base/node-param-options-type-unsorted-items
options: [
{
name: 'Claude 3.5 Sonnet(20241022)',
value: 'claude-3-5-sonnet-20241022',
},
{
name: 'Claude 3 Opus(20240229)',
value: 'claude-3-opus-20240229',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class ToolVectorStore implements INodeType {
name: 'name',
type: 'string',
default: '',
placeholder: 'e.g. state_of_union_address',
placeholder: 'e.g. company_knowledge_base',
validateType: 'string-alphanumeric',
description: 'Name of the vector store',
},
Expand All @@ -72,7 +72,7 @@ export class ToolVectorStore implements INodeType {
name: 'description',
type: 'string',
default: '',
placeholder: 'The most recent state of the Union address',
placeholder: 'Retrieves data about [insert information about your data here]...',
typeOptions: {
rows: 3,
},
Expand Down
36 changes: 36 additions & 0 deletions packages/cli/src/scaling/__tests__/publisher.service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,42 @@ describe('Publisher', () => {
JSON.stringify({ ...msg, senderId: hostId, selfSend: false, debounce: true }),
);
});

it('should not debounce `add-webhooks-triggers-and-pollers`', async () => {
const publisher = new Publisher(logger, redisClientService, instanceSettings);
const msg = mock<PubSub.Command>({ command: 'add-webhooks-triggers-and-pollers' });

await publisher.publishCommand(msg);

expect(client.publish).toHaveBeenCalledWith(
'n8n.commands',
JSON.stringify({
...msg,
_isMockObject: true,
senderId: hostId,
selfSend: true,
debounce: false,
}),
);
});

it('should not debounce `remove-triggers-and-pollers`', async () => {
const publisher = new Publisher(logger, redisClientService, instanceSettings);
const msg = mock<PubSub.Command>({ command: 'remove-triggers-and-pollers' });

await publisher.publishCommand(msg);

expect(client.publish).toHaveBeenCalledWith(
'n8n.commands',
JSON.stringify({
...msg,
_isMockObject: true,
senderId: hostId,
selfSend: true,
debounce: false,
}),
);
});
});

describe('publishWorkerResponse', () => {
Expand Down
7 changes: 5 additions & 2 deletions packages/cli/src/scaling/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { PubSub } from './pubsub/pubsub.types';

export const QUEUE_NAME = 'jobs';

export const JOB_TYPE_NAME = 'job';
Expand All @@ -11,7 +13,7 @@ export const WORKER_RESPONSE_PUBSUB_CHANNEL = 'n8n.worker-response';
/**
* Commands that should be sent to the sender as well, e.g. during workflow activation and
* deactivation in multi-main setup. */
export const SELF_SEND_COMMANDS = new Set([
export const SELF_SEND_COMMANDS = new Set<PubSub.Command['command']>([
'add-webhooks-triggers-and-pollers',
'remove-triggers-and-pollers',
]);
Expand All @@ -20,7 +22,8 @@ export const SELF_SEND_COMMANDS = new Set([
* Commands that should not be debounced when received, e.g. during webhook handling in
* multi-main setup.
*/
export const IMMEDIATE_COMMANDS = new Set([
export const IMMEDIATE_COMMANDS = new Set<PubSub.Command['command']>([
'add-webhooks-triggers-and-pollers',
'remove-triggers-and-pollers',
'relay-execution-lifecycle-event',
]);
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import CategorizedItemsRenderer from '../Renderers/CategorizedItemsRenderer.vue'
import type { IDataObject } from 'n8n-workflow';
import { useTelemetry } from '@/composables/useTelemetry';
import { useI18n } from '@/composables/useI18n';
import { useNodeCreatorStore } from '@/stores/nodeCreator.store';
const emit = defineEmits<{
nodeTypeSelected: [value: [actionKey: string, nodeName: string] | [nodeName: string]];
Expand All @@ -47,6 +48,8 @@ const {
actionsCategoryLocales,
} = useActions();
const nodeCreatorStore = useNodeCreatorStore();
// We only inject labels if search is empty
const parsedTriggerActions = computed(() =>
parseActions(actions.value, actionsCategoryLocales.value.triggers, false),
Expand Down Expand Up @@ -182,7 +185,7 @@ function trackActionsView() {
};
void useExternalHooks().run('nodeCreateList.onViewActions', trackingPayload);
telemetry?.trackNodesPanel('nodeCreateList.onViewActions', trackingPayload);
nodeCreatorStore.onViewActions(trackingPayload);
}
function resetSearch() {
Expand All @@ -206,7 +209,7 @@ function addHttpNode() {
void useExternalHooks().run('nodeCreateList.onActionsCustmAPIClicked', {
app_identifier,
});
telemetry?.trackNodesPanel('nodeCreateList.onActionsCustmAPIClicked', { app_identifier });
nodeCreatorStore.onActionsCustomAPIClicked({ app_identifier });
}
// Anonymous component to handle triggers and actions rendering order
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import ItemsRenderer from '../Renderers/ItemsRenderer.vue';
import CategorizedItemsRenderer from '../Renderers/CategorizedItemsRenderer.vue';
import NoResults from '../Panel/NoResults.vue';
import { useI18n } from '@/composables/useI18n';
import { useTelemetry } from '@/composables/useTelemetry';
import { getNodeIcon, getNodeIconColor, getNodeIconUrl } from '@/utils/nodeTypesUtils';
import { useUIStore } from '@/stores/ui.store';
Expand All @@ -36,11 +35,10 @@ const emit = defineEmits<{
}>();
const i18n = useI18n();
const telemetry = useTelemetry();
const uiStore = useUIStore();
const rootStore = useRootStore();
const { mergedNodes, actions } = useNodeCreatorStore();
const { mergedNodes, actions, onSubcategorySelected } = useNodeCreatorStore();
const { pushViewStack, popViewStack } = useViewStacks();
const { registerKeyHook } = useKeyboardNavigation();
Expand Down Expand Up @@ -83,7 +81,7 @@ function onSelected(item: INodeCreateElement) {
sections: item.properties.sections,
});
telemetry.trackNodesPanel('nodeCreateList.onSubcategorySelected', {
onSubcategorySelected({
subcategory: item.key,
});
}
Expand Down Expand Up @@ -153,9 +151,6 @@ function onSelected(item: INodeCreateElement) {
if (item.type === 'link') {
window.open(item.properties.url, '_blank');
telemetry.trackNodesPanel('nodeCreateList.onLinkSelected', {
link: item.properties.url,
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@ import SearchBar from './SearchBar.vue';
import ActionsRenderer from '../Modes/ActionsMode.vue';
import NodesRenderer from '../Modes/NodesMode.vue';
import { useI18n } from '@/composables/useI18n';
import { useDebounce } from '@/composables/useDebounce';
const i18n = useI18n();
const { callDebounced } = useDebounce();
const { mergedNodes } = useNodeCreatorStore();
const { pushViewStack, popViewStack, updateCurrentViewStack } = useViewStacks();
const { setActiveItemIndex, attachKeydownEvent, detachKeydownEvent } = useKeyboardNavigation();
const nodeCreatorStore = useNodeCreatorStore();
const activeViewStack = computed(() => useViewStacks().activeViewStack);
Expand Down Expand Up @@ -55,6 +58,19 @@ function onSearch(value: string) {
if (activeViewStack.value.uuid) {
updateCurrentViewStack({ search: value });
void setActiveItemIndex(getDefaultActiveIndex(value));
if (value.length) {
callDebounced(
nodeCreatorStore.onNodeFilterChanged,
{ trailing: true, debounceTime: 2000 },
{
newValue: value,
filteredNodes: activeViewStack.value.items ?? [],
filterMode: activeViewStack.value.rootView ?? 'Regular',
subcategory: activeViewStack.value.subcategory,
title: activeViewStack.value.title,
},
);
}
}
}
Expand Down Expand Up @@ -299,6 +315,7 @@ function onBackButton() {
margin-top: var(--spacing-4xs);
font-size: var(--font-size-s);
line-height: 19px;
color: var(--color-text-base);
font-weight: var(--font-weight-regular);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { useKeyboardNavigation } from '../composables/useKeyboardNavigation';
import { useViewStacks } from '../composables/useViewStacks';
import ItemsRenderer from './ItemsRenderer.vue';
import CategoryItem from '../ItemTypes/CategoryItem.vue';
import { useTelemetry } from '@/composables/useTelemetry';
import { useNodeCreatorStore } from '@/stores/nodeCreator.store';
export interface Props {
elements: INodeCreateElement[];
Expand All @@ -24,10 +24,10 @@ const props = withDefaults(defineProps<Props>(), {
elements: () => [],
});
const telemetry = useTelemetry();
const { popViewStack } = useViewStacks();
const { registerKeyHook } = useKeyboardNavigation();
const { workflowId } = useWorkflowsStore();
const nodeCreatorStore = useNodeCreatorStore();
const activeItemId = computed(() => useKeyboardNavigation()?.activeItemId);
const actionCount = computed(() => props.elements.filter(({ type }) => type === 'action').length);
Expand All @@ -38,10 +38,11 @@ function toggleExpanded() {
}
function setExpanded(isExpanded: boolean) {
const prev = expanded.value;
expanded.value = isExpanded;
if (expanded.value) {
telemetry.trackNodesPanel('nodeCreateList.onCategoryExpanded', {
if (expanded.value && !prev) {
nodeCreatorStore.onCategoryExpanded({
category_name: props.category,
workflow_id: workflowId,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,15 +332,19 @@ export const useActions = () => {
return storeWatcher;
}

function trackActionSelected(action: IUpdateInformation, telemetry: Telemetry, rootView: string) {
function trackActionSelected(
action: IUpdateInformation,
_telemetry: Telemetry,
rootView: string,
) {
const payload = {
node_type: action.key,
action: action.name,
source_mode: rootView.toLowerCase(),
resource: (action.value as INodeParameters).resource || '',
};
void useExternalHooks().run('nodeCreateList.addAction', payload);
telemetry?.trackNodesPanel('nodeCreateList.addAction', payload);
useNodeCreatorStore().onAddActions(payload);
}

return {
Expand Down
16 changes: 9 additions & 7 deletions packages/editor-ui/src/components/OutputPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,15 @@ const isTriggerNode = computed(() => {
});
const hasAiMetadata = computed(() => {
if (node.value) {
const resultData = workflowsStore.getWorkflowResultDataByNodeName(node.value.name);
if (isNodeRunning.value || !workflowRunData.value) {
return false;
}
if (!resultData || !Array.isArray(resultData) || resultData.length === 0) {
return false;
}
if (node.value) {
const connectedSubNodes = props.workflow.getParentNodes(node.value.name, 'ALL_NON_MAIN');
const resultData = connectedSubNodes.map(workflowsStore.getWorkflowResultDataByNodeName);
return !!resultData[resultData.length - 1].metadata;
return resultData && Array.isArray(resultData) && resultData.length > 0;
}
return false;
});
Expand Down Expand Up @@ -295,6 +296,7 @@ const activatePane = () => {
:block-u-i="blockUI"
:is-production-execution-preview="isProductionExecutionPreview"
:is-pane-active="isPaneActive"
:hide-pagination="outputMode === 'logs'"
pane-type="output"
:data-output-type="outputMode"
@activate-pane="activatePane"
Expand Down Expand Up @@ -368,7 +370,7 @@ const activatePane = () => {
</template>

<template v-if="outputMode === 'logs' && node" #content>
<RunDataAi :node="node" :run-index="runIndex" />
<RunDataAi :node="node" :run-index="runIndex" :workflow="workflow" />
</template>

<template #recovered-artificial-output-data>
Expand Down
5 changes: 5 additions & 0 deletions packages/editor-ui/src/components/RunData.vue
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ export default defineComponent({
type: Boolean,
default: false,
},
hidePagination: {
type: Boolean,
default: false,
},
},
setup(props) {
const ndvStore = useNDVStore();
Expand Down Expand Up @@ -1743,6 +1747,7 @@ export default defineComponent({
</div>
<div
v-if="
hidePagination === false &&
hasNodeRun &&
!hasRunError &&
displayMode !== 'binary' &&
Expand Down
Loading

0 comments on commit 29b1b25

Please sign in to comment.