@burdenoff/microfe-planmagnet 2026.930.16 → 2026.930.18

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 (51) hide show
  1. package/dist/planmagnet/board/ProjectBoard.d.ts.map +1 -1
  2. package/dist/planmagnet/board/ProjectBoard.js +278 -271
  3. package/dist/planmagnet/board/ProjectBoard.js.map +1 -1
  4. package/dist/planmagnet/comments/CommentThread.d.ts +44 -0
  5. package/dist/planmagnet/comments/CommentThread.d.ts.map +1 -0
  6. package/dist/planmagnet/comments/CommentThread.js +513 -0
  7. package/dist/planmagnet/comments/CommentThread.js.map +1 -0
  8. package/dist/planmagnet/comments/MentionComposer.d.ts +25 -0
  9. package/dist/planmagnet/comments/MentionComposer.d.ts.map +1 -0
  10. package/dist/planmagnet/comments/MentionComposer.js +148 -0
  11. package/dist/planmagnet/comments/MentionComposer.js.map +1 -0
  12. package/dist/planmagnet/comments/TargetComments.d.ts +7 -0
  13. package/dist/planmagnet/comments/TargetComments.d.ts.map +1 -0
  14. package/dist/planmagnet/comments/TargetComments.js +207 -0
  15. package/dist/planmagnet/comments/TargetComments.js.map +1 -0
  16. package/dist/planmagnet/comments/WorkItemComments.d.ts.map +1 -1
  17. package/dist/planmagnet/comments/WorkItemComments.js +68 -216
  18. package/dist/planmagnet/comments/WorkItemComments.js.map +1 -1
  19. package/dist/planmagnet/controls/LiveStatus.d.ts +7 -0
  20. package/dist/planmagnet/controls/LiveStatus.d.ts.map +1 -0
  21. package/dist/planmagnet/controls/LiveStatus.js +31 -0
  22. package/dist/planmagnet/controls/LiveStatus.js.map +1 -0
  23. package/dist/planmagnet/hooks/useLiveRefresh.d.ts +76 -0
  24. package/dist/planmagnet/hooks/useLiveRefresh.d.ts.map +1 -0
  25. package/dist/planmagnet/hooks/useLiveRefresh.js +143 -0
  26. package/dist/planmagnet/hooks/useLiveRefresh.js.map +1 -0
  27. package/dist/planmagnet/pages/DashboardDashboardPagePage.d.ts.map +1 -1
  28. package/dist/planmagnet/pages/DashboardDashboardPagePage.js +138 -125
  29. package/dist/planmagnet/pages/DashboardDashboardPagePage.js.map +1 -1
  30. package/dist/planmagnet/pages/DashboardsExecutivePagePage.d.ts.map +1 -1
  31. package/dist/planmagnet/pages/DashboardsExecutivePagePage.js +54 -39
  32. package/dist/planmagnet/pages/DashboardsExecutivePagePage.js.map +1 -1
  33. package/dist/planmagnet/pages/DashboardsLeadershipPagePage.d.ts.map +1 -1
  34. package/dist/planmagnet/pages/DashboardsLeadershipPagePage.js +52 -37
  35. package/dist/planmagnet/pages/DashboardsLeadershipPagePage.js.map +1 -1
  36. package/dist/planmagnet/pages/DashboardsProjectManagerPagePage.d.ts.map +1 -1
  37. package/dist/planmagnet/pages/DashboardsProjectManagerPagePage.js +93 -68
  38. package/dist/planmagnet/pages/DashboardsProjectManagerPagePage.js.map +1 -1
  39. package/dist/planmagnet/pages/DashboardsTeamUtilizationPagePage.d.ts.map +1 -1
  40. package/dist/planmagnet/pages/DashboardsTeamUtilizationPagePage.js +62 -47
  41. package/dist/planmagnet/pages/DashboardsTeamUtilizationPagePage.js.map +1 -1
  42. package/dist/planmagnet/pages/DocsDocDetailPagePage.d.ts.map +1 -1
  43. package/dist/planmagnet/pages/DocsDocDetailPagePage.js +74 -72
  44. package/dist/planmagnet/pages/DocsDocDetailPagePage.js.map +1 -1
  45. package/dist/planmagnet/pages/ProjectsPlanningDetailPagePage.d.ts.map +1 -1
  46. package/dist/planmagnet/pages/ProjectsPlanningDetailPagePage.js +140 -125
  47. package/dist/planmagnet/pages/ProjectsPlanningDetailPagePage.js.map +1 -1
  48. package/dist/planmagnet/pages/ProjectsProjectDetailPagePage.d.ts.map +1 -1
  49. package/dist/planmagnet/pages/ProjectsProjectDetailPagePage.js +213 -195
  50. package/dist/planmagnet/pages/ProjectsProjectDetailPagePage.js.map +1 -1
  51. package/package.json +1 -1
@@ -1,14 +1,11 @@
1
- import { usePlanMagnet as e } from "../providers/PlanMagnetProvider.js";
2
- import { PersonName as t } from "../people/People.js";
3
- import { throwOnError as n } from "../utils/mutationResult.js";
4
- import { useState as r } from "react";
5
- import { MessageSquare as i } from "lucide-react";
6
- import { gql as a } from "@apollo/client";
7
- import { useMutation as o, useQuery as s } from "@apollo/client/react";
8
- import { jsx as c, jsxs as l } from "react/jsx-runtime";
9
- import { AlertDialog as u, AlertDialogAction as d, AlertDialogCancel as f, AlertDialogContent as p, AlertDialogDescription as m, AlertDialogFooter as h, AlertDialogHeader as g, AlertDialogTitle as _, AlertDialogTrigger as v, Button as y, Card as b, CardContent as x, CardHeader as S, CardTitle as C } from "@burdenoff/fe-libs/ui";
1
+ import { CommentThread as e } from "./CommentThread.js";
2
+ import { useState as t } from "react";
3
+ import { MessageSquare as n } from "lucide-react";
4
+ import { gql as r } from "@apollo/client";
5
+ import { jsx as i, jsxs as a } from "react/jsx-runtime";
6
+ import { Card as o, CardContent as s, CardHeader as c, CardTitle as l } from "@burdenoff/fe-libs/ui";
10
7
  //#region src/planmagnet/comments/WorkItemComments.tsx
