camox 0.56.0 → 0.57.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.
@@ -1,5 +1,6 @@
1
1
  import { AuthContext } from "../../../lib/auth.js";
2
2
  import { useCurrentDraftId, useDraftScope } from "../../../lib/draft-scope.js";
3
+ import { useNavigate } from "../../navigation/navigation.js";
3
4
  import { reads, useReadQuery } from "../../../lib/studio-reads.js";
4
5
  import { cn } from "../../../lib/utils.js";
5
6
  import { BOTTOM_CARD_EDGES, CARD_BODY_EDGES } from "../../preview/components/SidebarStack.js";
@@ -17,7 +18,8 @@ import { EMPTY_THREAD_VIEW } from "@camox/api-contract/threads";
17
18
  * The Agent Sidebar's Chat widget, where an editor works with Camox's agent in a thread. Elsewhere in the
18
19
  * studio it is only hidden: the studio keeps following the editor's runs there. It follows
19
20
  * where the studio is: the editor's own Live thread on Live, and the draft's thread in a draft.
20
- * When the Live thread starts a draft, the studio enters it with the thread.
21
+ * When the agent on Live hands the editor's request off to a draft, the studio that asked enters
22
+ * it, if it still shows Live; the card the Live turn ends on opens it too.
21
23
  */
22
24
  function ChatWidget(t0) {
23
25
  const $ = c(6);
@@ -62,7 +64,7 @@ function ChatWidget(t0) {
62
64
  return t4;
63
65
  }
64
66
  function CurrentThread() {
65
- const $ = c(15);
67
+ const $ = c(14);
66
68
  const { apiUrl, projectUuid } = React.useContext(AuthContext);
67
69
  let t0;
68
70
  if ($[0] !== projectUuid) {
@@ -73,125 +75,105 @@ function CurrentThread() {
73
75
  const { data: project } = useReadQuery(t0);
74
76
  const draftId = useCurrentDraftId();
75
77
  const draftScope = useDraftScope();
76
- const [carried, setCarried] = React.useState();
78
+ const navigate = useNavigate();
77
79
  let t1;
78
80
  if ($[2] !== draftScope) {
79
- t1 = (started, thread) => {
80
- if (draftScope.current() !== null) return;
81
- const { startedDraft: _, continuedIn: __, ...state } = thread.state;
82
- setCarried({
83
- draftId: started,
84
- thread: {
85
- ...thread,
86
- state
87
- }
88
- });
89
- draftScope.enterStarted(started);
90
- };
81
+ t1 = (started) => draftScope.enterStarted(started);
91
82
  $[2] = draftScope;
92
83
  $[3] = t1;
93
84
  } else t1 = $[3];
94
85
  const enterDraft = t1;
95
86
  let t2;
96
- let t3;
97
- if ($[4] !== draftScope) {
98
- t2 = () => draftScope.subscribe((t4) => {
99
- const { move } = t4;
100
- if (move !== "started") setCarried(void 0);
87
+ if ($[4] !== navigate) {
88
+ t2 = (next) => void navigate({
89
+ to: window.location.href,
90
+ draft: next
101
91
  });
102
- t3 = [draftScope];
103
- $[4] = draftScope;
92
+ $[4] = navigate;
104
93
  $[5] = t2;
105
- $[6] = t3;
106
- } else {
107
- t2 = $[5];
108
- t3 = $[6];
109
- }
110
- React.useEffect(t2, t3);
94
+ } else t2 = $[5];
95
+ const openDraft = t2;
111
96
  if (!project) {
112
- let t4;
113
- if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
114
- t4 = /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(ThreadMessages, { view: EMPTY_THREAD_VIEW }), /* @__PURE__ */ jsx(ThreadComposer, { disabled: true })] });
115
- $[7] = t4;
116
- } else t4 = $[7];
117
- return t4;
97
+ let t3;
98
+ if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
99
+ t3 = /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(ThreadMessages, { view: EMPTY_THREAD_VIEW }), /* @__PURE__ */ jsx(ThreadComposer, { disabled: true })] });
100
+ $[6] = t3;
101
+ } else t3 = $[6];
102
+ return t3;
118
103
  }
