@nextclaw/ui 0.11.8 → 0.11.10

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.
Files changed (57) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/assets/{ChannelsList-dsxeZk5v.js → ChannelsList-C63gOoYI.js} +3 -3
  3. package/dist/assets/ChatPage-Ci3Gz0qh.js +37 -0
  4. package/dist/assets/{DocBrowser-B9RfxWIh.js → DocBrowser-CI4jOzJY.js} +1 -1
  5. package/dist/assets/{LogoBadge-iVDzhkNu.js → LogoBadge-DImV63-L.js} +1 -1
  6. package/dist/assets/{MarketplacePage-4MZIcD0K.js → MarketplacePage-B360oSAV.js} +1 -1
  7. package/dist/assets/{McpMarketplacePage-cwLMty-D.js → McpMarketplacePage-KIQgx_7h.js} +2 -2
  8. package/dist/assets/{ModelConfig-CNICBWzw.js → ModelConfig-Ben3tQoX.js} +1 -1
  9. package/dist/assets/{ProvidersList-CEHGsRSL.js → ProvidersList-DE-S9mq0.js} +1 -1
  10. package/dist/assets/RemoteAccessPage-DxUia6R-.js +1 -0
  11. package/dist/assets/RuntimeConfig-CQcGfNZT.js +1 -0
  12. package/dist/assets/{SearchConfig-CaFAgBMN.js → SearchConfig-DeOa-M6j.js} +1 -1
  13. package/dist/assets/{SecretsConfig-DzWq8hGZ.js → SecretsConfig-Ci8pJmzd.js} +2 -2
  14. package/dist/assets/{SessionsConfig-CJJTcxyQ.js → SessionsConfig-B6zq55yu.js} +2 -2
  15. package/dist/assets/chat-session-display--oo5yuIw.js +1 -0
  16. package/dist/assets/{index-BlrweCCh.js → index-LhlkB00c.js} +4 -4
  17. package/dist/assets/{label-DtssWSI4.js → label-3TKt0PoZ.js} +1 -1
  18. package/dist/assets/{page-layout-DnRqSldv.js → page-layout-CopkIM3Q.js} +1 -1
  19. package/dist/assets/{popover-Un2VFGcS.js → popover-CUx8uRJw.js} +1 -1
  20. package/dist/assets/security-config-BL29kTzz.js +1 -0
  21. package/dist/assets/{skeleton-DTFzTqqO.js → skeleton-Bs4zvcql.js} +1 -1
  22. package/dist/assets/{status-dot-DOJX6vii.js → status-dot-D6vJMwD7.js} +1 -1
  23. package/dist/assets/{switch-utBdpBRv.js → switch-A3-ClT1P.js} +1 -1
  24. package/dist/assets/{tabs-custom-ExyfvfgG.js → tabs-custom-BVSd5urq.js} +1 -1
  25. package/dist/assets/{useConfirmDialog-DjNtKs4n.js → useConfirmDialog-ChPriea6.js} +1 -1
  26. package/dist/index.html +1 -1
  27. package/package.json +5 -5
  28. package/src/api/ncp-session-query-cache.test.ts +89 -0
  29. package/src/api/ncp-session-query-cache.ts +85 -0
  30. package/src/api/types.ts +2 -0
  31. package/src/components/chat/ChatConversationPanel.test.tsx +1 -1
  32. package/src/components/chat/ChatConversationPanel.tsx +62 -32
  33. package/src/components/chat/ChatSidebar.test.tsx +87 -92
  34. package/src/components/chat/ChatSidebar.tsx +21 -36
  35. package/src/components/chat/adapters/chat-message.adapter.ts +17 -5
  36. package/src/components/chat/chat-session-label.service.ts +3 -3
  37. package/src/components/chat/containers/chat-message-list.container.test.tsx +101 -0
  38. package/src/components/chat/containers/chat-message-list.container.tsx +93 -54
  39. package/src/components/chat/managers/chat-session-list.manager.ts +0 -18
  40. package/src/components/chat/ncp/NcpChatPage.tsx +4 -52
  41. package/src/components/chat/ncp/ncp-chat-thread.manager.ts +4 -18
  42. package/src/components/chat/ncp/ncp-chat.presenter.ts +0 -2
  43. package/src/components/chat/ncp/ncp-session-adapter.test.ts +0 -23
  44. package/src/components/chat/ncp/ncp-session-adapter.ts +0 -19
  45. package/src/components/chat/ncp/use-ncp-session-list-view.ts +42 -0
  46. package/src/components/chat/presenter/chat-presenter-context.tsx +0 -3
  47. package/src/components/chat/stores/chat-session-list.store.ts +1 -7
  48. package/src/components/chat/stores/chat-thread.store.ts +3 -3
  49. package/src/hooks/use-realtime-query-bridge.ts +14 -19
  50. package/src/hooks/useConfig.ts +10 -11
  51. package/dist/assets/ChatPage-CWK4Bckz.js +0 -37
  52. package/dist/assets/RemoteAccessPage-uYxoaQ8V.js +0 -1
  53. package/dist/assets/RuntimeConfig-CYQq4S_m.js +0 -1
  54. package/dist/assets/ncp-session-adapter-C-jqQqcV.js +0 -1
  55. package/dist/assets/security-config-B7Bkebpm.js +0 -1
  56. package/src/components/chat/managers/chat-run-status.manager.ts +0 -32
  57. package/src/components/chat/stores/chat-run-status.store.ts +0 -30
