@controleonline/ui-crm 1.0.62 → 1.0.63

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.61",
2
+ "version": "1.0.57",
3
3
  "rc": 1,
4
- "branch": "rc/1.0.61-rc.1",
5
- "baseMaster": "f74060050bf143d4436051cd70d688618bd01dc5",
4
+ "branch": "rc/1.0.57-rc.1",
5
+ "baseMaster": "1fb0e0b679bc9845eb00abf31b7a476d9a3d4921",
6
6
  "tasks": [
7
- 1335
7
+ 1322
8
8
  ],
9
9
  "frozen": true,
10
10
  "repositories": {
11
- "ControleOnline/ui-crm": "54cacf3c5bc086cbd32a13b8b14b889df261e729"
11
+ "ControleOnline/ui-crm": "1d4360ffaf5f74e4e34147a8b284d50fbc6ce7d5"
12
12
  }
13
13
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@controleonline/ui-crm",
3
- "version": "1.0.62",
3
+ "version": "1.0.63",
4
4
  "author": "ControleOnline",
5
5
  "description": "ControleOnline CRM Quasar UI Component",
6
6
  "license": "MIT",
@@ -28,8 +28,6 @@ const PROVIDER_LABELS = {
28
28
  export default function McpPage() {
29
29
  const {showError, showSuccess} = useToastMessage();
30
30
  const peopleStore = useStore('people');
31
- const websocketStore = useStore('websocket');
32
- const wsMessages = websocketStore?.getters?.messages || [];
33
31
  const company =
34
32
  peopleStore?.getters?.currentCompany ||
35
33
  peopleStore?.getters?.mainCompany ||
@@ -46,8 +44,6 @@ export default function McpPage() {
46
44
  const [loadingChat, setLoadingChat] = useState(false);
47
45
  const [sending, setSending] = useState(false);
48
46
  const listRef = useRef(null);
49
- const pendingByTaskRef = useRef({}); // taskId -> userInteractionId
50
- const handledWsRef = useRef(new Set());
51
47
 
52
48
  const companyQuery = useMemo(
53
49
  () => (companyId ? {company_id: Number(companyId)} : {}),
@@ -135,46 +131,6 @@ export default function McpPage() {
135
131
  setDraft('');
136
132
  };
137
133
 
138
- // Realtime: apply mcp_chat_reply from websocket store (no HTTP poll)
139
- useEffect(() => {
140
- if (!Array.isArray(wsMessages) || wsMessages.length === 0) {
141
- return;
142
- }
143
- const latest = wsMessages[wsMessages.length - 1];
144
- const candidates = Array.isArray(latest) ? latest : [latest];
145
- candidates.forEach(evt => {
146
- if (!evt || typeof evt !== 'object') {
147
- return;
148
- }
149
- const eventName = String(evt.event || evt.action || '');
150
- if (eventName !== 'mcp_chat_reply') {
151
- return;
152
- }
153
- const taskId = Number(evt.task_id || evt.taskId || 0);
154
- const interactionId = Number(evt.interaction_id || evt.interactionId || 0);
155
- const key = `${taskId}:${interactionId}:${evt.status || ''}:${String(evt.body || '').slice(0, 40)}`;
156
- if (handledWsRef.current.has(key)) {
157
- return;
158
- }
159
- handledWsRef.current.add(key);
160
-
161
- if (taskId && Number(activeTaskId) === taskId) {
162
- // Refresh only the open chat once when reply arrives
163
- loadMessages(taskId);
164
- } else if (taskId && !activeTaskId) {
165
- setActiveTaskId(taskId);
166
- }
167
- if (taskId) {
168
- delete pendingByTaskRef.current[taskId];
169
- loadTasks();
170
- }
171
- if (String(evt.status || '') === 'error') {
172
- showError(evt.body || 'A IA retornou erro ao processar a mensagem');
173
- }
174
- setSending(false);
175
- });
176
- }, [wsMessages, activeTaskId, loadMessages, loadTasks, showError]);
177
-
178
134
  const sendMessage = async () => {
179
135
  const text = draft.trim();
180
136
  if (!text || sending) return;
@@ -190,38 +146,22 @@ export default function McpPage() {
190
146
  ...(activeTaskId ? {task_id: activeTaskId} : {}),
191
147
  ...(companyId ? {company_id: Number(companyId)} : {}),
192
148
  };
193
- // Optimistic local bubble while queue processes
194
- setMessages(prev => [
195
- ...prev,
196
- {
197
- id: `local-${Date.now()}`,
198
- body: text,
199
- status: 'pending',
200
- registeredBy: {id: companyId ? Number(companyId) + 1 : 0},
201
- },
202
- ]);
203
- setDraft('');
204
149
  const res = await api.post('/mcp/chat', body);
205
- const newTaskId = res?.task_id || res?.task?.id;
206
- const interactionId = res?.interaction_id;
207
- if (newTaskId) {
208
- pendingByTaskRef.current[Number(newTaskId)] = interactionId;
209
- if (Number(newTaskId) !== Number(activeTaskId)) {
210
- setActiveTaskId(Number(newTaskId));
211
- loadTasks();
212
- }
213
- // Single reload after persist (user message on server) — no poll loop
214
- await loadMessages(Number(newTaskId));
150
+ const newTaskId = res?.task?.id;
151
+ setDraft('');
152
+ if (newTaskId && newTaskId !== activeTaskId) {
153
+ setActiveTaskId(Number(newTaskId));
154
+ await loadTasks();
155
+ } else {
156
+ await loadMessages(activeTaskId || newTaskId);
215
157
  }
216
- // sending stays true until websocket reply (or error toast)
217
- if (!(res?.async || res?.status === 'pending')) {
218
- setSending(false);
219
- if (res?.message) {
220
- await loadMessages(newTaskId || activeTaskId);
221
- }
158
+ if (res?.reply) {
159
+ // optimistic refresh
160
+ await loadMessages(newTaskId || activeTaskId);
222
161
  }
223
162
  } catch (e) {
224
163
  showError(e?.message || e?.error || 'Falha ao enviar mensagem');
164
+ } finally {
225
165
  setSending(false);
226
166
  }
227
167
  };
@@ -240,9 +180,6 @@ export default function McpPage() {
240
180
  return (
241
181
  <View style={[styles.bubble, isUser ? styles.bubbleUser : styles.bubbleAi]}>
242
182
  <Text style={styles.bubbleText}>{body}</Text>
243
- {item?.status && item.status !== 'done' ? (
244
- <Text style={styles.bubbleMeta}>{String(item.status)}</Text>
245
- ) : null}
246
183
  </View>
247
184
  );
248
185
  };
@@ -84,7 +84,6 @@ export default StyleSheet.create({
84
84
  alignSelf: 'flex-start',
85
85
  backgroundColor: '#212a33',
86
86
  },
87
- bubbleMeta: {fontSize: 11, opacity: 0.7, marginTop: 4},
88
87
  bubbleText: {color: '#e7e9ea', fontSize: 14, lineHeight: 20},
89
88
  composer: {
90
89
  flexDirection: 'row',
@@ -82,7 +82,7 @@ const styles = StyleSheet.create({
82
82
  borderBottomColor: '#e2e8f0',
83
83
  },
84
84
 
85
- tabItem: { flex: 1, paddingVertical: 16, alignItems: 'center' },
85
+ tabItem: { flex: 1, minHeight: 40, justifyContent: 'center', alignItems: 'center' },
86
86
 
87
87
  tabActive: { borderBottomWidth: 3, borderBottomColor: colors.primary },
88
88