@dxos/plugin-thread 0.6.11 → 0.6.12-main.15a606f

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 (79) hide show
  1. package/dist/lib/browser/{ThreadArticle-O64ZECMF.mjs → ThreadArticle-4VU752F4.mjs} +3 -3
  2. package/dist/lib/browser/{ThreadMain-ZDCRC6RG.mjs → ThreadMain-ML3P4XSD.mjs} +3 -3
  3. package/dist/lib/browser/{chunk-5IBJO53M.mjs → chunk-7NUYW5IW.mjs} +2 -5
  4. package/dist/lib/browser/chunk-7NUYW5IW.mjs.map +7 -0
  5. package/dist/lib/browser/{chunk-GKPZHUT3.mjs → chunk-GJRBBPXI.mjs} +2 -2
  6. package/dist/lib/browser/{chunk-GKPZHUT3.mjs.map → chunk-GJRBBPXI.mjs.map} +1 -1
  7. package/dist/lib/browser/{chunk-P7ZE5N5M.mjs → chunk-XF5QKI75.mjs} +13 -11
  8. package/dist/lib/browser/chunk-XF5QKI75.mjs.map +7 -0
  9. package/dist/lib/browser/index.mjs +237 -207
  10. package/dist/lib/browser/index.mjs.map +4 -4
  11. package/dist/lib/browser/meta.json +1 -1
  12. package/dist/lib/browser/meta.mjs +1 -1
  13. package/dist/lib/browser/types.mjs +2 -2
  14. package/dist/lib/node/{ThreadArticle-DO56JXBU.cjs → ThreadArticle-ERUHPHVT.cjs} +7 -7
  15. package/dist/lib/node/{ThreadMain-XJX75GHG.cjs → ThreadMain-6DN7FDNB.cjs} +7 -7
  16. package/dist/lib/node/{chunk-BWBONZGU.cjs → chunk-6EVXCSDS.cjs} +5 -18
  17. package/dist/lib/node/chunk-6EVXCSDS.cjs.map +7 -0
  18. package/dist/lib/node/{chunk-D5GOVXHS.cjs → chunk-FXD3DYMO.cjs} +6 -6
  19. package/dist/lib/node/{chunk-D5GOVXHS.cjs.map → chunk-FXD3DYMO.cjs.map} +1 -1
  20. package/dist/lib/node/{chunk-5PZNPPQF.cjs → chunk-PZVUW4W2.cjs} +65 -63
  21. package/dist/lib/node/chunk-PZVUW4W2.cjs.map +7 -0
  22. package/dist/lib/node/index.cjs +324 -296
  23. package/dist/lib/node/index.cjs.map +4 -4
  24. package/dist/lib/node/meta.cjs +4 -4
  25. package/dist/lib/node/meta.cjs.map +1 -1
  26. package/dist/lib/node/meta.json +1 -1
  27. package/dist/lib/node/types.cjs +3 -3
  28. package/dist/lib/node/types.cjs.map +1 -1
  29. package/dist/lib/node-esm/ThreadArticle-NKI5F4W5.mjs +19 -0
  30. package/dist/lib/node-esm/ThreadArticle-NKI5F4W5.mjs.map +7 -0
  31. package/dist/lib/node-esm/ThreadMain-2A3VQLCW.mjs +27 -0
  32. package/dist/lib/node-esm/ThreadMain-2A3VQLCW.mjs.map +7 -0
  33. package/dist/lib/node-esm/chunk-A44C4MTQ.mjs +413 -0
  34. package/dist/lib/node-esm/chunk-A44C4MTQ.mjs.map +7 -0
  35. package/dist/lib/node-esm/chunk-Y475KZTX.mjs +20 -0
  36. package/dist/lib/node-esm/chunk-Y475KZTX.mjs.map +7 -0
  37. package/dist/lib/node-esm/chunk-YO46JGAE.mjs +21 -0
  38. package/dist/lib/node-esm/chunk-YO46JGAE.mjs.map +7 -0
  39. package/dist/lib/node-esm/index.mjs +1133 -0
  40. package/dist/lib/node-esm/index.mjs.map +7 -0
  41. package/dist/lib/node-esm/meta.json +1 -0
  42. package/dist/lib/node-esm/meta.mjs +12 -0
  43. package/dist/lib/node-esm/meta.mjs.map +7 -0
  44. package/dist/lib/node-esm/types.mjs +9 -0
  45. package/dist/lib/node-esm/types.mjs.map +7 -0
  46. package/dist/types/src/ThreadPlugin.d.ts.map +1 -1
  47. package/dist/types/src/components/ChatContainer.d.ts.map +1 -1
  48. package/dist/types/src/components/CommentContainer.d.ts.map +1 -1
  49. package/dist/types/src/components/CommentsContainer.d.ts.map +1 -1
  50. package/dist/types/src/components/MessageContainer.d.ts.map +1 -1
  51. package/dist/types/src/components/ThreadComplementary.d.ts +11 -0
  52. package/dist/types/src/components/ThreadComplementary.d.ts.map +1 -0
  53. package/dist/types/src/components/testing.d.ts +2 -0
  54. package/dist/types/src/components/testing.d.ts.map +1 -1
  55. package/dist/types/src/meta.d.ts +1 -4
  56. package/dist/types/src/meta.d.ts.map +1 -1
  57. package/dist/types/src/types.d.ts +1 -1
  58. package/dist/types/src/types.d.ts.map +1 -1
  59. package/package.json +37 -34
  60. package/src/ThreadPlugin.tsx +67 -178
  61. package/src/components/ChatContainer.tsx +7 -8
  62. package/src/components/CommentContainer.tsx +10 -7
  63. package/src/components/Comments.stories.tsx +2 -2
  64. package/src/components/CommentsContainer.tsx +22 -18
  65. package/src/components/MessageContainer.tsx +2 -1
  66. package/src/components/ThreadComplementary.tsx +120 -0
  67. package/src/meta.tsx +1 -5
  68. package/src/types.ts +1 -1
  69. package/dist/lib/browser/chunk-5IBJO53M.mjs.map +0 -7
  70. package/dist/lib/browser/chunk-P7ZE5N5M.mjs.map +0 -7
  71. package/dist/lib/node/chunk-5PZNPPQF.cjs.map +0 -7
  72. package/dist/lib/node/chunk-BWBONZGU.cjs.map +0 -7
  73. package/dist/types/src/types.test.d.ts +0 -2
  74. package/dist/types/src/types.test.d.ts.map +0 -1
  75. package/src/types.test.ts +0 -13
  76. /package/dist/lib/browser/{ThreadArticle-O64ZECMF.mjs.map → ThreadArticle-4VU752F4.mjs.map} +0 -0
  77. /package/dist/lib/browser/{ThreadMain-ZDCRC6RG.mjs.map → ThreadMain-ML3P4XSD.mjs.map} +0 -0
  78. /package/dist/lib/node/{ThreadArticle-DO56JXBU.cjs.map → ThreadArticle-ERUHPHVT.cjs.map} +0 -0
  79. /package/dist/lib/node/{ThreadMain-XJX75GHG.cjs.map → ThreadMain-6DN7FDNB.cjs.map} +0 -0
@@ -28,73 +28,76 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
  var node_exports = {};
30
30
  __export(node_exports, {
31
- ThreadAction: () => import_chunk_D5GOVXHS.ThreadAction,
31
+ ThreadAction: () => import_chunk_FXD3DYMO.ThreadAction,
32
32
  ThreadPlugin: () => ThreadPlugin,
33
33
  default: () => src_default,
34
- useAnalyticsCallback: () => import_chunk_5PZNPPQF.useAnalyticsCallback,
35
- useOnEditAnalytics: () => import_chunk_5PZNPPQF.useOnEditAnalytics,
36
- useStatus: () => import_chunk_5PZNPPQF.useStatus
34
+ useAnalyticsCallback: () => import_chunk_PZVUW4W2.useAnalyticsCallback,
35
+ useOnEditAnalytics: () => import_chunk_PZVUW4W2.useOnEditAnalytics,
36
+ useStatus: () => import_chunk_PZVUW4W2.useStatus
37
37
  });
38
38
  module.exports = __toCommonJS(node_exports);
39
- var import_chunk_D5GOVXHS = require("./chunk-D5GOVXHS.cjs");
40
- var import_chunk_5PZNPPQF = require("./chunk-5PZNPPQF.cjs");
41
- var import_chunk_BWBONZGU = require("./chunk-BWBONZGU.cjs");
42
- var import_react = require("@phosphor-icons/react");
39
+ var import_chunk_FXD3DYMO = require("./chunk-FXD3DYMO.cjs");
40
+ var import_chunk_PZVUW4W2 = require("./chunk-PZVUW4W2.cjs");
41
+ var import_chunk_6EVXCSDS = require("./chunk-6EVXCSDS.cjs");
43
42
  var import_signals_core = require("@preact/signals-core");
