camox 0.74.1 → 0.76.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/core/lib/artifactRuntime.js +4 -2
  2. package/dist/features/provider/AuthenticatedCamoxProvider.js +75 -63
  3. package/dist/features/renderer/RendererFrames.js +47 -41
  4. package/dist/features/routes/pageRuntime.d.ts +6 -4
  5. package/dist/features/routes/pageRuntime.js +5 -1
  6. package/dist/features/studio/components/ChatWidget.js +137 -121
  7. package/dist/features/studio/components/ClearThread.js +121 -0
  8. package/dist/features/studio/components/DeleteDraftDialog.js +67 -65
  9. package/dist/features/studio/components/DraftBar.js +60 -49
  10. package/dist/features/studio/components/DraftNotices.js +149 -0
  11. package/dist/features/studio/components/DraftsControl.js +217 -180
  12. package/dist/features/studio/components/DraftsSheet.js +387 -0
  13. package/dist/features/studio/components/PublishedTab.js +511 -0
  14. package/dist/features/studio/components/ReviewDraftDialog.js +104 -89
  15. package/dist/features/studio/components/SheetTable.js +46 -0
  16. package/dist/features/studio/components/Specialists.js +1 -1
  17. package/dist/features/studio/components/ThreadMessages.js +376 -171
  18. package/dist/features/studio/draftLabel.js +15 -1
  19. package/dist/features/studio/draftNotice.js +1 -0
  20. package/dist/features/studio/studioStore.js +5 -5
  21. package/dist/features/studio/useArchiveDraft.js +60 -0
  22. package/dist/features/studio/useRestoreDraft.js +70 -0
  23. package/dist/features/studio/viewSwitch.js +19 -11
  24. package/dist/lib/draft-scope.d.ts +1 -1
  25. package/dist/lib/draft-scope.js +6 -3
  26. package/dist/lib/queries.js +12 -1
  27. package/dist/lib/studio-reads.js +22 -0
  28. package/dist/lib/use-project-room.js +19 -13
  29. package/dist/lib/use-thread.js +1 -1
  30. package/dist/package.js +1 -1
  31. package/dist/studio.css +1 -1
  32. package/package.json +4 -4
@@ -1,6 +1,7 @@
1
1
  import { cn } from "../../../lib/utils.js";
2
2
  import { studioStore } from "../studioStore.js";
3
3
  import { plural } from "../draftLabel.js";
4
+ import { useArchiveDraft } from "../useArchiveDraft.js";
4
5
  import { useDrafts } from "./DraftsControl.js";
5
6
  import { c } from "react/compiler-runtime";
6
7
  import * as React from "react";
@@ -16,16 +17,18 @@ import { FloatingToolbar } from "@camox/ui/floating-toolbar";
16
17
  */
17
18
  const SETTLE_MS = 1500;
18
19
  /**
19
- * Asks what to do with the draft being viewed, once its edits settle: delete it or publish it.
20
+ * Asks what to do with the draft being viewed, once its edits settle: archive it, unless it's
21
+ * Camox's Catch-up Draft, or publish it.
20
22
  * Publishing waits while Camox's agent is mid-turn in the draft, so half a change never goes live;
21
23
  * nothing else Camox does holds it here. `stacked` places it in the Preview toolbar's column, just above the toolbar;
22
24
  * otherwise it floats at the bottom of the screen on its own.
23
25
  */
