@controleonline/ui-crm 1.0.57 → 1.0.59

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.57",
2
+ "version": "1.0.59",
3
3
  "rc": 1,
4
- "branch": "rc/1.0.57-rc.1",
5
- "baseMaster": "1fb0e0b679bc9845eb00abf31b7a476d9a3d4921",
4
+ "branch": "rc/1.0.59-rc.1",
5
+ "baseMaster": "54dd75b4f09b4be5cb3383131f1ec8f0bdb06567",
6
6
  "tasks": [
7
- 1322
7
+ 1327
8
8
  ],
9
9
  "frozen": true,
10
10
  "repositories": {
11
- "ControleOnline/ui-crm": "1d4360ffaf5f74e4e34147a8b284d50fbc6ce7d5"
11
+ "ControleOnline/ui-crm": "727f84955dbb774dd35d3f0357caf6cc76e17f88"
12
12
  }
13
13
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@controleonline/ui-crm",
3
- "version": "1.0.57",
3
+ "version": "1.0.59",
4
4
  "author": "ControleOnline",
5
5
  "description": "ControleOnline CRM Quasar UI Component",
6
6
  "license": "MIT",
@@ -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
- if (res?.reply) {
159
- // optimistic refresh
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',