mirror of
https://github.com/n8n-io/n8n
synced 2026-04-21 15:47:20 +00:00
feat: Removes computer use setup logic on Assistant AI opt-in flow and minor UX changes (no-changelog) (#28679)
This commit is contained in:
parent
d179f667c0
commit
d14f2546a1
2 changed files with 84 additions and 367 deletions
|
|
@ -4228,7 +4228,7 @@
|
|||
"settings.n8nAgent.enable.label": "Enable AI Assistant",
|
||||
"settings.n8nAgent.enable.description": "Enables the feature for all users in the instance",
|
||||
"settings.n8nAgent.computerUse.label": "Enable Computer Use for AI Assistant",
|
||||
"settings.n8nAgent.computerUse.description": "Allows users on this instance to connect AI Assistant to their computer to work with files, shell and browser",
|
||||
"settings.n8nAgent.computerUse.description": "Allows users on this instance to connect AI Assistant to their computer to work with files and the browser",
|
||||
"settings.n8nAgent.computerUse.disabled.warning": "Computer use has been disabled by your administrator",
|
||||
"settings.n8nAgent.permissions.title": "Permissions",
|
||||
"settings.n8nAgent.permissions.description": "Control which actions need approval before agent executes them. These settings don't grant users any extra permissions",
|
||||
|
|
|
|||
|
|
@ -1,141 +1,67 @@
|
|||
<script lang="ts" setup>
|
||||
import { computed, ref, onUnmounted, onMounted, watch } from 'vue';
|
||||
import { computed, ref, onMounted, watch } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { N8nButton, N8nHeading, N8nIcon, N8nIconButton, N8nText } from '@n8n/design-system';
|
||||
import { N8nButton, N8nHeading, N8nIcon, N8nText } from '@n8n/design-system';
|
||||
import { ElCheckbox } from 'element-plus';
|
||||
import { useI18n } from '@n8n/i18n';
|
||||
import Modal from '@/app/components/Modal.vue';
|
||||
import { useUIStore } from '@/app/stores/ui.store';
|
||||
import { usePushConnectionStore } from '@/app/stores/pushConnection.store';
|
||||
import { useTelemetry } from '@/app/composables/useTelemetry';
|
||||
import { useInstanceAiSettingsStore } from '../instanceAiSettings.store';
|
||||
import { canManageInstanceAi } from '../instanceAiPermissions';
|
||||
import MacOsIcon from '../assets/os-icons/macos-icon.svg';
|
||||
import WindowsIcon from '../assets/os-icons/windows-icon.svg';
|
||||
import LinuxIcon from '../assets/os-icons/linux-icon.svg';
|
||||
import { INSTANCE_AI_VIEW } from '../constants';
|
||||
|
||||
const props = defineProps<{ modalName: string }>();
|
||||
|
||||
const router = useRouter();
|
||||
const i18n = useI18n();
|
||||
const uiStore = useUIStore();
|
||||
const pushConnectionStore = usePushConnectionStore();
|
||||
const telemetry = useTelemetry();
|
||||
const instanceAiSettingsStore = useInstanceAiSettingsStore();
|
||||
|
||||
const choice = ref<'enable' | 'disable' | null>(null);
|
||||
const computerUseEnabled = ref(!(instanceAiSettingsStore.settings?.localGatewayDisabled ?? true));
|
||||
const isEnabled = computed(() => choice.value === 'enable');
|
||||
const hasChosen = computed(() => choice.value !== null);
|
||||
const isSaving = ref(false);
|
||||
const step = ref<'intro' | 'gateway'>('intro');
|
||||
const selectedOs = ref<'mac' | 'windows' | 'linux'>('mac');
|
||||
|
||||
const osTabs = [
|
||||
{
|
||||
id: 'mac' as const,
|
||||
labelKey: 'instanceAi.welcomeModal.gateway.os.mac' as const,
|
||||
icon: MacOsIcon,
|
||||
},
|
||||
{
|
||||
id: 'windows' as const,
|
||||
labelKey: 'instanceAi.welcomeModal.gateway.os.windows' as const,
|
||||
icon: WindowsIcon,
|
||||
},
|
||||
{
|
||||
id: 'linux' as const,
|
||||
labelKey: 'instanceAi.welcomeModal.gateway.os.linux' as const,
|
||||
icon: LinuxIcon,
|
||||
},
|
||||
];
|
||||
|
||||
const displayCommand = computed(
|
||||
() => instanceAiSettingsStore.setupCommand ?? 'npx @n8n/computer-use',
|
||||
);
|
||||
|
||||
const copyCommandAriaLabel = computed(() =>
|
||||
copied.value ? i18n.baseText('generic.copiedToClipboard') : i18n.baseText('generic.copy'),
|
||||
);
|
||||
|
||||
const isScrolledToEnd = ref(false);
|
||||
|
||||
function onCommandScroll(e: Event) {
|
||||
const el = e.target as HTMLElement;
|
||||
isScrolledToEnd.value = el.scrollLeft + el.clientWidth >= el.scrollWidth - 1;
|
||||
}
|
||||
const copied = ref(false);
|
||||
|
||||
const terminalInstructionsKey = computed(() => {
|
||||
if (selectedOs.value === 'windows') return 'instanceAi.welcomeModal.gateway.instructions.windows';
|
||||
if (selectedOs.value === 'linux') return 'instanceAi.welcomeModal.gateway.instructions.linux';
|
||||
return 'instanceAi.welcomeModal.gateway.instructions.mac';
|
||||
});
|
||||
|
||||
async function selectChoice(value: 'enable' | 'disable') {
|
||||
function selectChoice(value: 'enable' | 'disable') {
|
||||
if (isSaving.value) return;
|
||||
choice.value = value;
|
||||
}
|
||||
|
||||
function dismiss() {
|
||||
telemetry.track('AI Assistant opt-in modal dismissed', {
|
||||
choice: choice?.value,
|
||||
});
|
||||
uiStore.closeModal(props.modalName);
|
||||
}
|
||||
|
||||
async function onConfirm() {
|
||||
if (isSaving.value) return;
|
||||
isSaving.value = true;
|
||||
try {
|
||||
await instanceAiSettingsStore.persistEnabled(value === 'enable');
|
||||
instanceAiSettingsStore.setField('enabled', choice.value === 'enable');
|
||||
if (isEnabled.value) {
|
||||
instanceAiSettingsStore.setField('localGatewayDisabled', !computerUseEnabled.value);
|
||||
}
|
||||
await instanceAiSettingsStore.save();
|
||||
telemetry.track('AI Assistant opt-in modal choice confirmed', {
|
||||
choice: choice?.value,
|
||||
enabled: isEnabled?.value,
|
||||
});
|
||||
void instanceAiSettingsStore.persistOptinModalDismissed();
|
||||
dismiss();
|
||||
if (isEnabled.value) {
|
||||
void router.push({ name: INSTANCE_AI_VIEW });
|
||||
}
|
||||
} finally {
|
||||
isSaving.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function dismiss() {
|
||||
telemetry.track('n8n Agent opt-in modal dismissed', {
|
||||
step: step?.value,
|
||||
choice: choice?.value,
|
||||
gatewayConnected: instanceAiSettingsStore?.isGatewayConnected,
|
||||
});
|
||||
uiStore.closeModal(props.modalName);
|
||||
}
|
||||
|
||||
function goToGatewayStep() {
|
||||
step.value = 'gateway';
|
||||
pushConnectionStore.pushConnect();
|
||||
void instanceAiSettingsStore.fetchSetupCommand();
|
||||
instanceAiSettingsStore.startGatewayPushListener();
|
||||
telemetry.track('n8n Agent opt-in modal gateway step entered', {
|
||||
choice: choice.value,
|
||||
});
|
||||
}
|
||||
|
||||
function onGatewayStepCompleted() {
|
||||
telemetry.track('n8n Agent opt-in modal gateway step completed', {
|
||||
choice: choice?.value,
|
||||
gatewayConnected: instanceAiSettingsStore?.isGatewayConnected,
|
||||
skipped: !instanceAiSettingsStore?.isGatewayConnected,
|
||||
selectedOs: selectedOs.value,
|
||||
});
|
||||
dismiss();
|
||||
if (isEnabled.value) {
|
||||
void router.push('/instance-ai');
|
||||
}
|
||||
}
|
||||
|
||||
function onStep1Confirm() {
|
||||
telemetry.track('n8n Agent opt-in modal choice confirmed', {
|
||||
choice: choice?.value,
|
||||
enabled: isEnabled?.value,
|
||||
});
|
||||
void instanceAiSettingsStore.persistOptinModalDismissed();
|
||||
if (isEnabled.value) {
|
||||
goToGatewayStep();
|
||||
} else {
|
||||
dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
async function copyCommand() {
|
||||
if (!instanceAiSettingsStore.setupCommand) return;
|
||||
try {
|
||||
await navigator.clipboard.writeText(instanceAiSettingsStore.setupCommand);
|
||||
copied.value = true;
|
||||
setTimeout(() => {
|
||||
copied.value = false;
|
||||
}, 2000);
|
||||
} catch {
|
||||
// Ignore clipboard errors
|
||||
}
|
||||
function handleComputerUseToggle() {
|
||||
computerUseEnabled.value = !computerUseEnabled.value;
|
||||
}
|
||||
|
||||
watch(
|
||||
|
|
@ -152,26 +78,20 @@ onMounted(() => {
|
|||
uiStore.closeModal(props.modalName);
|
||||
return;
|
||||
}
|
||||
telemetry.track('n8n Agent opt-in modal shown');
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
instanceAiSettingsStore.stopGatewayPushListener();
|
||||
pushConnectionStore.pushDisconnect();
|
||||
telemetry.track('AI Assistant opt-in modal shown');
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal
|
||||
:name="props.modalName"
|
||||
:show-close="step === 'gateway'"
|
||||
:close-on-click-modal="false"
|
||||
:close-on-press-escape="step === 'gateway'"
|
||||
:close-on-press-escape="false"
|
||||
custom-class="instance-ai-welcome-modal"
|
||||
width="540"
|
||||
>
|
||||
<template #content>
|
||||
<div v-if="step === 'intro'" :class="$style.body">
|
||||
<div :class="$style.body">
|
||||
<div :class="$style.heroIcon">
|
||||
<N8nIcon icon="sparkles" :size="34" color="text-base" />
|
||||
</div>
|
||||
|
|
@ -247,6 +167,22 @@ onUnmounted(() => {
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="isEnabled" :class="$style.computerUseRow" @click="handleComputerUseToggle">
|
||||
<ElCheckbox
|
||||
:class="$style.computerUseCheckbox"
|
||||
:model-value="computerUseEnabled"
|
||||
data-test-id="instance-ai-welcome-modal-computer-use-toggle"
|
||||
/>
|
||||
<div :class="$style.computerUseLabels">
|
||||
<N8nText bold size="medium">
|
||||
{{ i18n.baseText('settings.n8nAgent.computerUse.label') }}
|
||||
</N8nText>
|
||||
<N8nText size="small" color="text-light">
|
||||
{{ i18n.baseText('settings.n8nAgent.computerUse.description') }}
|
||||
</N8nText>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div :class="$style.footer">
|
||||
<N8nText size="small" color="text-light" :class="$style.disclaimer">
|
||||
{{ i18n.baseText('instanceAi.welcomeModal.disclaimer') }}
|
||||
|
|
@ -258,6 +194,7 @@ onUnmounted(() => {
|
|||
variant="solid"
|
||||
size="large"
|
||||
:disabled="!hasChosen || isSaving"
|
||||
:loading="isSaving"
|
||||
:label="
|
||||
isEnabled
|
||||
? i18n.baseText('instanceAi.welcomeModal.enable')
|
||||
|
|
@ -265,82 +202,7 @@ onUnmounted(() => {
|
|||
"
|
||||
:class="$style.continueButton"
|
||||
data-test-id="instance-ai-welcome-modal-confirm"
|
||||
@click="onStep1Confirm()"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else :class="$style.gatewayBody">
|
||||
<div :class="$style.gatewayHeader">
|
||||
<div :class="$style.gatewayHeaderLeft">
|
||||
<N8nHeading tag="h2" size="large" :class="$style.gatewayTitle">
|
||||
{{ i18n.baseText('instanceAi.welcomeModal.gateway.title') }}
|
||||
</N8nHeading>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
:class="$style.gatewayTextBlock"
|
||||
v-n8n-html="i18n.baseText('instanceAi.welcomeModal.gateway.description')"
|
||||
/>
|
||||
<div :class="$style.commandLabel">
|
||||
{{ i18n.baseText('instanceAi.welcomeModal.gateway.commandLabel') }}
|
||||
</div>
|
||||
<div :class="$style.osTabs">
|
||||
<button
|
||||
v-for="tab in osTabs"
|
||||
:key="tab.id"
|
||||
:class="[$style.osTab, { [$style.osTabActive]: selectedOs === tab.id }]"
|
||||
@click="selectedOs = tab.id"
|
||||
>
|
||||
<component :is="tab.icon" :class="$style.osTabIcon" />
|
||||
<span>{{ i18n.baseText(tab.labelKey) }}</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div :class="$style.commandCard">
|
||||
<div :class="$style.commandRow">
|
||||
<code
|
||||
:class="[$style.commandText, { [$style.commandTextFaded]: !isScrolledToEnd }]"
|
||||
@scroll="onCommandScroll"
|
||||
>{{ displayCommand }}</code
|
||||
>
|
||||
<N8nIconButton
|
||||
:icon="copied ? 'check' : 'copy'"
|
||||
variant="ghost"
|
||||
size="small"
|
||||
icon-size="large"
|
||||
:class="$style.copyButton"
|
||||
:aria-label="copyCommandAriaLabel"
|
||||
data-test-id="instance-ai-welcome-modal-copy-command"
|
||||
@click="copyCommand"
|
||||
/>
|
||||
</div>
|
||||
<div v-if="instanceAiSettingsStore.isGatewayConnected" :class="$style.connectedRow">
|
||||
<N8nIcon icon="check" :size="14" />
|
||||
<span>{{ i18n.baseText('instanceAi.welcomeModal.gateway.connected') }}</span>
|
||||
</div>
|
||||
<div v-else :class="$style.waitingRow">
|
||||
<N8nIcon icon="spinner" color="primary" spin size="small" />
|
||||
<span>{{ i18n.baseText('instanceAi.welcomeModal.gateway.waiting') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<N8nText color="text-light" :class="$style.gatewayInstructions">
|
||||
{{ i18n.baseText(terminalInstructionsKey) }}
|
||||
</N8nText>
|
||||
|
||||
<div :class="$style.gatewayActions">
|
||||
<N8nButton
|
||||
:variant="instanceAiSettingsStore.isGatewayConnected ? 'solid' : 'outline'"
|
||||
size="large"
|
||||
:label="
|
||||
instanceAiSettingsStore.isGatewayConnected
|
||||
? i18n.baseText('instanceAi.welcomeModal.gateway.done')
|
||||
: i18n.baseText('instanceAi.welcomeModal.gateway.skip')
|
||||
"
|
||||
:class="[!instanceAiSettingsStore.isGatewayConnected && $style.skipButton]"
|
||||
@click="onGatewayStepCompleted()"
|
||||
@click="onConfirm()"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -491,6 +353,35 @@ onUnmounted(() => {
|
|||
text-align: left;
|
||||
}
|
||||
|
||||
.computerUseRow {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 10px;
|
||||
padding: var(--spacing--sm);
|
||||
border: 1px solid var(--border-color--strong);
|
||||
border-radius: var(--radius--xs);
|
||||
background: var(--color--foreground--tint-2);
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
:global(body[data-theme='dark']) .computerUseRow {
|
||||
background: rgba(255, 255, 255, 0.03);
|
||||
border-color: rgba(255, 255, 255, 0.14);
|
||||
}
|
||||
|
||||
.computerUseCheckbox {
|
||||
flex-shrink: 0;
|
||||
margin-top: 2px;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.computerUseLabels {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--spacing--3xs);
|
||||
}
|
||||
|
||||
.footer {
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
|
|
@ -511,180 +402,6 @@ onUnmounted(() => {
|
|||
.continueButton {
|
||||
min-width: 170px;
|
||||
}
|
||||
|
||||
.gatewayBody {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--spacing--sm);
|
||||
padding: var(--spacing--md);
|
||||
}
|
||||
|
||||
.gatewayHeader {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: var(--spacing--xs);
|
||||
}
|
||||
|
||||
.gatewayHeaderLeft {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.gatewayTitle {
|
||||
margin: 0;
|
||||
font-size: var(--font-size--xl);
|
||||
}
|
||||
|
||||
.optionalBadge {
|
||||
padding: var(--spacing--4xs) var(--spacing--2xs);
|
||||
border: 1px solid var(--color--foreground);
|
||||
border-radius: var(--radius--full);
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
color: var(--color--text--tint-1);
|
||||
}
|
||||
|
||||
.gatewayTextBlock {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
font-size: var(--font-size--xs);
|
||||
line-height: var(--line-height--xl);
|
||||
margin-bottom: var(--spacing--sm);
|
||||
}
|
||||
|
||||
.gatewayDivider {
|
||||
border: none;
|
||||
border-top: 1px solid var(--color--foreground);
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.osTabs {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
border: 1px solid var(--border-color--subtle);
|
||||
border-radius: var(--radius--xs);
|
||||
padding: var(--spacing--4xs);
|
||||
gap: var(--spacing--4xs);
|
||||
background: var(--border-color--subtle);
|
||||
}
|
||||
|
||||
.osTab {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: var(--spacing--2xs);
|
||||
border: 0;
|
||||
border-radius: var(--radius--xs);
|
||||
padding: 10px var(--spacing--2xs);
|
||||
background: transparent;
|
||||
color: var(--color--text--tint-1);
|
||||
font-weight: var(--font-weight--bold);
|
||||
cursor: pointer;
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.osTabActive {
|
||||
background: var(--border-color--subtle);
|
||||
color: var(--color--text);
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.osTabIcon {
|
||||
width: var(--spacing--sm);
|
||||
height: var(--spacing--sm);
|
||||
}
|
||||
|
||||
.commandCard {
|
||||
border-radius: var(--radius--xs);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.commandLabel {
|
||||
font-size: var(--font-size--xs);
|
||||
}
|
||||
|
||||
.commandRow {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
padding: var(--spacing--xs) 14px;
|
||||
background: var(--color--neutral-950);
|
||||
}
|
||||
|
||||
.commandText {
|
||||
color: var(--color--text--tint-1);
|
||||
white-space: nowrap;
|
||||
overflow: auto;
|
||||
&::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
-ms-overflow-style: none;
|
||||
scrollbar-width: none;
|
||||
font-size: var(--font-size--xs);
|
||||
}
|
||||
|
||||
.commandTextFaded {
|
||||
mask-image: linear-gradient(to right, black calc(100% - 24px), transparent 100%);
|
||||
}
|
||||
|
||||
.copyButton {
|
||||
flex-shrink: 0;
|
||||
--button--color: var(--color--text--tint-1);
|
||||
}
|
||||
|
||||
.connectedRow {
|
||||
display: flex;
|
||||
font-size: var(--font-size--2xs);
|
||||
align-items: center;
|
||||
gap: var(--spacing--2xs);
|
||||
padding: 10px 14px;
|
||||
background: var(--color--green-950);
|
||||
color: var(--color--green-400);
|
||||
font-weight: var(--font-weight--bold);
|
||||
}
|
||||
|
||||
:global(body:not([data-theme='dark'])) .connectedRow {
|
||||
background: var(--color--green-600);
|
||||
color: var(--color--green-50);
|
||||
}
|
||||
|
||||
.waitingRow {
|
||||
display: flex;
|
||||
font-size: var(--font-size--2xs);
|
||||
align-items: center;
|
||||
gap: var(--spacing--2xs);
|
||||
padding: 10px 14px;
|
||||
background: var(--color--background--light-2);
|
||||
color: var(--color--text--tint-1);
|
||||
font-weight: var(--font-weight--bold);
|
||||
}
|
||||
|
||||
:global(body:not([data-theme='dark'])) .waitingRow {
|
||||
background: var(--color--black-alpha-700);
|
||||
color: var(--color--text--tint-2);
|
||||
}
|
||||
|
||||
.gatewayInstructions {
|
||||
font-size: var(--font-size--xs);
|
||||
line-height: var(--line-height--xl);
|
||||
color: var(--color--text--tint-2);
|
||||
}
|
||||
|
||||
:global(body:not([data-theme='dark'])) .gatewayInstructions {
|
||||
color: var(--color--text);
|
||||
}
|
||||
|
||||
.gatewayActions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
margin-top: var(--spacing--2xs);
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="scss">
|
||||
|
|
|
|||
Loading…
Reference in a new issue