11
- var w = 1e4, T = 50, E = a`
8
+ var u = r`
12
9
  query WorkItemComments($workItemId: ID!, $pagination: PlanmagnetPaginationInput) {
13
10
  planmagnetWorkItemComments(workItemId: $workItemId, pagination: $pagination) {
14
11
  totalCount
@@ -22,16 +19,33 @@ var w = 1e4, T = 50, E = a`
22
19
  body
23
20
  createdAt
24
21
  editedAt
22
+ parentId
23
+ status
24
+ resolvedBy
25
+ resolvedAt
26
+ mentions
27
+ replies {
28
+ id
29
+ authorId
30
+ body
31
+ createdAt
32
+ editedAt
33
+ parentId
34
+ status
35
+ resolvedBy
36
+ resolvedAt
37
+ mentions
38
+ }
25
39
  }
26
40
  }
27
41
  }
28
- `, D = a`
42
+ `, d = r`
29
43
  mutation WorkItemCommentAdd($input: PlanmagnetAddWorkItemCommentInput!) {
30
44
  planmagnetAddWorkItemComment(input: $input) {
31
45
  id
32
46
  }
33
47
  }
34
- `, O = a`
48
+ `, f = r`
35
49
  mutation WorkItemCommentEdit($id: ID!, $body: String!) {
36
50
  planmagnetEditWorkItemComment(id: $id, body: $body) {
37
51
  id
@@ -39,219 +53,57 @@ var w = 1e4, T = 50, E = a`
39
53
  editedAt
40
54
  }
41
55
  }
42
- `, k = a`
56
+ `, p = r`
43
57
  mutation WorkItemCommentDelete($id: ID!) {
44
58
  planmagnetDeleteWorkItemComment(id: $id)
45
59
  }
46
- `, A = (e, t) => e instanceof Error ? e.message : t, j = (e) => new Date(e).toLocaleString();
47
- function M({ message: e }) {
48
- return /* @__PURE__ */ c("p", {
49
- role: "alert",
50
- className: "text-sm text-destructive",
51
- children: e
52
- });
53
- }
54
- function N({ workItemId: t }) {
55
- let { currentUser: a } = e(), [u, d] = r(""), [f, p] = r(null), [m, h] = r(!1), { data: g, loading: _, error: v, fetchMore: O } = s(E, {
56
- variables: {
57
- workItemId: t,
58
- pagination: { first: T }
59
- },
60
- skip: !t
61
- }), [k, j] = o(D, {
62
- refetchQueries: ["WorkItemComments", "WorkItemActivity"],
63
- awaitRefetchQueries: !0
64
- }), N = g?.planmagnetWorkItemComments, F = N?.items ?? [], I = u.trim(), L = I.length > w;
65
- return /* @__PURE__ */ l(b, {
60
+ `, m = r`
61
+ mutation WorkItemCommentResolve($id: ID!, $resolved: Boolean!) {
62
+ planmagnetResolveWorkItemComment(id: $id, resolved: $resolved) {
63
+ id
64
+ status
65
+ resolvedBy
66
+ resolvedAt
67
+ }
68
+ }
69
+ `;
70
+ function h({ workItemId: r }) {
71
+ let [h, g] = t(null);
72
+ return /* @__PURE__ */ a(o, {
66
73
  "data-testid": "work-item-comments",
67
- children: [/* @__PURE__ */ c(S, { children: /* @__PURE__ */ l(C, {
74
+ children: [/* @__PURE__ */ i(c, { children: /* @__PURE__ */ a(l, {
68
75
  className: "flex items-center gap-2",
69
76
  children: [
70
- /* @__PURE__ */ c(i, { className: "h-4 w-4" }),
71
- "Discussion ",
72
- N ? `(${N.totalCount})` : ""
77
+ /* @__PURE__ */ i(n, { className: "h-4 w-4" }),
78
+ "Discussion",
79
+ h === null ? "" : ` (${h})`
73
80
  ]
74
- }) }), /* @__PURE__ */ l(x, {
75
- className: "space-y-4",
76
- children: [
77
- f && /* @__PURE__ */ c(M, { message: f }),
78
- _ && !g && /* @__PURE__ */ c("p", {
79
- className: "text-sm text-muted-foreground",
80
- children: "Loading comments…"
81
- }),
82
- v && /* @__PURE__ */ c(M, { message: `Comments could not be loaded: ${v.message}` }),
83
- N && F.length === 0 && /* @__PURE__ */ c("p", {
84
- className: "text-sm text-muted-foreground",
85
- children: "No comments yet."
86
- }),
87
- /* @__PURE__ */ c("ol", {
88
- className: "space-y-3",
89
- children: F.map((e) => /* @__PURE__ */ c(P, {
90
- comment: e,
91
- mine: e.authorId === a?.id,
92
- onError: p
93
- }, e.id))
94
- }),
95
- N?.pageInfo.hasNextPage && /* @__PURE__ */ c(y, {
96
- size: "sm",
97
- variant: "outline",
98
- onClick: async () => {
99
- let e = N?.pageInfo.endCursor;
100
- if (e) {
101
- h(!0);
102
- try {
103
- await O({
104
- variables: { pagination: {
105
- first: T,
106
- after: e
107
- } },
108
- updateQuery: (e, { fetchMoreResult: t }) => ({ planmagnetWorkItemComments: {
109
- ...t.planmagnetWorkItemComments,
110
- items: [...e.planmagnetWorkItemComments.items, ...t.planmagnetWorkItemComments.items]
111
- } })
112
- });
113
- } finally {
114
- h(!1);
115
- }
116
- }
117
- },
118
- disabled: m,
119
- children: m ? "Loading…" : `Show more (${F.length} of ${N.totalCount})`
120
- }),
121
- /* @__PURE__ */ l("div", {
122
- className: "space-y-2 border-t pt-4",
123
- children: [
124
- /* @__PURE__ */ c("label", {
125
- htmlFor: `comment-${t}`,
126
- className: "sr-only",
127
- children: "Add a comment"
128
- }),
129
- /* @__PURE__ */ c("textarea", {
130
- id: `comment-${t}`,
131
- className: "w-full min-h-[80px] rounded-md border border-input bg-background px-3 py-2 text-sm",
132
- placeholder: "Add a comment…",
133
- value: u,
134
- onChange: (e) => d(e.target.value)
135
- }),
136
- L && /* @__PURE__ */ c(M, { message: `A comment can be at most ${w} characters.` }),
137
- /* @__PURE__ */ c("div", {
138
- className: "flex justify-end",
139
- children: /* @__PURE__ */ c(y, {
140
- size: "sm",
141
- onClick: async () => {
142
- p(null);
143
- try {
144
- await n(k({ variables: { input: {
145
- workItemId: t,
146
- body: I
147
- } } })), d("");
148
- } catch (e) {
149
- p(A(e, "The comment could not be posted."));
150
- }
151
- },
152
- disabled: !I || L || j.loading,
153
- "data-testid": "comment-post",
154
- children: j.loading ? "Posting…" : "Comment"
155
- })
156
- })
157
- ]
158
- })
159
- ]
160
- })]
161
- });
162
- }
163
- function P({ comment: e, mine: i, onError: a }) {
164
- let [s, b] = r(!1), [x, S] = r(e.body), C = a, w = {
165
- refetchQueries: ["WorkItemComments", "WorkItemActivity"],
166
- awaitRefetchQueries: !0
167
- }, [T, E] = o(O, w), [D, M] = o(k, w);
168
- return /* @__PURE__ */ l("li", {
169
- className: "rounded-md border p-3 space-y-1",
170
- "data-testid": "comment",
171
- children: [/* @__PURE__ */ l("div", {
172
- className: "flex items-center justify-between gap-2 text-xs text-muted-foreground",
173
- children: [/* @__PURE__ */ l("span", { children: [
174
- /* @__PURE__ */ c("span", {
175
- className: "font-medium text-foreground",
176
- children: /* @__PURE__ */ c(t, { id: e.authorId })
177
- }),
178
- " ",
179
- "· ",
180
- j(e.createdAt),
181
- e.editedAt && /* @__PURE__ */ c("span", {
182
- title: `Edited ${j(e.editedAt)}`,
183
- children: " · edited"
184
- })
185
- ] }), i && !s && /* @__PURE__ */ l("span", {
186
- className: "flex gap-1",
187
- children: [/* @__PURE__ */ c(y, {
188
- size: "sm",
189
- variant: "ghost",
190
- className: "h-6 px-2 text-xs",
191
- onClick: () => b(!0),
192
- children: "Edit"
193
- }), /* @__PURE__ */ l(u, { children: [/* @__PURE__ */ c(v, {
194
- asChild: !0,
195
- children: /* @__PURE__ */ c(y, {
196
- size: "sm",
197
- variant: "ghost",
198
- className: "h-6 px-2 text-xs",
199
- disabled: M.loading,
200
- children: "Delete"
201
- })
202
- }), /* @__PURE__ */ l(p, { children: [/* @__PURE__ */ l(g, { children: [/* @__PURE__ */ c(_, { children: "Delete this comment?" }), /* @__PURE__ */ c(m, { children: "It is removed from the discussion for everyone." })] }), /* @__PURE__ */ l(h, { children: [/* @__PURE__ */ c(f, { children: "Keep it" }), /* @__PURE__ */ c(d, {
203
- className: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
204
- onClick: async () => {
205
- C(null);
206
- try {
207
- await n(D({ variables: { id: e.id } }));
208
- } catch (e) {
209
- C(A(e, "The comment could not be deleted."));
210
- }
211
- },
212
- children: "Delete"
213
- })] })] })] })]
214
- })]
215
- }), s ? /* @__PURE__ */ l("div", {
216
- className: "space-y-2",
217
- children: [/* @__PURE__ */ c("textarea", {
218
- "aria-label": "Edit comment",
219
- className: "w-full min-h-[60px] rounded-md border border-input bg-background px-3 py-2 text-sm",
220
- value: x,
221
- onChange: (e) => S(e.target.value)
222
- }), /* @__PURE__ */ l("div", {
223
- className: "flex justify-end gap-2",
224
- children: [/* @__PURE__ */ c(y, {
225
- size: "sm",
226
- variant: "outline",
227
- onClick: () => {
228
- b(!1), S(e.body), C(null);
229
- },
230
- children: "Cancel"
231
- }), /* @__PURE__ */ c(y, {
232
- size: "sm",
233
- onClick: async () => {
234
- C(null);
235
- try {
236
- await n(T({ variables: {
237
- id: e.id,
238
- body: x.trim()
239
- } })), b(!1);
240
- } catch (e) {
241
- C(A(e, "The comment could not be saved."));
242
- }
243
- },
244
- disabled: !x.trim() || E.loading,
245
- children: E.loading ? "Saving…" : "Save"
246
- })]
247
- })]
248
- }) : /* @__PURE__ */ c("p", {
249
- className: "text-sm whitespace-pre-wrap break-words",
250
- children: e.body
251
- })]
81
+ }) }), /* @__PURE__ */ i(s, { children: /* @__PURE__ */ i(e, {
82
+ targetNoun: "task",
83
+ idPrefix: `work-item-comment-${r}`,
84
+ query: {
85
+ document: u,
86
+ dataKey: "planmagnetWorkItemComments",
87
+ variables: { workItemId: r },
88
+ skip: !r
89
+ },
90
+ add: {
91
+ document: d,
92
+ buildVariables: (e, t) => ({ input: {
93
+ workItemId: r,
94
+ body: e,
95
+ parentId: t
96
+ } })
97
+ },
98
+ edit: f,
99
+ remove: p,
100
+ resolve: m,
101
+ refetchQueries: ["WorkItemComments", "WorkItemActivity"],
102
+ onTotalCount: g
103
+ }) })]
252
104
  });
253
105
  }
