@dxos/plugin-thread 0.7.5-main.9d2a38b → 0.7.5-main.b19bfc8
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.
- package/dist/lib/browser/{ThreadContainer-4VLBSBI7.mjs → ThreadContainer-6OP5AG2W.mjs} +2 -2
- package/dist/lib/browser/chunk-MDOPJ2AL.mjs +15 -0
- package/dist/lib/browser/chunk-MDOPJ2AL.mjs.map +7 -0
- package/dist/lib/browser/{chunk-GQONSZ3J.mjs → chunk-UPKU23DA.mjs} +11 -23
- package/dist/lib/browser/chunk-UPKU23DA.mjs.map +7 -0
- package/dist/lib/browser/{chunk-NO5AZLUZ.mjs → chunk-YK3ICB7G.mjs} +2 -4
- package/dist/lib/browser/{chunk-NO5AZLUZ.mjs.map → chunk-YK3ICB7G.mjs.map} +3 -3
- package/dist/lib/browser/index.mjs +41 -46
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/intent-resolver-FAFQ54NP.mjs +287 -0
- package/dist/lib/browser/intent-resolver-FAFQ54NP.mjs.map +7 -0
- package/dist/lib/browser/{markdown-2NBXKXCY.mjs → markdown-RPYOUBVR.mjs} +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-CHCZO4TI.mjs → react-surface-KXXLCZMW.mjs} +42 -47
- package/dist/lib/browser/react-surface-KXXLCZMW.mjs.map +7 -0
- package/dist/lib/browser/{settings-TKOPRXSU.mjs → settings-WQTE5AEZ.mjs} +2 -2
- package/dist/lib/browser/types.mjs +1 -1
- package/dist/lib/node/{ThreadContainer-VOYLV4UL.cjs → ThreadContainer-LTKKLPXX.cjs} +6 -6
- package/dist/lib/node/{chunk-ZRN7B26W.cjs → chunk-BT24JUE3.cjs} +8 -13
- package/dist/lib/node/chunk-BT24JUE3.cjs.map +7 -0
- package/dist/lib/node/{chunk-AUVKOX5Q.cjs → chunk-CMEMMYDL.cjs} +5 -7
- package/dist/lib/node/{chunk-AUVKOX5Q.cjs.map → chunk-CMEMMYDL.cjs.map} +3 -3
- package/dist/lib/node/{chunk-6PUGKCPR.cjs → chunk-RQR5Z23G.cjs} +13 -24
- package/dist/lib/node/chunk-RQR5Z23G.cjs.map +7 -0
- package/dist/lib/node/index.cjs +42 -45
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/intent-resolver-DVBEXJ33.cjs +299 -0
- package/dist/lib/node/intent-resolver-DVBEXJ33.cjs.map +7 -0
- package/dist/lib/node/{markdown-FWRKMSKV.cjs → markdown-ELRGISXE.cjs} +7 -7
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/{react-surface-LO7S2HPR.cjs → react-surface-H5PDWLPO.cjs} +44 -49
- package/dist/lib/node/react-surface-H5PDWLPO.cjs.map +7 -0
- package/dist/lib/node/{settings-TH4YSUVU.cjs → settings-7VQYARM5.cjs} +6 -6
- package/dist/lib/node/types.cjs +3 -3
- package/dist/lib/node/types.cjs.map +1 -1
- package/dist/lib/node-esm/{ThreadContainer-7DZY2MWA.mjs → ThreadContainer-SV74JFRH.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-B3CF35MY.mjs → chunk-33NDMQQQ.mjs} +2 -4
- package/dist/lib/node-esm/{chunk-B3CF35MY.mjs.map → chunk-33NDMQQQ.mjs.map} +3 -3
- package/dist/lib/node-esm/{chunk-DYFIKKDT.mjs → chunk-CISLDOH7.mjs} +11 -23
- package/dist/lib/node-esm/chunk-CISLDOH7.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-UNLSWYA4.mjs +17 -0
- package/dist/lib/node-esm/chunk-UNLSWYA4.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +41 -46
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/intent-resolver-DHVLBNCC.mjs +288 -0
- package/dist/lib/node-esm/intent-resolver-DHVLBNCC.mjs.map +7 -0
- package/dist/lib/node-esm/{markdown-6AQFDAW3.mjs → markdown-23OB7EZG.mjs} +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-LAF3QIPB.mjs → react-surface-SNZ44ZXI.mjs} +42 -47
- package/dist/lib/node-esm/react-surface-SNZ44ZXI.mjs.map +7 -0
- package/dist/lib/node-esm/{settings-KEDRR7RM.mjs → settings-SGMM7UDT.mjs} +2 -2
- package/dist/lib/node-esm/types.mjs +1 -1
- package/dist/types/src/ThreadPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +7 -184
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/markdown.d.ts +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/state.d.ts +1 -1
- package/dist/types/src/components/Chat.stories.d.ts.map +1 -1
- package/dist/types/src/components/ChatContainer.d.ts +2 -3
- package/dist/types/src/components/ChatContainer.d.ts.map +1 -1
- package/dist/types/src/components/CommentContainer.d.ts +1 -2
- package/dist/types/src/components/CommentContainer.d.ts.map +1 -1
- package/dist/types/src/components/CommentsContainer.d.ts +1 -2
- package/dist/types/src/components/CommentsContainer.d.ts.map +1 -1
- package/dist/types/src/components/MessageContainer.d.ts +1 -2
- package/dist/types/src/components/MessageContainer.d.ts.map +1 -1
- package/dist/types/src/components/ThreadComplementary.d.ts +1 -2
- package/dist/types/src/components/ThreadComplementary.d.ts.map +1 -1
- package/dist/types/src/components/ThreadContainer.d.ts +2 -2
- package/dist/types/src/components/ThreadContainer.d.ts.map +1 -1
- package/dist/types/src/components/ThreadSettings.d.ts +1 -2
- package/dist/types/src/components/ThreadSettings.d.ts.map +1 -1
- package/dist/types/src/components/command-extension.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/components/testing.d.ts +12 -12
- package/dist/types/src/components/testing.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +0 -3
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +5 -7
- package/dist/types/src/types.d.ts.map +1 -1
- package/package.json +30 -30
- package/src/ThreadPlugin.tsx +45 -50
- package/src/capabilities/index.ts +0 -1
- package/src/capabilities/intent-resolver.ts +180 -164
- package/src/capabilities/react-surface.tsx +18 -18
- package/src/components/Chat.stories.tsx +1 -5
- package/src/components/ChatContainer.tsx +2 -2
- package/src/components/CommentContainer.tsx +2 -2
- package/src/components/Comments.stories.tsx +1 -1
- package/src/components/MessageContainer.tsx +6 -19
- package/src/components/ThreadComplementary.tsx +9 -6
- package/src/components/ThreadSettings.tsx +5 -11
- package/src/components/command-extension.ts +2 -5
- package/src/translations.ts +0 -1
- package/src/types.ts +1 -5
- package/dist/lib/browser/app-graph-builder-Q7A2ZRUA.mjs +0 -121
- package/dist/lib/browser/app-graph-builder-Q7A2ZRUA.mjs.map +0 -7
- package/dist/lib/browser/chunk-2B3EXYZ7.mjs +0 -18
- package/dist/lib/browser/chunk-2B3EXYZ7.mjs.map +0 -7
- package/dist/lib/browser/chunk-GQONSZ3J.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-PIEZ3LKQ.mjs +0 -275
- package/dist/lib/browser/intent-resolver-PIEZ3LKQ.mjs.map +0 -7
- package/dist/lib/browser/react-surface-CHCZO4TI.mjs.map +0 -7
- package/dist/lib/node/app-graph-builder-ZXW5KUDK.cjs +0 -135
- package/dist/lib/node/app-graph-builder-ZXW5KUDK.cjs.map +0 -7
- package/dist/lib/node/chunk-6PUGKCPR.cjs.map +0 -7
- package/dist/lib/node/chunk-ZRN7B26W.cjs.map +0 -7
- package/dist/lib/node/intent-resolver-X5O3SVLF.cjs +0 -287
- package/dist/lib/node/intent-resolver-X5O3SVLF.cjs.map +0 -7
- package/dist/lib/node/react-surface-LO7S2HPR.cjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-ATS6HGE6.mjs +0 -122
- package/dist/lib/node-esm/app-graph-builder-ATS6HGE6.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-DYFIKKDT.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-GS2OILYF.mjs +0 -20
- package/dist/lib/node-esm/chunk-GS2OILYF.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-XJWT5X6T.mjs +0 -276
- package/dist/lib/node-esm/intent-resolver-XJWT5X6T.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-LAF3QIPB.mjs.map +0 -7
- package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -180
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
- package/src/capabilities/app-graph-builder.ts +0 -120
- /package/dist/lib/browser/{ThreadContainer-4VLBSBI7.mjs.map → ThreadContainer-6OP5AG2W.mjs.map} +0 -0
- /package/dist/lib/browser/{markdown-2NBXKXCY.mjs.map → markdown-RPYOUBVR.mjs.map} +0 -0
- /package/dist/lib/browser/{settings-TKOPRXSU.mjs.map → settings-WQTE5AEZ.mjs.map} +0 -0
- /package/dist/lib/node/{ThreadContainer-VOYLV4UL.cjs.map → ThreadContainer-LTKKLPXX.cjs.map} +0 -0
- /package/dist/lib/node/{markdown-FWRKMSKV.cjs.map → markdown-ELRGISXE.cjs.map} +0 -0
- /package/dist/lib/node/{settings-TH4YSUVU.cjs.map → settings-7VQYARM5.cjs.map} +0 -0
- /package/dist/lib/node-esm/{ThreadContainer-7DZY2MWA.mjs.map → ThreadContainer-SV74JFRH.mjs.map} +0 -0
- /package/dist/lib/node-esm/{markdown-6AQFDAW3.mjs.map → markdown-23OB7EZG.mjs.map} +0 -0
- /package/dist/lib/node-esm/{settings-KEDRR7RM.mjs.map → settings-SGMM7UDT.mjs.map} +0 -0
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
createIntent,
|
|
9
9
|
createResolver,
|
|
10
10
|
LayoutAction,
|
|
11
|
-
NavigationAction,
|
|
12
11
|
type PluginsContext,
|
|
13
12
|
} from '@dxos/app-framework';
|
|
14
13
|
import { Ref } from '@dxos/echo-schema';
|
|
@@ -23,201 +22,218 @@ import { ThreadAction } from '../types';
|
|
|
23
22
|
|
|
24
23
|
export default (context: PluginsContext) =>
|
|
25
24
|
contributes(Capabilities.IntentResolver, [
|
|
26
|
-
createResolver(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if (
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
25
|
+
createResolver({
|
|
26
|
+
intent: ThreadAction.Create,
|
|
27
|
+
resolve: ({ name, cursor, subject }) => {
|
|
28
|
+
if (cursor && subject) {
|
|
29
|
+
// Seed the threads array if it does not exist.
|
|
30
|
+
if (subject?.threads === undefined) {
|
|
31
|
+
try {
|
|
32
|
+
// Static schema will throw an error if subject does not support threads array property.
|
|
33
|
+
subject.threads = [];
|
|
34
|
+
} catch (err) {
|
|
35
|
+
log.error('Subject does not support threads array', { typename: subject?.typename });
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
36
38
|
}
|
|
37
|
-
}
|
|
38
39
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
const { state } = context.requestCapability(ThreadCapabilities.MutableState);
|
|
41
|
+
const subjectId = fullyQualifiedId(subject);
|
|
42
|
+
const thread = create(ThreadType, { name, anchor: cursor, messages: [], status: 'staged' });
|
|
43
|
+
const draft = state.drafts[subjectId];
|
|
44
|
+
if (draft) {
|
|
45
|
+
draft.push(thread);
|
|
46
|
+
} else {
|
|
47
|
+
state.drafts[subjectId] = [thread];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
data: { object: thread },
|
|
52
|
+
intents: [
|
|
53
|
+
createIntent(ThreadAction.Select, { current: fullyQualifiedId(thread) }),
|
|
54
|
+
createIntent(LayoutAction.UpdateComplementary, { part: 'complementary', subject: 'comments' }),
|
|
55
|
+
],
|
|
56
|
+
};
|
|
45
57
|
} else {
|
|
46
|
-
|
|
58
|
+
// TODO(wittjosiah): Create separate intent for channel creation.
|
|
59
|
+
return {
|
|
60
|
+
data: { object: create(ChannelType, { threads: [makeRef(create(ThreadType, { messages: [] }))] }) },
|
|
61
|
+
};
|
|
47
62
|
}
|
|
63
|
+
},
|
|
64
|
+
}),
|
|
65
|
+
createResolver({
|
|
66
|
+
intent: ThreadAction.Select,
|
|
67
|
+
resolve: ({ current, skipOpen }) => {
|
|
68
|
+
const { state } = context.requestCapability(ThreadCapabilities.MutableState);
|
|
69
|
+
state.current = current;
|
|
48
70
|
|
|
49
71
|
return {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
createIntent(NavigationAction.Open, { activeParts: { complementary: 'comments' } }),
|
|
54
|
-
createIntent(LayoutAction.SetLayout, { element: 'complementary', state: true }),
|
|
55
|
-
],
|
|
56
|
-
};
|
|
57
|
-
} else {
|
|
58
|
-
// NOTE: This is the standalone thread creation case.
|
|
59
|
-
return {
|
|
60
|
-
data: { object: create(ChannelType, { threads: [makeRef(create(ThreadType, { messages: [] }))] }) },
|
|
72
|
+
intents: !skipOpen
|
|
73
|
+
? [createIntent(LayoutAction.UpdateComplementary, { part: 'complementary', subject: 'comments' })]
|
|
74
|
+
: undefined,
|
|
61
75
|
};
|
|
62
|
-
}
|
|
63
|
-
}),
|
|
64
|
-
createResolver(ThreadAction.Select, ({ current, skipOpen }) => {
|
|
65
|
-
const { state } = context.requestCapability(ThreadCapabilities.MutableState);
|
|
66
|
-
state.current = current;
|
|
67
|
-
|
|
68
|
-
return {
|
|
69
|
-
intents: !skipOpen
|
|
70
|
-
? [createIntent(NavigationAction.Open, { activeParts: { complementary: 'comments' } })]
|
|
71
|
-
: undefined,
|
|
72
|
-
};
|
|
73
|
-
}),
|
|
74
|
-
createResolver(ThreadAction.ToggleResolved, ({ thread }) => {
|
|
75
|
-
if (thread.status === 'active' || thread.status === undefined) {
|
|
76
|
-
thread.status = 'resolved';
|
|
77
|
-
} else if (thread.status === 'resolved') {
|
|
78
|
-
thread.status = 'active';
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const space = getSpace(thread);
|
|
82
|
-
const spaceId = space?.id;
|
|
83
|
-
|
|
84
|
-
return {
|
|
85
|
-
intents: [
|
|
86
|
-
createIntent(ObservabilityAction.SendEvent, {
|
|
87
|
-
name: 'threads.toggle-resolved',
|
|
88
|
-
properties: { threadId: thread.id, spaceId },
|
|
89
|
-
}),
|
|
90
|
-
],
|
|
91
|
-
};
|
|
76
|
+
},
|
|
92
77
|
}),
|
|
93
|
-
createResolver(
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
if (index !== -1) {
|
|
101
|
-
draft.splice(index, 1);
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
const space = getSpace(thread);
|
|
107
|
-
if (!space || !subject.threads) {
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
if (!undo) {
|
|
112
|
-
const index = subject.threads.findIndex((t: any) => t?.id === thread.id);
|
|
113
|
-
const cursor = subject.threads[index]?.anchor;
|
|
114
|
-
if (index !== -1) {
|
|
115
|
-
subject.threads?.splice(index, 1);
|
|
78
|
+
createResolver({
|
|
79
|
+
intent: ThreadAction.ToggleResolved,
|
|
80
|
+
resolve: ({ thread }) => {
|
|
81
|
+
if (thread.status === 'active' || thread.status === undefined) {
|
|
82
|
+
thread.status = 'resolved';
|
|
83
|
+
} else if (thread.status === 'resolved') {
|
|
84
|
+
thread.status = 'active';
|
|
116
85
|
}
|
|
117
86
|
|
|
118
|
-
space
|
|
87
|
+
const space = getSpace(thread);
|
|
88
|
+
const spaceId = space?.id;
|
|
119
89
|
|
|
120
90
|
return {
|
|
121
|
-
undoable: {
|
|
122
|
-
message: ['thread deleted label', { ns: THREAD_PLUGIN }],
|
|
123
|
-
data: { cursor },
|
|
124
|
-
},
|
|
125
91
|
intents: [
|
|
126
92
|
createIntent(ObservabilityAction.SendEvent, {
|
|
127
|
-
name: 'threads.
|
|
128
|
-
properties: { threadId: thread.id, spaceId
|
|
93
|
+
name: 'threads.toggle-resolved',
|
|
94
|
+
properties: { threadId: thread.id, spaceId },
|
|
129
95
|
}),
|
|
130
96
|
],
|
|
131
97
|
};
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
98
|
+
},
|
|
99
|
+
}),
|
|
100
|
+
createResolver({
|
|
101
|
+
intent: ThreadAction.Delete,
|
|
102
|
+
resolve: ({ subject, thread }, undo) => {
|
|
103
|
+
const { state } = context.requestCapability(ThreadCapabilities.MutableState);
|
|
104
|
+
const subjectId = fullyQualifiedId(subject);
|
|
105
|
+
const draft = state.drafts[subjectId];
|
|
106
|
+
if (draft) {
|
|
107
|
+
// Check if we're deleting a draft; if so, remove it.
|
|
108
|
+
const index = draft.findIndex((t) => t.id === thread.id);
|
|
109
|
+
if (index !== -1) {
|
|
110
|
+
draft.splice(index, 1);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
136
114
|
|
|
137
|
-
|
|
138
|
-
|
|
115
|
+
const space = getSpace(thread);
|
|
116
|
+
if (!space || !subject.threads) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (!undo) {
|
|
121
|
+
const index = subject.threads.findIndex((t: any) => t?.id === thread.id);
|
|
122
|
+
const cursor = subject.threads[index]?.anchor;
|
|
123
|
+
if (index !== -1) {
|
|
124
|
+
subject.threads?.splice(index, 1);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
space.db.remove(thread);
|
|
128
|
+
|
|
129
|
+
return {
|
|
130
|
+
undoable: {
|
|
131
|
+
message: ['thread deleted label', { ns: THREAD_PLUGIN }],
|
|
132
|
+
data: { cursor },
|
|
133
|
+
},
|
|
134
|
+
intents: [
|
|
135
|
+
createIntent(ObservabilityAction.SendEvent, {
|
|
136
|
+
name: 'threads.delete',
|
|
137
|
+
properties: { threadId: thread.id, spaceId: space.id },
|
|
138
|
+
}),
|
|
139
|
+
],
|
|
140
|
+
};
|
|
141
|
+
} else {
|
|
142
|
+
// TODO(wittjosiah): SDK should do this automatically.
|
|
143
|
+
const savedThread = space.db.add(thread);
|
|
144
|
+
subject.threads.push(savedThread);
|
|
145
|
+
|
|
146
|
+
return {
|
|
147
|
+
intents: [
|
|
148
|
+
createIntent(ObservabilityAction.SendEvent, {
|
|
149
|
+
name: 'threads.undo-delete',
|
|
150
|
+
properties: { threadId: thread.id, spaceId: space.id },
|
|
151
|
+
}),
|
|
152
|
+
],
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
}),
|
|
157
|
+
createResolver({
|
|
158
|
+
intent: ThreadAction.OnMessageAdd,
|
|
159
|
+
resolve: ({ thread, subject }) => {
|
|
160
|
+
const { state } = context.requestCapability(ThreadCapabilities.MutableState);
|
|
161
|
+
const subjectId = fullyQualifiedId(subject);
|
|
162
|
+
const space = getSpace(subject);
|
|
163
|
+
const intents = [];
|
|
164
|
+
const analyticsProperties = { threadId: thread.id, spaceId: space?.id };
|
|
165
|
+
|
|
166
|
+
if (state.drafts[subjectId]?.find((t) => t === thread)) {
|
|
167
|
+
// Move draft to document.
|
|
168
|
+
thread.status = 'active';
|
|
169
|
+
subject.threads ? subject.threads.push(makeRef(thread)) : (subject.threads = [makeRef(thread)]);
|
|
170
|
+
state.drafts[subjectId] = state.drafts[subjectId]?.filter(({ id }) => id !== thread.id);
|
|
171
|
+
intents.push(
|
|
139
172
|
createIntent(ObservabilityAction.SendEvent, {
|
|
140
|
-
name: 'threads.
|
|
141
|
-
properties:
|
|
173
|
+
name: 'threads.thread-created',
|
|
174
|
+
properties: analyticsProperties,
|
|
142
175
|
}),
|
|
143
|
-
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
}),
|
|
147
|
-
createResolver(ThreadAction.OnMessageAdd, ({ thread, subject }) => {
|
|
148
|
-
const { state } = context.requestCapability(ThreadCapabilities.MutableState);
|
|
149
|
-
const subjectId = fullyQualifiedId(subject);
|
|
150
|
-
const space = getSpace(subject);
|
|
151
|
-
const intents = [];
|
|
152
|
-
const analyticsProperties = { threadId: thread.id, spaceId: space?.id };
|
|
153
|
-
|
|
154
|
-
if (state.drafts[subjectId]?.find((t) => t === thread)) {
|
|
155
|
-
// Move draft to document.
|
|
156
|
-
thread.status = 'active';
|
|
157
|
-
subject.threads ? subject.threads.push(makeRef(thread)) : (subject.threads = [makeRef(thread)]);
|
|
158
|
-
state.drafts[subjectId] = state.drafts[subjectId]?.filter(({ id }) => id !== thread.id);
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
|
|
159
179
|
intents.push(
|
|
160
180
|
createIntent(ObservabilityAction.SendEvent, {
|
|
161
|
-
name: 'threads.
|
|
162
|
-
properties: analyticsProperties,
|
|
181
|
+
name: 'threads.message-added',
|
|
182
|
+
properties: { ...analyticsProperties, threadLength: thread.messages.length },
|
|
163
183
|
}),
|
|
164
184
|
);
|
|
165
|
-
}
|
|
166
185
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
name: 'threads.message-added',
|
|
170
|
-
properties: { ...analyticsProperties, threadLength: thread.messages.length },
|
|
171
|
-
}),
|
|
172
|
-
);
|
|
173
|
-
|
|
174
|
-
return { intents };
|
|
186
|
+
return { intents };
|
|
187
|
+
},
|
|
175
188
|
}),
|
|
176
|
-
createResolver(
|
|
177
|
-
|
|
189
|
+
createResolver({
|
|
190
|
+
intent: ThreadAction.DeleteMessage,
|
|
191
|
+
resolve: ({ subject, thread, messageId, message, messageIndex }, undo) => {
|
|
192
|
+
const space = getSpace(subject);
|
|
193
|
+
|
|
194
|
+
if (!undo) {
|
|
195
|
+
const messageIndex = thread.messages.findIndex(Ref.hasObjectId(messageId));
|
|
196
|
+
const message = thread.messages[messageIndex]?.target;
|
|
197
|
+
if (!message) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
178
200
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
201
|
+
if (messageIndex === 0 && thread.messages.length === 1) {
|
|
202
|
+
// If the message is the only message in the thread, delete the thread.
|
|
203
|
+
return {
|
|
204
|
+
intents: [createIntent(ThreadAction.Delete, { subject, thread })],
|
|
205
|
+
};
|
|
206
|
+
} else {
|
|
207
|
+
thread.messages.splice(messageIndex, 1);
|
|
208
|
+
}
|
|
185
209
|
|
|
186
|
-
if (messageIndex === 0 && thread.messages.length === 1) {
|
|
187
|
-
// If the message is the only message in the thread, delete the thread.
|
|
188
210
|
return {
|
|
189
|
-
|
|
211
|
+
undoable: {
|
|
212
|
+
message: ['message deleted label', { ns: THREAD_PLUGIN }],
|
|
213
|
+
data: { message, messageIndex },
|
|
214
|
+
},
|
|
215
|
+
intents: [
|
|
216
|
+
createIntent(ObservabilityAction.SendEvent, {
|
|
217
|
+
name: 'threads.message.delete',
|
|
218
|
+
properties: { threadId: thread.id, spaceId: space?.id },
|
|
219
|
+
}),
|
|
220
|
+
],
|
|
190
221
|
};
|
|
191
222
|
} else {
|
|
192
|
-
|
|
193
|
-
|
|
223
|
+
if (!messageIndex || !message) {
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
194
226
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
}),
|
|
205
|
-
],
|
|
206
|
-
};
|
|
207
|
-
} else {
|
|
208
|
-
if (!messageIndex || !message) {
|
|
209
|
-
return;
|
|
227
|
+
thread.messages.splice(messageIndex, 0, makeRef(message));
|
|
228
|
+
return {
|
|
229
|
+
intents: [
|
|
230
|
+
createIntent(ObservabilityAction.SendEvent, {
|
|
231
|
+
name: 'threads.message.undo-delete',
|
|
232
|
+
properties: { threadId: thread.id, spaceId: space?.id },
|
|
233
|
+
}),
|
|
234
|
+
],
|
|
235
|
+
};
|
|
210
236
|
}
|
|
211
|
-
|
|
212
|
-
thread.messages.splice(messageIndex, 0, makeRef(message));
|
|
213
|
-
return {
|
|
214
|
-
intents: [
|
|
215
|
-
createIntent(ObservabilityAction.SendEvent, {
|
|
216
|
-
name: 'threads.message.undo-delete',
|
|
217
|
-
properties: { threadId: thread.id, spaceId: space?.id },
|
|
218
|
-
}),
|
|
219
|
-
],
|
|
220
|
-
};
|
|
221
|
-
}
|
|
237
|
+
},
|
|
222
238
|
}),
|
|
223
239
|
]);
|
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
|
-
import { Capabilities, contributes, createSurface,
|
|
7
|
+
import { Capabilities, contributes, createSurface, useLayout } from '@dxos/app-framework';
|
|
8
8
|
import { type Ref } from '@dxos/echo-schema';
|
|
9
|
+
import { SettingsStore } from '@dxos/local-storage';
|
|
9
10
|
import { ChannelType, type ThreadType } from '@dxos/plugin-space/types';
|
|
10
11
|
import { getSpace } from '@dxos/react-client/echo';
|
|
11
12
|
|
|
@@ -21,18 +22,19 @@ export default () =>
|
|
|
21
22
|
filter: (data): data is { subject: ChannelType } =>
|
|
22
23
|
data.subject instanceof ChannelType && !!data.subject.threads[0],
|
|
23
24
|
component: ({ data, role }) => {
|
|
24
|
-
const
|
|
25
|
+
const layout = useLayout();
|
|
25
26
|
const channel = data.subject;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
27
|
+
void channel.threads[0].load();
|
|
28
|
+
const thread = channel.threads[0].target;
|
|
29
|
+
if (!thread) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const currentPosition = layout.active.findIndex((id) => id === channel.id);
|
|
34
|
+
if (currentPosition > 0) {
|
|
35
|
+
const objectToTheLeft = layout.active[currentPosition - 1];
|
|
36
|
+
const context = getSpace(channel)?.db.getObjectById(objectToTheLeft);
|
|
37
|
+
return <ThreadContainer role={role} thread={thread} context={context} />;
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
return <ThreadContainer role={role} thread={thread} />;
|
|
@@ -51,11 +53,9 @@ export default () =>
|
|
|
51
53
|
}),
|
|
52
54
|
createSurface({
|
|
53
55
|
id: `${THREAD_PLUGIN}/settings`,
|
|
54
|
-
role: '
|
|
55
|
-
filter: (data): data is
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return <ThreadSettings settings={settings} />;
|
|
59
|
-
},
|
|
56
|
+
role: 'article',
|
|
57
|
+
filter: (data): data is { subject: SettingsStore<ThreadSettingsProps> } =>
|
|
58
|
+
data.subject instanceof SettingsStore && data.subject.prefix === THREAD_PLUGIN,
|
|
59
|
+
component: ({ data: { subject } }) => <ThreadSettings settings={subject.value} />,
|
|
60
60
|
}),
|
|
61
61
|
]);
|
|
@@ -15,7 +15,6 @@ import { useClient } from '@dxos/react-client';
|
|
|
15
15
|
import { type Space } from '@dxos/react-client/echo';
|
|
16
16
|
import { useIdentity } from '@dxos/react-client/halo';
|
|
17
17
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
18
|
-
import { Mosaic } from '@dxos/react-ui-mosaic';
|
|
19
18
|
import { Thread } from '@dxos/react-ui-thread';
|
|
20
19
|
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
21
20
|
|
|
@@ -47,10 +46,7 @@ const Story = () => {
|
|
|
47
46
|
}
|
|
48
47
|
|
|
49
48
|
return (
|
|
50
|
-
<
|
|
51
|
-
<main className='max-is-prose mli-auto bs-dvh overflow-hidden'>{space && <ChatContainer thread={thread} />}</main>
|
|
52
|
-
<Mosaic.DragOverlay />
|
|
53
|
-
</Mosaic.Root>
|
|
49
|
+
<main className='max-is-prose mli-auto bs-dvh overflow-hidden'>{space && <ChatContainer thread={thread} />}</main>
|
|
54
50
|
);
|
|
55
51
|
};
|
|
56
52
|
|
|
@@ -7,7 +7,7 @@ import React, { useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
|
7
7
|
import { Ref } from '@dxos/echo-schema';
|
|
8
8
|
import { create, makeRef, RefArray } from '@dxos/live-object';
|
|
9
9
|
import { MessageType } from '@dxos/plugin-space/types';
|
|
10
|
-
import { fullyQualifiedId, getSpace, useMembers
|
|
10
|
+
import { fullyQualifiedId, getSpace, useMembers } from '@dxos/react-client/echo';
|
|
11
11
|
import { useIdentity } from '@dxos/react-client/halo';
|
|
12
12
|
import { Icon, ScrollArea, useThemeContext, useTranslation } from '@dxos/react-ui';
|
|
13
13
|
import { createBasicExtensions, createThemeExtensions, listener } from '@dxos/react-ui-editor';
|
|
@@ -82,7 +82,7 @@ export const ChatContainer = ({ thread, context, current, autoFocusTextbox }: Th
|
|
|
82
82
|
sender: { identityKey: identity.identityKey.toHex() },
|
|
83
83
|
timestamp: new Date().toISOString(),
|
|
84
84
|
text: messageRef.current,
|
|
85
|
-
context: makeRef(context
|
|
85
|
+
context: context ? makeRef(context) : undefined,
|
|
86
86
|
}),
|
|
87
87
|
),
|
|
88
88
|
);
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
mx,
|
|
19
19
|
} from '@dxos/react-ui-theme';
|
|
20
20
|
import { MessageTextbox, type MessageTextboxProps, Thread, ThreadFooter, ThreadHeading } from '@dxos/react-ui-thread';
|
|
21
|
-
import {
|
|
21
|
+
import { isNonNullable } from '@dxos/util';
|
|
22
22
|
|
|
23
23
|
import { MessageContainer } from './MessageContainer';
|
|
24
24
|
import { command } from './command-extension';
|
|
@@ -179,7 +179,7 @@ export const CommentContainer = ({
|
|
|
179
179
|
</div>
|
|
180
180
|
</div>
|
|
181
181
|
{/** TODO(dmaretskyi): How's `thread.messages` undefined? */}
|
|
182
|
-
{RefArray.allResolvedTargets(thread.messages?.filter(
|
|
182
|
+
{RefArray.allResolvedTargets(thread.messages?.filter(isNonNullable) ?? []).map((message) => (
|
|
183
183
|
<MessageContainer key={message.id} message={message} members={members} onDelete={handleMessageDelete} />
|
|
184
184
|
))}
|
|
185
185
|
{/*
|
|
@@ -44,7 +44,7 @@ const Story = ({ spaceKey }: ClientRepeatedComponentProps) => {
|
|
|
44
44
|
|
|
45
45
|
return (
|
|
46
46
|
<div className='flex justify-center overflow-y-auto bg-white dark:bg-black'>
|
|
47
|
-
<div className='flex flex-col w-[
|
|
47
|
+
<div className='flex flex-col w-[30rem]'>
|
|
48
48
|
<CommentsContainer threads={threads} detached={detached} onThreadDelete={console.log} />
|
|
49
49
|
</div>
|
|
50
50
|
</div>
|
|
@@ -14,7 +14,6 @@ import { type ReactiveEchoObject, type Expando, type SpaceMember } from '@dxos/r
|
|
|
14
14
|
import { useIdentity, type Identity } from '@dxos/react-client/halo';
|
|
15
15
|
import { Button, ButtonGroup, Tooltip, useOnTransition, useThemeContext, useTranslation } from '@dxos/react-ui';
|
|
16
16
|
import { createBasicExtensions, createThemeExtensions, useTextEditor } from '@dxos/react-ui-editor';
|
|
17
|
-
import { Mosaic, type MosaicTileComponent } from '@dxos/react-ui-mosaic';
|
|
18
17
|
import {
|
|
19
18
|
getSize,
|
|
20
19
|
hoverableControlItem,
|
|
@@ -26,7 +25,7 @@ import { MessageHeading, MessageRoot } from '@dxos/react-ui-thread';
|
|
|
26
25
|
|
|
27
26
|
import { command } from './command-extension';
|
|
28
27
|
import { useOnEditAnalytics } from '../hooks';
|
|
29
|
-
import {
|
|
28
|
+
import { THREAD_PLUGIN } from '../meta';
|
|
30
29
|
import { getMessageMetadata } from '../util';
|
|
31
30
|
|
|
32
31
|
// TODO(thure): #8149
|
|
@@ -109,11 +108,7 @@ export const MessageContainer = ({
|
|
|
109
108
|
};
|
|
110
109
|
|
|
111
110
|
const MessagePart = ({ part }: { part: Expando }) => {
|
|
112
|
-
return
|
|
113
|
-
<Mosaic.Container id={part.id}>
|
|
114
|
-
<Mosaic.DraggableTile type={THREAD_ITEM} path={part.id} item={part} Component={MessageBlockObjectTile} />
|
|
115
|
-
</Mosaic.Container>
|
|
116
|
-
);
|
|
111
|
+
return <MessageBlockObjectTile subject={part} />;
|
|
117
112
|
};
|
|
118
113
|
|
|
119
114
|
const TextboxBlock = ({
|
|
@@ -165,9 +160,9 @@ const TextboxBlock = ({
|
|
|
165
160
|
return <div role='none' ref={parentRef} className='mie-4' {...focusAttributes} />;
|
|
166
161
|
};
|
|
167
162
|
|
|
168
|
-
const MessageBlockObjectTile:
|
|
169
|
-
({
|
|
170
|
-
let title =
|
|
163
|
+
const MessageBlockObjectTile = forwardRef<HTMLDivElement, { subject: ReactiveEchoObject<any> }>(
|
|
164
|
+
({ subject }, forwardedRef) => {
|
|
165
|
+
let title = subject.name ?? subject.title ?? subject.type ?? 'Object';
|
|
171
166
|
if (typeof title !== 'string') {
|
|
172
167
|
title = title?.content ?? '';
|
|
173
168
|
}
|
|
@@ -176,17 +171,9 @@ const MessageBlockObjectTile: MosaicTileComponent<ReactiveEchoObject<any>> = for
|
|
|
176
171
|
<div
|
|
177
172
|
role='group'
|
|
178
173
|
className={mx('grid col-span-3 py-1 pr-4', hoverableControls, hoverableFocusedWithinControls)}
|
|
179
|
-
style={draggableStyle}
|
|
180
174
|
ref={forwardedRef}
|
|
181
175
|
>
|
|
182
|
-
<Surface
|
|
183
|
-
role='card'
|
|
184
|
-
limit={1}
|
|
185
|
-
data={{ subject: item }}
|
|
186
|
-
draggableProps={draggableProps}
|
|
187
|
-
fallback={title}
|
|
188
|
-
{...props}
|
|
189
|
-
/>
|
|
176
|
+
<Surface role='card' limit={1} data={{ subject }} fallback={title} />
|
|
190
177
|
</div>
|
|
191
178
|
);
|
|
192
179
|
},
|
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { useCallback, useEffect, useMemo } from 'react';
|
|
6
6
|
|
|
7
|
-
import { createIntent, LayoutAction,
|
|
7
|
+
import { createIntent, LayoutAction, useCapability, useCapabilities, useIntentDispatcher } from '@dxos/app-framework';
|
|
8
8
|
import { ThreadCapabilities } from '@dxos/plugin-space';
|
|
9
9
|
import { MessageType, type ThreadType } from '@dxos/plugin-space/types';
|
|
10
10
|
import { create, fullyQualifiedId, makeRef, RefArray } from '@dxos/react-client/echo';
|
|
11
11
|
import { useIdentity } from '@dxos/react-client/halo';
|
|
12
12
|
import { useAttended } from '@dxos/react-ui-attention';
|
|
13
|
-
import {
|
|
13
|
+
import { isNonNullable } from '@dxos/util';
|
|
14
14
|
|
|
15
15
|
import { ThreadCapabilities as LocalThreadCapabilities } from '../capabilities';
|
|
16
16
|
import { CommentsContainer } from '../components';
|
|
@@ -34,7 +34,7 @@ export const ThreadComplementary = ({ subject }: { subject: any }) => {
|
|
|
34
34
|
const threadObjects = RefArray.allResolvedTargets(subject.threads ?? []);
|
|
35
35
|
|
|
36
36
|
const threads = useMemo(() => {
|
|
37
|
-
return threadObjects.concat(drafts ?? []).filter(
|
|
37
|
+
return threadObjects.concat(drafts ?? []).filter(isNonNullable) as ThreadType[];
|
|
38
38
|
}, [JSON.stringify(threadObjects), JSON.stringify(drafts)]);
|
|
39
39
|
|
|
40
40
|
const detachedIds = useMemo(() => {
|
|
@@ -62,9 +62,12 @@ export const ThreadComplementary = ({ subject }: { subject: any }) => {
|
|
|
62
62
|
// This may be overloading this intent or highjacking its intended purpose.
|
|
63
63
|
void dispatch(
|
|
64
64
|
createIntent(LayoutAction.ScrollIntoView, {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
part: 'current',
|
|
66
|
+
subject: fullyQualifiedId(subject),
|
|
67
|
+
options: {
|
|
68
|
+
cursor: thread.anchor,
|
|
69
|
+
ref: threadId,
|
|
70
|
+
},
|
|
68
71
|
}),
|
|
69
72
|
);
|
|
70
73
|
}
|
|
@@ -4,20 +4,14 @@
|
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
// import { useTranslation } from '@dxos/react-ui';
|
|
8
|
+
import { DeprecatedFormContainer } from '@dxos/react-ui-form';
|
|
9
9
|
|
|
10
|
-
import { THREAD_PLUGIN } from '../meta';
|
|
10
|
+
// import { THREAD_PLUGIN } from '../meta';
|
|
11
11
|
import type { ThreadSettingsProps } from '../types';
|
|
12
12
|
|
|
13
13
|
export const ThreadSettings = ({ settings }: { settings: ThreadSettingsProps }) => {
|
|
14
|
-
const { t } = useTranslation(THREAD_PLUGIN);
|
|
14
|
+
// const { t } = useTranslation(THREAD_PLUGIN);
|
|
15
15
|
|
|
16
|
-
return
|
|
17
|
-
<>
|
|
18
|
-
<DeprecatedFormInput label={t('settings standalone label')}>
|
|
19
|
-
<Input.Switch checked={settings.standalone} onCheckedChange={(checked) => (settings.standalone = !!checked)} />
|
|
20
|
-
</DeprecatedFormInput>
|
|
21
|
-
</>
|
|
22
|
-
);
|
|
16
|
+
return <DeprecatedFormContainer></DeprecatedFormContainer>;
|
|
23
17
|
};
|