@nivaro/react 0.2.56 → 0.3.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/components/slots/TasksSlot.js +31 -29
- package/dist/full.css +1 -1
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/index.d.ts +73 -1
- package/dist/index.js +515 -505
- package/dist/shared/components/ItemEditForm.js +666 -658
- package/dist/shared/components/MyWorkView.js +47 -37
- package/dist/shared/components/ProfileView.js +163 -144
- package/dist/shared/components/ai/AiPlanCard.js +427 -0
- package/dist/shared/components/ai/AiPlanChanges.js +117 -0
- package/dist/shared/components/ai/TaskDo.js +1022 -0
- package/dist/shared/components/chat/ChatAnalyticsView.js +19 -17
- package/dist/shared/components/chat/ChatPanel.js +1356 -1317
- package/dist/shared/components/chat/HuddleAnalyticsTab.js +198 -0
- package/dist/shared/components/chat/RoomHeaderMenu.js +78 -65
- package/dist/shared/components/chat/chat-core.js +273 -264
- package/dist/shared/components/chat/huddle/HuddleAudioUi.js +397 -0
- package/dist/shared/components/chat/huddle/HuddleCallBar.js +296 -0
- package/dist/shared/components/chat/huddle/HuddleCallLayer.js +180 -0
- package/dist/shared/components/chat/huddle/HuddleCamera.js +124 -0
- package/dist/shared/components/chat/huddle/HuddleCollab.js +320 -0
- package/dist/shared/components/chat/huddle/HuddleControls.js +82 -121
- package/dist/shared/components/chat/huddle/HuddleDraw.js +231 -0
- package/dist/shared/components/chat/huddle/HuddleLiveBadge.js +52 -0
- package/dist/shared/components/chat/huddle/HuddlePeoplePicker.js +143 -0
- package/dist/shared/components/chat/huddle/HuddleScheduleCard.js +190 -0
- package/dist/shared/components/chat/huddle/HuddleScheduleForm.js +188 -0
- package/dist/shared/components/chat/huddle/HuddleStage.js +184 -89
- package/dist/shared/components/chat/huddle/HuddleStageTools.js +197 -0
- package/dist/shared/components/chat/huddle/huddle-audio-logic.js +156 -0
- package/dist/shared/components/chat/huddle/huddle-audio.js +69 -0
- package/dist/shared/components/chat/huddle/huddle-calls.js +129 -0
- package/dist/shared/components/chat/huddle/huddle-camera.js +143 -0
- package/dist/shared/components/chat/huddle/huddle-collab-store.js +391 -0
- package/dist/shared/components/chat/huddle/huddle-device-prefs.js +55 -0
- package/dist/shared/components/chat/huddle/huddle-devices.js +99 -0
- package/dist/shared/components/chat/huddle/huddle-draw.js +226 -0
- package/dist/shared/components/chat/huddle/huddle-follow-bus.js +96 -0
- package/dist/shared/components/chat/huddle/huddle-hold.js +62 -0
- package/dist/shared/components/chat/huddle/huddle-link-quality.js +159 -0
- package/dist/shared/components/chat/huddle/huddle-live.js +82 -0
- package/dist/shared/components/chat/huddle/huddle-pip.js +343 -0
- package/dist/shared/components/chat/huddle/huddle-quality.js +22 -0
- package/dist/shared/components/chat/huddle/huddle-reactions.js +71 -0
- package/dist/shared/components/chat/huddle/huddle-ring-refused.js +34 -0
- package/dist/shared/components/chat/huddle/huddle-schedule.js +102 -0
- package/dist/shared/components/chat/huddle/huddle-sfu.js +176 -0
- package/dist/shared/components/chat/huddle/huddle-shortcuts.js +91 -0
- package/dist/shared/components/chat/huddle/huddle-speaking.js +100 -0
- package/dist/shared/components/chat/huddle/huddle-store.js +431 -157
- package/dist/shared/components/chat/huddle/useHuddle.js +46 -38
- package/dist/shared/components/chat/huddle/useHuddleAudio.js +35 -0
- package/dist/shared/components/item-edit/GroupSection.js +1 -0
- package/dist/shared/components/item-edit/RecordChatActions.js +68 -59
- package/dist/shared/components/item-edit/UserChip.js +145 -142
- package/dist/shared/components/panels/TaskPanel.js +51 -49
- package/dist/shared/components/support/TicketDetailSheet.js +57 -42
- package/dist/shared/lib/notification-sound.js +25 -16
- package/package.json +2 -1
|
@@ -0,0 +1,1022 @@
|
|
|
1
|
+
import { jsxs as a, jsx as t, Fragment as Z } from "react/jsx-runtime";
|
|
2
|
+
import { useQueryClient as ae, useQuery as B, useMutation as L } from "@tanstack/react-query";
|
|
3
|
+
import { Sparkles as Y, Loader2 as R, CircleSlash as J, RotateCcw as se, Clock as ne, Check as O, MessageSquareText as ue, Undo2 as re, Pencil as me, Trash2 as pe, AlertTriangle as he, ShieldCheck as ie } from "lucide-react";
|
|
4
|
+
import { useState as k, useEffect as xe, useMemo as fe } from "react";
|
|
5
|
+
import { useOptionalNivaroClient as Q, useItemEditAuth as ge } from "../../context.js";
|
|
6
|
+
import { get as V, post as M, patch as ve } from "../../lib/commands.js";
|
|
7
|
+
import { cn as U } from "../../lib/utils.js";
|
|
8
|
+
import { Button as b } from "../ui/button.js";
|
|
9
|
+
import { Input as oe } from "../ui/input.js";
|
|
10
|
+
import { Popover as Ne, PopoverTrigger as ke, PopoverContent as be } from "../ui/popover.js";
|
|
11
|
+
import { SimpleSelect as ye } from "../ui/SimpleSelect.js";
|
|
12
|
+
import { Skeleton as z } from "../ui/skeleton.js";
|
|
13
|
+
import { Textarea as le } from "../ui/textarea.js";
|
|
14
|
+
import { AiPlanCard as we } from "./AiPlanCard.js";
|
|
15
|
+
const $e = /* @__PURE__ */ new Set(["proposed", "scheduled", "running", "paused", "failed", "executed"]), _e = {
|
|
16
|
+
send_message: ["subject", "message"],
|
|
17
|
+
create_task: ["title", "due_date", "priority"]
|
|
18
|
+
};
|
|
19
|
+
function q(e) {
|
|
20
|
+
var n;
|
|
21
|
+
return ((n = e == null ? void 0 : e.response) == null ? void 0 : n.error) ?? ((e == null ? void 0 : e.message) || "The request failed");
|
|
22
|
+
}
|
|
23
|
+
function H(e) {
|
|
24
|
+
return e == null || e === "" ? "blank" : typeof e == "object" ? JSON.stringify(e) : String(e);
|
|
25
|
+
}
|
|
26
|
+
function de(e) {
|
|
27
|
+
const n = e.replace(/_/g, " ").trim();
|
|
28
|
+
return n ? n[0].toUpperCase() + n.slice(1) : e;
|
|
29
|
+
}
|
|
30
|
+
const A = (e, n, o = `${n}s`) => `${e.toLocaleString()} ${e === 1 ? n : o}`;
|
|
31
|
+
function Ce(e) {
|
|
32
|
+
return e < 60 ? `${Math.max(1, Math.round(e))} s` : e < 3600 ? `${Math.round(e / 60)} min` : `${Math.round(e / 360) / 10} h`;
|
|
33
|
+
}
|
|
34
|
+
function Se(e) {
|
|
35
|
+
return e < 60 ? `${Math.round(e)} min` : `${Math.round(e / 6) / 10} h`;
|
|
36
|
+
}
|
|
37
|
+
function Pe() {
|
|
38
|
+
const e = Q();
|
|
39
|
+
return B({
|
|
40
|
+
queryKey: ["task-do", "me"],
|
|
41
|
+
queryFn: () => e.request(V("/ai/task-do/me")).then((o) => o.data),
|
|
42
|
+
enabled: !!e,
|
|
43
|
+
staleTime: 5 * 6e4,
|
|
44
|
+
retry: !1
|
|
45
|
+
}).data ?? null;
|
|
46
|
+
}
|
|
47
|
+
function qe(e, n, o, c) {
|
|
48
|
+
if (!e || n.status !== "open" && n.status !== "in_progress") return !1;
|
|
49
|
+
const d = n.kind === "support";
|
|
50
|
+
return (d ? !e.tickets : !e.tasks) || d && e.ticket_categories.length > 0 && !e.ticket_categories.includes(Number(n.category_id)) ? !1 : c ?? (!!o && !!n.assignee && n.assignee.toUpperCase() === o.toUpperCase());
|
|
51
|
+
}
|
|
52
|
+
function Xe({
|
|
53
|
+
task: e,
|
|
54
|
+
isAssignee: n,
|
|
55
|
+
subscribe: o,
|
|
56
|
+
compact: c,
|
|
57
|
+
onTaskChanged: d,
|
|
58
|
+
className: p
|
|
59
|
+
}) {
|
|
60
|
+
const h = Q(), { userId: u } = ge(), m = Pe(), [x, l] = k(!1);
|
|
61
|
+
return !h || !qe(m, e, u, n) ? null : /* @__PURE__ */ a(Ne, { open: x, onOpenChange: l, children: [
|
|
62
|
+
/* @__PURE__ */ t(ke, { asChild: !0, children: c ? /* @__PURE__ */ t(
|
|
63
|
+
"button",
|
|
64
|
+
{
|
|
65
|
+
type: "button",
|
|
66
|
+
className: U(
|
|
67
|
+
"rounded p-1 text-slate-400 transition-colors hover:bg-muted hover:text-nvr-navy dark:hover:text-nvr-cyan",
|
|
68
|
+
x && "bg-muted text-nvr-navy dark:text-nvr-cyan",
|
|
69
|
+
p
|
|
70
|
+
),
|
|
71
|
+
"aria-label": "Let AI do this",
|
|
72
|
+
"data-tip": "Let AI do this",
|
|
73
|
+
"data-task-do": e.id,
|
|
74
|
+
children: /* @__PURE__ */ t(Y, { className: "h-3.5 w-3.5" })
|
|
75
|
+
}
|
|
76
|
+
) : /* @__PURE__ */ a(
|
|
77
|
+
b,
|
|
78
|
+
{
|
|
79
|
+
type: "button",
|
|
80
|
+
size: "sm",
|
|
81
|
+
variant: "outline",
|
|
82
|
+
className: U("h-7 gap-1.5 px-2.5 text-[12px]", p),
|
|
83
|
+
"data-task-do": e.id,
|
|
84
|
+
children: [
|
|
85
|
+
/* @__PURE__ */ t(Y, { className: "h-3.5 w-3.5 text-nvr-navy dark:text-nvr-cyan" }),
|
|
86
|
+
"Let AI do this"
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
) }),
|
|
90
|
+
/* @__PURE__ */ t(
|
|
91
|
+
be,
|
|
92
|
+
{
|
|
93
|
+
align: "end",
|
|
94
|
+
collisionPadding: 16,
|
|
95
|
+
className: "w-[min(540px,calc(100vw-32px))] p-0",
|
|
96
|
+
onOpenAutoFocus: (f) => f.preventDefault(),
|
|
97
|
+
children: /* @__PURE__ */ t(Re, { task: e, subscribe: o, onTaskChanged: d })
|
|
98
|
+
}
|
|
99
|
+
)
|
|
100
|
+
] });
|
|
101
|
+
}
|
|
102
|
+
function Re({
|
|
103
|
+
task: e,
|
|
104
|
+
subscribe: n,
|
|
105
|
+
onTaskChanged: o
|
|
106
|
+
}) {
|
|
107
|
+
var W;
|
|
108
|
+
const c = Q(), d = ae(), p = e.kind === "support", [h, u] = k(null), [m, x] = k(null), [l, f] = k({}), [g, P] = k(null), [N, i] = k(""), [$, E] = k(!1), [v, T] = k(null), y = B({
|
|
109
|
+
queryKey: ["task-do", "task", e.id],
|
|
110
|
+
queryFn: () => c.request(V(`/ai/task-do/tasks/${e.id}`)).then((s) => s.data)
|
|
111
|
+
});
|
|
112
|
+
xe(() => {
|
|
113
|
+
if (h || !y.data) return;
|
|
114
|
+
const s = y.data.plans.find((w) => $e.has(w.status));
|
|
115
|
+
s && u(s.plan_id);
|
|
116
|
+
}, [y.data, h]);
|
|
117
|
+
const I = B({
|
|
118
|
+
queryKey: ["task-do", "plan", h],
|
|
119
|
+
queryFn: () => c.request(V(`/ai/task-do/plans/${encodeURIComponent(h)}`)).then((s) => s.data),
|
|
120
|
+
enabled: !!h
|
|
121
|
+
}), _ = L({
|
|
122
|
+
mutationFn: (s) => c.request(M(`/ai/task-do/tasks/${e.id}/draft`, s)).then((w) => w.data),
|
|
123
|
+
onMutate: () => {
|
|
124
|
+
T(null), P(null);
|
|
125
|
+
},
|
|
126
|
+
onSuccess: (s) => {
|
|
127
|
+
E(!1), i(""), s.kind === "plan" ? (x(null), f({}), d.setQueryData(["task-do", "plan", s.plan.plan_id], s.plan), u(s.plan.plan_id)) : s.kind === "questions" ? (x({ list: s.questions, note: s.note }), f({})) : (x(null), P({ reason: s.reason, checklist: s.checklist })), d.invalidateQueries({ queryKey: ["task-do", "task", e.id] });
|
|
128
|
+
},
|
|
129
|
+
onError: (s) => T(q(s))
|
|
130
|
+
}), j = (s = {}) => _.mutate({ ...s, ...h ? { previous_plan_id: h } : {} }), C = I.data, D = !!h, G = !!g || D && !!C && (C.status === "proposed" || C.status === "rejected" || C.status === "expired"), K = /* @__PURE__ */ a("div", { className: "flex items-start gap-2", children: [
|
|
131
|
+
/* @__PURE__ */ t(Y, { className: "mt-0.5 h-4 w-4 shrink-0 text-nvr-navy dark:text-nvr-cyan" }),
|
|
132
|
+
/* @__PURE__ */ a("div", { className: "min-w-0 flex-1", children: [
|
|
133
|
+
/* @__PURE__ */ t("p", { className: "text-[13px] font-semibold text-foreground", children: "Let AI do this" }),
|
|
134
|
+
/* @__PURE__ */ a("p", { className: "text-[11.5px] text-muted-foreground", children: [
|
|
135
|
+
"It reads the ",
|
|
136
|
+
p ? "ticket" : "task",
|
|
137
|
+
", the record and the thread as you, then drafts a plan you approve. Nothing changes until you say so."
|
|
138
|
+
] })
|
|
139
|
+
] })
|
|
140
|
+
] });
|
|
141
|
+
if (y.isLoading) return /* @__PURE__ */ t(ee, { text: "Checking…" });
|
|
142
|
+
if (!y.data || !y.data.ok && !D) {
|
|
143
|
+
const s = !y.data;
|
|
144
|
+
return /* @__PURE__ */ a("div", { className: "p-4", "data-task-do-panel": !0, children: [
|
|
145
|
+
K,
|
|
146
|
+
/* @__PURE__ */ t(
|
|
147
|
+
te,
|
|
148
|
+
{
|
|
149
|
+
text: s ? `Could not check whether AI can help with this ${p ? "ticket" : "task"}.` : ((W = y.data) == null ? void 0 : W.reason) ?? "Not available",
|
|
150
|
+
detail: s ? q(y.error) : null,
|
|
151
|
+
onRetry: s ? () => void y.refetch() : void 0,
|
|
152
|
+
retrying: y.isFetching
|
|
153
|
+
}
|
|
154
|
+
)
|
|
155
|
+
] });
|
|
156
|
+
}
|
|
157
|
+
return /* @__PURE__ */ a(
|
|
158
|
+
"div",
|
|
159
|
+
{
|
|
160
|
+
className: "max-h-[min(78vh,820px)] overflow-y-auto overscroll-contain p-4",
|
|
161
|
+
"data-task-do-panel": !0,
|
|
162
|
+
children: [
|
|
163
|
+
K,
|
|
164
|
+
_.isPending && /* @__PURE__ */ a("div", { className: "mt-3 space-y-2", "data-task-do-drafting": !0, children: [
|
|
165
|
+
/* @__PURE__ */ a("p", { className: "flex items-center gap-1.5 text-[12px] text-muted-foreground", children: [
|
|
166
|
+
/* @__PURE__ */ t(R, { className: "h-3 w-3 animate-spin" }),
|
|
167
|
+
" Reading the ",
|
|
168
|
+
p ? "ticket" : "task",
|
|
169
|
+
", the record and the thread…"
|
|
170
|
+
] }),
|
|
171
|
+
/* @__PURE__ */ t(z, { className: "h-4 w-3/4" }),
|
|
172
|
+
/* @__PURE__ */ t(z, { className: "h-4 w-full" }),
|
|
173
|
+
/* @__PURE__ */ t(z, { className: "h-4 w-2/3" })
|
|
174
|
+
] }),
|
|
175
|
+
!_.isPending && m && /* @__PURE__ */ a(
|
|
176
|
+
"form",
|
|
177
|
+
{
|
|
178
|
+
className: "mt-3 space-y-3",
|
|
179
|
+
"data-task-do-questions": !0,
|
|
180
|
+
onSubmit: (s) => {
|
|
181
|
+
s.preventDefault(), j({
|
|
182
|
+
answers: m.list.map((w) => ({
|
|
183
|
+
id: w.id,
|
|
184
|
+
question: w.text,
|
|
185
|
+
answer: (l[w.id] ?? "").trim() || "No answer"
|
|
186
|
+
}))
|
|
187
|
+
});
|
|
188
|
+
},
|
|
189
|
+
children: [
|
|
190
|
+
/* @__PURE__ */ a("p", { className: "text-[12.5px] text-foreground", children: [
|
|
191
|
+
"AI needs a few answers first",
|
|
192
|
+
m.note ? ` — ${m.note}` : "",
|
|
193
|
+
":"
|
|
194
|
+
] }),
|
|
195
|
+
/* @__PURE__ */ t("ol", { className: "space-y-2.5", children: m.list.map((s, w) => {
|
|
196
|
+
var r, S;
|
|
197
|
+
return /* @__PURE__ */ a("li", { children: [
|
|
198
|
+
/* @__PURE__ */ a("label", { className: "block text-[12px] text-foreground", htmlFor: `tdq-${s.id}`, children: [
|
|
199
|
+
/* @__PURE__ */ a("span", { className: "mr-1 tabular-nums text-muted-foreground", children: [
|
|
200
|
+
w + 1,
|
|
201
|
+
"."
|
|
202
|
+
] }),
|
|
203
|
+
s.text
|
|
204
|
+
] }),
|
|
205
|
+
(r = s.options) != null && r.length ? /* @__PURE__ */ t("div", { className: "mt-1 flex flex-wrap gap-1", children: s.options.map((F) => /* @__PURE__ */ t(
|
|
206
|
+
"button",
|
|
207
|
+
{
|
|
208
|
+
type: "button",
|
|
209
|
+
"aria-pressed": l[s.id] === F,
|
|
210
|
+
onClick: () => f((X) => ({ ...X, [s.id]: F })),
|
|
211
|
+
className: U(
|
|
212
|
+
"h-6 rounded-md border px-2 text-[11.5px]",
|
|
213
|
+
l[s.id] === F ? "border-nvr-cyan bg-nvr-cyan/10 text-foreground" : "border-slate-200 text-muted-foreground hover:bg-muted dark:border-border"
|
|
214
|
+
),
|
|
215
|
+
children: F
|
|
216
|
+
},
|
|
217
|
+
F
|
|
218
|
+
)) }) : null,
|
|
219
|
+
/* @__PURE__ */ t(
|
|
220
|
+
oe,
|
|
221
|
+
{
|
|
222
|
+
id: `tdq-${s.id}`,
|
|
223
|
+
className: "mt-1 h-7 text-[12px]",
|
|
224
|
+
value: l[s.id] ?? "",
|
|
225
|
+
placeholder: (S = s.options) != null && S.length ? "Or type an answer" : "Your answer",
|
|
226
|
+
onChange: (F) => f((X) => ({ ...X, [s.id]: F.target.value }))
|
|
227
|
+
}
|
|
228
|
+
)
|
|
229
|
+
] }, s.id);
|
|
230
|
+
}) }),
|
|
231
|
+
/* @__PURE__ */ a("div", { className: "flex items-center gap-2", children: [
|
|
232
|
+
/* @__PURE__ */ t(
|
|
233
|
+
b,
|
|
234
|
+
{
|
|
235
|
+
type: "submit",
|
|
236
|
+
size: "sm",
|
|
237
|
+
className: "h-7 bg-nvr-cyan text-white hover:bg-nvr-cyan/90",
|
|
238
|
+
disabled: !m.list.some((s) => (l[s.id] ?? "").trim()),
|
|
239
|
+
children: "Draft with these answers"
|
|
240
|
+
}
|
|
241
|
+
),
|
|
242
|
+
/* @__PURE__ */ t(
|
|
243
|
+
b,
|
|
244
|
+
{
|
|
245
|
+
type: "button",
|
|
246
|
+
size: "sm",
|
|
247
|
+
variant: "ghost",
|
|
248
|
+
className: "h-7",
|
|
249
|
+
onClick: () => x(null),
|
|
250
|
+
children: "Never mind"
|
|
251
|
+
}
|
|
252
|
+
)
|
|
253
|
+
] })
|
|
254
|
+
]
|
|
255
|
+
}
|
|
256
|
+
),
|
|
257
|
+
!_.isPending && g && /* @__PURE__ */ a("div", { className: "mt-3 space-y-2", "data-task-do-cannot": !0, children: [
|
|
258
|
+
/* @__PURE__ */ a("p", { className: "flex items-start gap-1.5 text-[12.5px] text-foreground", children: [
|
|
259
|
+
/* @__PURE__ */ t(J, { className: "mt-0.5 h-3.5 w-3.5 shrink-0 text-slate-400" }),
|
|
260
|
+
/* @__PURE__ */ a("span", { children: [
|
|
261
|
+
/* @__PURE__ */ t("span", { className: "font-medium", children: "AI can’t do this one." }),
|
|
262
|
+
" ",
|
|
263
|
+
g.reason
|
|
264
|
+
] })
|
|
265
|
+
] }),
|
|
266
|
+
/* @__PURE__ */ t("p", { className: "pl-5 text-[11.5px] text-muted-foreground", children: "Nothing was changed." }),
|
|
267
|
+
g.checklist.length > 0 && /* @__PURE__ */ a("div", { className: "pl-5", children: [
|
|
268
|
+
/* @__PURE__ */ t("p", { className: "text-[11.5px] font-medium text-muted-foreground", children: "To do it yourself" }),
|
|
269
|
+
/* @__PURE__ */ t("ol", { className: "mt-1 space-y-1", children: g.checklist.map((s, w) => /* @__PURE__ */ a(
|
|
270
|
+
"li",
|
|
271
|
+
{
|
|
272
|
+
className: "flex items-start gap-2 text-[12px] text-foreground",
|
|
273
|
+
children: [
|
|
274
|
+
/* @__PURE__ */ a("span", { className: "w-3.5 shrink-0 text-right tabular-nums text-muted-foreground", children: [
|
|
275
|
+
w + 1,
|
|
276
|
+
"."
|
|
277
|
+
] }),
|
|
278
|
+
s
|
|
279
|
+
]
|
|
280
|
+
},
|
|
281
|
+
`${w}-${s}`
|
|
282
|
+
)) })
|
|
283
|
+
] })
|
|
284
|
+
] }),
|
|
285
|
+
!_.isPending && !m && !g && !D && /* @__PURE__ */ a("div", { className: "mt-3 flex items-center gap-2", children: [
|
|
286
|
+
/* @__PURE__ */ a(
|
|
287
|
+
b,
|
|
288
|
+
{
|
|
289
|
+
size: "sm",
|
|
290
|
+
className: "h-7 bg-nvr-cyan text-white hover:bg-nvr-cyan/90",
|
|
291
|
+
onClick: () => _.mutate({}),
|
|
292
|
+
"data-task-do-start": !0,
|
|
293
|
+
children: [
|
|
294
|
+
/* @__PURE__ */ t(Y, { className: "h-3 w-3" }),
|
|
295
|
+
" Draft a plan"
|
|
296
|
+
]
|
|
297
|
+
}
|
|
298
|
+
),
|
|
299
|
+
/* @__PURE__ */ t("span", { className: "text-[11px] text-muted-foreground", children: "Takes a few seconds." })
|
|
300
|
+
] }),
|
|
301
|
+
D && !m && !g && !_.isPending && /* @__PURE__ */ a(Z, { children: [
|
|
302
|
+
I.isLoading && /* @__PURE__ */ t(ee, { text: "Loading the plan…" }),
|
|
303
|
+
I.isError && /* @__PURE__ */ t(te, { text: q(I.error) }),
|
|
304
|
+
C && /* @__PURE__ */ t(
|
|
305
|
+
Fe,
|
|
306
|
+
{
|
|
307
|
+
plan: C,
|
|
308
|
+
task: e,
|
|
309
|
+
ticket: p,
|
|
310
|
+
subscribe: n,
|
|
311
|
+
onTaskChanged: o,
|
|
312
|
+
onPlan: (s) => {
|
|
313
|
+
s.status !== C.status && (d.invalidateQueries({ queryKey: ["task-do", "plan", C.plan_id] }), d.invalidateQueries({ queryKey: ["task-do", "task", e.id] }));
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
)
|
|
317
|
+
] }),
|
|
318
|
+
v && /* @__PURE__ */ t("p", { className: "mt-2 text-[11.5px] text-rose-700 dark:text-rose-400", "data-task-do-error": !0, children: v }),
|
|
319
|
+
!_.isPending && G && y.data.ok && /* @__PURE__ */ t("div", { className: "mt-3 border-t border-slate-200 pt-2.5 dark:border-border", children: $ ? /* @__PURE__ */ a(
|
|
320
|
+
"form",
|
|
321
|
+
{
|
|
322
|
+
className: "space-y-1.5",
|
|
323
|
+
"data-task-do-redraft": !0,
|
|
324
|
+
onSubmit: (s) => {
|
|
325
|
+
s.preventDefault(), j({ note: N.trim() });
|
|
326
|
+
},
|
|
327
|
+
children: [
|
|
328
|
+
/* @__PURE__ */ t(
|
|
329
|
+
le,
|
|
330
|
+
{
|
|
331
|
+
autoFocus: !0,
|
|
332
|
+
"aria-label": g ? "What should it try instead" : "What should be different",
|
|
333
|
+
className: "min-h-[56px] text-[12px]",
|
|
334
|
+
placeholder: g ? "What should it try instead?" : "What should be different? e.g. only the open lines, and tell the vendor too",
|
|
335
|
+
value: N,
|
|
336
|
+
onChange: (s) => i(s.target.value)
|
|
337
|
+
}
|
|
338
|
+
),
|
|
339
|
+
/* @__PURE__ */ a("div", { className: "flex items-center gap-2", children: [
|
|
340
|
+
/* @__PURE__ */ t(
|
|
341
|
+
b,
|
|
342
|
+
{
|
|
343
|
+
type: "submit",
|
|
344
|
+
size: "sm",
|
|
345
|
+
className: "h-7 bg-nvr-cyan text-white hover:bg-nvr-cyan/90",
|
|
346
|
+
disabled: !N.trim(),
|
|
347
|
+
children: "Redraft"
|
|
348
|
+
}
|
|
349
|
+
),
|
|
350
|
+
/* @__PURE__ */ t(
|
|
351
|
+
b,
|
|
352
|
+
{
|
|
353
|
+
type: "button",
|
|
354
|
+
size: "sm",
|
|
355
|
+
variant: "ghost",
|
|
356
|
+
className: "h-7",
|
|
357
|
+
onClick: () => E(!1),
|
|
358
|
+
children: "Cancel"
|
|
359
|
+
}
|
|
360
|
+
),
|
|
361
|
+
!g && /* @__PURE__ */ t("span", { className: "text-[11px] text-muted-foreground", children: "The current draft is discarded." })
|
|
362
|
+
] })
|
|
363
|
+
]
|
|
364
|
+
}
|
|
365
|
+
) : /* @__PURE__ */ t(
|
|
366
|
+
"button",
|
|
367
|
+
{
|
|
368
|
+
type: "button",
|
|
369
|
+
className: "text-[11.5px] font-medium text-nvr-navy underline-offset-2 hover:underline dark:text-nvr-cyan",
|
|
370
|
+
onClick: () => E(!0),
|
|
371
|
+
"data-task-do-redraft-toggle": !0,
|
|
372
|
+
children: g ? "Try again with a note" : "Ask for a different plan…"
|
|
373
|
+
}
|
|
374
|
+
) })
|
|
375
|
+
]
|
|
376
|
+
}
|
|
377
|
+
);
|
|
378
|
+
}
|
|
379
|
+
function ee({ text: e }) {
|
|
380
|
+
return /* @__PURE__ */ a("div", { className: "space-y-2 p-4", "data-task-do-loading": !0, children: [
|
|
381
|
+
/* @__PURE__ */ a("p", { className: "flex items-center gap-1.5 text-[12px] text-muted-foreground", children: [
|
|
382
|
+
/* @__PURE__ */ t(R, { className: "h-3 w-3 animate-spin" }),
|
|
383
|
+
" ",
|
|
384
|
+
e
|
|
385
|
+
] }),
|
|
386
|
+
/* @__PURE__ */ t(z, { className: "h-4 w-2/3" }),
|
|
387
|
+
/* @__PURE__ */ t(z, { className: "h-4 w-full" })
|
|
388
|
+
] });
|
|
389
|
+
}
|
|
390
|
+
function te({
|
|
391
|
+
text: e,
|
|
392
|
+
detail: n,
|
|
393
|
+
onRetry: o,
|
|
394
|
+
retrying: c
|
|
395
|
+
}) {
|
|
396
|
+
return /* @__PURE__ */ a("div", { className: "mt-3 rounded-md bg-slate-50 px-3 py-2.5 dark:bg-muted/40", "data-task-do-problem": !0, children: [
|
|
397
|
+
/* @__PURE__ */ a("p", { className: "flex items-start gap-1.5 text-[12px] text-foreground", children: [
|
|
398
|
+
/* @__PURE__ */ t(J, { className: "mt-0.5 h-3.5 w-3.5 shrink-0 text-slate-400" }),
|
|
399
|
+
/* @__PURE__ */ t("span", { children: e })
|
|
400
|
+
] }),
|
|
401
|
+
n && /* @__PURE__ */ t("p", { className: "mt-0.5 pl-5 text-[11px] text-muted-foreground", children: n }),
|
|
402
|
+
o && /* @__PURE__ */ a(
|
|
403
|
+
b,
|
|
404
|
+
{
|
|
405
|
+
size: "sm",
|
|
406
|
+
variant: "outline",
|
|
407
|
+
className: "ml-5 mt-2 h-7",
|
|
408
|
+
onClick: o,
|
|
409
|
+
disabled: c,
|
|
410
|
+
children: [
|
|
411
|
+
c ? /* @__PURE__ */ t(R, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ t(se, { className: "h-3 w-3" }),
|
|
412
|
+
"Try again"
|
|
413
|
+
]
|
|
414
|
+
}
|
|
415
|
+
)
|
|
416
|
+
] });
|
|
417
|
+
}
|
|
418
|
+
const ce = { low: "Low risk", medium: "Medium risk", high: "High risk" };
|
|
419
|
+
function Ae({ level: e }) {
|
|
420
|
+
return /* @__PURE__ */ t(
|
|
421
|
+
"span",
|
|
422
|
+
{
|
|
423
|
+
className: U("rounded px-1.5 py-px text-[11px] font-medium", e === "high" ? "bg-rose-500/10 text-rose-700 dark:text-rose-400" : e === "medium" ? "bg-amber-500/10 text-amber-800 dark:text-amber-300" : "bg-emerald-500/10 text-emerald-700 dark:text-emerald-400"),
|
|
424
|
+
"data-task-do-risk": e,
|
|
425
|
+
children: ce[e]
|
|
426
|
+
}
|
|
427
|
+
);
|
|
428
|
+
}
|
|
429
|
+
function De({ plan: e }) {
|
|
430
|
+
const n = e.review, o = n.risk.irreversible, c = n.risk.reasons.filter(
|
|
431
|
+
(p) => !(o.length > 0 && /cannot be rolled back/.test(p))
|
|
432
|
+
), d = "bg-white px-2.5 py-1.5 dark:bg-card";
|
|
433
|
+
return /* @__PURE__ */ a("div", { className: "mt-2.5 space-y-2", "data-task-do-review": !0, children: [
|
|
434
|
+
/* @__PURE__ */ a("div", { className: "grid grid-cols-3 gap-px overflow-hidden rounded-md border border-slate-200 bg-slate-200 dark:border-border dark:bg-border", children: [
|
|
435
|
+
/* @__PURE__ */ a("div", { className: d, children: [
|
|
436
|
+
/* @__PURE__ */ t("p", { className: "text-[11px] text-muted-foreground", children: "Runs in" }),
|
|
437
|
+
/* @__PURE__ */ a("p", { className: "text-[13px] font-medium tabular-nums text-foreground", children: [
|
|
438
|
+
"≈ ",
|
|
439
|
+
Ce(n.estimate.run_seconds)
|
|
440
|
+
] }),
|
|
441
|
+
/* @__PURE__ */ t("p", { className: "text-[10.5px] text-muted-foreground", children: n.estimate.run_basis === "recent runs" ? "from recent runs" : "typical rate" })
|
|
442
|
+
] }),
|
|
443
|
+
/* @__PURE__ */ a("div", { className: d, children: [
|
|
444
|
+
/* @__PURE__ */ t("p", { className: "text-[11px] text-muted-foreground", children: "Saves you" }),
|
|
445
|
+
/* @__PURE__ */ t("p", { className: "text-[13px] font-medium tabular-nums text-foreground", children: n.estimate.hands_on_minutes != null ? `≈ ${Se(n.estimate.hands_on_minutes)}` : "—" }),
|
|
446
|
+
/* @__PURE__ */ t("p", { className: "text-[10.5px] text-muted-foreground", children: "AI’s estimate" })
|
|
447
|
+
] }),
|
|
448
|
+
/* @__PURE__ */ a("div", { className: d, children: [
|
|
449
|
+
/* @__PURE__ */ t("p", { className: "text-[11px] text-muted-foreground", children: "Risk" }),
|
|
450
|
+
/* @__PURE__ */ t("p", { className: "mt-0.5", children: /* @__PURE__ */ t(Ae, { level: n.risk.level }) }),
|
|
451
|
+
/* @__PURE__ */ t("p", { className: "text-[10.5px] text-muted-foreground", children: A(n.risk.records, "record") })
|
|
452
|
+
] })
|
|
453
|
+
] }),
|
|
454
|
+
n.risk.level !== "low" && c.length > 0 && /* @__PURE__ */ a("p", { className: "text-[11.5px] text-muted-foreground", "data-task-do-risk-why": !0, children: [
|
|
455
|
+
ce[n.risk.level],
|
|
456
|
+
": ",
|
|
457
|
+
c.join(" · ")
|
|
458
|
+
] }),
|
|
459
|
+
o.length > 0 ? /* @__PURE__ */ a(
|
|
460
|
+
"div",
|
|
461
|
+
{
|
|
462
|
+
className: "rounded-md border border-amber-200 bg-amber-50 px-2.5 py-1.5 text-[11.5px] text-amber-900 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-200",
|
|
463
|
+
"data-task-do-irreversible": !0,
|
|
464
|
+
children: [
|
|
465
|
+
/* @__PURE__ */ a("p", { className: "flex items-center gap-1.5 font-medium", children: [
|
|
466
|
+
/* @__PURE__ */ t(he, { className: "h-3.5 w-3.5 shrink-0" }),
|
|
467
|
+
o.length === 1 ? "One step can’t be undone once it runs" : `${o.length} steps can’t be undone once they run`
|
|
468
|
+
] }),
|
|
469
|
+
/* @__PURE__ */ t("ul", { className: "mt-0.5 space-y-px pl-5", children: o.map((p) => /* @__PURE__ */ a("li", { children: [
|
|
470
|
+
"Step ",
|
|
471
|
+
p.n,
|
|
472
|
+
" — ",
|
|
473
|
+
p.why
|
|
474
|
+
] }, p.n)) })
|
|
475
|
+
]
|
|
476
|
+
}
|
|
477
|
+
) : /* @__PURE__ */ a(
|
|
478
|
+
"p",
|
|
479
|
+
{
|
|
480
|
+
className: "flex items-center gap-1.5 text-[11.5px] text-muted-foreground",
|
|
481
|
+
"data-task-do-reversible": !0,
|
|
482
|
+
children: [
|
|
483
|
+
/* @__PURE__ */ t(ie, { className: "h-3.5 w-3.5 shrink-0 text-emerald-600 dark:text-emerald-400" }),
|
|
484
|
+
"Everything this plan changes can be undone afterwards."
|
|
485
|
+
]
|
|
486
|
+
}
|
|
487
|
+
)
|
|
488
|
+
] });
|
|
489
|
+
}
|
|
490
|
+
function Ee({ step: e, plan: n }) {
|
|
491
|
+
var h;
|
|
492
|
+
const o = n.review.touches.find((u) => u.step_id === e.id), c = (h = e.preview) != null && h.changes && typeof e.preview.changes == "object" ? e.preview.changes : {}, d = new Map(((o == null ? void 0 : o.fields) ?? []).map((u) => [u.field, u])), p = [.../* @__PURE__ */ new Set([...Object.keys(c), ...d.keys()])];
|
|
493
|
+
return p.length === 0 ? null : /* @__PURE__ */ a("dl", { className: "mt-0.5 space-y-px pl-5", "data-task-do-step-changes": !0, children: [
|
|
494
|
+
p.slice(0, 6).map((u) => {
|
|
495
|
+
const m = d.get(u), x = m ? m.to : c[u];
|
|
496
|
+
return /* @__PURE__ */ a("div", { className: "flex min-w-0 gap-1.5 text-[11px]", children: [
|
|
497
|
+
/* @__PURE__ */ t("dt", { className: "shrink-0 text-muted-foreground", children: de(u) }),
|
|
498
|
+
/* @__PURE__ */ a("dd", { className: "min-w-0 truncate text-slate-700 dark:text-slate-300", children: [
|
|
499
|
+
m && m.from !== void 0 && /* @__PURE__ */ a(Z, { children: [
|
|
500
|
+
/* @__PURE__ */ t("span", { className: "text-muted-foreground line-through decoration-slate-300 dark:decoration-slate-600", children: H(m.from) }),
|
|
501
|
+
" ",
|
|
502
|
+
"→",
|
|
503
|
+
" "
|
|
504
|
+
] }),
|
|
505
|
+
H(x)
|
|
506
|
+
] })
|
|
507
|
+
] }, u);
|
|
508
|
+
}),
|
|
509
|
+
p.length > 6 && /* @__PURE__ */ a("p", { className: "text-[11px] text-muted-foreground", children: [
|
|
510
|
+
"+",
|
|
511
|
+
p.length - 6,
|
|
512
|
+
" more fields"
|
|
513
|
+
] })
|
|
514
|
+
] });
|
|
515
|
+
}
|
|
516
|
+
function Ie({
|
|
517
|
+
step: e,
|
|
518
|
+
plan: n,
|
|
519
|
+
onEdit: o,
|
|
520
|
+
busy: c
|
|
521
|
+
}) {
|
|
522
|
+
var $, E;
|
|
523
|
+
const [d, p] = k(!1), [h, u] = k(""), [m, x] = k(""), l = n.review.touches.find((v) => v.step_id === e.id), f = ($ = e.preview) != null && $.changes && typeof e.preview.changes == "object" ? e.preview.changes : null, g = [
|
|
524
|
+
...Object.keys(f ?? {}).filter(
|
|
525
|
+
() => ["bulk_update", "create_record"].includes(e.kind)
|
|
526
|
+
),
|
|
527
|
+
..._e[e.kind] ?? []
|
|
528
|
+
], P = n.status === "proposed", N = [];
|
|
529
|
+
l && (l.records && N.push(A(l.records, l.collection ?? "record")), l.people && N.push(`tells ${A(l.people, "person", "people")}`), l.external && N.push("calls other systems"), l.email && N.push("may email"));
|
|
530
|
+
const i = Number(((E = e.preview) == null ? void 0 : E.hidden_fields) ?? 0);
|
|
531
|
+
return i && N.push(`${i} field${i === 1 ? "" : "s"} you may not read`), /* @__PURE__ */ a("div", { className: "mt-1 pl-5", "data-task-do-step-extra": !0, children: [
|
|
532
|
+
(N.length > 0 || (l == null ? void 0 : l.irreversible)) && /* @__PURE__ */ a("p", { className: "text-[11px] text-muted-foreground", children: [
|
|
533
|
+
N.join(" · "),
|
|
534
|
+
(l == null ? void 0 : l.irreversible) && /* @__PURE__ */ a("span", { className: "text-amber-800 dark:text-amber-300", children: [
|
|
535
|
+
N.length > 0 ? " · " : "",
|
|
536
|
+
"can’t be undone"
|
|
537
|
+
] })
|
|
538
|
+
] }),
|
|
539
|
+
P && !d && /* @__PURE__ */ a("div", { className: "mt-0.5 flex items-center gap-2", children: [
|
|
540
|
+
g.length > 0 && /* @__PURE__ */ a(
|
|
541
|
+
"button",
|
|
542
|
+
{
|
|
543
|
+
type: "button",
|
|
544
|
+
className: "flex items-center gap-1 text-[11px] text-muted-foreground hover:text-foreground",
|
|
545
|
+
onClick: () => {
|
|
546
|
+
u(g[0]), x(
|
|
547
|
+
f && g[0] in f ? H(f[g[0]]) : ""
|
|
548
|
+
), p(!0);
|
|
549
|
+
},
|
|
550
|
+
disabled: c,
|
|
551
|
+
"data-task-do-step-change": !0,
|
|
552
|
+
children: [
|
|
553
|
+
/* @__PURE__ */ t(me, { className: "h-3 w-3" }),
|
|
554
|
+
" Change a value"
|
|
555
|
+
]
|
|
556
|
+
}
|
|
557
|
+
),
|
|
558
|
+
n.steps.length > 1 && /* @__PURE__ */ a(
|
|
559
|
+
"button",
|
|
560
|
+
{
|
|
561
|
+
type: "button",
|
|
562
|
+
className: "flex items-center gap-1 text-[11px] text-muted-foreground hover:text-rose-700 dark:hover:text-rose-400",
|
|
563
|
+
onClick: () => o({ remove_step: e.id }),
|
|
564
|
+
disabled: c,
|
|
565
|
+
"data-task-do-step-remove": !0,
|
|
566
|
+
children: [
|
|
567
|
+
/* @__PURE__ */ t(pe, { className: "h-3 w-3" }),
|
|
568
|
+
" Remove step"
|
|
569
|
+
]
|
|
570
|
+
}
|
|
571
|
+
)
|
|
572
|
+
] }),
|
|
573
|
+
P && d && /* @__PURE__ */ a(
|
|
574
|
+
"form",
|
|
575
|
+
{
|
|
576
|
+
className: "mt-1 flex flex-wrap items-center gap-1.5",
|
|
577
|
+
onSubmit: (v) => {
|
|
578
|
+
v.preventDefault(), o({ set: { step_id: e.id, field: h, value: m } }), p(!1);
|
|
579
|
+
},
|
|
580
|
+
children: [
|
|
581
|
+
/* @__PURE__ */ t(
|
|
582
|
+
ye,
|
|
583
|
+
{
|
|
584
|
+
value: h,
|
|
585
|
+
onChange: (v) => {
|
|
586
|
+
u(v), x(f && v in f ? H(f[v]) : "");
|
|
587
|
+
},
|
|
588
|
+
options: g.map((v) => ({ value: v, label: de(v) })),
|
|
589
|
+
ariaLabel: "Field",
|
|
590
|
+
className: "h-7 w-[150px] text-[11.5px]"
|
|
591
|
+
}
|
|
592
|
+
),
|
|
593
|
+
/* @__PURE__ */ t(
|
|
594
|
+
oe,
|
|
595
|
+
{
|
|
596
|
+
className: "h-7 w-[180px] text-[11.5px]",
|
|
597
|
+
value: m,
|
|
598
|
+
onChange: (v) => x(v.target.value),
|
|
599
|
+
"aria-label": "New value",
|
|
600
|
+
autoFocus: !0
|
|
601
|
+
}
|
|
602
|
+
),
|
|
603
|
+
/* @__PURE__ */ a(b, { type: "submit", size: "sm", className: "h-7", variant: "outline", disabled: c, children: [
|
|
604
|
+
c ? /* @__PURE__ */ t(R, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ t(O, { className: "h-3 w-3" }),
|
|
605
|
+
"Apply"
|
|
606
|
+
] }),
|
|
607
|
+
/* @__PURE__ */ t(
|
|
608
|
+
b,
|
|
609
|
+
{
|
|
610
|
+
type: "button",
|
|
611
|
+
size: "sm",
|
|
612
|
+
variant: "ghost",
|
|
613
|
+
className: "h-7",
|
|
614
|
+
onClick: () => p(!1),
|
|
615
|
+
children: "Cancel"
|
|
616
|
+
}
|
|
617
|
+
)
|
|
618
|
+
]
|
|
619
|
+
}
|
|
620
|
+
)
|
|
621
|
+
] });
|
|
622
|
+
}
|
|
623
|
+
function Fe({
|
|
624
|
+
plan: e,
|
|
625
|
+
task: n,
|
|
626
|
+
ticket: o,
|
|
627
|
+
subscribe: c,
|
|
628
|
+
onTaskChanged: d,
|
|
629
|
+
onPlan: p
|
|
630
|
+
}) {
|
|
631
|
+
var s, w;
|
|
632
|
+
const h = Q(), u = ae(), [m, x] = k(null), [l, f] = k(null), [g, P] = k(!1), [N, i] = k(!1), [$, E] = k(e), v = ["task-do", "plan", e.plan_id], T = JSON.stringify(e.steps.map((r) => {
|
|
633
|
+
var S;
|
|
634
|
+
return [r.id, ((S = r.preview) == null ? void 0 : S.changes) ?? null];
|
|
635
|
+
})), y = L({
|
|
636
|
+
mutationFn: (r) => h.request(
|
|
637
|
+
M(`/ai/task-do/plans/${encodeURIComponent(e.plan_id)}/edit`, r)
|
|
638
|
+
).then((S) => S.data),
|
|
639
|
+
onMutate: () => x(null),
|
|
640
|
+
onSuccess: (r) => u.setQueryData(v, r),
|
|
641
|
+
onError: (r) => x(q(r))
|
|
642
|
+
}), I = L({
|
|
643
|
+
mutationFn: () => h.request(
|
|
644
|
+
M(`/ai/task-do/plans/${encodeURIComponent(e.plan_id)}/approve`)
|
|
645
|
+
).then((r) => r.data),
|
|
646
|
+
onSuccess: (r) => u.setQueryData(v, r),
|
|
647
|
+
onError: (r) => x(q(r))
|
|
648
|
+
}), _ = L({
|
|
649
|
+
mutationFn: () => o ? h.request(ve(`/support/tickets/${n.id}`, { status: "done" })) : h.request(M(`/tasks/${n.id}/complete`)),
|
|
650
|
+
onSuccess: () => {
|
|
651
|
+
i(!0);
|
|
652
|
+
for (const r of ["tasks", "my-work", "support-ticket", "support-tickets", "support-summary"])
|
|
653
|
+
u.invalidateQueries({ queryKey: [r] });
|
|
654
|
+
d == null || d();
|
|
655
|
+
},
|
|
656
|
+
onError: (r) => x(q(r))
|
|
657
|
+
}), j = L({
|
|
658
|
+
mutationFn: () => h.request(
|
|
659
|
+
M(`/ai/task-do/plans/${encodeURIComponent(e.plan_id)}/draft-reply`)
|
|
660
|
+
).then((r) => r.data.text),
|
|
661
|
+
onMutate: () => x(null),
|
|
662
|
+
onSuccess: (r) => f(r),
|
|
663
|
+
onError: (r) => x(q(r))
|
|
664
|
+
}), C = L({
|
|
665
|
+
mutationFn: (r) => h.request(M(`/support/tickets/${n.id}/comments`, { text: r })),
|
|
666
|
+
onSuccess: () => {
|
|
667
|
+
f(null), u.invalidateQueries({ queryKey: ["support-ticket"] }), d == null || d();
|
|
668
|
+
},
|
|
669
|
+
onError: (r) => x(q(r))
|
|
670
|
+
}), D = ((s = e.approval) == null ? void 0 : s.required) && !e.approval.approved_by, G = e.status === "executed", K = n.status === "open" || n.status === "in_progress", W = $.status === "proposed" || $.status === "scheduled";
|
|
671
|
+
return /* @__PURE__ */ a("div", { className: "mt-3", "data-task-do-plan": e.status, children: [
|
|
672
|
+
/* @__PURE__ */ t(Le, { plan: $, waiting: !!D }),
|
|
673
|
+
D && /* @__PURE__ */ a(
|
|
674
|
+
"div",
|
|
675
|
+
{
|
|
676
|
+
className: "flex items-start gap-1.5 rounded-md bg-slate-50 px-2.5 py-1.5 text-[11.5px] text-foreground dark:bg-muted/40",
|
|
677
|
+
"data-task-do-approval": !0,
|
|
678
|
+
children: [
|
|
679
|
+
/* @__PURE__ */ t(ne, { className: "mt-0.5 h-3.5 w-3.5 shrink-0 text-slate-400" }),
|
|
680
|
+
/* @__PURE__ */ a("span", { className: "min-w-0 flex-1", children: [
|
|
681
|
+
/* @__PURE__ */ t("span", { className: "font-medium", children: "Needs a second approval." }),
|
|
682
|
+
" ",
|
|
683
|
+
e.approval.reason,
|
|
684
|
+
".",
|
|
685
|
+
" ",
|
|
686
|
+
e.approval.superseded ? `${e.approval.superseded}. ` : "",
|
|
687
|
+
e.can_approve ? "You were asked to approve it — review the steps below first." : `Waiting for ${e.approval.approvers.length === 1 ? "one person" : `one of ${e.approval.approvers.length} people`} to approve; they have been told.`
|
|
688
|
+
] })
|
|
689
|
+
]
|
|
690
|
+
}
|
|
691
|
+
),
|
|
692
|
+
/* @__PURE__ */ t(
|
|
693
|
+
we,
|
|
694
|
+
{
|
|
695
|
+
plan: e,
|
|
696
|
+
quiet: !0,
|
|
697
|
+
subscribe: c,
|
|
698
|
+
className: "mt-3",
|
|
699
|
+
beforeSteps: W ? /* @__PURE__ */ t(De, { plan: e }) : null,
|
|
700
|
+
stepChanges: (r) => /* @__PURE__ */ t(Ee, { step: r, plan: e }),
|
|
701
|
+
stepExtra: (r) => /* @__PURE__ */ t(Ie, { step: r, plan: e, onEdit: (S) => y.mutate(S), busy: y.isPending }),
|
|
702
|
+
runDisabled: D ? e.can_approve ? "Once you approve, the assignee can run it." : "Approve & run opens once a second person approves." : null,
|
|
703
|
+
onPlan: (r) => {
|
|
704
|
+
E(r), p(r);
|
|
705
|
+
},
|
|
706
|
+
extraActions: (r) => D && e.can_approve && r.status === "proposed" ? /* @__PURE__ */ a(
|
|
707
|
+
b,
|
|
708
|
+
{
|
|
709
|
+
size: "sm",
|
|
710
|
+
className: "h-7 bg-nvr-cyan text-white hover:bg-nvr-cyan/90",
|
|
711
|
+
disabled: I.isPending,
|
|
712
|
+
onClick: () => I.mutate(),
|
|
713
|
+
"data-task-do-approve": !0,
|
|
714
|
+
children: [
|
|
715
|
+
I.isPending ? /* @__PURE__ */ t(R, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ t(O, { className: "h-3 w-3" }),
|
|
716
|
+
"Approve plan"
|
|
717
|
+
]
|
|
718
|
+
}
|
|
719
|
+
) : r.status === "executed" || e.can_undo ? /* @__PURE__ */ a(Z, { children: [
|
|
720
|
+
r.status === "executed" && K && !N && /* @__PURE__ */ a(
|
|
721
|
+
b,
|
|
722
|
+
{
|
|
723
|
+
size: "sm",
|
|
724
|
+
variant: "outline",
|
|
725
|
+
className: "h-7",
|
|
726
|
+
disabled: _.isPending,
|
|
727
|
+
onClick: () => _.mutate(),
|
|
728
|
+
"data-task-do-mark-done": !0,
|
|
729
|
+
children: [
|
|
730
|
+
_.isPending ? /* @__PURE__ */ t(R, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ t(O, { className: "h-3 w-3" }),
|
|
731
|
+
"Mark ",
|
|
732
|
+
o ? "ticket" : "task",
|
|
733
|
+
" done"
|
|
734
|
+
]
|
|
735
|
+
}
|
|
736
|
+
),
|
|
737
|
+
r.status === "executed" && o && l == null && /* @__PURE__ */ a(
|
|
738
|
+
b,
|
|
739
|
+
{
|
|
740
|
+
size: "sm",
|
|
741
|
+
variant: "outline",
|
|
742
|
+
className: "h-7",
|
|
743
|
+
disabled: j.isPending,
|
|
744
|
+
onClick: () => j.mutate(),
|
|
745
|
+
"data-task-do-draft-reply": !0,
|
|
746
|
+
children: [
|
|
747
|
+
j.isPending ? /* @__PURE__ */ t(R, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ t(ue, { className: "h-3 w-3" }),
|
|
748
|
+
"Draft reply to requester"
|
|
749
|
+
]
|
|
750
|
+
}
|
|
751
|
+
),
|
|
752
|
+
e.can_undo && /* @__PURE__ */ a(
|
|
753
|
+
b,
|
|
754
|
+
{
|
|
755
|
+
size: "sm",
|
|
756
|
+
variant: "ghost",
|
|
757
|
+
className: "h-7",
|
|
758
|
+
onClick: () => P((S) => !S),
|
|
759
|
+
"data-task-do-undo-toggle": !0,
|
|
760
|
+
children: [
|
|
761
|
+
/* @__PURE__ */ t(re, { className: "h-3 w-3" }),
|
|
762
|
+
" Undo what AI did"
|
|
763
|
+
]
|
|
764
|
+
}
|
|
765
|
+
)
|
|
766
|
+
] }) : null
|
|
767
|
+
},
|
|
768
|
+
T
|
|
769
|
+
),
|
|
770
|
+
N && /* @__PURE__ */ a("p", { className: "mt-2 flex items-center gap-1 text-[11.5px] text-emerald-700 dark:text-emerald-400", children: [
|
|
771
|
+
/* @__PURE__ */ t(O, { className: "h-3 w-3" }),
|
|
772
|
+
" ",
|
|
773
|
+
o ? "Ticket" : "Task",
|
|
774
|
+
" marked done."
|
|
775
|
+
] }),
|
|
776
|
+
l != null && /* @__PURE__ */ a(
|
|
777
|
+
"form",
|
|
778
|
+
{
|
|
779
|
+
className: "mt-2 space-y-1.5",
|
|
780
|
+
"data-task-do-reply": !0,
|
|
781
|
+
onSubmit: (r) => {
|
|
782
|
+
r.preventDefault(), l.trim() && C.mutate(l.trim());
|
|
783
|
+
},
|
|
784
|
+
children: [
|
|
785
|
+
/* @__PURE__ */ t(
|
|
786
|
+
"label",
|
|
787
|
+
{
|
|
788
|
+
htmlFor: `task-do-reply-${e.plan_id}`,
|
|
789
|
+
className: "block text-[12px] font-medium text-foreground",
|
|
790
|
+
children: "Reply to the requester"
|
|
791
|
+
}
|
|
792
|
+
),
|
|
793
|
+
/* @__PURE__ */ t("p", { className: "text-[11.5px] text-muted-foreground", children: "AI drafted this from what the plan did. Edit it, then send — it goes out as your reply. Nothing is sent until you do." }),
|
|
794
|
+
/* @__PURE__ */ t(
|
|
795
|
+
le,
|
|
796
|
+
{
|
|
797
|
+
id: `task-do-reply-${e.plan_id}`,
|
|
798
|
+
className: "min-h-[96px] text-[12px]",
|
|
799
|
+
value: l,
|
|
800
|
+
onChange: (r) => f(r.target.value)
|
|
801
|
+
}
|
|
802
|
+
),
|
|
803
|
+
/* @__PURE__ */ a("div", { className: "flex items-center gap-2", children: [
|
|
804
|
+
/* @__PURE__ */ a(
|
|
805
|
+
b,
|
|
806
|
+
{
|
|
807
|
+
type: "submit",
|
|
808
|
+
size: "sm",
|
|
809
|
+
className: "h-7 bg-nvr-cyan text-white hover:bg-nvr-cyan/90",
|
|
810
|
+
disabled: !l.trim() || C.isPending,
|
|
811
|
+
children: [
|
|
812
|
+
C.isPending ? /* @__PURE__ */ t(R, { className: "h-3 w-3 animate-spin" }) : null,
|
|
813
|
+
"Send reply"
|
|
814
|
+
]
|
|
815
|
+
}
|
|
816
|
+
),
|
|
817
|
+
/* @__PURE__ */ t(
|
|
818
|
+
b,
|
|
819
|
+
{
|
|
820
|
+
type: "button",
|
|
821
|
+
size: "sm",
|
|
822
|
+
variant: "ghost",
|
|
823
|
+
className: "h-7",
|
|
824
|
+
onClick: () => f(null),
|
|
825
|
+
children: "Discard"
|
|
826
|
+
}
|
|
827
|
+
)
|
|
828
|
+
] })
|
|
829
|
+
]
|
|
830
|
+
}
|
|
831
|
+
),
|
|
832
|
+
g && e.can_undo && /* @__PURE__ */ t(
|
|
833
|
+
Me,
|
|
834
|
+
{
|
|
835
|
+
planId: e.plan_id,
|
|
836
|
+
undoUntil: e.undo_until,
|
|
837
|
+
onDone: () => {
|
|
838
|
+
u.invalidateQueries({ queryKey: v });
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
),
|
|
842
|
+
G && !e.can_undo && ((w = e.made_steps) == null ? void 0 : w.length) === 0 && /* @__PURE__ */ t("p", { className: "mt-2 text-[11px] text-muted-foreground", children: "Nothing this plan did can be undone." }),
|
|
843
|
+
m && /* @__PURE__ */ t("p", { className: "mt-2 text-[11.5px] text-rose-700 dark:text-rose-400", "data-task-do-plan-error": !0, children: m })
|
|
844
|
+
] });
|
|
845
|
+
}
|
|
846
|
+
function Le({ plan: e, waiting: n }) {
|
|
847
|
+
const o = e.steps.length, c = e.steps.filter((l) => l.state.status === "done" || l.state.status === "skipped"), d = e.steps.find((l) => l.state.status === "failed"), p = e.records_changed > 0 ? ` · ${A(e.records_changed, "record")} changed` : "";
|
|
848
|
+
let h = null, u = null, m = "text-foreground";
|
|
849
|
+
switch (e.status) {
|
|
850
|
+
case "proposed":
|
|
851
|
+
if (n) return null;
|
|
852
|
+
h = /* @__PURE__ */ t(ie, { className: "h-3.5 w-3.5 text-slate-400" }), u = "Nothing has run yet. Check the steps, then approve — or change or discard them.", m = "text-muted-foreground";
|
|
853
|
+
break;
|
|
854
|
+
case "running": {
|
|
855
|
+
const l = Math.min(o, c.length + 1);
|
|
856
|
+
h = /* @__PURE__ */ t(R, { className: "h-3.5 w-3.5 animate-spin text-nvr-cyan" }), u = `Running step ${l} of ${o}${p}`;
|
|
857
|
+
break;
|
|
858
|
+
}
|
|
859
|
+
case "executed":
|
|
860
|
+
h = /* @__PURE__ */ t(O, { className: "h-3.5 w-3.5 text-emerald-600 dark:text-emerald-400" }), u = `Done — ${A(o, "step")} ran${p}. The thread has a summary.`;
|
|
861
|
+
break;
|
|
862
|
+
case "failed":
|
|
863
|
+
case "paused":
|
|
864
|
+
h = /* @__PURE__ */ t(ne, { className: "h-3.5 w-3.5 text-amber-600 dark:text-amber-400" }), u = d ? `Paused at step ${d.n} — the reason is under it. Steps after it have not run.` : `Paused after ${A(c.length, "step")}${p}.`;
|
|
865
|
+
break;
|
|
866
|
+
case "rejected":
|
|
867
|
+
u = c.length ? "Stopped — the remaining steps did not run." : "Discarded — nothing changed.", m = "text-muted-foreground";
|
|
868
|
+
break;
|
|
869
|
+
default:
|
|
870
|
+
return null;
|
|
871
|
+
}
|
|
872
|
+
const x = o ? Math.round(c.length / o * 100) : 0;
|
|
873
|
+
return /* @__PURE__ */ a("div", { "data-task-do-status": e.status, children: [
|
|
874
|
+
/* @__PURE__ */ a("p", { className: U("flex items-center gap-1.5 text-[12px]", m), "aria-live": "polite", children: [
|
|
875
|
+
h,
|
|
876
|
+
u
|
|
877
|
+
] }),
|
|
878
|
+
(e.status === "running" || e.status === "failed" || e.status === "paused") && /* @__PURE__ */ t(
|
|
879
|
+
"div",
|
|
880
|
+
{
|
|
881
|
+
className: "mt-1.5 h-1 overflow-hidden rounded-full bg-slate-100 dark:bg-muted",
|
|
882
|
+
role: "progressbar",
|
|
883
|
+
"aria-valuemin": 0,
|
|
884
|
+
"aria-valuemax": o,
|
|
885
|
+
"aria-valuenow": c.length,
|
|
886
|
+
"aria-label": "Steps finished",
|
|
887
|
+
children: /* @__PURE__ */ t(
|
|
888
|
+
"div",
|
|
889
|
+
{
|
|
890
|
+
className: U(
|
|
891
|
+
"h-full rounded-full transition-[width] duration-300 ease-out motion-reduce:transition-none",
|
|
892
|
+
e.status === "running" ? "bg-nvr-cyan" : "bg-amber-500"
|
|
893
|
+
),
|
|
894
|
+
style: { width: `${x}%` }
|
|
895
|
+
}
|
|
896
|
+
)
|
|
897
|
+
}
|
|
898
|
+
)
|
|
899
|
+
] });
|
|
900
|
+
}
|
|
901
|
+
function Me({
|
|
902
|
+
planId: e,
|
|
903
|
+
undoUntil: n,
|
|
904
|
+
onDone: o
|
|
905
|
+
}) {
|
|
906
|
+
const c = Q(), [d, p] = k(!1), [h, u] = k(null), m = B({
|
|
907
|
+
queryKey: ["task-do", "undo", e],
|
|
908
|
+
queryFn: () => c.request(
|
|
909
|
+
V(`/ai/task-do/plans/${encodeURIComponent(e)}/undo`)
|
|
910
|
+
).then((i) => i.data.steps)
|
|
911
|
+
}), x = L({
|
|
912
|
+
mutationFn: () => c.request(
|
|
913
|
+
M(`/ai/task-do/plans/${encodeURIComponent(e)}/undo`, {})
|
|
914
|
+
).then((i) => i.data),
|
|
915
|
+
onSuccess: (i) => {
|
|
916
|
+
u(
|
|
917
|
+
`Restored ${i.undone} record${i.undone === 1 ? "" : "s"}${i.skipped ? `; ${i.skipped} changed since and left alone` : ""}${i.failed ? `; ${i.failed} failed (${i.errors[0] ?? ""})` : ""}.`
|
|
918
|
+
), p(!1), m.refetch(), o();
|
|
919
|
+
},
|
|
920
|
+
onError: (i) => u(q(i))
|
|
921
|
+
}), l = m.data ?? [], f = l.reduce((i, $) => i + $.revertible, 0), g = l.flatMap(
|
|
922
|
+
(i) => i.records.filter(($) => $.status === "changed" || $.status === "gone")
|
|
923
|
+
), P = l.filter((i) => i.not_revertible), N = fe(() => {
|
|
924
|
+
if (!n) return null;
|
|
925
|
+
const i = new Date(n);
|
|
926
|
+
return Number.isNaN(i.getTime()) ? null : i.toLocaleDateString(void 0, { month: "short", day: "numeric" });
|
|
927
|
+
}, [n]);
|
|
928
|
+
return /* @__PURE__ */ a(
|
|
929
|
+
"div",
|
|
930
|
+
{
|
|
931
|
+
className: "mt-3 rounded-md border border-slate-200 bg-white p-3 dark:border-border dark:bg-card",
|
|
932
|
+
"data-task-do-undo": !0,
|
|
933
|
+
children: [
|
|
934
|
+
/* @__PURE__ */ a("p", { className: "flex items-center gap-1.5 text-[12.5px] font-medium text-foreground", children: [
|
|
935
|
+
/* @__PURE__ */ t(re, { className: "h-3.5 w-3.5 text-slate-400" }),
|
|
936
|
+
" Undo what AI did",
|
|
937
|
+
N && /* @__PURE__ */ a("span", { className: "font-normal text-muted-foreground", children: [
|
|
938
|
+
"· possible until ",
|
|
939
|
+
N
|
|
940
|
+
] })
|
|
941
|
+
] }),
|
|
942
|
+
m.isLoading && /* @__PURE__ */ a("div", { className: "mt-2 space-y-1.5", children: [
|
|
943
|
+
/* @__PURE__ */ t(z, { className: "h-3.5 w-2/3" }),
|
|
944
|
+
/* @__PURE__ */ t(z, { className: "h-3.5 w-1/2" })
|
|
945
|
+
] }),
|
|
946
|
+
m.isError && /* @__PURE__ */ a("p", { className: "mt-1.5 text-[11.5px] text-rose-700 dark:text-rose-400", children: [
|
|
947
|
+
"Could not check what can be restored: ",
|
|
948
|
+
q(m.error)
|
|
949
|
+
] }),
|
|
950
|
+
m.data && /* @__PURE__ */ a("div", { className: "mt-2 space-y-2 text-[11.5px]", children: [
|
|
951
|
+
/* @__PURE__ */ a("p", { className: "flex items-start gap-1.5 text-foreground", children: [
|
|
952
|
+
/* @__PURE__ */ t(O, { className: "mt-0.5 h-3.5 w-3.5 shrink-0 text-emerald-600 dark:text-emerald-400" }),
|
|
953
|
+
f > 0 ? `${A(f, "record")} will go back to what ${f === 1 ? "it was" : "they were"} before the plan ran.` : "Nothing is left to restore."
|
|
954
|
+
] }),
|
|
955
|
+
g.length > 0 && /* @__PURE__ */ a("div", { className: "flex items-start gap-1.5", "data-task-do-undo-conflicts": !0, children: [
|
|
956
|
+
/* @__PURE__ */ t(J, { className: "mt-0.5 h-3.5 w-3.5 shrink-0 text-slate-400" }),
|
|
957
|
+
/* @__PURE__ */ a("div", { className: "min-w-0", children: [
|
|
958
|
+
/* @__PURE__ */ a("p", { className: "text-foreground", children: [
|
|
959
|
+
A(g.length, "record"),
|
|
960
|
+
" left as",
|
|
961
|
+
" ",
|
|
962
|
+
g.length === 1 ? "it is" : "they are",
|
|
963
|
+
" — changed since, and newer edits are never overwritten:"
|
|
964
|
+
] }),
|
|
965
|
+
/* @__PURE__ */ a("ul", { className: "mt-0.5 space-y-px text-muted-foreground", children: [
|
|
966
|
+
g.slice(0, 4).map((i) => /* @__PURE__ */ a("li", { className: "truncate", children: [
|
|
967
|
+
i.label,
|
|
968
|
+
" — ",
|
|
969
|
+
i.reason ?? i.status
|
|
970
|
+
] }, `${i.collection}:${i.id}`)),
|
|
971
|
+
g.length > 4 && /* @__PURE__ */ a("li", { children: [
|
|
972
|
+
"+",
|
|
973
|
+
g.length - 4,
|
|
974
|
+
" more"
|
|
975
|
+
] })
|
|
976
|
+
] })
|
|
977
|
+
] })
|
|
978
|
+
] }),
|
|
979
|
+
P.length > 0 && /* @__PURE__ */ a("div", { className: "flex items-start gap-1.5 text-muted-foreground", children: [
|
|
980
|
+
/* @__PURE__ */ t(J, { className: "mt-0.5 h-3.5 w-3.5 shrink-0 text-slate-400" }),
|
|
981
|
+
/* @__PURE__ */ a("div", { className: "min-w-0", children: [
|
|
982
|
+
/* @__PURE__ */ t("p", { children: "Can’t be undone:" }),
|
|
983
|
+
/* @__PURE__ */ t("ul", { className: "mt-0.5 space-y-px", children: P.map((i) => /* @__PURE__ */ a("li", { children: [
|
|
984
|
+
"Step ",
|
|
985
|
+
i.n,
|
|
986
|
+
" — ",
|
|
987
|
+
i.not_revertible
|
|
988
|
+
] }, i.step_id)) })
|
|
989
|
+
] })
|
|
990
|
+
] })
|
|
991
|
+
] }),
|
|
992
|
+
h && /* @__PURE__ */ t("p", { className: "mt-2 text-[11.5px] text-foreground", "aria-live": "polite", children: h }),
|
|
993
|
+
f > 0 && /* @__PURE__ */ a("div", { className: "mt-2.5 flex items-center gap-2", children: [
|
|
994
|
+
/* @__PURE__ */ a(
|
|
995
|
+
b,
|
|
996
|
+
{
|
|
997
|
+
size: "sm",
|
|
998
|
+
variant: d ? "default" : "outline",
|
|
999
|
+
className: U("h-7", d && "bg-nvr-cyan text-white hover:bg-nvr-cyan/90"),
|
|
1000
|
+
disabled: x.isPending,
|
|
1001
|
+
onClick: () => d ? x.mutate() : p(!0),
|
|
1002
|
+
"data-task-do-undo-run": !0,
|
|
1003
|
+
children: [
|
|
1004
|
+
x.isPending ? /* @__PURE__ */ t(R, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ t(se, { className: "h-3 w-3" }),
|
|
1005
|
+
d ? `Yes, restore ${A(f, "record")}` : `Restore ${A(f, "record")}`
|
|
1006
|
+
]
|
|
1007
|
+
}
|
|
1008
|
+
),
|
|
1009
|
+
d && /* @__PURE__ */ t(b, { size: "sm", variant: "ghost", className: "h-7", onClick: () => p(!1), children: "Cancel" })
|
|
1010
|
+
] })
|
|
1011
|
+
]
|
|
1012
|
+
}
|
|
1013
|
+
);
|
|
1014
|
+
}
|
|
1015
|
+
export {
|
|
1016
|
+
Xe as TaskDoButton,
|
|
1017
|
+
Re as TaskDoPanel,
|
|
1018
|
+
Se as humanMinutes,
|
|
1019
|
+
Ce as humanSeconds,
|
|
1020
|
+
qe as taskDoAllowed,
|
|
1021
|
+
Pe as useTaskDoAvailable
|
|
1022
|
+
};
|