@xinghunm/ai-chat 1.4.0 → 1.4.1
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 +78 -94
- package/dist/index.mjs +88 -104
- 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,13 +385,6 @@ 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
390
|
const localSessions = state.sessions.filter(
|
|
@@ -407,10 +393,7 @@ var createChatStore = (initialState) => (0, import_vanilla.createStore)((set, ge
|
|
|
407
393
|
const localSessionIds = new Set(localSessions.map((session) => session.sessionId));
|
|
408
394
|
const nextSessions = [
|
|
409
395
|
...localSessions,
|
|
410
|
-
...sessions.filter((session) => !localSessionIds.has(session.sessionId))
|
|
411
|
-
...session,
|
|
412
|
-
mode: session.mode ?? DEFAULT_CHAT_AGENT_MODE
|
|
413
|
-
}))
|
|
396
|
+
...sessions.filter((session) => !localSessionIds.has(session.sessionId))
|
|
414
397
|
];
|
|
415
398
|
const nextMessagesBySession = { ...state.messagesBySession };
|
|
416
399
|
const nextErrorBySession = { ...state.errorBySession };
|
|
@@ -3140,9 +3123,8 @@ var ChatMessageItemView = ({
|
|
|
3140
3123
|
const hasMarkdownOnlyBlocks = hasStructuredBlocks && blocks.every((block) => block.type === "markdown");
|
|
3141
3124
|
const hasTextContent = Boolean(settledContent || freshContent || displayedContent);
|
|
3142
3125
|
const shouldRenderStructuredBlocks = hasStructuredBlocks && !(isAssistantStreaming && hasMarkdownOnlyBlocks && hasTextContent);
|
|
3143
|
-
const
|
|
3144
|
-
const
|
|
3145
|
-
const canSubmitQuestionnaire = isPlanMode && typeof onQuestionnaireSubmit === "function";
|
|
3126
|
+
const canSubmitConfirmation = typeof onConfirmationSubmit === "function";
|
|
3127
|
+
const canSubmitQuestionnaire = typeof onQuestionnaireSubmit === "function";
|
|
3146
3128
|
const shouldShowStreamingCaret = isAssistantStreaming && (!shouldRenderStructuredBlocks || hasTextContent);
|
|
3147
3129
|
const isUserMessage = message.role === "user";
|
|
3148
3130
|
const messageRenderMode = isUserMessage ? "plain-text" : "markdown";
|
|
@@ -3200,7 +3182,7 @@ var ChatMessageItemView = ({
|
|
|
3200
3182
|
ExecutionConfirmationCard,
|
|
3201
3183
|
{
|
|
3202
3184
|
proposal: block.proposal,
|
|
3203
|
-
interactive:
|
|
3185
|
+
interactive: canSubmitConfirmation,
|
|
3204
3186
|
onConfirm: canSubmitConfirmation ? () => onConfirmationSubmit({
|
|
3205
3187
|
proposalId: block.proposal.proposalId,
|
|
3206
3188
|
content: createExecutionConfirmationContent(block.proposal),
|
|
@@ -3830,7 +3812,7 @@ var groupConversationTurns = (historyMessages, streamingMessage) => {
|
|
|
3830
3812
|
];
|
|
3831
3813
|
};
|
|
3832
3814
|
var ChatThreadView = ({
|
|
3833
|
-
|
|
3815
|
+
activeMode = DEFAULT_CHAT_AGENT_MODE,
|
|
3834
3816
|
historyMessages,
|
|
3835
3817
|
streamingMessage,
|
|
3836
3818
|
error: error2,
|
|
@@ -4086,7 +4068,7 @@ var ChatThreadView = ({
|
|
|
4086
4068
|
style: isLatestTurn ? { scrollMarginTop: `${CHAT_THREAD_SCROLL_TOP_GAP}px` } : void 0,
|
|
4087
4069
|
children: renderChatMessage({
|
|
4088
4070
|
message: turn.userMessage,
|
|
4089
|
-
mode:
|
|
4071
|
+
mode: activeMode,
|
|
4090
4072
|
onConfirmationSubmit,
|
|
4091
4073
|
onQuestionnaireSubmit,
|
|
4092
4074
|
renderMessageBlock
|
|
@@ -4095,7 +4077,7 @@ var ChatThreadView = ({
|
|
|
4095
4077
|
) : null,
|
|
4096
4078
|
turn.responseMessages.map((message) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(MessageSlot, { children: renderChatMessage({
|
|
4097
4079
|
message,
|
|
4098
|
-
mode:
|
|
4080
|
+
mode: activeMode,
|
|
4099
4081
|
onConfirmationSubmit,
|
|
4100
4082
|
onQuestionnaireSubmit,
|
|
4101
4083
|
renderMessageBlock
|
|
@@ -4129,7 +4111,7 @@ var ChatThread = () => {
|
|
|
4129
4111
|
const activeSession = useChatStore(
|
|
4130
4112
|
(s) => s.sessions.find((session) => session.sessionId === s.activeSessionId)
|
|
4131
4113
|
);
|
|
4132
|
-
const
|
|
4114
|
+
const preferredMode = useChatStore((s) => s.preferredMode);
|
|
4133
4115
|
const messages = useChatStore(
|
|
4134
4116
|
(s) => s.messagesBySession[s.activeSessionId ?? ""] ?? EMPTY_MESSAGES
|
|
4135
4117
|
);
|
|
@@ -4168,7 +4150,7 @@ var ChatThread = () => {
|
|
|
4168
4150
|
if (customQuestionnaireSubmit) {
|
|
4169
4151
|
const handled = await customQuestionnaireSubmit(submission, {
|
|
4170
4152
|
sessionId: sourceSessionId ?? void 0,
|
|
4171
|
-
mode:
|
|
4153
|
+
mode: preferredMode
|
|
4172
4154
|
});
|
|
4173
4155
|
if (handled !== false) {
|
|
4174
4156
|
if (sourceSessionId && submission.sourceMessageId) {
|
|
@@ -4195,7 +4177,7 @@ var ChatThread = () => {
|
|
|
4195
4177
|
);
|
|
4196
4178
|
}
|
|
4197
4179
|
},
|
|
4198
|
-
[activeSessionId,
|
|
4180
|
+
[activeSessionId, customQuestionnaireSubmit, preferredMode, sendRef, updateQA]
|
|
4199
4181
|
);
|
|
4200
4182
|
const handleConfirmation = (0, import_react11.useCallback)(
|
|
4201
4183
|
async (submission) => {
|
|
@@ -4203,7 +4185,7 @@ var ChatThread = () => {
|
|
|
4203
4185
|
if (customConfirmationSubmit) {
|
|
4204
4186
|
const handled = await customConfirmationSubmit(submission, {
|
|
4205
4187
|
sessionId: sourceSessionId ?? void 0,
|
|
4206
|
-
mode:
|
|
4188
|
+
mode: preferredMode
|
|
4207
4189
|
});
|
|
4208
4190
|
if (handled !== false) {
|
|
4209
4191
|
return;
|
|
@@ -4214,7 +4196,7 @@ var ChatThread = () => {
|
|
|
4214
4196
|
includeComposerAttachments: false
|
|
4215
4197
|
});
|
|
4216
4198
|
},
|
|
4217
|
-
[activeSessionId,
|
|
4199
|
+
[activeSessionId, customConfirmationSubmit, preferredMode, sendRef]
|
|
4218
4200
|
);
|
|
4219
4201
|
const handleLoadPreviousMessages = (0, import_react11.useCallback)(async () => {
|
|
4220
4202
|
if (!activeSession || !onLoadMoreHistoryMessages || !historyMessagePagination?.hasMorePrevious || !historyMessagePagination.previousCursor || historyMessagePagination.isLoadingPrevious) {
|
|
@@ -4258,7 +4240,7 @@ var ChatThread = () => {
|
|
|
4258
4240
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
4259
4241
|
ChatThreadView,
|
|
4260
4242
|
{
|
|
4261
|
-
|
|
4243
|
+
activeMode: preferredMode,
|
|
4262
4244
|
historyMessages: messages,
|
|
4263
4245
|
streamingMessage,
|
|
4264
4246
|
error: error2,
|
|
@@ -6990,7 +6972,6 @@ var resolveSelectedChatModel = ({
|
|
|
6990
6972
|
var resolveSendSession = ({
|
|
6991
6973
|
activeSessionId,
|
|
6992
6974
|
selectedModel,
|
|
6993
|
-
selectedMode,
|
|
6994
6975
|
nowIso: nowIso2,
|
|
6995
6976
|
createSessionId
|
|
6996
6977
|
}) => {
|
|
@@ -7002,7 +6983,6 @@ var resolveSendSession = ({
|
|
|
7002
6983
|
}
|
|
7003
6984
|
const session = createDraftChatSession({
|
|
7004
6985
|
model: selectedModel,
|
|
7005
|
-
mode: selectedMode ?? DEFAULT_CHAT_AGENT_MODE,
|
|
7006
6986
|
nowIso: nowIso2,
|
|
7007
6987
|
createSessionId
|
|
7008
6988
|
});
|
|
@@ -7160,9 +7140,6 @@ var useChatComposer = () => {
|
|
|
7160
7140
|
const skillsLoader = transport.getSkills;
|
|
7161
7141
|
const activeSkillsLoaderRef = (0, import_react15.useRef)(skillsLoader);
|
|
7162
7142
|
const activeSessionId = useChatStore((s) => s.activeSessionId);
|
|
7163
|
-
const activeSession = useChatStore(
|
|
7164
|
-
(s) => s.sessions.find((x) => x.sessionId === s.activeSessionId) ?? null
|
|
7165
|
-
);
|
|
7166
7143
|
const preferredMode = useChatStore((s) => s.preferredMode);
|
|
7167
7144
|
const streamingSessionId = useChatStore(
|
|
7168
7145
|
(s) => s.activeSessionId && s.isStreamingBySession[s.activeSessionId] ? s.activeSessionId : null
|
|
@@ -7183,7 +7160,6 @@ var useChatComposer = () => {
|
|
|
7183
7160
|
const setSessionError = useChatStore((s) => s.setSessionError);
|
|
7184
7161
|
const clearSessionError = useChatStore((s) => s.clearSessionError);
|
|
7185
7162
|
const setPreferredMode = useChatStore((s) => s.setPreferredMode);
|
|
7186
|
-
const setSessionMode = useChatStore((s) => s.setSessionMode);
|
|
7187
7163
|
const [availableModels, setAvailableModels] = (0, import_react15.useState)([]);
|
|
7188
7164
|
const [isModelsLoading, setIsModelsLoading] = (0, import_react15.useState)(true);
|
|
7189
7165
|
const [isModelsError, setIsModelsError] = (0, import_react15.useState)(false);
|
|
@@ -7264,12 +7240,8 @@ var useChatComposer = () => {
|
|
|
7264
7240
|
);
|
|
7265
7241
|
}, [availableModels, isModelsLoading]);
|
|
7266
7242
|
(0, import_react15.useEffect)(() => {
|
|
7267
|
-
if (activeSession) {
|
|
7268
|
-
setSelectedModeLocal(activeSession.mode ?? DEFAULT_CHAT_AGENT_MODE);
|
|
7269
|
-
return;
|
|
7270
|
-
}
|
|
7271
7243
|
setSelectedModeLocal(preferredMode ?? DEFAULT_CHAT_AGENT_MODE);
|
|
7272
|
-
}, [
|
|
7244
|
+
}, [preferredMode]);
|
|
7273
7245
|
(0, import_react15.useEffect)(() => {
|
|
7274
7246
|
if (previousActiveSessionIdRef.current !== activeSessionId) {
|
|
7275
7247
|
setSelectedSkills([]);
|
|
@@ -7477,7 +7449,7 @@ var useChatComposer = () => {
|
|
|
7477
7449
|
const storeState = store.getState();
|
|
7478
7450
|
const currentActiveSessionId = options?.sessionId ?? storeState.activeSessionId;
|
|
7479
7451
|
const currentActiveSession = storeState.sessions.find((session2) => session2.sessionId === currentActiveSessionId) ?? null;
|
|
7480
|
-
const currentMode =
|
|
7452
|
+
const currentMode = selectedMode;
|
|
7481
7453
|
if (!(selectedModel || currentActiveSession?.model || availableModels[0]?.id)) {
|
|
7482
7454
|
return;
|
|
7483
7455
|
}
|
|
@@ -7485,7 +7457,6 @@ var useChatComposer = () => {
|
|
|
7485
7457
|
const { localSessionId, sessionId, session } = resolveSendSession({
|
|
7486
7458
|
activeSessionId: currentActiveSessionId,
|
|
7487
7459
|
selectedModel: resolvedModel,
|
|
7488
|
-
selectedMode: currentMode,
|
|
7489
7460
|
nowIso,
|
|
7490
7461
|
createSessionId: createDraftChatSessionId
|
|
7491
7462
|
});
|
|
@@ -7633,8 +7604,6 @@ var useChatComposer = () => {
|
|
|
7633
7604
|
setSelectedMode: (mode) => {
|
|
7634
7605
|
setSelectedModeLocal(mode);
|
|
7635
7606
|
setPreferredMode(mode);
|
|
7636
|
-
if (activeSessionId)
|
|
7637
|
-
setSessionMode(activeSessionId, mode);
|
|
7638
7607
|
if (activeSessionId) {
|
|
7639
7608
|
const previousRequest = lastRequestBySessionRef.current.get(activeSessionId);
|
|
7640
7609
|
if (previousRequest) {
|
|
@@ -8987,31 +8956,21 @@ var import_styled16 = __toESM(require("@emotion/styled"));
|
|
|
8987
8956
|
var import_react19 = require("react");
|
|
8988
8957
|
var import_styled15 = __toESM(require("@emotion/styled"));
|
|
8989
8958
|
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
|
-
);
|
|
8959
|
+
var ChatSessionItem = (0, import_react19.memo)(({ session, isActive, onClick }) => {
|
|
8960
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
8961
|
+
SessionButton,
|
|
8962
|
+
{
|
|
8963
|
+
type: "button",
|
|
8964
|
+
"data-active": isActive,
|
|
8965
|
+
"data-testid": `chat-session-item-${session.sessionId}`,
|
|
8966
|
+
onClick: () => onClick(session.sessionId),
|
|
8967
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(SessionTitle, { children: session.title })
|
|
8968
|
+
}
|
|
8969
|
+
);
|
|
8970
|
+
});
|
|
9007
8971
|
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
8972
|
var SessionTitle = import_styled15.default.span`
|
|
8973
|
+
display: block;
|
|
9015
8974
|
min-width: 0;
|
|
9016
8975
|
overflow: hidden;
|
|
9017
8976
|
text-overflow: ellipsis;
|
|
@@ -9025,22 +8984,31 @@ var SessionButton = import_styled15.default.button`
|
|
|
9025
8984
|
color: var(--text-primary);
|
|
9026
8985
|
background: rgba(255, 255, 255, 0.03);
|
|
9027
8986
|
cursor: pointer;
|
|
8987
|
+
transition:
|
|
8988
|
+
background-color 160ms ease,
|
|
8989
|
+
border-color 160ms ease,
|
|
8990
|
+
transform 160ms ease;
|
|
8991
|
+
|
|
8992
|
+
&:hover {
|
|
8993
|
+
background: rgba(255, 255, 255, 0.06);
|
|
8994
|
+
border-color: rgba(255, 255, 255, 0.08);
|
|
8995
|
+
}
|
|
8996
|
+
|
|
8997
|
+
&:focus-visible {
|
|
8998
|
+
outline: none;
|
|
8999
|
+
background: rgba(255, 255, 255, 0.06);
|
|
9000
|
+
border-color: rgba(255, 255, 255, 0.18);
|
|
9001
|
+
}
|
|
9002
|
+
|
|
9003
|
+
&:active {
|
|
9004
|
+
transform: scale(0.995);
|
|
9005
|
+
}
|
|
9028
9006
|
|
|
9029
9007
|
&[data-active='true'] {
|
|
9030
9008
|
border-color: rgba(255, 255, 255, 0.2);
|
|
9031
9009
|
background: rgba(255, 255, 255, 0.08);
|
|
9032
9010
|
}
|
|
9033
9011
|
`;
|
|
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
9012
|
|
|
9045
9013
|
// src/components/chat-conversation-list/lib/history-session-selection.ts
|
|
9046
9014
|
var shouldLoadHistorySessionMessages = ({
|
|
@@ -9107,9 +9075,12 @@ var ChatConversationList = () => {
|
|
|
9107
9075
|
if (!historySessionList) {
|
|
9108
9076
|
return localSessions;
|
|
9109
9077
|
}
|
|
9110
|
-
const
|
|
9078
|
+
const persistedLocalSessions = localSessions.filter(
|
|
9079
|
+
(session) => !isDraftChatSessionId(session.sessionId)
|
|
9080
|
+
);
|
|
9081
|
+
const localSessionIds = new Set(persistedLocalSessions.map((session) => session.sessionId));
|
|
9111
9082
|
return [
|
|
9112
|
-
...
|
|
9083
|
+
...persistedLocalSessions,
|
|
9113
9084
|
...historySessionList.sessions.filter((session) => !localSessionIds.has(session.sessionId))
|
|
9114
9085
|
];
|
|
9115
9086
|
}, [historySessionList, localSessions]);
|
|
@@ -9166,14 +9137,9 @@ var ChatConversationList = () => {
|
|
|
9166
9137
|
);
|
|
9167
9138
|
}
|
|
9168
9139
|
};
|
|
9169
|
-
const modeLabels = {
|
|
9170
|
-
ask: labels.modeLabelAsk,
|
|
9171
|
-
plan: labels.modeLabelPlan,
|
|
9172
|
-
agent: labels.modeLabelAgent
|
|
9173
|
-
};
|
|
9174
9140
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(Container3, { children: [
|
|
9175
9141
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(Toolbar, { children: [
|
|
9176
|
-
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Title3, { children:
|
|
9142
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Title3, { children: labels.sessionsTitle }),
|
|
9177
9143
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(CreateButton, { type: "button", "data-testid": "chat-create-session", onClick: startNewChat, children: labels.newChat })
|
|
9178
9144
|
] }),
|
|
9179
9145
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(List2, { "data-testid": "chat-session-list", onScroll: handleSessionListScroll, children: [
|
|
@@ -9182,7 +9148,6 @@ var ChatConversationList = () => {
|
|
|
9182
9148
|
{
|
|
9183
9149
|
session,
|
|
9184
9150
|
isActive: activeSessionId === session.sessionId,
|
|
9185
|
-
modeLabel: modeLabels[session.mode ?? DEFAULT_CHAT_AGENT_MODE] ?? "",
|
|
9186
9151
|
onClick: (sessionId) => void handleSelectSession(sessionId)
|
|
9187
9152
|
},
|
|
9188
9153
|
session.sessionId
|
|
@@ -9213,13 +9178,32 @@ var Title3 = import_styled16.default.h2`
|
|
|
9213
9178
|
color: var(--text-secondary);
|
|
9214
9179
|
`;
|
|
9215
9180
|
var CreateButton = import_styled16.default.button`
|
|
9216
|
-
border:
|
|
9181
|
+
border: 1px solid rgba(255, 255, 255, 0.18);
|
|
9217
9182
|
border-radius: 12px;
|
|
9218
9183
|
padding: 12px 14px;
|
|
9219
|
-
background:
|
|
9220
|
-
color:
|
|
9184
|
+
background: rgba(255, 255, 255, 0.9);
|
|
9185
|
+
color: rgba(20, 20, 20, 0.92);
|
|
9221
9186
|
text-align: left;
|
|
9222
9187
|
cursor: pointer;
|
|
9188
|
+
transition:
|
|
9189
|
+
background-color 160ms ease,
|
|
9190
|
+
border-color 160ms ease,
|
|
9191
|
+
transform 160ms ease;
|
|
9192
|
+
|
|
9193
|
+
&:hover {
|
|
9194
|
+
background: rgba(255, 255, 255, 0.96);
|
|
9195
|
+
border-color: rgba(255, 255, 255, 0.28);
|
|
9196
|
+
}
|
|
9197
|
+
|
|
9198
|
+
&:focus-visible {
|
|
9199
|
+
outline: none;
|
|
9200
|
+
background: rgba(255, 255, 255, 0.96);
|
|
9201
|
+
border-color: rgba(255, 255, 255, 0.32);
|
|
9202
|
+
}
|
|
9203
|
+
|
|
9204
|
+
&:active {
|
|
9205
|
+
transform: scale(0.995);
|
|
9206
|
+
}
|
|
9223
9207
|
`;
|
|
9224
9208
|
var List2 = import_styled16.default.div`
|
|
9225
9209
|
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,13 +338,6 @@ 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
343
|
const localSessions = state.sessions.filter(
|
|
@@ -360,10 +346,7 @@ var createChatStore = (initialState) => createStore((set, get) => ({
|
|
|
360
346
|
const localSessionIds = new Set(localSessions.map((session) => session.sessionId));
|
|
361
347
|
const nextSessions = [
|
|
362
348
|
...localSessions,
|
|
363
|
-
...sessions.filter((session) => !localSessionIds.has(session.sessionId))
|
|
364
|
-
...session,
|
|
365
|
-
mode: session.mode ?? DEFAULT_CHAT_AGENT_MODE
|
|
366
|
-
}))
|
|
349
|
+
...sessions.filter((session) => !localSessionIds.has(session.sessionId))
|
|
367
350
|
];
|
|
368
351
|
const nextMessagesBySession = { ...state.messagesBySession };
|
|
369
352
|
const nextErrorBySession = { ...state.errorBySession };
|
|
@@ -3097,9 +3080,8 @@ var ChatMessageItemView = ({
|
|
|
3097
3080
|
const hasMarkdownOnlyBlocks = hasStructuredBlocks && blocks.every((block) => block.type === "markdown");
|
|
3098
3081
|
const hasTextContent = Boolean(settledContent || freshContent || displayedContent);
|
|
3099
3082
|
const shouldRenderStructuredBlocks = hasStructuredBlocks && !(isAssistantStreaming && hasMarkdownOnlyBlocks && hasTextContent);
|
|
3100
|
-
const
|
|
3101
|
-
const
|
|
3102
|
-
const canSubmitQuestionnaire = isPlanMode && typeof onQuestionnaireSubmit === "function";
|
|
3083
|
+
const canSubmitConfirmation = typeof onConfirmationSubmit === "function";
|
|
3084
|
+
const canSubmitQuestionnaire = typeof onQuestionnaireSubmit === "function";
|
|
3103
3085
|
const shouldShowStreamingCaret = isAssistantStreaming && (!shouldRenderStructuredBlocks || hasTextContent);
|
|
3104
3086
|
const isUserMessage = message.role === "user";
|
|
3105
3087
|
const messageRenderMode = isUserMessage ? "plain-text" : "markdown";
|
|
@@ -3157,7 +3139,7 @@ var ChatMessageItemView = ({
|
|
|
3157
3139
|
ExecutionConfirmationCard,
|
|
3158
3140
|
{
|
|
3159
3141
|
proposal: block.proposal,
|
|
3160
|
-
interactive:
|
|
3142
|
+
interactive: canSubmitConfirmation,
|
|
3161
3143
|
onConfirm: canSubmitConfirmation ? () => onConfirmationSubmit({
|
|
3162
3144
|
proposalId: block.proposal.proposalId,
|
|
3163
3145
|
content: createExecutionConfirmationContent(block.proposal),
|
|
@@ -3787,7 +3769,7 @@ var groupConversationTurns = (historyMessages, streamingMessage) => {
|
|
|
3787
3769
|
];
|
|
3788
3770
|
};
|
|
3789
3771
|
var ChatThreadView = ({
|
|
3790
|
-
|
|
3772
|
+
activeMode = DEFAULT_CHAT_AGENT_MODE,
|
|
3791
3773
|
historyMessages,
|
|
3792
3774
|
streamingMessage,
|
|
3793
3775
|
error: error2,
|
|
@@ -4043,7 +4025,7 @@ var ChatThreadView = ({
|
|
|
4043
4025
|
style: isLatestTurn ? { scrollMarginTop: `${CHAT_THREAD_SCROLL_TOP_GAP}px` } : void 0,
|
|
4044
4026
|
children: renderChatMessage({
|
|
4045
4027
|
message: turn.userMessage,
|
|
4046
|
-
mode:
|
|
4028
|
+
mode: activeMode,
|
|
4047
4029
|
onConfirmationSubmit,
|
|
4048
4030
|
onQuestionnaireSubmit,
|
|
4049
4031
|
renderMessageBlock
|
|
@@ -4052,7 +4034,7 @@ var ChatThreadView = ({
|
|
|
4052
4034
|
) : null,
|
|
4053
4035
|
turn.responseMessages.map((message) => /* @__PURE__ */ jsx10(MessageSlot, { children: renderChatMessage({
|
|
4054
4036
|
message,
|
|
4055
|
-
mode:
|
|
4037
|
+
mode: activeMode,
|
|
4056
4038
|
onConfirmationSubmit,
|
|
4057
4039
|
onQuestionnaireSubmit,
|
|
4058
4040
|
renderMessageBlock
|
|
@@ -4086,7 +4068,7 @@ var ChatThread = () => {
|
|
|
4086
4068
|
const activeSession = useChatStore(
|
|
4087
4069
|
(s) => s.sessions.find((session) => session.sessionId === s.activeSessionId)
|
|
4088
4070
|
);
|
|
4089
|
-
const
|
|
4071
|
+
const preferredMode = useChatStore((s) => s.preferredMode);
|
|
4090
4072
|
const messages = useChatStore(
|
|
4091
4073
|
(s) => s.messagesBySession[s.activeSessionId ?? ""] ?? EMPTY_MESSAGES
|
|
4092
4074
|
);
|
|
@@ -4125,7 +4107,7 @@ var ChatThread = () => {
|
|
|
4125
4107
|
if (customQuestionnaireSubmit) {
|
|
4126
4108
|
const handled = await customQuestionnaireSubmit(submission, {
|
|
4127
4109
|
sessionId: sourceSessionId ?? void 0,
|
|
4128
|
-
mode:
|
|
4110
|
+
mode: preferredMode
|
|
4129
4111
|
});
|
|
4130
4112
|
if (handled !== false) {
|
|
4131
4113
|
if (sourceSessionId && submission.sourceMessageId) {
|
|
@@ -4152,7 +4134,7 @@ var ChatThread = () => {
|
|
|
4152
4134
|
);
|
|
4153
4135
|
}
|
|
4154
4136
|
},
|
|
4155
|
-
[activeSessionId,
|
|
4137
|
+
[activeSessionId, customQuestionnaireSubmit, preferredMode, sendRef, updateQA]
|
|
4156
4138
|
);
|
|
4157
4139
|
const handleConfirmation = useCallback3(
|
|
4158
4140
|
async (submission) => {
|
|
@@ -4160,7 +4142,7 @@ var ChatThread = () => {
|
|
|
4160
4142
|
if (customConfirmationSubmit) {
|
|
4161
4143
|
const handled = await customConfirmationSubmit(submission, {
|
|
4162
4144
|
sessionId: sourceSessionId ?? void 0,
|
|
4163
|
-
mode:
|
|
4145
|
+
mode: preferredMode
|
|
4164
4146
|
});
|
|
4165
4147
|
if (handled !== false) {
|
|
4166
4148
|
return;
|
|
@@ -4171,7 +4153,7 @@ var ChatThread = () => {
|
|
|
4171
4153
|
includeComposerAttachments: false
|
|
4172
4154
|
});
|
|
4173
4155
|
},
|
|
4174
|
-
[activeSessionId,
|
|
4156
|
+
[activeSessionId, customConfirmationSubmit, preferredMode, sendRef]
|
|
4175
4157
|
);
|
|
4176
4158
|
const handleLoadPreviousMessages = useCallback3(async () => {
|
|
4177
4159
|
if (!activeSession || !onLoadMoreHistoryMessages || !historyMessagePagination?.hasMorePrevious || !historyMessagePagination.previousCursor || historyMessagePagination.isLoadingPrevious) {
|
|
@@ -4215,7 +4197,7 @@ var ChatThread = () => {
|
|
|
4215
4197
|
return /* @__PURE__ */ jsx10(
|
|
4216
4198
|
ChatThreadView,
|
|
4217
4199
|
{
|
|
4218
|
-
|
|
4200
|
+
activeMode: preferredMode,
|
|
4219
4201
|
historyMessages: messages,
|
|
4220
4202
|
streamingMessage,
|
|
4221
4203
|
error: error2,
|
|
@@ -6947,7 +6929,6 @@ var resolveSelectedChatModel = ({
|
|
|
6947
6929
|
var resolveSendSession = ({
|
|
6948
6930
|
activeSessionId,
|
|
6949
6931
|
selectedModel,
|
|
6950
|
-
selectedMode,
|
|
6951
6932
|
nowIso: nowIso2,
|
|
6952
6933
|
createSessionId
|
|
6953
6934
|
}) => {
|
|
@@ -6959,7 +6940,6 @@ var resolveSendSession = ({
|
|
|
6959
6940
|
}
|
|
6960
6941
|
const session = createDraftChatSession({
|
|
6961
6942
|
model: selectedModel,
|
|
6962
|
-
mode: selectedMode ?? DEFAULT_CHAT_AGENT_MODE,
|
|
6963
6943
|
nowIso: nowIso2,
|
|
6964
6944
|
createSessionId
|
|
6965
6945
|
});
|
|
@@ -7117,9 +7097,6 @@ var useChatComposer = () => {
|
|
|
7117
7097
|
const skillsLoader = transport.getSkills;
|
|
7118
7098
|
const activeSkillsLoaderRef = useRef10(skillsLoader);
|
|
7119
7099
|
const activeSessionId = useChatStore((s) => s.activeSessionId);
|
|
7120
|
-
const activeSession = useChatStore(
|
|
7121
|
-
(s) => s.sessions.find((x) => x.sessionId === s.activeSessionId) ?? null
|
|
7122
|
-
);
|
|
7123
7100
|
const preferredMode = useChatStore((s) => s.preferredMode);
|
|
7124
7101
|
const streamingSessionId = useChatStore(
|
|
7125
7102
|
(s) => s.activeSessionId && s.isStreamingBySession[s.activeSessionId] ? s.activeSessionId : null
|
|
@@ -7140,7 +7117,6 @@ var useChatComposer = () => {
|
|
|
7140
7117
|
const setSessionError = useChatStore((s) => s.setSessionError);
|
|
7141
7118
|
const clearSessionError = useChatStore((s) => s.clearSessionError);
|
|
7142
7119
|
const setPreferredMode = useChatStore((s) => s.setPreferredMode);
|
|
7143
|
-
const setSessionMode = useChatStore((s) => s.setSessionMode);
|
|
7144
7120
|
const [availableModels, setAvailableModels] = useState8([]);
|
|
7145
7121
|
const [isModelsLoading, setIsModelsLoading] = useState8(true);
|
|
7146
7122
|
const [isModelsError, setIsModelsError] = useState8(false);
|
|
@@ -7221,12 +7197,8 @@ var useChatComposer = () => {
|
|
|
7221
7197
|
);
|
|
7222
7198
|
}, [availableModels, isModelsLoading]);
|
|
7223
7199
|
useEffect8(() => {
|
|
7224
|
-
if (activeSession) {
|
|
7225
|
-
setSelectedModeLocal(activeSession.mode ?? DEFAULT_CHAT_AGENT_MODE);
|
|
7226
|
-
return;
|
|
7227
|
-
}
|
|
7228
7200
|
setSelectedModeLocal(preferredMode ?? DEFAULT_CHAT_AGENT_MODE);
|
|
7229
|
-
}, [
|
|
7201
|
+
}, [preferredMode]);
|
|
7230
7202
|
useEffect8(() => {
|
|
7231
7203
|
if (previousActiveSessionIdRef.current !== activeSessionId) {
|
|
7232
7204
|
setSelectedSkills([]);
|
|
@@ -7434,7 +7406,7 @@ var useChatComposer = () => {
|
|
|
7434
7406
|
const storeState = store.getState();
|
|
7435
7407
|
const currentActiveSessionId = options?.sessionId ?? storeState.activeSessionId;
|
|
7436
7408
|
const currentActiveSession = storeState.sessions.find((session2) => session2.sessionId === currentActiveSessionId) ?? null;
|
|
7437
|
-
const currentMode =
|
|
7409
|
+
const currentMode = selectedMode;
|
|
7438
7410
|
if (!(selectedModel || currentActiveSession?.model || availableModels[0]?.id)) {
|
|
7439
7411
|
return;
|
|
7440
7412
|
}
|
|
@@ -7442,7 +7414,6 @@ var useChatComposer = () => {
|
|
|
7442
7414
|
const { localSessionId, sessionId, session } = resolveSendSession({
|
|
7443
7415
|
activeSessionId: currentActiveSessionId,
|
|
7444
7416
|
selectedModel: resolvedModel,
|
|
7445
|
-
selectedMode: currentMode,
|
|
7446
7417
|
nowIso,
|
|
7447
7418
|
createSessionId: createDraftChatSessionId
|
|
7448
7419
|
});
|
|
@@ -7590,8 +7561,6 @@ var useChatComposer = () => {
|
|
|
7590
7561
|
setSelectedMode: (mode) => {
|
|
7591
7562
|
setSelectedModeLocal(mode);
|
|
7592
7563
|
setPreferredMode(mode);
|
|
7593
|
-
if (activeSessionId)
|
|
7594
|
-
setSessionMode(activeSessionId, mode);
|
|
7595
7564
|
if (activeSessionId) {
|
|
7596
7565
|
const previousRequest = lastRequestBySessionRef.current.get(activeSessionId);
|
|
7597
7566
|
if (previousRequest) {
|
|
@@ -8943,32 +8912,22 @@ import styled16 from "@emotion/styled";
|
|
|
8943
8912
|
// src/components/chat-conversation-list/components/chat-session-item.tsx
|
|
8944
8913
|
import { memo as memo2 } from "react";
|
|
8945
8914
|
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
|
-
);
|
|
8915
|
+
import { jsx as jsx17 } from "@emotion/react/jsx-runtime";
|
|
8916
|
+
var ChatSessionItem = memo2(({ session, isActive, onClick }) => {
|
|
8917
|
+
return /* @__PURE__ */ jsx17(
|
|
8918
|
+
SessionButton,
|
|
8919
|
+
{
|
|
8920
|
+
type: "button",
|
|
8921
|
+
"data-active": isActive,
|
|
8922
|
+
"data-testid": `chat-session-item-${session.sessionId}`,
|
|
8923
|
+
onClick: () => onClick(session.sessionId),
|
|
8924
|
+
children: /* @__PURE__ */ jsx17(SessionTitle, { children: session.title })
|
|
8925
|
+
}
|
|
8926
|
+
);
|
|
8927
|
+
});
|
|
8964
8928
|
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
8929
|
var SessionTitle = styled15.span`
|
|
8930
|
+
display: block;
|
|
8972
8931
|
min-width: 0;
|
|
8973
8932
|
overflow: hidden;
|
|
8974
8933
|
text-overflow: ellipsis;
|
|
@@ -8982,22 +8941,31 @@ var SessionButton = styled15.button`
|
|
|
8982
8941
|
color: var(--text-primary);
|
|
8983
8942
|
background: rgba(255, 255, 255, 0.03);
|
|
8984
8943
|
cursor: pointer;
|
|
8944
|
+
transition:
|
|
8945
|
+
background-color 160ms ease,
|
|
8946
|
+
border-color 160ms ease,
|
|
8947
|
+
transform 160ms ease;
|
|
8948
|
+
|
|
8949
|
+
&:hover {
|
|
8950
|
+
background: rgba(255, 255, 255, 0.06);
|
|
8951
|
+
border-color: rgba(255, 255, 255, 0.08);
|
|
8952
|
+
}
|
|
8953
|
+
|
|
8954
|
+
&:focus-visible {
|
|
8955
|
+
outline: none;
|
|
8956
|
+
background: rgba(255, 255, 255, 0.06);
|
|
8957
|
+
border-color: rgba(255, 255, 255, 0.18);
|
|
8958
|
+
}
|
|
8959
|
+
|
|
8960
|
+
&:active {
|
|
8961
|
+
transform: scale(0.995);
|
|
8962
|
+
}
|
|
8985
8963
|
|
|
8986
8964
|
&[data-active='true'] {
|
|
8987
8965
|
border-color: rgba(255, 255, 255, 0.2);
|
|
8988
8966
|
background: rgba(255, 255, 255, 0.08);
|
|
8989
8967
|
}
|
|
8990
8968
|
`;
|
|
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
8969
|
|
|
9002
8970
|
// src/components/chat-conversation-list/lib/history-session-selection.ts
|
|
9003
8971
|
var shouldLoadHistorySessionMessages = ({
|
|
@@ -9018,7 +8986,7 @@ var shouldLoadHistorySessionMessages = ({
|
|
|
9018
8986
|
};
|
|
9019
8987
|
|
|
9020
8988
|
// src/components/chat-conversation-list/index.tsx
|
|
9021
|
-
import { jsx as jsx18, jsxs as
|
|
8989
|
+
import { jsx as jsx18, jsxs as jsxs12 } from "@emotion/react/jsx-runtime";
|
|
9022
8990
|
var SCROLL_LOAD_MORE_THRESHOLD_PX = 80;
|
|
9023
8991
|
var shouldLoadMoreSessions = ({
|
|
9024
8992
|
scrollTop,
|
|
@@ -9064,9 +9032,12 @@ var ChatConversationList = () => {
|
|
|
9064
9032
|
if (!historySessionList) {
|
|
9065
9033
|
return localSessions;
|
|
9066
9034
|
}
|
|
9067
|
-
const
|
|
9035
|
+
const persistedLocalSessions = localSessions.filter(
|
|
9036
|
+
(session) => !isDraftChatSessionId(session.sessionId)
|
|
9037
|
+
);
|
|
9038
|
+
const localSessionIds = new Set(persistedLocalSessions.map((session) => session.sessionId));
|
|
9068
9039
|
return [
|
|
9069
|
-
...
|
|
9040
|
+
...persistedLocalSessions,
|
|
9070
9041
|
...historySessionList.sessions.filter((session) => !localSessionIds.has(session.sessionId))
|
|
9071
9042
|
];
|
|
9072
9043
|
}, [historySessionList, localSessions]);
|
|
@@ -9123,23 +9094,17 @@ var ChatConversationList = () => {
|
|
|
9123
9094
|
);
|
|
9124
9095
|
}
|
|
9125
9096
|
};
|
|
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" }),
|
|
9097
|
+
return /* @__PURE__ */ jsxs12(Container3, { children: [
|
|
9098
|
+
/* @__PURE__ */ jsxs12(Toolbar, { children: [
|
|
9099
|
+
/* @__PURE__ */ jsx18(Title3, { children: labels.sessionsTitle }),
|
|
9134
9100
|
/* @__PURE__ */ jsx18(CreateButton, { type: "button", "data-testid": "chat-create-session", onClick: startNewChat, children: labels.newChat })
|
|
9135
9101
|
] }),
|
|
9136
|
-
/* @__PURE__ */
|
|
9102
|
+
/* @__PURE__ */ jsxs12(List2, { "data-testid": "chat-session-list", onScroll: handleSessionListScroll, children: [
|
|
9137
9103
|
sessions.map((session) => /* @__PURE__ */ jsx18(
|
|
9138
9104
|
ChatSessionItem,
|
|
9139
9105
|
{
|
|
9140
9106
|
session,
|
|
9141
9107
|
isActive: activeSessionId === session.sessionId,
|
|
9142
|
-
modeLabel: modeLabels[session.mode ?? DEFAULT_CHAT_AGENT_MODE] ?? "",
|
|
9143
9108
|
onClick: (sessionId) => void handleSelectSession(sessionId)
|
|
9144
9109
|
},
|
|
9145
9110
|
session.sessionId
|
|
@@ -9170,13 +9135,32 @@ var Title3 = styled16.h2`
|
|
|
9170
9135
|
color: var(--text-secondary);
|
|
9171
9136
|
`;
|
|
9172
9137
|
var CreateButton = styled16.button`
|
|
9173
|
-
border:
|
|
9138
|
+
border: 1px solid rgba(255, 255, 255, 0.18);
|
|
9174
9139
|
border-radius: 12px;
|
|
9175
9140
|
padding: 12px 14px;
|
|
9176
|
-
background:
|
|
9177
|
-
color:
|
|
9141
|
+
background: rgba(255, 255, 255, 0.9);
|
|
9142
|
+
color: rgba(20, 20, 20, 0.92);
|
|
9178
9143
|
text-align: left;
|
|
9179
9144
|
cursor: pointer;
|
|
9145
|
+
transition:
|
|
9146
|
+
background-color 160ms ease,
|
|
9147
|
+
border-color 160ms ease,
|
|
9148
|
+
transform 160ms ease;
|
|
9149
|
+
|
|
9150
|
+
&:hover {
|
|
9151
|
+
background: rgba(255, 255, 255, 0.96);
|
|
9152
|
+
border-color: rgba(255, 255, 255, 0.28);
|
|
9153
|
+
}
|
|
9154
|
+
|
|
9155
|
+
&:focus-visible {
|
|
9156
|
+
outline: none;
|
|
9157
|
+
background: rgba(255, 255, 255, 0.96);
|
|
9158
|
+
border-color: rgba(255, 255, 255, 0.32);
|
|
9159
|
+
}
|
|
9160
|
+
|
|
9161
|
+
&:active {
|
|
9162
|
+
transform: scale(0.995);
|
|
9163
|
+
}
|
|
9180
9164
|
`;
|
|
9181
9165
|
var List2 = styled16.div`
|
|
9182
9166
|
padding: 0 12px 16px;
|
|
@@ -9192,7 +9176,7 @@ var StateRow = styled16.div`
|
|
|
9192
9176
|
`;
|
|
9193
9177
|
|
|
9194
9178
|
// src/components/ai-chat/index.tsx
|
|
9195
|
-
import { Fragment as Fragment6, jsx as jsx19, jsxs as
|
|
9179
|
+
import { Fragment as Fragment6, jsx as jsx19, jsxs as jsxs13 } from "@emotion/react/jsx-runtime";
|
|
9196
9180
|
var NewTalkIcon = () => /* @__PURE__ */ jsx19(
|
|
9197
9181
|
"svg",
|
|
9198
9182
|
{
|
|
@@ -9203,7 +9187,7 @@ var NewTalkIcon = () => /* @__PURE__ */ jsx19(
|
|
|
9203
9187
|
fill: "none",
|
|
9204
9188
|
style: { display: "block" },
|
|
9205
9189
|
xmlns: "http://www.w3.org/2000/svg",
|
|
9206
|
-
children: /* @__PURE__ */
|
|
9190
|
+
children: /* @__PURE__ */ jsxs13(
|
|
9207
9191
|
"g",
|
|
9208
9192
|
{
|
|
9209
9193
|
transform: "translate(1.8909 2.0364)",
|
|
@@ -9212,7 +9196,7 @@ var NewTalkIcon = () => /* @__PURE__ */ jsx19(
|
|
|
9212
9196
|
strokeLinejoin: "round",
|
|
9213
9197
|
strokeWidth: "1.36533333",
|
|
9214
9198
|
children: [
|
|
9215
|
-
/* @__PURE__ */
|
|
9199
|
+
/* @__PURE__ */ jsxs13("g", { transform: "translate(9.8909 2.3273) rotate(-315) translate(-9.8909 -2.3273) translate(8.2909 0.7273)", children: [
|
|
9216
9200
|
/* @__PURE__ */ jsx19("path", { d: "M0 0C0 0 1.06666667 1.06666667 3.2 3.2" }),
|
|
9217
9201
|
/* @__PURE__ */ jsx19("path", { d: "M3.2 0C3.2 0 2.13333333 1.06666667 0 3.2" })
|
|
9218
9202
|
] }),
|
|
@@ -9254,9 +9238,9 @@ var AiChatWorkspaceContent = ({
|
|
|
9254
9238
|
useEffect11(() => {
|
|
9255
9239
|
onConversationStartedChange?.(isConversationStarted);
|
|
9256
9240
|
}, [isConversationStarted, onConversationStartedChange]);
|
|
9257
|
-
return /* @__PURE__ */
|
|
9241
|
+
return /* @__PURE__ */ jsxs13(Root, { "data-testid": "ai-chat", children: [
|
|
9258
9242
|
showConversationList ? /* @__PURE__ */ jsx19(ChatConversationList, {}) : null,
|
|
9259
|
-
/* @__PURE__ */
|
|
9243
|
+
/* @__PURE__ */ jsxs13(Workspace, { children: [
|
|
9260
9244
|
showNewChatButton && !showConversationList && !shouldShowComposerOnly ? /* @__PURE__ */ jsx19(QuickActions, { renderNewChatTrigger }) : null,
|
|
9261
9245
|
shouldShowComposerOnly ? null : /* @__PURE__ */ jsx19(ChatThread, {}),
|
|
9262
9246
|
/* @__PURE__ */ jsx19(ChatComposer, {})
|