44
- var import_react2 = __toESM(require("react"));
43
+ var import_react = __toESM(require("react"));
45
44
  var import_app_framework = require("@dxos/app-framework");
46
45
  var import_echo_schema = require("@dxos/echo-schema");
47
46
  var import_echo_schema2 = require("@dxos/echo-schema");
48
47
  var import_local_storage = require("@dxos/local-storage");
49
- var import_plugin_attention = require("@dxos/plugin-attention");
48
+ var import_log = require("@dxos/log");
50
49
  var import_plugin_client = require("@dxos/plugin-client");
51
50
  var import_plugin_graph = require("@dxos/plugin-graph");
52
- var import_types = require("@dxos/plugin-markdown/types");
53
51
  var import_meta = require("@dxos/plugin-observability/meta");
54
52
  var import_plugin_space = require("@dxos/plugin-space");
55
- var import_types2 = require("@dxos/plugin-space/types");
53
+ var import_types = require("@dxos/plugin-space/types");
56
54
  var import_echo = require("@dxos/react-client/echo");
57
- var import_react_ui = require("@dxos/react-ui");
58
- var import_react_ui_attention = require("@dxos/react-ui-attention");
59
55
  var import_react_ui_editor = require("@dxos/react-ui-editor");
60
56
  var import_react_ui_thread = require("@dxos/react-ui-thread");
61
57
  var import_util = require("@dxos/util");
58
+ var import_react2 = __toESM(require("react"));
62
59
  var import_react3 = __toESM(require("react"));
63
- var import_react4 = __toESM(require("react"));
64
60
  var import_plugin_settings = require("@dxos/plugin-settings");
65
- var import_react_ui2 = require("@dxos/react-ui");
66
- var import_react5 = require("@phosphor-icons/react");
67
- var import_react6 = __toESM(require("react"));
61
+ var import_react_ui = require("@dxos/react-ui");
62
+ var import_react4 = require("@phosphor-icons/react");
63
+ var import_react5 = __toESM(require("react"));
68
64
  var import_echo_schema3 = require("@dxos/echo-schema");
69
- var import_types3 = require("@dxos/plugin-space/types");
65
+ var import_types2 = require("@dxos/plugin-space/types");
70
66
  var import_echo2 = require("@dxos/react-client/echo");
71
67
  var import_halo = require("@dxos/react-client/halo");
72
- var import_react_ui3 = require("@dxos/react-ui");
68
+ var import_react_ui2 = require("@dxos/react-ui");
73
69
  var import_react_ui_editor2 = require("@dxos/react-ui-editor");
74
70
  var import_react_ui_theme = require("@dxos/react-ui-theme");
75
71
  var import_react_ui_thread2 = require("@dxos/react-ui-thread");
76
72
  var import_util2 = require("@dxos/util");
77
- var import_react7 = require("@phosphor-icons/react");
78
- var import_react8 = __toESM(require("react"));
79
- var import_react_ui4 = require("@dxos/react-ui");
73
+ var import_react6 = require("@phosphor-icons/react");
74
+ var import_react7 = __toESM(require("react"));
75
+ var import_echo3 = require("@dxos/react-client/echo");
76
+ var import_react_ui3 = require("@dxos/react-ui");
80
77
  var import_react_ui_deck = require("@dxos/react-ui-deck");
81
78
  var import_react_ui_theme2 = require("@dxos/react-ui-theme");
79
+ var import_react8 = __toESM(require("react"));
80
+ var import_app_framework2 = require("@dxos/app-framework");
81
+ var import_echo4 = require("@dxos/react-client/echo");
82
+ var import_react_ui4 = require("@dxos/react-ui");
83
+ var import_react_ui_attention = require("@dxos/react-ui-attention");
84
+ var import_util3 = require("@dxos/util");
82
85
  var ThreadSettings = ({ settings }) => {
83
- const { t } = (0, import_react_ui2.useTranslation)(import_chunk_BWBONZGU.THREAD_PLUGIN);
84
- return /* @__PURE__ */ import_react4.default.createElement(import_react4.default.Fragment, null, /* @__PURE__ */ import_react4.default.createElement(import_plugin_settings.SettingsValue, {
86
+ const { t } = (0, import_react_ui.useTranslation)(import_chunk_6EVXCSDS.THREAD_PLUGIN);
87
+ return /* @__PURE__ */ import_react3.default.createElement(import_react3.default.Fragment, null, /* @__PURE__ */ import_react3.default.createElement(import_plugin_settings.SettingsValue, {
85
88
  label: t("settings standalone label")
86
- }, /* @__PURE__ */ import_react4.default.createElement(import_react_ui2.Input.Switch, {
89
+ }, /* @__PURE__ */ import_react3.default.createElement(import_react_ui.Input.Switch, {
87
90
  checked: settings.standalone,
88
91
  onCheckedChange: (checked) => settings.standalone = !!checked
89
92
  })));
90
93
  };
91
94
  var sizeClass = (0, import_react_ui_theme.getSize)(4);
92
95
  var ToggleResolvedButton = ({ isResolved, onResolve }) => {
93
- const { t } = (0, import_react_ui3.useTranslation)(import_chunk_BWBONZGU.THREAD_PLUGIN);
96
+ const { t } = (0, import_react_ui2.useTranslation)(import_chunk_6EVXCSDS.THREAD_PLUGIN);
94
97
  const label = t(isResolved ? "mark as unresolved label" : "mark as resolved label");
95
- return /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.Tooltip.Root, null, /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.Tooltip.Trigger, {
98
+ return /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Root, null, /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Trigger, {
96
99
  asChild: true
97
- }, /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.Button, {
100
+ }, /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Button, {
98
101
  variant: "ghost",
99
102
  "data-testid": "thread.toggle-resolved",
100
103
  onClick: onResolve,
@@ -102,23 +105,23 @@ var ToggleResolvedButton = ({ isResolved, onResolve }) => {
102
105
  "min-bs-0 p-1",
103
106
  !isResolved && import_react_ui_theme.hoverableControlItem
104
107
  ]
105
- }, /* @__PURE__ */ import_react6.default.createElement("span", {
108
+ }, /* @__PURE__ */ import_react5.default.createElement("span", {
106
109
  className: "sr-only"
107
- }, label), isResolved ? /* @__PURE__ */ import_react6.default.createElement(import_react5.CheckCircle, {
110
+ }, label), isResolved ? /* @__PURE__ */ import_react5.default.createElement(import_react4.CheckCircle, {
108
111
  className: sizeClass,
109
112
  weight: "fill"
110
- }) : /* @__PURE__ */ import_react6.default.createElement(import_react5.CheckCircle, {
113
+ }) : /* @__PURE__ */ import_react5.default.createElement(import_react4.CheckCircle, {
111
114
  className: sizeClass
112
- }))), /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.Tooltip.Portal, null, /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.Tooltip.Content, {
115
+ }))), /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Portal, null, /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Content, {
113
116
  classNames: "z-[21]"
114
- }, label, /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.Tooltip.Arrow, null))));
117
+ }, label, /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Arrow, null))));
115
118
  };
116
119
  var DeleteThreadButton = ({ onDelete }) => {
117
- const { t } = (0, import_react_ui3.useTranslation)(import_chunk_BWBONZGU.THREAD_PLUGIN);
120
+ const { t } = (0, import_react_ui2.useTranslation)(import_chunk_6EVXCSDS.THREAD_PLUGIN);
118
121
  const label = t("delete thread label");
119
- return /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.Tooltip.Root, null, /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.Tooltip.Trigger, {
122
+ return /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Root, null, /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Trigger, {
120
123
  asChild: true
121
- }, /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.Button, {
124
+ }, /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Button, {
122
125
  variant: "ghost",
123
126
  "data-testid": "thread.delete",
124
127
  onClick: onDelete,
@@ -126,28 +129,28 @@ var DeleteThreadButton = ({ onDelete }) => {
126
129
  "min-bs-0 p-1",
127
130
  import_react_ui_theme.hoverableControlItem
128
131
  ]
129
- }, /* @__PURE__ */ import_react6.default.createElement("span", {
132
+ }, /* @__PURE__ */ import_react5.default.createElement("span", {
130
133
  className: "sr-only"
131
- }, label), /* @__PURE__ */ import_react6.default.createElement(import_react5.X, {
134
+ }, label), /* @__PURE__ */ import_react5.default.createElement(import_react4.X, {
132
135
  className: sizeClass
133
- }))), /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.Tooltip.Portal, null, /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.Tooltip.Content, {
136
+ }))), /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Portal, null, /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Content, {
134
137
  classNames: "z-[21]"
135
- }, label, /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.Tooltip.Arrow, null))));
138
+ }, label, /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Arrow, null))));
136
139
  };
