@wix/himalaya-cli 0.1928.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.
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/dev-server/src/builder.d.ts +2 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/schema.d.ts +7 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/chat-web/src/index.d.ts +12 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-chat-web.mjs +19 -9
- package/dist/browser-plane/assets.json +5 -5
- package/dist/browser-plane/preview-deferred/{95a3ae045bad903e458ea7a5800e60e1044f0f754a65d7127de66ba62e897068.bin → 7656e5effbeaee2ab20810b9903e7e785d9dffb0a0563f25c2746011cf4e23e9.bin} +1 -1
- package/dist/browser-plane/sw.js +10 -10
- package/dist/cli.mjs +256 -70
- package/dist/preview-assets.generated.bin +0 -0
- package/guides/component-index.md +1 -1
- package/guides/component-reference.json +1 -1
- package/guides/component-reference.md +7 -0
- package/guides/sdk-reference.json +2 -2
- package/package.json +2 -2
- package/templates/bare-fashion/tier5-src/_shared/owner-load-error.ts +1 -1
- package/templates/beauty-salon/tier5-src/_shared/owner-load-error.ts +1 -1
- package/templates/beauty-salon-owner/dev/index.ts +169 -139
- package/templates/beauty-salon-owner/tier5-src/_shared/owner-load-error.ts +1 -1
- package/templates/beauty-salon-owner/tier5-src/_shared/owner-maestro-availability.ts +12 -2
- package/templates/beauty-salon-owner/tier5-src/_shared/owner-maestro-tab.ts +81 -5
- package/templates/beauty-salon-owner/tier5-src/_shared/owner-selected-site.ts +15 -0
- package/templates/beauty-salon-owner/tier5-src/_shared/owner-widget-reads.ts +7 -0
- package/templates/beauty-salon-owner/tier5-src/himi-owner-lite-home/index.ts +30 -8
- package/templates/beauty-salon-owner/tier5-src/himi-owner-lite-inbox/index.ts +47 -8
- package/templates/beauty-salon-owner/tier5-src/himi-owner-lite-inbox-thread/index.ts +12 -5
- package/templates/beauty-salon-owner/tier5-src/himi-owner-lite-maestro/index.ts +132 -39
- package/templates/beauty-salon-owner/tier5-src/himi-owner-lite-maestro-history/index.ts +10 -8
- package/templates/beauty-salon-owner/tier5-src/himi-owner-lite-order/index.ts +4 -1
- package/templates/beauty-salon-owner/tier5-src/himi-owner-lite-record/index.ts +7 -1
- package/templates/beauty-salon-owner/tier5-src/wix-owner-booking/index.ts +4 -1
- package/templates/branded-lite/tier5-src/_shared/owner-load-error.ts +1 -1
- package/templates/brandy/tier5-src/_shared/owner-load-error.ts +1 -1
- package/templates/community-club/tier5-src/_shared/owner-load-error.ts +1 -1
- package/templates/community-club-owner/dev/index.ts +167 -132
- package/templates/community-club-owner/tier5-src/_shared/owner-load-error.ts +1 -1
- package/templates/community-club-owner/tier5-src/_shared/owner-maestro-availability.ts +12 -2
- package/templates/community-club-owner/tier5-src/_shared/owner-maestro-tab.ts +81 -5
- package/templates/community-club-owner/tier5-src/_shared/owner-selected-site.ts +15 -0
- package/templates/community-club-owner/tier5-src/_shared/owner-widget-reads.ts +7 -0
- package/templates/community-club-owner/tier5-src/himi-owner-lite-home/index.ts +30 -8
- package/templates/community-club-owner/tier5-src/himi-owner-lite-inbox/index.ts +47 -8
- package/templates/community-club-owner/tier5-src/himi-owner-lite-inbox-thread/index.ts +12 -5
- package/templates/community-club-owner/tier5-src/himi-owner-lite-maestro/index.ts +132 -39
- package/templates/community-club-owner/tier5-src/himi-owner-lite-maestro-history/index.ts +10 -8
- package/templates/community-club-owner/tier5-src/himi-owner-lite-order/index.ts +4 -1
- package/templates/community-club-owner/tier5-src/himi-owner-lite-record/index.ts +7 -1
- package/templates/conference/tier5-src/_shared/owner-load-error.ts +1 -1
- package/templates/events-meetups/tier5-src/_shared/owner-load-error.ts +1 -1
- package/templates/events-meetups-owner/dev/index.ts +165 -125
- package/templates/events-meetups-owner/tier5-src/_shared/owner-load-error.ts +1 -1
- package/templates/events-meetups-owner/tier5-src/_shared/owner-maestro-availability.ts +12 -2
- package/templates/events-meetups-owner/tier5-src/_shared/owner-maestro-tab.ts +81 -5
- package/templates/events-meetups-owner/tier5-src/_shared/owner-selected-site.ts +15 -0
- package/templates/events-meetups-owner/tier5-src/_shared/owner-widget-reads.ts +7 -0
- package/templates/events-meetups-owner/tier5-src/himi-owner-lite-home/index.ts +30 -8
- package/templates/events-meetups-owner/tier5-src/himi-owner-lite-inbox/index.ts +47 -8
- package/templates/events-meetups-owner/tier5-src/himi-owner-lite-inbox-thread/index.ts +12 -5
- package/templates/events-meetups-owner/tier5-src/himi-owner-lite-maestro/index.ts +132 -39
- package/templates/events-meetups-owner/tier5-src/himi-owner-lite-maestro-history/index.ts +10 -8
- package/templates/events-meetups-owner/tier5-src/himi-owner-lite-record/index.ts +7 -1
- package/templates/fitness-gym/tier5-src/_shared/owner-load-error.ts +1 -1
- package/templates/gym-fitness/tier5-src/_shared/owner-load-error.ts +1 -1
- package/templates/gym-fitness-owner/dev/index.ts +169 -139
- package/templates/gym-fitness-owner/tier5-src/_shared/owner-load-error.ts +1 -1
- package/templates/gym-fitness-owner/tier5-src/_shared/owner-maestro-availability.ts +12 -2
- package/templates/gym-fitness-owner/tier5-src/_shared/owner-maestro-tab.ts +81 -5
- package/templates/gym-fitness-owner/tier5-src/_shared/owner-selected-site.ts +15 -0
- package/templates/gym-fitness-owner/tier5-src/_shared/owner-widget-reads.ts +7 -0
- package/templates/gym-fitness-owner/tier5-src/himi-owner-lite-home/index.ts +30 -8
- package/templates/gym-fitness-owner/tier5-src/himi-owner-lite-inbox/index.ts +47 -8
- package/templates/gym-fitness-owner/tier5-src/himi-owner-lite-inbox-thread/index.ts +12 -5
- package/templates/gym-fitness-owner/tier5-src/himi-owner-lite-maestro/index.ts +132 -39
- package/templates/gym-fitness-owner/tier5-src/himi-owner-lite-maestro-history/index.ts +10 -8
- package/templates/gym-fitness-owner/tier5-src/himi-owner-lite-order/index.ts +4 -1
- package/templates/gym-fitness-owner/tier5-src/himi-owner-lite-record/index.ts +7 -1
- package/templates/gym-fitness-owner/tier5-src/wix-owner-booking/index.ts +4 -1
- package/templates/himi-chat/tier5-src/_shared/owner-load-error.ts +1 -1
- package/templates/medical-services/tier5-src/_shared/owner-load-error.ts +1 -1
- package/templates/nonprofit-cause/tier5-src/_shared/owner-load-error.ts +1 -1
- package/templates/nonprofit-cause-owner/dev/index.ts +167 -132
- package/templates/nonprofit-cause-owner/tier5-src/_shared/owner-load-error.ts +1 -1
- package/templates/nonprofit-cause-owner/tier5-src/_shared/owner-maestro-availability.ts +12 -2
- package/templates/nonprofit-cause-owner/tier5-src/_shared/owner-maestro-tab.ts +81 -5
- package/templates/nonprofit-cause-owner/tier5-src/_shared/owner-selected-site.ts +15 -0
- package/templates/nonprofit-cause-owner/tier5-src/_shared/owner-widget-reads.ts +7 -0
- package/templates/nonprofit-cause-owner/tier5-src/himi-owner-lite-home/index.ts +30 -8
- package/templates/nonprofit-cause-owner/tier5-src/himi-owner-lite-inbox/index.ts +47 -8
- package/templates/nonprofit-cause-owner/tier5-src/himi-owner-lite-inbox-thread/index.ts +12 -5
- package/templates/nonprofit-cause-owner/tier5-src/himi-owner-lite-maestro/index.ts +132 -39
- package/templates/nonprofit-cause-owner/tier5-src/himi-owner-lite-maestro-history/index.ts +10 -8
- package/templates/nonprofit-cause-owner/tier5-src/himi-owner-lite-record/index.ts +7 -1
- package/templates/nonprofit-cause-owner/tier5-src/wix-owner-booking/index.ts +4 -1
- package/templates/owner-lite/dev/index.ts +171 -141
- package/templates/owner-lite/himalaya.content.json +1 -1
- package/templates/owner-lite/tier5-src/_shared/owner-load-error.ts +1 -1
- package/templates/owner-lite/tier5-src/_shared/owner-maestro-availability.ts +12 -2
- package/templates/owner-lite/tier5-src/_shared/owner-maestro-tab.ts +81 -5
- package/templates/owner-lite/tier5-src/_shared/owner-selected-site.ts +15 -0
- package/templates/owner-lite/tier5-src/_shared/owner-widget-reads.ts +7 -0
- package/templates/owner-lite/tier5-src/himi-owner-lite-home/index.ts +30 -8
- package/templates/owner-lite/tier5-src/himi-owner-lite-inbox/index.ts +47 -8
- package/templates/owner-lite/tier5-src/himi-owner-lite-inbox-thread/index.ts +12 -5
- package/templates/owner-lite/tier5-src/himi-owner-lite-maestro/index.ts +132 -39
- package/templates/owner-lite/tier5-src/himi-owner-lite-maestro-history/index.ts +10 -8
- package/templates/owner-lite/tier5-src/himi-owner-lite-order/index.ts +4 -1
- package/templates/owner-lite/tier5-src/himi-owner-lite-record/index.ts +7 -1
- package/templates/owner-lite/tier5-src/wix-owner-booking/index.ts +4 -1
- package/templates/personal-fitness-trainer/tier5-src/_shared/owner-load-error.ts +1 -1
- package/templates/podcast-creator/tier5-src/_shared/owner-load-error.ts +1 -1
- package/templates/podcast-creator-owner/dev/index.ts +167 -132
- package/templates/podcast-creator-owner/tier5-src/_shared/owner-load-error.ts +1 -1
- package/templates/podcast-creator-owner/tier5-src/_shared/owner-maestro-availability.ts +12 -2
- package/templates/podcast-creator-owner/tier5-src/_shared/owner-maestro-tab.ts +81 -5
- package/templates/podcast-creator-owner/tier5-src/_shared/owner-selected-site.ts +15 -0
- package/templates/podcast-creator-owner/tier5-src/_shared/owner-widget-reads.ts +7 -0
- package/templates/podcast-creator-owner/tier5-src/himi-owner-lite-home/index.ts +30 -8
- package/templates/podcast-creator-owner/tier5-src/himi-owner-lite-inbox/index.ts +47 -8
- package/templates/podcast-creator-owner/tier5-src/himi-owner-lite-inbox-thread/index.ts +12 -5
- package/templates/podcast-creator-owner/tier5-src/himi-owner-lite-maestro/index.ts +132 -39
- package/templates/podcast-creator-owner/tier5-src/himi-owner-lite-maestro-history/index.ts +10 -8
- package/templates/podcast-creator-owner/tier5-src/himi-owner-lite-order/index.ts +4 -1
- package/templates/podcast-creator-owner/tier5-src/himi-owner-lite-record/index.ts +7 -1
- package/templates/portfolio-creative/tier5-src/_shared/owner-load-error.ts +1 -1
- package/templates/portfolio-creative-owner/dev/index.ts +169 -139
- package/templates/portfolio-creative-owner/tier5-src/_shared/owner-load-error.ts +1 -1
- package/templates/portfolio-creative-owner/tier5-src/_shared/owner-maestro-availability.ts +12 -2
- package/templates/portfolio-creative-owner/tier5-src/_shared/owner-maestro-tab.ts +81 -5
- package/templates/portfolio-creative-owner/tier5-src/_shared/owner-selected-site.ts +15 -0
- package/templates/portfolio-creative-owner/tier5-src/_shared/owner-widget-reads.ts +7 -0
- package/templates/portfolio-creative-owner/tier5-src/himi-owner-lite-home/index.ts +30 -8
- package/templates/portfolio-creative-owner/tier5-src/himi-owner-lite-inbox/index.ts +47 -8
- package/templates/portfolio-creative-owner/tier5-src/himi-owner-lite-inbox-thread/index.ts +12 -5
- package/templates/portfolio-creative-owner/tier5-src/himi-owner-lite-maestro/index.ts +132 -39
- package/templates/portfolio-creative-owner/tier5-src/himi-owner-lite-maestro-history/index.ts +10 -8
- package/templates/portfolio-creative-owner/tier5-src/himi-owner-lite-order/index.ts +4 -1
- package/templates/portfolio-creative-owner/tier5-src/himi-owner-lite-record/index.ts +7 -1
- package/templates/portfolio-creative-owner/tier5-src/wix-owner-booking/index.ts +4 -1
- package/templates/professional-services/tier5-src/_shared/owner-load-error.ts +1 -1
- package/templates/restaurant/tier5-src/_shared/owner-load-error.ts +1 -1
- package/templates/restaurant-owner/dev/index.ts +169 -139
- package/templates/restaurant-owner/tier5-src/_shared/owner-load-error.ts +1 -1
- package/templates/restaurant-owner/tier5-src/_shared/owner-maestro-availability.ts +12 -2
- package/templates/restaurant-owner/tier5-src/_shared/owner-maestro-tab.ts +81 -5
- package/templates/restaurant-owner/tier5-src/_shared/owner-selected-site.ts +15 -0
- package/templates/restaurant-owner/tier5-src/_shared/owner-widget-reads.ts +7 -0
- package/templates/restaurant-owner/tier5-src/himi-owner-lite-home/index.ts +30 -8
- package/templates/restaurant-owner/tier5-src/himi-owner-lite-inbox/index.ts +47 -8
- package/templates/restaurant-owner/tier5-src/himi-owner-lite-inbox-thread/index.ts +12 -5
- package/templates/restaurant-owner/tier5-src/himi-owner-lite-maestro/index.ts +132 -39
- package/templates/restaurant-owner/tier5-src/himi-owner-lite-maestro-history/index.ts +10 -8
- package/templates/restaurant-owner/tier5-src/himi-owner-lite-order/index.ts +4 -1
- package/templates/restaurant-owner/tier5-src/himi-owner-lite-record/index.ts +7 -1
- package/templates/restaurant-owner/tier5-src/wix-owner-booking/index.ts +4 -1
- package/templates/retail-store/tier5-src/_shared/owner-load-error.ts +1 -1
- package/templates/retail-store-owner/dev/index.ts +167 -132
- package/templates/retail-store-owner/tier5-src/_shared/owner-load-error.ts +1 -1
- package/templates/retail-store-owner/tier5-src/_shared/owner-maestro-availability.ts +12 -2
- package/templates/retail-store-owner/tier5-src/_shared/owner-maestro-tab.ts +81 -5
- package/templates/retail-store-owner/tier5-src/_shared/owner-selected-site.ts +15 -0
- package/templates/retail-store-owner/tier5-src/_shared/owner-widget-reads.ts +7 -0
- package/templates/retail-store-owner/tier5-src/himi-owner-lite-home/index.ts +30 -8
- package/templates/retail-store-owner/tier5-src/himi-owner-lite-inbox/index.ts +47 -8
- package/templates/retail-store-owner/tier5-src/himi-owner-lite-inbox-thread/index.ts +12 -5
- package/templates/retail-store-owner/tier5-src/himi-owner-lite-maestro/index.ts +132 -39
- package/templates/retail-store-owner/tier5-src/himi-owner-lite-maestro-history/index.ts +10 -8
- package/templates/retail-store-owner/tier5-src/himi-owner-lite-order/index.ts +4 -1
- package/templates/retail-store-owner/tier5-src/himi-owner-lite-record/index.ts +7 -1
- package/templates/salon-spa/tier5-src/_shared/owner-load-error.ts +1 -1
- package/templates/wholesale-store/tier5-src/_shared/owner-load-error.ts +1 -1
- package/templates/yoga-studio/tier5-src/_shared/owner-load-error.ts +1 -1
- package/templates/yoga-studio-owner/dev/index.ts +167 -132
- package/templates/yoga-studio-owner/tier5-src/_shared/owner-load-error.ts +1 -1
- package/templates/yoga-studio-owner/tier5-src/_shared/owner-maestro-availability.ts +12 -2
- package/templates/yoga-studio-owner/tier5-src/_shared/owner-maestro-tab.ts +81 -5
- package/templates/yoga-studio-owner/tier5-src/_shared/owner-selected-site.ts +15 -0
- package/templates/yoga-studio-owner/tier5-src/_shared/owner-widget-reads.ts +7 -0
- package/templates/yoga-studio-owner/tier5-src/himi-owner-lite-home/index.ts +30 -8
- package/templates/yoga-studio-owner/tier5-src/himi-owner-lite-inbox/index.ts +47 -8
- package/templates/yoga-studio-owner/tier5-src/himi-owner-lite-inbox-thread/index.ts +12 -5
- package/templates/yoga-studio-owner/tier5-src/himi-owner-lite-maestro/index.ts +132 -39
- package/templates/yoga-studio-owner/tier5-src/himi-owner-lite-maestro-history/index.ts +10 -8
- package/templates/yoga-studio-owner/tier5-src/himi-owner-lite-record/index.ts +7 -1
- 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 {
|
|
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
|
|
53
|
-
*
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
/**
|
|
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
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
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 (
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
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:
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 {
|
|
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 {
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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:
|
|
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;
|
|
@@ -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;
|
|
@@ -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;
|