@@ -1,4 +1,5 @@
1
- import { useEffect } from 'react';
1
+ import { useEffect, useRef } from 'react';
2
+ import { applyNcpSessionRealtimeEvent } from '@/api/ncp-session-query-cache';
2
3
  import { appClient } from '@/transport';
3
4
  import { useUiStore } from '@/stores/ui.store';
4
5
  import type { QueryClient } from '@tanstack/react-query';
@@ -30,39 +31,30 @@ function invalidateMarketplaceQueries(queryClient: QueryClient | undefined, conf
30
31
  }
31
32
  }
32
33
 
33
- function invalidateSessionQueries(queryClient: QueryClient | undefined, sessionKey?: string): void {
34
- if (!queryClient) {
35
- return;
36
- }
37
- queryClient.invalidateQueries({ queryKey: ['ncp-sessions'] });
38
- if (sessionKey && sessionKey.trim().length > 0) {
39
- queryClient.invalidateQueries({ queryKey: ['ncp-session-messages', sessionKey.trim()] });
40
- return;
41
- }
42
- queryClient.invalidateQueries({ queryKey: ['ncp-session-messages'] });
43
- }
44
-
45
34
  function handleConfigUpdatedEvent(queryClient: QueryClient | undefined, path: string): void {
46
35
  if (queryClient && shouldInvalidateConfigQuery(path)) {
47
36
  queryClient.invalidateQueries({ queryKey: ['config'] });
48
37
  }
49
- if (path.startsWith('session')) {
50
- invalidateSessionQueries(queryClient);
51
- }
52
38
  invalidateMarketplaceQueries(queryClient, path);
53
39
  }
54
40
 