254
106
  //#endregion
255
- export { N as WorkItemComments };
107
+ export { h as WorkItemComments };
256
108
 
257
109
  //# sourceMappingURL=WorkItemComments.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"WorkItemComments.js","names":[],"sources":["../../../src/planmagnet/comments/WorkItemComments.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { gql } from '@apollo/client';\nimport { useMutation, useQuery } from '@apollo/client/react';\nimport {\n AlertDialog,\n AlertDialogAction,\n AlertDialogCancel,\n AlertDialogContent,\n AlertDialogDescription,\n AlertDialogFooter,\n AlertDialogHeader,\n AlertDialogTitle,\n AlertDialogTrigger,\n Button,\n Card,\n CardContent,\n CardHeader,\n CardTitle,\n} from '@burdenoff/fe-libs/ui';\nimport { MessageSquare } from 'lucide-react';\nimport { usePlanMagnet } from '../providers/PlanMagnetProvider';\nimport { PersonName } from '../people/People';\nimport { throwOnError } from '../utils/mutationResult';\n\n/**\n * Discussion on a work item (P1.4). Anyone who can read the item sees the\n * thread; posting needs edit rights on work items; only a comment's author\n * can edit or delete it. The server enforces all three and says why it refused\n * (shown inline). The controls here only avoid offering what would be refused.\n */\n\nconst MAX_LENGTH = 10_000;\nconst PAGE = 50;\n\nconst COMMENTS = gql`\n query WorkItemComments($workItemId: ID!, $pagination: PlanmagnetPaginationInput) {\n planmagnetWorkItemComments(workItemId: $workItemId, pagination: $pagination) {\n totalCount\n pageInfo {\n hasNextPage\n endCursor\n }\n items {\n id\n authorId\n body\n createdAt\n editedAt\n }\n }\n }\n`;\nconst ADD = gql`\n mutation WorkItemCommentAdd($input: PlanmagnetAddWorkItemCommentInput!) {\n planmagnetAddWorkItemComment(input: $input) {\n id\n }\n }\n`;\nconst EDIT = gql`\n mutation WorkItemCommentEdit($id: ID!, $body: String!) {\n planmagnetEditWorkItemComment(id: $id, body: $body) {\n id\n body\n editedAt\n }\n }\n`;\nconst DELETE = gql`\n mutation WorkItemCommentDelete($id: ID!) {\n planmagnetDeleteWorkItemComment(id: $id)\n }\n`;\n\ninterface Comment {\n id: string;\n authorId: string;\n body: string;\n createdAt: string;\n editedAt: string | null;\n}\n\ninterface CommentsData {\n planmagnetWorkItemComments: {\n totalCount: number;\n pageInfo: { hasNextPage: boolean; endCursor: string | null };\n items: Comment[];\n };\n}\n\nconst messageOf = (e: unknown, fallback: string) => (e instanceof Error ? e.message : fallback);\nconst when = (iso: string) => new Date(iso).toLocaleString();\n\nfunction ErrorLine({ message }: { message: string }) {\n return (\n <p role=\"alert\" className=\"text-sm text-destructive\">\n {message}\n </p>\n );\n}\n\nexport function WorkItemComments({ workItemId }: { workItemId: string }) {\n const { currentUser } = usePlanMagnet();\n const [draft, setDraft] = useState('');\n const [error, setError] = useState<string | null>(null);\n const [loadingMore, setLoadingMore] = useState(false);\n\n const {\n data,\n loading,\n error: loadError,\n fetchMore,\n } = useQuery<CommentsData>(COMMENTS, {\n variables: { workItemId, pagination: { first: PAGE } },\n skip: !workItemId,\n });\n const refetch = {\n refetchQueries: ['WorkItemComments', 'WorkItemActivity'],\n awaitRefetchQueries: true,\n };\n const [add, addState] = useMutation(ADD, refetch);\n\n const thread = data?.planmagnetWorkItemComments;\n const comments = thread?.items ?? [];\n const trimmed = draft.trim();\n const tooLong = trimmed.length > MAX_LENGTH;\n\n const post = async () => {\n setError(null);\n try {\n await throwOnError(add({ variables: { input: { workItemId, body: trimmed } } }));\n setDraft('');\n } catch (e) {\n setError(messageOf(e, 'The comment could not be posted.'));\n }\n };\n\n const loadMore = async () => {\n const after = thread?.pageInfo.endCursor;\n if (!after) return;\n setLoadingMore(true);\n try {\n await fetchMore({\n variables: { pagination: { first: PAGE, after } },\n updateQuery: (prev, { fetchMoreResult }) => ({\n planmagnetWorkItemComments: {\n ...fetchMoreResult.planmagnetWorkItemComments,\n items: [\n ...prev.planmagnetWorkItemComments.items,\n ...fetchMoreResult.planmagnetWorkItemComments.items,\n ],\n },\n }),\n });\n } finally {\n setLoadingMore(false);\n }\n };\n\n return (\n <Card data-testid=\"work-item-comments\">\n <CardHeader>\n <CardTitle className=\"flex items-center gap-2\">\n <MessageSquare className=\"h-4 w-4\" />\n Discussion {thread ? `(${thread.totalCount})` : ''}\n </CardTitle>\n </CardHeader>\n <CardContent className=\"space-y-4\">\n {error && <ErrorLine message={error} />}\n {loading && !data && <p className=\"text-sm text-muted-foreground\">Loading comments…</p>}\n {loadError && <ErrorLine message={`Comments could not be loaded: ${loadError.message}`} />}\n {thread && comments.length === 0 && (\n <p className=\"text-sm text-muted-foreground\">No comments yet.</p>\n )}\n <ol className=\"space-y-3\">\n {comments.map((comment) => (\n <CommentRow\n key={comment.id}\n comment={comment}\n mine={comment.authorId === currentUser?.id}\n onError={setError}\n />\n ))}\n </ol>\n {thread?.pageInfo.hasNextPage && (\n <Button size=\"sm\" variant=\"outline\" onClick={loadMore} disabled={loadingMore}>\n {loadingMore ? 'Loading…' : `Show more (${comments.length} of ${thread.totalCount})`}\n </Button>\n )}\n <div className=\"space-y-2 border-t pt-4\">\n <label htmlFor={`comment-${workItemId}`} className=\"sr-only\">\n Add a comment\n </label>\n <textarea\n id={`comment-${workItemId}`}\n className=\"w-full min-h-[80px] rounded-md border border-input bg-background px-3 py-2 text-sm\"\n placeholder=\"Add a comment…\"\n value={draft}\n onChange={(e) => setDraft(e.target.value)}\n />\n {tooLong && <ErrorLine message={`A comment can be at most ${MAX_LENGTH} characters.`} />}\n <div className=\"flex justify-end\">\n <Button\n size=\"sm\"\n onClick={post}\n disabled={!trimmed || tooLong || addState.loading}\n data-testid=\"comment-post\"\n >\n {addState.loading ? 'Posting…' : 'Comment'}\n </Button>\n </div>\n </div>\n </CardContent>\n </Card>\n );\n}\n\n/**\n * Refusals are reported to the PANEL, not kept in the row: a refused edit or\n * delete still refetches the thread, and when the comment is gone (deleted\n * elsewhere) the row unmounts, taking a row-level message with it. Seen in the\n * prod verification: the comment vanished and the reason was never shown.\n */\nfunction CommentRow({\n comment,\n mine,\n onError,\n}: {\n comment: Comment;\n mine: boolean;\n onError: (message: string | null) => void;\n}) {\n const [editing, setEditing] = useState(false);\n const [text, setText] = useState(comment.body);\n const setError = onError;\n const refetch = {\n refetchQueries: ['WorkItemComments', 'WorkItemActivity'],\n awaitRefetchQueries: true,\n };\n const [edit, editState] = useMutation(EDIT, refetch);\n const [remove, removeState] = useMutation(DELETE, refetch);\n\n const save = async () => {\n setError(null);\n try {\n await throwOnError(edit({ variables: { id: comment.id, body: text.trim() } }));\n setEditing(false);\n } catch (e) {\n setError(messageOf(e, 'The comment could not be saved.'));\n }\n };\n\n return (\n <li className=\"rounded-md border p-3 space-y-1\" data-testid=\"comment\">\n <div className=\"flex items-center justify-between gap-2 text-xs text-muted-foreground\">\n <span>\n <span className=\"font-medium text-foreground\">\n <PersonName id={comment.authorId} />\n </span>{' '}\n · {when(comment.createdAt)}\n {comment.editedAt && <span title={`Edited ${when(comment.editedAt)}`}> · edited</span>}\n </span>\n {mine && !editing && (\n <span className=\"flex gap-1\">\n <Button\n size=\"sm\"\n variant=\"ghost\"\n className=\"h-6 px-2 text-xs\"\n onClick={() => setEditing(true)}\n >\n Edit\n </Button>\n <AlertDialog>\n <AlertDialogTrigger asChild>\n <Button\n size=\"sm\"\n variant=\"ghost\"\n className=\"h-6 px-2 text-xs\"\n disabled={removeState.loading}\n >\n Delete\n </Button>\n </AlertDialogTrigger>\n <AlertDialogContent>\n <AlertDialogHeader>\n <AlertDialogTitle>Delete this comment?</AlertDialogTitle>\n <AlertDialogDescription>\n It is removed from the discussion for everyone.\n </AlertDialogDescription>\n </AlertDialogHeader>\n <AlertDialogFooter>\n <AlertDialogCancel>Keep it</AlertDialogCancel>\n <AlertDialogAction\n className=\"bg-destructive text-destructive-foreground hover:bg-destructive/90\"\n onClick={async () => {\n setError(null);\n try {\n await throwOnError(remove({ variables: { id: comment.id } }));\n } catch (e) {\n setError(messageOf(e, 'The comment could not be deleted.'));\n }\n }}\n >\n Delete\n </AlertDialogAction>\n </AlertDialogFooter>\n </AlertDialogContent>\n </AlertDialog>\n </span>\n )}\n </div>\n {editing ? (\n <div className=\"space-y-2\">\n <textarea\n aria-label=\"Edit comment\"\n className=\"w-full min-h-[60px] rounded-md border border-input bg-background px-3 py-2 text-sm\"\n value={text}\n onChange={(e) => setText(e.target.value)}\n />\n <div className=\"flex justify-end gap-2\">\n <Button\n size=\"sm\"\n variant=\"outline\"\n onClick={() => {\n setEditing(false);\n setText(comment.body);\n setError(null);\n }}\n >\n Cancel\n </Button>\n <Button size=\"sm\" onClick={save} disabled={!text.trim() || editState.loading}>\n {editState.loading ? 'Saving…' : 'Save'}\n </Button>\n </div>\n </div>\n ) : (\n <p className=\"text-sm whitespace-pre-wrap break-words\">{comment.body}</p>\n )}\n </li>\n );\n}\n"],"mappings":";;;;;;;;;;AA+BA,IAAM,IAAa,KACb,IAAO,IAEP,IAAW,CAAG;;;;;;;;;;;;;;;;;GAkBd,IAAM,CAAG;;;;;;GAOT,IAAO,CAAG;;;;;;;;GASV,IAAS,CAAG;;;;GAsBZ,KAAa,GAAY,MAAsB,aAAa,QAAQ,EAAE,UAAU,GAChF,KAAQ,MAAgB,IAAI,KAAK,EAAI,CAAC,gBAAgB;AAE5D,SAAS,EAAU,EAAE,cAAgC;AACnD,QACE,kBAAC,KAAD;EAAG,MAAK;EAAQ,WAAU;YACvB;EACC,CAAA;;AAIR,SAAgB,EAAiB,EAAE,iBAAsC;CACvE,IAAM,EAAE,mBAAgB,GAAe,EACjC,CAAC,GAAO,KAAY,EAAS,GAAG,EAChC,CAAC,GAAO,KAAY,EAAwB,KAAK,EACjD,CAAC,GAAa,KAAkB,EAAS,GAAM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GAAK,WAAU;aAAf,CACE,kBAAC,YAAD;IACE,cAAW;IACX,WAAU;IACV,OAAO;IACP,WAAW,MAAM,EAAQ,EAAE,OAAO,MAAM;IACxC,CAAA,EACF,kBAAC,OAAD;IAAK,WAAU;cAAf,CACE,kBAAC,GAAD;KACE,MAAK;KACL,SAAQ;KACR,eAAe;AAGb,MAFA,EAAW,GAAM,EACjB,EAAQ,EAAQ,KAAK,EACrB,EAAS,KAAK;;eAEjB;KAEQ,CAAA,EACT,kBAAC,GAAD;KAAQ,MAAK;KAAK,SAzFf,YAAY;AACvB,QAAS,KAAK;AACd,UAAI;AAEF,OADA,MAAM,EAAa,EAAK,EAAE,WAAW;QAAE,IAAI,EAAQ;QAAI,MAAM,EAAK,MAAM;QAAE,EAAE,CAAC,CAAC,EAC9E,EAAW,GAAM;eACV,GAAG;AACV,SAAS,EAAU,GAAG,kCAAkC,CAAC;;;KAmFlB,UAAU,CAAC,EAAK,MAAM,IAAI,EAAU;eAClE,EAAU,UAAU,YAAY;KAC1B,CAAA,CACL;MACF;OAEN,kBAAC,KAAD;GAAG,WAAU;aAA2C,EAAQ;GAAS,CAAA,CAExE"}
