@wix/himalaya-cli 0.1929.0 → 0.1930.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.
Files changed (183) hide show
  1. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/dev-server/src/builder.d.ts +2 -0
  2. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/schema.d.ts +7 -0
  3. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/chat-web/src/index.d.ts +12 -0
  4. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-chat-web.mjs +19 -9
  5. package/dist/browser-plane/assets.json +5 -5
  6. package/dist/browser-plane/preview-deferred/{95a3ae045bad903e458ea7a5800e60e1044f0f754a65d7127de66ba62e897068.bin → 7656e5effbeaee2ab20810b9903e7e785d9dffb0a0563f25c2746011cf4e23e9.bin} +1 -1
  7. package/dist/browser-plane/sw.js +10 -10
  8. package/dist/cli.mjs +254 -70
  9. package/dist/preview-assets.generated.bin +0 -0
  10. package/guides/component-index.md +1 -1
  11. package/guides/component-reference.json +1 -1
  12. package/guides/component-reference.md +7 -0
  13. package/guides/sdk-reference.json +2 -2
  14. package/package.json +2 -2
  15. package/templates/bare-fashion/tier5-src/_shared/owner-load-error.ts +1 -1
  16. package/templates/beauty-salon/tier5-src/_shared/owner-load-error.ts +1 -1
  17. package/templates/beauty-salon-owner/dev/index.ts +169 -139
  18. package/templates/beauty-salon-owner/tier5-src/_shared/owner-load-error.ts +1 -1
  19. package/templates/beauty-salon-owner/tier5-src/_shared/owner-maestro-availability.ts +12 -2
  20. package/templates/beauty-salon-owner/tier5-src/_shared/owner-maestro-tab.ts +81 -5
  21. package/templates/beauty-salon-owner/tier5-src/_shared/owner-selected-site.ts +15 -0
  22. package/templates/beauty-salon-owner/tier5-src/_shared/owner-widget-reads.ts +7 -0
  23. package/templates/beauty-salon-owner/tier5-src/himi-owner-lite-home/index.ts +30 -8
  24. package/templates/beauty-salon-owner/tier5-src/himi-owner-lite-inbox/index.ts +47 -8
  25. package/templates/beauty-salon-owner/tier5-src/himi-owner-lite-inbox-thread/index.ts +12 -5
  26. package/templates/beauty-salon-owner/tier5-src/himi-owner-lite-maestro/index.ts +132 -39
  27. package/templates/beauty-salon-owner/tier5-src/himi-owner-lite-maestro-history/index.ts +10 -8
  28. package/templates/beauty-salon-owner/tier5-src/himi-owner-lite-order/index.ts +4 -1
  29. package/templates/beauty-salon-owner/tier5-src/himi-owner-lite-record/index.ts +7 -1
  30. package/templates/beauty-salon-owner/tier5-src/wix-owner-booking/index.ts +4 -1
  31. package/templates/branded-lite/tier5-src/_shared/owner-load-error.ts +1 -1
  32. package/templates/brandy/tier5-src/_shared/owner-load-error.ts +1 -1
  33. package/templates/community-club/tier5-src/_shared/owner-load-error.ts +1 -1
  34. package/templates/community-club-owner/dev/index.ts +167 -132
  35. package/templates/community-club-owner/tier5-src/_shared/owner-load-error.ts +1 -1
  36. package/templates/community-club-owner/tier5-src/_shared/owner-maestro-availability.ts +12 -2
  37. package/templates/community-club-owner/tier5-src/_shared/owner-maestro-tab.ts +81 -5
  38. package/templates/community-club-owner/tier5-src/_shared/owner-selected-site.ts +15 -0
  39. package/templates/community-club-owner/tier5-src/_shared/owner-widget-reads.ts +7 -0
  40. package/templates/community-club-owner/tier5-src/himi-owner-lite-home/index.ts +30 -8
  41. package/templates/community-club-owner/tier5-src/himi-owner-lite-inbox/index.ts +47 -8
  42. package/templates/community-club-owner/tier5-src/himi-owner-lite-inbox-thread/index.ts +12 -5
  43. package/templates/community-club-owner/tier5-src/himi-owner-lite-maestro/index.ts +132 -39
  44. package/templates/community-club-owner/tier5-src/himi-owner-lite-maestro-history/index.ts +10 -8
  45. package/templates/community-club-owner/tier5-src/himi-owner-lite-order/index.ts +4 -1
  46. package/templates/community-club-owner/tier5-src/himi-owner-lite-record/index.ts +7 -1
  47. package/templates/conference/tier5-src/_shared/owner-load-error.ts +1 -1
  48. package/templates/events-meetups/tier5-src/_shared/owner-load-error.ts +1 -1
  49. package/templates/events-meetups-owner/dev/index.ts +165 -125
  50. package/templates/events-meetups-owner/tier5-src/_shared/owner-load-error.ts +1 -1
  51. package/templates/events-meetups-owner/tier5-src/_shared/owner-maestro-availability.ts +12 -2
  52. package/templates/events-meetups-owner/tier5-src/_shared/owner-maestro-tab.ts +81 -5
  53. package/templates/events-meetups-owner/tier5-src/_shared/owner-selected-site.ts +15 -0
  54. package/templates/events-meetups-owner/tier5-src/_shared/owner-widget-reads.ts +7 -0
  55. package/templates/events-meetups-owner/tier5-src/himi-owner-lite-home/index.ts +30 -8
  56. package/templates/events-meetups-owner/tier5-src/himi-owner-lite-inbox/index.ts +47 -8
  57. package/templates/events-meetups-owner/tier5-src/himi-owner-lite-inbox-thread/index.ts +12 -5
  58. package/templates/events-meetups-owner/tier5-src/himi-owner-lite-maestro/index.ts +132 -39
  59. package/templates/events-meetups-owner/tier5-src/himi-owner-lite-maestro-history/index.ts +10 -8
  60. package/templates/events-meetups-owner/tier5-src/himi-owner-lite-record/index.ts +7 -1
  61. package/templates/fitness-gym/tier5-src/_shared/owner-load-error.ts +1 -1
  62. package/templates/gym-fitness/tier5-src/_shared/owner-load-error.ts +1 -1
  63. package/templates/gym-fitness-owner/dev/index.ts +169 -139
  64. package/templates/gym-fitness-owner/tier5-src/_shared/owner-load-error.ts +1 -1
  65. package/templates/gym-fitness-owner/tier5-src/_shared/owner-maestro-availability.ts +12 -2
  66. package/templates/gym-fitness-owner/tier5-src/_shared/owner-maestro-tab.ts +81 -5
  67. package/templates/gym-fitness-owner/tier5-src/_shared/owner-selected-site.ts +15 -0
  68. package/templates/gym-fitness-owner/tier5-src/_shared/owner-widget-reads.ts +7 -0
  69. package/templates/gym-fitness-owner/tier5-src/himi-owner-lite-home/index.ts +30 -8
  70. package/templates/gym-fitness-owner/tier5-src/himi-owner-lite-inbox/index.ts +47 -8
  71. package/templates/gym-fitness-owner/tier5-src/himi-owner-lite-inbox-thread/index.ts +12 -5
  72. package/templates/gym-fitness-owner/tier5-src/himi-owner-lite-maestro/index.ts +132 -39
  73. package/templates/gym-fitness-owner/tier5-src/himi-owner-lite-maestro-history/index.ts +10 -8
  74. package/templates/gym-fitness-owner/tier5-src/himi-owner-lite-order/index.ts +4 -1
  75. package/templates/gym-fitness-owner/tier5-src/himi-owner-lite-record/index.ts +7 -1
  76. package/templates/gym-fitness-owner/tier5-src/wix-owner-booking/index.ts +4 -1
  77. package/templates/himi-chat/tier5-src/_shared/owner-load-error.ts +1 -1
  78. package/templates/medical-services/tier5-src/_shared/owner-load-error.ts +1 -1
  79. package/templates/nonprofit-cause/tier5-src/_shared/owner-load-error.ts +1 -1
  80. package/templates/nonprofit-cause-owner/dev/index.ts +167 -132
  81. package/templates/nonprofit-cause-owner/tier5-src/_shared/owner-load-error.ts +1 -1
  82. package/templates/nonprofit-cause-owner/tier5-src/_shared/owner-maestro-availability.ts +12 -2
  83. package/templates/nonprofit-cause-owner/tier5-src/_shared/owner-maestro-tab.ts +81 -5
  84. package/templates/nonprofit-cause-owner/tier5-src/_shared/owner-selected-site.ts +15 -0
  85. package/templates/nonprofit-cause-owner/tier5-src/_shared/owner-widget-reads.ts +7 -0
  86. package/templates/nonprofit-cause-owner/tier5-src/himi-owner-lite-home/index.ts +30 -8
  87. package/templates/nonprofit-cause-owner/tier5-src/himi-owner-lite-inbox/index.ts +47 -8
  88. package/templates/nonprofit-cause-owner/tier5-src/himi-owner-lite-inbox-thread/index.ts +12 -5
  89. package/templates/nonprofit-cause-owner/tier5-src/himi-owner-lite-maestro/index.ts +132 -39
  90. package/templates/nonprofit-cause-owner/tier5-src/himi-owner-lite-maestro-history/index.ts +10 -8
  91. package/templates/nonprofit-cause-owner/tier5-src/himi-owner-lite-record/index.ts +7 -1
  92. package/templates/nonprofit-cause-owner/tier5-src/wix-owner-booking/index.ts +4 -1
  93. package/templates/owner-lite/dev/index.ts +171 -141
  94. package/templates/owner-lite/himalaya.content.json +1 -1
  95. package/templates/owner-lite/tier5-src/_shared/owner-load-error.ts +1 -1
  96. package/templates/owner-lite/tier5-src/_shared/owner-maestro-availability.ts +12 -2
  97. package/templates/owner-lite/tier5-src/_shared/owner-maestro-tab.ts +81 -5
  98. package/templates/owner-lite/tier5-src/_shared/owner-selected-site.ts +15 -0
  99. package/templates/owner-lite/tier5-src/_shared/owner-widget-reads.ts +7 -0
  100. package/templates/owner-lite/tier5-src/himi-owner-lite-home/index.ts +30 -8
  101. package/templates/owner-lite/tier5-src/himi-owner-lite-inbox/index.ts +47 -8
  102. package/templates/owner-lite/tier5-src/himi-owner-lite-inbox-thread/index.ts +12 -5
  103. package/templates/owner-lite/tier5-src/himi-owner-lite-maestro/index.ts +132 -39
  104. package/templates/owner-lite/tier5-src/himi-owner-lite-maestro-history/index.ts +10 -8
  105. package/templates/owner-lite/tier5-src/himi-owner-lite-order/index.ts +4 -1
  106. package/templates/owner-lite/tier5-src/himi-owner-lite-record/index.ts +7 -1
  107. package/templates/owner-lite/tier5-src/wix-owner-booking/index.ts +4 -1
  108. package/templates/personal-fitness-trainer/tier5-src/_shared/owner-load-error.ts +1 -1
  109. package/templates/podcast-creator/tier5-src/_shared/owner-load-error.ts +1 -1
  110. package/templates/podcast-creator-owner/dev/index.ts +167 -132
  111. package/templates/podcast-creator-owner/tier5-src/_shared/owner-load-error.ts +1 -1
  112. package/templates/podcast-creator-owner/tier5-src/_shared/owner-maestro-availability.ts +12 -2
  113. package/templates/podcast-creator-owner/tier5-src/_shared/owner-maestro-tab.ts +81 -5
  114. package/templates/podcast-creator-owner/tier5-src/_shared/owner-selected-site.ts +15 -0
  115. package/templates/podcast-creator-owner/tier5-src/_shared/owner-widget-reads.ts +7 -0
  116. package/templates/podcast-creator-owner/tier5-src/himi-owner-lite-home/index.ts +30 -8
  117. package/templates/podcast-creator-owner/tier5-src/himi-owner-lite-inbox/index.ts +47 -8
  118. package/templates/podcast-creator-owner/tier5-src/himi-owner-lite-inbox-thread/index.ts +12 -5
  119. package/templates/podcast-creator-owner/tier5-src/himi-owner-lite-maestro/index.ts +132 -39
  120. package/templates/podcast-creator-owner/tier5-src/himi-owner-lite-maestro-history/index.ts +10 -8
  121. package/templates/podcast-creator-owner/tier5-src/himi-owner-lite-order/index.ts +4 -1
  122. package/templates/podcast-creator-owner/tier5-src/himi-owner-lite-record/index.ts +7 -1
  123. package/templates/portfolio-creative/tier5-src/_shared/owner-load-error.ts +1 -1
  124. package/templates/portfolio-creative-owner/dev/index.ts +169 -139
  125. package/templates/portfolio-creative-owner/tier5-src/_shared/owner-load-error.ts +1 -1
  126. package/templates/portfolio-creative-owner/tier5-src/_shared/owner-maestro-availability.ts +12 -2
  127. package/templates/portfolio-creative-owner/tier5-src/_shared/owner-maestro-tab.ts +81 -5
  128. package/templates/portfolio-creative-owner/tier5-src/_shared/owner-selected-site.ts +15 -0
  129. package/templates/portfolio-creative-owner/tier5-src/_shared/owner-widget-reads.ts +7 -0
  130. package/templates/portfolio-creative-owner/tier5-src/himi-owner-lite-home/index.ts +30 -8
  131. package/templates/portfolio-creative-owner/tier5-src/himi-owner-lite-inbox/index.ts +47 -8
  132. package/templates/portfolio-creative-owner/tier5-src/himi-owner-lite-inbox-thread/index.ts +12 -5
  133. package/templates/portfolio-creative-owner/tier5-src/himi-owner-lite-maestro/index.ts +132 -39
  134. package/templates/portfolio-creative-owner/tier5-src/himi-owner-lite-maestro-history/index.ts +10 -8
  135. package/templates/portfolio-creative-owner/tier5-src/himi-owner-lite-order/index.ts +4 -1
  136. package/templates/portfolio-creative-owner/tier5-src/himi-owner-lite-record/index.ts +7 -1
  137. package/templates/portfolio-creative-owner/tier5-src/wix-owner-booking/index.ts +4 -1
  138. package/templates/professional-services/tier5-src/_shared/owner-load-error.ts +1 -1
  139. package/templates/restaurant/tier5-src/_shared/owner-load-error.ts +1 -1
  140. package/templates/restaurant-owner/dev/index.ts +169 -139
  141. package/templates/restaurant-owner/tier5-src/_shared/owner-load-error.ts +1 -1
  142. package/templates/restaurant-owner/tier5-src/_shared/owner-maestro-availability.ts +12 -2
  143. package/templates/restaurant-owner/tier5-src/_shared/owner-maestro-tab.ts +81 -5
  144. package/templates/restaurant-owner/tier5-src/_shared/owner-selected-site.ts +15 -0
  145. package/templates/restaurant-owner/tier5-src/_shared/owner-widget-reads.ts +7 -0
  146. package/templates/restaurant-owner/tier5-src/himi-owner-lite-home/index.ts +30 -8
  147. package/templates/restaurant-owner/tier5-src/himi-owner-lite-inbox/index.ts +47 -8
  148. package/templates/restaurant-owner/tier5-src/himi-owner-lite-inbox-thread/index.ts +12 -5
  149. package/templates/restaurant-owner/tier5-src/himi-owner-lite-maestro/index.ts +132 -39
  150. package/templates/restaurant-owner/tier5-src/himi-owner-lite-maestro-history/index.ts +10 -8
  151. package/templates/restaurant-owner/tier5-src/himi-owner-lite-order/index.ts +4 -1
  152. package/templates/restaurant-owner/tier5-src/himi-owner-lite-record/index.ts +7 -1
  153. package/templates/restaurant-owner/tier5-src/wix-owner-booking/index.ts +4 -1
  154. package/templates/retail-store/tier5-src/_shared/owner-load-error.ts +1 -1
  155. package/templates/retail-store-owner/dev/index.ts +167 -132
  156. package/templates/retail-store-owner/tier5-src/_shared/owner-load-error.ts +1 -1
  157. package/templates/retail-store-owner/tier5-src/_shared/owner-maestro-availability.ts +12 -2
  158. package/templates/retail-store-owner/tier5-src/_shared/owner-maestro-tab.ts +81 -5
  159. package/templates/retail-store-owner/tier5-src/_shared/owner-selected-site.ts +15 -0
  160. package/templates/retail-store-owner/tier5-src/_shared/owner-widget-reads.ts +7 -0
  161. package/templates/retail-store-owner/tier5-src/himi-owner-lite-home/index.ts +30 -8
  162. package/templates/retail-store-owner/tier5-src/himi-owner-lite-inbox/index.ts +47 -8
  163. package/templates/retail-store-owner/tier5-src/himi-owner-lite-inbox-thread/index.ts +12 -5
  164. package/templates/retail-store-owner/tier5-src/himi-owner-lite-maestro/index.ts +132 -39
  165. package/templates/retail-store-owner/tier5-src/himi-owner-lite-maestro-history/index.ts +10 -8
  166. package/templates/retail-store-owner/tier5-src/himi-owner-lite-order/index.ts +4 -1
  167. package/templates/retail-store-owner/tier5-src/himi-owner-lite-record/index.ts +7 -1
  168. package/templates/salon-spa/tier5-src/_shared/owner-load-error.ts +1 -1
  169. package/templates/wholesale-store/tier5-src/_shared/owner-load-error.ts +1 -1
  170. package/templates/yoga-studio/tier5-src/_shared/owner-load-error.ts +1 -1
  171. package/templates/yoga-studio-owner/dev/index.ts +167 -132
  172. package/templates/yoga-studio-owner/tier5-src/_shared/owner-load-error.ts +1 -1
  173. package/templates/yoga-studio-owner/tier5-src/_shared/owner-maestro-availability.ts +12 -2
  174. package/templates/yoga-studio-owner/tier5-src/_shared/owner-maestro-tab.ts +81 -5
  175. package/templates/yoga-studio-owner/tier5-src/_shared/owner-selected-site.ts +15 -0
  176. package/templates/yoga-studio-owner/tier5-src/_shared/owner-widget-reads.ts +7 -0
  177. package/templates/yoga-studio-owner/tier5-src/himi-owner-lite-home/index.ts +30 -8
  178. package/templates/yoga-studio-owner/tier5-src/himi-owner-lite-inbox/index.ts +47 -8
  179. package/templates/yoga-studio-owner/tier5-src/himi-owner-lite-inbox-thread/index.ts +12 -5
  180. package/templates/yoga-studio-owner/tier5-src/himi-owner-lite-maestro/index.ts +132 -39
  181. package/templates/yoga-studio-owner/tier5-src/himi-owner-lite-maestro-history/index.ts +10 -8
  182. package/templates/yoga-studio-owner/tier5-src/himi-owner-lite-record/index.ts +7 -1
  183. package/templates/yoga-studio-owner/tier5-src/wix-owner-booking/index.ts +4 -1
