@nextclaw/ui 0.6.15 → 0.8.0
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.
- package/CHANGELOG.md +26 -0
- package/README.md +2 -0
- package/dist/assets/ChannelsList-DBcoVJRW.js +1 -0
- package/dist/assets/ChatPage-CD3cxyyM.js +37 -0
- package/dist/assets/DocBrowser-DDX2HMXW.js +1 -0
- package/dist/assets/{LogoBadge-Cer0jX6t.js → LogoBadge-J53F_3JA.js} +1 -1
- package/dist/assets/MarketplacePage-0BZ4bza0.js +49 -0
- package/dist/assets/ModelConfig-Wzq9wGHV.js +1 -0
- package/dist/assets/ProvidersList-kwzRS8_M.js +1 -0
- package/dist/assets/RuntimeConfig-N771_AM6.js +1 -0
- package/dist/assets/SearchConfig-DVt5QVa_.js +1 -0
- package/dist/assets/{SecretsConfig-BnGVZiv4.js → SecretsConfig-CkwauPa8.js} +2 -2
- package/dist/assets/SessionsConfig-C3mnHzkZ.js +2 -0
- package/dist/assets/{session-run-status-tZ4ISNj-.js → chat-message-pxr79GDs.js} +3 -3
- package/dist/assets/index-BIvFMkN4.js +1 -0
- package/dist/assets/index-CzkY1reu.js +8 -0
- package/dist/assets/{index-CkqvHQAt.js → index-GdpEEKnz.js} +1 -1
- package/dist/assets/index-RZ0kHHRI.css +1 -0
- package/dist/assets/{label-DkL14Jvl.js → label-CmksBHgc.js} +1 -1
- package/dist/assets/page-layout-Db0GbnhS.js +1 -0
- package/dist/assets/security-config-CjLFME5Q.js +1 -0
- package/dist/assets/skeleton-CkpQeVWN.js +1 -0
- package/dist/assets/{switch-CgbPbIX3.js → switch-C24d-UJU.js} +1 -1
- package/dist/assets/tabs-custom-D89bh-fc.js +1 -0
- package/dist/assets/useConfirmDialog-BeP35LcG.js +5 -0
- package/dist/assets/vendor-psXJBy9u.js +407 -0
- package/dist/index.html +3 -3
- package/package.json +12 -5
- package/src/App.tsx +49 -27
- package/src/api/client.ts +1 -0
- package/src/api/config.ts +98 -0
- package/src/api/types.ts +45 -0
- package/src/components/auth/login-page.tsx +69 -0
- package/src/components/chat/ChatConversationPanel.tsx +12 -54
- package/src/components/chat/ChatPage.tsx +10 -324
- package/src/components/chat/adapters/chat-input-bar.adapter.test.ts +80 -0
- package/src/components/chat/adapters/chat-input-bar.adapter.ts +329 -0
- package/src/components/chat/adapters/chat-message.adapter.test.ts +138 -0
- package/src/components/chat/adapters/chat-message.adapter.ts +200 -0
- package/src/components/chat/chat-chain.test.ts +22 -0
- package/src/components/chat/chat-chain.ts +23 -0
- package/src/components/chat/chat-input/chat-input-bar.controller.test.tsx +128 -0
- package/src/components/chat/chat-input/chat-input-bar.controller.ts +105 -0
- package/src/components/chat/chat-page-shell.tsx +103 -0
- package/src/components/chat/containers/chat-input-bar.container.tsx +270 -0
- package/src/components/chat/containers/chat-message-list.container.tsx +71 -0
- package/src/components/chat/index.ts +1 -0
- package/src/components/chat/legacy/LegacyChatPage.tsx +228 -0
- package/src/components/chat/managers/chat-thread.manager.ts +3 -1
- package/src/components/chat/ncp/NcpChatPage.tsx +349 -0
- package/src/components/chat/ncp/ncp-chat-input.manager.ts +173 -0
- package/src/components/chat/ncp/ncp-chat-page-data.ts +134 -0
- package/src/components/chat/ncp/ncp-chat-thread.manager.ts +89 -0
- package/src/components/chat/ncp/ncp-chat.presenter.ts +33 -0
- package/src/components/chat/ncp/ncp-session-adapter.test.ts +49 -0
- package/src/components/chat/ncp/ncp-session-adapter.ts +194 -0
- package/src/components/chat/nextclaw/index.ts +23 -0
- package/src/components/chat/presenter/chat-presenter-context.tsx +43 -4
- package/src/components/config/runtime-security-card.tsx +276 -0
- package/src/components/config/security-config.tsx +12 -0
- package/src/components/layout/Sidebar.tsx +6 -1
- package/src/components/marketplace/MarketplacePage.test.tsx +170 -0
- package/src/components/marketplace/MarketplacePage.tsx +77 -28
- package/src/hooks/use-auth.ts +111 -0
- package/src/hooks/useConfig.ts +42 -0
- package/src/hooks/useMarketplace.ts +9 -0
- package/src/lib/i18n.ts +73 -1
- package/src/test/setup.ts +16 -0
- package/tailwind.config.js +8 -3
- package/tsconfig.json +6 -2
- package/vite.config.ts +2 -1
- package/vitest.config.ts +16 -0
- package/dist/assets/ChannelsList-DzeVn-JC.js +0 -1
- package/dist/assets/ChatPage-BiFhIm1-.js +0 -36
- package/dist/assets/DocBrowser-By3lF9yN.js +0 -1
- package/dist/assets/MarketplacePage-EZxALdIz.js +0 -49
- package/dist/assets/ModelConfig-AchYxLft.js +0 -1
- package/dist/assets/ProvidersList-BsD-4kKX.js +0 -1
- package/dist/assets/RuntimeConfig-sKOERbFD.js +0 -1
- package/dist/assets/SearchConfig-DAfvDwX6.js +0 -1
- package/dist/assets/SessionsConfig-CzvrKDRs.js +0 -2
- package/dist/assets/card-BAM7vbMg.js +0 -1
- package/dist/assets/index-D9rRqOi8.css +0 -1
- package/dist/assets/index-DJZ5y7t1.js +0 -8
- package/dist/assets/input-BoelTiYL.js +0 -1
- package/dist/assets/page-layout-CERNdqzB.js +0 -1
- package/dist/assets/popover-uwYz3Chm.js +0 -1
- package/dist/assets/tabs-custom-pDyl95el.js +0 -1
- package/dist/assets/useConfirmDialog-DyP6Ac75.js +0 -5
- package/dist/assets/vendor-BKtTvQYU.js +0 -407
- package/src/components/chat/ChatThread.tsx +0 -402
- package/src/components/chat/SkillsPicker.tsx +0 -137
- package/src/components/chat/chat-input/ChatInputBarView.tsx +0 -82
- package/src/components/chat/chat-input/ChatInputBottomToolbar.tsx +0 -83
- package/src/components/chat/chat-input/components/ChatInputModelStateHint.tsx +0 -39
- package/src/components/chat/chat-input/components/ChatInputSelectedSkillsSection.tsx +0 -31
- package/src/components/chat/chat-input/components/ChatInputSlashPanelSection.tsx +0 -112
- package/src/components/chat/chat-input/components/bottom-toolbar/ChatInputAttachButton.tsx +0 -24
- package/src/components/chat/chat-input/components/bottom-toolbar/ChatInputModelSelector.tsx +0 -58
- package/src/components/chat/chat-input/components/bottom-toolbar/ChatInputSendControls.tsx +0 -56
- package/src/components/chat/chat-input/components/bottom-toolbar/ChatInputSessionTypeSelector.tsx +0 -40
- package/src/components/chat/chat-input/components/bottom-toolbar/ChatInputThinkingSelector.tsx +0 -74
- package/src/components/chat/chat-input/useChatInputBarController.ts +0 -322
|
@@ -1,330 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { CronConfig } from '@/components/config/CronConfig';
|
|
7
|
-
import { MarketplacePage } from '@/components/marketplace/MarketplacePage';
|
|
8
|
-
import { useSessionRunStatus } from '@/components/chat/chat-page-runtime';
|
|
9
|
-
import { useChatRuntimeController } from '@/components/chat/useChatRuntimeController';
|
|
10
|
-
import { parseSessionKeyFromRoute, resolveAgentIdFromSessionKey } from '@/components/chat/chat-session-route';
|
|
11
|
-
import { useChatPageData, sessionDisplayName } from '@/components/chat/chat-page-data';
|
|
12
|
-
import { ChatPresenterProvider } from '@/components/chat/presenter/chat-presenter-context';
|
|
13
|
-
import { ChatPresenter } from '@/components/chat/presenter/chat.presenter';
|
|
14
|
-
import { useChatInputStore } from '@/components/chat/stores/chat-input.store';
|
|
15
|
-
import { useChatSessionListStore } from '@/components/chat/stores/chat-session-list.store';
|
|
16
|
-
import { useLocation, useNavigate, useParams } from 'react-router-dom';
|
|
17
|
-
|
|
18
|
-
type MainPanelView = 'chat' | 'cron' | 'skills';
|
|
19
|
-
|
|
20
|
-
type ChatPageProps = {
|
|
21
|
-
view: MainPanelView;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
type UseSessionSyncParams = {
|
|
25
|
-
view: MainPanelView;
|
|
26
|
-
routeSessionKey: string | null;
|
|
27
|
-
selectedSessionKey: string | null;
|
|
28
|
-
selectedAgentId: string;
|
|
29
|
-
setSelectedSessionKey: Dispatch<SetStateAction<string | null>>;
|
|
30
|
-
setSelectedAgentId: Dispatch<SetStateAction<string>>;
|
|
31
|
-
selectedSessionKeyRef: MutableRefObject<string | null>;
|
|
32
|
-
resetStreamState: () => void;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
function useChatSessionSync(params: UseSessionSyncParams): void {
|
|
36
|
-
const {
|
|
37
|
-
view,
|
|
38
|
-
routeSessionKey,
|
|
39
|
-
selectedSessionKey,
|
|
40
|
-
selectedAgentId,
|
|
41
|
-
setSelectedSessionKey,
|
|
42
|
-
setSelectedAgentId,
|
|
43
|
-
selectedSessionKeyRef,
|
|
44
|
-
resetStreamState
|
|
45
|
-
} = params;
|
|
46
|
-
|
|
47
|
-
useEffect(() => {
|
|
48
|
-
if (view !== 'chat') {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
if (routeSessionKey) {
|
|
52
|
-
if (selectedSessionKey !== routeSessionKey) {
|
|
53
|
-
setSelectedSessionKey(routeSessionKey);
|
|
54
|
-
}
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
if (selectedSessionKey !== null) {
|
|
58
|
-
setSelectedSessionKey(null);
|
|
59
|
-
resetStreamState();
|
|
60
|
-
}
|
|
61
|
-
}, [resetStreamState, routeSessionKey, selectedSessionKey, setSelectedSessionKey, view]);
|
|
62
|
-
|
|
63
|
-
useEffect(() => {
|
|
64
|
-
const inferred = selectedSessionKey ? resolveAgentIdFromSessionKey(selectedSessionKey) : null;
|
|
65
|
-
if (!inferred) {
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
if (selectedAgentId !== inferred) {
|
|
69
|
-
setSelectedAgentId(inferred);
|
|
70
|
-
}
|
|
71
|
-
}, [selectedAgentId, selectedSessionKey, setSelectedAgentId]);
|
|
72
|
-
|
|
73
|
-
useEffect(() => {
|
|
74
|
-
selectedSessionKeyRef.current = selectedSessionKey;
|
|
75
|
-
}, [selectedSessionKey, selectedSessionKeyRef]);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
type ChatPageLayoutProps = {
|
|
79
|
-
view: MainPanelView;
|
|
80
|
-
confirmDialog: JSX.Element;
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
function ChatPageLayout({ view, confirmDialog }: ChatPageLayoutProps) {
|
|
84
|
-
return (
|
|
85
|
-
<div className="h-full flex">
|
|
86
|
-
<ChatSidebar />
|
|
87
|
-
|
|
88
|
-
{view === 'chat' ? (
|
|
89
|
-
<ChatConversationPanel />
|
|
90
|
-
) : (
|
|
91
|
-
<section className="flex-1 min-h-0 overflow-hidden bg-gradient-to-b from-gray-50/60 to-white">
|
|
92
|
-
{view === 'cron' ? (
|
|
93
|
-
<div className="h-full overflow-auto custom-scrollbar">
|
|
94
|
-
<div className="mx-auto w-full max-w-[min(1120px,100%)] px-6 py-5">
|
|
95
|
-
<CronConfig />
|
|
96
|
-
</div>
|
|
97
|
-
</div>
|
|
98
|
-
) : (
|
|
99
|
-
<div className="h-full overflow-hidden">
|
|
100
|
-
<div className="mx-auto flex h-full min-h-0 w-full max-w-[min(1120px,100%)] flex-col px-6 py-5">
|
|
101
|
-
<MarketplacePage forcedType="skills" />
|
|
102
|
-
</div>
|
|
103
|
-
</div>
|
|
104
|
-
)}
|
|
105
|
-
</section>
|
|
106
|
-
)}
|
|
107
|
-
|
|
108
|
-
{confirmDialog}
|
|
109
|
-
</div>
|
|
110
|
-
);
|
|
111
|
-
}
|
|
1
|
+
import { useLocation } from 'react-router-dom';
|
|
2
|
+
import { resolveChatChain } from '@/components/chat/chat-chain';
|
|
3
|
+
import type { ChatPageProps } from '@/components/chat/chat-page-shell';
|
|
4
|
+
import { LegacyChatPage } from '@/components/chat/legacy/LegacyChatPage';
|
|
5
|
+
import { NcpChatPage } from '@/components/chat/ncp/NcpChatPage';
|
|
112
6
|
|
|
113
7
|
export function ChatPage({ view }: ChatPageProps) {
|
|
114
|
-
const [presenter] = useState(() => new ChatPresenter());
|
|
115
|
-
const query = useChatSessionListStore((state) => state.snapshot.query);
|
|
116
|
-
const selectedSessionKey = useChatSessionListStore((state) => state.snapshot.selectedSessionKey);
|
|
117
|
-
const selectedAgentId = useChatSessionListStore((state) => state.snapshot.selectedAgentId);
|
|
118
|
-
const pendingSessionType = useChatInputStore((state) => state.snapshot.pendingSessionType);
|
|
119
|
-
const { confirm, ConfirmDialog } = useConfirmDialog();
|
|
120
8
|
const location = useLocation();
|
|
121
|
-
const
|
|
122
|
-
const { sessionId: routeSessionIdParam } = useParams<{ sessionId?: string }>();
|
|
123
|
-
const threadRef = useRef<HTMLDivElement | null>(null);
|
|
124
|
-
const selectedSessionKeyRef = useRef<string | null>(selectedSessionKey);
|
|
125
|
-
const thinkingHydratedSessionKeyRef = useRef<string | null>(null);
|
|
126
|
-
const routeSessionKey = useMemo(
|
|
127
|
-
() => parseSessionKeyFromRoute(routeSessionIdParam),
|
|
128
|
-
[routeSessionIdParam]
|
|
129
|
-
);
|
|
130
|
-
const {
|
|
131
|
-
sessionsQuery,
|
|
132
|
-
installedSkillsQuery,
|
|
133
|
-
chatCapabilitiesQuery,
|
|
134
|
-
historyQuery,
|
|
135
|
-
isProviderStateResolved,
|
|
136
|
-
modelOptions,
|
|
137
|
-
sessions,
|
|
138
|
-
skillRecords,
|
|
139
|
-
selectedSession,
|
|
140
|
-
historyMessages,
|
|
141
|
-
selectedSessionThinkingLevel,
|
|
142
|
-
sessionTypeOptions,
|
|
143
|
-
defaultSessionType,
|
|
144
|
-
selectedSessionType,
|
|
145
|
-
canEditSessionType,
|
|
146
|
-
sessionTypeUnavailable,
|
|
147
|
-
sessionTypeUnavailableMessage
|
|
148
|
-
} = useChatPageData({
|
|
149
|
-
query,
|
|
150
|
-
selectedSessionKey,
|
|
151
|
-
selectedAgentId,
|
|
152
|
-
pendingSessionType,
|
|
153
|
-
setPendingSessionType: presenter.chatInputManager.setPendingSessionType,
|
|
154
|
-
setSelectedModel: presenter.chatInputManager.setSelectedModel
|
|
155
|
-
});
|
|
156
|
-
const {
|
|
157
|
-
uiMessages,
|
|
158
|
-
isSending,
|
|
159
|
-
isAwaitingAssistantOutput,
|
|
160
|
-
canStopCurrentRun,
|
|
161
|
-
stopDisabledReason,
|
|
162
|
-
lastSendError,
|
|
163
|
-
activeBackendRunId,
|
|
164
|
-
sendMessage,
|
|
165
|
-
stopCurrentRun,
|
|
166
|
-
resumeRun,
|
|
167
|
-
resetStreamState,
|
|
168
|
-
applyHistoryMessages
|
|
169
|
-
} = useChatRuntimeController(
|
|
170
|
-
{
|
|
171
|
-
selectedSessionKeyRef,
|
|
172
|
-
setSelectedSessionKey: presenter.chatSessionListManager.setSelectedSessionKey,
|
|
173
|
-
setDraft: presenter.chatInputManager.setDraft,
|
|
174
|
-
refetchSessions: sessionsQuery.refetch,
|
|
175
|
-
refetchHistory: historyQuery.refetch
|
|
176
|
-
},
|
|
177
|
-
presenter.chatController
|
|
178
|
-
);
|
|
179
|
-
|
|
180
|
-
console.log('[ChatPage] uiMessages', { uiMessages, historyMessages });
|
|
181
|
-
useEffect(() => {
|
|
182
|
-
presenter.chatStreamActionsManager.bind({
|
|
183
|
-
sendMessage,
|
|
184
|
-
stopCurrentRun,
|
|
185
|
-
resumeRun,
|
|
186
|
-
resetStreamState,
|
|
187
|
-
applyHistoryMessages
|
|
188
|
-
});
|
|
189
|
-
}, [applyHistoryMessages, presenter, resetStreamState, resumeRun, sendMessage, stopCurrentRun]);
|
|
190
|
-
|
|
191
|
-
const { sessionRunStatusByKey } = useSessionRunStatus({
|
|
192
|
-
view,
|
|
193
|
-
selectedSessionKey,
|
|
194
|
-
activeBackendRunId,
|
|
195
|
-
isLocallyRunning: isSending || Boolean(activeBackendRunId),
|
|
196
|
-
resumeRun: presenter.chatStreamActionsManager.resumeRun
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
useChatSessionSync({
|
|
200
|
-
view,
|
|
201
|
-
routeSessionKey,
|
|
202
|
-
selectedSessionKey,
|
|
203
|
-
selectedAgentId,
|
|
204
|
-
setSelectedSessionKey: presenter.chatSessionListManager.setSelectedSessionKey,
|
|
205
|
-
setSelectedAgentId: presenter.chatSessionListManager.setSelectedAgentId,
|
|
206
|
-
selectedSessionKeyRef,
|
|
207
|
-
resetStreamState: presenter.chatStreamActionsManager.resetStreamState
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
useEffect(() => {
|
|
211
|
-
presenter.chatStreamActionsManager.applyHistoryMessages(historyMessages, {
|
|
212
|
-
isLoading: historyQuery.isLoading
|
|
213
|
-
});
|
|
214
|
-
}, [historyMessages, historyQuery.isLoading, presenter]);
|
|
215
|
-
|
|
216
|
-
useEffect(() => {
|
|
217
|
-
presenter.chatUiManager.syncState({
|
|
218
|
-
pathname: location.pathname
|
|
219
|
-
});
|
|
220
|
-
presenter.chatUiManager.bindActions({
|
|
221
|
-
navigate,
|
|
222
|
-
confirm
|
|
223
|
-
});
|
|
224
|
-
}, [confirm, location.pathname, navigate, presenter]);
|
|
225
|
-
const currentSessionDisplayName = selectedSession ? sessionDisplayName(selectedSession) : undefined;
|
|
226
|
-
|
|
227
|
-
useEffect(() => {
|
|
228
|
-
presenter.chatThreadManager.bindActions({
|
|
229
|
-
refetchSessions: sessionsQuery.refetch
|
|
230
|
-
});
|
|
231
|
-
}, [
|
|
232
|
-
presenter,
|
|
233
|
-
sessionsQuery.refetch,
|
|
234
|
-
]);
|
|
235
|
-
|
|
236
|
-
useEffect(() => {
|
|
237
|
-
const shouldHydrateThinkingFromHistory =
|
|
238
|
-
!isSending &&
|
|
239
|
-
!isAwaitingAssistantOutput &&
|
|
240
|
-
!historyQuery.isLoading &&
|
|
241
|
-
selectedSessionKey !== thinkingHydratedSessionKeyRef.current;
|
|
9
|
+
const chatChain = resolveChatChain(location.search);
|
|
242
10
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
canStopGeneration: canStopCurrentRun,
|
|
247
|
-
stopDisabledReason,
|
|
248
|
-
stopSupported: chatCapabilitiesQuery.data?.stopSupported ?? false,
|
|
249
|
-
stopReason: chatCapabilitiesQuery.data?.stopReason,
|
|
250
|
-
sendError: lastSendError,
|
|
251
|
-
isSending,
|
|
252
|
-
modelOptions,
|
|
253
|
-
sessionTypeOptions,
|
|
254
|
-
selectedSessionType,
|
|
255
|
-
...(shouldHydrateThinkingFromHistory ? { selectedThinkingLevel: selectedSessionThinkingLevel } : {}),
|
|
256
|
-
canEditSessionType,
|
|
257
|
-
sessionTypeUnavailable,
|
|
258
|
-
skillRecords,
|
|
259
|
-
isSkillsLoading: installedSkillsQuery.isLoading
|
|
260
|
-
});
|
|
261
|
-
if (shouldHydrateThinkingFromHistory) {
|
|
262
|
-
thinkingHydratedSessionKeyRef.current = selectedSessionKey;
|
|
263
|
-
}
|
|
264
|
-
if (!selectedSessionKey) {
|
|
265
|
-
thinkingHydratedSessionKeyRef.current = null;
|
|
266
|
-
}
|
|
267
|
-
presenter.chatSessionListManager.syncSnapshot({
|
|
268
|
-
sessions,
|
|
269
|
-
query,
|
|
270
|
-
isLoading: sessionsQuery.isLoading
|
|
271
|
-
});
|
|
272
|
-
presenter.chatRunStatusManager.syncSnapshot({
|
|
273
|
-
sessionRunStatusByKey,
|
|
274
|
-
isLocallyRunning: isSending || Boolean(activeBackendRunId),
|
|
275
|
-
activeBackendRunId
|
|
276
|
-
});
|
|
277
|
-
presenter.chatThreadManager.syncSnapshot({
|
|
278
|
-
isProviderStateResolved,
|
|
279
|
-
modelOptions,
|
|
280
|
-
sessionTypeUnavailable,
|
|
281
|
-
sessionTypeUnavailableMessage,
|
|
282
|
-
selectedSessionKey,
|
|
283
|
-
sessionDisplayName: currentSessionDisplayName,
|
|
284
|
-
canDeleteSession: Boolean(selectedSession),
|
|
285
|
-
threadRef,
|
|
286
|
-
isHistoryLoading: historyQuery.isLoading,
|
|
287
|
-
uiMessages,
|
|
288
|
-
isSending,
|
|
289
|
-
isAwaitingAssistantOutput
|
|
290
|
-
});
|
|
291
|
-
}, [
|
|
292
|
-
activeBackendRunId,
|
|
293
|
-
canEditSessionType,
|
|
294
|
-
canStopCurrentRun,
|
|
295
|
-
currentSessionDisplayName,
|
|
296
|
-
chatCapabilitiesQuery.data?.stopReason,
|
|
297
|
-
chatCapabilitiesQuery.data?.stopSupported,
|
|
298
|
-
defaultSessionType,
|
|
299
|
-
historyQuery.isLoading,
|
|
300
|
-
installedSkillsQuery.isLoading,
|
|
301
|
-
isAwaitingAssistantOutput,
|
|
302
|
-
isProviderStateResolved,
|
|
303
|
-
isSending,
|
|
304
|
-
lastSendError,
|
|
305
|
-
uiMessages,
|
|
306
|
-
modelOptions,
|
|
307
|
-
presenter,
|
|
308
|
-
query,
|
|
309
|
-
selectedSession,
|
|
310
|
-
selectedSessionThinkingLevel,
|
|
311
|
-
selectedSessionKey,
|
|
312
|
-
selectedAgentId,
|
|
313
|
-
selectedSessionType,
|
|
314
|
-
sessionRunStatusByKey,
|
|
315
|
-
sessionTypeOptions,
|
|
316
|
-
sessionTypeUnavailable,
|
|
317
|
-
sessionTypeUnavailableMessage,
|
|
318
|
-
sessions,
|
|
319
|
-
sessionsQuery.isLoading,
|
|
320
|
-
stopDisabledReason,
|
|
321
|
-
threadRef,
|
|
322
|
-
skillRecords
|
|
323
|
-
]);
|
|
11
|
+
if (chatChain === 'ncp') {
|
|
12
|
+
return <NcpChatPage view={view} />;
|
|
13
|
+
}
|
|
324
14
|
|
|
325
|
-
return
|
|
326
|
-
<ChatPresenterProvider presenter={presenter}>
|
|
327
|
-
<ChatPageLayout view={view} confirmDialog={<ConfirmDialog />} />
|
|
328
|
-
</ChatPresenterProvider>
|
|
329
|
-
);
|
|
15
|
+
return <LegacyChatPage view={view} />;
|
|
330
16
|
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { buildChatSlashItems, buildSelectedSkillItems, buildSkillPickerModel } from '@/components/chat/adapters/chat-input-bar.adapter';
|
|
2
|
+
import type { ChatSkillRecord } from '@/components/chat/adapters/chat-input-bar.adapter';
|
|
3
|
+
|
|
4
|
+
function createSkillRecord(partial: Partial<ChatSkillRecord>): ChatSkillRecord {
|
|
5
|
+
return {
|
|
6
|
+
key: 'demo.skill',
|
|
7
|
+
label: 'Demo Skill',
|
|
8
|
+
...partial
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
describe('buildChatSlashItems', () => {
|
|
13
|
+
const texts = {
|
|
14
|
+
slashSkillSubtitle: 'Skill',
|
|
15
|
+
slashSkillSpecLabel: 'Spec',
|
|
16
|
+
noSkillDescription: 'No description'
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
it('sorts exact spec matches ahead of weaker matches', () => {
|
|
20
|
+
const items = buildChatSlashItems(
|
|
21
|
+
[
|
|
22
|
+
createSkillRecord({ key: 'web-search', label: 'Web Search' }),
|
|
23
|
+
createSkillRecord({ key: 'weather', label: 'Web Weather' })
|
|
24
|
+
],
|
|
25
|
+
'web',
|
|
26
|
+
texts
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
expect(items.map((item) => item.value)).toEqual(['web-search', 'weather']);
|
|
30
|
+
expect(items[0]?.detailLines).toContain('Spec: web-search');
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('returns an empty list when nothing matches', () => {
|
|
34
|
+
const items = buildChatSlashItems([createSkillRecord({ key: 'weather' })], 'terminal', texts);
|
|
35
|
+
expect(items).toEqual([]);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
describe('buildSelectedSkillItems', () => {
|
|
40
|
+
it('keeps selected specs and resolves labels when available', () => {
|
|
41
|
+
const chips = buildSelectedSkillItems(
|
|
42
|
+
['web-search', 'missing-skill'],
|
|
43
|
+
[createSkillRecord({ key: 'web-search', label: 'Web Search' })]
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
expect(chips).toEqual([
|
|
47
|
+
{ key: 'web-search', label: 'Web Search' },
|
|
48
|
+
{ key: 'missing-skill', label: 'missing-skill' }
|
|
49
|
+
]);
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
describe('buildSkillPickerModel', () => {
|
|
54
|
+
it('builds a stable semantic model for toolbar skill picker', () => {
|
|
55
|
+
const onSelectedKeysChange = vi.fn();
|
|
56
|
+
const model = buildSkillPickerModel({
|
|
57
|
+
skillRecords: [createSkillRecord({ key: 'web-search', label: 'Web Search', description: 'Search web' })],
|
|
58
|
+
selectedSkills: ['web-search'],
|
|
59
|
+
isLoading: false,
|
|
60
|
+
onSelectedKeysChange,
|
|
61
|
+
texts: {
|
|
62
|
+
title: 'Skills',
|
|
63
|
+
searchPlaceholder: 'Search skills',
|
|
64
|
+
emptyLabel: 'No skills',
|
|
65
|
+
loadingLabel: 'Loading',
|
|
66
|
+
manageLabel: 'Manage'
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
expect(model).toMatchObject({
|
|
71
|
+
title: 'Skills',
|
|
72
|
+
selectedKeys: ['web-search'],
|
|
73
|
+
manageHref: '/marketplace/skills'
|
|
74
|
+
});
|
|
75
|
+
expect(model.options[0]).toMatchObject({
|
|
76
|
+
key: 'web-search',
|
|
77
|
+
label: 'Web Search'
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
});
|