fix: Show automation ideas even after the first recording is sent

This commit is contained in:
Roman Davydchuk 2026-09-11 07:45:26 +00:00
parent 300eb3b68f
commit e7efe649b4
No known key found for this signature in database
GPG Key ID: D89CEFB786D4B52F
4 changed files with 38 additions and 9 deletions

View File

@ -926,7 +926,7 @@ async function extractPageContext(
async function requestRecommendations(): Promise<{ success: boolean; error?: string }> {
const relay = activeConnection?.relay;
if (!relay || recording) {
if (!relay || (recording && recording.status !== 'submitted')) {
log.debug('recommendations skipped: not connected or a recording is in progress');
broadcastRecommendationsChange('unavailable');
return { success: false, error: 'No automation ideas are available right now.' };

View File

@ -1,5 +1,5 @@
<script setup lang="ts">
import { computed, ref } from 'vue';
import { computed, ref, watch } from 'vue';
import {
N8nButton,
N8nCheckbox,
@ -60,6 +60,7 @@ const {
ideas: recommendationIdeas,
isSending: isSendingRecommendation,
send: sendRecommendation,
refresh: refreshRecommendations,
} = useRecommendations();
const showTabSelection = ref(false);
@ -103,6 +104,15 @@ const recordingTitle = computed(() => {
return 'Review recording';
});
watch(
() => recording.value?.status,
(status, previousStatus) => {
if (status === 'submitted' && previousStatus === 'submitting') {
void refreshRecommendations();
}
},
);
async function disconnectFromInstance() {
await disconnect();
showSettings.value = false;
@ -260,9 +270,18 @@ async function submitToInstanceUrl() {
Complete the task in your browser. Return here when you're ready to review the recorded
actions.
</p>
<p v-else-if="recording.status === 'submitted'" class="subtitle">
AI Assistant is building this in a new conversation.
</p>
<template v-else-if="recording.status === 'submitted'">
<p class="subtitle">AI Assistant is building this in a new conversation.</p>
<template v-if="recommendationsStatus === 'loading' || recommendationsStatus === 'ready'">
<h2 class="ideas-title">Automation ideas for this page</h2>
<AutomationIdeas
:status="recommendationsStatus"
:ideas="recommendationIdeas"
:is-sending="isSendingRecommendation"
@pick="sendRecommendation"
/>
</template>
</template>
<p v-else-if="recording.status === 'submitting'" class="subtitle">
n8n is starting a new conversation from your recording.
</p>
@ -531,6 +550,13 @@ async function submitToInstanceUrl() {
margin: 0 0 var(--spacing--sm);
}
.ideas-title {
font-size: var(--font-size--sm);
font-weight: var(--font-weight--medium);
color: var(--color--text--shade-1);
margin: var(--spacing--lg) 0 var(--spacing--sm);
}
.divider {
border: none;
border-top: var(--border-width) var(--border-style) var(--color--foreground--tint-1);

View File

@ -43,6 +43,7 @@ const recommendationsState = {
ideas: ref<Array<{ id: string; title: string; description: string }>>([]),
isSending: ref(false),
send: vi.fn(),
refresh: vi.fn(),
};
vi.mock('./composables/useConnection', () => ({ useConnection: () => state }));

View File

@ -26,13 +26,15 @@ export function useRecommendations() {
ideas.value = message.ideas ?? [];
}
async function refresh(): Promise<void> {
await chrome.runtime.sendMessage({ type: 'getRecommendations' });
}
chrome.runtime.onMessage.addListener(onMessage);
onMounted(async () => {
await chrome.runtime.sendMessage({ type: 'getRecommendations' });
});
onMounted(refresh);
onUnmounted(() => chrome.runtime.onMessage.removeListener(onMessage));
return { status, ideas, isSending, send };
return { status, ideas, isSending, send, refresh };
}