@controleonline/ui-crm 1.0.58 → 1.0.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.0.
|
|
2
|
+
"version": "1.0.59",
|
|
3
3
|
"rc": 1,
|
|
4
|
-
"branch": "rc/1.0.
|
|
5
|
-
"baseMaster": "
|
|
4
|
+
"branch": "rc/1.0.59-rc.1",
|
|
5
|
+
"baseMaster": "54dd75b4f09b4be5cb3383131f1ec8f0bdb06567",
|
|
6
6
|
"tasks": [
|
|
7
|
-
|
|
7
|
+
1327
|
|
8
8
|
],
|
|
9
9
|
"frozen": true,
|
|
10
10
|
"repositories": {
|
|
11
|
-
"ControleOnline/ui-crm": "
|
|
11
|
+
"ControleOnline/ui-crm": "727f84955dbb774dd35d3f0357caf6cc76e17f88"
|
|
12
12
|
}
|
|
13
13
|
}
|
package/package.json
CHANGED
|
@@ -131,6 +131,28 @@ export default function McpPage() {
|
|
|
131
131
|
setDraft('');
|
|
132
132
|
};
|
|
133
133
|
|
|
134
|
+
const pollUntilDone = async (taskId, interactionId) => {
|
|
135
|
+
const maxAttempts = 40;
|
|
136
|
+
for (let i = 0; i < maxAttempts; i += 1) {
|
|
137
|
+
await new Promise(r => setTimeout(r, 1500));
|
|
138
|
+
try {
|
|
139
|
+
await loadMessages(taskId);
|
|
140
|
+
if (interactionId) {
|
|
141
|
+
const detail = await api.fetch(`/task_interations/${interactionId}`);
|
|
142
|
+
const st = detail?.status || detail?.['status'];
|
|
143
|
+
if (st === 'done' || st === 'error') {
|
|
144
|
+
return st;
|
|
145
|
+
}
|
|
146
|
+
} else {
|
|
147
|
+
return 'done';
|
|
148
|
+
}
|
|
149
|
+
} catch {
|
|
150
|
+
// keep polling
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return 'timeout';
|
|
154
|
+
};
|
|
155
|
+
|
|
134
156
|
const sendMessage = async () => {
|
|
135
157
|
const text = draft.trim();
|
|
136
158
|
if (!text || sending) return;
|
|
@@ -147,16 +169,24 @@ export default function McpPage() {
|
|
|
147
169
|
...(companyId ? {company_id: Number(companyId)} : {}),
|
|
148
170
|
};
|
|
149
171
|
const res = await api.post('/mcp/chat', body);
|
|
150
|
-
const newTaskId = res?.task?.id;
|
|
172
|
+
const newTaskId = res?.task_id || res?.task?.id;
|
|
173
|
+
const interactionId = res?.interaction_id;
|
|
151
174
|
setDraft('');
|
|
152
|
-
if (newTaskId && newTaskId !== activeTaskId) {
|
|
175
|
+
if (newTaskId && Number(newTaskId) !== Number(activeTaskId)) {
|
|
153
176
|
setActiveTaskId(Number(newTaskId));
|
|
154
177
|
await loadTasks();
|
|
155
|
-
} else {
|
|
156
|
-
await loadMessages(activeTaskId || newTaskId);
|
|
157
178
|
}
|
|
158
|
-
|
|
159
|
-
|
|
179
|
+
await loadMessages(newTaskId || activeTaskId);
|
|
180
|
+
// Phase 2 runs in queue; poll for status/reply (WS will also push when available)
|
|
181
|
+
if (res?.async || res?.status === 'pending') {
|
|
182
|
+
const finalStatus = await pollUntilDone(newTaskId || activeTaskId, interactionId);
|
|
183
|
+
await loadMessages(newTaskId || activeTaskId);
|
|
184
|
+
if (finalStatus === 'error') {
|
|
185
|
+
showError('A IA retornou erro ao processar a mensagem');
|
|
186
|
+
} else if (finalStatus === 'timeout') {
|
|
187
|
+
showError('Ainda processando… atualize o chat em instantes');
|
|
188
|
+
}
|
|
189
|
+
} else if (res?.message) {
|
|
160
190
|
await loadMessages(newTaskId || activeTaskId);
|
|
161
191
|
}
|
|
162
192
|
} catch (e) {
|
|
@@ -180,6 +210,9 @@ export default function McpPage() {
|
|
|
180
210
|
return (
|
|
181
211
|
<View style={[styles.bubble, isUser ? styles.bubbleUser : styles.bubbleAi]}>
|
|
182
212
|
<Text style={styles.bubbleText}>{body}</Text>
|
|
213
|
+
{item?.status && item.status !== 'done' ? (
|
|
214
|
+
<Text style={styles.bubbleMeta}>{String(item.status)}</Text>
|
|
215
|
+
) : null}
|
|
183
216
|
</View>
|
|
184
217
|
);
|
|
185
218
|
};
|
|
@@ -84,6 +84,7 @@ export default StyleSheet.create({
|
|
|
84
84
|
alignSelf: 'flex-start',
|
|
85
85
|
backgroundColor: '#212a33',
|
|
86
86
|
},
|
|
87
|
+
bubbleMeta: {fontSize: 11, opacity: 0.7, marginTop: 4},
|
|
87
88
|
bubbleText: {color: '#e7e9ea', fontSize: 14, lineHeight: 20},
|
|
88
89
|
composer: {
|
|
89
90
|
flexDirection: 'row',
|