@parallelworks/tandem-web 0.183.0 → 0.184.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.
@@ -5,19 +5,21 @@ import { isoDate as c } from "../lib/datePhrases.js";
5
5
  import { docPath as l, useTemplateValues as u } from "../lib/docs.js";
6
6
  import { modeBelow as d, runnerModeCommand as f, usePermissionModeName as p } from "../lib/permissionModes.js";
7
7
  import { Link as m } from "../lib/router.js";
8
- import { AgentIcon as h, CalendarIcon as g, FileTextIcon as _, FolderIcon as v, UploadIcon as y } from "./icons.js";
9
- import { useMarkdownTransfer as b } from "./MarkdownTransfer.js";
10
- import { RunnerBadge as x } from "./RunnerBadge.js";
11
- import { ActionMenu as S, Button as C, ErrorText as w, Popover as T, RelativeTime as E, Select as D, Textarea as O, useClosePopover as k } from "@parallelworks/ui";
12
- import { useEffect as A, useState as j } from "react";
13
- import { useErrorMessage as M } from "@parallelworks/problem/react";
14
- import { useFormatter as N, useTranslations as P } from "use-intl";
15
- import { jsx as F, jsxs as I } from "react/jsx-runtime";
16
- import { useMutation as L, useQuery as R, useQueryClient as z } from "@tanstack/react-query";
8
+ import { subpageViewsQuery as h, useSubpageActions as g } from "../lib/subpageViews.js";
9
+ import { AgentIcon as _, CalendarIcon as v, FileTextIcon as y, FolderIcon as b, SpreadsheetIcon as x, UploadIcon as S } from "./icons.js";
10
+ import { useMarkdownTransfer as C } from "./MarkdownTransfer.js";
11
+ import { RunnerBadge as w } from "./RunnerBadge.js";
12
+ import { subpageLayouts as T } from "./SubpageViews.js";
13
+ import { ActionMenu as E, Button as D, ErrorText as O, Popover as k, RelativeTime as A, Select as j, Textarea as M, useClosePopover as N } from "@parallelworks/ui";
14
+ import { useEffect as P, useState as F } from "react";
15
+ import { useErrorMessage as I } from "@parallelworks/problem/react";
16
+ import { useFormatter as L, useTranslations as R } from "use-intl";
17
+ import { jsx as z, jsxs as B } from "react/jsx-runtime";
18
+ import { useMutation as V, useQuery as H, useQueryClient as U } from "@tanstack/react-query";
17
19
  // src/components/DocStart.tsx