1
+ {"version":3,"file":"WorkItemComments.js","names":[],"sources":["../../../src/planmagnet/comments/WorkItemComments.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { gql } from '@apollo/client';\nimport { Card, CardContent, CardHeader, CardTitle } from '@burdenoff/fe-libs/ui';\nimport { MessageSquare } from 'lucide-react';\nimport { CommentThread } from './CommentThread';\n\n/**\n * Discussion on a work item (CWF-02 threading, CWF-14 resolution, CWF-13 mentions). Anyone who can read the item\n * sees the thread; posting/replying/resolving need the item's write tier; only a comment's author can edit or\n * delete it. The engine (list, threading, resolve, mention composer) lives in `CommentThread.tsx`, shared with\n * the project and doc panels (`TargetComments.tsx`) — this file only wires the work-item-specific GraphQL\n * operations and keeps the Card chrome/title this page already had.\n */\n\nconst WORK_ITEM_COMMENTS = gql`\n query WorkItemComments($workItemId: ID!, $pagination: PlanmagnetPaginationInput) {\n planmagnetWorkItemComments(workItemId: $workItemId, pagination: $pagination) {\n totalCount\n pageInfo {\n hasNextPage\n endCursor\n }\n items {\n id\n authorId\n body\n createdAt\n editedAt\n parentId\n status\n resolvedBy\n resolvedAt\n mentions\n replies {\n id\n authorId\n body\n createdAt\n editedAt\n parentId\n status\n resolvedBy\n resolvedAt\n mentions\n }\n }\n }\n }\n`;\nconst ADD_WORK_ITEM_COMMENT = gql`\n mutation WorkItemCommentAdd($input: PlanmagnetAddWorkItemCommentInput!) {\n planmagnetAddWorkItemComment(input: $input) {\n id\n }\n }\n`;\nconst EDIT_WORK_ITEM_COMMENT = gql`\n mutation WorkItemCommentEdit($id: ID!, $body: String!) {\n planmagnetEditWorkItemComment(id: $id, body: $body) {\n id\n body\n editedAt\n }\n }\n`;\nconst DELETE_WORK_ITEM_COMMENT = gql`\n mutation WorkItemCommentDelete($id: ID!) {\n planmagnetDeleteWorkItemComment(id: $id)\n }\n`;\nconst RESOLVE_WORK_ITEM_COMMENT = gql`\n mutation WorkItemCommentResolve($id: ID!, $resolved: Boolean!) {\n planmagnetResolveWorkItemComment(id: $id, resolved: $resolved) {\n id\n status\n resolvedBy\n resolvedAt\n }\n }\n`;\n\nexport function WorkItemComments({ workItemId }: { workItemId: string }) {\n const [totalCount, setTotalCount] = useState<number | null>(null);\n return (\n <Card data-testid=\"work-item-comments\">\n <CardHeader>\n <CardTitle className=\"flex items-center gap-2\">\n <MessageSquare className=\"h-4 w-4\" />\n Discussion{totalCount !== null ? ` (${totalCount})` : ''}\n </CardTitle>\n </CardHeader>\n <CardContent>\n <CommentThread\n targetNoun=\"task\"\n idPrefix={`work-item-comment-${workItemId}`}\n query={{\n document: WORK_ITEM_COMMENTS,\n dataKey: 'planmagnetWorkItemComments',\n variables: { workItemId },\n skip: !workItemId,\n }}\n add={{\n document: ADD_WORK_ITEM_COMMENT,\n buildVariables: (body, parentId) => ({ input: { workItemId, body, parentId } }),\n }}\n edit={EDIT_WORK_ITEM_COMMENT}\n remove={DELETE_WORK_ITEM_COMMENT}\n resolve={RESOLVE_WORK_ITEM_COMMENT}\n refetchQueries={['WorkItemComments', 'WorkItemActivity']}\n onTotalCount={setTotalCount}\n />\n </CardContent>\n </Card>\n );\n}\n"],"mappings":";;;;;;;AAcA,IAAM,IAAqB,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCxB,IAAwB,CAAG;;;;;;GAO3B,IAAyB,CAAG;;;;;;;;GAS5B,IAA2B,CAAG;;;;GAK9B,IAA4B,CAAG;;;;;;;;;;AAWrC,SAAgB,EAAiB,EAAE,iBAAsC;CACvE,IAAM,CAAC,GAAY,KAAiB,EAAwB,KAAK;AACjE,QACE,kBAAC,GAAD;EAAM,eAAY;YAAlB,CACE,kBAAC,GAAD,EAAA,UACE,kBAAC,GAAD;GAAW,WAAU;aAArB;IACE,kBAAC,GAAD,EAAe,WAAU,WAAY,CAAA;;IAC1B,MAAe,OAA4B,KAArB,KAAK,EAAW;IACvC;MACD,CAAA,EACb,kBAAC,GAAD,EAAA,UACE,kBAAC,GAAD;GACE,YAAW;GACX,UAAU,qBAAqB;GAC/B,OAAO;IACL,UAAU;IACV,SAAS;IACT,WAAW,EAAE,eAAY;IACzB,MAAM,CAAC;IACR;GACD,KAAK;IACH,UAAU;IACV,iBAAiB,GAAM,OAAc,EAAE,OAAO;KAAE;KAAY;KAAM;KAAU,EAAE;IAC/E;GACD,MAAM;GACN,QAAQ;GACR,SAAS;GACT,gBAAgB,CAAC,oBAAoB,mBAAmB;GACxD,cAAc;GACd,CAAA,EACU,CAAA,CACT"}
@@ -0,0 +1,7 @@
1
+ import { LiveRefreshMode } from '../hooks/useLiveRefresh';
2
+
3
+ export declare function LiveStatus({ mode, className, }: {
4
+ mode: LiveRefreshMode | null;
5
+ className?: string;
6
+ }): import("react/jsx-runtime").JSX.Element | null;
7
+ //# sourceMappingURL=LiveStatus.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LiveStatus.d.ts","sourceRoot":"","sources":["../../../src/planmagnet/controls/LiveStatus.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AA4B/D,wBAAgB,UAAU,CAAC,EACzB,IAAI,EACJ,SAAc,GACf,EAAE;IACD,IAAI,EAAE,eAAe,GAAG,IAAI,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,kDAaA"}
@@ -0,0 +1,31 @@
1
+ import { jsx as e, jsxs as t } from "react/jsx-runtime";
2
+ //#region src/planmagnet/controls/LiveStatus.tsx
3
+ var n = {
4
+ connecting: "Connecting…",
5
+ live: "Live",
6
+ polling: "Updating every 30 s"
7
+ }, r = {
8
+ connecting: "bg-muted-foreground animate-pulse",
9
+ live: "bg-status-success",
10
+ polling: "bg-muted-foreground"
11
+ }, i = {
12
+ connecting: "text-muted-foreground",
13
+ live: "text-status-success-text",
14
+ polling: "text-muted-foreground"
15
+ };
16
+ function a({ mode: a, className: o = "" }) {
17
+ return a ? /* @__PURE__ */ t("span", {
18
+ role: "status",
19
+ "aria-live": "polite",
20
+ "data-testid": "live-status",
21
+ className: `inline-flex items-center gap-1.5 text-xs ${i[a]} ${o}`,
22
+ children: [/* @__PURE__ */ e("span", {
23
+ "aria-hidden": "true",
24
+ className: `h-1.5 w-1.5 shrink-0 rounded-full ${r[a]}`
25
+ }), n[a]]
26
+ }) : null;
27
+ }
28
+ //#endregion
29
+ export { a as LiveStatus };
30
+
31
+ //# sourceMappingURL=LiveStatus.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LiveStatus.js","names":[],"sources":["../../../src/planmagnet/controls/LiveStatus.tsx"],"sourcesContent":["import type { LiveRefreshMode } from '../hooks/useLiveRefresh';\n\n/**\n * The small, unobtrusive indicator a page using `useLiveRefresh` shows next to its heading: \"Live\" while the\n * subscription is confirmed working, \"Updating every 30 s\" once it has fallen back to polling, and a brief\n * \"Connecting…\" in between. `aria-live=\"polite\"` so a mode change (most commonly the one-time drop to polling)\n * is announced without interrupting whatever the screen reader is doing. Renders nothing while `mode` is\n * `null` — nothing to report yet (a required id, e.g. a sprint's, hasn't loaded).\n */\n\nconst LABEL: Record<LiveRefreshMode, string> = {\n connecting: 'Connecting…',\n live: 'Live',\n polling: 'Updating every 30 s',\n};\n\nconst DOT_CLASS: Record<LiveRefreshMode, string> = {\n connecting: 'bg-muted-foreground animate-pulse',\n live: 'bg-status-success',\n polling: 'bg-muted-foreground',\n};\n\nconst TEXT_CLASS: Record<LiveRefreshMode, string> = {\n connecting: 'text-muted-foreground',\n live: 'text-status-success-text',\n polling: 'text-muted-foreground',\n};\n\nexport function LiveStatus({\n mode,\n className = '',\n}: {\n mode: LiveRefreshMode | null;\n className?: string;\n}) {\n if (!mode) return null;\n return (\n <span\n role=\"status\"\n aria-live=\"polite\"\n data-testid=\"live-status\"\n className={`inline-flex items-center gap-1.5 text-xs ${TEXT_CLASS[mode]} ${className}`}\n >\n <span aria-hidden=\"true\" className={`h-1.5 w-1.5 shrink-0 rounded-full ${DOT_CLASS[mode]}`} />\n {LABEL[mode]}\n </span>\n );\n}\n"],"mappings":";;AAUA,IAAM,IAAyC;CAC7C,YAAY;CACZ,MAAM;CACN,SAAS;CACV,EAEK,IAA6C;CACjD,YAAY;CACZ,MAAM;CACN,SAAS;CACV,EAEK,IAA8C;CAClD,YAAY;CACZ,MAAM;CACN,SAAS;CACV;AAED,SAAgB,EAAW,EACzB,SACA,eAAY,MAIX;AAED,QADK,IAEH,kBAAC,QAAD;EACE,MAAK;EACL,aAAU;EACV,eAAY;EACZ,WAAW,4CAA4C,EAAW,GAAM,GAAG;YAJ7E,CAME,kBAAC,QAAD;GAAM,eAAY;GAAO,WAAW,qCAAqC,EAAU;GAAW,CAAA,EAC7F,EAAM,GACF;MAVS"}
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Live updates (PDM-05/11/21, ANR-23): a page subscribes to a thin, workspace-scoped event stream over the
3
+ * gateway SSE path and re-reads its own named queries when something relevant changed — it never applies the
4
+ * event payload as data (the payload carries identifiers and `changedFields` only, by server design, so a
5
+ * subscriber re-reads under its own permissions instead of trusting something that bypassed RBAC and row-level
6
+ * scoping). See `useDataSinkSubscription.ts` (microfe-bigconsole) for the sibling pattern this generalizes:
7
+ * `skip` when the ids a subscription needs haven't loaded yet, and treat a transport/backend error as expected
8
+ * degradation, not a page-breaking failure.
9
+ *
10
+ * Every event stream requires `workspaceId` server-side — a subscription whose `workspaceId` is not the
11
+ * caller's own workspace is refused by the gateway, so this hook always reads it from `usePlanMagnet()` rather
12
+ * than accepting it as a prop a caller could get wrong.
13
+ *
14
+ * Connection lifecycle. SSE has no connect acknowledgement: a refused subscription (bad variables, another
15
+ * workspace, no auth) comes back at once as an error, while an accepted one simply stays open with nothing to
16
+ * say until something changes. So a stream still open and error-free after `connectTimeoutMs` is treated as
17
+ * live, and the first event proves it earlier. The server closes a stream after 60 s without events
18
+ * (`REALTIME_SUBSCRIPTION_IDLE_TIMEOUT_MS` in the svc), which Apollo reports as completion — that is routine,
19
+ * so the hook resubscribes rather than going quiet. A stream that keeps completing within seconds of opening is
20
+ * not healthy and degrades to polling.
21
+ *
22
+ * Graceful fallback (this is the point of the hook, not an edge case): if the subscription errors, or keeps
23
+ * closing as soon as it opens, `mode` becomes `'polling'` and a 30-second interval takes over, paused while the
24
+ * tab is hidden (`document.visibilityState`). There is no reconnect-to-live attempt within one mount — once
25
+ * degraded, a page stays on polling until it remounts. `standalone` dev/Storybook builds (no SSE link
26
+ * configured — see `PlanMagnetProvider`) always take this path; that is expected, not a defect, and is why a
27
+ * subscription error here is never surfaced as a page error.
28
+ */
29
+ export type LiveRefreshKind = 'workItem' | 'project' | 'sprint';
30
+ export type LiveRefreshMode = 'connecting' | 'live' | 'polling';
31
+ export interface UseLiveRefreshOptions {
32
+ /** Which event stream to subscribe to — see `PlanmagnetOn{Project,Sprint,WorkItem}Updated` in the schema. */
33
+ kind: LiveRefreshKind;
34
+ /** Narrows the stream server-side. Omitted on `workItem`/`project` this is a workspace-wide stream (the
35
+ * Dashboard and role dashboards want every project's events); `sprint` needs `sprintId` to mean anything on a
36
+ * single sprint's page, so the hook skips subscribing until it has one. */
37
+ projectId?: string | null;
38
+ /** For `kind: 'sprint'`, at least one of `sprintId`/`projectId` is required — one sprint's own events, or
39
+ * every sprint in one project's. Neither means "skip" (every sprint workspace-wide has no current caller). */
40
+ sprintId?: string | null;
41
+ /** Narrows a `workItem`-kind stream to one item. Unused by every current caller (the board/dashboards want
42
+ * every item's events for their scope) but supported for a future single-item page. */
43
+ workItemId?: string | null;
44
+ /** Apollo operation names this page's queries were declared with — refetched by name
45
+ * (`client.refetchQueries({ include })`) on a (debounced, optionally throttled) event. Never the literal
46
+ * query document, and never the event's own payload used as data. */
47
+ queries: readonly string[];
48
+ /** Coalesces a burst of events (e.g. a bulk update moving 20 cards) into one refetch. Default 500. */
49
+ debounceMs?: number;
50
+ /** A floor between refetches once debounced, for a page whose queries are expensive to re-run on every
51
+ * change (ANR-23: the Dashboard and role dashboards, at most once per 15s). Unset: only the debounce window
52
+ * applies. A pulse arriving inside the floor is never dropped — it runs at the floor's far edge (trailing). */
53
+ minIntervalMs?: number;
54
+ /** How long an open, error-free subscription stays "Connecting…" before it counts as live. Default 8000. */
55
+ connectTimeoutMs?: number;
56
+ /** Polling cadence once on the fallback path. Default 30000 (ANR-23/PDM-05: "every 30s"). */
57
+ pollIntervalMs?: number;
58
+ /** An extra gate beyond the kind's own required id(s) — e.g. a sprint page's `workItem`-kind stream (no id of
59
+ * its own is required) should still wait for the sprint's `projectId` to resolve, and skip entirely for a
60
+ * team-scoped sprint (no `projectId` at all) rather than falling back to a workspace-wide stream. Default
61
+ * `true` (no extra gate). */
62
+ enabled?: boolean;
63
+ }
64
+ export interface UseLiveRefreshResult {
65
+ /** `null` while a required id (e.g. a sprint page before `sprintId` resolves) hasn't loaded — there is
66
+ * nothing to subscribe to yet, so `LiveStatus` renders nothing rather than a misleading "Connecting…". */
67
+ mode: LiveRefreshMode | null;
68
+ }
69
+ /** Rolls up more than one `useLiveRefresh` result into the single indicator a page shows (e.g. the sprint
70
+ * detail page subscribes to both sprint events and the sprint's project's work item events). Reports the least
71
+ * favorable non-null mode present — `'polling'` beats `'connecting'` beats `'live'` — so the page never claims
72
+ * "Live" while one of its own streams is actually degraded. `null` (nothing subscribed yet) only when every
73
+ * input is `null`. */
74
+ export declare function combineLiveRefreshModes(...modes: ReadonlyArray<LiveRefreshMode | null>): LiveRefreshMode | null;
75
+ export declare function useLiveRefresh({ kind, projectId, sprintId, workItemId, queries, debounceMs, minIntervalMs, connectTimeoutMs, pollIntervalMs, enabled, }: UseLiveRefreshOptions): UseLiveRefreshResult;
76
+ //# sourceMappingURL=useLiveRefresh.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLiveRefresh.d.ts","sourceRoot":"","sources":["../../../src/planmagnet/hooks/useLiveRefresh.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,MAAM,MAAM,eAAe,GAAG,UAAU,GAAG,SAAS,GAAG,QAAQ,CAAC;AAChE,MAAM,MAAM,eAAe,GAAG,YAAY,GAAG,MAAM,GAAG,SAAS,CAAC;AA6DhE,MAAM,WAAW,qBAAqB;IACpC,6GAA6G;IAC7G,IAAI,EAAE,eAAe,CAAC;IACtB;;+EAE2E;IAC3E,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B;kHAC8G;IAC9G,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB;2FACuF;IACvF,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B;;yEAEqE;IACrE,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B,sGAAsG;IACtG,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;mHAE+G;IAC/G,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,4GAA4G;IAC5G,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,6FAA6F;IAC7F,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;iCAG6B;IAC7B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,oBAAoB;IACnC;8GAC0G;IAC1G,IAAI,EAAE,eAAe,GAAG,IAAI,CAAC;CAC9B;AAED;;;;sBAIsB;AACtB,wBAAgB,uBAAuB,CACrC,GAAG,KAAK,EAAE,aAAa,CAAC,eAAe,GAAG,IAAI,CAAC,GAC9C,eAAe,GAAG,IAAI,CAMxB;AA8DD,wBAAgB,cAAc,CAAC,EAC7B,IAAI,EACJ,SAAS,EACT,QAAQ,EACR,UAAU,EACV,OAAO,EACP,UAAgB,EAChB,aAAa,EACb,gBAAuB,EACvB,cAAsB,EACtB,OAAc,GACf,EAAE,qBAAqB,GAAG,oBAAoB,CAgI9C"}
@@ -0,0 +1,143 @@
1
+ import { usePlanMagnet as e } from "../providers/PlanMagnetProvider.js";
2
+ import { useCallback as t, useEffect as n, useRef as r, useState as i } from "react";
3
+ import { gql as a } from "@apollo/client";
4
+ import { useApolloClient as o, useSubscription as s } from "@apollo/client/react";
5
+ //#region src/planmagnet/hooks/useLiveRefresh.ts
6
+ var c = a`
7
+ subscription PlanmagnetLiveProjectUpdated($workspaceId: ID!, $projectId: ID) {
8
+ planmagnetOnProjectUpdated(workspaceId: $workspaceId, projectId: $projectId) {
9
+ kind
10
+ id
11
+ workspaceId
12
+ changedFields
13
+ actorId
14
+ at
15
+ }
16
+ }
17
+ `, l = a`
18
+ subscription PlanmagnetLiveSprintUpdated($workspaceId: ID!, $sprintId: ID, $projectId: ID) {
19
+ planmagnetOnSprintUpdated(
20
+ workspaceId: $workspaceId
21
+ sprintId: $sprintId
22
+ projectId: $projectId
23
+ ) {
24
+ kind
25
+ id
26
+ projectId
27
+ workspaceId
28
+ changedFields
29
+ actorId
30
+ at
31
+ }
32
+ }
33
+ `, u = a`
34
+ subscription PlanmagnetLiveWorkItemUpdated($workspaceId: ID!, $projectId: ID, $workItemId: ID) {
35
+ planmagnetOnWorkItemUpdated(
36
+ workspaceId: $workspaceId
37
+ projectId: $projectId
38
+ workItemId: $workItemId
39
+ ) {
40
+ kind
41
+ id
42
+ projectId
43
+ workspaceId
44
+ changedFields
45
+ actorId
46
+ at
47
+ }
48
+ }
49
+ `;
50
+ function d(...e) {
51
+ let t = e.filter((e) => e !== null);
52
+ return t.length === 0 ? null : t.includes("polling") ? "polling" : t.includes("connecting") ? "connecting" : "live";
53
+ }
54
+ var f = 5e3, p = 3;
55
+ function m(e) {
56
+ return e === "project" ? c : e === "sprint" ? l : u;
57
+ }
58
+ function h(e, i, a) {
59
+ let o = r(null), s = r(null), c = r(0), l = r(!1), u = t(() => {
60
+ l.current = !1, c.current = Date.now(), e();
61
+ }, [e]), d = t(() => {
62
+ o.current && clearTimeout(o.current), o.current = setTimeout(() => {
63
+ if (o.current = null, !a) {
64
+ u();
65
+ return;
66
+ }
67
+ let e = Date.now() - c.current;
68
+ if (e >= a) {
69
+ u();
70
+ return;
71
+ }
72
+ l.current || (l.current = !0, s.current = setTimeout(u, a - e));
73
+ }, i);
74
+ }, [
75
+ i,
76
+ a,
77
+ u
78
+ ]);
79
+ return n(() => () => {
80
+ o.current && clearTimeout(o.current), s.current && clearTimeout(s.current);
81
+ }, []), d;
82
+ }
83
+ function g({ kind: a, projectId: c, sprintId: l, workItemId: u, queries: d, debounceMs: g = 500, minIntervalMs: _, connectTimeoutMs: v = 8e3, pollIntervalMs: y = 3e4, enabled: b = !0 }) {
84
+ let { workspaceId: x } = e(), S = o(), C = !x || a === "sprint" && !l && !c || a === "project" && !c || !b, w = C ? null : `${a}:${x}:${c ?? ""}:${l ?? ""}:${u ?? ""}`, T = t(() => {
85
+ S.refetchQueries({ include: [...d] });
86
+ }, [S, d]), E = h(T, g, _), [D, O] = i(w ? "connecting" : null), [k, A] = i(w);
87
+ w !== k && (A(w), O(w ? "connecting" : null)), n(() => {
88
+ if (!w) return;
89
+ let e = setTimeout(() => {
90
+ O((e) => e === "connecting" ? "live" : e);
91
+ }, v);
92
+ return () => clearTimeout(e);
93
+ }, [w, v]);
94
+ let j = r(0), M = r(0), N = r(null);
95
+ n(() => (j.current = Date.now(), M.current = 0, () => {
96
+ N.current && clearTimeout(N.current), N.current = null;
97
+ }), [w]);
98
+ let P = r(null), F = t(() => {
99
+ if (M.current = Date.now() - j.current < f ? M.current + 1 : 0, M.current >= p) {
100
+ O("polling");
101
+ return;
102
+ }
103
+ N.current = setTimeout(() => {
104
+ N.current = null, j.current = Date.now(), P.current?.();
105
+ }, 0);
106
+ }, []), { restart: I } = s(m(a), {
107
+ variables: {
108
+ workspaceId: x,
109
+ projectId: c ?? void 0,
110
+ sprintId: l ?? void 0,
111
+ workItemId: u ?? void 0
112
+ },
113
+ skip: C,
114
+ onData: () => {
115
+ O((e) => e === "connecting" ? "live" : e), E();
116
+ },
117
+ onError: (e) => {
118
+ console.debug("[useLiveRefresh] subscription unavailable, falling back to polling:", {
119
+ kind: a,
120
+ message: e instanceof Error ? e.message : String(e)
121
+ }), O("polling");
122
+ },
123
+ onComplete: F
124
+ });
125
+ return n(() => {
126
+ P.current = I;
127
+ }, [I]), n(() => {
128
+ if (C || D !== "polling") return;
129
+ let e = setInterval(() => {
130
+ typeof document < "u" && document.visibilityState === "hidden" || T();
131
+ }, y);
132
+ return () => clearInterval(e);
133
+ }, [
134
+ C,
135
+ D,
136
+ y,
137
+ T
138
+ ]), { mode: C ? null : D };
139
+ }
140
+ //#endregion
141
+ export { d as combineLiveRefreshModes, g as useLiveRefresh };
142
+
143
+ //# sourceMappingURL=useLiveRefresh.js.map