rift-ds 1.33.0 → 1.35.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 +3 -3
- package/behaviors/chat-card.css +11 -6
- package/behaviors/locale.d.ts +9 -0
- package/behaviors/locale.js +2 -0
- package/bin/templates/blocks/app/dashboard/page.tsx +1 -1
- package/bin/templates/blocks/components/blocks/AppShell.module.css +10 -6
- package/chat/AssistantTurn.d.ts +2 -0
- package/chat/AssistantTurn.js +18 -7
- package/chat/ChatProvider.js +14 -0
- package/chat/ChatTabs.js +1 -1
- package/chat/ChatWidget.css +10 -0
- package/chat/ChatWidget.d.ts +9 -5
- package/chat/ChatWidget.js +7 -4
- package/chat/DemoWelcome.js +2 -2
- package/chat/FollowupSuggestions.js +1 -1
- 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/ActionBar/ActionBar.css +78 -0
- package/components/ActionBar/ActionBar.d.ts +40 -0
- package/components/ActionBar/ActionBar.js +29 -0
- 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/AiButton/AiButton.js +1 -1
- package/components/Alert/Alert.css +16 -0
- package/components/Alert/Alert.d.ts +2 -2
- package/components/Alert/Alert.js +3 -1
- package/components/AppSidebar/AppSidebar.css +140 -4
- package/components/AppSidebar/AppSidebar.d.ts +12 -0
- package/components/AppSidebar/AppSidebar.js +7 -3
- package/components/ChatThread/ChatThread.d.ts +5 -1
- package/components/ChatThread/ChatThread.js +1 -1
- package/components/Composer/Composer.css +14 -9
- package/components/Composer/Composer.d.ts +10 -8
- package/components/Composer/Composer.js +2 -1
- package/components/ContextMenu/ContextMenu.d.ts +5 -1
- package/components/ContextMenu/ContextMenu.js +2 -1
- package/components/ContributionGraph/ContributionGraph.d.ts +7 -1
- package/components/ContributionGraph/ContributionGraph.js +4 -18
- package/components/ContributionGraph/weeks.d.ts +8 -0
- package/components/ContributionGraph/weeks.js +25 -0
- package/components/DataTable/DataTable.js +1 -1
- package/components/DocumentChip/DocumentChip.js +1 -1
- package/components/EntitySwitcher/EntitySwitcher.css +11 -3
- package/components/EntitySwitcher/EntitySwitcher.js +1 -1
- package/components/EventCalendar/EventCalendar.css +152 -0
- package/components/EventCalendar/EventCalendar.d.ts +50 -4
- package/components/EventCalendar/EventCalendar.js +154 -23
- package/components/EventCalendar/eventTime.d.ts +31 -0
- package/components/EventCalendar/eventTime.js +42 -0
- package/components/FileInput/FileInput.d.ts +12 -4
- package/components/FileInput/FileInput.js +27 -4
- package/components/Input/Input.css +30 -0
- package/components/Input/Input.d.ts +8 -0
- package/components/Input/Input.js +3 -0
- package/components/MessageCard/MessageCard.css +1 -1
- package/components/Popover/Popover.d.ts +5 -1
- package/components/Popover/Popover.js +3 -1
- package/components/ProgressBar/ProgressBar.d.ts +5 -1
- package/components/ProgressBar/ProgressBar.js +1 -1
- package/components/PromptSuggestions/PromptSuggestions.d.ts +5 -1
- package/components/PromptSuggestions/PromptSuggestions.js +1 -1
- package/components/ResourceTimeline/ResourceTimeline.js +2 -2
- package/components/SegmentedControl/SegmentedControl.css +120 -3
- package/components/SegmentedControl/SegmentedControl.d.ts +9 -0
- package/components/SegmentedControl/SegmentedControl.js +11 -1
- package/components/ShaderScene/ShaderScene.d.ts +3 -3
- package/components/ShaderScene/scenes.d.ts +17 -0
- package/components/ShaderScene/scenes.js +175 -1
- package/components/SourceTrail/SourceTrail.css +1 -1
- package/components/Stat/Stat.css +12 -0
- package/components/Stat/Stat.d.ts +5 -0
- package/components/Stat/Stat.js +9 -3
- package/components/TableToolbar/TableToolbar.js +2 -2
- package/components/ThemeToggle/ThemeToggle.d.ts +1 -1
- package/components/ThreadTabs/ThreadTabs.d.ts +5 -1
- package/components/ThreadTabs/ThreadTabs.js +2 -1
- package/components/ToggleGroup/ToggleGroup.d.ts +5 -1
- package/components/ToolCall/ToolCall.css +2 -2
- package/components/UsageCard/UsageCard.css +4 -3
- package/components/registry.json +21 -4
- package/components/registry.json.d.ts +21 -4
- package/components/registry.json.js +1 -1
- package/index.d.ts +1 -0
- package/index.js +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ An open source React design system built for AI products and coding agents: comp
|
|
|
13
13
|
|
|
14
14
|
## Why Rift DS
|
|
15
15
|
|
|
16
|
-
- **<!-- component-count -->
|
|
16
|
+
- **<!-- component-count -->195<!-- /component-count --> components.** Buttons, forms and tables through to charts, navigation and overlays, each typed and documented with live examples. Every one forwards a ref and your own attributes to its element, state you can own works controlled or uncontrolled (a modal opens when your app says so, by design), and every word a component writes has a prop you can localise. The build checks the first two on every component, and the words wherever they sit in markup. React and React DOM are the only required peer dependencies.
|
|
17
17
|
- **A matching <!-- figma-kit-link -->[Figma kit](https://www.figma.com/community/file/1701820123445795117)<!-- /figma-kit-link -->.** Every component has a page in it, with a sticker sheet of its states, built on variables named after the same tokens. Duplicate it from the Figma Community to design with the same system.
|
|
18
18
|
- **AI patterns, the whole chat and templates, ready to use.** Composer, streaming chat thread, tool calls, reasoning and thread panel are in the box, the complete AI chat ships assembled as one widget that one command scaffolds, and the docs site has complete template screens built from them.
|
|
19
19
|
- **Fully themeable.** The shipped themes are complete looks to start from, each in light and dark. One `data-brand` attribute applies a theme, and a few CSS overrides make your own.
|
|
@@ -112,13 +112,13 @@ import 'rift-ds/tokens/presets/presets.css';
|
|
|
112
112
|
|
|
113
113
|
## Components
|
|
114
114
|
|
|
115
|
-
<!-- component-count -->
|
|
115
|
+
<!-- component-count -->195<!-- /component-count --> components, including a chat set for AI products (Chat thread, Composer, Tool call, Reasoning, Thread panel) and Shader field, a WebGL2 ambient background whose light sources read your colour tokens at runtime, so it re-themes with everything else. Details and live examples are on the [docs site](https://rift-ds.com/components).
|
|
116
116
|
|
|
117
117
|
<details>
|
|
118
118
|
<summary>The full list</summary>
|
|
119
119
|
|
|
120
120
|
<!-- component-list:start -->
|
|
121
|
-
Accordion · Action card · Action readout · Agent plan · Agent rail · Agent status · AI button · Alert · Alert dialog · Anchor nav · Animated number · App layout · App sidebar · Area chart · Artifact card · Artifact panel · Attachment drop zone · Attachment group · Attachment tile · Attachment viewer · Avatar · Avatar group · Back to top · Badge · Banner · Bar chart · Bento tile · Bento tile art · Bottom nav · Breadcrumb · Button · Button group · Card · Card stack · Carousel · Chat header · Chat marker · Chat message · Chat thread · Checkbox · Checklist · Chip · Code block · Code diff · Colour picker · Combo chart · Combobox · Command palette · Command palette trigger · Composer · Contact card · Context menu · Contribution graph · Copy button · Currency input · Data table · Date input · Date picker · Date range picker · Deadline · Decision row · Description list · Dialog · Divider · Document chip · Document viewer · Drawer · Dropdown · Dropdown menu · Empty state · Entity card · Entity switcher · Error summary · Event calendar · Field · Figure · File input · File row · Filter bar · Form section · Funnel chart · Gantt chart · Gauge · Globe · Grid · Heading · Hover card · Icon · Icon button · Image compare · Input · Inspector colour picker · Inspector dropdown · Inspector input · Inspector section · Inspector segments · Inspector slider · Inspector toggle switch · Instructions · Interrupt card · Kbd · Legend tile · Lightbox · Line chart · Link · Link list · List · Map callout · Map legend · Masked input · Mega menu · Mention · Menu bar · Message actions · Message card · Meter · Model picker · Nav · Nav list · Notification centre · Number input · Org chart · Page header · Pagination · Panel · Pie chart · Pin input · Pixel avatar · Popover · Progress bar · Progressive blur · Prompt suggestions · Prose · Question card · Quote · Radar chart · Radial chart · Radio button · Rating · Reasoning · Resource timeline · Rich dropdown · Scatter chart · Section title · Segmented control · Selection card · Shader field · Shader scene · Sidebar panel · Signature pad · Site footer · Site header · Site layout · Skeleton · Slider · Source chip · Source trail · Sparkline · Spinner · Split button · Split pane · Stack · Stacked bar chart · Stat · Status dot · Stepper · Streaming text · Swatch · Table · Table toolbar · Tabs · Tag input · Text · Textarea · Theme picker · Theme toggle · Thread panel · Thread tabs · Time picker · Timeline · Toast · Toggle group · Toggle switch · Tool call · Toolbar · Tooltip · Top app bar · Tree view · Treemap · Usage card · Waveform · Widget · Wizard · World map
|
|
121
|
+
Accordion · Action bar · Action card · Action readout · Agent plan · Agent rail · Agent status · AI button · Alert · Alert dialog · Anchor nav · Animated number · App layout · App sidebar · Area chart · Artifact card · Artifact panel · Attachment drop zone · Attachment group · Attachment tile · Attachment viewer · Avatar · Avatar group · Back to top · Badge · Banner · Bar chart · Bento tile · Bento tile art · Bottom nav · Breadcrumb · Button · Button group · Card · Card stack · Carousel · Chat header · Chat marker · Chat message · Chat thread · Checkbox · Checklist · Chip · Code block · Code diff · Colour picker · Combo chart · Combobox · Command palette · Command palette trigger · Composer · Contact card · Context menu · Contribution graph · Copy button · Currency input · Data table · Date input · Date picker · Date range picker · Deadline · Decision row · Description list · Dialog · Divider · Document chip · Document viewer · Drawer · Dropdown · Dropdown menu · Empty state · Entity card · Entity switcher · Error summary · Event calendar · Field · Figure · File input · File row · Filter bar · Form section · Funnel chart · Gantt chart · Gauge · Globe · Grid · Heading · Hover card · Icon · Icon button · Image compare · Input · Inspector colour picker · Inspector dropdown · Inspector input · Inspector section · Inspector segments · Inspector slider · Inspector toggle switch · Instructions · Interrupt card · Kbd · Legend tile · Lightbox · Line chart · Link · Link list · List · Map callout · Map legend · Masked input · Mega menu · Mention · Menu bar · Message actions · Message card · Meter · Model picker · Nav · Nav list · Notification centre · Number input · Org chart · Page header · Pagination · Panel · Pie chart · Pin input · Pixel avatar · Popover · Progress bar · Progressive blur · Prompt suggestions · Prose · Question card · Quote · Radar chart · Radial chart · Radio button · Rating · Reasoning · Resource timeline · Rich dropdown · Scatter chart · Section title · Segmented control · Selection card · Shader field · Shader scene · Sidebar panel · Signature pad · Site footer · Site header · Site layout · Skeleton · Slider · Source chip · Source trail · Sparkline · Spinner · Split button · Split pane · Stack · Stacked bar chart · Stat · Status dot · Stepper · Streaming text · Swatch · Table · Table toolbar · Tabs · Tag input · Text · Textarea · Theme picker · Theme toggle · Thread panel · Thread tabs · Time picker · Timeline · Toast · Toggle group · Toggle switch · Tool call · Toolbar · Tooltip · Top app bar · Tree view · Treemap · Usage card · Waveform · Widget · Wizard · World map
|
|
122
122
|
<!-- component-list:end -->
|
|
123
123
|
|
|
124
124
|
</details>
|
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/behaviors/locale.d.ts
CHANGED
|
@@ -38,6 +38,15 @@ export declare function weekdayHeadersIn(locale: string): string[];
|
|
|
38
38
|
/** Whether `locale` is written in English, the language every built-in label defaults to. */
|
|
39
39
|
export declare function isEnglish(locale: string): boolean;
|
|
40
40
|
/** Whether `locale` writes times on a 12-hour clock (en-US) rather than a 24-hour one (en-GB, de-DE). */
|
|
41
|
+
/**
|
|
42
|
+
* Formatted date or time text with its spaces made plain. ICU writes thin
|
|
43
|
+
* and narrow no-break spaces around a range's dash and before a day period
|
|
44
|
+
* ("November 16 – 22", "1:40 PM"), and Node and browsers ship different ICU
|
|
45
|
+
* versions, so one call can print different spaces on the server and in the
|
|
46
|
+
* browser and break hydration. Every range a component prints goes through
|
|
47
|
+
* this.
|
|
48
|
+
*/
|
|
49
|
+
export declare const plainSpaces: (text: string) => string;
|
|
41
50
|
export declare function uses12HourClock(locale: string): boolean;
|
|
42
51
|
/**
|
|
43
52
|
* A number as `locale` writes it, grouped and with its own decimal mark:
|
package/behaviors/locale.js
CHANGED
|
@@ -42,6 +42,7 @@ function isEnglish(locale) {
|
|
|
42
42
|
return false;
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
+
const plainSpaces = (text) => text.replace(/[\u00A0\u2009\u202F]/g, " ");
|
|
45
46
|
function uses12HourClock(locale) {
|
|
46
47
|
const cycle = new Intl.DateTimeFormat(locale, { hour: "numeric" }).resolvedOptions().hourCycle;
|
|
47
48
|
return cycle === "h11" || cycle === "h12";
|
|
@@ -83,6 +84,7 @@ export {
|
|
|
83
84
|
formatNumber,
|
|
84
85
|
formatPercent,
|
|
85
86
|
isEnglish,
|
|
87
|
+
plainSpaces,
|
|
86
88
|
rotateWeek,
|
|
87
89
|
uses12HourClock,
|
|
88
90
|
weekStartOf,
|
|
@@ -101,7 +101,7 @@ export default function DashboardPage() {
|
|
|
101
101
|
<span>{row.name}</span>
|
|
102
102
|
<span className={styles.muted}>{row.done}%</span>
|
|
103
103
|
</div>
|
|
104
|
-
<ProgressBar value={row.done} size="compact"
|
|
104
|
+
<ProgressBar value={row.done} size="compact" aria-label={`${row.name} progress`} />
|
|
105
105
|
</li>
|
|
106
106
|
))}
|
|
107
107
|
</ul>
|
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
--ds-sidebar-float-inset: var(--shell-inset);
|
|
12
12
|
/* The rail's width, which the main column clears. */
|
|
13
13
|
--shell-rail: 64px;
|
|
14
|
+
/* The content's side gutter, which the top bar's fill and blur reach
|
|
15
|
+
across too, so nothing scrolls past them at the surface's corners. */
|
|
16
|
+
--shell-gutter: var(--padding-1000);
|
|
14
17
|
|
|
15
18
|
display: flex;
|
|
16
19
|
min-width: 0;
|
|
@@ -79,7 +82,7 @@
|
|
|
79
82
|
display: flex;
|
|
80
83
|
flex-direction: column;
|
|
81
84
|
gap: var(--gap-500);
|
|
82
|
-
padding: var(--shell-inset) var(--
|
|
85
|
+
padding: var(--shell-inset) var(--shell-gutter) var(--padding-1500);
|
|
83
86
|
}
|
|
84
87
|
|
|
85
88
|
/* ---------------------------------------------------------- top bar */
|
|
@@ -106,7 +109,7 @@
|
|
|
106
109
|
position: absolute;
|
|
107
110
|
top: calc(-1 * var(--shell-inset));
|
|
108
111
|
bottom: 0;
|
|
109
|
-
inset-inline: calc(-1 * var(--
|
|
112
|
+
inset-inline: calc(-1 * var(--shell-gutter));
|
|
110
113
|
z-index: -1;
|
|
111
114
|
background: linear-gradient(to bottom, var(--ds-shell-surface) var(--shell-inset), transparent);
|
|
112
115
|
pointer-events: none;
|
|
@@ -122,7 +125,7 @@
|
|
|
122
125
|
position: absolute;
|
|
123
126
|
top: calc(-1 * var(--shell-inset));
|
|
124
127
|
bottom: calc(-1 * var(--gap-1000));
|
|
125
|
-
inset-inline: calc(-1 * var(--
|
|
128
|
+
inset-inline: calc(-1 * var(--shell-gutter));
|
|
126
129
|
height: auto;
|
|
127
130
|
z-index: -1;
|
|
128
131
|
opacity: 0;
|
|
@@ -184,8 +187,8 @@
|
|
|
184
187
|
|
|
185
188
|
/* Laptop: a tighter side gutter. */
|
|
186
189
|
@media (max-width: 1279px) {
|
|
187
|
-
.
|
|
188
|
-
|
|
190
|
+
.shell {
|
|
191
|
+
--shell-gutter: var(--padding-500);
|
|
189
192
|
}
|
|
190
193
|
}
|
|
191
194
|
|
|
@@ -194,6 +197,7 @@
|
|
|
194
197
|
@media (max-width: 768px) {
|
|
195
198
|
.shell {
|
|
196
199
|
--shell-inset: var(--padding-400);
|
|
200
|
+
--shell-gutter: var(--shell-inset);
|
|
197
201
|
}
|
|
198
202
|
|
|
199
203
|
.shell .main,
|
|
@@ -215,7 +219,7 @@
|
|
|
215
219
|
}
|
|
216
220
|
|
|
217
221
|
.content {
|
|
218
|
-
padding: var(--shell-inset) var(--shell-
|
|
222
|
+
padding: var(--shell-inset) var(--shell-gutter) var(--padding-1000);
|
|
219
223
|
}
|
|
220
224
|
|
|
221
225
|
/* Clear the menu button (40px) at the bar's left end. */
|
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/ChatTabs.js
CHANGED
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`. */
|
|
@@ -262,8 +266,8 @@ export interface ChatWidgetProps {
|
|
|
262
266
|
onAttachmentDownload?: AttachmentGroupProps['onDownload'];
|
|
263
267
|
/** The words of the files on a sent message, over AttachmentGroup's English defaults: the list's name ("Attachments"), the overflow buttons ("Show 3 more", "Show fewer"), the tiles' status lines (`attachmentTileLabels`) and the viewer a pressed file opens in (`attachmentViewerLabels`). */
|
|
264
268
|
attachmentGroupLabels?: Pick<AttachmentGroupProps, 'label' | 'showMoreLabel' | 'showLessLabel' | 'attachmentTileLabels' | 'attachmentViewerLabels'>;
|
|
265
|
-
/** The conversation's names, over ChatThread's English defaults: the scrolling region ("Conversation") and the scroll-to-latest control ("Scroll to the latest message"). */
|
|
266
|
-
chatThreadLabels?: Pick<ChatThreadProps, 'ariaLabel' | 'jumpLabel'>;
|
|
269
|
+
/** The conversation's names, over ChatThread's English defaults: the scrolling region ("Conversation", as `aria-label`; the deprecated `ariaLabel` still works) and the scroll-to-latest control ("Scroll to the latest message"). */
|
|
270
|
+
chatThreadLabels?: Pick<ChatThreadProps, 'aria-label' | 'ariaLabel' | 'jumpLabel'>;
|
|
267
271
|
/** The model picker's words, over ModelPicker's English defaults: the open list's name ("Model") and the trigger's text when nothing is selected ("Choose a model"). The trigger's own name is `modelPickerLabel`. */
|
|
268
272
|
modelPickerLabels?: Pick<ModelPickerProps, 'listLabel' | 'placeholder'>;
|
|
269
273
|
/** The artifact panel's words, over ArtifactPanel's English defaults: the view switch ("Preview", "Code", "Artifact view"), the expand and close buttons ("Expand the artifact", "Collapse the artifact", "Close the artifact") and the code view's CodeBlock (`codeBlockLabels`). */
|
|
@@ -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,
|
|
@@ -439,7 +442,7 @@ function ChatWidget({
|
|
|
439
442
|
PromptSuggestions,
|
|
440
443
|
{
|
|
441
444
|
layout: "stack",
|
|
442
|
-
|
|
445
|
+
"aria-label": startersLabel,
|
|
443
446
|
pending: startersThinking,
|
|
444
447
|
entrance: startersEntrance,
|
|
445
448
|
suggestions: starters,
|
|
@@ -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/DemoWelcome.js
CHANGED
|
@@ -129,10 +129,10 @@ function DemoWelcome({
|
|
|
129
129
|
onAsk
|
|
130
130
|
}) {
|
|
131
131
|
if (variant === "links") {
|
|
132
|
-
return /* @__PURE__ */ jsx(PromptSuggestions, { layout: "tiles",
|
|
132
|
+
return /* @__PURE__ */ jsx(PromptSuggestions, { layout: "tiles", "aria-label": "Places to start", suggestions: LINKS, onValueChange: onAsk });
|
|
133
133
|
}
|
|
134
134
|
if (variant === "cards") {
|
|
135
|
-
return /* @__PURE__ */ jsx(PromptSuggestions, { layout: "cards",
|
|
135
|
+
return /* @__PURE__ */ jsx(PromptSuggestions, { layout: "cards", "aria-label": "Things to ask", suggestions: CARDS, onValueChange: onAsk });
|
|
136
136
|
}
|
|
137
137
|
if (variant === "dashboard") return /* @__PURE__ */ jsx(DemoBoard, { onAsk });
|
|
138
138
|
return null;
|
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) {
|