@nextclaw/ui 0.9.9 → 0.9.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 (44) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/assets/ChannelsList-BgJbR6E9.js +1 -0
  3. package/dist/assets/{ChatPage-CMthudUt.js → ChatPage-Bv9UJPse.js} +24 -24
  4. package/dist/assets/{DocBrowser-BOvBC_5q.js → DocBrowser-Dw9BGO1m.js} +1 -1
  5. package/dist/assets/{LogoBadge-BUvLZbji.js → LogoBadge-CLc2B6st.js} +1 -1
  6. package/dist/assets/{MarketplacePage-CcbfvtGX.js → MarketplacePage-ChqCNL7k.js} +1 -1
  7. package/dist/assets/{McpMarketplacePage-D56yvyWI.js → McpMarketplacePage-B3PF-7ED.js} +1 -1
  8. package/dist/assets/ModelConfig-Dqz_NOow.js +1 -0
  9. package/dist/assets/{ProvidersList-Bd4n7muZ.js → ProvidersList-D2WaZShJ.js} +1 -1
  10. package/dist/assets/{RemoteAccessPage-Be8jduPM.js → RemoteAccessPage-D_l9irp4.js} +1 -1
  11. package/dist/assets/{RuntimeConfig-D8DYogZ1.js → RuntimeConfig-TDxQLuGy.js} +1 -1
  12. package/dist/assets/{SearchConfig-BtiGCmXR.js → SearchConfig-gba64nGn.js} +1 -1
  13. package/dist/assets/{SecretsConfig-fwAjbwlq.js → SecretsConfig-DpL8wgly.js} +1 -1
  14. package/dist/assets/{SessionsConfig-Y7_TDSk2.js → SessionsConfig-CAODVTNW.js} +1 -1
  15. package/dist/assets/{chat-message-Cwq8nW0e.js → chat-message-CSG50nNb.js} +1 -1
  16. package/dist/assets/index-DaEflNCE.js +8 -0
  17. package/dist/assets/{label-C0dJBNgU.js → label-3T28q3PJ.js} +1 -1
  18. package/dist/assets/{page-layout-4_789zOC.js → page-layout-BrXOQeua.js} +1 -1
  19. package/dist/assets/{popover-CWmq2f6H.js → popover-BrBJjElY.js} +1 -1
  20. package/dist/assets/{security-config-CZeVwEwq.js → security-config-oGAhN4Zf.js} +1 -1
  21. package/dist/assets/{skeleton-kjkadEki.js → skeleton-CIPQUKo2.js} +1 -1
  22. package/dist/assets/{status-dot-C7cVa53V.js → status-dot-QL3hmT1d.js} +1 -1
  23. package/dist/assets/{switch-C6zdGbY0.js → switch-Dbt2kUg2.js} +1 -1
  24. package/dist/assets/{tabs-custom-BQj0Z-ZC.js → tabs-custom-y5hdkzXk.js} +1 -1
  25. package/dist/assets/{useConfirmDialog-yX-ZMNf9.js → useConfirmDialog-B4zwBVbl.js} +1 -1
  26. package/dist/index.html +1 -1
  27. package/package.json +4 -4
  28. package/src/App.tsx +2 -2
  29. package/src/api/client.ts +5 -5
  30. package/src/api/config.ts +3 -2
  31. package/src/components/chat/chat-stream/transport.ts +67 -16
  32. package/src/components/config/ModelConfig.test.tsx +78 -0
  33. package/src/components/config/ModelConfig.tsx +4 -1
  34. package/src/hooks/use-realtime-query-bridge.ts +108 -0
  35. package/src/transport/app-client.ts +107 -0
  36. package/src/transport/index.ts +9 -0
  37. package/src/transport/local.transport.ts +286 -0
  38. package/src/transport/remote.transport.ts +398 -0
  39. package/src/transport/transport.types.ts +41 -0
  40. package/dist/assets/ChannelsList-a063_8pv.js +0 -1
  41. package/dist/assets/ModelConfig-D5AuTffd.js +0 -1
  42. package/dist/assets/index-C6dwNe7e.js +0 -8
  43. package/src/api/websocket.ts +0 -79
  44. package/src/hooks/useWebSocket.ts +0 -190