119
- const t4 = `${project.id}:${draftId ?? "live"}`;
120
- const t5 = carried?.draftId === draftId ? carried.thread : void 0;
121
- let t6;
122
- if ($[8] !== apiUrl || $[9] !== draftId || $[10] !== enterDraft || $[11] !== project.id || $[12] !== t4 || $[13] !== t5) {
123
- t6 = /* @__PURE__ */ jsx(Thread, {
104
+ const t3 = `${project.id}:${draftId ?? "live"}`;
105
+ let t4;
106
+ if ($[7] !== apiUrl || $[8] !== draftId || $[9] !== enterDraft || $[10] !== openDraft || $[11] !== project.id || $[12] !== t3) {
107
+ t4 = /* @__PURE__ */ jsx(Thread, {
124
108
  apiUrl,
125
109
  projectId: project.id,
126
110
  draftId,
127
- carried: t5,
128
- onEnterDraft: enterDraft
129
- }, t4);
130
- $[8] = apiUrl;
131
- $[9] = draftId;
132
- $[10] = enterDraft;
111
+ onEnterDraft: enterDraft,
112
+ onOpenDraft: openDraft
113
+ }, t3);
114
+ $[7] = apiUrl;
115
+ $[8] = draftId;
116
+ $[9] = enterDraft;
117
+ $[10] = openDraft;
133
118
  $[11] = project.id;
134
- $[12] = t4;
135
- $[13] = t5;
136
- $[14] = t6;
137
- } else t6 = $[14];
138
- return t6;
119
+ $[12] = t3;
120
+ $[13] = t4;
121
+ } else t4 = $[13];
122
+ return t4;
139
123
  }
140
124
  function Thread(t0) {
141
125
  const $ = c(26);
142
- const { apiUrl, projectId, draftId, carried, onEnterDraft } = t0;
126
+ const { apiUrl, projectId, draftId, onEnterDraft, onOpenDraft } = t0;
143
127
  let t1;
144
- if ($[0] !== carried || $[1] !== onEnterDraft) {
145
- t1 = {
146
- carried,
147
- onEnterDraft
148
- };
149
- $[0] = carried;
150
- $[1] = onEnterDraft;
151
- $[2] = t1;
152
- } else t1 = $[2];
128
+ if ($[0] !== onEnterDraft) {
129
+ t1 = { onEnterDraft };
130
+ $[0] = onEnterDraft;
131
+ $[1] = t1;
132
+ } else t1 = $[1];
153
133
  const { view, sending, send, stop, error, touched } = useThread(apiUrl, projectId, draftId, t1);
154
134
  const follow = React.use(FollowAgentContext);
155
135
  let t2;
156
- if ($[3] !== follow) {
136
+ if ($[2] !== follow) {
157
137
  t2 = (batch) => follow?.receive(batch);
158
- $[3] = follow;
159
- $[4] = t2;
160
- } else t2 = $[4];
138
+ $[2] = follow;
139
+ $[3] = t2;
140
+ } else t2 = $[3];
161
141
  const followTouched = React.useEffectEvent(t2);
162
142
  let t3;
163
- if ($[5] !== followTouched || $[6] !== touched) {
143
+ if ($[4] !== followTouched || $[5] !== touched) {
164
144
  t3 = () => {
165
145
  if (touched) followTouched(touched.batch);
166
146
  };
167
- $[5] = followTouched;
168
- $[6] = touched;
169
- $[7] = t3;
170
- } else t3 = $[7];
147
+ $[4] = followTouched;
148
+ $[5] = touched;
149
+ $[6] = t3;
150
+ } else t3 = $[6];
171
151
  let t4;
172
- if ($[8] !== touched) {
152
+ if ($[7] !== touched) {
173
153
  t4 = [touched];
174
- $[8] = touched;
175
- $[9] = t4;
176
- } else t4 = $[9];
154
+ $[7] = touched;
155
+ $[8] = t4;
156
+ } else t4 = $[8];
177
157
  React.useEffect(t3, t4);
178
158
  let t5;
179
- if ($[10] !== follow || $[11] !== send) {
159
+ if ($[9] !== follow || $[10] !== send) {
180
160
  t5 = (text) => {
181
161
  follow?.resume();
182
162
  send(text);
183
163
  };
184
- $[10] = follow;
185
- $[11] = send;
186
- $[12] = t5;
187
- } else t5 = $[12];
164
+ $[9] = follow;
165
+ $[10] = send;
166
+ $[11] = t5;
167
+ } else t5 = $[11];
188
168
  const sendFollowing = t5;
189
169
  let t6;
190
- if ($[13] !== sending || $[14] !== view) {
170
+ if ($[12] !== onOpenDraft || $[13] !== sending || $[14] !== view) {
191
171
  t6 = /* @__PURE__ */ jsx(ThreadMessages, {
192
172
  view,
193
- sending
173
+ sending,
174
+ onOpenDraft
194
175
  });
176
+ $[12] = onOpenDraft;
195
177
  $[13] = sending;
196
178
  $[14] = view;
197
179
  $[15] = t6;