@dxos/plugin-search 0.8.2-staging.7ac8446 → 0.8.2
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/app-graph-builder-NZN3MIDZ.mjs +77 -0
- package/dist/lib/browser/app-graph-builder-NZN3MIDZ.mjs.map +7 -0
- package/dist/lib/browser/{chunk-J6YWSQTW.mjs → chunk-ARZYMSFF.mjs} +3 -3
- package/dist/lib/browser/{chunk-J6YWSQTW.mjs.map → chunk-ARZYMSFF.mjs.map} +1 -1
- package/dist/lib/browser/{chunk-NFZSXZMP.mjs → chunk-CKQAVN5U.mjs} +23 -17
- package/dist/lib/browser/chunk-CKQAVN5U.mjs.map +7 -0
- package/dist/lib/browser/{chunk-LXHJVTYG.mjs → chunk-VMEXQBHE.mjs} +7 -7
- package/dist/lib/browser/chunk-VMEXQBHE.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +6 -6
- package/dist/lib/browser/{intent-resolver-G76A35DX.mjs → intent-resolver-RWC63UGI.mjs} +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-QBBLEI2Q.mjs → react-surface-UJOSZGP5.mjs} +293 -258
- package/dist/lib/browser/react-surface-UJOSZGP5.mjs.map +7 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts +2 -179
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +1 -177
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/components/SearchDialog.d.ts.map +1 -1
- package/dist/types/src/components/SearchResults/SearchResults.d.ts.map +1 -1
- package/dist/types/src/components/Searchbar/Searchbar.d.ts.map +1 -1
- package/dist/types/src/hooks/sync.d.ts.map +1 -1
- package/dist/types/src/hooks/useGlobalSearch.d.ts.map +1 -1
- package/dist/types/src/hooks/useSearchResults.d.ts.map +1 -1
- package/dist/types/src/hooks/useWebSearch.d.ts +1 -1
- package/dist/types/src/hooks/useWebSearch.d.ts.map +1 -1
- package/dist/types/src/search/exa.d.ts +4 -4
- package/dist/types/src/search/exa.d.ts.map +1 -1
- package/dist/types/src/types/action.d.ts +5 -5
- package/dist/types/src/types/action.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +35 -28
- package/src/capabilities/app-graph-builder.ts +59 -41
- package/src/capabilities/react-surface.tsx +4 -7
- package/src/components/SearchDialog.tsx +8 -7
- package/src/components/SearchMain.tsx +4 -4
- package/src/components/SearchResults/SearchResults.tsx +1 -1
- package/src/components/Searchbar/Searchbar.tsx +2 -2
- package/src/hooks/sync.test.ts +4 -4
- package/src/hooks/sync.ts +8 -7
- package/src/hooks/useSearchResults.ts +2 -2
- package/src/hooks/useWebSearch.ts +6 -8
- package/src/meta.ts +2 -2
- package/src/search/exa.test.ts +7 -8
- package/src/search/exa.ts +32 -26
- package/src/types/action.tsx +4 -4
- package/dist/lib/browser/app-graph-builder-RHZORTY2.mjs +0 -76
- package/dist/lib/browser/app-graph-builder-RHZORTY2.mjs.map +0 -7
- package/dist/lib/browser/chunk-LXHJVTYG.mjs.map +0 -7
- package/dist/lib/browser/chunk-NFZSXZMP.mjs.map +0 -7
- package/dist/lib/browser/react-surface-QBBLEI2Q.mjs.map +0 -7
- /package/dist/lib/browser/{intent-resolver-G76A35DX.mjs.map → intent-resolver-RWC63UGI.mjs.map} +0 -0
|
@@ -4,151 +4,173 @@ import {
|
|
|
4
4
|
useGlobalSearch,
|
|
5
5
|
useGlobalSearchResults,
|
|
6
6
|
useSearchResults
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-CKQAVN5U.mjs";
|
|
8
8
|
import {
|
|
9
9
|
SEARCH_PLUGIN,
|
|
10
10
|
SEARCH_RESULT
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-ARZYMSFF.mjs";
|
|
12
12
|
|
|
13
13
|
// packages/plugins/plugin-search/src/capabilities/react-surface.tsx
|
|
14
14
|
import React5 from "react";
|
|
15
|
-
import { Capabilities, contributes, createSurface
|
|
16
|
-
import {
|
|
15
|
+
import { Capabilities, contributes, createSurface } from "@dxos/app-framework";
|
|
16
|
+
import { useActiveSpace } from "@dxos/plugin-space";
|
|
17
17
|
import { isSpace } from "@dxos/react-client/echo";
|
|
18
18
|
|
|
19
19
|
// packages/plugins/plugin-search/src/components/Searchbar/Searchbar.tsx
|
|
20
|
+
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
20
21
|
import { MagnifyingGlass } from "@phosphor-icons/react";
|
|
21
22
|
import React, { useEffect, useRef, useState } from "react";
|
|
22
23
|
import { Input } from "@dxos/react-ui";
|
|
23
24
|
import { getSize, mx } from "@dxos/react-ui-theme";
|
|
24
25
|
var Searchbar = ({ classes, variant, placeholder, value, onChange, onSubmit }) => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
setText(value);
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
26
|
+
var _effect = _useSignals();
|
|
27
|
+
try {
|
|
28
|
+
const inputRef = useRef(null);
|
|
29
|
+
const [text, setText] = useState(value);
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
setText(value);
|
|
32
|
+
}, [
|
|
33
|
+
value
|
|
34
|
+
]);
|
|
35
|
+
const handleChange = (text2) => {
|
|
36
|
+
setText(text2);
|
|
37
|
+
onChange?.(text2);
|
|
38
|
+
};
|
|
39
|
+
const handleReset = () => {
|
|
40
|
+
handleChange(void 0);
|
|
41
|
+
inputRef.current?.focus();
|
|
42
|
+
};
|
|
43
|
+
const handleKeyDown = (event) => {
|
|
44
|
+
switch (event.key) {
|
|
45
|
+
case "Enter":
|
|
46
|
+
onSubmit?.(text);
|
|
47
|
+
break;
|
|
48
|
+
case "Escape":
|
|
49
|
+
handleReset();
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
54
|
+
className: "flex shrink-0w-full items-center pli-1 pbs-1"
|
|
55
|
+
}, /* @__PURE__ */ React.createElement(Input.Root, null, /* @__PURE__ */ React.createElement(Input.TextInput, {
|
|
56
|
+
ref: inputRef,
|
|
57
|
+
placeholder,
|
|
58
|
+
variant,
|
|
59
|
+
value: text ?? "",
|
|
60
|
+
classNames: mx("pl-3 pr-10", classes?.input),
|
|
61
|
+
onChange: ({ target }) => handleChange(target.value),
|
|
62
|
+
onKeyDown: handleKeyDown
|
|
63
|
+
}), /* @__PURE__ */ React.createElement("div", {
|
|
64
|
+
role: "button",
|
|
65
|
+
className: "-ml-7 p-0 cursor-pointer",
|
|
66
|
+
onClick: handleReset
|
|
67
|
+
}, /* @__PURE__ */ React.createElement(MagnifyingGlass, {
|
|
68
|
+
className: getSize(5)
|
|
69
|
+
}))));
|
|
70
|
+
} finally {
|
|
71
|
+
_effect.f();
|
|
72
|
+
}
|
|
67
73
|
};
|
|
68
74
|
|
|
69
75
|
// packages/plugins/plugin-search/src/components/SearchMain.tsx
|
|
76
|
+
import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
|
|
70
77
|
import React3, { useState as useState3 } from "react";
|
|
71
78
|
import { log as log3 } from "@dxos/log";
|
|
72
79
|
import { useClient } from "@dxos/react-client";
|
|
73
80
|
import { Filter, useQuery } from "@dxos/react-client/echo";
|
|
74
81
|
import { useTranslation } from "@dxos/react-ui";
|
|
75
|
-
import {
|
|
82
|
+
import { activeSurface, mx as mx3 } from "@dxos/react-ui-theme";
|
|
76
83
|
|
|
77
84
|
// packages/plugins/plugin-search/src/components/SearchResults/SearchResults.tsx
|
|
85
|
+
import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
|
|
78
86
|
import React2, { forwardRef } from "react";
|
|
79
87
|
import { Card } from "@dxos/react-ui-card";
|
|
80
88
|
import { ghostHover, mx as mx2 } from "@dxos/react-ui-theme";
|
|
81
89
|
var Snippet = ({ text, match }) => {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if (
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
before
|
|
90
|
+
var _effect = _useSignals2();
|
|
91
|
+
try {
|
|
92
|
+
let content = /* @__PURE__ */ React2.createElement(React2.Fragment, null, text);
|
|
93
|
+
if (match) {
|
|
94
|
+
const result = text.match(match);
|
|
95
|
+
if (result?.index !== void 0) {
|
|
96
|
+
const maxOffset = 16;
|
|
97
|
+
let before = text.slice(0, result.index);
|
|
98
|
+
if (before.length > maxOffset) {
|
|
99
|
+
const idx = before.indexOf(" ", result.index - maxOffset);
|
|
100
|
+
before = "\u2026 " + before.slice(idx);
|
|
101
|
+
}
|
|
102
|
+
const after = text.slice(result.index + result[0].length);
|
|
103
|
+
content = /* @__PURE__ */ React2.createElement(React2.Fragment, null, before, /* @__PURE__ */ React2.createElement("span", {
|
|
104
|
+
className: "text-blue-500"
|
|
105
|
+
}, result[0]), after);
|
|
91
106
|
}
|
|
92
|
-
const after = text.slice(result.index + result[0].length);
|
|
93
|
-
content = /* @__PURE__ */ React2.createElement(React2.Fragment, null, before, /* @__PURE__ */ React2.createElement("span", {
|
|
94
|
-
className: "text-blue-500"
|
|
95
|
-
}, result[0]), after);
|
|
96
107
|
}
|
|
108
|
+
return /* @__PURE__ */ React2.createElement("span", {
|
|
109
|
+
className: "text-xs mb-1 line-clamp-3 text-neutral-300"
|
|
110
|
+
}, content);
|
|
111
|
+
} finally {
|
|
112
|
+
_effect.f();
|
|
97
113
|
}
|
|
98
|
-
return /* @__PURE__ */ React2.createElement("span", {
|
|
99
|
-
className: "text-xs mb-1 line-clamp-3 text-neutral-300"
|
|
100
|
-
}, content);
|
|
101
114
|
};
|
|
102
115
|
var SearchItem = /* @__PURE__ */ forwardRef((item, forwardRef3) => {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
116
|
+
var _effect = _useSignals2();
|
|
117
|
+
try {
|
|
118
|
+
const { id, objectType, label, snippet, match, selected, onSelect } = item;
|
|
119
|
+
const Icon2 = void 0;
|
|
120
|
+
return /* @__PURE__ */ React2.createElement(Card.Root, {
|
|
121
|
+
ref: forwardRef3,
|
|
122
|
+
classNames: mx2("mx-2 mt-2 cursor-pointer", selected && "!bg-activeSurface", ghostHover),
|
|
123
|
+
onClick: () => onSelect?.(id)
|
|
124
|
+
}, objectType && /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement("div", {
|
|
125
|
+
className: "text-xs text-neutral-400 ml-4"
|
|
126
|
+
}, objectType)), /* @__PURE__ */ React2.createElement(Card.Header, null, /* @__PURE__ */ React2.createElement(Card.Title, {
|
|
127
|
+
title: label ?? "Untitled"
|
|
128
|
+
}), Icon2 && /* @__PURE__ */ React2.createElement(Card.Endcap, {
|
|
129
|
+
Icon: Icon2
|
|
130
|
+
})), snippet && /* @__PURE__ */ React2.createElement(Card.Body, {
|
|
131
|
+
gutter: true
|
|
132
|
+
}, /* @__PURE__ */ React2.createElement(Snippet, {
|
|
133
|
+
text: snippet,
|
|
134
|
+
match
|
|
135
|
+
})));
|
|
136
|
+
} finally {
|
|
137
|
+
_effect.f();
|
|
138
|
+
}
|
|
121
139
|
});
|
|
122
140
|
var SearchResults = ({ items, selected, onSelect }) => {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
141
|
+
var _effect = _useSignals2();
|
|
142
|
+
try {
|
|
143
|
+
return /* @__PURE__ */ React2.createElement("div", {
|
|
144
|
+
className: "flex flex-col grow overflow-y-auto"
|
|
145
|
+
}, /* @__PURE__ */ React2.createElement("div", {
|
|
146
|
+
className: "flex flex-col"
|
|
147
|
+
}, items.map((item) => /* @__PURE__ */ React2.createElement(SearchItem, {
|
|
148
|
+
key: item.id,
|
|
149
|
+
type: SEARCH_RESULT,
|
|
150
|
+
...item,
|
|
151
|
+
onSelect,
|
|
152
|
+
selected: selected === item.id
|
|
153
|
+
}))));
|
|
154
|
+
} finally {
|
|
155
|
+
_effect.f();
|
|
156
|
+
}
|
|
134
157
|
};
|
|
135
158
|
|
|
136
159
|
// packages/plugins/plugin-search/src/hooks/useWebSearch.ts
|
|
137
160
|
import { useState as useState2 } from "react";
|
|
138
|
-
import { AIServiceEdgeClient } from "@dxos/
|
|
139
|
-
import { AI_SERVICE_ENDPOINT } from "@dxos/
|
|
161
|
+
import { AIServiceEdgeClient } from "@dxos/ai";
|
|
162
|
+
import { AI_SERVICE_ENDPOINT, EXA_API_KEY } from "@dxos/ai/testing";
|
|
140
163
|
import { getSchema, getTypename } from "@dxos/echo-schema";
|
|
141
164
|
import { log as log2 } from "@dxos/log";
|
|
142
165
|
import { getIconAnnotation } from "@dxos/schema";
|
|
143
166
|
import { Testing } from "@dxos/schema/testing";
|
|
144
167
|
|
|
145
168
|
// packages/plugins/plugin-search/src/search/exa.ts
|
|
146
|
-
import { Option, SchemaAST
|
|
169
|
+
import { Option, Schema, SchemaAST } from "effect";
|
|
147
170
|
import Exa from "exa-js";
|
|
148
|
-
import {
|
|
149
|
-
import { MixedStreamParser } from "@dxos/assistant";
|
|
171
|
+
import { Message, MixedStreamParser, createTool } from "@dxos/ai";
|
|
150
172
|
import { isEncodedReference } from "@dxos/echo-protocol";
|
|
151
|
-
import {
|
|
173
|
+
import { create, getTypeAnnotation, ObjectId, ReferenceAnnotationId } from "@dxos/echo-schema";
|
|
152
174
|
import { mapAst } from "@dxos/effect";
|
|
153
175
|
import { assertArgument, failedInvariant } from "@dxos/invariant";
|
|
154
176
|
import { log } from "@dxos/log";
|
|
@@ -163,7 +185,7 @@ var search = async (options) => {
|
|
|
163
185
|
additionalSearchTerms: contextSearchTerms
|
|
164
186
|
}, {
|
|
165
187
|
F: __dxlog_file,
|
|
166
|
-
L:
|
|
188
|
+
L: 53,
|
|
167
189
|
S: void 0,
|
|
168
190
|
C: (f, a) => f(...a)
|
|
169
191
|
});
|
|
@@ -182,7 +204,7 @@ var search = async (options) => {
|
|
|
182
204
|
context
|
|
183
205
|
}, {
|
|
184
206
|
F: __dxlog_file,
|
|
185
|
-
L:
|
|
207
|
+
L: 69,
|
|
186
208
|
S: void 0,
|
|
187
209
|
C: (f, a) => f(...a)
|
|
188
210
|
});
|
|
@@ -201,7 +223,7 @@ var search = async (options) => {
|
|
|
201
223
|
model: "@anthropic/claude-3-5-haiku-20241022",
|
|
202
224
|
systemPrompt,
|
|
203
225
|
history: [
|
|
204
|
-
|
|
226
|
+
create(Message, {
|
|
205
227
|
role: "user",
|
|
206
228
|
content: context.results.map((r) => ({
|
|
207
229
|
type: "text",
|
|
@@ -211,11 +233,11 @@ ${r.text}`
|
|
|
211
233
|
}))
|
|
212
234
|
})
|
|
213
235
|
],
|
|
214
|
-
schema:
|
|
236
|
+
schema: Schema.Struct({
|
|
215
237
|
...Object.fromEntries(mappedSchema.map((schema, index) => [
|
|
216
238
|
`objects_${index}`,
|
|
217
|
-
|
|
218
|
-
description: `The objects to answer the query of type ${getTypeAnnotation(schema)?.typename ??
|
|
239
|
+
Schema.Array(schema).annotations({
|
|
240
|
+
description: `The objects to answer the query of type ${getTypeAnnotation(schema)?.typename ?? SchemaAST.getIdentifierAnnotation(schema.ast).pipe(Option.getOrNull)}`
|
|
219
241
|
})
|
|
220
242
|
]))
|
|
221
243
|
})
|
|
@@ -225,7 +247,7 @@ ${r.text}`
|
|
|
225
247
|
result
|
|
226
248
|
}, {
|
|
227
249
|
F: __dxlog_file,
|
|
228
|
-
L:
|
|
250
|
+
L: 113,
|
|
229
251
|
S: void 0,
|
|
230
252
|
C: (f, a) => f(...a)
|
|
231
253
|
});
|
|
@@ -260,11 +282,11 @@ var DATA_EXTRACTION_INSTRUCTIONS = `
|
|
|
260
282
|
- Prefer using ids when available.
|
|
261
283
|
`;
|
|
262
284
|
var getStructuredOutput = async (aiService, request) => {
|
|
263
|
-
const result = await new MixedStreamParser().parse(await aiService.
|
|
285
|
+
const result = await new MixedStreamParser().parse(await aiService.execStream({
|
|
264
286
|
...request,
|
|
265
287
|
systemPrompt: request.systemPrompt + "\nDo not output anything other then the tool call. Call the submit_result tool with the result.",
|
|
266
288
|
tools: [
|
|
267
|
-
|
|
289
|
+
createTool("submit_result", {
|
|
268
290
|
name: "submit_result",
|
|
269
291
|
description: "Submit the result",
|
|
270
292
|
schema: request.schema,
|
|
@@ -284,7 +306,7 @@ var getSearchTerms = async (aiService, context) => {
|
|
|
284
306
|
Prefer own names of people, companies, and projects, technologies, and other entities.
|
|
285
307
|
`,
|
|
286
308
|
history: [
|
|
287
|
-
|
|
309
|
+
create(Message, {
|
|
288
310
|
role: "user",
|
|
289
311
|
content: [
|
|
290
312
|
{
|
|
@@ -296,8 +318,8 @@ ${context}`
|
|
|
296
318
|
]
|
|
297
319
|
})
|
|
298
320
|
],
|
|
299
|
-
schema:
|
|
300
|
-
terms:
|
|
321
|
+
schema: Schema.Struct({
|
|
322
|
+
terms: Schema.Array(Schema.String).annotations({
|
|
301
323
|
description: "The search terms to use to find the objects. 0-10 terms."
|
|
302
324
|
})
|
|
303
325
|
})
|
|
@@ -326,27 +348,26 @@ var sanitizeObjects = (entries) => {
|
|
|
326
348
|
}
|
|
327
349
|
return recurse(value);
|
|
328
350
|
});
|
|
329
|
-
return
|
|
351
|
+
return create(entry.schema, data);
|
|
330
352
|
});
|
|
331
353
|
};
|
|
332
|
-
var SoftRef =
|
|
333
|
-
"/":
|
|
354
|
+
var SoftRef = Schema.Struct({
|
|
355
|
+
"/": Schema.String
|
|
334
356
|
}).annotations({
|
|
335
357
|
description: "Reference to another object."
|
|
336
358
|
});
|
|
337
359
|
var mapSchemaRefs = (schema) => {
|
|
338
360
|
const go = (ast) => {
|
|
339
|
-
if (
|
|
361
|
+
if (SchemaAST.getAnnotation(ast, ReferenceAnnotationId).pipe(Option.isSome)) {
|
|
340
362
|
return SoftRef.ast;
|
|
341
363
|
}
|
|
342
364
|
return mapAst(ast, go);
|
|
343
365
|
};
|
|
344
|
-
return
|
|
366
|
+
return Schema.make(mapAst(schema.ast, go));
|
|
345
367
|
};
|
|
346
368
|
|
|
347
369
|
// packages/plugins/plugin-search/src/hooks/useWebSearch.ts
|
|
348
370
|
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-search/src/hooks/useWebSearch.ts";
|
|
349
|
-
var EXA_API_KEY = "9c7e17ff-0c85-4cd5-827a-8b489f139e03";
|
|
350
371
|
var useWebSearch = ({ query, context }) => {
|
|
351
372
|
const aiService = new AIServiceEdgeClient({
|
|
352
373
|
endpoint: AI_SERVICE_ENDPOINT.REMOTE
|
|
@@ -361,7 +382,7 @@ var useWebSearch = ({ query, context }) => {
|
|
|
361
382
|
context
|
|
362
383
|
}, {
|
|
363
384
|
F: __dxlog_file2,
|
|
364
|
-
L:
|
|
385
|
+
L: 30,
|
|
365
386
|
S: void 0,
|
|
366
387
|
C: (f, a) => f(...a)
|
|
367
388
|
});
|
|
@@ -370,7 +391,7 @@ var useWebSearch = ({ query, context }) => {
|
|
|
370
391
|
context,
|
|
371
392
|
schema: [
|
|
372
393
|
Testing.Project,
|
|
373
|
-
Testing.
|
|
394
|
+
Testing.Organization,
|
|
374
395
|
Testing.Contact
|
|
375
396
|
],
|
|
376
397
|
aiService,
|
|
@@ -411,54 +432,61 @@ var useWebSearch = ({ query, context }) => {
|
|
|
411
432
|
// packages/plugins/plugin-search/src/components/SearchMain.tsx
|
|
412
433
|
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-search/src/components/SearchMain.tsx";
|
|
413
434
|
var SearchMain = ({ classNames, space }) => {
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
435
|
+
var _effect = _useSignals3();
|
|
436
|
+
try {
|
|
437
|
+
const { t } = useTranslation(SEARCH_PLUGIN);
|
|
438
|
+
const client = useClient();
|
|
439
|
+
const { setMatch } = useGlobalSearch();
|
|
440
|
+
const [query, setQuery] = useState3();
|
|
441
|
+
const allSpaces = false;
|
|
442
|
+
const objects = useQuery(allSpaces ? client.spaces : space, Filter.everything());
|
|
443
|
+
const results = useGlobalSearchResults(objects);
|
|
444
|
+
const { runSearch, results: webResults, isLoading } = useWebSearch({
|
|
445
|
+
query
|
|
446
|
+
});
|
|
447
|
+
const [selected, setSelected] = useState3();
|
|
448
|
+
const handleSelect = (id) => {
|
|
449
|
+
setSelected((selected2) => selected2 === id ? void 0 : id);
|
|
450
|
+
};
|
|
451
|
+
const allResults = [
|
|
452
|
+
...results,
|
|
453
|
+
...webResults
|
|
454
|
+
];
|
|
455
|
+
log3.info("results", {
|
|
456
|
+
results,
|
|
457
|
+
webResults
|
|
458
|
+
}, {
|
|
459
|
+
F: __dxlog_file3,
|
|
460
|
+
L: 47,
|
|
461
|
+
S: void 0,
|
|
462
|
+
C: (f, a) => f(...a)
|
|
463
|
+
});
|
|
464
|
+
return /* @__PURE__ */ React3.createElement("div", {
|
|
465
|
+
className: mx3("flex flex-col grow h-full overflow-hidden", classNames)
|
|
466
|
+
}, /* @__PURE__ */ React3.createElement(Searchbar, {
|
|
467
|
+
placeholder: t("search placeholder"),
|
|
468
|
+
onChange: (text) => {
|
|
469
|
+
setQuery(text);
|
|
470
|
+
setMatch?.(text);
|
|
471
|
+
},
|
|
472
|
+
onSubmit: runSearch
|
|
473
|
+
}), isLoading && /* @__PURE__ */ React3.createElement("div", {
|
|
474
|
+
className: mx3("flex flex-col grow overflow-hidden", activeSurface)
|
|
475
|
+
}, "Loading..."), allResults.length > 0 && /* @__PURE__ */ React3.createElement("div", {
|
|
476
|
+
className: mx3("flex flex-col grow overflow-hidden", activeSurface)
|
|
477
|
+
}, /* @__PURE__ */ React3.createElement(SearchResults, {
|
|
478
|
+
items: allResults,
|
|
479
|
+
selected,
|
|
480
|
+
onSelect: handleSelect
|
|
481
|
+
})));
|
|
482
|
+
} finally {
|
|
483
|
+
_effect.f();
|
|
484
|
+
}
|
|
459
485
|
};
|
|
460
486
|
|
|
461
487
|
// packages/plugins/plugin-search/src/components/SearchDialog.tsx
|
|
488
|
+
import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
|
|
489
|
+
import { Option as Option2 } from "effect";
|
|
462
490
|
import React4, { forwardRef as forwardRef2, useCallback, useState as useState4 } from "react";
|
|
463
491
|
import { LayoutAction, createIntent, useAppGraph, useIntentDispatcher, useLayout } from "@dxos/app-framework";
|
|
464
492
|
import { useClient as useClient2 } from "@dxos/react-client";
|
|
@@ -468,100 +496,110 @@ import { SearchList } from "@dxos/react-ui-searchlist";
|
|
|
468
496
|
import { descriptionText, mx as mx4 } from "@dxos/react-ui-theme";
|
|
469
497
|
var SEARCH_DIALOG = `${SEARCH_PLUGIN}/SearchDialog`;
|
|
470
498
|
var SearchListResult = /* @__PURE__ */ forwardRef2(({ node, onSelect }, forwardedRef) => {
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
499
|
+
var _effect = _useSignals4();
|
|
500
|
+
try {
|
|
501
|
+
const { t } = useTranslation2(SEARCH_PLUGIN);
|
|
502
|
+
const label = toLocalizedString(node?.properties.label ?? "never", t);
|
|
503
|
+
return /* @__PURE__ */ React4.createElement(SearchList.Item, {
|
|
504
|
+
value: label,
|
|
505
|
+
key: node.id,
|
|
506
|
+
classNames: "flex gap-2 items-center pli-2",
|
|
507
|
+
onSelect: () => onSelect?.(node.id),
|
|
508
|
+
ref: forwardedRef
|
|
509
|
+
}, /* @__PURE__ */ React4.createElement(Icon, {
|
|
510
|
+
size: 5,
|
|
511
|
+
icon: node?.properties.icon
|
|
512
|
+
}), /* @__PURE__ */ React4.createElement("span", {
|
|
513
|
+
className: "is-0 grow truncate"
|
|
514
|
+
}, label));
|
|
515
|
+
} finally {
|
|
516
|
+
_effect.f();
|
|
517
|
+
}
|
|
485
518
|
});
|
|
486
519
|
var SearchDialog = ({ pivotId }) => {
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
layout
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
}
|
|
505
|
-
}));
|
|
506
|
-
const index = layout.active.findIndex((id) => id === nodeId);
|
|
507
|
-
if (index !== -1) {
|
|
508
|
-
await dispatch(createIntent(LayoutAction.ScrollIntoView, {
|
|
509
|
-
part: "current",
|
|
510
|
-
subject: nodeId
|
|
511
|
-
}));
|
|
512
|
-
} else {
|
|
513
|
-
await dispatch(createIntent(LayoutAction.Open, {
|
|
514
|
-
part: "main",
|
|
515
|
-
subject: [
|
|
516
|
-
nodeId
|
|
517
|
-
],
|
|
520
|
+
var _effect = _useSignals4();
|
|
521
|
+
try {
|
|
522
|
+
const { t } = useTranslation2(SEARCH_PLUGIN);
|
|
523
|
+
const { graph } = useAppGraph();
|
|
524
|
+
const layout = useLayout();
|
|
525
|
+
const closed = (Array.isArray(layout.inactive) ? layout.inactive : [
|
|
526
|
+
layout.inactive
|
|
527
|
+
]).map((id) => graph?.getNode(id)).filter(Boolean);
|
|
528
|
+
const [queryString, setQueryString] = useState4("");
|
|
529
|
+
const client = useClient2();
|
|
530
|
+
const dangerouslyLoadAllObjects = useQuery2(client.spaces, Filter2.everything());
|
|
531
|
+
const [pending, results] = useSearchResults(queryString, dangerouslyLoadAllObjects);
|
|
532
|
+
const resultObjects = Array.from(results.keys());
|
|
533
|
+
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
534
|
+
const handleSelect = useCallback(async (nodeId) => {
|
|
535
|
+
await dispatch(createIntent(LayoutAction.UpdateDialog, {
|
|
536
|
+
part: "dialog",
|
|
518
537
|
options: {
|
|
519
|
-
|
|
520
|
-
positioning: "end"
|
|
538
|
+
state: false
|
|
521
539
|
}
|
|
522
540
|
}));
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
541
|
+
const index = layout.active.findIndex((id) => id === nodeId);
|
|
542
|
+
if (index !== -1) {
|
|
543
|
+
await dispatch(createIntent(LayoutAction.ScrollIntoView, {
|
|
544
|
+
part: "current",
|
|
545
|
+
subject: nodeId
|
|
546
|
+
}));
|
|
547
|
+
} else {
|
|
548
|
+
await dispatch(createIntent(LayoutAction.Open, {
|
|
549
|
+
part: "main",
|
|
550
|
+
subject: [
|
|
551
|
+
nodeId
|
|
552
|
+
],
|
|
553
|
+
options: {
|
|
554
|
+
pivotId,
|
|
555
|
+
positioning: "end"
|
|
556
|
+
}
|
|
557
|
+
}));
|
|
558
|
+
}
|
|
559
|
+
}, [
|
|
560
|
+
pivotId,
|
|
561
|
+
dispatch,
|
|
562
|
+
layout
|
|
563
|
+
]);
|
|
564
|
+
return /* @__PURE__ */ React4.createElement(Dialog.Content, {
|
|
565
|
+
classNames: [
|
|
566
|
+
"md:max-is-[24rem] overflow-hidden mbs-12"
|
|
567
|
+
]
|
|
568
|
+
}, /* @__PURE__ */ React4.createElement(Dialog.Title, null, t("search dialog title")), /* @__PURE__ */ React4.createElement(SearchList.Root, {
|
|
569
|
+
label: t("search placeholder"),
|
|
570
|
+
classNames: "flex flex-col grow overflow-hidden my-2"
|
|
571
|
+
}, /* @__PURE__ */ React4.createElement(SearchList.Input, {
|
|
572
|
+
value: queryString,
|
|
573
|
+
onValueChange: (nextValue) => {
|
|
574
|
+
setQueryString(nextValue);
|
|
575
|
+
},
|
|
576
|
+
placeholder: t("search placeholder"),
|
|
577
|
+
classNames: "px-1 my-2"
|
|
578
|
+
}), /* @__PURE__ */ React4.createElement(SearchList.Content, {
|
|
579
|
+
classNames: "max-bs-[24rem] overflow-auto"
|
|
580
|
+
}, queryString.length > 0 ? resultObjects.length > 0 ? resultObjects.map((object) => graph.getNode(fullyQualifiedId(object))).filter(Option2.isSome).map((node) => /* @__PURE__ */ React4.createElement(SearchListResult, {
|
|
581
|
+
key: node.value.id,
|
|
582
|
+
node: node.value,
|
|
583
|
+
onSelect: handleSelect
|
|
584
|
+
})) : /* @__PURE__ */ React4.createElement("p", {
|
|
585
|
+
className: "pli-1"
|
|
586
|
+
}, t(pending ? "pending results message" : "empty results message")) : /* @__PURE__ */ React4.createElement(React4.Fragment, null, closed.length > 0 && /* @__PURE__ */ React4.createElement("h2", {
|
|
587
|
+
className: mx4("mlb-1", descriptionText)
|
|
588
|
+
}, t("recently closed heading")), closed.filter(Option2.isSome).map((node) => /* @__PURE__ */ React4.createElement(SearchListResult, {
|
|
589
|
+
key: node.value.id,
|
|
590
|
+
node: node.value,
|
|
591
|
+
onSelect: handleSelect
|
|
592
|
+
}))))), /* @__PURE__ */ React4.createElement(Dialog.Close, {
|
|
593
|
+
asChild: true
|
|
594
|
+
}, /* @__PURE__ */ React4.createElement(Button, {
|
|
595
|
+
variant: "primary",
|
|
596
|
+
classNames: "mbs-2"
|
|
597
|
+
}, t("close label", {
|
|
598
|
+
ns: "os"
|
|
599
|
+
}))));
|
|
600
|
+
} finally {
|
|
601
|
+
_effect.f();
|
|
602
|
+
}
|
|
565
603
|
};
|
|
566
604
|
|
|
567
605
|
// packages/plugins/plugin-search/src/capabilities/react-surface.tsx
|
|
@@ -573,13 +611,10 @@ var react_surface_default = () => contributes(Capabilities.ReactSurface, [
|
|
|
573
611
|
component: ({ data }) => /* @__PURE__ */ React5.createElement(SearchContextProvider, null, /* @__PURE__ */ React5.createElement(SearchDialog, data.props))
|
|
574
612
|
}),
|
|
575
613
|
createSurface({
|
|
576
|
-
|
|
577
|
-
id: "search-input",
|
|
614
|
+
id: `${SEARCH_DIALOG}/search-input`,
|
|
578
615
|
role: "search-input",
|
|
579
616
|
component: () => {
|
|
580
|
-
const
|
|
581
|
-
const { graph } = useAppGraph2();
|
|
582
|
-
const space = graph ? getActiveSpace(graph, layout.active[0]) : void 0;
|
|
617
|
+
const space = useActiveSpace();
|
|
583
618
|
if (!space) {
|
|
584
619
|
return null;
|
|
585
620
|
}
|
|
@@ -606,4 +641,4 @@ var react_surface_default = () => contributes(Capabilities.ReactSurface, [
|
|
|
606
641
|
export {
|
|
607
642
|
react_surface_default as default
|
|
608
643
|
};
|
|
609
|
-
//# sourceMappingURL=react-surface-
|
|
644
|
+
//# sourceMappingURL=react-surface-UJOSZGP5.mjs.map
|