@xinghunm/ai-chat 1.4.0 → 1.4.2
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/dist/index.d.mts +3 -4
- package/dist/index.d.ts +3 -4
- package/dist/index.js +88 -105
- package/dist/index.mjs +99 -116
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -19,7 +19,7 @@ type ChatMessageStatus = (typeof CHAT_MESSAGE_STATUSES)[number];
|
|
|
19
19
|
declare const CHAT_AGENT_MODES: readonly ["ask", "plan", "agent"];
|
|
20
20
|
type ChatAgentMode = (typeof CHAT_AGENT_MODES)[number];
|
|
21
21
|
/**
|
|
22
|
-
* Default agent mode used for new
|
|
22
|
+
* Default agent mode used for new sends.
|
|
23
23
|
*/
|
|
24
24
|
declare const DEFAULT_CHAT_AGENT_MODE: ChatAgentMode;
|
|
25
25
|
/**
|
|
@@ -31,7 +31,6 @@ interface ChatSession {
|
|
|
31
31
|
createdAt: string;
|
|
32
32
|
updatedAt: string;
|
|
33
33
|
model: string;
|
|
34
|
-
mode?: ChatAgentMode;
|
|
35
34
|
}
|
|
36
35
|
/**
|
|
37
36
|
* Loading states for externally hydrated historical session messages.
|
|
@@ -453,6 +452,7 @@ interface AiChatLabels {
|
|
|
453
452
|
stopButton?: string;
|
|
454
453
|
retryButton?: string;
|
|
455
454
|
scrollToLatest?: string;
|
|
455
|
+
sessionsTitle?: string;
|
|
456
456
|
placeholder?: string;
|
|
457
457
|
modeLabelAsk?: string;
|
|
458
458
|
modeLabelPlan?: string;
|
|
@@ -505,7 +505,7 @@ interface NewChatTriggerRenderProps {
|
|
|
505
505
|
declare const DEFAULT_AI_CHAT_LABELS: Required<AiChatLabels>;
|
|
506
506
|
|
|
507
507
|
interface AiChatProviderBaseProps {
|
|
508
|
-
/** Initial agent mode for new
|
|
508
|
+
/** Initial agent mode used by the composer for new sends. */
|
|
509
509
|
defaultMode?: ChatAgentMode;
|
|
510
510
|
/** Optional label overrides for UI strings. */
|
|
511
511
|
labels?: AiChatLabels;
|
|
@@ -751,7 +751,6 @@ interface ChatActions {
|
|
|
751
751
|
setActiveSession: (sessionId: string | null) => void;
|
|
752
752
|
replaceSessionId: (previousSessionId: string, nextSessionId: string) => void;
|
|
753
753
|
setPreferredMode: (mode: ChatAgentMode) => void;
|
|
754
|
-
setSessionMode: (sessionId: string, mode: ChatAgentMode) => void;
|
|
755
754
|
hydrateHistorySessions: (sessions: ChatSession[]) => void;
|
|
756
755
|
appendMessage: (sessionId: string, message: ChatMessage) => void;
|
|
757
756
|
hydrateHistorySessionMessages: (sessionId: string, messages: ChatMessage[]) => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ type ChatMessageStatus = (typeof CHAT_MESSAGE_STATUSES)[number];
|
|
|
19
19
|
declare const CHAT_AGENT_MODES: readonly ["ask", "plan", "agent"];
|
|
20
20
|
type ChatAgentMode = (typeof CHAT_AGENT_MODES)[number];
|
|
21
21
|
/**
|
|
22
|
-
* Default agent mode used for new
|
|
22
|
+
* Default agent mode used for new sends.
|
|
23
23
|
*/
|
|
24
24
|
declare const DEFAULT_CHAT_AGENT_MODE: ChatAgentMode;
|
|
25
25
|
/**
|
|
@@ -31,7 +31,6 @@ interface ChatSession {
|
|
|
31
31
|
createdAt: string;
|
|
32
32
|
updatedAt: string;
|
|
33
33
|
model: string;
|
|
34
|
-
mode?: ChatAgentMode;
|
|
35
34
|
}
|
|
36
35
|
/**
|
|
37
36
|
* Loading states for externally hydrated historical session messages.
|
|
@@ -453,6 +452,7 @@ interface AiChatLabels {
|
|
|
453
452
|
stopButton?: string;
|
|
454
453
|
retryButton?: string;
|
|
455
454
|
scrollToLatest?: string;
|
|
455
|
+
sessionsTitle?: string;
|
|
456
456
|
placeholder?: string;
|
|
457
457
|
modeLabelAsk?: string;
|
|
458
458
|
modeLabelPlan?: string;
|
|
@@ -505,7 +505,7 @@ interface NewChatTriggerRenderProps {
|
|
|
505
505
|
declare const DEFAULT_AI_CHAT_LABELS: Required<AiChatLabels>;
|
|
506
506
|
|
|
507
507
|
interface AiChatProviderBaseProps {
|
|
508
|
-
/** Initial agent mode for new
|
|
508
|
+
/** Initial agent mode used by the composer for new sends. */
|
|
509
509
|
defaultMode?: ChatAgentMode;
|
|
510
510
|
/** Optional label overrides for UI strings. */
|
|
511
511
|
labels?: AiChatLabels;
|
|
@@ -751,7 +751,6 @@ interface ChatActions {
|
|
|
751
751
|
setActiveSession: (sessionId: string | null) => void;
|
|
752
752
|
replaceSessionId: (previousSessionId: string, nextSessionId: string) => void;
|
|
753
753
|
setPreferredMode: (mode: ChatAgentMode) => void;
|
|
754
|
-
setSessionMode: (sessionId: string, mode: ChatAgentMode) => void;
|
|
755
754
|
hydrateHistorySessions: (sessions: ChatSession[]) => void;
|
|
756
755
|
appendMessage: (sessionId: string, message: ChatMessage) => void;
|
|
757
756
|
hydrateHistorySessionMessages: (sessionId: string, messages: ChatMessage[]) => void;
|
package/dist/index.js
CHANGED
|
@@ -70,6 +70,7 @@ var DEFAULT_AI_CHAT_LABELS = {
|
|
|
70
70
|
stopButton: "Stop",
|
|
71
71
|
retryButton: "Retry",
|
|
72
72
|
scrollToLatest: "Jump to latest",
|
|
73
|
+
sessionsTitle: "Sessions",
|
|
73
74
|
placeholder: "Ask something...",
|
|
74
75
|
modeLabelAsk: "Ask",
|
|
75
76
|
modeLabelPlan: "Plan",
|
|
@@ -113,7 +114,6 @@ var createDraftChatSessionId = () => `${DRAFT_CHAT_SESSION_ID_PREFIX}${Date.now(
|
|
|
113
114
|
var isDraftChatSessionId = (sessionId) => Boolean(sessionId?.startsWith(DRAFT_CHAT_SESSION_ID_PREFIX));
|
|
114
115
|
var createDraftChatSession = ({
|
|
115
116
|
model,
|
|
116
|
-
mode = DEFAULT_CHAT_AGENT_MODE,
|
|
117
117
|
nowIso: nowIso2,
|
|
118
118
|
createSessionId = createDraftChatSessionId
|
|
119
119
|
}) => {
|
|
@@ -123,8 +123,7 @@ var createDraftChatSession = ({
|
|
|
123
123
|
title: "New Chat",
|
|
124
124
|
createdAt: iso,
|
|
125
125
|
updatedAt: iso,
|
|
126
|
-
model
|
|
127
|
-
mode
|
|
126
|
+
model
|
|
128
127
|
};
|
|
129
128
|
};
|
|
130
129
|
|
|
@@ -254,11 +253,7 @@ var createChatStore = (initialState) => (0, import_vanilla.createStore)((set, ge
|
|
|
254
253
|
createSession: (session) => {
|
|
255
254
|
const state = get();
|
|
256
255
|
const exists = state.sessions.some((s) => s.sessionId === session.sessionId);
|
|
257
|
-
const
|
|
258
|
-
...session,
|
|
259
|
-
mode: session.mode ?? DEFAULT_CHAT_AGENT_MODE
|
|
260
|
-
};
|
|
261
|
-
const nextSessions = exists ? state.sessions : [nextSession, ...state.sessions];
|
|
256
|
+
const nextSessions = exists ? state.sessions : [session, ...state.sessions];
|
|
262
257
|
const nextMessagesBySession = { ...state.messagesBySession };
|
|
263
258
|
const nextErrorBySession = { ...state.errorBySession };
|
|
264
259
|
const nextIsStreamingBySession = { ...state.isStreamingBySession };
|
|
@@ -303,10 +298,8 @@ var createChatStore = (initialState) => (0, import_vanilla.createStore)((set, ge
|
|
|
303
298
|
});
|
|
304
299
|
},
|
|
305
300
|
startNewChat: () => {
|
|
306
|
-
const state = get();
|
|
307
301
|
const session = createDraftChatSession({
|
|
308
302
|
model: "",
|
|
309
|
-
mode: state.preferredMode,
|
|
310
303
|
nowIso: () => (/* @__PURE__ */ new Date()).toISOString()
|
|
311
304
|
});
|
|
312
305
|
get().createSession(session);
|
|
@@ -392,25 +385,26 @@ var createChatStore = (initialState) => (0, import_vanilla.createStore)((set, ge
|
|
|
392
385
|
setPreferredMode: (mode) => {
|
|
393
386
|
set({ preferredMode: mode });
|
|
394
387
|
},
|
|
395
|
-
setSessionMode: (sessionId, mode) => {
|
|
396
|
-
const state = get();
|
|
397
|
-
const nextSessions = state.sessions.map(
|
|
398
|
-
(s) => s.sessionId === sessionId ? { ...s, mode } : s
|
|
399
|
-
);
|
|
400
|
-
set({ sessions: nextSessions });
|
|
401
|
-
},
|
|
402
388
|
hydrateHistorySessions: (sessions) => {
|
|
403
389
|
const state = get();
|
|
404
|
-
const
|
|
390
|
+
const draftSessions = state.sessions.filter(
|
|
405
391
|
(session) => isDraftChatSessionId(session.sessionId)
|
|
406
392
|
);
|
|
407
|
-
const
|
|
393
|
+
const activePersistedSession = state.sessions.find(
|
|
394
|
+
(session) => session.sessionId === state.activeSessionId && !isDraftChatSessionId(session.sessionId)
|
|
395
|
+
);
|
|
396
|
+
const hasActiveInIncoming = sessions.some(
|
|
397
|
+
(session) => session.sessionId === state.activeSessionId
|
|
398
|
+
);
|
|
399
|
+
const keepActiveSession = activePersistedSession && !hasActiveInIncoming ? [activePersistedSession] : [];
|
|
400
|
+
const excludeIds = /* @__PURE__ */ new Set([
|
|
401
|
+
...draftSessions.map((s) => s.sessionId),
|
|
402
|
+
...keepActiveSession.map((s) => s.sessionId)
|
|
403
|
+
]);
|
|
408
404
|
const nextSessions = [
|
|
409
|
-
...
|
|
410
|
-
...sessions.filter((session) => !
|
|
411
|
-
|
|
412
|
-
mode: session.mode ?? DEFAULT_CHAT_AGENT_MODE
|
|
413
|
-
}))
|
|
405
|
+
...draftSessions,
|
|
406
|
+
...sessions.filter((session) => !excludeIds.has(session.sessionId)),
|
|
407
|
+
...keepActiveSession
|
|
414
408
|
];
|
|
415
409
|
const nextMessagesBySession = { ...state.messagesBySession };
|
|
416
410
|
const nextErrorBySession = { ...state.errorBySession };
|
|
@@ -3140,9 +3134,8 @@ var ChatMessageItemView = ({
|
|
|
3140
3134
|
const hasMarkdownOnlyBlocks = hasStructuredBlocks && blocks.every((block) => block.type === "markdown");
|
|
3141
3135
|
const hasTextContent = Boolean(settledContent || freshContent || displayedContent);
|
|
3142
3136
|
const shouldRenderStructuredBlocks = hasStructuredBlocks && !(isAssistantStreaming && hasMarkdownOnlyBlocks && hasTextContent);
|
|
3143
|
-
const
|
|
3144
|
-
const
|
|
3145
|
-
const canSubmitQuestionnaire = isPlanMode && typeof onQuestionnaireSubmit === "function";
|
|
3137
|
+
const canSubmitConfirmation = typeof onConfirmationSubmit === "function";
|
|
3138
|
+
const canSubmitQuestionnaire = typeof onQuestionnaireSubmit === "function";
|
|
3146
3139
|
const shouldShowStreamingCaret = isAssistantStreaming && (!shouldRenderStructuredBlocks || hasTextContent);
|
|
3147
3140
|
const isUserMessage = message.role === "user";
|
|
3148
3141
|
const messageRenderMode = isUserMessage ? "plain-text" : "markdown";
|
|
@@ -3200,7 +3193,7 @@ var ChatMessageItemView = ({
|
|
|
3200
3193
|
ExecutionConfirmationCard,
|
|
3201
3194
|
{
|
|
3202
3195
|
proposal: block.proposal,
|
|
3203
|
-
interactive:
|
|
3196
|
+
interactive: canSubmitConfirmation,
|
|
3204
3197
|
onConfirm: canSubmitConfirmation ? () => onConfirmationSubmit({
|
|
3205
3198
|
proposalId: block.proposal.proposalId,
|
|
3206
3199
|
content: createExecutionConfirmationContent(block.proposal),
|
|
@@ -3830,7 +3823,7 @@ var groupConversationTurns = (historyMessages, streamingMessage) => {
|
|
|
3830
3823
|
];
|
|
3831
3824
|
};
|
|
3832
3825
|
var ChatThreadView = ({
|
|
3833
|
-
|
|
3826
|
+
activeMode = DEFAULT_CHAT_AGENT_MODE,
|
|
3834
3827
|
historyMessages,
|
|
3835
3828
|
streamingMessage,
|
|
3836
3829
|
error: error2,
|
|
@@ -4086,7 +4079,7 @@ var ChatThreadView = ({
|
|
|
4086
4079
|
style: isLatestTurn ? { scrollMarginTop: `${CHAT_THREAD_SCROLL_TOP_GAP}px` } : void 0,
|
|
4087
4080
|
children: renderChatMessage({
|
|
4088
4081
|
message: turn.userMessage,
|
|
4089
|
-
mode:
|
|
4082
|
+
mode: activeMode,
|
|
4090
4083
|
onConfirmationSubmit,
|
|
4091
4084
|
onQuestionnaireSubmit,
|
|
4092
4085
|
renderMessageBlock
|
|
@@ -4095,7 +4088,7 @@ var ChatThreadView = ({
|
|
|
4095
4088
|
) : null,
|
|
4096
4089
|
turn.responseMessages.map((message) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(MessageSlot, { children: renderChatMessage({
|
|
4097
4090
|
message,
|
|
4098
|
-
mode:
|
|
4091
|
+
mode: activeMode,
|
|
4099
4092
|
onConfirmationSubmit,
|
|
4100
4093
|
onQuestionnaireSubmit,
|
|
4101
4094
|
renderMessageBlock
|
|
@@ -4129,7 +4122,7 @@ var ChatThread = () => {
|
|
|
4129
4122
|
const activeSession = useChatStore(
|
|
4130
4123
|
(s) => s.sessions.find((session) => session.sessionId === s.activeSessionId)
|
|
4131
4124
|
);
|
|
4132
|
-
const
|
|
4125
|
+
const preferredMode = useChatStore((s) => s.preferredMode);
|
|
4133
4126
|
const messages = useChatStore(
|
|
4134
4127
|
(s) => s.messagesBySession[s.activeSessionId ?? ""] ?? EMPTY_MESSAGES
|
|
4135
4128
|
);
|
|
@@ -4168,7 +4161,7 @@ var ChatThread = () => {
|
|
|
4168
4161
|
if (customQuestionnaireSubmit) {
|
|
4169
4162
|
const handled = await customQuestionnaireSubmit(submission, {
|
|
4170
4163
|
sessionId: sourceSessionId ?? void 0,
|
|
4171
|
-
mode:
|
|
4164
|
+
mode: preferredMode
|
|
4172
4165
|
});
|
|
4173
4166
|
if (handled !== false) {
|
|
4174
4167
|
if (sourceSessionId && submission.sourceMessageId) {
|
|
@@ -4195,7 +4188,7 @@ var ChatThread = () => {
|
|
|
4195
4188
|
);
|
|
4196
4189
|
}
|
|
4197
4190
|
},
|
|
4198
|
-
[activeSessionId,
|
|
4191
|
+
[activeSessionId, customQuestionnaireSubmit, preferredMode, sendRef, updateQA]
|
|
4199
4192
|
);
|
|
4200
4193
|
const handleConfirmation = (0, import_react11.useCallback)(
|
|
4201
4194
|
async (submission) => {
|
|
@@ -4203,7 +4196,7 @@ var ChatThread = () => {
|
|
|
4203
4196
|
if (customConfirmationSubmit) {
|
|
4204
4197
|
const handled = await customConfirmationSubmit(submission, {
|
|
4205
4198
|
sessionId: sourceSessionId ?? void 0,
|
|
4206
|
-
mode:
|
|
4199
|
+
mode: preferredMode
|
|
4207
4200
|
});
|
|
4208
4201
|
if (handled !== false) {
|
|
4209
4202
|
return;
|
|
@@ -4214,7 +4207,7 @@ var ChatThread = () => {
|
|
|
4214
4207
|
includeComposerAttachments: false
|
|
4215
4208
|
});
|
|
4216
4209
|
},
|
|
4217
|
-
[activeSessionId,
|
|
4210
|
+
[activeSessionId, customConfirmationSubmit, preferredMode, sendRef]
|
|
4218
4211
|
);
|
|
4219
4212
|
const handleLoadPreviousMessages = (0, import_react11.useCallback)(async () => {
|
|
4220
4213
|
if (!activeSession || !onLoadMoreHistoryMessages || !historyMessagePagination?.hasMorePrevious || !historyMessagePagination.previousCursor || historyMessagePagination.isLoadingPrevious) {
|
|
@@ -4258,7 +4251,7 @@ var ChatThread = () => {
|
|
|
4258
4251
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
4259
4252
|
ChatThreadView,
|
|
4260
4253
|
{
|
|
4261
|
-
|
|
4254
|
+
activeMode: preferredMode,
|
|
4262
4255
|
historyMessages: messages,
|
|
4263
4256
|
streamingMessage,
|
|
4264
4257
|
error: error2,
|
|
@@ -6990,7 +6983,6 @@ var resolveSelectedChatModel = ({
|
|
|
6990
6983
|
var resolveSendSession = ({
|
|
6991
6984
|
activeSessionId,
|
|
6992
6985
|
selectedModel,
|
|
6993
|
-
selectedMode,
|
|
6994
6986
|
nowIso: nowIso2,
|
|
6995
6987
|
createSessionId
|
|
6996
6988
|
}) => {
|
|
@@ -7002,7 +6994,6 @@ var resolveSendSession = ({
|
|
|
7002
6994
|
}
|
|
7003
6995
|
const session = createDraftChatSession({
|
|
7004
6996
|
model: selectedModel,
|
|
7005
|
-
mode: selectedMode ?? DEFAULT_CHAT_AGENT_MODE,
|
|
7006
6997
|
nowIso: nowIso2,
|
|
7007
6998
|
createSessionId
|
|
7008
6999
|
});
|
|
@@ -7160,9 +7151,6 @@ var useChatComposer = () => {
|
|
|
7160
7151
|
const skillsLoader = transport.getSkills;
|
|
7161
7152
|
const activeSkillsLoaderRef = (0, import_react15.useRef)(skillsLoader);
|
|
7162
7153
|
const activeSessionId = useChatStore((s) => s.activeSessionId);
|
|
7163
|
-
const activeSession = useChatStore(
|
|
7164
|
-
(s) => s.sessions.find((x) => x.sessionId === s.activeSessionId) ?? null
|
|
7165
|
-
);
|
|
7166
7154
|
const preferredMode = useChatStore((s) => s.preferredMode);
|
|
7167
7155
|
const streamingSessionId = useChatStore(
|
|
7168
7156
|
(s) => s.activeSessionId && s.isStreamingBySession[s.activeSessionId] ? s.activeSessionId : null
|
|
@@ -7183,7 +7171,6 @@ var useChatComposer = () => {
|
|
|
7183
7171
|
const setSessionError = useChatStore((s) => s.setSessionError);
|
|
7184
7172
|
const clearSessionError = useChatStore((s) => s.clearSessionError);
|
|
7185
7173
|
const setPreferredMode = useChatStore((s) => s.setPreferredMode);
|
|
7186
|
-
const setSessionMode = useChatStore((s) => s.setSessionMode);
|
|
7187
7174
|
const [availableModels, setAvailableModels] = (0, import_react15.useState)([]);
|
|
7188
7175
|
const [isModelsLoading, setIsModelsLoading] = (0, import_react15.useState)(true);
|
|
7189
7176
|
const [isModelsError, setIsModelsError] = (0, import_react15.useState)(false);
|
|
@@ -7264,12 +7251,8 @@ var useChatComposer = () => {
|
|
|
7264
7251
|
);
|
|
7265
7252
|
}, [availableModels, isModelsLoading]);
|
|
7266
7253
|
(0, import_react15.useEffect)(() => {
|
|
7267
|
-
if (activeSession) {
|
|
7268
|
-
setSelectedModeLocal(activeSession.mode ?? DEFAULT_CHAT_AGENT_MODE);
|
|
7269
|
-
return;
|
|
7270
|
-
}
|
|
7271
7254
|
setSelectedModeLocal(preferredMode ?? DEFAULT_CHAT_AGENT_MODE);
|
|
7272
|
-
}, [
|
|
7255
|
+
}, [preferredMode]);
|
|
7273
7256
|
(0, import_react15.useEffect)(() => {
|
|
7274
7257
|
if (previousActiveSessionIdRef.current !== activeSessionId) {
|
|
7275
7258
|
setSelectedSkills([]);
|
|
@@ -7477,7 +7460,7 @@ var useChatComposer = () => {
|
|
|
7477
7460
|
const storeState = store.getState();
|
|
7478
7461
|
const currentActiveSessionId = options?.sessionId ?? storeState.activeSessionId;
|
|
7479
7462
|
const currentActiveSession = storeState.sessions.find((session2) => session2.sessionId === currentActiveSessionId) ?? null;
|
|
7480
|
-
const currentMode =
|
|
7463
|
+
const currentMode = selectedMode;
|
|
7481
7464
|
if (!(selectedModel || currentActiveSession?.model || availableModels[0]?.id)) {
|
|
7482
7465
|
return;
|
|
7483
7466
|
}
|
|
@@ -7485,7 +7468,6 @@ var useChatComposer = () => {
|
|
|
7485
7468
|
const { localSessionId, sessionId, session } = resolveSendSession({
|
|
7486
7469
|
activeSessionId: currentActiveSessionId,
|
|
7487
7470
|
selectedModel: resolvedModel,
|
|
7488
|
-
selectedMode: currentMode,
|
|
7489
7471
|
nowIso,
|
|
7490
7472
|
createSessionId: createDraftChatSessionId
|
|
7491
7473
|
});
|
|
@@ -7633,8 +7615,6 @@ var useChatComposer = () => {
|
|
|
7633
7615
|
setSelectedMode: (mode) => {
|
|
7634
7616
|
setSelectedModeLocal(mode);
|
|
7635
7617
|
setPreferredMode(mode);
|
|
7636
|
-
if (activeSessionId)
|
|
7637
|
-
setSessionMode(activeSessionId, mode);
|
|
7638
7618
|
if (activeSessionId) {
|
|
7639
7619
|
const previousRequest = lastRequestBySessionRef.current.get(activeSessionId);
|
|
7640
7620
|
if (previousRequest) {
|
|
@@ -8987,31 +8967,21 @@ var import_styled16 = __toESM(require("@emotion/styled"));
|
|
|
8987
8967
|
var import_react19 = require("react");
|
|
8988
8968
|
var import_styled15 = __toESM(require("@emotion/styled"));
|
|
8989
8969
|
var import_jsx_runtime17 = require("@emotion/react/jsx-runtime");
|
|
8990
|
-
var ChatSessionItem = (0, import_react19.memo)(
|
|
8991
|
-
|
|
8992
|
-
|
|
8993
|
-
|
|
8994
|
-
|
|
8995
|
-
|
|
8996
|
-
|
|
8997
|
-
|
|
8998
|
-
|
|
8999
|
-
|
|
9000
|
-
|
|
9001
|
-
|
|
9002
|
-
] })
|
|
9003
|
-
}
|
|
9004
|
-
);
|
|
9005
|
-
}
|
|
9006
|
-
);
|
|
8970
|
+
var ChatSessionItem = (0, import_react19.memo)(({ session, isActive, onClick }) => {
|
|
8971
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
8972
|
+
SessionButton,
|
|
8973
|
+
{
|
|
8974
|
+
type: "button",
|
|
8975
|
+
"data-active": isActive,
|
|
8976
|
+
"data-testid": `chat-session-item-${session.sessionId}`,
|
|
8977
|
+
onClick: () => onClick(session.sessionId),
|
|
8978
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(SessionTitle, { children: session.title })
|
|
8979
|
+
}
|
|
8980
|
+
);
|
|
8981
|
+
});
|
|
9007
8982
|
ChatSessionItem.displayName = "ChatSessionItem";
|
|
9008
|
-
var SessionMeta = import_styled15.default.div`
|
|
9009
|
-
display: flex;
|
|
9010
|
-
align-items: center;
|
|
9011
|
-
justify-content: space-between;
|
|
9012
|
-
gap: 8px;
|
|
9013
|
-
`;
|
|
9014
8983
|
var SessionTitle = import_styled15.default.span`
|
|
8984
|
+
display: block;
|
|
9015
8985
|
min-width: 0;
|
|
9016
8986
|
overflow: hidden;
|
|
9017
8987
|
text-overflow: ellipsis;
|
|
@@ -9025,22 +8995,31 @@ var SessionButton = import_styled15.default.button`
|
|
|
9025
8995
|
color: var(--text-primary);
|
|
9026
8996
|
background: rgba(255, 255, 255, 0.03);
|
|
9027
8997
|
cursor: pointer;
|
|
8998
|
+
transition:
|
|
8999
|
+
background-color 160ms ease,
|
|
9000
|
+
border-color 160ms ease,
|
|
9001
|
+
transform 160ms ease;
|
|
9002
|
+
|
|
9003
|
+
&:hover {
|
|
9004
|
+
background: rgba(255, 255, 255, 0.06);
|
|
9005
|
+
border-color: rgba(255, 255, 255, 0.08);
|
|
9006
|
+
}
|
|
9007
|
+
|
|
9008
|
+
&:focus-visible {
|
|
9009
|
+
outline: none;
|
|
9010
|
+
background: rgba(255, 255, 255, 0.06);
|
|
9011
|
+
border-color: rgba(255, 255, 255, 0.18);
|
|
9012
|
+
}
|
|
9013
|
+
|
|
9014
|
+
&:active {
|
|
9015
|
+
transform: scale(0.995);
|
|
9016
|
+
}
|
|
9028
9017
|
|
|
9029
9018
|
&[data-active='true'] {
|
|
9030
9019
|
border-color: rgba(255, 255, 255, 0.2);
|
|
9031
9020
|
background: rgba(255, 255, 255, 0.08);
|
|
9032
9021
|
}
|
|
9033
9022
|
`;
|
|
9034
|
-
var ModeBadge = import_styled15.default.span`
|
|
9035
|
-
flex-shrink: 0;
|
|
9036
|
-
border-radius: 999px;
|
|
9037
|
-
border: 1px solid rgba(255, 255, 255, 0.1);
|
|
9038
|
-
padding: 4px 10px;
|
|
9039
|
-
font-size: 11px;
|
|
9040
|
-
line-height: 1;
|
|
9041
|
-
color: var(--text-secondary);
|
|
9042
|
-
background: rgba(255, 255, 255, 0.04);
|
|
9043
|
-
`;
|
|
9044
9023
|
|
|
9045
9024
|
// src/components/chat-conversation-list/lib/history-session-selection.ts
|
|
9046
9025
|
var shouldLoadHistorySessionMessages = ({
|
|
@@ -9103,16 +9082,7 @@ var ChatConversationList = () => {
|
|
|
9103
9082
|
isLoadingMoreRef.current = false;
|
|
9104
9083
|
hasSeenLoadingMoreRef.current = false;
|
|
9105
9084
|
}, [historySessionList?.sessions.length, historySessionList?.hasMore]);
|
|
9106
|
-
const sessions =
|
|
9107
|
-
if (!historySessionList) {
|
|
9108
|
-
return localSessions;
|
|
9109
|
-
}
|
|
9110
|
-
const localSessionIds = new Set(localSessions.map((session) => session.sessionId));
|
|
9111
|
-
return [
|
|
9112
|
-
...localSessions,
|
|
9113
|
-
...historySessionList.sessions.filter((session) => !localSessionIds.has(session.sessionId))
|
|
9114
|
-
];
|
|
9115
|
-
}, [historySessionList, localSessions]);
|
|
9085
|
+
const sessions = localSessions;
|
|
9116
9086
|
const handleSessionListScroll = (event) => {
|
|
9117
9087
|
if (!historySessionList?.hasMore || historySessionList.isLoading || !onLoadMoreSessions || isLoadingMoreRef.current) {
|
|
9118
9088
|
return;
|
|
@@ -9166,14 +9136,9 @@ var ChatConversationList = () => {
|
|
|
9166
9136
|
);
|
|
9167
9137
|
}
|
|
9168
9138
|
};
|
|
9169
|
-
const modeLabels = {
|
|
9170
|
-
ask: labels.modeLabelAsk,
|
|
9171
|
-
plan: labels.modeLabelPlan,
|
|
9172
|
-
agent: labels.modeLabelAgent
|
|
9173
|
-
};
|
|
9174
9139
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(Container3, { children: [
|
|
9175
9140
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(Toolbar, { children: [
|
|
9176
|
-
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Title3, { children:
|
|
9141
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Title3, { children: labels.sessionsTitle }),
|
|
9177
9142
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(CreateButton, { type: "button", "data-testid": "chat-create-session", onClick: startNewChat, children: labels.newChat })
|
|
9178
9143
|
] }),
|
|
9179
9144
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(List2, { "data-testid": "chat-session-list", onScroll: handleSessionListScroll, children: [
|
|
@@ -9182,7 +9147,6 @@ var ChatConversationList = () => {
|
|
|
9182
9147
|
{
|
|
9183
9148
|
session,
|
|
9184
9149
|
isActive: activeSessionId === session.sessionId,
|
|
9185
|
-
modeLabel: modeLabels[session.mode ?? DEFAULT_CHAT_AGENT_MODE] ?? "",
|
|
9186
9150
|
onClick: (sessionId) => void handleSelectSession(sessionId)
|
|
9187
9151
|
},
|
|
9188
9152
|
session.sessionId
|
|
@@ -9213,13 +9177,32 @@ var Title3 = import_styled16.default.h2`
|
|
|
9213
9177
|
color: var(--text-secondary);
|
|
9214
9178
|
`;
|
|
9215
9179
|
var CreateButton = import_styled16.default.button`
|
|
9216
|
-
border:
|
|
9180
|
+
border: 1px solid rgba(255, 255, 255, 0.18);
|
|
9217
9181
|
border-radius: 12px;
|
|
9218
9182
|
padding: 12px 14px;
|
|
9219
|
-
background:
|
|
9220
|
-
color:
|
|
9183
|
+
background: rgba(255, 255, 255, 0.9);
|
|
9184
|
+
color: rgba(20, 20, 20, 0.92);
|
|
9221
9185
|
text-align: left;
|
|
9222
9186
|
cursor: pointer;
|
|
9187
|
+
transition:
|
|
9188
|
+
background-color 160ms ease,
|
|
9189
|
+
border-color 160ms ease,
|
|
9190
|
+
transform 160ms ease;
|
|
9191
|
+
|
|
9192
|
+
&:hover {
|
|
9193
|
+
background: rgba(255, 255, 255, 0.96);
|
|
9194
|
+
border-color: rgba(255, 255, 255, 0.28);
|
|
9195
|
+
}
|
|
9196
|
+
|
|
9197
|
+
&:focus-visible {
|
|
9198
|
+
outline: none;
|
|
9199
|
+
background: rgba(255, 255, 255, 0.96);
|
|
9200
|
+
border-color: rgba(255, 255, 255, 0.32);
|
|
9201
|
+
}
|
|
9202
|
+
|
|
9203
|
+
&:active {
|
|
9204
|
+
transform: scale(0.995);
|
|
9205
|
+
}
|
|
9223
9206
|
`;
|
|
9224
9207
|
var List2 = import_styled16.default.div`
|
|
9225
9208
|
padding: 0 12px 16px;
|
package/dist/index.mjs
CHANGED
|
@@ -23,6 +23,7 @@ var DEFAULT_AI_CHAT_LABELS = {
|
|
|
23
23
|
stopButton: "Stop",
|
|
24
24
|
retryButton: "Retry",
|
|
25
25
|
scrollToLatest: "Jump to latest",
|
|
26
|
+
sessionsTitle: "Sessions",
|
|
26
27
|
placeholder: "Ask something...",
|
|
27
28
|
modeLabelAsk: "Ask",
|
|
28
29
|
modeLabelPlan: "Plan",
|
|
@@ -66,7 +67,6 @@ var createDraftChatSessionId = () => `${DRAFT_CHAT_SESSION_ID_PREFIX}${Date.now(
|
|
|
66
67
|
var isDraftChatSessionId = (sessionId) => Boolean(sessionId?.startsWith(DRAFT_CHAT_SESSION_ID_PREFIX));
|
|
67
68
|
var createDraftChatSession = ({
|
|
68
69
|
model,
|
|
69
|
-
mode = DEFAULT_CHAT_AGENT_MODE,
|
|
70
70
|
nowIso: nowIso2,
|
|
71
71
|
createSessionId = createDraftChatSessionId
|
|
72
72
|
}) => {
|
|
@@ -76,8 +76,7 @@ var createDraftChatSession = ({
|
|
|
76
76
|
title: "New Chat",
|
|
77
77
|
createdAt: iso,
|
|
78
78
|
updatedAt: iso,
|
|
79
|
-
model
|
|
80
|
-
mode
|
|
79
|
+
model
|
|
81
80
|
};
|
|
82
81
|
};
|
|
83
82
|
|
|
@@ -207,11 +206,7 @@ var createChatStore = (initialState) => createStore((set, get) => ({
|
|
|
207
206
|
createSession: (session) => {
|
|
208
207
|
const state = get();
|
|
209
208
|
const exists = state.sessions.some((s) => s.sessionId === session.sessionId);
|
|
210
|
-
const
|
|
211
|
-
...session,
|
|
212
|
-
mode: session.mode ?? DEFAULT_CHAT_AGENT_MODE
|
|
213
|
-
};
|
|
214
|
-
const nextSessions = exists ? state.sessions : [nextSession, ...state.sessions];
|
|
209
|
+
const nextSessions = exists ? state.sessions : [session, ...state.sessions];
|
|
215
210
|
const nextMessagesBySession = { ...state.messagesBySession };
|
|
216
211
|
const nextErrorBySession = { ...state.errorBySession };
|
|
217
212
|
const nextIsStreamingBySession = { ...state.isStreamingBySession };
|
|
@@ -256,10 +251,8 @@ var createChatStore = (initialState) => createStore((set, get) => ({
|
|
|
256
251
|
});
|
|
257
252
|
},
|
|
258
253
|
startNewChat: () => {
|
|
259
|
-
const state = get();
|
|
260
254
|
const session = createDraftChatSession({
|
|
261
255
|
model: "",
|
|
262
|
-
mode: state.preferredMode,
|
|
263
256
|
nowIso: () => (/* @__PURE__ */ new Date()).toISOString()
|
|
264
257
|
});
|
|
265
258
|
get().createSession(session);
|
|
@@ -345,25 +338,26 @@ var createChatStore = (initialState) => createStore((set, get) => ({
|
|
|
345
338
|
setPreferredMode: (mode) => {
|
|
346
339
|
set({ preferredMode: mode });
|
|
347
340
|
},
|
|
348
|
-
setSessionMode: (sessionId, mode) => {
|
|
349
|
-
const state = get();
|
|
350
|
-
const nextSessions = state.sessions.map(
|
|
351
|
-
(s) => s.sessionId === sessionId ? { ...s, mode } : s
|
|
352
|
-
);
|
|
353
|
-
set({ sessions: nextSessions });
|
|
354
|
-
},
|
|
355
341
|
hydrateHistorySessions: (sessions) => {
|
|
356
342
|
const state = get();
|
|
357
|
-
const
|
|
343
|
+
const draftSessions = state.sessions.filter(
|
|
358
344
|
(session) => isDraftChatSessionId(session.sessionId)
|
|
359
345
|
);
|
|
360
|
-
const
|
|
346
|
+
const activePersistedSession = state.sessions.find(
|
|
347
|
+
(session) => session.sessionId === state.activeSessionId && !isDraftChatSessionId(session.sessionId)
|
|
348
|
+
);
|
|
349
|
+
const hasActiveInIncoming = sessions.some(
|
|
350
|
+
(session) => session.sessionId === state.activeSessionId
|
|
351
|
+
);
|
|
352
|
+
const keepActiveSession = activePersistedSession && !hasActiveInIncoming ? [activePersistedSession] : [];
|
|
353
|
+
const excludeIds = /* @__PURE__ */ new Set([
|
|
354
|
+
...draftSessions.map((s) => s.sessionId),
|
|
355
|
+
...keepActiveSession.map((s) => s.sessionId)
|
|
356
|
+
]);
|
|
361
357
|
const nextSessions = [
|
|
362
|
-
...
|
|
363
|
-
...sessions.filter((session) => !
|
|
364
|
-
|
|
365
|
-
mode: session.mode ?? DEFAULT_CHAT_AGENT_MODE
|
|
366
|
-
}))
|
|
358
|
+
...draftSessions,
|
|
359
|
+
...sessions.filter((session) => !excludeIds.has(session.sessionId)),
|
|
360
|
+
...keepActiveSession
|
|
367
361
|
];
|
|
368
362
|
const nextMessagesBySession = { ...state.messagesBySession };
|
|
369
363
|
const nextErrorBySession = { ...state.errorBySession };
|
|
@@ -3097,9 +3091,8 @@ var ChatMessageItemView = ({
|
|
|
3097
3091
|
const hasMarkdownOnlyBlocks = hasStructuredBlocks && blocks.every((block) => block.type === "markdown");
|
|
3098
3092
|
const hasTextContent = Boolean(settledContent || freshContent || displayedContent);
|
|
3099
3093
|
const shouldRenderStructuredBlocks = hasStructuredBlocks && !(isAssistantStreaming && hasMarkdownOnlyBlocks && hasTextContent);
|
|
3100
|
-
const
|
|
3101
|
-
const
|
|
3102
|
-
const canSubmitQuestionnaire = isPlanMode && typeof onQuestionnaireSubmit === "function";
|
|
3094
|
+
const canSubmitConfirmation = typeof onConfirmationSubmit === "function";
|
|
3095
|
+
const canSubmitQuestionnaire = typeof onQuestionnaireSubmit === "function";
|
|
3103
3096
|
const shouldShowStreamingCaret = isAssistantStreaming && (!shouldRenderStructuredBlocks || hasTextContent);
|
|
3104
3097
|
const isUserMessage = message.role === "user";
|
|
3105
3098
|
const messageRenderMode = isUserMessage ? "plain-text" : "markdown";
|
|
@@ -3157,7 +3150,7 @@ var ChatMessageItemView = ({
|
|
|
3157
3150
|
ExecutionConfirmationCard,
|
|
3158
3151
|
{
|
|
3159
3152
|
proposal: block.proposal,
|
|
3160
|
-
interactive:
|
|
3153
|
+
interactive: canSubmitConfirmation,
|
|
3161
3154
|
onConfirm: canSubmitConfirmation ? () => onConfirmationSubmit({
|
|
3162
3155
|
proposalId: block.proposal.proposalId,
|
|
3163
3156
|
content: createExecutionConfirmationContent(block.proposal),
|
|
@@ -3787,7 +3780,7 @@ var groupConversationTurns = (historyMessages, streamingMessage) => {
|
|
|
3787
3780
|
];
|
|
3788
3781
|
};
|
|
3789
3782
|
var ChatThreadView = ({
|
|
3790
|
-
|
|
3783
|
+
activeMode = DEFAULT_CHAT_AGENT_MODE,
|
|
3791
3784
|
historyMessages,
|
|
3792
3785
|
streamingMessage,
|
|
3793
3786
|
error: error2,
|
|
@@ -4043,7 +4036,7 @@ var ChatThreadView = ({
|
|
|
4043
4036
|
style: isLatestTurn ? { scrollMarginTop: `${CHAT_THREAD_SCROLL_TOP_GAP}px` } : void 0,
|
|
4044
4037
|
children: renderChatMessage({
|
|
4045
4038
|
message: turn.userMessage,
|
|
4046
|
-
mode:
|
|
4039
|
+
mode: activeMode,
|
|
4047
4040
|
onConfirmationSubmit,
|
|
4048
4041
|
onQuestionnaireSubmit,
|
|
4049
4042
|
renderMessageBlock
|
|
@@ -4052,7 +4045,7 @@ var ChatThreadView = ({
|
|
|
4052
4045
|
) : null,
|
|
4053
4046
|
turn.responseMessages.map((message) => /* @__PURE__ */ jsx10(MessageSlot, { children: renderChatMessage({
|
|
4054
4047
|
message,
|
|
4055
|
-
mode:
|
|
4048
|
+
mode: activeMode,
|
|
4056
4049
|
onConfirmationSubmit,
|
|
4057
4050
|
onQuestionnaireSubmit,
|
|
4058
4051
|
renderMessageBlock
|
|
@@ -4086,7 +4079,7 @@ var ChatThread = () => {
|
|
|
4086
4079
|
const activeSession = useChatStore(
|
|
4087
4080
|
(s) => s.sessions.find((session) => session.sessionId === s.activeSessionId)
|
|
4088
4081
|
);
|
|
4089
|
-
const
|
|
4082
|
+
const preferredMode = useChatStore((s) => s.preferredMode);
|
|
4090
4083
|
const messages = useChatStore(
|
|
4091
4084
|
(s) => s.messagesBySession[s.activeSessionId ?? ""] ?? EMPTY_MESSAGES
|
|
4092
4085
|
);
|
|
@@ -4125,7 +4118,7 @@ var ChatThread = () => {
|
|
|
4125
4118
|
if (customQuestionnaireSubmit) {
|
|
4126
4119
|
const handled = await customQuestionnaireSubmit(submission, {
|
|
4127
4120
|
sessionId: sourceSessionId ?? void 0,
|
|
4128
|
-
mode:
|
|
4121
|
+
mode: preferredMode
|
|
4129
4122
|
});
|
|
4130
4123
|
if (handled !== false) {
|
|
4131
4124
|
if (sourceSessionId && submission.sourceMessageId) {
|
|
@@ -4152,7 +4145,7 @@ var ChatThread = () => {
|
|
|
4152
4145
|
);
|
|
4153
4146
|
}
|
|
4154
4147
|
},
|
|
4155
|
-
[activeSessionId,
|
|
4148
|
+
[activeSessionId, customQuestionnaireSubmit, preferredMode, sendRef, updateQA]
|
|
4156
4149
|
);
|
|
4157
4150
|
const handleConfirmation = useCallback3(
|
|
4158
4151
|
async (submission) => {
|
|
@@ -4160,7 +4153,7 @@ var ChatThread = () => {
|
|
|
4160
4153
|
if (customConfirmationSubmit) {
|
|
4161
4154
|
const handled = await customConfirmationSubmit(submission, {
|
|
4162
4155
|
sessionId: sourceSessionId ?? void 0,
|
|
4163
|
-
mode:
|
|
4156
|
+
mode: preferredMode
|
|
4164
4157
|
});
|
|
4165
4158
|
if (handled !== false) {
|
|
4166
4159
|
return;
|
|
@@ -4171,7 +4164,7 @@ var ChatThread = () => {
|
|
|
4171
4164
|
includeComposerAttachments: false
|
|
4172
4165
|
});
|
|
4173
4166
|
},
|
|
4174
|
-
[activeSessionId,
|
|
4167
|
+
[activeSessionId, customConfirmationSubmit, preferredMode, sendRef]
|
|
4175
4168
|
);
|
|
4176
4169
|
const handleLoadPreviousMessages = useCallback3(async () => {
|
|
4177
4170
|
if (!activeSession || !onLoadMoreHistoryMessages || !historyMessagePagination?.hasMorePrevious || !historyMessagePagination.previousCursor || historyMessagePagination.isLoadingPrevious) {
|
|
@@ -4215,7 +4208,7 @@ var ChatThread = () => {
|
|
|
4215
4208
|
return /* @__PURE__ */ jsx10(
|
|
4216
4209
|
ChatThreadView,
|
|
4217
4210
|
{
|
|
4218
|
-
|
|
4211
|
+
activeMode: preferredMode,
|
|
4219
4212
|
historyMessages: messages,
|
|
4220
4213
|
streamingMessage,
|
|
4221
4214
|
error: error2,
|
|
@@ -6947,7 +6940,6 @@ var resolveSelectedChatModel = ({
|
|
|
6947
6940
|
var resolveSendSession = ({
|
|
6948
6941
|
activeSessionId,
|
|
6949
6942
|
selectedModel,
|
|
6950
|
-
selectedMode,
|
|
6951
6943
|
nowIso: nowIso2,
|
|
6952
6944
|
createSessionId
|
|
6953
6945
|
}) => {
|
|
@@ -6959,7 +6951,6 @@ var resolveSendSession = ({
|
|
|
6959
6951
|
}
|
|
6960
6952
|
const session = createDraftChatSession({
|
|
6961
6953
|
model: selectedModel,
|
|
6962
|
-
mode: selectedMode ?? DEFAULT_CHAT_AGENT_MODE,
|
|
6963
6954
|
nowIso: nowIso2,
|
|
6964
6955
|
createSessionId
|
|
6965
6956
|
});
|
|
@@ -7117,9 +7108,6 @@ var useChatComposer = () => {
|
|
|
7117
7108
|
const skillsLoader = transport.getSkills;
|
|
7118
7109
|
const activeSkillsLoaderRef = useRef10(skillsLoader);
|
|
7119
7110
|
const activeSessionId = useChatStore((s) => s.activeSessionId);
|
|
7120
|
-
const activeSession = useChatStore(
|
|
7121
|
-
(s) => s.sessions.find((x) => x.sessionId === s.activeSessionId) ?? null
|
|
7122
|
-
);
|
|
7123
7111
|
const preferredMode = useChatStore((s) => s.preferredMode);
|
|
7124
7112
|
const streamingSessionId = useChatStore(
|
|
7125
7113
|
(s) => s.activeSessionId && s.isStreamingBySession[s.activeSessionId] ? s.activeSessionId : null
|
|
@@ -7140,7 +7128,6 @@ var useChatComposer = () => {
|
|
|
7140
7128
|
const setSessionError = useChatStore((s) => s.setSessionError);
|
|
7141
7129
|
const clearSessionError = useChatStore((s) => s.clearSessionError);
|
|
7142
7130
|
const setPreferredMode = useChatStore((s) => s.setPreferredMode);
|
|
7143
|
-
const setSessionMode = useChatStore((s) => s.setSessionMode);
|
|
7144
7131
|
const [availableModels, setAvailableModels] = useState8([]);
|
|
7145
7132
|
const [isModelsLoading, setIsModelsLoading] = useState8(true);
|
|
7146
7133
|
const [isModelsError, setIsModelsError] = useState8(false);
|
|
@@ -7221,12 +7208,8 @@ var useChatComposer = () => {
|
|
|
7221
7208
|
);
|
|
7222
7209
|
}, [availableModels, isModelsLoading]);
|
|
7223
7210
|
useEffect8(() => {
|
|
7224
|
-
if (activeSession) {
|
|
7225
|
-
setSelectedModeLocal(activeSession.mode ?? DEFAULT_CHAT_AGENT_MODE);
|
|
7226
|
-
return;
|
|
7227
|
-
}
|
|
7228
7211
|
setSelectedModeLocal(preferredMode ?? DEFAULT_CHAT_AGENT_MODE);
|
|
7229
|
-
}, [
|
|
7212
|
+
}, [preferredMode]);
|
|
7230
7213
|
useEffect8(() => {
|
|
7231
7214
|
if (previousActiveSessionIdRef.current !== activeSessionId) {
|
|
7232
7215
|
setSelectedSkills([]);
|
|
@@ -7434,7 +7417,7 @@ var useChatComposer = () => {
|
|
|
7434
7417
|
const storeState = store.getState();
|
|
7435
7418
|
const currentActiveSessionId = options?.sessionId ?? storeState.activeSessionId;
|
|
7436
7419
|
const currentActiveSession = storeState.sessions.find((session2) => session2.sessionId === currentActiveSessionId) ?? null;
|
|
7437
|
-
const currentMode =
|
|
7420
|
+
const currentMode = selectedMode;
|
|
7438
7421
|
if (!(selectedModel || currentActiveSession?.model || availableModels[0]?.id)) {
|
|
7439
7422
|
return;
|
|
7440
7423
|
}
|
|
@@ -7442,7 +7425,6 @@ var useChatComposer = () => {
|
|
|
7442
7425
|
const { localSessionId, sessionId, session } = resolveSendSession({
|
|
7443
7426
|
activeSessionId: currentActiveSessionId,
|
|
7444
7427
|
selectedModel: resolvedModel,
|
|
7445
|
-
selectedMode: currentMode,
|
|
7446
7428
|
nowIso,
|
|
7447
7429
|
createSessionId: createDraftChatSessionId
|
|
7448
7430
|
});
|
|
@@ -7590,8 +7572,6 @@ var useChatComposer = () => {
|
|
|
7590
7572
|
setSelectedMode: (mode) => {
|
|
7591
7573
|
setSelectedModeLocal(mode);
|
|
7592
7574
|
setPreferredMode(mode);
|
|
7593
|
-
if (activeSessionId)
|
|
7594
|
-
setSessionMode(activeSessionId, mode);
|
|
7595
7575
|
if (activeSessionId) {
|
|
7596
7576
|
const previousRequest = lastRequestBySessionRef.current.get(activeSessionId);
|
|
7597
7577
|
if (previousRequest) {
|
|
@@ -8937,38 +8917,28 @@ var SkillButton = styled14.button`
|
|
|
8937
8917
|
`;
|
|
8938
8918
|
|
|
8939
8919
|
// src/components/chat-conversation-list/index.tsx
|
|
8940
|
-
import { useEffect as useEffect10,
|
|
8920
|
+
import { useEffect as useEffect10, useRef as useRef12 } from "react";
|
|
8941
8921
|
import styled16 from "@emotion/styled";
|
|
8942
8922
|
|
|
8943
8923
|
// src/components/chat-conversation-list/components/chat-session-item.tsx
|
|
8944
8924
|
import { memo as memo2 } from "react";
|
|
8945
8925
|
import styled15 from "@emotion/styled";
|
|
8946
|
-
import { jsx as jsx17
|
|
8947
|
-
var ChatSessionItem = memo2(
|
|
8948
|
-
|
|
8949
|
-
|
|
8950
|
-
|
|
8951
|
-
|
|
8952
|
-
|
|
8953
|
-
|
|
8954
|
-
|
|
8955
|
-
|
|
8956
|
-
|
|
8957
|
-
|
|
8958
|
-
|
|
8959
|
-
] })
|
|
8960
|
-
}
|
|
8961
|
-
);
|
|
8962
|
-
}
|
|
8963
|
-
);
|
|
8926
|
+
import { jsx as jsx17 } from "@emotion/react/jsx-runtime";
|
|
8927
|
+
var ChatSessionItem = memo2(({ session, isActive, onClick }) => {
|
|
8928
|
+
return /* @__PURE__ */ jsx17(
|
|
8929
|
+
SessionButton,
|
|
8930
|
+
{
|
|
8931
|
+
type: "button",
|
|
8932
|
+
"data-active": isActive,
|
|
8933
|
+
"data-testid": `chat-session-item-${session.sessionId}`,
|
|
8934
|
+
onClick: () => onClick(session.sessionId),
|
|
8935
|
+
children: /* @__PURE__ */ jsx17(SessionTitle, { children: session.title })
|
|
8936
|
+
}
|
|
8937
|
+
);
|
|
8938
|
+
});
|
|
8964
8939
|
ChatSessionItem.displayName = "ChatSessionItem";
|
|
8965
|
-
var SessionMeta = styled15.div`
|
|
8966
|
-
display: flex;
|
|
8967
|
-
align-items: center;
|
|
8968
|
-
justify-content: space-between;
|
|
8969
|
-
gap: 8px;
|
|
8970
|
-
`;
|
|
8971
8940
|
var SessionTitle = styled15.span`
|
|
8941
|
+
display: block;
|
|
8972
8942
|
min-width: 0;
|
|
8973
8943
|
overflow: hidden;
|
|
8974
8944
|
text-overflow: ellipsis;
|
|
@@ -8982,22 +8952,31 @@ var SessionButton = styled15.button`
|
|
|
8982
8952
|
color: var(--text-primary);
|
|
8983
8953
|
background: rgba(255, 255, 255, 0.03);
|
|
8984
8954
|
cursor: pointer;
|
|
8955
|
+
transition:
|
|
8956
|
+
background-color 160ms ease,
|
|
8957
|
+
border-color 160ms ease,
|
|
8958
|
+
transform 160ms ease;
|
|
8959
|
+
|
|
8960
|
+
&:hover {
|
|
8961
|
+
background: rgba(255, 255, 255, 0.06);
|
|
8962
|
+
border-color: rgba(255, 255, 255, 0.08);
|
|
8963
|
+
}
|
|
8964
|
+
|
|
8965
|
+
&:focus-visible {
|
|
8966
|
+
outline: none;
|
|
8967
|
+
background: rgba(255, 255, 255, 0.06);
|
|
8968
|
+
border-color: rgba(255, 255, 255, 0.18);
|
|
8969
|
+
}
|
|
8970
|
+
|
|
8971
|
+
&:active {
|
|
8972
|
+
transform: scale(0.995);
|
|
8973
|
+
}
|
|
8985
8974
|
|
|
8986
8975
|
&[data-active='true'] {
|
|
8987
8976
|
border-color: rgba(255, 255, 255, 0.2);
|
|
8988
8977
|
background: rgba(255, 255, 255, 0.08);
|
|
8989
8978
|
}
|
|
8990
8979
|
`;
|
|
8991
|
-
var ModeBadge = styled15.span`
|
|
8992
|
-
flex-shrink: 0;
|
|
8993
|
-
border-radius: 999px;
|
|
8994
|
-
border: 1px solid rgba(255, 255, 255, 0.1);
|
|
8995
|
-
padding: 4px 10px;
|
|
8996
|
-
font-size: 11px;
|
|
8997
|
-
line-height: 1;
|
|
8998
|
-
color: var(--text-secondary);
|
|
8999
|
-
background: rgba(255, 255, 255, 0.04);
|
|
9000
|
-
`;
|
|
9001
8980
|
|
|
9002
8981
|
// src/components/chat-conversation-list/lib/history-session-selection.ts
|
|
9003
8982
|
var shouldLoadHistorySessionMessages = ({
|
|
@@ -9018,7 +8997,7 @@ var shouldLoadHistorySessionMessages = ({
|
|
|
9018
8997
|
};
|
|
9019
8998
|
|
|
9020
8999
|
// src/components/chat-conversation-list/index.tsx
|
|
9021
|
-
import { jsx as jsx18, jsxs as
|
|
9000
|
+
import { jsx as jsx18, jsxs as jsxs12 } from "@emotion/react/jsx-runtime";
|
|
9022
9001
|
var SCROLL_LOAD_MORE_THRESHOLD_PX = 80;
|
|
9023
9002
|
var shouldLoadMoreSessions = ({
|
|
9024
9003
|
scrollTop,
|
|
@@ -9060,16 +9039,7 @@ var ChatConversationList = () => {
|
|
|
9060
9039
|
isLoadingMoreRef.current = false;
|
|
9061
9040
|
hasSeenLoadingMoreRef.current = false;
|
|
9062
9041
|
}, [historySessionList?.sessions.length, historySessionList?.hasMore]);
|
|
9063
|
-
const sessions =
|
|
9064
|
-
if (!historySessionList) {
|
|
9065
|
-
return localSessions;
|
|
9066
|
-
}
|
|
9067
|
-
const localSessionIds = new Set(localSessions.map((session) => session.sessionId));
|
|
9068
|
-
return [
|
|
9069
|
-
...localSessions,
|
|
9070
|
-
...historySessionList.sessions.filter((session) => !localSessionIds.has(session.sessionId))
|
|
9071
|
-
];
|
|
9072
|
-
}, [historySessionList, localSessions]);
|
|
9042
|
+
const sessions = localSessions;
|
|
9073
9043
|
const handleSessionListScroll = (event) => {
|
|
9074
9044
|
if (!historySessionList?.hasMore || historySessionList.isLoading || !onLoadMoreSessions || isLoadingMoreRef.current) {
|
|
9075
9045
|
return;
|
|
@@ -9123,23 +9093,17 @@ var ChatConversationList = () => {
|
|
|
9123
9093
|
);
|
|
9124
9094
|
}
|
|
9125
9095
|
};
|
|
9126
|
-
|
|
9127
|
-
|
|
9128
|
-
|
|
9129
|
-
agent: labels.modeLabelAgent
|
|
9130
|
-
};
|
|
9131
|
-
return /* @__PURE__ */ jsxs13(Container3, { children: [
|
|
9132
|
-
/* @__PURE__ */ jsxs13(Toolbar, { children: [
|
|
9133
|
-
/* @__PURE__ */ jsx18(Title3, { children: "Sessions" }),
|
|
9096
|
+
return /* @__PURE__ */ jsxs12(Container3, { children: [
|
|
9097
|
+
/* @__PURE__ */ jsxs12(Toolbar, { children: [
|
|
9098
|
+
/* @__PURE__ */ jsx18(Title3, { children: labels.sessionsTitle }),
|
|
9134
9099
|
/* @__PURE__ */ jsx18(CreateButton, { type: "button", "data-testid": "chat-create-session", onClick: startNewChat, children: labels.newChat })
|
|
9135
9100
|
] }),
|
|
9136
|
-
/* @__PURE__ */
|
|
9101
|
+
/* @__PURE__ */ jsxs12(List2, { "data-testid": "chat-session-list", onScroll: handleSessionListScroll, children: [
|
|
9137
9102
|
sessions.map((session) => /* @__PURE__ */ jsx18(
|
|
9138
9103
|
ChatSessionItem,
|
|
9139
9104
|
{
|
|
9140
9105
|
session,
|
|
9141
9106
|
isActive: activeSessionId === session.sessionId,
|
|
9142
|
-
modeLabel: modeLabels[session.mode ?? DEFAULT_CHAT_AGENT_MODE] ?? "",
|
|
9143
9107
|
onClick: (sessionId) => void handleSelectSession(sessionId)
|
|
9144
9108
|
},
|
|
9145
9109
|
session.sessionId
|
|
@@ -9170,13 +9134,32 @@ var Title3 = styled16.h2`
|
|
|
9170
9134
|
color: var(--text-secondary);
|
|
9171
9135
|
`;
|
|
9172
9136
|
var CreateButton = styled16.button`
|
|
9173
|
-
border:
|
|
9137
|
+
border: 1px solid rgba(255, 255, 255, 0.18);
|
|
9174
9138
|
border-radius: 12px;
|
|
9175
9139
|
padding: 12px 14px;
|
|
9176
|
-
background:
|
|
9177
|
-
color:
|
|
9140
|
+
background: rgba(255, 255, 255, 0.9);
|
|
9141
|
+
color: rgba(20, 20, 20, 0.92);
|
|
9178
9142
|
text-align: left;
|
|
9179
9143
|
cursor: pointer;
|
|
9144
|
+
transition:
|
|
9145
|
+
background-color 160ms ease,
|
|
9146
|
+
border-color 160ms ease,
|
|
9147
|
+
transform 160ms ease;
|
|
9148
|
+
|
|
9149
|
+
&:hover {
|
|
9150
|
+
background: rgba(255, 255, 255, 0.96);
|
|
9151
|
+
border-color: rgba(255, 255, 255, 0.28);
|
|
9152
|
+
}
|
|
9153
|
+
|
|
9154
|
+
&:focus-visible {
|
|
9155
|
+
outline: none;
|
|
9156
|
+
background: rgba(255, 255, 255, 0.96);
|
|
9157
|
+
border-color: rgba(255, 255, 255, 0.32);
|
|
9158
|
+
}
|
|
9159
|
+
|
|
9160
|
+
&:active {
|
|
9161
|
+
transform: scale(0.995);
|
|
9162
|
+
}
|
|
9180
9163
|
`;
|
|
9181
9164
|
var List2 = styled16.div`
|
|
9182
9165
|
padding: 0 12px 16px;
|
|
@@ -9192,7 +9175,7 @@ var StateRow = styled16.div`
|
|
|
9192
9175
|
`;
|
|
9193
9176
|
|
|
9194
9177
|
// src/components/ai-chat/index.tsx
|
|
9195
|
-
import { Fragment as Fragment6, jsx as jsx19, jsxs as
|
|
9178
|
+
import { Fragment as Fragment6, jsx as jsx19, jsxs as jsxs13 } from "@emotion/react/jsx-runtime";
|
|
9196
9179
|
var NewTalkIcon = () => /* @__PURE__ */ jsx19(
|
|
9197
9180
|
"svg",
|
|
9198
9181
|
{
|
|
@@ -9203,7 +9186,7 @@ var NewTalkIcon = () => /* @__PURE__ */ jsx19(
|
|
|
9203
9186
|
fill: "none",
|
|
9204
9187
|
style: { display: "block" },
|
|
9205
9188
|
xmlns: "http://www.w3.org/2000/svg",
|
|
9206
|
-
children: /* @__PURE__ */
|
|
9189
|
+
children: /* @__PURE__ */ jsxs13(
|
|
9207
9190
|
"g",
|
|
9208
9191
|
{
|
|
9209
9192
|
transform: "translate(1.8909 2.0364)",
|
|
@@ -9212,7 +9195,7 @@ var NewTalkIcon = () => /* @__PURE__ */ jsx19(
|
|
|
9212
9195
|
strokeLinejoin: "round",
|
|
9213
9196
|
strokeWidth: "1.36533333",
|
|
9214
9197
|
children: [
|
|
9215
|
-
/* @__PURE__ */
|
|
9198
|
+
/* @__PURE__ */ jsxs13("g", { transform: "translate(9.8909 2.3273) rotate(-315) translate(-9.8909 -2.3273) translate(8.2909 0.7273)", children: [
|
|
9216
9199
|
/* @__PURE__ */ jsx19("path", { d: "M0 0C0 0 1.06666667 1.06666667 3.2 3.2" }),
|
|
9217
9200
|
/* @__PURE__ */ jsx19("path", { d: "M3.2 0C3.2 0 2.13333333 1.06666667 0 3.2" })
|
|
9218
9201
|
] }),
|
|
@@ -9254,9 +9237,9 @@ var AiChatWorkspaceContent = ({
|
|
|
9254
9237
|
useEffect11(() => {
|
|
9255
9238
|
onConversationStartedChange?.(isConversationStarted);
|
|
9256
9239
|
}, [isConversationStarted, onConversationStartedChange]);
|
|
9257
|
-
return /* @__PURE__ */
|
|
9240
|
+
return /* @__PURE__ */ jsxs13(Root, { "data-testid": "ai-chat", children: [
|
|
9258
9241
|
showConversationList ? /* @__PURE__ */ jsx19(ChatConversationList, {}) : null,
|
|
9259
|
-
/* @__PURE__ */
|
|
9242
|
+
/* @__PURE__ */ jsxs13(Workspace, { children: [
|
|
9260
9243
|
showNewChatButton && !showConversationList && !shouldShowComposerOnly ? /* @__PURE__ */ jsx19(QuickActions, { renderNewChatTrigger }) : null,
|
|
9261
9244
|
shouldShowComposerOnly ? null : /* @__PURE__ */ jsx19(ChatThread, {}),
|
|
9262
9245
|
/* @__PURE__ */ jsx19(ChatComposer, {})
|