@dxos/plugin-search 0.8.2-main.fbd8ed0 → 0.8.2-staging.42af850

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 (27) hide show
  1. package/dist/lib/browser/{app-graph-builder-N6QQA637.mjs → app-graph-builder-NZN3MIDZ.mjs} +3 -3
  2. package/dist/lib/browser/{chunk-J6YWSQTW.mjs → chunk-ARZYMSFF.mjs} +3 -3
  3. package/dist/lib/browser/{chunk-J6YWSQTW.mjs.map → chunk-ARZYMSFF.mjs.map} +1 -1
  4. package/dist/lib/browser/{chunk-SNU4XR5T.mjs → chunk-CKQAVN5U.mjs} +15 -9
  5. package/dist/lib/browser/{chunk-SNU4XR5T.mjs.map → chunk-CKQAVN5U.mjs.map} +1 -1
  6. package/dist/lib/browser/{chunk-4KPMT56H.mjs → chunk-VMEXQBHE.mjs} +3 -3
  7. package/dist/lib/browser/{chunk-4KPMT56H.mjs.map → chunk-VMEXQBHE.mjs.map} +1 -1
  8. package/dist/lib/browser/index.mjs +6 -6
  9. package/dist/lib/browser/{intent-resolver-QKBYLREY.mjs → intent-resolver-RWC63UGI.mjs} +3 -3
  10. package/dist/lib/browser/meta.json +1 -1
  11. package/dist/lib/browser/{react-surface-MG2K2YZ3.mjs → react-surface-UJOSZGP5.mjs} +272 -235
  12. package/dist/lib/browser/react-surface-UJOSZGP5.mjs.map +7 -0
  13. package/dist/types/src/hooks/useWebSearch.d.ts +1 -1
  14. package/dist/types/src/hooks/useWebSearch.d.ts.map +1 -1
  15. package/dist/types/src/search/exa.d.ts +1 -1
  16. package/dist/types/src/search/exa.d.ts.map +1 -1
  17. package/package.json +29 -27
  18. package/src/components/SearchMain.tsx +3 -3
  19. package/src/components/SearchResults/SearchResults.tsx +1 -1
  20. package/src/hooks/sync.test.ts +2 -2
  21. package/src/hooks/useWebSearch.ts +5 -7
  22. package/src/meta.ts +2 -2
  23. package/src/search/exa.test.ts +2 -3
  24. package/src/search/exa.ts +9 -3
  25. package/dist/lib/browser/react-surface-MG2K2YZ3.mjs.map +0 -7
  26. /package/dist/lib/browser/{app-graph-builder-N6QQA637.mjs.map → app-graph-builder-NZN3MIDZ.mjs.map} +0 -0
  27. /package/dist/lib/browser/{intent-resolver-QKBYLREY.mjs.map → intent-resolver-RWC63UGI.mjs.map} +0 -0
@@ -4,11 +4,11 @@ import {
4
4
  useGlobalSearch,
5
5
  useGlobalSearchResults,
6
6
  useSearchResults
7
- } from "./chunk-SNU4XR5T.mjs";
7
+ } from "./chunk-CKQAVN5U.mjs";
8
8
  import {
9
9
  SEARCH_PLUGIN,
10
10
  SEARCH_RESULT
11
- } from "./chunk-J6YWSQTW.mjs";
11
+ } from "./chunk-ARZYMSFF.mjs";
12
12
 
13
13
  // packages/plugins/plugin-search/src/capabilities/react-surface.tsx
14
14
  import React5 from "react";
