PluginProbe
Extendify / 3.2.2
Extendify v3.2.2
3.2.2 3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 All 128 releases
← All changes | src/Agent/state/chat.js +10 -23 3.2.0 → 3.2.2 View file →
@@ -1,35 +1,15 @@
1 1 import { buildToolMessages } from '@agent/lib/tool-messages';
2 -import { isChangeSiteDesignWorkflowAvailable, makeId } from '@agent/lib/util';
2 +import { makeId } from '@agent/lib/util';
3 3 import { useStatusStore } from '@agent/state/status';
4 4 import apiFetch from '@wordpress/api-fetch';
5 -import { __ } from '@wordpress/i18n';
6 5 import { create } from 'zustand';
7 6 import { createJSONStorage, devtools, persist } from 'zustand/middleware';
8 7
9 8 const { chatHistory } = window.extAgentData;
10 9
11 -const welcomeMessage = [
12 - {
13 - id: 1,
14 - type: 'message',
15 - details: {
16 - role: 'assistant',
17 - // translators: this is the initial message in the agent chat, welcoming the user. Keep it short and friendly and follow the same markdown format and emoji.
18 - content: isChangeSiteDesignWorkflowAvailable()
19 - ? __(
20 - '#### Your site is ready 🎉\nWant to explore other website designs?',
21 - 'extendify-local',
22 - )
23 - : __(
24 - '#### Your site is ready 🎉\nWant to explore other site colors?',
25 - 'extendify-local',
26 - ),
27 - },
28 - },
29 -];
30 10 const state = (set, get) => ({
31 - messages: chatHistory?.length ? chatHistory.toReversed() : welcomeMessage,
11 + messages: chatHistory?.length ? chatHistory.toReversed() : [],
32 12 // API messages, back to the last finished workflow.
33 13 getCurrentMessages: ({ includeTools = true } = {}) => {
34 14 const messages = [];
35 15 let foundUserMessage = false;
@@ -63,9 +43,16 @@
63 43 let segment = [];
64 44 for (const { type, details } of get().messages) {
65 45 const finished = ['completed', 'canceled'].includes(details.status);
66 46 if (['workflow', 'workflow-component'].includes(type) && finished) {
67 - segments.push({ workflowId: details.workflowId, segment });
47 + // A canceled run's reply claims a change the next run then skips.
48 + const kept =
49 + details.status === 'canceled'
50 + ? segment.filter(
51 + (m) => m.role !== 'assistant' || typeof m.content !== 'string',
52 + )
53 + : segment;
54 + segments.push({ workflowId: details.workflowId, segment: kept });
68 55 segment = [];
69 56 continue;
70 57 }
71 58 // An error ended a run without a marker; what precedes it is dead.