@saar-ai/web-widget 0.10.0 → 0.12.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/dist/adopt-stylesheet.d.ts +11 -0
- package/dist/adopt-stylesheet.d.ts.map +1 -0
- package/dist/chunks/{host-widget-BtiYIMwb.js → host-widget-Cc0KjJwZ.js} +2366 -280
- package/dist/concierge-shell.css +2 -0
- package/dist/concierge-state.d.ts +234 -0
- package/dist/concierge-state.d.ts.map +1 -0
- package/dist/dock/dock-renderer.d.ts +3 -0
- package/dist/dock/dock-renderer.d.ts.map +1 -0
- package/dist/dock/dock-row.d.ts +3 -23
- package/dist/dock/dock-row.d.ts.map +1 -1
- package/dist/dock/dock-state.d.ts +34 -174
- package/dist/dock/dock-state.d.ts.map +1 -1
- package/dist/generated/concierge-shell-css.d.ts +2 -0
- package/dist/generated/concierge-shell-css.d.ts.map +1 -0
- package/dist/generated/widget-css.d.ts.map +1 -1
- package/dist/handoff-initials.d.ts +34 -0
- package/dist/handoff-initials.d.ts.map +1 -0
- package/dist/host-widget.d.ts +24 -1
- package/dist/host-widget.d.ts.map +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +35 -138
- package/dist/mount.d.ts +4 -5
- package/dist/mount.d.ts.map +1 -1
- package/dist/next/index.js +1 -1
- package/dist/renderers.d.ts +3 -0
- package/dist/renderers.d.ts.map +1 -0
- package/dist/styles.d.ts +1 -0
- package/dist/styles.d.ts.map +1 -1
- package/dist/voice-widget.d.ts +93 -3
- package/dist/voice-widget.d.ts.map +1 -1
- package/dist/widget/concierge-launcher.d.ts +68 -0
- package/dist/widget/concierge-launcher.d.ts.map +1 -0
- package/dist/widget/concierge-shell.d.ts +299 -0
- package/dist/widget/concierge-shell.d.ts.map +1 -0
- package/dist/widget/position.d.ts +65 -0
- package/dist/widget/position.d.ts.map +1 -0
- package/dist/widget/shell-renderer.d.ts +3 -0
- package/dist/widget/shell-renderer.d.ts.map +1 -0
- package/dist/widget/transcript-geometry.d.ts +220 -0
- package/dist/widget/transcript-geometry.d.ts.map +1 -0
- package/dist/widget/widget-view.d.ts +138 -0
- package/dist/widget/widget-view.d.ts.map +1 -0
- package/dist/widget.css +1 -1
- package/package.json +1 -1
- package/src/styles/brand.css +51 -0
- package/src/styles/concierge-shell-entry.css +55 -0
- package/src/styles/concierge.css +9 -38
- package/src/styles/widget-entry.css +39 -1
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ConversationView } from '../voice-widget.js';
|
|
2
|
+
export declare function ShellRenderer({ turns, showMic, callPhase, micOpen, onToggleMic, onEndCall, statusKind, statusLine, escalated, operatorName, humanTyping, composing, channel, draft, onDraftChange, submit, attaching, onAttach, attachInput, transcript, extras, messages, skinStyle, avatar, attribution, voice: derivedVoice, dock, }: ConversationView): import("react").JSX.Element;
|
|
3
|
+
//# sourceMappingURL=shell-renderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shell-renderer.d.ts","sourceRoot":"","sources":["../../src/widget/shell-renderer.tsx"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAQ3D,wBAAgB,aAAa,CAAC,EAC5B,KAAK,EACL,OAAO,EACP,SAAS,EACT,OAAO,EACP,WAAW,EACX,SAAS,EACT,UAAU,EACV,UAAU,EACV,SAAS,EACT,YAAY,EACZ,WAAW,EACX,SAAS,EACT,OAAO,EACP,KAAK,EACL,aAAa,EACb,MAAM,EACN,SAAS,EACT,QAAQ,EACR,WAAW,EACX,UAAU,EACV,MAAM,EACN,QAAQ,EACR,SAAS,EACT,MAAM,EACN,WAAW,EACX,KAAK,EAAE,YAAY,EACnB,IAAI,GACL,EAAE,gBAAgB,+BAoPlB"}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PANEL GEOMETRY — where the conversation's first row sits, as a FRACTION of
|
|
3
|
+
* the panel's height, and what that costs horizontally.
|
|
4
|
+
*
|
|
5
|
+
* Four CSS length expressions and the arithmetic behind them, used by
|
|
6
|
+
* `concierge-shell.tsx`'s `transcriptEdgeFade`. Their own module, and NOT
|
|
7
|
+
* re-exported from `index.ts`: `concierge-shell.geometry.test.tsx` has to read
|
|
8
|
+
* the exact strings the component ships (jsdom's CSS serializer mangles a
|
|
9
|
+
* `max()` containing a subtraction, so reading them back off a rendered element
|
|
10
|
+
* tests jsdom rather than this widget), while the package's public API stays
|
|
11
|
+
* the components themselves.
|
|
12
|
+
*
|
|
13
|
+
* One ratio ties the four lengths together, and it is the whole
|
|
14
|
+
* repair for a bug that shipped: the panel is an ellipse (`rounded-full` on a
|
|
15
|
+
* `w x 1.6w` box), so how much width it offers depends entirely on how far down
|
|
16
|
+
* you are. The clearances below scaled with `cqh` while the transcript's
|
|
17
|
+
* horizontal inset was a fixed 8px tuned for the oval's wide middle, so the
|
|
18
|
+
* taller the panel got the HIGHER the first message sat proportionally — into a
|
|
19
|
+
* narrower part of the curve, with no matching inset. Measured live in
|
|
20
|
+
* Storybook, first agent bubble's top-left corner against the curve at its own
|
|
21
|
+
* top edge: 14px inside the ellipse at a 582px panel, 37px at 720px, 62px at
|
|
22
|
+
* 920px (the 2000x1150 desktop it was reported on). `overflow-clip` on the
|
|
23
|
+
* surface then cut exactly that much off the bubble.
|
|
24
|
+
*
|
|
25
|
+
* 0.1924 is not chosen, it is READ OFF the short panel: 112px (the tuned
|
|
26
|
+
* clearance, see {@link TRANSCRIPT_FADE_TOP_LEN}) over 582px (the panel a
|
|
27
|
+
* 375x812 phone renders) is 0.19244. Holding that ratio at every size is what
|
|
28
|
+
* makes the geometry scale-invariant — every panel then presents the first row
|
|
29
|
+
* at the same point on the same curve, and ONE horizontal inset serves all of
|
|
30
|
+
* them ({@link TRANSCRIPT_INSET_X}). Expressed as `19.24cqh` in the lengths
|
|
31
|
+
* below; `cqh` is the panel's own height, via `[container-type:size]` on the
|
|
32
|
+
* panel div (verified live: `14cqh` resolved to 128.8px on a 920px panel).
|
|
33
|
+
*
|
|
34
|
+
* Not a JS constant that gets multiplied out — the panel's height is never
|
|
35
|
+
* known to JS, only to CSS, which is why every length here is an expression.
|
|
36
|
+
*/
|
|
37
|
+
/**
|
|
38
|
+
* Top ramp when the transcript starts at the panel's top, under the floating
|
|
39
|
+
* orb — it has to span the orb, so a message is gone before it reaches it
|
|
40
|
+
* rather than sliding out from behind it half-visible.
|
|
41
|
+
*
|
|
42
|
+
* A CSS length EXPRESSION, not a bare number, since the aspect-ratio panel
|
|
43
|
+
* (`w-[min(97vw,50dvh)]` + `aspect-[5/8]`) ranges from ~582px tall (mobile,
|
|
44
|
+
* width-bound) to 800px+ (desktop, height-bound) — a fixed 112px clearance
|
|
45
|
+
* tuned for the OLD fixed-520px panel left too little air under the orb on a
|
|
46
|
+
* tall one and too much on a short one. `max(112px, 19.24cqh)` is a floor, not
|
|
47
|
+
* a fixed value: it stays exactly 112px (today's tuned figure) on a short
|
|
48
|
+
* panel, where 19.24cqh would fall below it, and grows with `cqh` — the query
|
|
49
|
+
* container's own height, established by `[container-type:size]` on the
|
|
50
|
+
* panel div below — once the panel is tall enough that 19.24% of it exceeds
|
|
51
|
+
* 112px. `cqh` rather than `dvh` specifically: the panel's real rendered
|
|
52
|
+
* height, not the viewport's, since the panel does not always fill the
|
|
53
|
+
* viewport (mobile: width-bound, height is `w / (8/5)`, shorter than 100dvh).
|
|
54
|
+
*
|
|
55
|
+
* 19.24, not the 14 this shipped with: 14cqh gave a TALL panel proportionally
|
|
56
|
+
* LESS clearance than the 112px floor gives a short one (14% against 19.24%),
|
|
57
|
+
* which pushed the first message up into the narrowing part of the ellipse —
|
|
58
|
+
* see the ratio's own note above for the measurements. The floor and the
|
|
59
|
+
* scaling term now agree at 582px (19.24% of 582 = 111.98), so the two meet
|
|
60
|
+
* without a step rather than crossing over at some unrelated height.
|
|
61
|
+
*/
|
|
62
|
+
export declare const TRANSCRIPT_FADE_TOP_LEN = "max(112px, 19.24cqh)";
|
|
63
|
+
/**
|
|
64
|
+
* Top ramp when a `badge` sits above the transcript.
|
|
65
|
+
*
|
|
66
|
+
* A badge has ALREADY pushed the transcript clear of the orb, so reusing the
|
|
67
|
+
* orb-sized ramp charges for the same clearance twice: it left a 112px dead
|
|
68
|
+
* band directly under the badge and dissolved the opening message for no
|
|
69
|
+
* reason (measured in `WithABadgeAndNoVoice` — orb ends 565, badge 573-598,
|
|
70
|
+
* first message could not start above 710). At that point the fade is only
|
|
71
|
+
* doing its ordinary job of softening a scroll edge, so it wants an ordinary
|
|
72
|
+
* scroll-edge length. Same floor+`cqh` scheme as {@link TRANSCRIPT_FADE_TOP_LEN}
|
|
73
|
+
* above and for the same reason — this ramp needs to soften proportionally
|
|
74
|
+
* more of a tall panel's scroll edge than a short one's.
|
|
75
|
+
*
|
|
76
|
+
* The third arm is the ellipse, and it is what keeps this variant honest at
|
|
77
|
+
* sizes the badge's own fixed offsets stop covering. With a badge the first row
|
|
78
|
+
* is pushed down by chrome that does NOT scale — 1px surface border + 6px
|
|
79
|
+
* column padding + the badge wrapper's `mt-[104px]` + 4px list padding = 115px
|
|
80
|
+
* — so the row lands at `(115px + this ramp) / panelHeight`, a fraction that
|
|
81
|
+
* SHRINKS as the panel grows. `19.24cqh - 115px` is that equation solved for
|
|
82
|
+
* the ramp, so the row lands on the same point of the curve the no-badge
|
|
83
|
+
* variant does. It is inert on the panels this variant was tuned against
|
|
84
|
+
* (negative at 582px, 4.5px at 720px, so the other two arms win) and takes over
|
|
85
|
+
* only above ~745px, where the fixed 115px has stopped being enough.
|
|
86
|
+
*
|
|
87
|
+
* The badge's own height is counted as ZERO in that 115px, deliberately:
|
|
88
|
+
* `badge` is an arbitrary node from the host (`voice-widget.tsx` passes a
|
|
89
|
+
* one-line status pill, ~26px), and only the shortest-badge bound holds for
|
|
90
|
+
* every caller. A taller badge pushes the row further down, which is the safe
|
|
91
|
+
* direction.
|
|
92
|
+
*/
|
|
93
|
+
export declare const TRANSCRIPT_FADE_TOP_WITH_BADGE_LEN = "max(28px, 4cqh, 19.24cqh - 115px)";
|
|
94
|
+
export declare const TRANSCRIPT_FADE_BOTTOM_LEN = "max(118px, 20.27cqh)";
|
|
95
|
+
/**
|
|
96
|
+
* The transcript's horizontal inset — the width the ellipse actually costs.
|
|
97
|
+
*
|
|
98
|
+
* `10.6cqw` is where the curve is at the first row's height: on an ellipse of
|
|
99
|
+
* width `w`, at the fraction 0.1924 of the way down (the ratio the clearances
|
|
100
|
+
* above hold at every size), the left edge lies `w * (1 - sqrt(1 - (2*0.1924 -
|
|
101
|
+
* 1)^2)) / 2` = `0.1058 * w` in from the bounding box. Rounded up to 10.6% so
|
|
102
|
+
* the rounding goes toward clearance rather than away from it.
|
|
103
|
+
*
|
|
104
|
+
* `- 11px` because 11px of that is already paid for by fixed chrome outside
|
|
105
|
+
* this element: the surface's 1px border plus the inner column's `px-2.5`. The
|
|
106
|
+
* inset is measured from the PANEL's box, which is where the curve is; this
|
|
107
|
+
* padding only has to make up the difference. Verified live: a 363.8px-wide
|
|
108
|
+
* panel put the first bubble's left edge at 19px = 11px chrome + the 8px this
|
|
109
|
+
* replaces.
|
|
110
|
+
*
|
|
111
|
+
* The `8px` floor is the value this shipped with, kept as a lower bound so a
|
|
112
|
+
* degenerately small panel can never end up with less padding than a plain
|
|
113
|
+
* scroll edge wants. It is inert at every real size (the formula gives 27.6px
|
|
114
|
+
* on the smallest panel the widget renders).
|
|
115
|
+
*
|
|
116
|
+
* Symmetric on purpose, and applied as `padding-inline` so it stays symmetric
|
|
117
|
+
* in RTL: the ellipse is symmetric, the visitor's own bubbles are `justify-end`
|
|
118
|
+
* against the other side of it, and either side is the first row's side
|
|
119
|
+
* depending on who spoke.
|
|
120
|
+
*/
|
|
121
|
+
export declare const TRANSCRIPT_INSET_X = "max(8px, 10.6cqw - 11px)";
|
|
122
|
+
/**
|
|
123
|
+
* How far above the panel's BOTTOM the composer's text input ends, as a
|
|
124
|
+
* fraction of panel height — the composer's answer to
|
|
125
|
+
* {@link TRANSCRIPT_FADE_TOP_LEN}'s 19.24cqh, and the number
|
|
126
|
+
* {@link COMPOSER_MAX_WIDTH_LEN} is derived from.
|
|
127
|
+
*
|
|
128
|
+
* Read off the short panel exactly as the transcript's ratio was: 69px (the
|
|
129
|
+
* input's bottom edge on a 582px panel today — 1px surface border + the
|
|
130
|
+
* overlay's 6px `bottom-1.5` + the 62px microphone block) over 582px is
|
|
131
|
+
* 0.11856. Holding THAT ratio at every panel size is the whole repair: the
|
|
132
|
+
* composer's offsets are plain pixels (6px, and a 40px input over a 62px
|
|
133
|
+
* microphone block), so on a taller panel they place the input a SMALLER
|
|
134
|
+
* fraction of the way up from the tip — further into the narrowing curve — and
|
|
135
|
+
* no fixed width can be correct at two sizes at once. Pinned, one `cqw`
|
|
136
|
+
* expression serves every panel.
|
|
137
|
+
*
|
|
138
|
+
* Exported for the geometry test, which needs the fraction itself rather than
|
|
139
|
+
* either length below.
|
|
140
|
+
*/
|
|
141
|
+
export declare const COMPOSER_ROW_FRACTION = 0.1186;
|
|
142
|
+
/**
|
|
143
|
+
* The composer overlay's bottom offset when the microphone is drawn.
|
|
144
|
+
*
|
|
145
|
+
* `11.86cqh` is {@link COMPOSER_ROW_FRACTION} as a length. `- 63px` is
|
|
146
|
+
* everything between this offset and the input's bottom edge that does NOT
|
|
147
|
+
* scale: the surface's 1px border (the overlay is positioned against the inner
|
|
148
|
+
* column's padding box, one border inside the panel) plus the 62px microphone
|
|
149
|
+
* block — a 10px `gap-2.5`, the row's 4px `mt-1`, and a 48px `size-12` button.
|
|
150
|
+
*
|
|
151
|
+
* `max(6px, …)` keeps the 6px this shipped with as a floor, and the two arms
|
|
152
|
+
* MEET at the panel it was tuned on rather than crossing somewhere unrelated:
|
|
153
|
+
* `11.86cqh - 63px` is 6.03px at 582px, so a phone renders what it rendered
|
|
154
|
+
* before to a hundredth of a pixel and only larger panels lift the composer.
|
|
155
|
+
*/
|
|
156
|
+
export declare const COMPOSER_BOTTOM_LEN = "max(6px, 11.86cqh - 63px)";
|
|
157
|
+
/**
|
|
158
|
+
* The composer overlay's bottom offset when there is NO microphone.
|
|
159
|
+
*
|
|
160
|
+
* Same target row, minus only the 1px surface border: with `voice` omitted the
|
|
161
|
+
* overlay's last child IS the input, so the 62px the microphone block
|
|
162
|
+
* contributed above has to come from this offset instead. That is a real move —
|
|
163
|
+
* 6px to 68px on a phone — and it is the fix rather than a side effect. Left at
|
|
164
|
+
* 6px the input sits 7px off a `rounded-full` panel's bottom tip, where the
|
|
165
|
+
* ellipse offers 79px of width in total; no width cap can rescue that row, so
|
|
166
|
+
* the row itself has to come up to where the panel is wide enough to hold it.
|
|
167
|
+
*
|
|
168
|
+
* The band it moves into is the one the microphone would have occupied, which
|
|
169
|
+
* the transcript already clears ({@link TRANSCRIPT_FADE_BOTTOM_LEN} is sized
|
|
170
|
+
* for the input + microphone pair regardless of whether the pair is drawn), so
|
|
171
|
+
* nothing above has to move to make room.
|
|
172
|
+
*/
|
|
173
|
+
export declare const COMPOSER_BOTTOM_NO_VOICE_LEN = "max(6px, 11.86cqh - 1px)";
|
|
174
|
+
/**
|
|
175
|
+
* The composer's width cap — what the ellipse actually offers at that row.
|
|
176
|
+
*
|
|
177
|
+
* On an ellipse of width `w`, at the fraction `1 - 0.1186` of the way down, the
|
|
178
|
+
* full chord is `w * sqrt(1 - (2*0.8814 - 1)^2)` = `0.6465 * w`. So `64.65cqw`
|
|
179
|
+
* is not a taste-tuned percentage, it is the panel's own width at the row the
|
|
180
|
+
* two offsets above pin the input to — where `w-[71%]`, the class this caps,
|
|
181
|
+
* was 6.4% of the panel too wide at EVERY size (10.8px of overhang on a phone,
|
|
182
|
+
* 52.0px on a 920px panel, because the row also drifts lower as the panel
|
|
183
|
+
* grows).
|
|
184
|
+
*
|
|
185
|
+
* `- 10px` is clearance, 5px each side, matching the 5px the transcript's rows
|
|
186
|
+
* clear the curve by — the panel paints a 1.5px gradient ring plus a 1px
|
|
187
|
+
* surface border at that edge, and the input's own rounding means the arc, not
|
|
188
|
+
* the corner, is what approaches the curve.
|
|
189
|
+
*
|
|
190
|
+
* Applied as `max-width` over the existing `w-[71%]`, not in place of it: 71%
|
|
191
|
+
* stays the upper bound the composer had, and this only ever tightens it (the
|
|
192
|
+
* ellipse term is below 71% for any panel, since 0.6465 < 0.71). The `160px`
|
|
193
|
+
* floor is the "cap it sensibly" arm — it stops a degenerately small panel from
|
|
194
|
+
* resolving the composer to a few dozen pixels of unusable input, and it is
|
|
195
|
+
* inert at every size the widget really renders (it binds only below a 248px
|
|
196
|
+
* panel; the narrowest phone in circulation, 320px, gives 310px).
|
|
197
|
+
*/
|
|
198
|
+
export declare const COMPOSER_MAX_WIDTH_LEN = "max(160px, 64.65cqw - 10px)";
|
|
199
|
+
/**
|
|
200
|
+
* The opaque ground the composer sits on, which has to keep covering it.
|
|
201
|
+
*
|
|
202
|
+
* The transcript runs the panel's whole height and passes BEHIND this row, so
|
|
203
|
+
* this gradient is the only thing between a message and the input's own
|
|
204
|
+
* translucent chip fill. It was a fixed `h-[132px]`, tuned when the composer
|
|
205
|
+
* was pinned 6px off the bottom on every panel — and the moment the offsets
|
|
206
|
+
* above start lifting the composer on a tall panel, a fixed ground stops
|
|
207
|
+
* reaching its top edge (the composer's top is `11.86cqh + 40px` above the
|
|
208
|
+
* panel's bottom: 109px at 582px, but 149px at 920px, against 132px of ground).
|
|
209
|
+
*
|
|
210
|
+
* 22.68cqh is the same read-off-the-short-panel derivation as everything else
|
|
211
|
+
* here — 132/582 = 0.22680 — so a phone renders exactly the 132px it rendered
|
|
212
|
+
* before and the ground grows with the row it is under. It stays above the
|
|
213
|
+
* composer's own top at every size, and stays the same shade taller than the
|
|
214
|
+
* transcript's bottom clearance that it is today ({@link
|
|
215
|
+
* TRANSCRIPT_FADE_BOTTOM_LEN} is 20.27cqh against this 22.68cqh, exactly the
|
|
216
|
+
* 118:132 relationship the two were tuned at), so they still meet without a
|
|
217
|
+
* seam or a band of doubly-darkened panel.
|
|
218
|
+
*/
|
|
219
|
+
export declare const COMPOSER_GROUND_LEN = "max(132px, 22.68cqh)";
|
|
220
|
+
//# sourceMappingURL=transcript-geometry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transcript-geometry.d.ts","sourceRoot":"","sources":["../../src/widget/transcript-geometry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,uBAAuB,yBAAyB,CAAC;AAC9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,eAAO,MAAM,kCAAkC,sCAAsC,CAAC;AAiBtF,eAAO,MAAM,0BAA0B,yBAAyB,CAAC;AACjE;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,kBAAkB,6BAA6B,CAAC;AAqB7D;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,qBAAqB,SAAS,CAAC;AAC5C;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,mBAAmB,8BAA8B,CAAC;AAC/D;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,4BAA4B,6BAA6B,CAAC;AACvE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,sBAAsB,gCAAgC,CAAC;AACpE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,mBAAmB,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE WIDGET'S VIEW — the launcher-and-panel renderer's presentation of a
|
|
3
|
+
* state the shared machine already decided (docs/CONCIERGE_GENERATIONS.md §3,
|
|
4
|
+
* §4).
|
|
5
|
+
*
|
|
6
|
+
* `../concierge-state.ts` decides WHICH of the fourteen states the session is
|
|
7
|
+
* in; this module decides what the widget draws for it, exactly as
|
|
8
|
+
* `../dock/dock-state.ts`'s `deriveDockView` does for the dock. Both are
|
|
9
|
+
* exhaustive over `CONCIERGE_STATES` by construction — the `never` tail below
|
|
10
|
+
* stops the build when a state is added to the machine and not given a row
|
|
11
|
+
* here — and `concierge-state.test.ts` asserts that every state reaches both.
|
|
12
|
+
*
|
|
13
|
+
* ## Phase 1: the mapping exists; phase 4 gives each row its behaviour
|
|
14
|
+
*
|
|
15
|
+
* This is the FIRST cut, and it is deliberately the smallest honest one. The
|
|
16
|
+
* widget today carries four avatar moods (`BotState`) and receives every
|
|
17
|
+
* session fact through ad-hoc props; this view is where those props become
|
|
18
|
+
* one derived answer per state instead. What each state should DO in the
|
|
19
|
+
* widget — the plan's "widget-native presentation" — is decided row by row in
|
|
20
|
+
* phase 4, with a spec row and a story each. Until a row is worked, its
|
|
21
|
+
* mapping here is the plainest reading of the state: the avatar mood the
|
|
22
|
+
* state implies, whether the launcher should carry a badge, and the line the
|
|
23
|
+
* panel should show. Nothing in `concierge-shell.tsx` consumes this yet.
|
|
24
|
+
*
|
|
25
|
+
* ## What the widget does NOT get, on purpose
|
|
26
|
+
*
|
|
27
|
+
* There is no `glass` here and there will not be one: §3.6's receded surface
|
|
28
|
+
* is a property of a ROW that sits over the page, and the widget has no row
|
|
29
|
+
* to recede. That is the first entry in the plan's "behaviour that differs on
|
|
30
|
+
* purpose", and its absence from this type is the record of it.
|
|
31
|
+
*/
|
|
32
|
+
import type { BotState } from '../bot-state.js';
|
|
33
|
+
import type { ConciergeSnapshot, ConciergeState, ConciergeStateInput } from '../concierge-state.js';
|
|
34
|
+
/** What the panel does in this state. `as-is` is the common answer: the shopper put it where it is. */
|
|
35
|
+
export type WidgetPanelPolicy = 'as-is' | 'closed';
|
|
36
|
+
/**
|
|
37
|
+
* The launcher, per state — the widget's counterpart to everything the dock
|
|
38
|
+
* says with its ROW (docs/CONCIERGE_GENERATIONS.md §4).
|
|
39
|
+
*
|
|
40
|
+
* The dock can say things in the row because the row is always on screen.
|
|
41
|
+
* While the widget's panel is closed the launcher is all there is, so this is
|
|
42
|
+
* the whole of what it can say. Every field is `false` in the states with
|
|
43
|
+
* nothing to add, so a renderer reads one shape rather than fourteen.
|
|
44
|
+
*/
|
|
45
|
+
export interface WidgetLauncherSpec {
|
|
46
|
+
/** `connecting` — working, and the keyboard is still available (§4). */
|
|
47
|
+
readonly busy: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* `ducked` — the dock recedes its row behind glass; the widget has no row,
|
|
50
|
+
* so the LAUNCHER recedes instead. Deliberately not glass: §4 records glass
|
|
51
|
+
* as having no widget analogue.
|
|
52
|
+
*/
|
|
53
|
+
readonly dimmed: boolean;
|
|
54
|
+
/** `offline` — there is nothing to open, and the tenant's message says why. */
|
|
55
|
+
readonly disabled: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Something landed behind a closed panel — `cards` (the dock's
|
|
58
|
+
* "{n} picks — see") and `reconnecting`. The renderer draws a dot; the count
|
|
59
|
+
* itself is `shelfCount`.
|
|
60
|
+
*/
|
|
61
|
+
readonly badge: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* `human` — the operator's initials replace the mark, the widget's
|
|
64
|
+
* counterpart to the dock's handoff disc (§4's surfaces table).
|
|
65
|
+
*/
|
|
66
|
+
readonly initials: boolean;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* The line the panel shows for this state, as data. `key` is a
|
|
70
|
+
* `WidgetMessages` key resolved by the renderer against the tenant's
|
|
71
|
+
* catalogue; `text` is something live. `null` means the state has no line of
|
|
72
|
+
* its own — the transcript IS the content.
|
|
73
|
+
*/
|
|
74
|
+
export type WidgetStatusSpec = null | {
|
|
75
|
+
readonly kind: 'text';
|
|
76
|
+
readonly text: string;
|
|
77
|
+
} | {
|
|
78
|
+
readonly kind: 'message';
|
|
79
|
+
readonly key: WidgetMessageKey;
|
|
80
|
+
};
|
|
81
|
+
/** The `WidgetMessages` keys this module can name. Narrow on purpose — a typo is a compile error. */
|
|
82
|
+
export type WidgetMessageKey = 'dock_connecting' | 'dock_listening' | 'dock_thinking' | 'dock_ducked' | 'dock_still_here' | 'dock_still_here_resume' | 'dock_muted' | 'dock_mic_blocked' | 'dock_cards' | 'dock_voice_failed' | 'escalated_banner';
|
|
83
|
+
export interface WidgetView {
|
|
84
|
+
readonly state: ConciergeState;
|
|
85
|
+
/** The avatar's mood — the four `BotState`s the widget already draws. */
|
|
86
|
+
readonly avatar: BotState;
|
|
87
|
+
/** What the launcher says while the panel is closed — see {@link WidgetLauncherSpec}. */
|
|
88
|
+
readonly launcher: WidgetLauncherSpec;
|
|
89
|
+
readonly panel: WidgetPanelPolicy;
|
|
90
|
+
readonly status: WidgetStatusSpec;
|
|
91
|
+
/** The composer cannot be used in this state. */
|
|
92
|
+
readonly composerDisabled: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* The status belongs in an `aria-live` region as well as on screen.
|
|
95
|
+
*
|
|
96
|
+
* Not every state's does. A partial transcript rewrites itself on every word
|
|
97
|
+
* and a preamble is already being spoken aloud; announcing those talks over
|
|
98
|
+
* the shopper. What earns an announcement is a state they have to ACT on or
|
|
99
|
+
* would otherwise miss: the microphone closed, a permission refused, the
|
|
100
|
+
* connection dropped, an error, the shop closed, a human arriving.
|
|
101
|
+
*/
|
|
102
|
+
readonly announce: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Somebody on the other side is composing; the panel shows dots.
|
|
105
|
+
*
|
|
106
|
+
* Read from the INPUT, not from the state, and the difference matters: the
|
|
107
|
+
* machine's `typing` state is "an engaged text session" — the dock's name
|
|
108
|
+
* for the row whose caption is the shopper's own field — and it is true for
|
|
109
|
+
* the whole of a text conversation. What the dots mean is `input.composing`,
|
|
110
|
+
* which is what `deriveDockView` draws its own dots from (`activity:
|
|
111
|
+
* 'dots'`). A widget keyed on the STATE would show dots for the entire
|
|
112
|
+
* session, which is the bug this comment exists to stop coming back.
|
|
113
|
+
*
|
|
114
|
+
* True only in the two states the dock draws dots in — `typing` and
|
|
115
|
+
* `human`. The voice states have their own activity (a waveform, a
|
|
116
|
+
* progress track), and dots under a live call would claim the wrong thing
|
|
117
|
+
* is happening.
|
|
118
|
+
*/
|
|
119
|
+
readonly typing: boolean;
|
|
120
|
+
/**
|
|
121
|
+
* `speaking` — the agent is talking and the shopper may cut in. The dock
|
|
122
|
+
* offers this in its row; the widget offers it in the panel.
|
|
123
|
+
*/
|
|
124
|
+
readonly interrupt: boolean;
|
|
125
|
+
/** Shared with the dock, never recomputed — see `ConciergeSnapshot`. */
|
|
126
|
+
readonly handoff: boolean;
|
|
127
|
+
readonly callActive: boolean;
|
|
128
|
+
readonly shelfCount: number;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* The widget's presentation of a state the shared machine already decided.
|
|
132
|
+
*
|
|
133
|
+
* @param snapshot the state and the shared facts — see {@link ConciergeSnapshot}
|
|
134
|
+
* @param input the session, read for CONTENT only (a partial transcript, an
|
|
135
|
+
* operator's line, the host's error text) — never to decide the state
|
|
136
|
+
*/
|
|
137
|
+
export declare function deriveWidgetView(snapshot: ConciergeSnapshot, input: ConciergeStateInput): WidgetView;
|
|
138
|
+
//# sourceMappingURL=widget-view.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"widget-view.d.ts","sourceRoot":"","sources":["../../src/widget/widget-view.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAEpG,uGAAuG;AACvG,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEnD;;;;;;;;GAQG;AACH,MAAM,WAAW,kBAAkB;IACjC,wEAAwE;IACxE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,+EAA+E;IAC/E,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B;AAWD;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GACxB,IAAI,GACJ;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAChD;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,gBAAgB,CAAA;CAAE,CAAC;AAEjE,qGAAqG;AACrG,MAAM,MAAM,gBAAgB,GACxB,iBAAiB,GACjB,gBAAgB,GAChB,eAAe,GACf,aAAa,GACb,iBAAiB,GACjB,wBAAwB,GACxB,YAAY,GACZ,kBAAkB,GAClB,YAAY,GACZ,mBAAmB,GACnB,kBAAkB,CAAC;AAEvB,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;IAC/B,yEAAyE;IACzE,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;IAC1B,yFAAyF;IACzF,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,CAAC;IACtC,QAAQ,CAAC,KAAK,EAAE,iBAAiB,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAClC,iDAAiD;IACjD,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;IACnC;;;;;;;;OAQG;IACH,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B;;;;;;;;;;;;;;;OAeG;IACH,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB;;;OAGG;IACH,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,wEAAwE;IACxE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,iBAAiB,EAC3B,KAAK,EAAE,mBAAmB,GACzB,UAAU,CAmNZ"}
|