@@ -17,126 +17,149 @@ 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
- const inputRef = useRef(null);
26
- const [text, setText] = useState(value);
27
- useEffect(() => {
28
- setText(value);
29
- }, [
30
- value
31
- ]);
32
- const handleChange = (text2) => {
33
- setText(text2);
34
- onChange?.(text2);
35
- };
36
- const handleReset = () => {
37
- handleChange(void 0);
38
- inputRef.current?.focus();
39
- };
40
- const handleKeyDown = (event) => {
41
- switch (event.key) {
42
- case "Enter":
43
- onSubmit?.(text);
44
- break;
45
- case "Escape":
46
- handleReset();
47
- break;
48
- }
49
- };
50
- return /* @__PURE__ */ React.createElement("div", {
51
- className: "flex shrink-0w-full items-center pli-1 pbs-1"
52
- }, /* @__PURE__ */ React.createElement(Input.Root, null, /* @__PURE__ */ React.createElement(Input.TextInput, {
53
- ref: inputRef,
54
- placeholder,
55
- variant,
56
- value: text ?? "",
57
- classNames: mx("pl-3 pr-10", classes?.input),
58
- onChange: ({ target }) => handleChange(target.value),
59
- onKeyDown: handleKeyDown
60
- }), /* @__PURE__ */ React.createElement("div", {
61
- role: "button",
62
- className: "-ml-7 p-0 cursor-pointer",
63
- onClick: handleReset
64
- }, /* @__PURE__ */ React.createElement(MagnifyingGlass, {
65
- className: getSize(5)
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 { groupSurface, mx as mx3 } from "@dxos/react-ui-theme";
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
- let content = /* @__PURE__ */ React2.createElement(React2.Fragment, null, text);
83
- if (match) {
84
- const result = text.match(match);
85
- if (result?.index !== void 0) {
86
- const maxOffset = 16;
87
- let before = text.slice(0, result.index);
88
- if (before.length > maxOffset) {
89
- const idx = before.indexOf(" ", result.index - maxOffset);
90
- before = "\u2026 " + before.slice(idx);
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
- const { id, objectType, label, snippet, match, selected, onSelect } = item;
104
- const Icon2 = void 0;
105
- return /* @__PURE__ */ React2.createElement(Card.Root, {
106
- ref: forwardRef3,
107
- classNames: mx2("mx-2 mt-2 cursor-pointer", selected && "!bg-groupSurface", ghostHover),
108
- onClick: () => onSelect?.(id)
109
- }, objectType && /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement("div", {
110
- className: "text-xs text-neutral-400 ml-4"
111
- }, objectType)), /* @__PURE__ */ React2.createElement(Card.Header, null, /* @__PURE__ */ React2.createElement(Card.Title, {
112
- title: label ?? "Untitled"
113
- }), Icon2 && /* @__PURE__ */ React2.createElement(Card.Endcap, {
114
- Icon: Icon2
115
- })), snippet && /* @__PURE__ */ React2.createElement(Card.Body, {
116
- gutter: true
117
- }, /* @__PURE__ */ React2.createElement(Snippet, {
118
- text: snippet,
119
- match
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
- return /* @__PURE__ */ React2.createElement("div", {
124
- className: "flex flex-col grow overflow-y-auto"
125
- }, /* @__PURE__ */ React2.createElement("div", {
126
- className: "flex flex-col"
127
- }, items.map((item) => /* @__PURE__ */ React2.createElement(SearchItem, {
128
- key: item.id,
129
- type: SEARCH_RESULT,
130
- ...item,
131
- onSelect,
132
- selected: selected === item.id
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/assistant";
139
- import { AI_SERVICE_ENDPOINT } from "@dxos/assistant/testing";
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";
@@ -145,8 +168,7 @@ import { Testing } from "@dxos/schema/testing";
145
168
  // packages/plugins/plugin-search/src/search/exa.ts
146
169
  import { Option, Schema, SchemaAST } from "effect";
147
170
  import Exa from "exa-js";
148
- import { defineTool, Message } from "@dxos/artifact";
149
- import { MixedStreamParser } from "@dxos/assistant";
171
+ import { Message, MixedStreamParser, createTool } from "@dxos/ai";
150
172
  import { isEncodedReference } from "@dxos/echo-protocol";
151
173
  import { create, getTypeAnnotation, ObjectId, ReferenceAnnotationId } from "@dxos/echo-schema";
152
174
  import { mapAst } from "@dxos/effect";
@@ -163,7 +185,7 @@ var search = async (options) => {
163
185
  additionalSearchTerms: contextSearchTerms
164
186
  }, {
165
187
  F: __dxlog_file,
166
- L: 47,
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: 63,
207
+ L: 69,
186
208
  S: void 0,
187
209
  C: (f, a) => f(...a)
188
210
  });
@@ -225,7 +247,7 @@ ${r.text}`
225
247
  result
226
248
  }, {
227
249
  F: __dxlog_file,
228
- L: 107,
250
+ L: 113,
229
251
  S: void 0,
230
252
  C: (f, a) => f(...a)
231
253
  });
@@ -264,7 +286,7 @@ var getStructuredOutput = async (aiService, request) => {
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
- defineTool("submit_result", {
289
+ createTool("submit_result", {
268
290
  name: "submit_result",
269
291
  description: "Submit the result",
270
292
  schema: request.schema,
@@ -346,7 +368,6 @@ var mapSchemaRefs = (schema) => {
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: 33,
385
+ L: 30,
365
386
  S: void 0,
366
387
  C: (f, a) => f(...a)
367
388
  });
@@ -411,54 +432,60 @@ 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
- const { t } = useTranslation(SEARCH_PLUGIN);
415
- const client = useClient();
416
- const { setMatch } = useGlobalSearch();
417
- const [query, setQuery] = useState3();
418
- const allSpaces = false;
419
- const objects = useQuery(allSpaces ? client.spaces : space, Filter.everything());
420
- const results = useGlobalSearchResults(objects);
421
- const { runSearch, results: webResults, isLoading } = useWebSearch({
422
- query
423
- });
424
- const [selected, setSelected] = useState3();
425
- const handleSelect = (id) => {
426
- setSelected((selected2) => selected2 === id ? void 0 : id);
427
- };
428
- const allResults = [
429
- ...results,
430
- ...webResults
431
- ];
432
- log3.info("results", {
433
- results,
434
- webResults
435
- }, {
436
- F: __dxlog_file3,
437
- L: 47,
438
- S: void 0,
439
- C: (f, a) => f(...a)
440
- });
441
- return /* @__PURE__ */ React3.createElement("div", {
442
- className: mx3("flex flex-col grow h-full overflow-hidden", classNames)
443
- }, /* @__PURE__ */ React3.createElement(Searchbar, {
444
- placeholder: t("search placeholder"),
445
- onChange: (text) => {
446
- setQuery(text);
447
- setMatch?.(text);
448
- },
449
- onSubmit: runSearch
450
- }), isLoading && /* @__PURE__ */ React3.createElement("div", {
451
- className: mx3("flex flex-col grow overflow-hidden", groupSurface)
452
- }, "Loading..."), allResults.length > 0 && /* @__PURE__ */ React3.createElement("div", {
453
- className: mx3("flex flex-col grow overflow-hidden", groupSurface)
454
- }, /* @__PURE__ */ React3.createElement(SearchResults, {
455
- items: allResults,
456
- selected,
457
- onSelect: handleSelect
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";
462
489
  import { Option as Option2 } from "effect";
463
490
  import React4, { forwardRef as forwardRef2, useCallback, useState as useState4 } from "react";
464
491
  import { LayoutAction, createIntent, useAppGraph, useIntentDispatcher, useLayout } from "@dxos/app-framework";
@@ -469,100 +496,110 @@ import { SearchList } from "@dxos/react-ui-searchlist";
469
496
  import { descriptionText, mx as mx4 } from "@dxos/react-ui-theme";
470
497
  var SEARCH_DIALOG = `${SEARCH_PLUGIN}/SearchDialog`;
471
498
  var SearchListResult = /* @__PURE__ */ forwardRef2(({ node, onSelect }, forwardedRef) => {
472
- const { t } = useTranslation2(SEARCH_PLUGIN);
473
- const label = toLocalizedString(node?.properties.label ?? "never", t);
474
- return /* @__PURE__ */ React4.createElement(SearchList.Item, {
475
- value: label,
476
- key: node.id,
477
- classNames: "flex gap-2 items-center pli-2",
478
- onSelect: () => onSelect?.(node.id),
479
- ref: forwardedRef
480
- }, /* @__PURE__ */ React4.createElement(Icon, {
481
- size: 5,
482
- icon: node?.properties.icon
483
- }), /* @__PURE__ */ React4.createElement("span", {
484
- className: "is-0 grow truncate"
485
- }, label));
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
+ }
486
518
  });
487
519
  var SearchDialog = ({ pivotId }) => {
488
- const { t } = useTranslation2(SEARCH_PLUGIN);
489
- const { graph } = useAppGraph();
490
- const layout = useLayout();
491
- const closed = (Array.isArray(layout.inactive) ? layout.inactive : [
492
- layout.inactive
493
- ]).map((id) => graph?.getNode(id)).filter(Boolean);
494
- const [queryString, setQueryString] = useState4("");
495
- const client = useClient2();
496
- const dangerouslyLoadAllObjects = useQuery2(client.spaces, Filter2.everything());
497
- const [pending, results] = useSearchResults(queryString, dangerouslyLoadAllObjects);
498
- const resultObjects = Array.from(results.keys());
499
- const { dispatchPromise: dispatch } = useIntentDispatcher();
500
- const handleSelect = useCallback(async (nodeId) => {
501
- await dispatch(createIntent(LayoutAction.UpdateDialog, {
502
- part: "dialog",
503
- options: {
504
- state: false
505
- }
506
- }));
507
- const index = layout.active.findIndex((id) => id === nodeId);
508
- if (index !== -1) {
509
- await dispatch(createIntent(LayoutAction.ScrollIntoView, {
510
- part: "current",
511
- subject: nodeId
512
- }));
513
- } else {
514
- await dispatch(createIntent(LayoutAction.Open, {
515
- part: "main",
516
- subject: [
517
- nodeId
518
- ],
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",
519
537
  options: {
520
- pivotId,
521
- positioning: "end"
538
+ state: false
522
539
  }
523
540
  }));
524
- }
525
- }, [
526
- pivotId,
527
- dispatch,
528
- layout
529
- ]);
530
- return /* @__PURE__ */ React4.createElement(Dialog.Content, {
531
- classNames: [
532
- "md:max-is-[24rem] overflow-hidden mbs-12"
533
- ]
534
- }, /* @__PURE__ */ React4.createElement(Dialog.Title, null, t("search dialog title")), /* @__PURE__ */ React4.createElement(SearchList.Root, {
535
- label: t("search placeholder"),
536
- classNames: "flex flex-col grow overflow-hidden my-2"
537
- }, /* @__PURE__ */ React4.createElement(SearchList.Input, {
538
- value: queryString,
539
- onValueChange: (nextValue) => {
540
- setQueryString(nextValue);
541
- },
542
- placeholder: t("search placeholder"),
543
- classNames: "px-1 my-2"
544
- }), /* @__PURE__ */ React4.createElement(SearchList.Content, {
545
- classNames: "max-bs-[24rem] overflow-auto"
546
- }, queryString.length > 0 ? resultObjects.length > 0 ? resultObjects.map((object) => graph.getNode(fullyQualifiedId(object))).filter(Option2.isSome).map((node) => /* @__PURE__ */ React4.createElement(SearchListResult, {
547
- key: node.value.id,
548
- node: node.value,
549
- onSelect: handleSelect
550
- })) : /* @__PURE__ */ React4.createElement("p", {
551
- className: "pli-1"
552
- }, t(pending ? "pending results message" : "empty results message")) : /* @__PURE__ */ React4.createElement(React4.Fragment, null, closed.length > 0 && /* @__PURE__ */ React4.createElement("h2", {
553
- className: mx4("mlb-1", descriptionText)
554
- }, t("recently closed heading")), closed.filter(Option2.isSome).map((node) => /* @__PURE__ */ React4.createElement(SearchListResult, {
555
- key: node.value.id,
556
- node: node.value,
557
- onSelect: handleSelect
558
- }))))), /* @__PURE__ */ React4.createElement(Dialog.Close, {
559
- asChild: true
560
- }, /* @__PURE__ */ React4.createElement(Button, {
561
- variant: "primary",
562
- classNames: "mbs-2"
563
- }, t("close label", {
564
- ns: "os"
565
- }))));
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
+ }
566
603
  };
567
604
 
568
605
  // packages/plugins/plugin-search/src/capabilities/react-surface.tsx
@@ -604,4 +641,4 @@ var react_surface_default = () => contributes(Capabilities.ReactSurface, [
604
641
  export {
605
642
  react_surface_default as default
606
643
  };
607
- //# sourceMappingURL=react-surface-MG2K2YZ3.mjs.map
644
+ //# sourceMappingURL=react-surface-UJOSZGP5.mjs.map