chat-js 1.0.0-alpha.8 → 1.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -5
- package/dist/index.js +7161 -6308
- package/package.json +2 -2
- package/templates/chat-app/agent/agent.ts +0 -2
- package/templates/chat-app/app/editor.css +0 -6
- package/templates/chat-app/app/layout.tsx +11 -18
- package/templates/chat-app/app/opengraph-image.png +0 -0
- package/templates/chat-app/chat.config.ts +0 -44
- package/templates/chat-app/chatjs/core/gateway/runtime.ts +0 -7
- package/templates/chat-app/chatjs/core/ui/slots.tsx +15 -5
- package/templates/chat-app/chatjs/generated/installed-chat-ui.ts +4 -0
- package/templates/chat-app/chatjs/generated/installed.ts +2 -0
- package/templates/chat-app/chatjs/plugins/guest-chat/signed-out.tsx +7 -4
- package/templates/chat-app/chatjs/plugins/mcp/routes/connectors-page.tsx +4 -1
- package/templates/chat-app/chatjs/plugins/mcp/ui/connectors-settings.tsx +1 -1
- package/templates/chat-app/chatjs/plugins/mcp/ui/mcp-connect-dialog.tsx +1 -1
- package/templates/chat-app/chatjs/plugins/mcp/ui/mcp-create-dialog.tsx +1 -1
- package/templates/chat-app/chatjs/plugins/model-preferences/model-row.tsx +3 -0
- package/templates/chat-app/chatjs/plugins/model-preferences/models-settings.tsx +1 -0
- package/templates/chat-app/chatjs/plugins/projects/routes/project-page.tsx +10 -1
- package/templates/chat-app/chatjs/plugins/projects/ui/delete-project-dialog.tsx +0 -3
- package/templates/chat-app/chatjs/plugins/projects/ui/project-icon-picker.tsx +1 -0
- package/templates/chat-app/chatjs/plugins/streamdown-math/chat-ui.ts +11 -0
- package/templates/chat-app/chatjs/plugins/streamdown-math/plugin.json +6 -0
- package/templates/chat-app/chatjs/plugins/streamdown-mermaid/chat-ui.ts +10 -0
- package/templates/chat-app/chatjs/plugins/streamdown-mermaid/plugin.json +6 -0
- package/templates/chat-app/chatjs/providers/gateway.ts +49 -55
- package/templates/chat-app/chatjs/tools/generate-image/tool.test.ts +3 -14
- package/templates/chat-app/components/ai-elements/response.tsx +16 -15
- package/templates/chat-app/components/auth-form-view.tsx +35 -43
- package/templates/chat-app/components/chat/chat-composer.tsx +55 -20
- package/templates/chat-app/components/chat/chat-sidebar.tsx +5 -3
- package/templates/chat-app/components/composer/prompt-form.tsx +7 -1
- package/templates/chat-app/components/eve/eve-chat-error.tsx +12 -2
- package/templates/chat-app/components/eve/eve-conversation.tsx +223 -154
- package/templates/chat-app/components/eve/eve-creation-recovery.tsx +32 -1
- package/templates/chat-app/components/eve/eve-history-list.tsx +1 -1
- package/templates/chat-app/components/model-selection-indicator.tsx +12 -10
- package/templates/chat-app/components/model-selector-view.tsx +211 -186
- package/templates/chat-app/components/new-chat-button.tsx +1 -1
- package/templates/chat-app/components/settings/settings-nav.tsx +1 -1
- package/templates/chat-app/components/settings/settings-navigation-link.tsx +1 -0
- package/templates/chat-app/components/sidebar-top-row.tsx +1 -1
- package/templates/chat-app/components/ui/sidebar.tsx +1 -1
- package/templates/chat-app/components/ui/trace.tsx +1 -1
- package/templates/chat-app/hooks/use-auto-focus.ts +12 -13
- package/templates/chat-app/lib/ai/active-gateway.ts +0 -9
- package/templates/chat-app/lib/ai/app-models.test.ts +0 -4
- package/templates/chat-app/lib/ai/app-models.ts +11 -6
- package/templates/chat-app/lib/ai/gateways/registry.ts +4 -31
- package/templates/chat-app/lib/ai/model-catalog.ts +50 -0
- package/templates/chat-app/lib/ai/models.ts +4 -39
- package/templates/chat-app/lib/ai/providers.ts +2 -16
- package/templates/chat-app/lib/config-schema.ts +0 -96
- package/templates/chat-app/lib/devtools-disabled.ts +1 -0
- package/templates/chat-app/lib/eve/model-selection.test.ts +47 -50
- package/templates/chat-app/lib/eve/model-selection.ts +5 -37
- package/templates/chat-app/lib/eve/tool-cost.test.ts +18 -6
- package/templates/chat-app/lib/eve/tool-cost.ts +10 -18
- package/templates/chat-app/oxfmt.config.ts +0 -2
- package/templates/chat-app/package.json +7 -9
- package/templates/chat-app/proxy.ts +2 -4
- package/templates/chat-app/scripts/build-eve.test.ts +56 -0
- package/templates/chat-app/scripts/build-eve.ts +12 -5
- package/templates/chat-app/scripts/check-env.ts +2 -17
- package/templates/chat-app/scripts/environment-validation-report.ts +1 -20
- package/templates/chat-app/trpc/react.tsx +2 -2
- package/templates/electron/forge.config.ts +1 -19
- package/templates/electron/scripts/write-branding.ts +1 -5
- package/templates/chat-app/app/privacy/page.tsx +0 -153
- package/templates/chat-app/app/terms/page.tsx +0 -270
- package/templates/chat-app/components/ai-elements/context-hover.radix.tsx +0 -15
- package/templates/chat-app/components/ai-elements/context-hover.tsx +0 -17
- package/templates/chat-app/components/ai-elements/context.tsx +0 -405
- package/templates/chat-app/components/composer/editor.css +0 -96
- package/templates/chat-app/components/lexical-chat-input.tsx +0 -276
- package/templates/chat-app/components/model-selection-indicator.radix.tsx +0 -17
- package/templates/chat-app/components/ui/resizable.tsx +0 -49
- package/templates/chat-app/lib/ai/gateways/fallback-models.ts +0 -29
- package/templates/chat-app/lib/ai/models.generated.ts +0 -4242
- package/templates/chat-app/lib/ai/usage-token-details.test.ts +0 -76
- package/templates/chat-app/lib/ai/usage-token-details.ts +0 -33
- package/templates/chat-app/scripts/fetch-models.ts +0 -30
- package/templates/chat-app/scripts/gateway-snapshot-warning.test.ts +0 -9
|
@@ -85,15 +85,79 @@ const composerStatus = (
|
|
|
85
85
|
return "ready";
|
|
86
86
|
};
|
|
87
87
|
|
|
88
|
-
const
|
|
88
|
+
const isInactive = (error: Error | undefined): boolean =>
|
|
89
|
+
SessionNotActiveError.is(error) && error.code === "session_not_active";
|
|
90
|
+
|
|
91
|
+
const conversationError = (
|
|
92
|
+
view: SessionView,
|
|
93
|
+
commandError: Error | undefined,
|
|
94
|
+
agentError: Error | undefined
|
|
95
|
+
): { title: string; message: string; reconnect?: true } | undefined => {
|
|
96
|
+
if (isInactive(commandError) || isInactive(agentError)) {
|
|
97
|
+
return {
|
|
98
|
+
title: "Conversation ended",
|
|
99
|
+
message: "Start a new chat to continue.",
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
if (isEveCommandRejection(commandError)) {
|
|
103
|
+
return { title: "Request rejected", message: commandError.message };
|
|
104
|
+
}
|
|
105
|
+
const currentError = commandError ?? agentError;
|
|
89
106
|
const latestTurn = turns(view).at(-1);
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
107
|
+
const replyFailure =
|
|
108
|
+
latestTurn?.status === "running"
|
|
109
|
+
? undefined
|
|
110
|
+
: failure(view, latestTurn?.turnId);
|
|
111
|
+
// Eve projects a failed reply into agent.error using its code and message.
|
|
112
|
+
if (
|
|
113
|
+
replyFailure &&
|
|
114
|
+
(!currentError ||
|
|
115
|
+
(currentError.name === replyFailure.code &&
|
|
116
|
+
currentError.message === replyFailure.message))
|
|
117
|
+
) {
|
|
118
|
+
return {
|
|
119
|
+
title: "Reply interrupted",
|
|
120
|
+
message: "Try sending your message again.",
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
if (currentError) {
|
|
124
|
+
return {
|
|
125
|
+
title: "Connection interrupted",
|
|
126
|
+
message: "You may be missing the latest reply.",
|
|
127
|
+
reconnect: true,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
return undefined;
|
|
93
131
|
};
|
|
94
132
|
|
|
95
|
-
const
|
|
96
|
-
|
|
133
|
+
const EveConversationError = ({
|
|
134
|
+
error,
|
|
135
|
+
reconnect,
|
|
136
|
+
reconnectDisabled,
|
|
137
|
+
}: {
|
|
138
|
+
readonly error: ReturnType<typeof conversationError>;
|
|
139
|
+
readonly reconnect: () => void;
|
|
140
|
+
readonly reconnectDisabled: boolean;
|
|
141
|
+
}): ReactJSX.Element | null => {
|
|
142
|
+
if (!error) {
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
return (
|
|
146
|
+
<EveChatError title={error.title} message={error.message}>
|
|
147
|
+
{error.reconnect === true ? (
|
|
148
|
+
<Button
|
|
149
|
+
disabled={reconnectDisabled}
|
|
150
|
+
onClick={reconnect}
|
|
151
|
+
size="sm"
|
|
152
|
+
type="button"
|
|
153
|
+
variant="outline"
|
|
154
|
+
>
|
|
155
|
+
Reconnect
|
|
156
|
+
</Button>
|
|
157
|
+
) : undefined}
|
|
158
|
+
</EveChatError>
|
|
159
|
+
);
|
|
160
|
+
};
|
|
97
161
|
|
|
98
162
|
const interactionControls = (
|
|
99
163
|
agent: Pick<NativeChatAgent, "view" | "error" | "status">,
|
|
@@ -324,6 +388,8 @@ const EveDeliveryRecovery = ({
|
|
|
324
388
|
files,
|
|
325
389
|
run,
|
|
326
390
|
sendPendingMessage,
|
|
391
|
+
reconnect,
|
|
392
|
+
reconnectDisabled,
|
|
327
393
|
setCommandFailure,
|
|
328
394
|
}: {
|
|
329
395
|
readonly pendingMessage: NonNullable<
|
|
@@ -338,68 +404,96 @@ const EveDeliveryRecovery = ({
|
|
|
338
404
|
readonly sendPendingMessage: (
|
|
339
405
|
pending: ActivePendingEveMessage
|
|
340
406
|
) => Promise<void>;
|
|
407
|
+
readonly reconnect: () => void;
|
|
408
|
+
readonly reconnectDisabled: boolean;
|
|
341
409
|
readonly setCommandFailure: (failure?: Error) => void;
|
|
342
|
-
}): ReactJSX.Element =>
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
<
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
410
|
+
}): ReactJSX.Element => {
|
|
411
|
+
const { rejection } = pendingMessage;
|
|
412
|
+
const rejected = hasText(rejection);
|
|
413
|
+
const message = rejected
|
|
414
|
+
? rejection
|
|
415
|
+
: "Your draft is saved in this tab. Sending it again may create a duplicate.";
|
|
416
|
+
return (
|
|
417
|
+
<EveChatError
|
|
418
|
+
title={rejected ? "Message not sent" : "Message delivery is unconfirmed"}
|
|
419
|
+
message={
|
|
420
|
+
rejected && pendingMessage.retryable === true
|
|
421
|
+
? "Chat is temporarily busy. Try sending again."
|
|
422
|
+
: message
|
|
423
|
+
}
|
|
424
|
+
>
|
|
425
|
+
<div className="text-foreground space-y-2">
|
|
426
|
+
{hasText(pendingMessage.message) && (
|
|
427
|
+
<p className="line-clamp-2 wrap-anywhere whitespace-pre-wrap">
|
|
428
|
+
{pendingMessage.message}
|
|
429
|
+
</p>
|
|
430
|
+
)}
|
|
431
|
+
<AttachmentList
|
|
432
|
+
attachments={pendingMessage.attachments}
|
|
433
|
+
variant="pill"
|
|
434
|
+
/>
|
|
435
|
+
<div className="flex flex-wrap gap-2">
|
|
436
|
+
{!rejected && (
|
|
437
|
+
<Button
|
|
438
|
+
disabled={reconnectDisabled}
|
|
439
|
+
onClick={reconnect}
|
|
440
|
+
size="sm"
|
|
441
|
+
type="button"
|
|
442
|
+
variant="outline"
|
|
443
|
+
>
|
|
444
|
+
Reconnect
|
|
445
|
+
</Button>
|
|
446
|
+
)}
|
|
447
|
+
{pendingMessage.retryable === true &&
|
|
448
|
+
hasText(pendingMessage.operationId) && (
|
|
449
|
+
<Button
|
|
450
|
+
onClick={() => {
|
|
451
|
+
void run(async () => {
|
|
452
|
+
const retried = delivery.retry(pendingMessage);
|
|
453
|
+
if (retried) {
|
|
454
|
+
await sendPendingMessage(retried);
|
|
455
|
+
}
|
|
456
|
+
});
|
|
457
|
+
}}
|
|
458
|
+
size="sm"
|
|
459
|
+
type="button"
|
|
460
|
+
variant="outline"
|
|
461
|
+
>
|
|
462
|
+
Retry message
|
|
463
|
+
</Button>
|
|
464
|
+
)}
|
|
354
465
|
<Button
|
|
355
466
|
onClick={() => {
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
await sendPendingMessage(retried);
|
|
467
|
+
composerDraft.setText((current) => {
|
|
468
|
+
if (current) {
|
|
469
|
+
return `${current}\n\n${pendingMessage.message}`;
|
|
360
470
|
}
|
|
471
|
+
return pendingMessage.message;
|
|
361
472
|
});
|
|
473
|
+
files.setAttachments((current) => [
|
|
474
|
+
...current,
|
|
475
|
+
...pendingMessage.attachments.filter(
|
|
476
|
+
(file) =>
|
|
477
|
+
!current.some((existing) => existing.url === file.url)
|
|
478
|
+
),
|
|
479
|
+
]);
|
|
480
|
+
composerDraft.setSelectedTool(
|
|
481
|
+
pendingMessage.selectedTool ?? null
|
|
482
|
+
);
|
|
483
|
+
delivery.release(pendingMessage);
|
|
484
|
+
setCommandFailure();
|
|
362
485
|
}}
|
|
363
486
|
size="sm"
|
|
364
487
|
type="button"
|
|
365
|
-
variant="
|
|
488
|
+
variant="ghost"
|
|
366
489
|
>
|
|
367
|
-
|
|
490
|
+
Restore draft
|
|
368
491
|
</Button>
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
return `${current}\n\n${pendingMessage.message}`;
|
|
375
|
-
}
|
|
376
|
-
return pendingMessage.message;
|
|
377
|
-
});
|
|
378
|
-
files.setAttachments((current) => [
|
|
379
|
-
...current,
|
|
380
|
-
...pendingMessage.attachments.filter(
|
|
381
|
-
(file) => !current.some((existing) => existing.url === file.url)
|
|
382
|
-
),
|
|
383
|
-
]);
|
|
384
|
-
composerDraft.setSelectedTool(pendingMessage.selectedTool ?? null);
|
|
385
|
-
delivery.release(pendingMessage);
|
|
386
|
-
setCommandFailure(
|
|
387
|
-
hasText(pendingMessage.rejection)
|
|
388
|
-
? undefined
|
|
389
|
-
: new Error(
|
|
390
|
-
"The original operation remains unresolved. Sending this restored draft creates a new message and may duplicate it."
|
|
391
|
-
)
|
|
392
|
-
);
|
|
393
|
-
}}
|
|
394
|
-
size="sm"
|
|
395
|
-
type="button"
|
|
396
|
-
variant="ghost"
|
|
397
|
-
>
|
|
398
|
-
Restore draft
|
|
399
|
-
</Button>
|
|
400
|
-
</div>
|
|
401
|
-
</output>
|
|
402
|
-
);
|
|
492
|
+
</div>
|
|
493
|
+
</div>
|
|
494
|
+
</EveChatError>
|
|
495
|
+
);
|
|
496
|
+
};
|
|
403
497
|
|
|
404
498
|
const conversationActionLocks = ({
|
|
405
499
|
busy,
|
|
@@ -430,15 +524,6 @@ const conversationActionLocks = ({
|
|
|
430
524
|
fork.locked || Boolean(editingMessageId) || Boolean(pendingMessage),
|
|
431
525
|
});
|
|
432
526
|
|
|
433
|
-
const showComposerReconnect = (
|
|
434
|
-
message: string | undefined,
|
|
435
|
-
pendingRejection: string | undefined,
|
|
436
|
-
commandError: Error | undefined
|
|
437
|
-
): boolean =>
|
|
438
|
-
hasText(message) &&
|
|
439
|
-
!hasText(pendingRejection) &&
|
|
440
|
-
!isEveCommandRejection(commandError);
|
|
441
|
-
|
|
442
527
|
const EveConversationComposer = ({
|
|
443
528
|
input,
|
|
444
529
|
pendingMessage,
|
|
@@ -448,12 +533,8 @@ const EveConversationComposer = ({
|
|
|
448
533
|
busy,
|
|
449
534
|
commandPending,
|
|
450
535
|
cancelPending,
|
|
451
|
-
displayedError,
|
|
452
|
-
commandFailure,
|
|
453
|
-
agentError,
|
|
454
536
|
onStop,
|
|
455
537
|
onSubmit,
|
|
456
|
-
onReconnect,
|
|
457
538
|
}: {
|
|
458
539
|
readonly input: ReturnType<typeof useConversationInput>;
|
|
459
540
|
readonly pendingMessage: ReturnType<typeof useEveMessageDelivery>["pending"];
|
|
@@ -463,12 +544,8 @@ const EveConversationComposer = ({
|
|
|
463
544
|
readonly busy: boolean;
|
|
464
545
|
readonly commandPending: boolean;
|
|
465
546
|
readonly cancelPending: boolean;
|
|
466
|
-
readonly displayedError: string | undefined;
|
|
467
|
-
readonly commandFailure: Error | undefined;
|
|
468
|
-
readonly agentError: Error | undefined;
|
|
469
547
|
readonly onStop: () => void;
|
|
470
548
|
readonly onSubmit: () => void;
|
|
471
|
-
readonly onReconnect: () => void;
|
|
472
549
|
}): ReactJSX.Element => {
|
|
473
550
|
const { composerDraft, files, modelSelection, comparison, fork } = input;
|
|
474
551
|
const statusForComposer = composerStatus(status, turnOpen);
|
|
@@ -477,72 +554,48 @@ const EveConversationComposer = ({
|
|
|
477
554
|
const handleSelectedToolChange = composerDraft.setSelectedTool;
|
|
478
555
|
const handleDraftChange = composerDraft.setText;
|
|
479
556
|
return (
|
|
480
|
-
|
|
481
|
-
{
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
pendingMessage,
|
|
508
|
-
composerDraft.selectedTool
|
|
509
|
-
),
|
|
510
|
-
}}
|
|
511
|
-
modelIds={composerModelIds(
|
|
512
|
-
input.modelIds,
|
|
513
|
-
comparison?.modelIds,
|
|
514
|
-
visibleModelId
|
|
515
|
-
)}
|
|
516
|
-
modelPicker={
|
|
517
|
-
<ParallelResponseModelPicker
|
|
518
|
-
disabled={Boolean(pendingMessage)}
|
|
519
|
-
modelSelection={modelSelection}
|
|
520
|
-
retainedModelId={visibleModelId}
|
|
521
|
-
retainedModelIds={comparison?.modelIds}
|
|
522
|
-
/>
|
|
523
|
-
}
|
|
524
|
-
onDraftChange={handleDraftChange}
|
|
525
|
-
onStop={onStop}
|
|
526
|
-
onSubmit={onSubmit}
|
|
527
|
-
readOnly={Boolean(comparison)}
|
|
528
|
-
stopDisabled={cancelPending || status === "resuming"}
|
|
529
|
-
/>
|
|
530
|
-
{showComposerReconnect(
|
|
531
|
-
displayedError,
|
|
532
|
-
pendingMessage?.rejection,
|
|
533
|
-
commandFailure ?? agentError
|
|
534
|
-
) && (
|
|
535
|
-
<Button
|
|
536
|
-
disabled={busy || commandPending || cancelPending}
|
|
537
|
-
onClick={onReconnect}
|
|
538
|
-
size="sm"
|
|
539
|
-
type="button"
|
|
540
|
-
variant="ghost"
|
|
541
|
-
>
|
|
542
|
-
Reconnect
|
|
543
|
-
</Button>
|
|
557
|
+
<EveComposer
|
|
558
|
+
status={statusForComposer}
|
|
559
|
+
allowSendWhileStreaming
|
|
560
|
+
disabled={
|
|
561
|
+
!composerDraft.loaded ||
|
|
562
|
+
(busy && !steering) ||
|
|
563
|
+
commandPending ||
|
|
564
|
+
cancelPending ||
|
|
565
|
+
Boolean(pendingMessage) ||
|
|
566
|
+
fork.locked
|
|
567
|
+
}
|
|
568
|
+
draft={composerDraft.text}
|
|
569
|
+
capabilities={{
|
|
570
|
+
files,
|
|
571
|
+
onToolChange: handleSelectedToolChange,
|
|
572
|
+
turnOptionsLocked: statusForComposer !== "ready",
|
|
573
|
+
attachmentModelPending: steering && !hasText(activeModelId),
|
|
574
|
+
selectedTool: retainedToolSelection(
|
|
575
|
+
comparison,
|
|
576
|
+
pendingMessage,
|
|
577
|
+
composerDraft.selectedTool
|
|
578
|
+
),
|
|
579
|
+
}}
|
|
580
|
+
modelIds={composerModelIds(
|
|
581
|
+
input.modelIds,
|
|
582
|
+
comparison?.modelIds,
|
|
583
|
+
visibleModelId
|
|
544
584
|
)}
|
|
545
|
-
|
|
585
|
+
modelPicker={
|
|
586
|
+
<ParallelResponseModelPicker
|
|
587
|
+
disabled={Boolean(pendingMessage)}
|
|
588
|
+
modelSelection={modelSelection}
|
|
589
|
+
retainedModelId={visibleModelId}
|
|
590
|
+
retainedModelIds={comparison?.modelIds}
|
|
591
|
+
/>
|
|
592
|
+
}
|
|
593
|
+
onDraftChange={handleDraftChange}
|
|
594
|
+
onStop={onStop}
|
|
595
|
+
onSubmit={onSubmit}
|
|
596
|
+
readOnly={Boolean(comparison)}
|
|
597
|
+
stopDisabled={cancelPending || status === "resuming"}
|
|
598
|
+
/>
|
|
546
599
|
);
|
|
547
600
|
};
|
|
548
601
|
|
|
@@ -587,9 +640,9 @@ const EveConversation = ({
|
|
|
587
640
|
delivery.accept
|
|
588
641
|
);
|
|
589
642
|
const displayedError =
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
643
|
+
pendingMessage || commandPending
|
|
644
|
+
? undefined
|
|
645
|
+
: conversationError(agent.view, commandFailure, agent.error);
|
|
593
646
|
// Failed provisional messages are retained in the recovery panel below.
|
|
594
647
|
// They must not look like accepted transcript entries or survive a retry twice.
|
|
595
648
|
const messages = selectedConversationMessages(
|
|
@@ -681,6 +734,14 @@ const EveConversation = ({
|
|
|
681
734
|
controller.commands.update(branchId, { cancellation: 0 });
|
|
682
735
|
}
|
|
683
736
|
};
|
|
737
|
+
const reconnect = (): void => {
|
|
738
|
+
void run(async () => {
|
|
739
|
+
await agent.resume();
|
|
740
|
+
if (hasText(pendingMessage?.operationId)) {
|
|
741
|
+
await refreshDeliveryReceipt(pendingMessage.operationId);
|
|
742
|
+
}
|
|
743
|
+
});
|
|
744
|
+
};
|
|
684
745
|
const sendPendingMessage = async (
|
|
685
746
|
pending: ActivePendingEveMessage
|
|
686
747
|
): Promise<void> => {
|
|
@@ -922,11 +983,23 @@ const EveConversation = ({
|
|
|
922
983
|
<p aria-live="polite" className="sr-only">
|
|
923
984
|
{statusLabel}
|
|
924
985
|
</p>
|
|
925
|
-
{
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
986
|
+
{hasText(snapshot.error) && (
|
|
987
|
+
<EveChatError
|
|
988
|
+
title="Couldn’t load all messages"
|
|
989
|
+
message="Refresh the page to try again."
|
|
990
|
+
/>
|
|
991
|
+
)}
|
|
992
|
+
<EveConversationError
|
|
993
|
+
error={displayedError}
|
|
994
|
+
reconnect={reconnect}
|
|
995
|
+
reconnectDisabled={busy || cancelPending}
|
|
996
|
+
/>
|
|
997
|
+
{hasText(composerDraft.error) && (
|
|
998
|
+
<EveChatError
|
|
999
|
+
title="Draft unavailable"
|
|
1000
|
+
message={composerDraft.error}
|
|
1001
|
+
/>
|
|
1002
|
+
)}
|
|
930
1003
|
{pendingMessage && !commandPending && (
|
|
931
1004
|
<EveDeliveryRecovery
|
|
932
1005
|
pendingMessage={pendingMessage}
|
|
@@ -935,6 +1008,8 @@ const EveConversation = ({
|
|
|
935
1008
|
files={files}
|
|
936
1009
|
run={run}
|
|
937
1010
|
sendPendingMessage={sendPendingMessage}
|
|
1011
|
+
reconnect={reconnect}
|
|
1012
|
+
reconnectDisabled={busy || cancelPending}
|
|
938
1013
|
setCommandFailure={setCommandFailure}
|
|
939
1014
|
/>
|
|
940
1015
|
)}
|
|
@@ -950,9 +1025,6 @@ const EveConversation = ({
|
|
|
950
1025
|
busy={busy}
|
|
951
1026
|
commandPending={commandPending}
|
|
952
1027
|
cancelPending={cancelPending}
|
|
953
|
-
displayedError={displayedError}
|
|
954
|
-
commandFailure={commandFailure}
|
|
955
|
-
agentError={agent.error}
|
|
956
1028
|
onStop={() => {
|
|
957
1029
|
startEventAction(cancel);
|
|
958
1030
|
}}
|
|
@@ -975,9 +1047,6 @@ const EveConversation = ({
|
|
|
975
1047
|
));
|
|
976
1048
|
});
|
|
977
1049
|
}}
|
|
978
|
-
onReconnect={() => {
|
|
979
|
-
void run(agent.resume);
|
|
980
|
-
}}
|
|
981
1050
|
/>
|
|
982
1051
|
}
|
|
983
1052
|
/>
|
|
@@ -60,10 +60,30 @@ const matchesSavedRequest = (
|
|
|
60
60
|
);
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
+
const emptyRecoveryMessage = (
|
|
64
|
+
{
|
|
65
|
+
loaded,
|
|
66
|
+
pending,
|
|
67
|
+
rejected,
|
|
68
|
+
failure,
|
|
69
|
+
}: {
|
|
70
|
+
readonly loaded: boolean;
|
|
71
|
+
readonly pending: ReturnType<typeof readCreationRequest>;
|
|
72
|
+
readonly rejected: boolean;
|
|
73
|
+
readonly failure: string;
|
|
74
|
+
},
|
|
75
|
+
message: string | undefined,
|
|
76
|
+
initialFailure: string
|
|
77
|
+
): string | undefined =>
|
|
78
|
+
loaded && !pending && !rejected && !failure && !initialFailure
|
|
79
|
+
? message
|
|
80
|
+
: undefined;
|
|
81
|
+
|
|
63
82
|
export const EveCreationRecovery = ({
|
|
64
83
|
ownerId,
|
|
65
84
|
operationId,
|
|
66
85
|
firstMessage,
|
|
86
|
+
missingRequestMessage,
|
|
67
87
|
scope,
|
|
68
88
|
initiallyRejected = false,
|
|
69
89
|
initialFailure = "",
|
|
@@ -71,6 +91,7 @@ export const EveCreationRecovery = ({
|
|
|
71
91
|
}: {
|
|
72
92
|
readonly ownerId: string;
|
|
73
93
|
readonly operationId?: string;
|
|
94
|
+
readonly missingRequestMessage?: string;
|
|
74
95
|
readonly firstMessage: string;
|
|
75
96
|
readonly scope?: Readonly<CreationScope>;
|
|
76
97
|
readonly initiallyRejected?: boolean;
|
|
@@ -119,11 +140,12 @@ export const EveCreationRecovery = ({
|
|
|
119
140
|
),
|
|
120
141
|
[ownerId, operationId, scope, initiallyRejected]
|
|
121
142
|
);
|
|
122
|
-
const
|
|
143
|
+
const recovery = useSyncExternalStore(
|
|
123
144
|
store.subscribe,
|
|
124
145
|
store.getSnapshot,
|
|
125
146
|
store.getServerSnapshot
|
|
126
147
|
);
|
|
148
|
+
const { pending, rejected, loaded, failure } = recovery;
|
|
127
149
|
const { setRejected, setFailure } = useMemo(
|
|
128
150
|
() => ({
|
|
129
151
|
setRejected: (value: boolean): void => {
|
|
@@ -209,6 +231,15 @@ export const EveCreationRecovery = ({
|
|
|
209
231
|
}
|
|
210
232
|
};
|
|
211
233
|
|
|
234
|
+
const emptyMessage = emptyRecoveryMessage(
|
|
235
|
+
recovery,
|
|
236
|
+
missingRequestMessage,
|
|
237
|
+
initialFailure
|
|
238
|
+
);
|
|
239
|
+
if (hasText(emptyMessage)) {
|
|
240
|
+
return <p className="text-muted-foreground text-sm">{emptyMessage}</p>;
|
|
241
|
+
}
|
|
242
|
+
|
|
212
243
|
const status = recoveryStatus(
|
|
213
244
|
loaded,
|
|
214
245
|
pending !== undefined,
|
|
@@ -201,7 +201,7 @@ export const EveHistoryList = ({
|
|
|
201
201
|
): React.JSX.Element => (
|
|
202
202
|
<div className="[&:not(:first-child)]:mt-6" key={group.label}>
|
|
203
203
|
{group.label && (
|
|
204
|
-
<div className="text-sidebar-foreground/
|
|
204
|
+
<div className="text-sidebar-foreground/65 px-2 py-1 text-xs">
|
|
205
205
|
{group.label}
|
|
206
206
|
</div>
|
|
207
207
|
)}
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
1
|
+
import { CheckIcon } from "lucide-react";
|
|
2
|
+
import { cn } from "@/lib/utils";
|
|
3
3
|
|
|
4
|
-
/** The
|
|
4
|
+
/** The option exposes selection. Its checkmark is purely visual. */
|
|
5
5
|
export const ModelSelectionIndicator = ({
|
|
6
6
|
selected,
|
|
7
7
|
}: {
|
|
8
8
|
readonly selected: boolean;
|
|
9
9
|
}) => (
|
|
10
|
-
<
|
|
11
|
-
aria-hidden
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
<span
|
|
11
|
+
aria-hidden="true"
|
|
12
|
+
className={cn(
|
|
13
|
+
"bg-input/90 grid size-4 shrink-0 place-items-center rounded-[5px]",
|
|
14
|
+
selected && "bg-primary text-primary-foreground"
|
|
15
|
+
)}
|
|
16
|
+
>
|
|
17
|
+
{selected && <CheckIcon className="size-3.5" />}
|
|
18
|
+
</span>
|
|
17
19
|
);
|