24
26
  function DraftBar(t0) {
25
- const $ = c(26);
27
+ const $ = c(32);
26
28
  const { stacked: t1 } = t0;
27
29
  const stacked = t1 === void 0 ? false : t1;
28
30
  const { projectId, current } = useDrafts();
31
+ const { archive, archiving } = useArchiveDraft(projectId);
29
32
  const settled = useSettled(current?.id ?? null, current?.lastChangedAt ?? null);
30
33
  let t2;
31
34
  if ($[0] !== current) {
@@ -68,82 +71,90 @@ function DraftBar(t0) {
68
71
  $[9] = t7;
69
72
  } else t7 = $[9];
70
73
  let t8;
71
- if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
72
- t8 = /* @__PURE__ */ jsx(Button, {
74
+ if ($[10] !== archive || $[11] !== archiving || $[12] !== current.catchUp) {
75
+ t8 = !current.catchUp && /* @__PURE__ */ jsx(Button, {
73
76
  type: "button",
74
77
  variant: "outline",
75
- onClick: _temp,
76
- children: "Delete"
78
+ disabled: archiving,
79
+ onClick: archive,
80
+ children: "Archive"
77
81
  });
78
- $[10] = t8;
79
- } else t8 = $[10];
82
+ $[10] = archive;
83
+ $[11] = archiving;
84
+ $[12] = current.catchUp;
85
+ $[13] = t8;
86
+ } else t8 = $[13];
80
87
  const t9 = !working;
81
88
  const t10 = working ? 0 : void 0;
82
89
  let t11;
83
- if ($[11] !== t10) {
90
+ if ($[14] !== t10) {
84
91
  t11 = /* @__PURE__ */ jsx("span", { tabIndex: t10 });
85
- $[11] = t10;
86
- $[12] = t11;
87
- } else t11 = $[12];
92
+ $[14] = t10;
93
+ $[15] = t11;
94
+ } else t11 = $[15];
88
95
  const t12 = empty || working;
89
96
  let t13;
90
- if ($[13] !== t12) {
97
+ if ($[16] !== t12) {
91
98
  t13 = /* @__PURE__ */ jsx(Button, {
92
99
  type: "button",
93
100
  disabled: t12,
94
- onClick: _temp2,
101
+ onClick: _temp,
95
102
  children: "Publish…"
96
103
  });
97
- $[13] = t12;
98
- $[14] = t13;
99
- } else t13 = $[14];
104
+ $[16] = t12;
105
+ $[17] = t13;
106
+ } else t13 = $[17];
100
107
  let t14;
101
- if ($[15] !== t11 || $[16] !== t13) {
108
+ if ($[18] !== t11 || $[19] !== t13) {
102
109
  t14 = /* @__PURE__ */ jsx(TooltipTrigger, {
103
110
  render: t11,
104
111
  children: t13
105
112
  });
106
- $[15] = t11;
107
- $[16] = t13;
108
- $[17] = t14;
109
- } else t14 = $[17];
113
+ $[18] = t11;
114
+ $[19] = t13;
115
+ $[20] = t14;
116
+ } else t14 = $[20];
110
117
  let t15;
111
- if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
118
+ if ($[21] === Symbol.for("react.memo_cache_sentinel")) {
112
119
  t15 = /* @__PURE__ */ jsx(TooltipContent, { children: "Camox's agent is working" });
113
- $[18] = t15;
114
- } else t15 = $[18];
120
+ $[21] = t15;
121
+ } else t15 = $[21];
115
122
  let t16;
116
- if ($[19] !== t14 || $[20] !== t9) {
117
- t16 = /* @__PURE__ */ jsxs("div", {
118
- className: "flex items-center gap-2",
119
- children: [t8, /* @__PURE__ */ jsxs(Tooltip, {
120
- disabled: t9,
121
- children: [t14, t15]
122
- })]
123
+ if ($[22] !== t14 || $[23] !== t9) {
124
+ t16 = /* @__PURE__ */ jsxs(Tooltip, {
125
+ disabled: t9,
126
+ children: [t14, t15]
123
127
  });
124
- $[19] = t14;
125
- $[20] = t9;
126
- $[21] = t16;
127
- } else t16 = $[21];
128
+ $[22] = t14;
129
+ $[23] = t9;
130
+ $[24] = t16;
131
+ } else t16 = $[24];
128
132
  let t17;
129
- if ($[22] !== t16 || $[23] !== t4 || $[24] !== t7) {
130
- t17 = /* @__PURE__ */ jsxs(FloatingToolbar, {
133
+ if ($[25] !== t16 || $[26] !== t8) {
134
+ t17 = /* @__PURE__ */ jsxs("div", {
135
+ className: "flex items-center gap-2",
136
+ children: [t8, t16]
137
+ });
138
+ $[25] = t16;
139
+ $[26] = t8;
140
+ $[27] = t17;
141
+ } else t17 = $[27];
142
+ let t18;
143
+ if ($[28] !== t17 || $[29] !== t4 || $[30] !== t7) {
144
+ t18 = /* @__PURE__ */ jsxs(FloatingToolbar, {
131
145
  "aria-label": "Draft",
132
146
  className: t4,
133
- children: [t7, t16]
147
+ children: [t7, t17]
134
148
  });
135
- $[22] = t16;
136
- $[23] = t4;
137
- $[24] = t7;
138
- $[25] = t17;
139
- } else t17 = $[25];
140
- return t17;
141
- }
142
- function _temp2() {
143
- return studioStore.send({ type: "openReviewDraftDialog" });
149
+ $[28] = t17;
150
+ $[29] = t4;
151
+ $[30] = t7;
152
+ $[31] = t18;
153
+ } else t18 = $[31];
154
+ return t18;
144
155
  }
145
156
  function _temp() {
146
- return studioStore.send({ type: "openDeleteDraftDialog" });
157
+ return studioStore.send({ type: "openReviewDraftDialog" });
147
158
  }
148
159
  /**
149
160
  * Whether the draft went without a change for `SETTLE_MS`. Once settled it stays so for that
@@ -0,0 +1,149 @@
1
+ import { useDraftScope } from "../../../lib/draft-scope.js";
2
+ import { AuthContext } from "../../../lib/auth.js";
3
+ import { reads, useReadQuery } from "../../../lib/studio-reads.js";
4
+ import { draftNoticeMessage } from "../draftNotice.js";
5
+ import { useRestoreDraft } from "../useRestoreDraft.js";
6
+ import { c } from "react/compiler-runtime";
7
+ import * as React from "react";
8
+ import { jsx, jsxs } from "react/jsx-runtime";
9
+ import { toast } from "@camox/ui/toaster";
10
+ import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from "@camox/ui/alert-dialog";
11
+ import { Spinner } from "@camox/ui/spinner";
12
+
13
+ //#region src/features/studio/components/DraftNotices.tsx
14
+ /**
15
+ * Says why the studio shows Live when the draft a member opened, or was in, can't be shown. A
16
+ * draft that's only archived can come back (ADR 0046), so a dialog says so and offers to restore
17
+ * it; anything else is a toast. Opening the link restores nothing by itself.
18
+ */
19
+ function DraftNotices() {
20
+ const $ = c(34);
21
+ const draftScope = useDraftScope();
22
+ const [archived, setArchived] = React.useState(null);
23
+ let t0;
24
+ let t1;
25
+ if ($[0] !== draftScope) {
26
+ t0 = () => draftScope.onNotice((notice) => {
27
+ if (notice.reason === "archived") setArchived(notice);
28
+ else toast(draftNoticeMessage(notice));
29
+ });
30
+ t1 = [draftScope];
31
+ $[0] = draftScope;
32
+ $[1] = t0;
33
+ $[2] = t1;
34
+ } else {
35
+ t0 = $[1];
36
+ t1 = $[2];
37
+ }
38
+ React.useEffect(t0, t1);
39
+ const { projectUuid } = React.useContext(AuthContext);
40
+ let t2;
41
+ if ($[3] !== projectUuid) {
42
+ t2 = reads.project({ projectUuid });
43
+ $[3] = projectUuid;
44
+ $[4] = t2;
45
+ } else t2 = $[4];
46
+ const { data: project } = useReadQuery(t2);
47
+ let t3;
48
+ if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
49
+ t3 = { onRestored: () => setArchived(null) };
50
+ $[5] = t3;
51
+ } else t3 = $[5];
52
+ const { restore, restoring } = useRestoreDraft(project?.id, t3);
53
+ const t4 = archived !== null;
54
+ let t5;
55
+ if ($[6] !== restoring) {
56
+ t5 = (open) => {
57
+ if (!open && !restoring) setArchived(null);
58
+ };
59
+ $[6] = restoring;
60
+ $[7] = t5;
61
+ } else t5 = $[7];
62
+ let t6;
63
+ if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
64
+ t6 = /* @__PURE__ */ jsx(AlertDialogTitle, { children: "This draft is archived" });
65
+ $[8] = t6;
66
+ } else t6 = $[8];
67
+ let t7;
68
+ if ($[9] !== archived) {
69
+ t7 = archived && draftNoticeMessage(archived);
70
+ $[9] = archived;
71
+ $[10] = t7;
72
+ } else t7 = $[10];
73
+ let t8;
74
+ if ($[11] !== t7) {
75
+ t8 = /* @__PURE__ */ jsxs(AlertDialogHeader, { children: [t6, /* @__PURE__ */ jsxs(AlertDialogDescription, { children: [t7, " Restore it to pick up where it stopped."] })] });
76
+ $[11] = t7;
77
+ $[12] = t8;
78
+ } else t8 = $[12];
79
+ const t9 = restoring !== void 0;
80
+ let t10;
81
+ if ($[13] !== t9) {
82
+ t10 = /* @__PURE__ */ jsx(AlertDialogCancel, {
83
+ variant: "outline",
84
+ size: "default",
85
+ disabled: t9,
86
+ children: "Stay on Live"
87
+ });
88
+ $[13] = t9;
89
+ $[14] = t10;
90
+ } else t10 = $[14];
91
+ const t11 = restoring !== void 0 || !project;
92
+ let t12;
93
+ if ($[15] !== archived || $[16] !== restore) {
94
+ t12 = () => {
95
+ if (archived) restore(archived.draftId);
96
+ };
97
+ $[15] = archived;
98
+ $[16] = restore;
99
+ $[17] = t12;
100
+ } else t12 = $[17];
101
+ let t13;
102
+ if ($[18] !== restoring) {
103
+ t13 = restoring !== void 0 ? /* @__PURE__ */ jsx(Spinner, {}) : null;
104
+ $[18] = restoring;
105
+ $[19] = t13;
106
+ } else t13 = $[19];
107
+ let t14;
108
+ if ($[20] !== t11 || $[21] !== t12 || $[22] !== t13) {
109
+ t14 = /* @__PURE__ */ jsxs(AlertDialogAction, {
110
+ disabled: t11,
111
+ onClick: t12,
112
+ children: [t13, "Restore"]
113
+ });
114
+ $[20] = t11;
115
+ $[21] = t12;
116
+ $[22] = t13;
117
+ $[23] = t14;
118
+ } else t14 = $[23];
119
+ let t15;
120
+ if ($[24] !== t10 || $[25] !== t14) {
121
+ t15 = /* @__PURE__ */ jsxs(AlertDialogFooter, { children: [t10, t14] });
122
+ $[24] = t10;
123
+ $[25] = t14;
124
+ $[26] = t15;
125
+ } else t15 = $[26];
126
+ let t16;
127
+ if ($[27] !== t15 || $[28] !== t8) {
128
+ t16 = /* @__PURE__ */ jsxs(AlertDialogContent, { children: [t8, t15] });
129
+ $[27] = t15;
130
+ $[28] = t8;
131
+ $[29] = t16;
132
+ } else t16 = $[29];
133
+ let t17;
134
+ if ($[30] !== t16 || $[31] !== t4 || $[32] !== t5) {
135
+ t17 = /* @__PURE__ */ jsx(AlertDialog, {
136
+ open: t4,
137
+ onOpenChange: t5,
138
+ children: t16
139
+ });
140
+ $[30] = t16;
141
+ $[31] = t4;
142
+ $[32] = t5;
143
+ $[33] = t17;
144
+ } else t17 = $[33];
145
+ return t17;
146
+ }
147
+
148
+ //#endregion
149
+ export { DraftNotices };