@@ -1,190 +0,0 @@
1
- import { useEffect, useState } from 'react';
2
- import { ConfigWebSocket } from '@/api/websocket';
3
- import { API_BASE } from '@/api/client';
4
- import { useUiStore } from '@/stores/ui.store';
5
- import type { QueryClient } from '@tanstack/react-query';
6
-
7
- function shouldInvalidateConfigQuery(configPath: string) {
8
- const normalized = configPath.trim().toLowerCase();
9
- if (!normalized) {
10
- return true;
11
- }
12
- if (normalized.startsWith('plugins') || normalized.startsWith('skills')) {
13
- return false;
14
- }
15
- return true;
16
- }
17
-
18
- function invalidateMarketplaceQueries(queryClient: QueryClient | undefined, configPath: string): void {
19
- if (configPath.startsWith('plugins')) {
20
- queryClient?.invalidateQueries({ queryKey: ['ncp-session-types'] });
21
- queryClient?.invalidateQueries({ queryKey: ['marketplace-installed', 'plugin'] });
22
- queryClient?.invalidateQueries({ queryKey: ['marketplace-items'] });
23
- }
24
- if (configPath.startsWith('mcp')) {
25
- queryClient?.invalidateQueries({ queryKey: ['marketplace-mcp-installed'] });
26
- queryClient?.invalidateQueries({ queryKey: ['marketplace-mcp-items'] });
27
- queryClient?.invalidateQueries({ queryKey: ['marketplace-mcp-doctor'] });
28
- }
29
- }
30
-
31
- export function useWebSocket(queryClient?: QueryClient) {
32
- const [ws, setWs] = useState<ConfigWebSocket | null>(null);
33
- const { setConnectionStatus } = useUiStore();
34
-
35
- useEffect(() => {
36
- const wsUrl = (() => {
37
- const base = API_BASE?.replace(/\/$/, '');
38
- if (!base) {
39
- return 'ws://127.0.0.1:55667/ws';
40
- }
41
- try {
42
- const resolved = new URL(base, window.location.origin);
43
- const protocol =
44
- resolved.protocol === 'https:'
45
- ? 'wss:'
46
- : resolved.protocol === 'http:'
47
- ? 'ws:'
48
- : resolved.protocol;
49
- return `${protocol}//${resolved.host}/ws`;
50
- } catch {
51
- if (base.startsWith('wss://') || base.startsWith('ws://')) {
52
- return `${base}/ws`;
53
- }
54
- if (base.startsWith('https://')) {
55
- return `${base.replace(/^https:/, 'wss:')}/ws`;
56
- }
57
- if (base.startsWith('http://')) {
58
- return `${base.replace(/^http:/, 'ws:')}/ws`;
59
- }
60
- return `${base}/ws`;
61
- }
62
- })();
63
- const client = new ConfigWebSocket(wsUrl);
64
- let isSocketOpen = false;
65
-
66
- const probeHealth = async (): Promise<boolean> => {
67
- const base = API_BASE?.replace(/\/$/, '') || window.location.origin;
68
- const url = `${base}/api/health`;
69
- try {
70
- const response = await fetch(url, { method: 'GET', cache: 'no-store' });
71
- if (!response.ok) {
72
- return false;
73
- }
74
- const payload = await response.json() as {
75
- ok?: boolean;
76
- data?: {
77
- status?: string;
78
- };
79
- };
80
- return payload.ok === true && payload.data?.status === 'ok';
81
- } catch {
82
- return false;
83
- }
84
- };
85
-
86
- const syncConnectionStatusFromHealth = async () => {
87
- if (isSocketOpen) {
88
- setConnectionStatus('connected');
89
- return;
90
- }
91
- const healthy = await probeHealth();
92
- setConnectionStatus(healthy ? 'connected' : 'disconnected');
93
- };
94
-
95
- const invalidateSessionQueries = (sessionKey?: string) => {
96
- if (!queryClient) {
97
- return;
98
- }
99
- queryClient.invalidateQueries({ queryKey: ['sessions'] });
100
- queryClient.invalidateQueries({ queryKey: ['ncp-sessions'] });
101
- if (sessionKey && sessionKey.trim().length > 0) {
102
- queryClient.invalidateQueries({ queryKey: ['session-history', sessionKey.trim()] });
103
- queryClient.invalidateQueries({ queryKey: ['ncp-session-messages', sessionKey.trim()] });
104
- return;
105
- }
106
- queryClient.invalidateQueries({ queryKey: ['session-history'] });
107
- queryClient.invalidateQueries({ queryKey: ['ncp-session-messages'] });
108
- };
109
-
110
- setConnectionStatus('connecting');
111
-
112
- client.on('connection.open', () => {
113
- isSocketOpen = true;
114
- setConnectionStatus('connected');
115
- });
116
-
117
- client.on('connection.close', () => {
118
- isSocketOpen = false;
119
- void syncConnectionStatusFromHealth();
120
- });
121
-
122
- client.on('connection.error', () => {
123
- isSocketOpen = false;
124
- void syncConnectionStatusFromHealth();
125
- });
126
-
127
- client.on('config.updated', (event) => {
128
- const payload = event.payload as { path?: unknown } | undefined;
129
- const configPath = typeof payload?.path === 'string' ? payload.path : '';
130
- // Trigger refetch of config
131
- if (queryClient && shouldInvalidateConfigQuery(configPath)) {
132
- queryClient.invalidateQueries({ queryKey: ['config'] });
133
- }
134
- if (configPath.startsWith('session')) {
135
- invalidateSessionQueries();
136
- }
137
- invalidateMarketplaceQueries(queryClient, configPath);
138
- });
139
-
140
- client.on('run.updated', (event) => {
141
- if (event.type !== 'run.updated') {
142
- return;
143
- }
144
- if (!queryClient) {
145
- return;
146
- }
147
- const sessionKey = event.payload.run.sessionKey;
148
- const runId = event.payload.run.runId;
149
- queryClient.invalidateQueries({ queryKey: ['chat-runs'] });
150
- if (sessionKey) {
151
- queryClient.invalidateQueries({ queryKey: ['sessions'] });
152
- queryClient.invalidateQueries({ queryKey: ['session-history', sessionKey] });
153
- } else {
154
- queryClient.invalidateQueries({ queryKey: ['session-history'] });
155
- }
156
- if (runId) {
157
- queryClient.invalidateQueries({ queryKey: ['chat-run', runId] });
158
- }
159
- });
160
-
161
- client.on('session.updated', (event) => {
162
- if (event.type !== 'session.updated') {
163
- return;
164
- }
165
- invalidateSessionQueries(event.payload.sessionKey);
166
- });
167
-
168
- client.on('error', (event) => {
169
- if (event.type === 'error') {
170
- console.error('WebSocket error:', event.payload.message);
171
- }
172
- });
173
-
174
- client.connect();
175
- setWs(client);
176
- void syncConnectionStatusFromHealth();
177
- const healthTimer = window.setInterval(() => {
178
- void syncConnectionStatusFromHealth();
179
- }, 10_000);
180
-
181
- return () => {
182
- window.clearInterval(healthTimer);
183
- isSocketOpen = false;
184
- client.disconnect();
185
- setConnectionStatus('disconnected');
186
- };
187
- }, [setConnectionStatus, queryClient]);
188
-
189
- return ws;
190
- }