18
- function B(e, t) {
19
- let [n, r] = j(e ? e.isEmpty : !t.trim());
20
- return A(() => {
20
+ function W(e, t) {
21
+ let [n, r] = F(e ? e.isEmpty : !t.trim());
22
+ return P(() => {
21
23
  if (!e) return;
22
24
  let t = () => r(e.isEmpty);
23
25
  return t(), e.on("update", t), () => {
@@ -25,8 +27,8 @@ function B(e, t) {
25
27
  };
26
28
  }, [e]), n;
27
29
  }
28
- function V({ workspace: n, doc: i, team: a, editor: o }) {
29
- let s = P("docStart"), l = P("docs"), d = N(), f = M(), p = z(), m = B(o, i.body ?? ""), { data: h = [] } = R(r(n)), x = b(n), T = u(), E = L({
30
+ function G({ workspace: n, doc: i, team: a, editor: o }) {
31
+ let s = R("docStart"), l = R("docs"), d = L(), f = I(), p = U(), m = W(o, i.body ?? ""), { data: _ = [] } = H(r(n)), w = C(n), k = R("subpages"), A = g(n), { data: j = [] } = H(h(n, i.key)), M = u(), N = V({
30
32
  mutationFn: async (r) => t(await e.PATCH("/api/v1/workspaces/{workspace}/docs/{doc}", {
31
33
  params: { path: {
32
34
  workspace: n,
@@ -49,108 +51,130 @@ function V({ workspace: n, doc: i, team: a, editor: o }) {
49
51
  "docs"
50
52
  ] })
51
53
  });
52
- if (!m) return null;
53
- let D = !i.title.trim() || i.title === l("untitled"), O = /* @__PURE__ */ new Date(), k = h.filter((e) => e.starter || (e.teamId ?? "") === (i.teamId ?? "")).sort((e, t) => Number(e.starter) - Number(t.starter));
54
- return /* @__PURE__ */ I("section", {
54
+ if (!m || j.length > 0) return null;
55
+ let P = !i.title.trim() || i.title === l("untitled"), F = /* @__PURE__ */ new Date(), G = _.filter((e) => e.starter || (e.teamId ?? "") === (i.teamId ?? "")).sort((e, t) => Number(e.starter) - Number(t.starter));
56
+ return /* @__PURE__ */ B("section", {
55
57
  "aria-labelledby": "doc-start",
56
58
  className: "mt-2",
57
59
  children: [
58
- /* @__PURE__ */ F("h2", {
60
+ /* @__PURE__ */ z("h2", {
59
61
  id: "doc-start",
60
62
  className: "text-xs text-muted-foreground",
61
63
  children: s("title")
62
64
  }),
63
- /* @__PURE__ */ I("div", {
65
+ /* @__PURE__ */ B("div", {
64
66
  className: "mt-2 flex flex-wrap items-center gap-2",
65
67
  children: [
66
- /* @__PURE__ */ F(H, {
68
+ /* @__PURE__ */ z(K, {
67
69
  workspace: n,
68
70
  doc: i,
69
71
  team: a
70
72
  }),
71
- /* @__PURE__ */ I(C, {
73
+ /* @__PURE__ */ B(D, {
72
74
  size: "sm",
73
75
  variant: "secondary",
74
- disabled: E.isPending,
75
- onClick: () => E.mutate({
76
+ disabled: N.isPending,
77
+ onClick: () => N.mutate({
76
78
  startFrom: "meeting-notes",
77
- variables: { date: c(O) },
78
- ...D && { title: s("meetingTitle", { date: d.dateTime(O, { dateStyle: "medium" }) }) }
79
+ variables: { date: c(F) },
80
+ ...P && { title: s("meetingTitle", { date: d.dateTime(F, { dateStyle: "medium" }) }) }
79
81
  }),
80
- children: [/* @__PURE__ */ F(g, { className: "size-3.5" }), s("meetingNotes")]
82
+ children: [/* @__PURE__ */ z(v, { className: "size-3.5" }), s("meetingNotes")]
81
83
  }),
82
- /* @__PURE__ */ F(S, {
84
+ /* @__PURE__ */ z(E, {
85
+ label: s("database"),
86
+ items: T.filter((e) => e.database).map(({ layout: e, icon: t, message: n }) => ({
87
+ label: k(n),
88
+ icon: /* @__PURE__ */ z(t, {}),
89
+ onClick: () => A.addView.mutate({
90
+ doc: i.key,
91
+ name: k(n),
92
+ layout: e
93
+ })
94
+ })),
95
+ trigger: /* @__PURE__ */ B(D, {
96
+ size: "sm",
97
+ variant: "secondary",
98
+ disabled: A.addView.isPending,
99
+ children: [/* @__PURE__ */ z(x, { className: "size-3.5" }), s("database")]
100
+ })
101
+ }),
102
+ /* @__PURE__ */ z(E, {
83
103
  label: s("templates"),
84
104
  empty: s("noTemplates"),
85
- items: k.map((e) => ({
105
+ items: G.map((e) => ({
86
106
  label: e.title,
87
- onClick: () => E.mutate({
107
+ onClick: () => N.mutate({
88
108
  startFrom: e.id,
89
- variables: T()
109
+ variables: M()
90
110
  })
91
111
  })),
92
- trigger: /* @__PURE__ */ I(C, {
112
+ trigger: /* @__PURE__ */ B(D, {
93
113
  size: "sm",
94
114
  variant: "secondary",
95
- disabled: E.isPending,
96
- children: [/* @__PURE__ */ F(_, { className: "size-3.5" }), s("templates")]
115
+ disabled: N.isPending,
116
+ children: [/* @__PURE__ */ z(y, { className: "size-3.5" }), s("templates")]
97
117
  })
98
118
  }),
99
- /* @__PURE__ */ I(C, {
119
+ /* @__PURE__ */ B(D, {
100
120
  size: "sm",
101
121
  variant: "secondary",
102
- onClick: () => x.pick({ parent: i.key }),
103
- children: [/* @__PURE__ */ F(y, { className: "size-3.5" }), s("importFiles")]
122
+ onClick: () => w.pick({ parent: i.key }),
123
+ children: [/* @__PURE__ */ z(S, { className: "size-3.5" }), s("importFiles")]
104
124
  }),
105
- /* @__PURE__ */ I(C, {
125
+ /* @__PURE__ */ B(D, {
106
126
  size: "sm",
107
127
  variant: "secondary",
108
- onClick: () => x.pick({ parent: i.key }, !0),
109
- children: [/* @__PURE__ */ F(v, { className: "size-3.5" }), s("importFolder")]
128
+ onClick: () => w.pick({ parent: i.key }, !0),
129
+ children: [/* @__PURE__ */ z(b, { className: "size-3.5" }), s("importFolder")]
110
130
  })
111
131
  ]
112
132
  }),
113
- E.isError && /* @__PURE__ */ F(w, {
133
+ N.isError && /* @__PURE__ */ z(O, {
114
134
  className: "mt-2",
115
- children: f(E.error)
135
+ children: f(N.error)
116
136
  }),
117
- x.dialog
137
+ A.addView.isError && /* @__PURE__ */ z(O, {
138
+ className: "mt-2",
139
+ children: f(A.addView.error)
140
+ }),
141
+ w.dialog
118
142
  ]
119
143
  });
120
144
  }
121
- function H({ workspace: e, doc: t, team: n }) {
122
- let r = P("docStart");
123
- return /* @__PURE__ */ F(T, {
145
+ function K({ workspace: e, doc: t, team: n }) {
146
+ let r = R("docStart");
147
+ return /* @__PURE__ */ z(k, {
124
148
  title: r("askAgent"),
125
149
  align: "start",
126
150
  initialFocus: "first-control",
127
151
  className: "w-96 max-w-[calc(100vw-2rem)]",
128
- trigger: /* @__PURE__ */ I(C, {
152
+ trigger: /* @__PURE__ */ B(D, {
129
153
  size: "sm",
130
154
  variant: "secondary",
131
- children: [/* @__PURE__ */ F(h, { className: "size-3.5" }), r("askAgent")]
155
+ children: [/* @__PURE__ */ z(_, { className: "size-3.5" }), r("askAgent")]
132
156
  }),
133
- children: /* @__PURE__ */ F(U, {
157
+ children: /* @__PURE__ */ z(q, {
134
158
  workspace: e,
135
159
  doc: t,
136
160
  team: n
137
161
  })
138
162
  });
139
163
  }
140
- function U({ workspace: r, doc: o, team: c }) {
141
- let u = P("docStart"), m = M(), h = p(), g = k(), _ = z(), { data: v = [] } = R(n(r)), { data: y = [] } = R(i(r)), { data: b = [] } = R(a(r)), S = v.filter((e) => !e.archivedAt), [T, E] = j(S[0]?.slug ?? ""), [A, N] = j(c?.key ?? b.find((e) => !e.archivedAt)?.key ?? ""), [B, V] = j(""), H = S.find((e) => e.slug === T), U = H ? s(H, y).find((e) => e.online)?.runner : void 0, W = H && U?.permissionMode && d(U.permissionMode, H.permissionMode) ? U.permissionMode : void 0, G = L({
164
+ function q({ workspace: r, doc: o, team: c }) {
165
+ let u = R("docStart"), m = I(), h = p(), g = N(), _ = U(), { data: v = [] } = H(n(r)), { data: y = [] } = H(i(r)), { data: b = [] } = H(a(r)), x = v.filter((e) => !e.archivedAt), [S, C] = F(x[0]?.slug ?? ""), [T, E] = F(c?.key ?? b.find((e) => !e.archivedAt)?.key ?? ""), [k, A] = F(""), P = x.find((e) => e.slug === S), L = P ? s(P, y).find((e) => e.online)?.runner : void 0, W = P && L?.permissionMode && d(L.permissionMode, P.permissionMode) ? L.permissionMode : void 0, G = V({
142
166
  mutationFn: async () => t(await e.POST("/api/v1/workspaces/{workspace}/teams/{key}/issues", {
143
167
  params: { path: {
144
168
  workspace: r,
145
- key: A
169
+ key: T
146
170
  } },
147
171
  body: {
148
172
  title: u("issueTitle", { doc: o.title || u("thisDoc") }),
149
- body: `${B.trim()}\n\n${u("issueBody", { doc: `[${o.title || u("thisDoc")}](${l(r, o)})` })}`,
173
+ body: `${k.trim()}\n\n${u("issueBody", { doc: `[${o.title || u("thisDoc")}](${l(r, o)})` })}`,
150
174
  origin: { doc: o.key },
151
175
  assignees: [{
152
176
  kind: "agent",
153
- handle: T
177
+ handle: S
154
178
  }]
155
179
  }
156
180
  })),
@@ -162,30 +186,30 @@ function U({ workspace: r, doc: o, team: c }) {
162
186
  ] }), g();
163
187
  }
164
188
  });
165
- return S.length === 0 ? /* @__PURE__ */ F("p", {
189
+ return x.length === 0 ? /* @__PURE__ */ z("p", {
166
190
  className: "text-sm text-muted-foreground",
167
191
  children: u("noAgents")
168
- }) : /* @__PURE__ */ I("form", {
192
+ }) : /* @__PURE__ */ B("form", {
169
193
  className: "space-y-3",
170
194
  onSubmit: (e) => {
171
- e.preventDefault(), B.trim() && T && A && G.mutate();
195
+ e.preventDefault(), k.trim() && S && T && G.mutate();
172
196
  },
173
197
  children: [
174
- /* @__PURE__ */ I("div", {
198
+ /* @__PURE__ */ B("div", {
175
199
  className: "flex gap-2",
176
- children: [/* @__PURE__ */ F(D, {
200
+ children: [/* @__PURE__ */ z(j, {
177
201
  "aria-label": u("agent"),
178
- value: T,
179
- onValueChange: (e) => e && E(e),
180
- items: S.map((e) => ({
202
+ value: S,
203
+ onValueChange: (e) => e && C(e),
204
+ items: x.map((e) => ({
181
205
  value: e.slug,
182
206
  label: e.name
183
207
  })),
184
208
  width: "fill"
185
- }), !c && /* @__PURE__ */ F(D, {
209
+ }), !c && /* @__PURE__ */ z(j, {
186
210
  "aria-label": u("team"),
187
- value: A,
188
- onValueChange: (e) => e && N(e),
211
+ value: T,
212
+ onValueChange: (e) => e && E(e),
189
213
  items: b.filter((e) => !e.archivedAt).map((e) => ({
190
214
  value: e.key,
191
215
  label: e.name
@@ -193,73 +217,73 @@ function U({ workspace: r, doc: o, team: c }) {
193
217
  width: "fill"
194
218
  })]
195
219
  }),
196
- /* @__PURE__ */ F(O, {
220
+ /* @__PURE__ */ z(M, {
197
221
  "aria-label": u("prompt"),
198
222
  placeholder: u("promptPlaceholder"),
199
- value: B,
200
- onChange: (e) => V(e.target.value),
223
+ value: k,
224
+ onChange: (e) => A(e.target.value),
201
225
  onKeyDown: (e) => {
202
226
  e.key === "Enter" && (e.metaKey || e.ctrlKey) && e.currentTarget.form?.requestSubmit();
203
227
  },
204
228
  rows: 4
205
229
  }),
206
- /* @__PURE__ */ I("div", {
230
+ /* @__PURE__ */ B("div", {
207
231
  className: "space-y-1 text-xs text-muted-foreground",
208
- children: [U ? /* @__PURE__ */ F("p", {
232
+ children: [L ? /* @__PURE__ */ z("p", {
209
233
  className: "flex flex-wrap items-center gap-1",
210
- children: u.rich("runsOn", { runner: () => /* @__PURE__ */ F(x, {
234
+ children: u.rich("runsOn", { runner: () => /* @__PURE__ */ z(w, {
211
235
  workspace: r,
212
- name: U.name,
213
- kind: U.kind
236
+ name: L.name,
237
+ kind: L.kind
214
238
  }) })
215
- }) : /* @__PURE__ */ F("p", {
239
+ }) : /* @__PURE__ */ z("p", {
216
240
  className: "text-warning",
217
241
  children: u("noRunner")
218
- }), U && W && H && /* @__PURE__ */ F("p", {
242
+ }), L && W && P && /* @__PURE__ */ z("p", {
219
243
  className: "text-pretty",
220
244
  children: u.rich("capped", {
221
- runner: U.name,
245
+ runner: L.name,
222
246
  got: h(W),
223
- asked: h(H.permissionMode),
224
- code: () => /* @__PURE__ */ F("code", { children: f(H.permissionMode) })
247
+ asked: h(P.permissionMode),
248
+ code: () => /* @__PURE__ */ z("code", { children: f(P.permissionMode) })
225
249
  })
226
250
  })]
227
251
  }),
228
- G.isError && /* @__PURE__ */ F(w, { children: m(G.error) }),
229
- /* @__PURE__ */ F("div", {
252
+ G.isError && /* @__PURE__ */ z(O, { children: m(G.error) }),
253
+ /* @__PURE__ */ z("div", {
230
254
  className: "flex justify-end",
231
- children: /* @__PURE__ */ F(C, {
255
+ children: /* @__PURE__ */ z(D, {
232
256
  type: "submit",
233
257
  size: "sm",
234
258
  variant: "primary",
235
259
  loading: G.isPending,
236
- disabled: !B.trim() || !T || !A,
260
+ disabled: !k.trim() || !S || !T,
237
261
  children: u("start")
238
262
  })
239
263
  })
240
264
  ]
241
265
  });
242
266
  }
243
- function W({ workspace: e, doc: t }) {
244
- let n = P("docStart"), r = P("agentWork.state"), { data: i = [] } = R(o(e, {
267
+ function J({ workspace: e, doc: t }) {
268
+ let n = R("docStart"), r = R("agentWork.state"), { data: i = [] } = H(o(e, {
245
269
  doc: t.key,
246
270
  live: !0
247
271
  }));
248
- return i.length === 0 ? null : /* @__PURE__ */ F("ul", {
272
+ return i.length === 0 ? null : /* @__PURE__ */ z("ul", {
249
273
  "aria-label": n("runs"),
250
274
  className: "mt-3 space-y-1.5",
251
- children: i.map((t) => /* @__PURE__ */ I("li", {
275
+ children: i.map((t) => /* @__PURE__ */ B("li", {
252
276
  className: "flex flex-wrap items-center gap-x-2 gap-y-1 rounded-lg border border-agent/50 bg-card px-3 py-2 text-xs",
253
277
  children: [
254
- /* @__PURE__ */ F("span", {
278
+ /* @__PURE__ */ z("span", {
255
279
  className: "font-medium",
256
280
  children: t.agentName
257
281
  }),
258
- /* @__PURE__ */ F("span", {
282
+ /* @__PURE__ */ z("span", {
259
283
  className: "text-muted-foreground",
260
284
  children: r(t.state)
261
285
  }),
262
- /* @__PURE__ */ F(m, {
286
+ /* @__PURE__ */ z(m, {
263
287
  to: "/$workspace/issues/$identifier",
264
288
  params: {
265
289
  workspace: e,
@@ -268,15 +292,15 @@ function W({ workspace: e, doc: t }) {
268
292
  className: "min-w-0 flex-1 truncate text-muted-foreground hover:text-foreground hover:underline",
269
293
  children: t.identifier
270
294
  }),
271
- t.lastRunnerName ? /* @__PURE__ */ F(x, {
295
+ t.lastRunnerName ? /* @__PURE__ */ z(w, {
272
296
  workspace: e,
273
297
  name: t.lastRunnerName,
274
298
  kind: t.runnerKind
275
- }) : /* @__PURE__ */ F("span", {
299
+ }) : /* @__PURE__ */ z("span", {
276
300
  className: "text-muted-foreground",
277
301
  children: n("waitingForRunner")
278
302
  }),
279
- /* @__PURE__ */ F(E, {
303
+ /* @__PURE__ */ z(A, {
280
304
  value: t.createdAt,
281
305
  format: "compact",
282
306
  className: "text-muted-foreground"
@@ -285,4 +309,4 @@ function W({ workspace: e, doc: t }) {
285
309
  }, t.id))
286
310
  });
287
311
  }
288
- export { W as DocRuns, V as DocStart };
312
+ export { J as DocRuns, G as DocStart };