137
140
  var CommentContainer = ({ thread, detached, context, current, autoFocusTextbox, onAttend, onThreadDelete, onMessageDelete, onResolve, onComment }) => {
138
141
  const identity = (0, import_halo.useIdentity)();
139
142
  const space = (0, import_echo2.getSpace)(thread);
140
143
  const members = (0, import_echo2.useMembers)(space?.key);
141
- const activity = (0, import_chunk_5PZNPPQF.useStatus)(space, thread.id);
142
- const { t } = (0, import_react_ui3.useTranslation)(import_chunk_BWBONZGU.THREAD_PLUGIN);
143
- const threadScrollRef = (0, import_react6.useRef)(null);
144
- const [autoFocus, setAutoFocus] = (0, import_react6.useState)(!!autoFocusTextbox);
145
- const { themeMode } = (0, import_react_ui3.useThemeContext)();
146
- const textboxMetadata = (0, import_chunk_5PZNPPQF.getMessageMetadata)(thread.id, identity);
147
- const [_count, _setCount] = (0, import_react6.useState)(0);
144
+ const activity = (0, import_chunk_PZVUW4W2.useStatus)(space, (0, import_echo2.fullyQualifiedId)(thread));
145
+ const { t } = (0, import_react_ui2.useTranslation)(import_chunk_6EVXCSDS.THREAD_PLUGIN);
146
+ const threadScrollRef = (0, import_react5.useRef)(null);
147
+ const [autoFocus, setAutoFocus] = (0, import_react5.useState)(!!autoFocusTextbox);
148
+ const { themeMode } = (0, import_react_ui2.useThemeContext)();
149
+ const textboxMetadata = (0, import_chunk_PZVUW4W2.getMessageMetadata)((0, import_echo2.fullyQualifiedId)(thread), identity);
150
+ const [_count, _setCount] = (0, import_react5.useState)(0);
148
151
  const rerenderEditor = () => _setCount((count) => count + 1);
149
- const messageRef = (0, import_react6.useRef)("");
150
- const extensions = (0, import_react6.useMemo)(() => [
152
+ const messageRef = (0, import_react5.useRef)("");
153
+ const extensions = (0, import_react5.useMemo)(() => [
151
154
  (0, import_react_ui_editor2.createBasicExtensions)({
152
155
  placeholder: t("message placeholder")
153
156
  }),
@@ -157,11 +160,11 @@ var CommentContainer = ({ thread, detached, context, current, autoFocusTextbox,
157
160
  (0, import_react_ui_editor2.listener)({
158
161
  onChange: (text) => messageRef.current = text
159
162
  }),
160
- import_chunk_5PZNPPQF.command
163
+ import_chunk_PZVUW4W2.command
161
164
  ], [
162
165
  _count
163
166
  ]);
164
- (0, import_react6.useEffect)(() => {
167
+ (0, import_react5.useEffect)(() => {
165
168
  setAutoFocus(!!autoFocusTextbox);
166
169
  }, [
167
170
  autoFocusTextbox
@@ -170,11 +173,11 @@ var CommentContainer = ({ thread, detached, context, current, autoFocusTextbox,
170
173
  behavior,
171
174
  block: "end"
172
175
  }), 10);
173
- const handleCreate = (0, import_react6.useCallback)(() => {
176
+ const handleCreate = (0, import_react5.useCallback)(() => {
174
177
  if (!messageRef.current) {
175
178
  return false;
176
179
  }
177
- thread.messages.push((0, import_echo_schema3.create)(import_types3.MessageType, {
180
+ thread.messages.push((0, import_echo_schema3.create)(import_types2.MessageType, {
178
181
  sender: {
179
182
  identityKey: identity.identityKey.toHex()
180
183
  },
@@ -192,64 +195,66 @@ var CommentContainer = ({ thread, detached, context, current, autoFocusTextbox,
192
195
  thread,
193
196
  identity
194
197
  ]);
195
- const handleDeleteMessage = (id) => onMessageDelete?.(id);
196
- return /* @__PURE__ */ import_react6.default.createElement(import_react_ui_thread2.Thread, {
198
+ return /* @__PURE__ */ import_react5.default.createElement(import_react_ui_thread2.Thread, {
197
199
  onClickCapture: onAttend,
198
200
  onFocusCapture: onAttend,
199
201
  current,
200
- id: thread.id
201
- }, /* @__PURE__ */ import_react6.default.createElement("div", {
202
+ id: (0, import_echo2.fullyQualifiedId)(thread)
203
+ }, /* @__PURE__ */ import_react5.default.createElement("div", {
202
204
  role: "none",
203
205
  className: (0, import_react_ui_theme.mx)("col-span-2 grid grid-cols-[var(--rail-size)_1fr_min-content]", import_react_ui_theme.hoverableControls, import_react_ui_theme.hoverableFocusedWithinControls)
204
- }, detached ? /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.Tooltip.Root, null, /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.Tooltip.Trigger, {
206
+ }, detached ? /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Root, null, /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Trigger, {
205
207
  asChild: true
206
- }, /* @__PURE__ */ import_react6.default.createElement(import_react_ui_thread2.ThreadHeading, {
208
+ }, /* @__PURE__ */ import_react5.default.createElement(import_react_ui_thread2.ThreadHeading, {
207
209
  detached: true
208
- }, thread.name ?? t("thread title placeholder"))), /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.Tooltip.Portal, null, /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.Tooltip.Content, {
210
+ }, thread.name ?? t("thread title placeholder"))), /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Portal, null, /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Content, {
209
211
  classNames: "z-[21]",
210
212
  side: "top"
211
- }, t("detached thread label"), /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.Tooltip.Arrow, null)))) : /* @__PURE__ */ import_react6.default.createElement(import_react_ui_thread2.ThreadHeading, null, thread.name ?? t("thread title placeholder")), /* @__PURE__ */ import_react6.default.createElement("div", {
213
+ }, t("detached thread label"), /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Arrow, null)))) : /* @__PURE__ */ import_react5.default.createElement(import_react_ui_thread2.ThreadHeading, null, thread.name ?? t("thread title placeholder")), /* @__PURE__ */ import_react5.default.createElement("div", {
212
214
  className: "flex flex-row items-center pli-1"
213
- }, thread.status === "staged" && /* @__PURE__ */ import_react6.default.createElement(import_react_ui3.Tag, {
215
+ }, thread.status === "staged" && /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tag, {
214
216
  palette: "neutral"
215
- }, t("draft button")), onResolve && !(thread?.status === "staged") && /* @__PURE__ */ import_react6.default.createElement(ToggleResolvedButton, {
217
+ }, t("draft button")), onResolve && !(thread?.status === "staged") && /* @__PURE__ */ import_react5.default.createElement(ToggleResolvedButton, {
216
218
  isResolved: thread?.status === "resolved",
217
219
  onResolve
218
- }), onThreadDelete && /* @__PURE__ */ import_react6.default.createElement(DeleteThreadButton, {
220
+ }), onThreadDelete && /* @__PURE__ */ import_react5.default.createElement(DeleteThreadButton, {
219
221
  onDelete: onThreadDelete
220
- }))), thread.messages.filter(import_util2.nonNullable).map((message) => /* @__PURE__ */ import_react6.default.createElement(import_chunk_5PZNPPQF.MessageContainer, {
222
+ }))), thread.messages.filter(import_util2.nonNullable).map((message) => /* @__PURE__ */ import_react5.default.createElement(import_chunk_PZVUW4W2.MessageContainer, {
221
223
  key: message.id,
222
224
  message,
223
225
  members,
224
- onDelete: handleDeleteMessage
225
- })), /* @__PURE__ */ import_react6.default.createElement(import_react_ui_thread2.MessageTextbox, {
226
+ onDelete: (id) => onMessageDelete?.(id)
227
+ })), /* @__PURE__ */ import_react5.default.createElement(import_react_ui_thread2.MessageTextbox, {
226
228
  extensions,
227
229
  autoFocus,
228
230
  onSend: handleCreate,
229
231
  ...textboxMetadata
230
- }), /* @__PURE__ */ import_react6.default.createElement(import_react_ui_thread2.ThreadFooter, {
232
+ }), /* @__PURE__ */ import_react5.default.createElement(import_react_ui_thread2.ThreadFooter, {
231
233
  activity
232
- }, t("activity message")), /* @__PURE__ */ import_react6.default.createElement("div", {
234
+ }, t("activity message")), /* @__PURE__ */ import_react5.default.createElement("div", {
233
235
  role: "none",
234
236
  className: "bs-px -mbs-px",
235
237
  ref: threadScrollRef
236
238
  }));
237
239
  };
238
240
  var CommentsHeading = ({ attendableId }) => {
239
- const { t } = (0, import_react_ui4.useTranslation)(import_chunk_BWBONZGU.THREAD_PLUGIN);
240
- return /* @__PURE__ */ import_react8.default.createElement("div", {
241
+ const { t } = (0, import_react_ui3.useTranslation)(import_chunk_6EVXCSDS.THREAD_PLUGIN);
242
+ return /* @__PURE__ */ import_react7.default.createElement("div", {
241
243
  role: "none",
242
244
  className: "flex items-center"
243
- }, /* @__PURE__ */ import_react8.default.createElement(import_react_ui_deck.PlankHeading.Button, {
245
+ }, /* @__PURE__ */ import_react7.default.createElement(import_react_ui_deck.PlankHeading.Button, {
244
246
  attendableId
245
- }, /* @__PURE__ */ import_react8.default.createElement(import_react7.Quotes, import_react_ui_deck.plankHeadingIconProps)), /* @__PURE__ */ import_react8.default.createElement(import_react_ui_deck.PlankHeading.Label, {
247
+ }, /* @__PURE__ */ import_react7.default.createElement(import_react_ui3.Icon, {
248
+ icon: "ph--quotes--regular",
249
+ size: 5
250
+ })), /* @__PURE__ */ import_react7.default.createElement(import_react_ui_deck.PlankHeading.Label, {
246
251
  attendableId
247
252
  }, t("comments heading")));
248
253
  };
249
254
  var CommentsContainer = ({ threads, detached = [], currentId, autoFocusCurrentTextbox, showResolvedThreads, onThreadAttend, onThreadDelete, onMessageDelete, onThreadToggleResolved, ...props }) => {
250
- const { t } = (0, import_react_ui4.useTranslation)(import_chunk_BWBONZGU.THREAD_PLUGIN);
255
+ const { t } = (0, import_react_ui3.useTranslation)(import_chunk_6EVXCSDS.THREAD_PLUGIN);
251
256
  const filteredThreads = showResolvedThreads ? threads : threads.filter((thread) => !(thread?.status === "resolved"));
252
- (0, import_react8.useEffect)(() => {
257
+ (0, import_react7.useEffect)(() => {
253
258
  if (currentId) {
254
259
  document.getElementById(currentId)?.scrollIntoView({
255
260
  behavior: "smooth",
@@ -259,46 +264,157 @@ var CommentsContainer = ({ threads, detached = [], currentId, autoFocusCurrentTe
259
264
  }, [
260
265
  currentId
261
266
  ]);
262
- return /* @__PURE__ */ import_react8.default.createElement(import_react8.default.Fragment, null, filteredThreads.length > 0 ? filteredThreads.map((thread) => /* @__PURE__ */ import_react8.default.createElement(CommentContainer, {
263
- key: thread.id,
264
- thread,
265
- current: currentId === thread.id,
266
- detached: detached.includes(thread.id),
267
- autoFocusTextbox: autoFocusCurrentTextbox && currentId === thread.id,
268
- ...onThreadAttend && {
269
- onAttend: () => onThreadAttend(thread)
270
- },
271
- ...onThreadDelete && {
272
- onThreadDelete: () => onThreadDelete(thread)
273
- },
274
- ...onMessageDelete && {
275
- onMessageDelete: (messageId) => onMessageDelete(thread, messageId)
276
- },
277
- ...onThreadToggleResolved && {
278
- onResolve: () => onThreadToggleResolved(thread)
279
- },
280
- ...props
281
- })) : /* @__PURE__ */ import_react8.default.createElement("div", {
267
+ return /* @__PURE__ */ import_react7.default.createElement(import_react7.default.Fragment, null, filteredThreads.length > 0 ? filteredThreads.map((thread) => {
268
+ const threadId = (0, import_echo3.fullyQualifiedId)(thread);
269
+ return /* @__PURE__ */ import_react7.default.createElement(CommentContainer, {
270
+ key: threadId,
271
+ thread,
272
+ current: currentId === threadId,
273
+ detached: detached.includes(threadId),
274
+ autoFocusTextbox: autoFocusCurrentTextbox && currentId === threadId,
275
+ ...onThreadAttend && {
276
+ onAttend: () => onThreadAttend(thread)
277
+ },
278
+ ...onThreadDelete && {
279
+ onThreadDelete: () => onThreadDelete(thread)
280
+ },
281
+ ...onMessageDelete && {
282
+ onMessageDelete: (messageId) => onMessageDelete(thread, messageId)
283
+ },
284
+ ...onThreadToggleResolved && {
285
+ onResolve: () => onThreadToggleResolved(thread)
286
+ },
287
+ ...props
288
+ });
289
+ }) : /* @__PURE__ */ import_react7.default.createElement("div", {
282
290
  role: "alert",
283
291
  className: (0, import_react_ui_theme2.mx)(import_react_ui_theme2.descriptionText, "place-self-center border border-dashed border-neutral-400/50 rounded-lg text-center p-4 m-4")
284
- }, /* @__PURE__ */ import_react8.default.createElement("h2", {
292
+ }, /* @__PURE__ */ import_react7.default.createElement("h2", {
285
293
  className: "mbe-2 font-medium text-baseText"
286
- }, t("no comments title")), /* @__PURE__ */ import_react8.default.createElement("p", null, /* @__PURE__ */ import_react8.default.createElement(import_react_ui4.Trans, {
294
+ }, t("no comments title")), /* @__PURE__ */ import_react7.default.createElement("p", null, /* @__PURE__ */ import_react7.default.createElement(import_react_ui3.Trans, {
287
295
  t,
288
296
  i18nKey: "no comments message",
289
297
  components: {
290
- commentIcon: /* @__PURE__ */ import_react8.default.createElement(import_react7.ChatText, {
298
+ commentIcon: /* @__PURE__ */ import_react7.default.createElement(import_react6.ChatText, {
291
299
  className: "inline-block"
292
300
  })
293
301
  }
294
302
  }))));
295
303
  };
296
- var ThreadMain = import_react3.default.lazy(() => import("./ThreadMain-XJX75GHG.cjs"));
297
- var ThreadArticle = import_react3.default.lazy(() => import("./ThreadArticle-DO56JXBU.cjs"));
304
+ var ThreadMain = import_react2.default.lazy(() => import("./ThreadMain-6DN7FDNB.cjs"));
305
+ var ThreadArticle = import_react2.default.lazy(() => import("./ThreadArticle-ERUHPHVT.cjs"));
306
+ var providesThreadsConfig = (plugin) => "thread" in plugin.provides ? plugin : void 0;
307
+ var ThreadComplementary = ({ role, subject, stagedThreads, current, focus, showResolvedThreads }) => {
308
+ const dispatch = (0, import_app_framework2.useIntentDispatcher)();
309
+ const threadsIntegrators = (0, import_app_framework2.useResolvePlugins)(providesThreadsConfig);
310
+ const threadProvides = (0, import_react8.useMemo)(() => threadsIntegrators.map((p) => p.provides.thread), [
311
+ threadsIntegrators
312
+ ]);
313
+ const createSort = (0, import_react8.useMemo)(() => threadProvides.find((p) => p.predicate(subject))?.createSort, [
314
+ threadProvides,
315
+ subject
316
+ ]);
317
+ const sort = (0, import_react8.useMemo)(() => createSort?.(subject), [
318
+ createSort,
319
+ subject
320
+ ]);
321
+ const threads = (0, import_react8.useMemo)(() => {
322
+ return subject.threads.concat(stagedThreads ?? []).filter(import_util3.nonNullable);
323
+ }, [
324
+ JSON.stringify(subject.threads),
325
+ JSON.stringify(stagedThreads)
326
+ ]);
327
+ const detachedIds = (0, import_react8.useMemo)(() => {
328
+ return threads.filter(({ anchor }) => !anchor).map((thread) => (0, import_echo4.fullyQualifiedId)(thread));
329
+ }, [
330
+ threads
331
+ ]);
332
+ (0, import_react8.useEffect)(() => {
333
+ if (!sort) {
334
+ return;
335
+ }
336
+ threads.sort((a, b) => sort(a?.anchor, b?.anchor));
337
+ }, [
338
+ sort,
339
+ threads
340
+ ]);
341
+ const { attended } = (0, import_react_ui_attention.useAttentionContext)("Thread Complementary");
342
+ const qualifiedSubjectId = (0, import_echo4.fullyQualifiedId)(subject);
343
+ const attendableAttrs = (0, import_react_ui_attention.createAttendableAttributes)(qualifiedSubjectId);
344
+ return /* @__PURE__ */ import_react8.default.createElement("div", {
345
+ role: "none",
346
+ className: "contents group/attention",
347
+ ...attendableAttrs
348
+ }, role === "complementary" && /* @__PURE__ */ import_react8.default.createElement(CommentsHeading, {
349
+ attendableId: qualifiedSubjectId
350
+ }), /* @__PURE__ */ import_react8.default.createElement(import_react_ui4.ScrollArea.Root, {
351
+ classNames: "row-span-2"
352
+ }, /* @__PURE__ */ import_react8.default.createElement(import_react_ui4.ScrollArea.Viewport, null, /* @__PURE__ */ import_react8.default.createElement(CommentsContainer, {
353
+ threads,
354
+ detached: detachedIds,
355
+ currentId: attended.has(qualifiedSubjectId) ? current : void 0,
356
+ autoFocusCurrentTextbox: focus,
357
+ showResolvedThreads,
358
+ onThreadAttend: (thread) => {
359
+ const threadId = (0, import_echo4.fullyQualifiedId)(thread);
360
+ if (current !== threadId) {
361
+ current = threadId;
362
+ void dispatch?.([
363
+ {
364
+ action: import_app_framework2.LayoutAction.SCROLL_INTO_VIEW,
365
+ data: {
366
+ id: (0, import_echo4.fullyQualifiedId)(subject),
367
+ thread: threadId,
368
+ cursor: thread.anchor
369
+ }
370
+ }
371
+ ]);
372
+ }
373
+ },
374
+ onThreadDelete: (thread) => {
375
+ return dispatch({
376
+ plugin: import_chunk_6EVXCSDS.THREAD_PLUGIN,
377
+ action: import_chunk_FXD3DYMO.ThreadAction.DELETE,
378
+ data: {
379
+ subject,
380
+ thread
381
+ }
382
+ });
383
+ },
384
+ onMessageDelete: (thread, messageId) => dispatch({
385
+ plugin: import_chunk_6EVXCSDS.THREAD_PLUGIN,
386
+ action: import_chunk_FXD3DYMO.ThreadAction.DELETE_MESSAGE,
387
+ data: {
388
+ subject,
389
+ thread,
390
+ messageId
391
+ }
392
+ }),
393
+ onThreadToggleResolved: (thread) => dispatch({
394
+ plugin: import_chunk_6EVXCSDS.THREAD_PLUGIN,
395
+ action: import_chunk_FXD3DYMO.ThreadAction.TOGGLE_RESOLVED,
396
+ data: {
397
+ thread
398
+ }
399
+ }),
400
+ onComment: (thread) => {
401
+ void dispatch({
402
+ action: import_chunk_FXD3DYMO.ThreadAction.ON_MESSAGE_ADD,
403
+ data: {
404
+ thread,
405
+ subject
406
+ }
407
+ });
408
+ }
409
+ }), /* @__PURE__ */ import_react8.default.createElement("div", {
410
+ role: "none",
411
+ className: "bs-10"
412
+ }), /* @__PURE__ */ import_react8.default.createElement(import_react_ui4.ScrollArea.Scrollbar, null, /* @__PURE__ */ import_react8.default.createElement(import_react_ui4.ScrollArea.Thumb, null)))));
413
+ };
298
414
  var translations_default = [
299
415
  {
300
416
  "en-US": {
301
- [import_chunk_BWBONZGU.THREAD_PLUGIN]: {
417
+ [import_chunk_6EVXCSDS.THREAD_PLUGIN]: {
302
418
  "plugin name": "Threads",
303
419
  "channel name placeholder": "New channel",
304
420
  "channel title label": "Title",
@@ -329,12 +445,12 @@ var translations_default = [
329
445
  }
330
446
  }
331
447
  ];
448
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-thread/src/ThreadPlugin.tsx";
332
449
  var initialViewState = {
333
450
  showResolvedThreads: false
334
451
  };
335
- var providesThreadsConfig = (plugin) => "thread" in plugin.provides ? plugin : void 0;
336
452
  var ThreadPlugin = () => {
337
- const settings = new import_local_storage.LocalStorageStore(import_chunk_BWBONZGU.THREAD_PLUGIN);
453
+ const settings = new import_local_storage.LocalStorageStore(import_chunk_6EVXCSDS.THREAD_PLUGIN);
338
454
  const state = (0, import_echo_schema2.create)({
339
455
  staging: {}
340
456
  });
@@ -347,13 +463,11 @@ var ThreadPlugin = () => {
347
463
  }
348
464
  return viewStore[subjectId];
349
465
  };
350
- let attentionPlugin;
351
466
  let navigationPlugin;
352
467
  let intentPlugin;
353
- let dispatch;
354
468
  const unsubscribeCallbacks = [];
355
469
  return {
356
- meta: import_chunk_BWBONZGU.meta_default,
470
+ meta: import_chunk_6EVXCSDS.meta_default,
357
471
  ready: async (plugins) => {
358
472
  settings.prop({
359
473
  key: "standalone",
@@ -361,36 +475,8 @@ var ThreadPlugin = () => {
361
475
  allowUndefined: true
362
476
  })
363
477
  });
364
- attentionPlugin = (0, import_app_framework.resolvePlugin)(plugins, import_plugin_attention.parseAttentionPlugin);
365
478
  navigationPlugin = (0, import_app_framework.resolvePlugin)(plugins, import_app_framework.parseNavigationPlugin);
366
479
  intentPlugin = (0, import_app_framework.resolvePlugin)(plugins, import_app_framework.parseIntentPlugin);
367
- dispatch = intentPlugin?.provides.intent.dispatch;
368
- const graphPlugin = (0, import_app_framework.resolvePlugin)(plugins, import_app_framework.parseGraphPlugin);
369
- const client = (0, import_app_framework.resolvePlugin)(plugins, import_plugin_client.parseClientPlugin)?.provides.client;
370
- if (!client) {
371
- return;
372
- }
373
- const channelsQuery = client.spaces.query(import_echo.Filter.schema(import_types2.ChannelType));
374
- const queryUnsubscribe = channelsQuery.subscribe();
375
- const unsubscribe = (0, import_signals_core.effect)(() => {
376
- const attention = attentionPlugin?.provides.attention;
377
- if (!attention?.attended) {
378
- return;
379
- }
380
- const firstAttendedNodeWithComments = Array.from(attention.attended).map((id) => graphPlugin?.provides.graph.findNode(id)).find((node) => node?.data instanceof import_types.DocumentType && (node.data.threads?.length ?? 0) > 0);
381
- if (firstAttendedNodeWithComments) {
382
- void intentPlugin?.provides.intent.dispatch({
383
- action: import_app_framework.NavigationAction.OPEN,
384
- data: {
385
- activeParts: {
386
- complementary: `${firstAttendedNodeWithComments.id}${import_app_framework.SLUG_PATH_SEPARATOR}comments`
387
- }
388
- }
389
- });
390
- }
391
- });
392
- unsubscribeCallbacks.push(queryUnsubscribe);
393
- unsubscribeCallbacks.push(unsubscribe);
394
480
  },
395
481
  unload: async () => {
396
482
  unsubscribeCallbacks.forEach((unsubscribe) => unsubscribe());
@@ -399,27 +485,26 @@ var ThreadPlugin = () => {
399
485
  settings: settings.values,
400
486
  metadata: {
401
487
  records: {
402
- [import_types2.ChannelType.typename]: {
488
+ [import_types.ChannelType.typename]: {
403
489
  placeholder: [
404
490
  "channel title placeholder",
405
491
  {
406
- ns: import_chunk_BWBONZGU.THREAD_PLUGIN
492
+ ns: import_chunk_6EVXCSDS.THREAD_PLUGIN
407
493
  }
408
494
  ],
409
- icon: (props) => /* @__PURE__ */ import_react2.default.createElement(import_react.Chat, props),
410
- iconSymbol: "ph--chat--regular",
495
+ icon: "ph--chat--regular",
411
496
  // TODO(wittjosiah): Move out of metadata.
412
497
  loadReferences: (channel) => (0, import_echo.loadObjectReferences)(channel, (channel2) => channel2.threads)
413
498
  },
414
- [import_types2.ThreadType.typename]: {
499
+ [import_types.ThreadType.typename]: {
415
500
  // TODO(wittjosiah): Move out of metadata.
416
501
  loadReferences: (thread) => (0, import_echo.loadObjectReferences)(thread, (thread2) => thread2.messages)
417
502
  },
418
- [import_types2.MessageType.typename]: {
503
+ [import_types.MessageType.typename]: {
419
504
  // TODO(wittjosiah): Move out of metadata.
420
505
  loadReferences: (message) => []
421
506
  },
422
- [import_chunk_BWBONZGU.THREAD_ITEM]: {
507
+ [import_chunk_6EVXCSDS.THREAD_ITEM]: {
423
508
  parse: (item, type) => {
424
509
  switch (type) {
425
510
  case "node":
@@ -446,47 +531,53 @@ var ThreadPlugin = () => {
446
531
  ],
447
532
  echo: {
448
533
  schema: [
449
- import_types2.ChannelType,
450
- import_types2.ThreadType,
451
- import_types2.MessageType
534
+ import_types.ChannelType,
535
+ import_types.ThreadType,
536
+ import_types.MessageType
452
537
  ]
453
538
  },
454
539
  graph: {
455
540
  builder: (plugins) => {
456
541
  const client = (0, import_app_framework.resolvePlugin)(plugins, import_plugin_client.parseClientPlugin)?.provides.client;
457
- const dispatch2 = (0, import_app_framework.resolvePlugin)(plugins, import_app_framework.parseIntentPlugin)?.provides.intent.dispatch;
542
+ const dispatch = (0, import_app_framework.resolvePlugin)(plugins, import_app_framework.parseIntentPlugin)?.provides.intent.dispatch;
458
543
  const metadataResolver = (0, import_app_framework.resolvePlugin)(plugins, import_app_framework.parseMetadataResolverPlugin)?.provides.metadata.resolver;
459
- if (!client || !dispatch2 || !metadataResolver) {
544
+ if (!client || !dispatch || !metadataResolver) {
460
545
  return [];
461
546
  }
462
547
  return [
463
548
  (0, import_plugin_graph.createExtension)({
464
- id: `${import_chunk_BWBONZGU.THREAD_PLUGIN}/comments-for-subject`,
549
+ id: `${import_chunk_6EVXCSDS.THREAD_PLUGIN}/comments-for-subject`,
465
550
  resolver: ({ id }) => {
466
551
  if (!id.endsWith("~comments")) {
467
552
  return;
468
553
  }
469
- const docId = id.split("~").at(0);
470
- const [spaceId, objectId] = docId?.split(":") ?? [];
554
+ const subjectId = id.split("~").at(0);
555
+ const [spaceId, objectId] = subjectId?.split(":") ?? [];
471
556
  const space = client.spaces.get().find((space2) => space2.id === spaceId);
472
- const doc = space?.db.getObjectById(objectId);
473
- if (!doc || !docId) {
557
+ const object = (0, import_plugin_graph.toSignal)((onChange) => {
558
+ const timeout = setTimeout(async () => {
559
+ await space?.db.loadObjectById(objectId);
560
+ onChange();
561
+ });
562
+ return () => clearTimeout(timeout);
563
+ }, () => space?.db.getObjectById(objectId));
564
+ if (!object || !subjectId) {
474
565
  return;
475
566
  }
476
- const docMeta = metadataResolver((0, import_echo_schema.getTypename)(doc) ?? "");
477
- const label = docMeta.label?.(doc) || doc.name || docMeta.placeholder || [
567
+ const meta = metadataResolver((0, import_echo_schema.getTypename)(object) ?? "");
568
+ const label = meta.label?.(object) || object.name || meta.placeholder || [
478
569
  "unnamed object threads label",
479
570
  {
480
- ns: import_chunk_BWBONZGU.THREAD_PLUGIN
571
+ ns: import_chunk_6EVXCSDS.THREAD_PLUGIN
481
572
  }
482
573
  ];
483
- const viewState = getViewState(docId);
574
+ const viewState = getViewState(subjectId);
484
575
  return {
485
576
  id,
486
577
  type: "orphan-comments-for-subject",
487
- data: doc,
578
+ data: object,
488
579
  properties: {
489
- icon: import_chunk_BWBONZGU.meta_default.iconComponent,
580
+ icon: meta.icon,
490
581
  label,
491
582
  showResolvedThreads: viewState.showResolvedThreads
492
583
  }
@@ -502,7 +593,7 @@ var ThreadPlugin = () => {
502
593
  const toggle = () => {
503
594
  const newToggleState = !viewState.showResolvedThreads;
504
595
  viewState.showResolvedThreads = newToggleState;
505
- void dispatch2({
596
+ void dispatch({
506
597
  action: import_meta.ObservabilityAction.SEND_EVENT,
507
598
  data: {
508
599
  name: "threads.toggle-show-resolved",
@@ -516,25 +607,26 @@ var ThreadPlugin = () => {
516
607
  };
517
608
  return [
518
609
  {
519
- id: `${import_chunk_BWBONZGU.THREAD_PLUGIN}/toggle-show-resolved/${node.id}`,
610
+ id: `${import_chunk_6EVXCSDS.THREAD_PLUGIN}/toggle-show-resolved/${node.id}`,
520
611
  data: toggle,
521
612
  properties: {
522
613
  label: [
523
614
  "toggle show resolved",
524
615
  {
525
- ns: import_chunk_BWBONZGU.THREAD_PLUGIN
616
+ ns: import_chunk_6EVXCSDS.THREAD_PLUGIN
526
617
  }
527
618
  ],
528
619
  menuItemType: "toggle",
529
620
  isChecked: viewState.showResolvedThreads,
530
- testId: "threadPlugin.toggleShowResolved"
621
+ testId: "threadPlugin.toggleShowResolved",
622
+ icon: viewState.showResolvedThreads ? "ph--eye-slash--regular" : "ph--eye--regular"
531
623
  }
532
624
  }
533
625
  ];
534
626
  }
535
627
  }),
536
628
  (0, import_plugin_graph.createExtension)({
537
- id: import_chunk_D5GOVXHS.ThreadAction.CREATE,
629
+ id: import_chunk_FXD3DYMO.ThreadAction.CREATE,
538
630
  filter: (node) => !!settings.values.standalone && (0, import_plugin_graph.isActionGroup)(node) && node.id.startsWith(import_plugin_space.SpaceAction.ADD_OBJECT),
539
631
  actions: ({ node }) => {
540
632
  const id = node.id.split("/").at(-1);
@@ -547,12 +639,12 @@ var ThreadPlugin = () => {
547
639
  }
548
640
  return [
549
641
  {
550
- id: `${import_chunk_BWBONZGU.THREAD_PLUGIN}/create/${node.id}`,
642
+ id: `${import_chunk_6EVXCSDS.THREAD_PLUGIN}/create/${node.id}`,
551
643
  data: async () => {
552
- await dispatch2([
644
+ await dispatch([
553
645
  {
554
- plugin: import_chunk_BWBONZGU.THREAD_PLUGIN,
555
- action: import_chunk_D5GOVXHS.ThreadAction.CREATE
646
+ plugin: import_chunk_6EVXCSDS.THREAD_PLUGIN,
647
+ action: import_chunk_FXD3DYMO.ThreadAction.CREATE
556
648
  },
557
649
  {
558
650
  action: import_plugin_space.SpaceAction.ADD_OBJECT,
@@ -569,11 +661,10 @@ var ThreadPlugin = () => {
569
661
  label: [
570
662
  "create channel label",
571
663
  {
572
- ns: import_chunk_BWBONZGU.THREAD_PLUGIN
664
+ ns: import_chunk_6EVXCSDS.THREAD_PLUGIN
573
665
  }
574
666
  ],
575
- icon: (props) => /* @__PURE__ */ import_react2.default.createElement(import_react.Chat, props),
576
- iconSymbol: "ph--chat--regular",
667
+ icon: "ph--chat--regular",
577
668
  testId: "threadPlugin.createObject"
578
669
  }
579
670
  }
@@ -587,21 +678,19 @@ var ThreadPlugin = () => {
587
678
  component: ({ data, role }) => {
588
679
  switch (role) {
589
680
  case "main": {
590
- return data.active instanceof import_types2.ChannelType && data.active.threads[0] ? /* @__PURE__ */ import_react2.default.createElement(ThreadMain, {
681
+ return data.active instanceof import_types.ChannelType && data.active.threads[0] ? /* @__PURE__ */ import_react.default.createElement(ThreadMain, {
591
682
  thread: data.active.threads[0]
592
683
  }) : null;
593
684
  }
594
685
  case "settings": {
595
- return data.plugin === import_chunk_BWBONZGU.meta_default.id ? /* @__PURE__ */ import_react2.default.createElement(ThreadSettings, {
686
+ return data.plugin === import_chunk_6EVXCSDS.meta_default.id ? /* @__PURE__ */ import_react.default.createElement(ThreadSettings, {
596
687
  settings: settings.values
597
688
  }) : null;
598
689
  }
599
690
  case "article":
600
691
  case "complementary": {
601
692
  const location = navigationPlugin?.provides.location;
602
- const threadsIntegrators = (0, import_app_framework.useResolvePlugins)(providesThreadsConfig);
603
- const threadProvides = threadsIntegrators.map((p) => p.provides.thread);
604
- if (data.object instanceof import_types2.ChannelType && data.object.threads[0]) {
693
+ if (data.object instanceof import_types.ChannelType && data.object.threads[0]) {
605
694
  const channel = data.object;
606
695
  if ((0, import_app_framework.isLayoutParts)(location?.active) && location.active.main) {
607
696
  const layoutEntries = location.active.main;
@@ -609,101 +698,33 @@ var ThreadPlugin = () => {
609
698
  if (currentPosition > 0) {
610
699
  const objectToTheLeft = layoutEntries[currentPosition - 1];
611
700
  const context = (0, import_echo.getSpace)(data.object)?.db.getObjectById(objectToTheLeft.id);
612
- return /* @__PURE__ */ import_react2.default.createElement(ThreadArticle, {
701
+ return /* @__PURE__ */ import_react.default.createElement(ThreadArticle, {
613
702
  thread: data.object.threads[0],
614
703
  context
615
704
  });
616
705
  }
617
706
  }
618
- return /* @__PURE__ */ import_react2.default.createElement(ThreadArticle, {
707
+ return /* @__PURE__ */ import_react.default.createElement(ThreadArticle, {
619
708
  thread: data.object.threads[0]
620
709
  });
621
710
  }
622
- if (data.subject instanceof import_types2.ThreadType) {
623
- return /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, /* @__PURE__ */ import_react2.default.createElement(import_chunk_5PZNPPQF.ChatHeading, {
711
+ if (data.subject instanceof import_types.ThreadType) {
712
+ return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(import_chunk_PZVUW4W2.ChatHeading, {
624
713
  attendableId: data.subject.id
625
- }), /* @__PURE__ */ import_react2.default.createElement(import_chunk_5PZNPPQF.ChatContainer, {
714
+ }), /* @__PURE__ */ import_react.default.createElement(import_chunk_PZVUW4W2.ChatContainer, {
626
715
  thread: data.subject
627
716
  }));
628
717
  }
629
718
  if (data.subject && typeof data.subject === "object" && "threads" in data.subject && Array.isArray(data.subject.threads)) {
630
- const threads = data.subject.threads.concat(state.staging[(0, import_echo.fullyQualifiedId)(data.subject)]).filter(import_util.nonNullable);
631
- const createSort = threadProvides.find((p) => p.predicate(data.subject))?.createSort;
632
- if (createSort) {
633
- const sort = createSort(data.subject);
634
- threads.sort((a, b) => sort(a.anchor, b.anchor));
635
- }
636
- const detached = data.subject.threads.filter(import_util.nonNullable).filter(({ anchor }) => !anchor).map((thread) => thread.id);
637
- const qualifiedSubjectId = (0, import_echo.fullyQualifiedId)(data.subject);
638
- const attention = attentionPlugin?.provides.attention?.attended ?? /* @__PURE__ */ new Set([
639
- qualifiedSubjectId
640
- ]);
641
- const attendableAttrs = (0, import_react_ui_attention.createAttendableAttributes)(qualifiedSubjectId);
642
- const { showResolvedThreads } = getViewState(qualifiedSubjectId);
643
- return /* @__PURE__ */ import_react2.default.createElement("div", {
644
- role: "none",
645
- className: "contents group/attention",
646
- ...attendableAttrs
647
- }, role === "complementary" && /* @__PURE__ */ import_react2.default.createElement(CommentsHeading, {
648
- attendableId: qualifiedSubjectId
649
- }), /* @__PURE__ */ import_react2.default.createElement(import_react_ui.ScrollArea.Root, {
650
- classNames: "row-span-2"
651
- }, /* @__PURE__ */ import_react2.default.createElement(import_react_ui.ScrollArea.Viewport, null, /* @__PURE__ */ import_react2.default.createElement(CommentsContainer, {
652
- threads,
653
- detached,
654
- currentId: attention.has(qualifiedSubjectId) ? state.current : void 0,
655
- autoFocusCurrentTextbox: state.focus,
656
- showResolvedThreads,
657
- onThreadAttend: (thread) => {
658
- if (state.current !== thread.id) {
659
- state.current = thread.id;
660
- void dispatch?.({
661
- action: import_app_framework.LayoutAction.SCROLL_INTO_VIEW,
662
- data: {
663
- id: (0, import_echo.fullyQualifiedId)(data.subject),
664
- thread: (0, import_echo.fullyQualifiedId)(thread),
665
- cursor: thread.anchor
666
- }
667
- });
668
- }
669
- },
670
- onThreadDelete: (thread) => dispatch?.({
671
- plugin: import_chunk_BWBONZGU.THREAD_PLUGIN,
672
- action: import_chunk_D5GOVXHS.ThreadAction.DELETE,
673
- data: {
674
- subject: data.subject,
675
- thread
676
- }
677
- }),
678
- onMessageDelete: (thread, messageId) => dispatch?.({
679
- plugin: import_chunk_BWBONZGU.THREAD_PLUGIN,
680
- action: import_chunk_D5GOVXHS.ThreadAction.DELETE_MESSAGE,
681
- data: {
682
- subject: data.subject,
683
- thread,
684
- messageId
685
- }
686
- }),
687
- onThreadToggleResolved: (thread) => dispatch?.({
688
- plugin: import_chunk_BWBONZGU.THREAD_PLUGIN,
689
- action: import_chunk_D5GOVXHS.ThreadAction.TOGGLE_RESOLVED,
690
- data: {
691
- thread
692
- }
693
- }),
694
- onComment: (thread) => {
695
- void intentPlugin?.provides.intent.dispatch({
696
- action: import_chunk_D5GOVXHS.ThreadAction.ON_MESSAGE_ADD,
697
- data: {
698
- thread,
699
- subject: data.subject
700
- }
701
- });
702
- }
703
- }), /* @__PURE__ */ import_react2.default.createElement("div", {
704
- role: "none",
705
- className: "bs-10"
706
- }), /* @__PURE__ */ import_react2.default.createElement(import_react_ui.ScrollArea.Scrollbar, null, /* @__PURE__ */ import_react2.default.createElement(import_react_ui.ScrollArea.Thumb, null)))));
719
+ const { showResolvedThreads } = getViewState((0, import_echo.fullyQualifiedId)(data.subject));
720
+ return /* @__PURE__ */ import_react.default.createElement(ThreadComplementary, {
721
+ role,
722
+ subject: data.subject,
723
+ stagedThreads: state.staging[(0, import_echo.fullyQualifiedId)(data.subject)],
724
+ current: state.current,
725
+ focus: true,
726
+ showResolvedThreads
727
+ });
707
728
  }
708
729
  }
709
730
  }
@@ -713,11 +734,24 @@ var ThreadPlugin = () => {
713
734
  intent: {
714
735
  resolver: async (intent) => {
715
736
  switch (intent.action) {
716
- case import_chunk_D5GOVXHS.ThreadAction.CREATE: {
737
+ case import_chunk_FXD3DYMO.ThreadAction.CREATE: {
717
738
  if (intent.data && intent.data.cursor !== void 0) {
718
739
  const { cursor, name, subject } = intent.data;
740
+ if (subject?.threads === void 0) {
741
+ try {
742
+ subject.threads = [];
743
+ } catch (e) {
744
+ import_log.log.error("Subject does not support threads array", subject?.typename, {
745
+ F: __dxlog_file,
746
+ L: 331,
747
+ S: void 0,
748
+ C: (f, a) => f(...a)
749
+ });
750
+ return;
751
+ }
752
+ }
719
753
  const subjectId = (0, import_echo.fullyQualifiedId)(subject);
720
- const thread = (0, import_echo_schema2.create)(import_types2.ThreadType, {
754
+ const thread = (0, import_echo_schema2.create)(import_types.ThreadType, {
721
755
  name,
722
756
  anchor: cursor,
723
757
  messages: [],
@@ -736,17 +770,9 @@ var ThreadPlugin = () => {
736
770
  intents: [
737
771
  [
738
772
  {
739
- action: import_app_framework.NavigationAction.OPEN,
740
- data: {
741
- activeParts: {
742
- complementary: `${subjectId}${import_app_framework.SLUG_PATH_SEPARATOR}comments${import_app_framework.SLUG_COLLECTION_INDICATOR}`
743
- }
744
- }
745
- },
746
- {
747
- action: import_chunk_D5GOVXHS.ThreadAction.SELECT,
773
+ action: import_chunk_FXD3DYMO.ThreadAction.SELECT,
748
774
  data: {
749
- current: thread.id,
775
+ current: (0, import_echo.fullyQualifiedId)(thread),
750
776
  focus: true
751
777
  }
752
778
  },
@@ -763,9 +789,9 @@ var ThreadPlugin = () => {
763
789
  };
764
790
  } else {
765
791
  return {
766
- data: (0, import_echo_schema2.create)(import_types2.ChannelType, {
792
+ data: (0, import_echo_schema2.create)(import_types.ChannelType, {
767
793
  threads: [
768
- (0, import_echo_schema2.create)(import_types2.ThreadType, {
794
+ (0, import_echo_schema2.create)(import_types.ThreadType, {
769
795
  messages: []
770
796
  })
771
797
  ]
@@ -773,16 +799,16 @@ var ThreadPlugin = () => {
773
799
  };
774
800
  }
775
801
  }
776
- case import_chunk_D5GOVXHS.ThreadAction.SELECT: {
802
+ case import_chunk_FXD3DYMO.ThreadAction.SELECT: {
777
803
  state.focus = intent.data?.current === state.current ? state.focus : intent.data?.focus;
778
804
  state.current = intent.data?.current;
779
805
  return {
780
806
  data: true
781
807
  };
782
808
  }
783
- case import_chunk_D5GOVXHS.ThreadAction.TOGGLE_RESOLVED: {
809
+ case import_chunk_FXD3DYMO.ThreadAction.TOGGLE_RESOLVED: {
784
810
  const { thread } = intent.data ?? {};
785
- if (!(thread instanceof import_types2.ThreadType)) {
811
+ if (!(thread instanceof import_types.ThreadType)) {
786
812
  return;
787
813
  }
788
814
  if (thread.status === "active" || thread.status === void 0) {
@@ -809,9 +835,9 @@ var ThreadPlugin = () => {
809
835
  ]
810
836
  };
811
837
  }
812
- case import_chunk_D5GOVXHS.ThreadAction.DELETE: {
838
+ case import_chunk_FXD3DYMO.ThreadAction.DELETE: {
813
839
  const { subject, thread } = intent.data ?? {};
814
- if (!(subject instanceof import_types.DocumentType) || !(thread instanceof import_types2.ThreadType)) {
840
+ if (!(thread instanceof import_types.ThreadType) || !(subject && typeof subject === "object" && "threads" in subject)) {
815
841
  return;
816
842
  }
817
843
  const subjectId = (0, import_echo.fullyQualifiedId)(subject);
@@ -820,7 +846,9 @@ var ThreadPlugin = () => {
820
846
  const index = stagingArea.findIndex((t) => t.id === thread.id);
821
847
  if (index !== -1) {
822
848
  stagingArea.splice(index, 1);
823
- return;
849
+ return {
850
+ data: true
851
+ };
824
852
  }
825
853
  }
826
854
  const space = (0, import_echo.getSpace)(thread);
@@ -836,7 +864,7 @@ var ThreadPlugin = () => {
836
864
  space.db.remove(thread);
837
865
  return {
838
866
  undoable: {
839
- message: translations_default[0]["en-US"][import_chunk_BWBONZGU.THREAD_PLUGIN]["thread deleted label"],
867
+ message: translations_default[0]["en-US"][import_chunk_6EVXCSDS.THREAD_PLUGIN]["thread deleted label"],
840
868
  data: {
841
869
  cursor
842
870
  }
@@ -879,9 +907,9 @@ var ThreadPlugin = () => {
879
907
  }
880
908
  break;
881
909
  }
882
- case import_chunk_D5GOVXHS.ThreadAction.ON_MESSAGE_ADD: {
910
+ case import_chunk_FXD3DYMO.ThreadAction.ON_MESSAGE_ADD: {
883
911
  const { thread, subject } = intent.data ?? {};
884
- if (!(thread instanceof import_types2.ThreadType) || !(subject && typeof subject === "object" && "threads" in subject)) {
912
+ if (!(thread instanceof import_types.ThreadType) || !(subject && typeof subject === "object" && "threads" in subject && Array.isArray(subject.threads))) {
885
913
  return;
886
914
  }
887
915
  const subjectId = (0, import_echo.fullyQualifiedId)(subject);
@@ -922,10 +950,10 @@ var ThreadPlugin = () => {
922
950
  ]
923
951
  };
924
952
  }
925
- case import_chunk_D5GOVXHS.ThreadAction.DELETE_MESSAGE: {
953
+ case import_chunk_FXD3DYMO.ThreadAction.DELETE_MESSAGE: {
926
954
  const { subject, thread, messageId } = intent.data ?? {};
927
955
  const space = (0, import_echo.getSpace)(subject);
928
- if (!(subject instanceof import_types.DocumentType) || !(thread instanceof import_types2.ThreadType) || !space) {
956
+ if (!(thread instanceof import_types.ThreadType) || !(subject && typeof subject === "object" && "threads" in subject)) {
929
957
  return;
930
958
  }
931
959
  if (!intent.undo) {
@@ -939,7 +967,7 @@ var ThreadPlugin = () => {
939
967
  intents: [
940
968
  [
941
969
  {
942
- action: import_chunk_D5GOVXHS.ThreadAction.DELETE,
970
+ action: import_chunk_FXD3DYMO.ThreadAction.DELETE,
943
971
  data: {
944
972
  subject,
945
973
  thread
@@ -953,7 +981,7 @@ var ThreadPlugin = () => {
953
981
  }
954
982
  return {
955
983
  undoable: {
956
- message: translations_default[0]["en-US"][import_chunk_BWBONZGU.THREAD_PLUGIN]["message deleted label"],
984
+ message: translations_default[0]["en-US"][import_chunk_6EVXCSDS.THREAD_PLUGIN]["message deleted label"],
957
985
  data: {
958
986
  message,
959
987
  messageIndex
@@ -967,7 +995,7 @@ var ThreadPlugin = () => {
967
995
  name: "threads.message.delete",
968
996
  properties: {
969
997
  threadId: thread.id,
970
- spaceId: space.id
998
+ spaceId: space?.id
971
999
  }
972
1000
  }
973
1001
  }
@@ -977,7 +1005,7 @@ var ThreadPlugin = () => {
977
1005
  } else if (intent.undo) {
978
1006
  const message = intent.data?.message;
979
1007
  const messageIndex = intent.data?.messageIndex;
980
- if (!(message instanceof import_types2.MessageType) || !(typeof messageIndex === "number")) {
1008
+ if (!(message instanceof import_types.MessageType) || !(typeof messageIndex === "number")) {
981
1009
  return;
982
1010
  }
983
1011
  thread.messages.splice(messageIndex, 0, message);
@@ -991,7 +1019,7 @@ var ThreadPlugin = () => {
991
1019
  name: "threads.message.undo-delete",
992
1020
  properties: {
993
1021
  threadId: thread.id,
994
- spaceId: space.id
1022
+ spaceId: space?.id
995
1023
  }
996
1024
  }
997
1025
  }
@@ -1033,7 +1061,7 @@ var ThreadPlugin = () => {
1033
1061
  }
1034
1062
  }),
1035
1063
  (0, import_react_ui_editor.createExternalCommentSync)(doc.id, (sink) => (0, import_signals_core.effect)(() => sink()), () => threads.value.filter((thread) => thread?.anchor).map((thread) => ({
1036
- id: thread.id,
1064
+ id: (0, import_echo.fullyQualifiedId)(thread),
1037
1065
  cursor: thread.anchor
1038
1066
  }))),
1039
1067
  (0, import_react_ui_editor.comments)({
@@ -1044,7 +1072,7 @@ var ThreadPlugin = () => {
1044
1072
  "content"
1045
1073
  ]), start, end);
1046
1074
  void intentPlugin?.provides.intent.dispatch({
1047
- action: import_chunk_D5GOVXHS.ThreadAction.CREATE,
1075
+ action: import_chunk_FXD3DYMO.ThreadAction.CREATE,
1048
1076
  data: {
1049
1077
  cursor,
1050
1078
  name,
@@ -1055,7 +1083,7 @@ var ThreadPlugin = () => {
1055
1083
  onDelete: ({ id }) => {
1056
1084
  const stagingArea = state.staging[(0, import_echo.fullyQualifiedId)(doc)];
1057
1085
  if (stagingArea) {
1058
- const index = stagingArea.findIndex((thread2) => thread2.id === id);
1086
+ const index = stagingArea.findIndex((thread2) => (0, import_echo.fullyQualifiedId)(thread2) === id);
1059
1087
  if (index !== -1) {
1060
1088
  stagingArea.splice(index, 1);
1061
1089
  }
@@ -1066,8 +1094,8 @@ var ThreadPlugin = () => {
1066
1094
  }
1067
1095
  },
1068
1096
  onUpdate: ({ id, cursor }) => {
1069
- const thread = state.staging[(0, import_echo.fullyQualifiedId)(doc)]?.find((thread2) => thread2.id === id) ?? doc.threads.find((thread2) => thread2?.id === id);
1070
- if (thread instanceof import_types2.ThreadType && thread.anchor) {
1097
+ const thread = state.staging[(0, import_echo.fullyQualifiedId)(doc)]?.find((thread2) => (0, import_echo.fullyQualifiedId)(thread2) === id) ?? doc.threads.find((thread2) => thread2?.id === id);
1098
+ if (thread instanceof import_types.ThreadType && thread.anchor) {
1071
1099
  const [start, end] = thread.anchor.split(":");
1072
1100
  thread.name = doc.content && (0, import_echo.getTextInRange)((0, import_echo.createDocAccessor)(doc.content, [
1073
1101
  "content"
@@ -1076,11 +1104,11 @@ var ThreadPlugin = () => {
1076
1104
  }
1077
1105
  },
1078
1106
  onSelect: ({ selection: { current, closest } }) => {
1079
- const dispatch2 = intentPlugin?.provides.intent.dispatch;
1080
- if (dispatch2) {
1081
- void dispatch2([
1107
+ const dispatch = intentPlugin?.provides.intent.dispatch;
1108
+ if (dispatch) {
1109
+ void dispatch([
1082
1110
  {
1083
- action: import_chunk_D5GOVXHS.ThreadAction.SELECT,
1111
+ action: import_chunk_FXD3DYMO.ThreadAction.SELECT,
1084
1112
  data: {
1085
1113
  current: current ?? closest
1086
1114
  }