@@ -29,8 +29,9 @@ import { defineService } from "@himalaya/state";
29
29
  import { get as appInfo } from "@himalaya/app-info";
30
30
  import { deviceTimeZone } from "../_shared/engine-intl.js";
31
31
  import { copyParam, stashCopy } from "../_shared/himi-copy.js";
32
- import { readSelectedSite } from "../_shared/owner-selected-site.js";
32
+ import { currentBusinessId } from "../_shared/owner-selected-site.js";
33
33
  import { forSymphonyAccount, hostCannotRunMaestro, maestroAvailability, type HostCannotRunMaestro } from "../_shared/owner-maestro-availability.js";
34
+ import { clearAskRequest, isAskMaestroKind, pendingAskRequest, type AskMaestroKind } from "../_shared/owner-maestro-tab.js";
34
35
  import {
35
36
  chatDecisions, chatMessages, decisionIdsOf, linkCardOf, replyText, sendVerdict,
36
37
  type Decision, type LinkCard, type Verdict,
@@ -49,18 +50,15 @@ interface WixApi { call: (method: string, path: string, body?: unknown, headers?
49
50
  interface Host { wixApi?: WixApi; input?: Record<string, unknown> }
50
51
  const host = (): Host => (globalThis as { himalaya?: Host }).himalaya ?? {};
51
52
 
52
- /** The business the owner is looking at: the one the host has scoped, else the one the Sites
53
- * picker recorded (a host that has not scoped a business yet, as the web preview's sample
54
- * session never does). It is only ever an address: Symphony honours it for the account's own
53
+ /** The business the owner is looking at (`currentBusinessId`: the one picked on Sites, else the
54
+ * one the host scoped). It is only ever an address: Symphony honours it for the account's own
55
55
  * sites and nothing else. */
56
56
  function activeSiteId(): string {
57
- const v = host().input?.__himiPreferenceBusiness;
58
- const scoped = typeof v === "string" ? v.trim() : "";
59
- return scoped || readSelectedSite()?.id || "";
57
+ return currentBusinessId();
60
58
  }
61
59
 
62
60
 
63
- /** One transcript row: the owner's turn, Maestro's reply, the thinking line, or a card. The
61
+ /** One transcript row: the owner's turn, Maestro's reply, the thinking line, a note, or a card. The
64
62
  * `*Hidden` flags pick which part of the one row template shows. */
65
63
  export interface Bubble {
66
64
  id: string;
@@ -68,6 +66,8 @@ export interface Bubble {
68
66
  userHidden: string;
69
67
  assistantHidden: string;
70
68
  thinkingHidden: string;
69
+ /** A line about the chat itself, such as "Stopped". Not something Maestro said. */
70
+ noteHidden: string;
71
71
  cardHidden: string;
72
72
  cardTitle: string;
73
73
  cardText: string;
@@ -85,12 +85,14 @@ export interface Bubble {
85
85
  planVersion: string;
86
86
  }
87
87
  const NO_CARD = {
88
- cardHidden: "true", cardTitle: "", cardText: "", cardStatus: "", primaryLabel: "", primaryHidden: "true",
88
+ noteHidden: "true", cardHidden: "true", cardTitle: "", cardText: "", cardStatus: "", primaryLabel: "", primaryHidden: "true",
89
89
  secondaryLabel: "", secondaryHidden: "true", url: "", decisionId: "", verdictId: "", planVersion: "",
90
90
  } as const;
91
91
  const userBubble = (id: string, content: string): Bubble => ({ ...NO_CARD, id, content, userHidden: "false", assistantHidden: "true", thinkingHidden: "true" });
92
92
  const assistantBubble = (id: string, content: string): Bubble => ({ ...NO_CARD, id, content, userHidden: "true", assistantHidden: "false", thinkingHidden: "true" });
93
- const thinkingBubble = (): Bubble => ({ ...NO_CARD, id: THINKING_ID, content: "", userHidden: "true", assistantHidden: "true", thinkingHidden: "false" });
93
+ /** The one line that says Maestro is working. It names the step Maestro is on once it reports one. */
94
+ const thinkingBubble = (step = ""): Bubble => ({ ...NO_CARD, id: THINKING_ID, content: step || copy.thinking(), userHidden: "true", assistantHidden: "true", thinkingHidden: "false" });
95
+ const noteBubble = (id: string, content: string): Bubble => ({ ...NO_CARD, id, content, userHidden: "true", assistantHidden: "true", thinkingHidden: "true", noteHidden: "false" });
94
96
  const cardBubble = (id: string, card: Partial<Bubble>): Bubble =>
95
97
  ({ ...NO_CARD, id, content: "", userHidden: "true", assistantHidden: "true", thinkingHidden: "true", cardHidden: "false", ...card });
96
98
 
@@ -175,10 +177,12 @@ export interface MaestroState {
175
177
  noInput: boolean;
176
178
  busy: boolean;
177
179
  idle: boolean;
178
- /** What Maestro is doing right now ("" collapses the line). */
180
+ /** The step Maestro is on once its reply has started ("" collapses the line). Before that the
181
+ * thinking row says it, so the two never show together. */
179
182
  statusText: string;
180
- /** The item this chat was opened about ("" collapses the line). */
183
+ /** The item this chat was opened about, and whether that line shows. */
181
184
  contextLabel: string;
185
+ contextHidden: string;
182
186
  error: string;
183
187
  /** Changes on every send: the host's transcript scroll follows the new turn. */
184
188
  scrollSend: string;
@@ -206,7 +210,8 @@ export interface MaestroState {
206
210
 
207
211
  const copy = {
208
212
  greeting: () => copyParam("ownerMaestro.greeting", "Hi, I'm Maestro. Ask me to check on your business or to get something done."),
209
- thinking: () => copyParam("ownerMaestro.thinking", "Maestro is working on it…"),
213
+ thinking: () => copyParam("ownerMaestro.working", "Working on it…"),
214
+ stopped: () => copyParam("ownerMaestro.stopped", "You stopped waiting for this reply. Maestro may still finish the work."),
210
215
  failed: () => copyParam("ownerMaestro.failed", "Maestro couldn't answer. Try again in a moment."),
211
216
  historyFailed: () => copyParam("ownerMaestro.historyFailed", "That conversation couldn't be opened. Try again in a moment."),
212
217
  connectTitle: (name: string) => copyParam("ownerMaestro.connect.title", "Connect {name}").replace("{name}", name),
@@ -265,7 +270,31 @@ const copy = {
265
270
  },
266
271
  };
267
272
 
268
- function prompts(): Prompt[] {
273
+ type AskKind = AskMaestroKind;
274
+
275
+ /** The prompt cards of an empty chat: about the business, or about the item the chat was opened on. */
276
+ function prompts(kind: AskKind | "" = ""): Prompt[] {
277
+ if (kind === "order") {
278
+ return [
279
+ { id: "p1", title: copyParam("ownerMaestro.order.p1.title", "Summarize this order"), text: copyParam("ownerMaestro.order.p1.text", "Summarize this order for me.") },
280
+ { id: "p2", title: copyParam("ownerMaestro.order.p2.title", "What does it still need?"), text: copyParam("ownerMaestro.order.p2.text", "What does this order still need from me?") },
281
+ { id: "p3", title: copyParam("ownerMaestro.order.p3.title", "Draft a message to the customer"), text: copyParam("ownerMaestro.order.p3.text", "Draft a message to this order's customer and show it to me before sending.") },
282
+ ];
283
+ }
284
+ if (kind === "booking") {
285
+ return [
286
+ { id: "p1", title: copyParam("ownerMaestro.booking.p1.title", "Summarize this booking"), text: copyParam("ownerMaestro.booking.p1.text", "Summarize this booking for me.") },
287
+ { id: "p2", title: copyParam("ownerMaestro.booking.p2.title", "What does it still need?"), text: copyParam("ownerMaestro.booking.p2.text", "What does this booking still need from me?") },
288
+ { id: "p3", title: copyParam("ownerMaestro.booking.p3.title", "Draft a reminder"), text: copyParam("ownerMaestro.booking.p3.text", "Draft a reminder for this booking's customer and show it to me before sending.") },
289
+ ];
290
+ }
291
+ if (kind === "contact") {
292
+ return [
293
+ { id: "p1", title: copyParam("ownerMaestro.contact.p1.title", "Summarize this contact"), text: copyParam("ownerMaestro.contact.p1.text", "Summarize what you know about this contact.") },
294
+ { id: "p2", title: copyParam("ownerMaestro.contact.p2.title", "What have they bought or booked?"), text: copyParam("ownerMaestro.contact.p2.text", "What has this contact bought or booked with my business?") },
295
+ { id: "p3", title: copyParam("ownerMaestro.contact.p3.title", "Draft a message to them"), text: copyParam("ownerMaestro.contact.p3.text", "Draft a message to this contact and show it to me before sending.") },
296
+ ];
297
+ }
269
298
  return [
270
299
  { id: "p1", title: copyParam("ownerMaestro.p1.title", "Catch me up"), text: copyParam("ownerMaestro.p1.text", "Catch me up on what happened in my business since yesterday.") },
271
300
  { id: "p2", title: copyParam("ownerMaestro.p2.title", "What needs me today?"), text: copyParam("ownerMaestro.p2.text", "What needs my attention today?") },
@@ -277,7 +306,7 @@ const initial: MaestroState = {
277
306
  phase: "checking", checkingHidden: "false", chatHidden: "true", unavailableHidden: "true",
278
307
  unavailableTitle: "", unavailableText: "",
279
308
  messages: [], emptyHidden: "false", prompts: [], quickReplies: [], quickRepliesHidden: "true",
280
- input: "", hasInput: false, noInput: true, busy: false, idle: true, statusText: "", contextLabel: "", error: "", scrollSend: "", scrollAnchor: "", ok: false,
309
+ input: "", hasInput: false, noInput: true, busy: false, idle: true, statusText: "", contextLabel: "", contextHidden: "true", error: "", scrollSend: "", scrollAnchor: "", ok: false,
281
310
  _site: "", _account: "", _convId: "", _role: "", _openId: "", _openRaw: "", _turn: 0, _context: "", _decisionIds: [], _resumedId: "", _askKey: "",
282
311
  };
283
312
 
@@ -286,18 +315,55 @@ const inputString = (key: string): string => {
286
315
  return typeof v === "string" ? v.trim() : "";
287
316
  };
288
317
 
318
+ /** The kind of item an ask key names ("" for none): the key starts with it. */
319
+ const askKindOf = (key: string): AskKind | "" => {
320
+ const kind = key.split(":")[0];
321
+ return isAskMaestroKind(kind) ? kind : "";
322
+ };
323
+
324
+ interface Ask { key: string; kind: AskKind; id: string; subject: string }
325
+
289
326
  /** The item a detail screen opened this chat about. Only an order, a booking or a contact, and
290
- * only with an id: the id is what Maestro looks the item up by. */
291
- function askedAbout(): { key: string; label: string; context: string } | null {
327
+ * only with an id: the id is what Maestro looks the item up by. It arrives in the screen's own
328
+ * params (a pushed Maestro screen), or as a request the detail screen left before it switched
329
+ * to the Maestro tab; each request has its own stamp, so asking again about the same item is a
330
+ * new ask. */
331
+ function askedAbout(): Ask | null {
292
332
  const kind = inputString("kind");
293
333
  const id = inputString("id");
294
- if (!id || (kind !== "order" && kind !== "booking" && kind !== "contact")) return null;
295
- const subject = inputString("subject").slice(0, 80);
296
- return {
297
- key: `${kind}:${id}`,
298
- label: copy.about(kind, subject),
299
- context: `The owner opened this chat from the Owner app's ${kind} screen. It is about the ${kind} with id ${id}${subject ? ` ("${subject}")` : ""}. Unless they say otherwise, their questions are about that ${kind}.`,
300
- };
334
+ if (id && isAskMaestroKind(kind)) {
335
+ return { key: `${kind}:${id}`, kind, id, subject: inputString("subject").slice(0, 80) };
336
+ }
337
+ const request = pendingAskRequest(Date.now(), activeSiteId());
338
+ return request ? { key: `${request.kind}:${request.id}#${request.n}`, kind: request.kind, id: request.id, subject: request.subject.slice(0, 80) } : null;
339
+ }
340
+
341
+ /** Drop the request a chat was opened from, by the stamp its key carries (`kind:id#stamp`). A
342
+ * chat opened from screen params has no stamp and left no request. */
343
+ function dropAskRequest(askKey: string): void {
344
+ const stamp = Number(askKey.split("#")[1]);
345
+ if (askKey.includes("#") && Number.isFinite(stamp)) clearAskRequest(stamp);
346
+ }
347
+
348
+ const askLabel = (ask: Ask, subject: string): string => copy.about(ask.kind, subject);
349
+ const askContext = (ask: Ask, subject: string): string =>
350
+ `The owner opened this chat from the Owner app's ${ask.kind} screen. It is about the ${ask.kind} with id ${ask.id}${subject ? ` ("${subject}")` : ""}. Unless they say otherwise, their questions are about that ${ask.kind}.`;
351
+
352
+ /** A contact's name, for a chat opened about one. A detail screen never passes it: on the web
353
+ * host a screen's params are part of the address. Read here instead, from the business on
354
+ * screen. `read: false` when it could not be read: the chat then names the contact by what it
355
+ * is, and Maestro is given its id only. */
356
+ async function contactName(api: WixApi, id: string, site: string): Promise<{ read: boolean; name: string }> {
357
+ let res: { contact?: { info?: { name?: { first?: string; last?: string } }; primaryInfo?: { email?: string } } } | null;
358
+ try {
359
+ // The business is named: this tab's own connection may still be on another one.
360
+ res = (await api.call("GET", `https://www.wixapis.com/contacts/v4/contacts/${encodeURIComponent(id)}`, undefined, site ? { "wix-site-id": site } : undefined)) as typeof res;
361
+ } catch {
362
+ return { read: false, name: "" };
363
+ }
364
+ const name = res?.contact?.info?.name;
365
+ const full = [name?.first, name?.last].filter((part): part is string => typeof part === "string" && !!part.trim()).map((part) => part.trim()).join(" ");
366
+ return { read: true, name: (full || res?.contact?.primaryInfo?.email || "").slice(0, 80) };
301
367
  }
302
368
 
303
369
  // What the owner left with New chat. A screen pushed from history or from an item keeps its
@@ -382,9 +448,9 @@ let draft = "";
382
448
  let chatSeq = 0;
383
449
 
384
450
  const freshChat = (s: MaestroState, input = ""): MaestroState => ({
385
- ...s, messages: [], emptyHidden: "false", quickReplies: [], quickRepliesHidden: "true",
451
+ ...s, messages: [], emptyHidden: "false", prompts: prompts(), quickReplies: [], quickRepliesHidden: "true",
386
452
  input, hasInput: input.trim().length > 0, noInput: input.trim().length === 0,
387
- busy: false, idle: true, statusText: "", contextLabel: "", error: "", scrollSend: "", scrollAnchor: "",
453
+ busy: false, idle: true, statusText: "", contextLabel: "", contextHidden: "true", error: "", scrollSend: "", scrollAnchor: "",
388
454
  _convId: "", _role: "", _openId: "", _openRaw: "", _context: "", _decisionIds: [], _resumedId: "", _askKey: "",
389
455
  });
390
456
 
@@ -409,13 +475,15 @@ async function send(s: MaestroState, raw: string, choice?: { askId: string; opti
409
475
  if (!convId) return { ...s, ...typed, error: copy.failed() };
410
476
  }
411
477
  const typedMeanwhile = draftSeq !== draftAtSend;
478
+ // The chat a detail screen asked for is in use: the request has done its work.
479
+ dropAskRequest(s._askKey);
412
480
  const turn = s._turn + 1;
413
481
  const next: MaestroState = {
414
482
  ...s, _convId: convId, _turn: turn, _role: "", _openId: "", _openRaw: "", _decisionIds: [],
415
483
  messages: [...settled(s.messages), userBubble(`u${turn}`, text), thinkingBubble()],
416
484
  emptyHidden: "true", quickReplies: [], quickRepliesHidden: "true",
417
485
  input: "", hasInput: false, noInput: true, busy: true, idle: false,
418
- statusText: copy.thinking(), error: "", scrollSend: `turn-${turn}`, scrollAnchor: `${SCREEN}.message_u${turn}`, ok: false,
486
+ statusText: "", error: "", scrollSend: `turn-${turn}`, scrollAnchor: `${SCREEN}.message_u${turn}`, ok: false,
419
487
  };
420
488
  const kept: MaestroState = typedMeanwhile
421
489
  ? { ...next, input: draft, hasInput: draft.trim().length > 0, noInput: draft.trim().length === 0 }
@@ -460,6 +528,14 @@ async function endTurn(s: MaestroState, error = ""): Promise<MaestroState> {
460
528
  return { ...next, messages: withCards(next.messages, cards) };
461
529
  }
462
530
 
531
+ /** The step Maestro reports it is on. While the thinking row shows, the row says it; once the
532
+ * reply has started there is no such row, and the status line under the transcript says it. */
533
+ function withStep(s: MaestroState, line: string): MaestroState {
534
+ if (!line) return s;
535
+ if (!s.messages.some((b) => b.id === THINKING_ID)) return { ...s, statusText: line };
536
+ return { ...s, statusText: "", messages: s.messages.map((b) => (b.id === THINKING_ID ? thinkingBubble(line) : b)) };
537
+ }
538
+
463
539
  /** The cards one event names: a link is drawn at once, a decision is noted for the turn's end. */
464
540
  function withEventCards(s: MaestroState, data: Record<string, unknown>): MaestroState {
465
541
  const link = linkCardOf(data);
@@ -483,7 +559,11 @@ async function resume(api: WixApi, s: MaestroState, conversationId: string): Pro
483
559
  for (const id of m.decisionIds) if (!decisionIds.includes(id)) decisionIds.push(id);
484
560
  }
485
561
  messages = withCards(messages, await decisionCards(api, conversationId, decisionIds));
486
- return { ...freshChat(s), _convId: conversationId, messages, emptyHidden: messages.length ? "true" : "false" };
562
+ // A past chat opens on its latest message: a new token with no row to pin follows the end.
563
+ return {
564
+ ...freshChat(s), _convId: conversationId, messages, emptyHidden: messages.length ? "true" : "false",
565
+ scrollSend: messages.length ? `open-${conversationId}-${messages.length}` : "", scrollAnchor: "",
566
+ };
487
567
  }
488
568
 
489
569
  /** Answer a decision card. Refused while a turn streams: the card's result is built from the
@@ -565,7 +645,7 @@ const svc = defineService<MaestroState, {
565
645
  // A chat saved by a build without cards has rows with no card fields, and a missing
566
646
  // "hidden" reads as shown: each row is completed so no empty card is drawn.
567
647
  const rows = (s.busy ? s.messages : settled(s.messages)).map((b) => ({ ...NO_CARD, ...b }));
568
- ready = { ...s, prompts: prompts(), messages: rows };
648
+ ready = { ...s, prompts: prompts(askKindOf(s._askKey)), messages: rows, contextHidden: s.contextLabel ? "false" : "true" };
569
649
  } else {
570
650
  // The host could not say. A chat already open is kept (above); a new one is not opened.
571
651
  if (reads === "unknown") return unavailable(fresh, "unreachable");
@@ -602,7 +682,20 @@ const svc = defineService<MaestroState, {
602
682
  }
603
683
  const ask = past ? null : askedAbout();
604
684
  if (ask && ask.key !== leftAsk && ask.key !== ready._askKey) {
605
- return { ...freshChat(ready, ready.input), contextLabel: ask.label, _context: ask.context, _askKey: ask.key };
685
+ let subject = ask.subject;
686
+ if (!subject && ask.kind === "contact" && api) {
687
+ const chatAtStart = chatSeq;
688
+ const draftAtStart = draftSeq;
689
+ // As for a past chat: no send starts while the name is read, since this result would overwrite it.
690
+ reading += 1;
691
+ try { subject = (await contactName(api, ask.id, site)).name; } finally { reading -= 1; }
692
+ if (chatSeq !== chatAtStart) return freshChat(ready, draft);
693
+ ready = withDraftSince(ready, draftAtStart);
694
+ }
695
+ return {
696
+ ...freshChat(ready, ready.input), prompts: prompts(ask.kind),
697
+ contextLabel: askLabel(ask, subject), contextHidden: "false", _context: askContext(ask, subject), _askKey: ask.key,
698
+ };
606
699
  }
607
700
  return ready;
608
701
  },
@@ -627,7 +720,11 @@ const svc = defineService<MaestroState, {
627
720
  },
628
721
  // Local only, as in the Symphony iOS app: the turn keeps running on the server, and what it
629
722
  // still streams is dropped because nothing is in flight here any more.
630
- stop: async (s) => (s.busy ? endTurn(s) : s),
723
+ // The transcript says so, since nothing else would: without the note a stopped turn looks
724
+ // like a message Maestro ignored.
725
+ stop: async (s) => (s.busy
726
+ ? endTurn({ ...s, messages: [...settled(s.messages), noteBubble(`stopped_${s._turn}`, copy.stopped())] })
727
+ : s),
631
728
  newChat: async (s) => {
632
729
  if (s.phase !== "ready") return s;
633
730
  chatSeq += 1;
@@ -635,6 +732,8 @@ const svc = defineService<MaestroState, {
635
732
  draft = "";
636
733
  leftPastChat = s._resumedId || leftPastChat;
637
734
  leftAsk = s._askKey || leftAsk;
735
+ // The chat a detail screen asked for was left: a worker started later must not reopen it.
736
+ dropAskRequest(s._askKey);
638
737
  return freshChat(s);
639
738
  },
640
739
  // A card's one or two buttons. What they do depends on the card.
@@ -656,10 +755,7 @@ const svc = defineService<MaestroState, {
656
755
  if (ev?.type === "metadata") {
657
756
  return typeof data.conversationId === "string" && data.conversationId ? { ...s, _convId: data.conversationId } : s;
658
757
  }
659
- if (ev?.type === "thinking") {
660
- const line = (data.text ?? "").trim().split("\n").pop() ?? "";
661
- return line ? { ...s, statusText: line } : s;
662
- }
758
+ if (ev?.type === "thinking") return withStep(s, (data.text ?? "").trim().split("\n").pop() ?? "");
663
759
  if (ev?.type === "messageStart") {
664
760
  return { ...s, _role: typeof data.role === "string" ? data.role : "", _openId: "" };
665
761
  }
@@ -667,10 +763,7 @@ const svc = defineService<MaestroState, {
667
763
  const delta = typeof data.deltaText === "string" ? data.deltaText : "";
668
764
  if (!delta) return s;
669
765
  // Only the reply itself becomes a bubble; a step or a thought is the status line.
670
- if (s._role && s._role !== "ASSISTANT") {
671
- const line = delta.trim().split("\n").pop() ?? "";
672
- return line ? { ...s, statusText: line } : s;
673
- }
766
+ if (s._role && s._role !== "ASSISTANT") return withStep(s, delta.trim().split("\n").pop() ?? "");
674
767
  const messages = settled(s.messages);
675
768
  const open = messages.findIndex((b) => b.id === s._openId);
676
769
  if (open >= 0) {
@@ -5,10 +5,10 @@
5
5
  // messages itself. Nothing is cached here: storage is shared by everyone who signs in on the
6
6
  // device, and a business id is not an account.
7
7
 
8
- import { formatMonthDay } from "../_shared/engine-intl.js";
8
+ import { formatClock, formatMonthDayTime } from "../_shared/engine-intl.js";
9
9
  import { defineService } from "@himalaya/state";
10
10
  import { copyParam, stashCopy } from "../_shared/himi-copy.js";
11
- import { readSelectedSite } from "../_shared/owner-selected-site.js";
11
+ import { currentBusinessId } from "../_shared/owner-selected-site.js";
12
12
  import { symphonyAccount, type MaestroWixApi } from "../_shared/owner-maestro-availability.js";
13
13
  import { pastChats, type PastChat } from "../_shared/owner-maestro-chat.js";
14
14
 
@@ -17,9 +17,7 @@ const host = (): Host => (globalThis as { himalaya?: Host }).himalaya ?? {};
17
17
 
18
18
  /** The same business the Maestro screen talks about. */
19
19
  function activeSiteId(): string {
20
- const v = host().input?.__himiPreferenceBusiness;
21
- const scoped = typeof v === "string" ? v.trim() : "";
22
- return scoped || readSelectedSite()?.id || "";
20
+ return currentBusinessId();
23
21
  }
24
22
 
25
23
  /** `stamp` marks the list a row was shown in, so opening the same chat from a later list is a new request. */
@@ -53,10 +51,14 @@ function bucketOf(updated: string, now: number): string {
53
51
  return copyParam("ownerMaestroHistory.older", "Older");
54
52
  }
55
53
 
56
- function dayLabel(updated: string): string {
54
+ /** When a chat was last active: the time for one from today, whose rows would otherwise all
55
+ * read the same date; the date and the time for an older one. */
56
+ function whenLabel(updated: string, now: number): string {
57
57
  const at = Date.parse(updated);
58
58
  if (Number.isNaN(at)) return "";
59
- return formatMonthDay(new Date(at));
59
+ const midnight = new Date(now);
60
+ midnight.setHours(0, 0, 0, 0);
61
+ return at >= midnight.getTime() ? formatClock(new Date(at)) : formatMonthDayTime(new Date(at));
60
62
  }
61
63
 
62
64
  /** Rows in the order given, with the bucket named on the first row of each bucket only. */
@@ -66,7 +68,7 @@ function rowsOf(chats: PastChat[], now: number): HistoryRow[] {
66
68
  const bucket = bucketOf(c.updated, now);
67
69
  const section = bucket === last ? "" : bucket;
68
70
  last = bucket;
69
- return { id: c.id, title: c.title || copyParam("ownerMaestroHistory.untitled", "Untitled conversation"), subtitle: dayLabel(c.updated), section, stamp: String(now) };
71
+ return { id: c.id, title: c.title || copyParam("ownerMaestroHistory.untitled", "Untitled conversation"), subtitle: whenLabel(c.updated, now), section, stamp: String(now) };
70
72
  });
71
73
  }
72
74
 
@@ -9,7 +9,7 @@
9
9
  import { defineService } from "@himalaya/state";
10
10
  import { getOrder, type WixOrder, type WixOrderLineItem } from "@himalaya/wix-ecom";
11
11
  import { ownerLoadError, isOwnerPreviewDemo, ownerDemoFallback } from "../_shared/owner-load-error.js";
12
- import { askMaestroHidden } from "../_shared/owner-maestro-tab.js";
12
+ import { askMaestroHidden, askMaestroNav } from "../_shared/owner-maestro-tab.js";
13
13
  import { DEMO_ORDERS, DEMO_NOTE, demoOrderDate } from "../_shared/owner-preview-demo.js";
14
14
  import { stashCopy, copyParam } from "../_shared/himi-copy.js";
15
15
  import { formatDateMedium } from "../_shared/engine-intl.js";
@@ -287,9 +287,12 @@ const svc = defineService<OrderState, {
287
287
  follow: (s: OrderState) => OrderState | undefined;
288
288
  onFollowStarted: (s: OrderState, activityId?: string) => OrderState;
289
289
  unfollow: (s: OrderState) => OrderState;
290
+ askMaestro: (s: OrderState) => OrderState;
290
291
  }>("himiOwnerLiteOrder", {
291
292
  state: shape({ status: "loading" }),
292
293
  actions: {
294
+ // "Ask Maestro": the chat opens on the Maestro tab, about this order.
295
+ askMaestro: (s) => askMaestroNav(s, { kind: "order", id: s.id, subject: s.title }),
293
296
  load: async (s, arg) => {
294
297
  stashCopy(arg); // absorb the descriptor's onAppear copy-pack param
295
298
  const id = idFrom(arg, s.id) || inputId();
@@ -2,7 +2,7 @@ import { defineService } from '@himalaya/state';
2
2
  import { getOwnerRecord, ownerModuleError, type OwnerRecord } from '../_shared/owner-module-data.js';
3
3
  import { ownerInput, inputOwnerModule, openOwnerDashboard } from '../_shared/owner-module-runtime.js';
4
4
  import { stashCopy, copyParam } from '../_shared/himi-copy.js';
5
- import { askMaestroHidden } from '../_shared/owner-maestro-tab.js';
5
+ import { askMaestroHidden, askMaestroNav } from '../_shared/owner-maestro-tab.js';
6
6
  const moduleId = inputOwnerModule();
7
7
  interface State {
8
8
  /** The record on screen, so the screen can name it to another screen. */
@@ -18,6 +18,12 @@ const svc = defineService('himiOwnerRecord', {
18
18
  state: { id: '', askMaestroHidden: 'true', status: 'loading', title: '', subtitle: '', image: '', noImage: true, statusLabel: '', fields: [], error: '',
19
19
  notLoading: false, notErrored: true, hideContent: true, handoffError: '' } as State,
20
20
  actions: {
21
+ // "Ask Maestro": the chat opens on the Maestro tab, about this record.
22
+ // The screen says what kind of record this is (only a contact's detail has the button). No
23
+ // subject: a contact's title is a person's name, which the Maestro worker reads itself.
24
+ askMaestro(state: State, arg?: unknown): State {
25
+ return askMaestroNav(state, { kind: (arg as { kind?: unknown } | undefined)?.kind, id: state.id });
26
+ },
21
27
  async load(state: State, arg?: unknown): Promise<State | undefined> {
22
28
  stashCopy(arg);
23
29
  const revision = ++generation;
@@ -13,7 +13,7 @@ import { formatWeekdayDateTime } from "../_shared/engine-intl.js";
13
13
  import { ownerLoadError, isBridgeUnavailable, isOwnerPreviewDemo } from "../_shared/owner-load-error.js";
14
14
  import { DEMO_APPOINTMENTS, DEMO_NOTE, demoAppointmentWindow } from "../_shared/owner-preview-demo.js";
15
15
  import { copyParam } from "../_shared/himi-copy.js";
16
- import { askMaestroHidden } from "../_shared/owner-maestro-tab.js";
16
+ import { askMaestroHidden, askMaestroNav } from "../_shared/owner-maestro-tab.js";
17
17
 
18
18
  interface ActionRow { id: string; label: string; action: string; url: string; screen: string; title: string; }
19
19
  interface KV { id: string; label: string; value: string; }
@@ -206,9 +206,12 @@ const svc = defineService<BookingState, {
206
206
  markPaid: (s: BookingState) => Promise<BookingState>;
207
207
  setAttended: (s: BookingState) => Promise<BookingState>;
208
208
  setNoShow: (s: BookingState) => Promise<BookingState>;
209
+ askMaestro: (s: BookingState) => BookingState;
209
210
  }>("ownerBooking", {
210
211
  state: { id: "", askMaestroHidden: "true", status: "loading", title: "", subtitle: "", initial: "?", when: "—", ends: "—", participants: "—", email: "—", phone: "—", staff: "—", location: "", locationHeader: "", videoLabel: "", videoUrl: "", intakeHeader: "", intake: "", actions: [], bookingStatus: "—", payment: "—", statusRaw: "", paymentRaw: "", orderId: "", isClass: false, attendedRaw: false, hideConfirm: true, hideMarkPaid: true, hideAttendance: true, hideDecline: true, hideCancel: true, revision: "", actionError: "", error: "", demoNote: "", notDemo: true },
211
212
  actions: {
213
+ // "Ask Maestro": the chat opens on the Maestro tab, about this booking.
214
+ askMaestro: (s) => askMaestroNav(s, { kind: "booking", id: s.id, subject: s.title }),
212
215
  load: async (s) => {
213
216
  try { return { ...(await fetchInto(s)), id: bookingId(), askMaestroHidden: askMaestroHidden() }; }
214
217
  catch (e) {
@@ -146,7 +146,7 @@ const CODED = /HTTP (\d{3}) \[([A-Z0-9_]+)\]/;
146
146
  * `HTTP 428 [MISSING_METASITE_ID]: Couldn't extract metasiteId from the request
147
147
  * context` where "6 orders" belongs.
148
148
  */
149
- const SITE_CONTEXT_CODES = ["MISSING_METASITE_ID", "MISSING_REQUEST_SITE_CONTEXT", "MISSING_SITE_CONTEXT"];
149
+ export const SITE_CONTEXT_CODES = ["MISSING_METASITE_ID", "MISSING_REQUEST_SITE_CONTEXT", "MISSING_SITE_CONTEXT"];
150
150
  /** Longest raw upstream text worth showing. Beyond this it stops being a
151
151
  * message and starts being a payload dump. */
152
152
  const MAX_RAW = 200;