rift-ds 1.33.0 → 1.34.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/behaviors/chat-card.css +11 -6
- package/chat/AssistantTurn.d.ts +2 -0
- package/chat/AssistantTurn.js +18 -7
- package/chat/ChatProvider.js +14 -0
- package/chat/ChatWidget.css +10 -0
- package/chat/ChatWidget.d.ts +7 -3
- package/chat/ChatWidget.js +6 -3
- package/chat/agentState.d.ts +2 -1
- package/chat/agentState.js +4 -1
- package/chat/awaiting.d.ts +19 -0
- package/chat/awaiting.js +21 -0
- package/chat/context.d.ts +4 -0
- package/chat/index.d.ts +1 -0
- package/chat/index.js +3 -1
- package/chat/server.d.ts +8 -3
- package/chat/server.js +1 -1
- package/components/ActionCard/ActionCard.css +3 -3
- package/components/AgentStatus/AgentStatus.css +114 -22
- package/components/AgentStatus/AgentStatus.d.ts +10 -7
- package/components/AgentStatus/AgentStatus.js +10 -0
- package/components/AiButton/AiButton.d.ts +3 -3
- package/components/Composer/Composer.css +14 -9
- package/components/Composer/Composer.d.ts +10 -8
- package/components/Composer/Composer.js +2 -1
- package/components/MessageCard/MessageCard.css +1 -1
- package/components/SourceTrail/SourceTrail.css +1 -1
- package/components/ToolCall/ToolCall.css +2 -2
- package/components/UsageCard/UsageCard.css +4 -3
- package/package.json +1 -1
package/behaviors/chat-card.css
CHANGED
|
@@ -48,15 +48,15 @@
|
|
|
48
48
|
/* Insets: every row's first thing stands this far in; stacked cards and
|
|
49
49
|
opened panels hold their text this far off the top and bottom edges. */
|
|
50
50
|
--ds-chat-card-inset: var(--padding-500);
|
|
51
|
-
--ds-chat-card-edge: var(--padding-
|
|
51
|
+
--ds-chat-card-edge: var(--padding-400);
|
|
52
52
|
|
|
53
53
|
/* Rhythm, three steps: a title's subline (a description, detail, meta or
|
|
54
54
|
subtitle line) sits straight under it, its leading the only space; a
|
|
55
55
|
body under that (a description under a meta line, a list of facts)
|
|
56
56
|
stands a text gap off; blocks (text to buttons) a block gap apart. */
|
|
57
57
|
--ds-chat-card-gap-subline: 0;
|
|
58
|
-
--ds-chat-card-gap-text: var(--gap-
|
|
59
|
-
--ds-chat-card-gap-block: var(--gap-
|
|
58
|
+
--ds-chat-card-gap-text: var(--gap-300);
|
|
59
|
+
--ds-chat-card-gap-block: var(--gap-500);
|
|
60
60
|
|
|
61
61
|
/* One-row cards: a compact control and this much above and below, so a
|
|
62
62
|
label row and a row holding a button are one height. */
|
|
@@ -70,12 +70,17 @@
|
|
|
70
70
|
/* The fact list: a label beside its value, a line each, as ActionReadout
|
|
71
71
|
and ActionCard list what a change will do or did. A card sets only where
|
|
72
72
|
the list sits. */
|
|
73
|
+
/* The list's own margin is cleared at no specificity, so the card's rule
|
|
74
|
+
for where the list sits wins whichever stylesheet loads last. */
|
|
75
|
+
:where(.ds-chat-card-facts) {
|
|
76
|
+
margin: 0;
|
|
77
|
+
}
|
|
78
|
+
|
|
73
79
|
.ds-chat-card-facts {
|
|
74
80
|
display: grid;
|
|
75
81
|
grid-template-columns: max-content minmax(0, 1fr);
|
|
76
|
-
column-gap: var(--gap-
|
|
77
|
-
row-gap: var(--gap-
|
|
78
|
-
margin: 0;
|
|
82
|
+
column-gap: var(--gap-500);
|
|
83
|
+
row-gap: var(--gap-200);
|
|
79
84
|
font-family: var(--font-paragraph-sm-family);
|
|
80
85
|
font-size: var(--font-paragraph-sm-size);
|
|
81
86
|
font-weight: var(--font-paragraph-sm-weight);
|
package/chat/AssistantTurn.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ export interface AssistantTurnLabels {
|
|
|
10
10
|
};
|
|
11
11
|
/** The reasoning disclosure's summary once thinking is over, given the seconds it took when known. */
|
|
12
12
|
reasoning?: (durationSeconds: number | undefined) => string;
|
|
13
|
+
/** The status line while a card in the reply waits on the reader's Confirm. Defaults to "Waiting for approval". */
|
|
14
|
+
awaitingApproval?: string;
|
|
13
15
|
/** The question card a reply ends in. */
|
|
14
16
|
questionCard?: Partial<QuestionCardLabels>;
|
|
15
17
|
/** The follow-up row's hidden "(chosen)" text. */
|
package/chat/AssistantTurn.js
CHANGED
|
@@ -8,6 +8,7 @@ import { CodeBlock } from "../components/CodeBlock/CodeBlock.js";
|
|
|
8
8
|
import { ChatMessage } from "../components/ChatMessage/ChatMessage.js";
|
|
9
9
|
import { Prose } from "../components/Prose/Prose.js";
|
|
10
10
|
import { Reasoning } from "../components/Reasoning/Reasoning.js";
|
|
11
|
+
import { TurnIdContext } from "./awaiting.js";
|
|
11
12
|
import { useChatWidget } from "./context.js";
|
|
12
13
|
import { DOCK_QUERY } from "./queries.js";
|
|
13
14
|
import { FollowupSuggestions } from "./FollowupSuggestions.js";
|
|
@@ -15,6 +16,8 @@ import { ResponseActions } from "./ResponseActions.js";
|
|
|
15
16
|
import { turnCards } from "./artifacts.js";
|
|
16
17
|
import { TurnCard } from "./TurnContent.js";
|
|
17
18
|
import { TurnQuestion } from "./TurnQuestion.js";
|
|
19
|
+
const DEFAULT_REASONING_LABEL = (durationSeconds) => durationSeconds !== void 0 ? `Thought for ${durationSeconds}s` : "Thought process";
|
|
20
|
+
const DEFAULT_AWAITING_APPROVAL_LABEL = "Waiting for approval";
|
|
18
21
|
const CodeBlockLabelsContext = createContext(void 0);
|
|
19
22
|
function MarkdownLink({ href, children }) {
|
|
20
23
|
const { view, setOpen, renderLink, isInternalHref } = useChatWidget();
|
|
@@ -66,9 +69,11 @@ function AssistantTurn({
|
|
|
66
69
|
const leadCards = allCards.filter((card) => card.lead);
|
|
67
70
|
const cards = allCards.filter((card) => !card.lead);
|
|
68
71
|
const led = leadCards.length > 0;
|
|
69
|
-
const
|
|
70
|
-
const
|
|
71
|
-
const
|
|
72
|
+
const showReasoning = thinking || tracePoints.length > 0 || led || durationSeconds !== void 0;
|
|
73
|
+
const { turns, live: liveTurn, freshFollowupsId, awaiting: awaitingCards } = useChatWidget();
|
|
74
|
+
const turnId = (live ?? turn)?.id ?? null;
|
|
75
|
+
let awaiting = false;
|
|
76
|
+
for (const id of awaitingCards.values()) if (id === turnId) awaiting = true;
|
|
72
77
|
const followupsPending = !!turn && turn.text !== "" && !!turn.exchangeId && !turn.followups && !turn.question && !liveTurn && turns[turns.length - 1]?.id === turn.id;
|
|
73
78
|
return /* @__PURE__ */ jsx(
|
|
74
79
|
ChatMessage,
|
|
@@ -86,15 +91,21 @@ function AssistantTurn({
|
|
|
86
91
|
chosenLabel: labels?.promptSuggestions?.chosenLabel
|
|
87
92
|
}
|
|
88
93
|
) : followupsPending && turn ? /* @__PURE__ */ jsx(FollowupSuggestions, { turnId: turn.id, suggestions: [], pending: true }) : void 0,
|
|
89
|
-
children: /* @__PURE__ */ jsxs("div", { className: "ds-chat-widget__response", children: [
|
|
94
|
+
children: /* @__PURE__ */ jsx(TurnIdContext.Provider, { value: turnId, children: /* @__PURE__ */ jsxs("div", { className: "ds-chat-widget__response", children: [
|
|
90
95
|
showReasoning && /* @__PURE__ */ jsx(
|
|
91
96
|
Reasoning,
|
|
92
97
|
{
|
|
93
98
|
streaming: thinking && !led,
|
|
94
99
|
summaryOnly: tracePoints.length === 0,
|
|
95
100
|
duration: durationSeconds,
|
|
96
|
-
|
|
97
|
-
|
|
101
|
+
summary: thinking && live ? /* @__PURE__ */ jsx(AgentStatus, { state: "working", label: live.statusLabel }) : awaiting ? /* @__PURE__ */ jsx(AgentStatus, { state: "waiting", label: labels?.awaitingApproval ?? DEFAULT_AWAITING_APPROVAL_LABEL }) : /* @__PURE__ */ jsx(
|
|
102
|
+
AgentStatus,
|
|
103
|
+
{
|
|
104
|
+
state: source?.outcome === "failed" ? "error" : "done",
|
|
105
|
+
className: "ds-chat-widget__thought",
|
|
106
|
+
label: (labels?.reasoning ?? DEFAULT_REASONING_LABEL)(durationSeconds)
|
|
107
|
+
}
|
|
108
|
+
),
|
|
98
109
|
children: tracePoints.length > 0 && /* @__PURE__ */ jsx("ul", { children: tracePoints.map((point, index) => /* @__PURE__ */ jsx("li", { children: point }, `${index}-${point.slice(0, 24)}`)) })
|
|
99
110
|
}
|
|
100
111
|
),
|
|
@@ -103,7 +114,7 @@ function AssistantTurn({
|
|
|
103
114
|
cards.map((card, index) => /* @__PURE__ */ jsx(TurnCard, { card }, index)),
|
|
104
115
|
text !== "" && /* @__PURE__ */ jsx(CodeBlockLabelsContext.Provider, { value: labels?.codeBlock, children: /* @__PURE__ */ jsx(Prose, { children: /* @__PURE__ */ jsx(ReactMarkdown, { remarkPlugins: [remarkGfm], components: markdownComponents, children: text }) }) }),
|
|
105
116
|
turn?.question && /* @__PURE__ */ jsx(TurnQuestion, { turn, labels: labels?.questionCard })
|
|
106
|
-
] })
|
|
117
|
+
] }) })
|
|
107
118
|
}
|
|
108
119
|
);
|
|
109
120
|
}
|
package/chat/ChatProvider.js
CHANGED
|
@@ -72,6 +72,16 @@ function ChatProvider({
|
|
|
72
72
|
const target = useMemo(() => followupTarget(chat.turns), [chat.turns]);
|
|
73
73
|
const askedRef = useRef(/* @__PURE__ */ new Set());
|
|
74
74
|
const [freshFollowupsId, setFreshFollowupsId] = useState(null);
|
|
75
|
+
const [awaiting, setAwaitingMap] = useState(() => /* @__PURE__ */ new Map());
|
|
76
|
+
const setAwaiting = useCallback((key, turnId) => {
|
|
77
|
+
setAwaitingMap((current) => {
|
|
78
|
+
if ((current.get(key) ?? null) === turnId) return current;
|
|
79
|
+
const next = new Map(current);
|
|
80
|
+
if (turnId === null) next.delete(key);
|
|
81
|
+
else next.set(key, turnId);
|
|
82
|
+
return next;
|
|
83
|
+
});
|
|
84
|
+
}, []);
|
|
75
85
|
useEffect(() => {
|
|
76
86
|
if (!target || askedRef.current.has(target.id)) return;
|
|
77
87
|
askedRef.current.add(target.id);
|
|
@@ -176,6 +186,8 @@ function ChatProvider({
|
|
|
176
186
|
setStarterRevealKey,
|
|
177
187
|
starterSeed,
|
|
178
188
|
freshFollowupsId,
|
|
189
|
+
awaiting,
|
|
190
|
+
setAwaiting,
|
|
179
191
|
view,
|
|
180
192
|
setView,
|
|
181
193
|
placement,
|
|
@@ -206,6 +218,8 @@ function ChatProvider({
|
|
|
206
218
|
starterRevealKey,
|
|
207
219
|
starterSeed,
|
|
208
220
|
freshFollowupsId,
|
|
221
|
+
awaiting,
|
|
222
|
+
setAwaiting,
|
|
209
223
|
view,
|
|
210
224
|
placement,
|
|
211
225
|
setPlacement,
|
package/chat/ChatWidget.css
CHANGED
|
@@ -510,6 +510,16 @@
|
|
|
510
510
|
gap: var(--gap-500);
|
|
511
511
|
}
|
|
512
512
|
|
|
513
|
+
/* The finished reasoning line: the tick keeps the positive colour and the
|
|
514
|
+
words go back to the quiet summary they were, in the trigger's own face
|
|
515
|
+
and colour, so the mark is the only thing on the line that says done. */
|
|
516
|
+
.ds-chat-widget__thought.ds-agent-status {
|
|
517
|
+
--ds-agent-label-color: inherit;
|
|
518
|
+
|
|
519
|
+
font: inherit;
|
|
520
|
+
letter-spacing: inherit;
|
|
521
|
+
}
|
|
522
|
+
|
|
513
523
|
/* No divider: the composer floats free of the transcript. */
|
|
514
524
|
.ds-chat-widget__footer {
|
|
515
525
|
display: flex;
|
package/chat/ChatWidget.d.ts
CHANGED
|
@@ -112,8 +112,8 @@ export interface ChatWidgetProps {
|
|
|
112
112
|
questionsPlaceholder?: string;
|
|
113
113
|
/** Show the conversation starters on the welcome screen. */
|
|
114
114
|
showStarters?: boolean;
|
|
115
|
-
/** The header mark
|
|
116
|
-
logo?: string | null;
|
|
115
|
+
/** The header mark: an image src, or a node drawn as given, such as an inline SVG that reads the theme's tokens. Null (the default) shows the name alone. */
|
|
116
|
+
logo?: string | ReactNode | null;
|
|
117
117
|
/** The welcome screen's line under the greeting. */
|
|
118
118
|
tagline?: string;
|
|
119
119
|
/** The conversation starters: a few pre-written questions. Each must fit the chip budget (SUGGESTION_MAX_CHARS); one that does not is dropped rather than clipped. */
|
|
@@ -124,6 +124,8 @@ export interface ChatWidgetProps {
|
|
|
124
124
|
startersPending?: boolean;
|
|
125
125
|
/** Replaces the composer's leading actions (the model picker). */
|
|
126
126
|
composerActions?: ReactNode;
|
|
127
|
+
/** The composer's gradient ring, Composer's `aiGlow`: `'streaming'` (the default) lights it only while a reply is in flight, `true` also on focus, `false` never. */
|
|
128
|
+
composerGlow?: boolean | 'streaming';
|
|
127
129
|
/** The models the picker offers. The pick rides on each send as a wire value; the server resolves it. Omit for no picker. */
|
|
128
130
|
models?: ChatModelOption[];
|
|
129
131
|
/** The picker's selection before the server has reported its default. Defaults to the first model. */
|
|
@@ -252,6 +254,8 @@ export interface ChatWidgetProps {
|
|
|
252
254
|
pastedTextLabel?: string;
|
|
253
255
|
/** The reasoning disclosure's summary once the thinking is over, given the seconds it took when known. Defaults to "Thought for <n>s", or "Thought process" with no duration. */
|
|
254
256
|
reasoningLabel?: (durationSeconds: number | undefined) => string;
|
|
257
|
+
/** A reply's status line while a card in it waits on the reader's Confirm. Defaults to "Waiting for approval". */
|
|
258
|
+
awaitingApprovalLabel?: string;
|
|
255
259
|
/** The composer's words, over Composer's English defaults: the attach button ("Attach files"), the drop overlay on the shell ("Drop files to attach"), the queued files' list ("Attachments") and their tiles (`attachmentTileLabels`), the stop button ("Stop generating"), the text field's name ("Message"), and the sentences announced when files or mention matches change. The send button's name is `sendLabel`. */
|
|
256
260
|
composerLabels?: Pick<ComposerProps, 'attachLabel' | 'dropLabel' | 'filesLabel' | 'attachmentTileLabels' | 'stopLabel' | 'aria-label' | 'formatFileAnnouncement' | 'formatMentionAnnouncement'>;
|
|
257
261
|
/** The drop overlay's headline when a file is dragged over the chat with attachments on, over AttachmentDropZone's "Drop files to attach". Its second line is `attachHint`. */
|
|
@@ -287,4 +291,4 @@ export interface ChatWidgetProps {
|
|
|
287
291
|
* a stage card, a whole page). It reads all of its state from ChatProvider,
|
|
288
292
|
* so the conversation is the same object wherever it shows.
|
|
289
293
|
*/
|
|
290
|
-
export declare function ChatWidget({ fullscreenEnabled, layout, backdrop, closeEnabled, placementEnabled, compact, phone, title, flow, placeholder, questionsPlaceholder, showStarters, logo, tagline, starters: startersInput, startersKey, startersPending, composerActions, models, defaultModel, lockedModelDescription, fileAttachments, maxAttachments, maxAttachmentBytes, mentions, threads, threadsProps, tabs, aside, agent, artifacts, context: contextProp, contextClearLabel, contextLabel, contextNote, contextPlacement, attachHint: attachHintText, greetings, placementLabels, agentStatus, artifactPanelTitle, artifactEmptyTitle, artifactEmptyDescription, widgets, widgetsLayout, widgetsWidth, disclaimer, startersLabel, newChatLabel, showAgentLabel, hideAgentLabel, closeAgentLabel, showArtifactLabel, hideArtifactLabel, closeArtifactLabel, placementLabel, enterFullscreenLabel, exitFullscreenLabel, closeLabel, openThreadsLabel, closeThreadsLabel, modelPickerLabel, sendLabel, copyResponseLabel, copiedResponseLabel, copiedAnnouncementLabel, goodResponseLabel, badResponseLabel, followupsLabel, pastedTextLabel, reasoningLabel, tabsProps, composerLabels, attachmentDropZoneLabels, attachmentGroupLabels, renderAttachmentPreview, onAttachmentDownload, chatThreadLabels, modelPickerLabels, artifactPanelLabels, agentRailLabels, questionCardLabels, questionSummaryLabels, codeBlockLabels, promptSuggestionsLabels, }: ChatWidgetProps): import("react").JSX.Element;
|
|
294
|
+
export declare function ChatWidget({ fullscreenEnabled, layout, backdrop, closeEnabled, placementEnabled, compact, phone, title, flow, placeholder, questionsPlaceholder, showStarters, logo, tagline, starters: startersInput, startersKey, startersPending, composerActions, models, defaultModel, lockedModelDescription, fileAttachments, maxAttachments, maxAttachmentBytes, mentions, threads, threadsProps, tabs, aside, agent, artifacts, context: contextProp, contextClearLabel, contextLabel, contextNote, contextPlacement, attachHint: attachHintText, greetings, placementLabels, agentStatus, artifactPanelTitle, artifactEmptyTitle, artifactEmptyDescription, widgets, widgetsLayout, widgetsWidth, disclaimer, startersLabel, newChatLabel, showAgentLabel, hideAgentLabel, closeAgentLabel, showArtifactLabel, hideArtifactLabel, closeArtifactLabel, placementLabel, enterFullscreenLabel, exitFullscreenLabel, closeLabel, openThreadsLabel, closeThreadsLabel, modelPickerLabel, sendLabel, copyResponseLabel, copiedResponseLabel, copiedAnnouncementLabel, goodResponseLabel, badResponseLabel, followupsLabel, pastedTextLabel, reasoningLabel, awaitingApprovalLabel, composerGlow, tabsProps, composerLabels, attachmentDropZoneLabels, attachmentGroupLabels, renderAttachmentPreview, onAttachmentDownload, chatThreadLabels, modelPickerLabels, artifactPanelLabels, agentRailLabels, questionCardLabels, questionSummaryLabels, codeBlockLabels, promptSuggestionsLabels, }: ChatWidgetProps): import("react").JSX.Element;
|
package/chat/ChatWidget.js
CHANGED
|
@@ -116,6 +116,8 @@ function ChatWidget({
|
|
|
116
116
|
followupsLabel = "Follow-up questions",
|
|
117
117
|
pastedTextLabel,
|
|
118
118
|
reasoningLabel,
|
|
119
|
+
awaitingApprovalLabel,
|
|
120
|
+
composerGlow = "streaming",
|
|
119
121
|
tabsProps,
|
|
120
122
|
composerLabels,
|
|
121
123
|
attachmentDropZoneLabels,
|
|
@@ -145,10 +147,11 @@ function ChatWidget({
|
|
|
145
147
|
() => ({
|
|
146
148
|
codeBlock: codeBlockLabels,
|
|
147
149
|
reasoning: reasoningLabel,
|
|
150
|
+
awaitingApproval: awaitingApprovalLabel,
|
|
148
151
|
questionCard: questionCardLabels,
|
|
149
152
|
promptSuggestions: promptSuggestionsLabels
|
|
150
153
|
}),
|
|
151
|
-
[codeBlockLabels, reasoningLabel, questionCardLabels, promptSuggestionsLabels]
|
|
154
|
+
[codeBlockLabels, reasoningLabel, awaitingApprovalLabel, questionCardLabels, promptSuggestionsLabels]
|
|
152
155
|
);
|
|
153
156
|
const {
|
|
154
157
|
turns,
|
|
@@ -612,7 +615,7 @@ function ChatWidget({
|
|
|
612
615
|
onClick: () => setThreadsOpen(true)
|
|
613
616
|
}
|
|
614
617
|
),
|
|
615
|
-
logo
|
|
618
|
+
typeof logo === "string" ? /* @__PURE__ */ jsx("img", { src: logo, alt: "", width: 20, height: 20 }) : logo,
|
|
616
619
|
/* @__PURE__ */ jsx("span", { className: "ds-chat-widget__brand-name", children: title })
|
|
617
620
|
] }),
|
|
618
621
|
actions: (
|
|
@@ -685,7 +688,7 @@ function ChatWidget({
|
|
|
685
688
|
disabled: questionsOpen,
|
|
686
689
|
sendLabel,
|
|
687
690
|
inline: composerHasActions ? false : "chat",
|
|
688
|
-
aiGlow:
|
|
691
|
+
aiGlow: composerGlow,
|
|
689
692
|
value: draft,
|
|
690
693
|
onValueChange: setDraft,
|
|
691
694
|
onSubmit: handleSubmit,
|
package/chat/agentState.d.ts
CHANGED
|
@@ -7,7 +7,8 @@ import { AgentStatusState } from '../components/AgentStatus/AgentStatusPatterns'
|
|
|
7
7
|
* the end of a reply is only reported once.
|
|
8
8
|
*
|
|
9
9
|
* `thinking` until the first words, `working` once words or rich content are
|
|
10
|
-
* arriving, `waiting` while a question stands unanswered
|
|
10
|
+
* arriving, `waiting` while a question stands unanswered or a card waits on
|
|
11
|
+
* the reader's Confirm (see `useTurnAwaiting`), then `done` or
|
|
11
12
|
* `error` for a beat as a reply ends. A reply the visitor stopped, or a chat
|
|
12
13
|
* they reset, goes straight back to `idle`.
|
|
13
14
|
*/
|
package/chat/agentState.js
CHANGED
|
@@ -3,7 +3,7 @@ import { useState, useEffect } from "react";
|
|
|
3
3
|
import { MOTION_FEEDBACK_RESET_MS } from "../tokens/motion.js";
|
|
4
4
|
import { useChatWidget } from "./context.js";
|
|
5
5
|
function useChatAgentState() {
|
|
6
|
-
const { live, turns } = useChatWidget();
|
|
6
|
+
const { live, turns, awaiting } = useChatWidget();
|
|
7
7
|
const [ended, setEnded] = useState(null);
|
|
8
8
|
const last = turns[turns.length - 1];
|
|
9
9
|
const inFlight = live !== null;
|
|
@@ -22,6 +22,9 @@ function useChatAgentState() {
|
|
|
22
22
|
return live.phase === "thinking" && !live.content && !live.cards?.length ? "thinking" : "working";
|
|
23
23
|
}
|
|
24
24
|
if (last?.role === "assistant" && last.question && !last.answers) return "waiting";
|
|
25
|
+
for (const turnId of awaiting.values()) {
|
|
26
|
+
if (turns.some((turn) => turn.id === turnId)) return "waiting";
|
|
27
|
+
}
|
|
25
28
|
return ended ?? "idle";
|
|
26
29
|
}
|
|
27
30
|
export {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** The id of the assistant turn a card is drawn in, so a card's wait is recorded against its reply. */
|
|
2
|
+
export declare const TurnIdContext: import('react').Context<string | null>;
|
|
3
|
+
/**
|
|
4
|
+
* Report that the card this is called from waits on the reader, such as a
|
|
5
|
+
* proposed change with Confirm still to press. The wait is recorded once, on
|
|
6
|
+
* the chat provider, and everything that reports the agent reads it from
|
|
7
|
+
* there: the reply's status line reads as waiting for approval, and
|
|
8
|
+
* `useChatAgentState` returns `waiting` for whatever opens the chat, so the
|
|
9
|
+
* two can never disagree. Outside a chat turn it does nothing.
|
|
10
|
+
*
|
|
11
|
+
* Pass the card's own stable `key` when it has one: the wait then outlives
|
|
12
|
+
* the card being unmounted with the panel closed, which is when the opener's
|
|
13
|
+
* state matters most, and ends only when the card says it no longer waits.
|
|
14
|
+
* Without a key the wait ends when the card unmounts.
|
|
15
|
+
*
|
|
16
|
+
* A layout effect, so the line never paints its finished form for a frame
|
|
17
|
+
* before the card's wait is counted.
|
|
18
|
+
*/
|
|
19
|
+
export declare function useTurnAwaiting(awaiting: boolean, key?: string): void;
|
package/chat/awaiting.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useContext, useId, useLayoutEffect, createContext } from "react";
|
|
3
|
+
import { ChatWidgetContext } from "./context.js";
|
|
4
|
+
const TurnIdContext = createContext(null);
|
|
5
|
+
function useTurnAwaiting(awaiting, key) {
|
|
6
|
+
const setAwaiting = useContext(ChatWidgetContext)?.setAwaiting;
|
|
7
|
+
const turnId = useContext(TurnIdContext);
|
|
8
|
+
const ownKey = useId();
|
|
9
|
+
const entry = key ?? ownKey;
|
|
10
|
+
const sticky = key !== void 0;
|
|
11
|
+
useLayoutEffect(() => {
|
|
12
|
+
if (!setAwaiting || !turnId) return;
|
|
13
|
+
setAwaiting(entry, awaiting ? turnId : null);
|
|
14
|
+
if (sticky) return;
|
|
15
|
+
return () => setAwaiting(entry, null);
|
|
16
|
+
}, [setAwaiting, turnId, entry, awaiting, sticky]);
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
TurnIdContext,
|
|
20
|
+
useTurnAwaiting
|
|
21
|
+
};
|
package/chat/context.d.ts
CHANGED
|
@@ -47,6 +47,10 @@ export interface ChatWidgetContextValue extends ChatState {
|
|
|
47
47
|
starterSeed: number;
|
|
48
48
|
/** The turn whose follow-ups landed most recently in this open session, or null. Its row plays the entrance. */
|
|
49
49
|
freshFollowupsId: string | null;
|
|
50
|
+
/** The cards waiting on the reader's Confirm, by card key, each with the id of the turn it stands in. The one record the reply's status line and `useChatAgentState` both read. Written through `setAwaiting`, usually by `useTurnAwaiting`. */
|
|
51
|
+
awaiting: ReadonlyMap<string, string>;
|
|
52
|
+
/** Record that the card under `key` waits on the reader in the turn `turnId`, or, given `null`, that it no longer does. */
|
|
53
|
+
setAwaiting: (key: string, turnId: string | null) => void;
|
|
50
54
|
view: ChatView;
|
|
51
55
|
setView: (view: ChatView) => void;
|
|
52
56
|
/** The panel's seat: a dock edge or floating. Provider-lifetime, so a reload returns to the host's default. */
|
package/chat/index.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export { defineAction, planAction, skippedText, createConfirmationMark, sanitise
|
|
|
22
22
|
export { ChatLauncher, CHAT_PANEL_ID, type ChatLauncherProps } from './ChatLauncher';
|
|
23
23
|
export { preloadChatWidget } from './deferredChatWidget';
|
|
24
24
|
export { useChatAgentState } from './agentState';
|
|
25
|
+
export { useTurnAwaiting } from './awaiting';
|
|
25
26
|
export { ChatThreads, type ChatThreadsProps } from './ChatThreads';
|
|
26
27
|
export { ChatTabs, type ChatTabsProps } from './ChatTabs';
|
|
27
28
|
export { ChatAgentPane, type ChatAgentPaneProps } from './ChatAgentPane';
|
package/chat/index.js
CHANGED
|
@@ -7,6 +7,7 @@ import { confirmSequence, confirmationLine, createConfirmationMark, defineAction
|
|
|
7
7
|
import { CHAT_PANEL_ID, ChatLauncher } from "./ChatLauncher.js";
|
|
8
8
|
import { preloadChatWidget } from "./deferredChatWidget.js";
|
|
9
9
|
import { useChatAgentState } from "./agentState.js";
|
|
10
|
+
import { useTurnAwaiting } from "./awaiting.js";
|
|
10
11
|
import { ChatThreads } from "./ChatThreads.js";
|
|
11
12
|
import { ChatTabs } from "./ChatTabs.js";
|
|
12
13
|
import { ChatAgentPane } from "./ChatAgentPane.js";
|
|
@@ -128,5 +129,6 @@ export {
|
|
|
128
129
|
useHeldHighlight,
|
|
129
130
|
useSelectionFocus,
|
|
130
131
|
useTakeoverViewport,
|
|
131
|
-
useThreads
|
|
132
|
+
useThreads,
|
|
133
|
+
useTurnAwaiting
|
|
132
134
|
};
|
package/chat/server.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { default as Anthropic } from '@anthropic-ai/sdk';
|
|
2
|
-
import { ChatCard, ChatFeedbackVerdict, ChatModelOption, ChatPageAction } from './types';
|
|
2
|
+
import { ChatCard, ChatFeedbackVerdict, ChatModelOption, ChatPageAction, ChatTransportMessage } from './types';
|
|
3
3
|
/** What a tool hands back: text for the model, and optionally a card for the visitor. */
|
|
4
4
|
export { defineAction, planAction, skippedText, createConfirmationMark, sanitiseConfirmation, confirmationLine, planSequence, confirmSequence, defineContext, type ChatAction, type ActionPlan, type ActionConfirmation, type ConfirmationMark, type SanitiseConfirmationOptions, type ConfirmationLineOptions, type SequenceStep, type SequencePlan, type ConfirmedStep, type ContextField, type ContextShape, type ContextValues, type ContextSchema, } from './actions';
|
|
5
5
|
export { sanitiseSelection, selectionLines, DEFAULT_SELECTION_LIMITS, type ChatSelection, type SelectionKind, type SelectionLimits, type SelectionLinesOptions } from './selectionContext';
|
|
@@ -156,9 +156,14 @@ export interface ChatHandlerOptions {
|
|
|
156
156
|
}) => string | SystemBlocks);
|
|
157
157
|
/**
|
|
158
158
|
* An uncached trailing block built from the request's context, after the
|
|
159
|
-
* cache breakpoint. Defaults to naming the page; return null for none.
|
|
159
|
+
* cache breakpoint. Defaults to naming the page; return null for none. The
|
|
160
|
+
* second argument is the conversation as the handler received it, the
|
|
161
|
+
* latest message last, for a block that answers what the visitor named
|
|
162
|
+
* (a page, a record) as well as where they are.
|
|
160
163
|
*/
|
|
161
|
-
contextBlock?: (path: string
|
|
164
|
+
contextBlock?: (path: string, conversation: {
|
|
165
|
+
messages: readonly ChatTransportMessage[];
|
|
166
|
+
}) => string | null;
|
|
162
167
|
/** The models on offer. The client sends a `value`; the handler calls the matching `id`. */
|
|
163
168
|
models: ChatModelOption[];
|
|
164
169
|
/** The wire value that serves when the budget has headroom and the visitor has not chosen. Defaults to the first model. */
|
package/chat/server.js
CHANGED
|
@@ -224,7 +224,7 @@ function createChatHandler(options) {
|
|
|
224
224
|
typeof options.system === "function" ? options.system({ path: parsed.path }) : options.system
|
|
225
225
|
);
|
|
226
226
|
const toolContext = { context: parsed.path, request: {} };
|
|
227
|
-
const trailing = parsed.path ? contextBlock(parsed.path) : null;
|
|
227
|
+
const trailing = parsed.path ? contextBlock(parsed.path, { messages: parsed.messages }) : null;
|
|
228
228
|
const system = trailing ? [...systemBase, { type: "text", text: trailing }] : systemBase;
|
|
229
229
|
const body = new ReadableStream({
|
|
230
230
|
async start(controller) {
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
|
|
8
8
|
A content card of the chat furniture: the
|
|
9
9
|
container fill behind its border, at the
|
|
10
|
-
ArtifactCard's radius, with
|
|
11
|
-
padding so its text
|
|
12
|
-
reply's own text does.
|
|
10
|
+
ArtifactCard's radius, with the recipe's
|
|
11
|
+
edge and inset as its padding so its text
|
|
12
|
+
starts where the reply's own text does.
|
|
13
13
|
============================================ */
|
|
14
14
|
|
|
15
15
|
.ds-action-card {
|
|
@@ -192,18 +192,7 @@
|
|
|
192
192
|
--ds-agent-label-color: var(--color-status-error-text);
|
|
193
193
|
}
|
|
194
194
|
|
|
195
|
-
/*
|
|
196
|
-
finished, and twinkle: one or two dots at a time dip and return, so the
|
|
197
|
-
finished mark stays alive without drawing the eye. The doubled class and
|
|
198
|
-
:nth-child(n) lift the rule over every pattern's dark-dot opt-outs, so
|
|
199
|
-
the whole matrix twinkles whatever the pattern. */
|
|
200
|
-
.ds-agent-status.ds-agent-status--done .ds-agent-status__dot:nth-child(n),
|
|
201
|
-
.ds-agent-status.ds-agent-status--error .ds-agent-status__dot:nth-child(n) {
|
|
202
|
-
opacity: 1;
|
|
203
|
-
transform: none;
|
|
204
|
-
animation: ds-agent-dot-twinkle var(--ds-agent-twinkle-cycle) var(--motion-ease-standard) infinite;
|
|
205
|
-
animation-delay: calc(var(--ds-agent-twinkle-step, 0) * var(--ds-agent-twinkle-slot));
|
|
206
|
-
}
|
|
195
|
+
/* What the matrix draws once a run ends or waits is in GLYPHS, below. */
|
|
207
196
|
|
|
208
197
|
/* ============================================
|
|
209
198
|
SIZES
|
|
@@ -574,7 +563,7 @@
|
|
|
574
563
|
animation-delay: calc(var(--ds-agent-twinkle-step, 0) * var(--ds-agent-twinkle-slot));
|
|
575
564
|
}
|
|
576
565
|
|
|
577
|
-
/* The twinkle's scatter
|
|
566
|
+
/* The twinkle pattern's scatter */
|
|
578
567
|
.ds-agent-status__dot:nth-child(1) { --ds-agent-twinkle-step: 7; }
|
|
579
568
|
.ds-agent-status__dot:nth-child(2) { --ds-agent-twinkle-step: 2; }
|
|
580
569
|
.ds-agent-status__dot:nth-child(3) { --ds-agent-twinkle-step: 10; }
|
|
@@ -653,15 +642,6 @@
|
|
|
653
642
|
--ds-agent-color: var(--color-status-error-icon);
|
|
654
643
|
}
|
|
655
644
|
|
|
656
|
-
/* Finished: solid and twinkling, as AgentStatus's matrix does. */
|
|
657
|
-
.ds-agent-status-mark.ds-agent-status-mark--done .ds-agent-status-mark__dot:nth-child(n),
|
|
658
|
-
.ds-agent-status-mark.ds-agent-status-mark--error .ds-agent-status-mark__dot:nth-child(n) {
|
|
659
|
-
opacity: 1;
|
|
660
|
-
transform: none;
|
|
661
|
-
animation: ds-agent-dot-twinkle var(--ds-agent-twinkle-cycle) var(--motion-ease-standard) infinite;
|
|
662
|
-
animation-delay: calc(var(--ds-agent-twinkle-step, 0) * var(--ds-agent-twinkle-slot));
|
|
663
|
-
}
|
|
664
|
-
|
|
665
645
|
.ds-agent-status-mark--animated .ds-agent-status-mark__dot {
|
|
666
646
|
animation: ds-agent-dot var(--ds-agent-cycle) var(--motion-ease-standard) infinite;
|
|
667
647
|
animation-delay: calc(var(--ds-agent-step, 0) * var(--ds-agent-slot));
|
|
@@ -1107,6 +1087,116 @@
|
|
|
1107
1087
|
}
|
|
1108
1088
|
}
|
|
1109
1089
|
|
|
1090
|
+
/* ============================================
|
|
1091
|
+
GLYPHS
|
|
1092
|
+
The three states that ask something of the
|
|
1093
|
+
reader each resolve the matrix into a mark of
|
|
1094
|
+
their own, so the shape says which one it is
|
|
1095
|
+
before the colour or the label does:
|
|
1096
|
+
|
|
1097
|
+
done error waiting
|
|
1098
|
+
. . . o o . . o o . . .
|
|
1099
|
+
o . o . . o o . . o . .
|
|
1100
|
+
. o . . o . . o o . o o
|
|
1101
|
+
|
|
1102
|
+
a tick, a cross, and a prompt whose cursor
|
|
1103
|
+
breathes. The mark's square grid draws the same
|
|
1104
|
+
three with a row to spare. Each is drawn in
|
|
1105
|
+
stroke order, one dot a slot, then holds. The
|
|
1106
|
+
doubled class and :nth-child(n) lift these
|
|
1107
|
+
rules over every pattern's own, so a finished
|
|
1108
|
+
matrix draws its glyph whatever pattern ran.
|
|
1109
|
+
Waiting draws the prompt on its default pattern
|
|
1110
|
+
only: a pattern asked for by name still runs.
|
|
1111
|
+
============================================ */
|
|
1112
|
+
|
|
1113
|
+
.ds-agent-status--waiting.ds-agent-status--breathe,
|
|
1114
|
+
.ds-agent-status-mark--waiting.ds-agent-status-mark--breathe {
|
|
1115
|
+
/* The glyph is the signal now, so the unlit dots fall back to the
|
|
1116
|
+
working floor and the prompt stands clear of them. */
|
|
1117
|
+
--ds-agent-dot-dim: 0.2;
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
.ds-agent-status.ds-agent-status--done .ds-agent-status__dot:nth-child(n),
|
|
1121
|
+
.ds-agent-status.ds-agent-status--error .ds-agent-status__dot:nth-child(n),
|
|
1122
|
+
.ds-agent-status.ds-agent-status--waiting.ds-agent-status--breathe .ds-agent-status__dot:nth-child(n),
|
|
1123
|
+
.ds-agent-status-mark.ds-agent-status-mark--done .ds-agent-status-mark__dot:nth-child(n),
|
|
1124
|
+
.ds-agent-status-mark.ds-agent-status-mark--error .ds-agent-status-mark__dot:nth-child(n),
|
|
1125
|
+
.ds-agent-status-mark.ds-agent-status-mark--waiting.ds-agent-status-mark--breathe .ds-agent-status-mark__dot:nth-child(n) {
|
|
1126
|
+
opacity: var(--ds-agent-dot-dim);
|
|
1127
|
+
transform: scale(var(--ds-agent-dot-rest));
|
|
1128
|
+
animation: none;
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
.ds-agent-status.ds-agent-status--done .ds-agent-status__dot:is(:nth-child(4), :nth-child(5), :nth-child(7), :nth-child(10)),
|
|
1132
|
+
.ds-agent-status.ds-agent-status--error .ds-agent-status__dot:is(:nth-child(1), :nth-child(4), :nth-child(6), :nth-child(7), :nth-child(9), :nth-child(12)),
|
|
1133
|
+
.ds-agent-status.ds-agent-status--waiting.ds-agent-status--breathe .ds-agent-status__dot:is(:nth-child(1), :nth-child(6), :nth-child(9)),
|
|
1134
|
+
.ds-agent-status-mark.ds-agent-status-mark--done .ds-agent-status-mark__dot:is(:nth-child(8), :nth-child(9), :nth-child(11), :nth-child(14)),
|
|
1135
|
+
.ds-agent-status-mark.ds-agent-status-mark--error .ds-agent-status-mark__dot:is(:nth-child(1), :nth-child(4), :nth-child(6), :nth-child(7), :nth-child(10), :nth-child(11), :nth-child(13), :nth-child(16)),
|
|
1136
|
+
.ds-agent-status-mark.ds-agent-status-mark--waiting.ds-agent-status-mark--breathe .ds-agent-status-mark__dot:is(:nth-child(1), :nth-child(6), :nth-child(9)) {
|
|
1137
|
+
opacity: 1;
|
|
1138
|
+
transform: none;
|
|
1139
|
+
animation: var(--ds-agent-glyph-draw, none) var(--motion-duration-slow) var(--motion-ease-entrance) backwards;
|
|
1140
|
+
animation-delay: calc(var(--ds-agent-glyph-step, 0) * var(--ds-agent-slot));
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
/* The stroke-by-stroke draw runs only when the indicator reaches its state
|
|
1144
|
+
while on screen. One that mounts already there shows the glyph standing. */
|
|
1145
|
+
.ds-agent-status--arrived,
|
|
1146
|
+
.ds-agent-status-mark--arrived {
|
|
1147
|
+
--ds-agent-glyph-draw: ds-agent-dot-draw;
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1150
|
+
/* The prompt's cursor: the two dots after the chevron, breathing. */
|
|
1151
|
+
.ds-agent-status.ds-agent-status--waiting.ds-agent-status--breathe .ds-agent-status__dot:is(:nth-child(11), :nth-child(12)),
|
|
1152
|
+
.ds-agent-status-mark.ds-agent-status-mark--waiting.ds-agent-status-mark--breathe .ds-agent-status-mark__dot:is(:nth-child(15), :nth-child(16)) {
|
|
1153
|
+
animation: ds-agent-dot-breathe var(--ds-agent-cycle) var(--motion-ease-standard) infinite;
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
/* Stroke order. The tick runs down its short arm and up its long one; the
|
|
1157
|
+
cross draws one stroke, then the other; the chevron runs top to bottom. */
|
|
1158
|
+
.ds-agent-status--done .ds-agent-status__dot:nth-child(5) { --ds-agent-glyph-step: 0; }
|
|
1159
|
+
.ds-agent-status--done .ds-agent-status__dot:nth-child(10) { --ds-agent-glyph-step: 1; }
|
|
1160
|
+
.ds-agent-status--done .ds-agent-status__dot:nth-child(7) { --ds-agent-glyph-step: 2; }
|
|
1161
|
+
.ds-agent-status--done .ds-agent-status__dot:nth-child(4) { --ds-agent-glyph-step: 3; }
|
|
1162
|
+
.ds-agent-status--error .ds-agent-status__dot:nth-child(1) { --ds-agent-glyph-step: 0; }
|
|
1163
|
+
.ds-agent-status--error .ds-agent-status__dot:nth-child(6) { --ds-agent-glyph-step: 1; }
|
|
1164
|
+
.ds-agent-status--error .ds-agent-status__dot:nth-child(12) { --ds-agent-glyph-step: 2; }
|
|
1165
|
+
.ds-agent-status--error .ds-agent-status__dot:nth-child(4) { --ds-agent-glyph-step: 3; }
|
|
1166
|
+
.ds-agent-status--error .ds-agent-status__dot:nth-child(7) { --ds-agent-glyph-step: 4; }
|
|
1167
|
+
.ds-agent-status--error .ds-agent-status__dot:nth-child(9) { --ds-agent-glyph-step: 5; }
|
|
1168
|
+
.ds-agent-status--waiting .ds-agent-status__dot:nth-child(1) { --ds-agent-glyph-step: 0; }
|
|
1169
|
+
.ds-agent-status--waiting .ds-agent-status__dot:nth-child(6) { --ds-agent-glyph-step: 1; }
|
|
1170
|
+
.ds-agent-status--waiting .ds-agent-status__dot:nth-child(9) { --ds-agent-glyph-step: 2; }
|
|
1171
|
+
|
|
1172
|
+
.ds-agent-status-mark--done .ds-agent-status-mark__dot:nth-child(9) { --ds-agent-glyph-step: 0; }
|
|
1173
|
+
.ds-agent-status-mark--done .ds-agent-status-mark__dot:nth-child(14) { --ds-agent-glyph-step: 1; }
|
|
1174
|
+
.ds-agent-status-mark--done .ds-agent-status-mark__dot:nth-child(11) { --ds-agent-glyph-step: 2; }
|
|
1175
|
+
.ds-agent-status-mark--done .ds-agent-status-mark__dot:nth-child(8) { --ds-agent-glyph-step: 3; }
|
|
1176
|
+
.ds-agent-status-mark--error .ds-agent-status-mark__dot:nth-child(1) { --ds-agent-glyph-step: 0; }
|
|
1177
|
+
.ds-agent-status-mark--error .ds-agent-status-mark__dot:nth-child(6) { --ds-agent-glyph-step: 1; }
|
|
1178
|
+
.ds-agent-status-mark--error .ds-agent-status-mark__dot:nth-child(11) { --ds-agent-glyph-step: 2; }
|
|
1179
|
+
.ds-agent-status-mark--error .ds-agent-status-mark__dot:nth-child(16) { --ds-agent-glyph-step: 3; }
|
|
1180
|
+
.ds-agent-status-mark--error .ds-agent-status-mark__dot:nth-child(4) { --ds-agent-glyph-step: 4; }
|
|
1181
|
+
.ds-agent-status-mark--error .ds-agent-status-mark__dot:nth-child(7) { --ds-agent-glyph-step: 5; }
|
|
1182
|
+
.ds-agent-status-mark--error .ds-agent-status-mark__dot:nth-child(10) { --ds-agent-glyph-step: 6; }
|
|
1183
|
+
.ds-agent-status-mark--error .ds-agent-status-mark__dot:nth-child(13) { --ds-agent-glyph-step: 7; }
|
|
1184
|
+
.ds-agent-status-mark--waiting .ds-agent-status-mark__dot:nth-child(1) { --ds-agent-glyph-step: 0; }
|
|
1185
|
+
.ds-agent-status-mark--waiting .ds-agent-status-mark__dot:nth-child(6) { --ds-agent-glyph-step: 1; }
|
|
1186
|
+
.ds-agent-status-mark--waiting .ds-agent-status-mark__dot:nth-child(9) { --ds-agent-glyph-step: 2; }
|
|
1187
|
+
|
|
1188
|
+
@keyframes ds-agent-dot-draw {
|
|
1189
|
+
from {
|
|
1190
|
+
opacity: var(--ds-agent-dot-dim);
|
|
1191
|
+
transform: scale(var(--ds-agent-dot-rest));
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
60% {
|
|
1195
|
+
opacity: 1;
|
|
1196
|
+
transform: scale(1.2);
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1110
1200
|
/* ============================================
|
|
1111
1201
|
REDUCED MOTION
|
|
1112
1202
|
The global guard collapses every animation to
|
|
@@ -1121,6 +1211,8 @@
|
|
|
1121
1211
|
.ds-agent-status.ds-agent-status--error .ds-agent-status__dot:nth-child(n),
|
|
1122
1212
|
.ds-agent-status-mark.ds-agent-status-mark--done .ds-agent-status-mark__dot:nth-child(n),
|
|
1123
1213
|
.ds-agent-status-mark.ds-agent-status-mark--error .ds-agent-status-mark__dot:nth-child(n),
|
|
1214
|
+
.ds-agent-status.ds-agent-status--waiting.ds-agent-status--breathe .ds-agent-status__dot:nth-child(n),
|
|
1215
|
+
.ds-agent-status-mark.ds-agent-status-mark--waiting.ds-agent-status-mark--breathe .ds-agent-status-mark__dot:nth-child(n),
|
|
1124
1216
|
.ds-agent-status--animated.ds-agent-status--twinkle .ds-agent-status__dot:nth-child(n),
|
|
1125
1217
|
.ds-agent-status-mark--animated.ds-agent-status-mark--twinkle .ds-agent-status-mark__dot:nth-child(n) {
|
|
1126
1218
|
animation: none;
|
|
@@ -2,11 +2,11 @@ import { default as React } from 'react';
|
|
|
2
2
|
import { AgentStatusPattern, AgentStatusState } from './AgentStatusPatterns';
|
|
3
3
|
/** Props owned by AgentStatus itself — everything else falls through to the root element. */
|
|
4
4
|
type AgentStatusOwnProps = {
|
|
5
|
-
/** What the agent is doing. Drives the colour, the default label, and whether the matrix animates. */
|
|
5
|
+
/** What the agent is doing. Drives the colour, the default label, and whether the matrix animates. `waiting` takes the warning status colour, `done` the positive one (with a tick) and `error` the error one (with a cross); the other three stay monochrome. */
|
|
6
6
|
state?: AgentStatusState;
|
|
7
7
|
/** Status text. Falls back to a default for the state. Ignored when `children` are given. */
|
|
8
8
|
label?: string;
|
|
9
|
-
/** Which dot-matrix choreography to run. Defaults to `
|
|
9
|
+
/** Which dot-matrix choreography to run while the agent is active. Defaults to `orbit`. `waiting` with no pattern draws its glyph instead, a prompt whose cursor breathes (the same as AgentStatusMark); `done` and `error` draw a tick and a cross whatever the pattern. */
|
|
10
10
|
pattern?: AgentStatusPattern;
|
|
11
11
|
/**
|
|
12
12
|
* Sweep a highlight across the label while the agent is active. Defaults to
|
|
@@ -22,8 +22,9 @@ type AgentStatusOwnProps = {
|
|
|
22
22
|
/**
|
|
23
23
|
* `inline` sits in a line of content; `bar` is a full-width row for the
|
|
24
24
|
* top of a panel; `pill` is a glass pill for a status that floats over
|
|
25
|
-
* the page while a run goes on; once it ends the dots
|
|
26
|
-
* status colour, as in every variant. The pill does not
|
|
25
|
+
* the page while a run goes on; once it ends the dots draw a tick or a
|
|
26
|
+
* cross in the status colour, as in every variant. The pill does not
|
|
27
|
+
* position itself.
|
|
27
28
|
*/
|
|
28
29
|
variant?: 'inline' | 'bar' | 'pill';
|
|
29
30
|
/** A trailing control after the status text, such as a link that opens the run. Meant for the `pill` and `bar` variants. */
|
|
@@ -41,6 +42,8 @@ export interface AgentStatusProps extends AgentStatusOwnProps, Omit<React.Compon
|
|
|
41
42
|
*
|
|
42
43
|
* Colour carries meaning rather than decoration — the three working states are
|
|
43
44
|
* monochrome, and only `waiting`, `done` and `error` take a status colour.
|
|
45
|
+
* Those three also resolve the matrix into a glyph of their own (a prompt, a
|
|
46
|
+
* tick, a cross), so the shape says which it is before the colour does.
|
|
44
47
|
* The whole thing is one polite live region, so a screen reader hears the state
|
|
45
48
|
* change without the caller wiring anything up.
|
|
46
49
|
*/
|
|
@@ -49,7 +52,7 @@ export declare const AgentStatus: React.ForwardRefExoticComponent<AgentStatusPro
|
|
|
49
52
|
type AgentStatusMarkOwnProps = {
|
|
50
53
|
/** What the agent is doing. Drives the colour and whether the dots animate, as on AgentStatus. Defaults to `working`, unlike AgentStatus's `thinking`: the mark stands in for an icon on a control (AiButton's, a pill's), where the commonest moment it is drawn is a run under way, while the labelled AgentStatus most often opens a reply. */
|
|
51
54
|
state?: AgentStatusState;
|
|
52
|
-
/** Which choreography to run: every AgentStatus pattern, redrawn for the square grid. Defaults to `
|
|
55
|
+
/** Which choreography to run while the agent is active: every AgentStatus pattern, redrawn for the square grid. Defaults to `orbit`. `waiting` with no pattern draws its glyph instead, a prompt whose cursor breathes; `done` and `error` draw a tick and a cross whatever the pattern. */
|
|
53
56
|
pattern?: AgentStatusPattern;
|
|
54
57
|
/** Additional CSS classes */
|
|
55
58
|
className?: string;
|
|
@@ -61,8 +64,8 @@ export interface AgentStatusMarkProps extends AgentStatusMarkOwnProps, Omit<Reac
|
|
|
61
64
|
* by `--icon-size`, drawn inside a Material Symbol's live area, so it swaps
|
|
62
65
|
* with a glyph without moving or outgrowing it. Every AgentStatus pattern
|
|
63
66
|
* runs on it, redrawn for the square, in AgentStatus's cycle and colours;
|
|
64
|
-
* orbit is the default, and
|
|
65
|
-
* the first host.
|
|
67
|
+
* orbit is the default, and waiting, done and error draw AgentStatus's
|
|
68
|
+
* three glyphs. AiButton's status is the first host.
|
|
66
69
|
* Hidden from assistive technology; the host announces the state.
|
|
67
70
|
*/
|
|
68
71
|
export declare const AgentStatusMark: React.ForwardRefExoticComponent<AgentStatusMarkProps & React.RefAttributes<HTMLSpanElement>>;
|
|
@@ -11,6 +11,12 @@ const DEFAULT_LABELS = {
|
|
|
11
11
|
done: "Done",
|
|
12
12
|
error: "Failed"
|
|
13
13
|
};
|
|
14
|
+
function useArrived(state) {
|
|
15
|
+
const [initial] = useState(state);
|
|
16
|
+
const [arrived, setArrived] = useState(false);
|
|
17
|
+
if (!arrived && state !== initial) setArrived(true);
|
|
18
|
+
return arrived;
|
|
19
|
+
}
|
|
14
20
|
const ACTIVE_STATES = ["thinking", "working", "waiting"];
|
|
15
21
|
const AgentStatus = React.forwardRef(
|
|
16
22
|
({
|
|
@@ -26,6 +32,7 @@ const AgentStatus = React.forwardRef(
|
|
|
26
32
|
...rest
|
|
27
33
|
}, ref) => {
|
|
28
34
|
const baseClass = "ds-agent-status";
|
|
35
|
+
const arrived = useArrived(state);
|
|
29
36
|
const isActive = ACTIVE_STATES.includes(state);
|
|
30
37
|
const isShimmering = shimmer ?? isActive;
|
|
31
38
|
const resolvedSize = size === "sm" ? "compact" : size === "md" ? "default" : size;
|
|
@@ -47,6 +54,7 @@ const AgentStatus = React.forwardRef(
|
|
|
47
54
|
`${baseClass}--${resolvedSize}`,
|
|
48
55
|
`${baseClass}--${variant}`,
|
|
49
56
|
isActive ? `${baseClass}--animated` : "",
|
|
57
|
+
arrived ? `${baseClass}--arrived` : "",
|
|
50
58
|
className
|
|
51
59
|
].filter(Boolean).join(" ");
|
|
52
60
|
return /* @__PURE__ */ jsxs("div", { ...rest, ref, className: classes, role: "status", children: [
|
|
@@ -87,11 +95,13 @@ const MARK_DOT_COUNT = 16;
|
|
|
87
95
|
const AgentStatusMark = React.forwardRef(
|
|
88
96
|
({ state = "working", pattern, className = "", ...rest }, ref) => {
|
|
89
97
|
const baseClass = "ds-agent-status-mark";
|
|
98
|
+
const arrived = useArrived(state);
|
|
90
99
|
const classes = [
|
|
91
100
|
baseClass,
|
|
92
101
|
`${baseClass}--${state}`,
|
|
93
102
|
`${baseClass}--${pattern ?? (state === "waiting" ? "breathe" : "orbit")}`,
|
|
94
103
|
ACTIVE_STATES.includes(state) ? `${baseClass}--animated` : "",
|
|
104
|
+
arrived ? `${baseClass}--arrived` : "",
|
|
95
105
|
className
|
|
96
106
|
].filter(Boolean).join(" ");
|
|
97
107
|
return /* @__PURE__ */ jsx("span", { "aria-hidden": "true", ...rest, ref, className: classes, children: Array.from({ length: MARK_DOT_COUNT }, (_, i) => /* @__PURE__ */ jsx("span", { className: `${baseClass}__dot` }, i)) });
|
|
@@ -40,9 +40,9 @@ type AiButtonOwnProps = {
|
|
|
40
40
|
* What the agent behind the button is doing, in AgentStatus's vocabulary.
|
|
41
41
|
* The label never changes; the icon carries the state. `thinking` and
|
|
42
42
|
* `working` show AgentStatusMark and spin the ring faster, `waiting` shows
|
|
43
|
-
* the mark
|
|
44
|
-
* `error` turn the button to their status colours with the mark
|
|
45
|
-
*
|
|
43
|
+
* the mark's prompt glyph in the warning colour with the ring at rest, and `done` and
|
|
44
|
+
* `error` turn the button to their status colours with the mark drawing a
|
|
45
|
+
* tick or a cross in the status colour, then return to the resting look after a
|
|
46
46
|
* beat. The button stays clickable throughout, unlike Button's
|
|
47
47
|
* `loading`, so a click can open the conversation to watch the work.
|
|
48
48
|
*/
|
|
@@ -65,13 +65,17 @@
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
/* ============================================
|
|
68
|
-
AI GLOW —
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
AI GLOW — the `aiGlow` prop
|
|
69
|
+
The AI gradient ring in place of the shell's border: AiButton's signal
|
|
70
|
+
that a model is at work. By default (`aiGlow="streaming"`) a composer
|
|
71
|
+
wears it only while a response streams (the working rules below): focus
|
|
72
|
+
keeps the plain selected border, so the ring means work alone. `aiGlow`
|
|
73
|
+
as `true` adds the focus form, `--ai-glow-focus`: while focused, the
|
|
74
|
+
plain selected border stands down and the ring takes its place. `false`
|
|
75
|
+
leaves both classes off.
|
|
72
76
|
============================================ */
|
|
73
77
|
|
|
74
|
-
.ds-composer--ai-glow:focus-within {
|
|
78
|
+
.ds-composer--ai-glow-focus:focus-within {
|
|
75
79
|
border-color: transparent;
|
|
76
80
|
}
|
|
77
81
|
|
|
@@ -154,13 +158,13 @@
|
|
|
154
158
|
the entrance pace and the ring fades up a --motion-duration-fast beat
|
|
155
159
|
behind it — the transition here (the destination state's) governs the
|
|
156
160
|
way in; the resting rules above govern the quick way back. */
|
|
157
|
-
.ds-composer--ai-glow:focus-within::before {
|
|
161
|
+
.ds-composer--ai-glow-focus:focus-within::before {
|
|
158
162
|
opacity: 1;
|
|
159
163
|
transition: opacity var(--motion-duration-slower) var(--motion-ease-entrance) var(--motion-duration-fast);
|
|
160
164
|
animation-play-state: running;
|
|
161
165
|
}
|
|
162
166
|
|
|
163
|
-
.ds-composer--ai-glow:focus-within::after {
|
|
167
|
+
.ds-composer--ai-glow-focus:focus-within::after {
|
|
164
168
|
opacity: 0.3;
|
|
165
169
|
transform: none;
|
|
166
170
|
transition:
|
|
@@ -198,8 +202,9 @@
|
|
|
198
202
|
|
|
199
203
|
/* Working: while a response streams, the ring stays lit and keeps turning
|
|
200
204
|
whether or not the field holds focus — the visible half of the `streaming`
|
|
201
|
-
contract
|
|
202
|
-
|
|
205
|
+
contract, and the only time a composer on the default wears the ring at
|
|
206
|
+
all. The pairing is defined in design.md's Composer section; with
|
|
207
|
+
`aiGlow` off, streaming changes nothing here. */
|
|
203
208
|
.ds-composer--ai-glow.ds-composer--streaming {
|
|
204
209
|
border-color: transparent;
|
|
205
210
|
}
|
|
@@ -26,8 +26,8 @@ type ComposerOwnProps = {
|
|
|
26
26
|
onSubmit?: (value: string) => void;
|
|
27
27
|
/**
|
|
28
28
|
* A response is streaming: the send button becomes a stop button, submit
|
|
29
|
-
* is blocked, and Enter is inert.
|
|
30
|
-
*
|
|
29
|
+
* is blocked, and Enter is inert. The gradient ring is lit and turning
|
|
30
|
+
* while this is true, unless `aiGlow` is `false`.
|
|
31
31
|
*/
|
|
32
32
|
streaming?: boolean;
|
|
33
33
|
/** Fires when the stop button is pressed while `streaming`. */
|
|
@@ -39,13 +39,15 @@ type ComposerOwnProps = {
|
|
|
39
39
|
/** Growth cap in text rows before the textarea scrolls internally. Defaults to 12 in a chat composer, or 3 in the mini composer. */
|
|
40
40
|
maxRows?: number;
|
|
41
41
|
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
42
|
+
* AiButton's slowly rotating gradient ring and glow on the shell, the
|
|
43
|
+
* system's "a model is at work here" signal. `'streaming'`, the default,
|
|
44
|
+
* lights it only while `streaming` is true and keeps the plain selected
|
|
45
|
+
* border on focus, so the ring means the agent is working and nothing
|
|
46
|
+
* else, and a resting composer never competes with a reply's live status.
|
|
47
|
+
* `true` also lights it whenever the field is focused, in place of the
|
|
48
|
+
* selected border. `false` never lights it.
|
|
47
49
|
*/
|
|
48
|
-
aiGlow?: boolean;
|
|
50
|
+
aiGlow?: boolean | 'streaming';
|
|
49
51
|
/**
|
|
50
52
|
* Contextual note rendered as a full-width, non-interactive chip — the
|
|
51
53
|
* "what the model is looking at" line a chat host pins over the message
|
|
@@ -37,7 +37,7 @@ const Composer = React.forwardRef(
|
|
|
37
37
|
size = "default",
|
|
38
38
|
inline = false,
|
|
39
39
|
maxRows = inline === true ? 3 : 12,
|
|
40
|
-
aiGlow =
|
|
40
|
+
aiGlow = "streaming",
|
|
41
41
|
context,
|
|
42
42
|
contextIcon,
|
|
43
43
|
contextPlacement = "inside",
|
|
@@ -366,6 +366,7 @@ const Composer = React.forwardRef(
|
|
|
366
366
|
const classes = [
|
|
367
367
|
baseClass,
|
|
368
368
|
aiGlow ? `${baseClass}--ai-glow` : "",
|
|
369
|
+
aiGlow === true ? `${baseClass}--ai-glow-focus` : "",
|
|
369
370
|
inline === true && size === "compact" ? `${baseClass}--compact` : "",
|
|
370
371
|
inline ? `${baseClass}--inline` : "",
|
|
371
372
|
inline === "chat" ? `${baseClass}--inline-chat` : "",
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
padding: var(--padding-400) var(--ds-chat-card-inset) var(--padding-200);
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
/* Without media the body opens the card, at the chat cards'
|
|
89
|
+
/* Without media the body opens the card, at the chat cards' edge. */
|
|
90
90
|
.ds-message-card__body:first-child {
|
|
91
91
|
padding-top: var(--ds-chat-card-edge);
|
|
92
92
|
}
|
|
@@ -126,7 +126,7 @@
|
|
|
126
126
|
|
|
127
127
|
.ds-source-trail__list {
|
|
128
128
|
margin: 0;
|
|
129
|
-
/*
|
|
129
|
+
/* The recipe's edge above and below, every chat card's edge inset. */
|
|
130
130
|
padding: var(--ds-chat-card-edge) var(--ds-chat-card-inset);
|
|
131
131
|
border-top: var(--border-025) solid var(--color-divider);
|
|
132
132
|
list-style: none;
|
|
@@ -278,8 +278,8 @@
|
|
|
278
278
|
.ds-tool-call__content > .ds-code-block .ds-code-block__header {
|
|
279
279
|
order: 1;
|
|
280
280
|
justify-content: flex-start;
|
|
281
|
-
/*
|
|
282
|
-
margin-block-start: var(--gap-
|
|
281
|
+
/* A block gap off the code, the chat cards' seam. */
|
|
282
|
+
margin-block-start: var(--ds-chat-card-gap-block);
|
|
283
283
|
padding: 0;
|
|
284
284
|
border-bottom: none;
|
|
285
285
|
}
|
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
============================================ */
|
|
6
6
|
|
|
7
7
|
/* Base — the card chrome itself comes from ds-chart. In a chat it is one
|
|
8
|
-
of the chat cards, so it takes their padding, title and rhythm:
|
|
9
|
-
above and below inside
|
|
10
|
-
|
|
8
|
+
of the chat cards, so it takes their padding, title and rhythm: the
|
|
9
|
+
recipe's edge above and below inside its inset at the sides, a
|
|
10
|
+
title-body title with its subtitle under it, and a block gap between
|
|
11
|
+
blocks. */
|
|
11
12
|
.ds-usage-card.ds-chart:not(.ds-chart--bare) {
|
|
12
13
|
padding: var(--ds-chat-card-edge) var(--ds-chat-card-inset);
|
|
13
14
|
border: var(--ds-chat-card-border);
|
package/package.json
CHANGED