55
41
  function handleRealtimeEvent(
56
42
  queryClient: QueryClient | undefined,
57
43
  setConnectionStatus: SetConnectionStatus,
44
+ shouldResyncSessionsRef: { current: boolean },
58
45
  event: Parameters<Parameters<typeof appClient.subscribe>[0]>[0]
59
46
  ): void {
60
47
  if (event.type === 'connection.open') {
61
48
  setConnectionStatus('connected');
49
+ if (shouldResyncSessionsRef.current) {
50
+ shouldResyncSessionsRef.current = false;
51
+ queryClient?.invalidateQueries({ queryKey: ['ncp-sessions'] });
52
+ }
62
53
  return;
63
54
  }
64
55
  if (event.type === 'connection.close' || event.type === 'connection.error') {
65
56
  setConnectionStatus('disconnected');
57
+ shouldResyncSessionsRef.current = true;
66
58
  return;
67
59
  }
68
60
  if (event.type === 'config.updated') {
@@ -70,8 +62,8 @@ function handleRealtimeEvent(
70
62
  handleConfigUpdatedEvent(queryClient, configPath);
71
63
  return;
72
64
  }
73
- if (event.type === 'session.updated') {
74
- invalidateSessionQueries(queryClient, event.payload.sessionKey);
65
+ if (event.type === 'session.summary.upsert' || event.type === 'session.summary.delete') {
66
+ applyNcpSessionRealtimeEvent(queryClient, event);
75
67
  return;
76
68
  }
77
69
  if (event.type === 'error') {
@@ -81,10 +73,13 @@ function handleRealtimeEvent(
81
73
 
82
74
  export function useRealtimeQueryBridge(queryClient?: QueryClient) {
83
75
  const { setConnectionStatus } = useUiStore();
76
+ const shouldResyncSessionsRef = useRef(false);
84
77
 
85
78
  useEffect(() => {
86
79
  setConnectionStatus('connecting');
87
80
 
88
- return appClient.subscribe((event) => handleRealtimeEvent(queryClient, setConnectionStatus, event));
81
+ return appClient.subscribe((event) =>
82
+ handleRealtimeEvent(queryClient, setConnectionStatus, shouldResyncSessionsRef, event)
83
+ );
89
84
  }, [queryClient, setConnectionStatus]);
90
85
  }
@@ -1,4 +1,8 @@
1
1
  import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
2
+ import {
3
+ deleteNcpSessionSummaryInQueryClient,
4
+ upsertNcpSessionSummaryInQueryClient
5
+ } from '@/api/ncp-session-query-cache';
2
6
  import {
3
7
  fetchAppMeta,
4
8
  fetchConfig,
@@ -230,11 +234,7 @@ export function useNcpSessions(params?: { limit?: number }) {
230
234
  queryKey: ['ncp-sessions', params?.limit ?? null],
231
235
  queryFn: () => fetchNcpSessions(params),
232
236
  staleTime: 5_000,
233
- retry: false,
234
- refetchInterval: (query) => {
235
- const hasRunningSession = Boolean(query.state.data?.sessions.some((session) => session.status === 'running'));
236
- return hasRunningSession ? 800 : false;
237
- }
237
+ retry: false
238
238
  });
239
239
  }
240
240
 
@@ -253,9 +253,9 @@ export function useDeleteNcpSession() {
253
253
 
254
254
  return useMutation({
255
255
  mutationFn: ({ sessionId }: { sessionId: string }) => deleteNcpSession(sessionId),
256
- onSuccess: () => {
257
- queryClient.invalidateQueries({ queryKey: ['ncp-sessions'] });
258
- queryClient.invalidateQueries({ queryKey: ['ncp-session-messages'] });
256
+ onSuccess: (_data, variables) => {
257
+ deleteNcpSessionSummaryInQueryClient(queryClient, variables.sessionId);
258
+ queryClient.removeQueries({ queryKey: ['ncp-session-messages', variables.sessionId] });
259
259
  toast.success(t('configSavedApplied'));
260
260
  },
261
261
  onError: (error: Error) => {
@@ -270,9 +270,8 @@ export function useUpdateNcpSession() {
270
270
  return useMutation({
271
271
  mutationFn: ({ sessionId, data }: { sessionId: string; data: Parameters<typeof updateNcpSession>[1] }) =>
272
272
  updateNcpSession(sessionId, data),
273
- onSuccess: (_data, variables) => {
274
- queryClient.invalidateQueries({ queryKey: ['ncp-sessions'] });
275
- queryClient.invalidateQueries({ queryKey: ['ncp-session-messages', variables.sessionId] });
273
+ onSuccess: (data) => {
274
+ upsertNcpSessionSummaryInQueryClient(queryClient, data);
276
275
  toast.success(t('configSavedApplied'));
277
276
  },
278
277
  onError: (error: Error) => {