@dxos/plugin-search 0.8.3-staging.0fa589b → 0.8.4-main.1da679c

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 (62) hide show
  1. package/dist/lib/browser/{app-graph-builder-NZN3MIDZ.mjs → app-graph-builder-OHY2FEHI.mjs} +7 -7
  2. package/dist/lib/browser/{app-graph-builder-NZN3MIDZ.mjs.map → app-graph-builder-OHY2FEHI.mjs.map} +3 -3
  3. package/dist/lib/browser/{chunk-VMEXQBHE.mjs → chunk-JVMYGOKS.mjs} +3 -3
  4. package/dist/lib/browser/{chunk-ARZYMSFF.mjs → chunk-KNS62YL2.mjs} +2 -2
  5. package/dist/lib/browser/{chunk-SB4WGHS2.mjs → chunk-YJGLEPHU.mjs} +6 -6
  6. package/dist/lib/browser/{chunk-SB4WGHS2.mjs.map → chunk-YJGLEPHU.mjs.map} +3 -3
  7. package/dist/lib/browser/index.mjs +14 -14
  8. package/dist/lib/browser/index.mjs.map +3 -3
  9. package/dist/lib/browser/intent-resolver-GZBL6XIZ.mjs +22 -0
  10. package/dist/lib/browser/{intent-resolver-RWC63UGI.mjs.map → intent-resolver-GZBL6XIZ.mjs.map} +3 -3
  11. package/dist/lib/browser/meta.json +1 -1
  12. package/dist/lib/browser/{react-surface-TJYKAIR5.mjs → react-surface-GAS4UCXV.mjs} +120 -294
  13. package/dist/lib/browser/react-surface-GAS4UCXV.mjs.map +7 -0
  14. package/dist/types/src/capabilities/app-graph-builder.d.ts +1 -1
  15. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
  16. package/dist/types/src/capabilities/index.d.ts +3 -3
  17. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  18. package/dist/types/src/capabilities/intent-resolver.d.ts +1 -1
  19. package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
  20. package/dist/types/src/capabilities/react-surface.d.ts +1 -1
  21. package/dist/types/src/components/Search.stories.d.ts +15 -10
  22. package/dist/types/src/components/Search.stories.d.ts.map +1 -1
  23. package/dist/types/src/components/SearchMain.d.ts.map +1 -1
  24. package/dist/types/src/components/SearchResults/SearchResults.d.ts.map +1 -1
  25. package/dist/types/src/components/SearchResults/SearchResults.stories.d.ts +12 -7
  26. package/dist/types/src/components/SearchResults/SearchResults.stories.d.ts.map +1 -1
  27. package/dist/types/src/components/Searchbar/Searchbar.d.ts.map +1 -1
  28. package/dist/types/src/components/Searchbar/Searchbar.stories.d.ts +10 -7
  29. package/dist/types/src/components/Searchbar/Searchbar.stories.d.ts.map +1 -1
  30. package/dist/types/src/hooks/useGlobalSearch.d.ts.map +1 -1
  31. package/dist/types/src/hooks/useWebSearch.d.ts.map +1 -1
  32. package/dist/types/src/search/exa.d.ts +0 -2
  33. package/dist/types/src/search/exa.d.ts.map +1 -1
  34. package/dist/types/src/translations.d.ts +13 -13
  35. package/dist/types/src/translations.d.ts.map +1 -1
  36. package/dist/types/src/types/index.d.ts +1 -1
  37. package/dist/types/src/types/index.d.ts.map +1 -1
  38. package/dist/types/tsconfig.tsbuildinfo +1 -1
  39. package/package.json +34 -35
  40. package/src/SearchPlugin.tsx +3 -3
  41. package/src/capabilities/app-graph-builder.ts +2 -2
  42. package/src/capabilities/intent-resolver.ts +1 -1
  43. package/src/capabilities/react-surface.tsx +1 -1
  44. package/src/components/Search.stories.tsx +16 -7
  45. package/src/components/SearchMain.tsx +4 -3
  46. package/src/components/SearchResults/SearchResults.stories.tsx +16 -13
  47. package/src/components/SearchResults/SearchResults.tsx +13 -15
  48. package/src/components/Searchbar/Searchbar.stories.tsx +7 -5
  49. package/src/components/Searchbar/Searchbar.tsx +3 -5
  50. package/src/hooks/sync.test.ts +1 -1
  51. package/src/hooks/sync.ts +1 -1
  52. package/src/hooks/useGlobalSearch.tsx +3 -2
  53. package/src/hooks/useSearchResults.ts +2 -2
  54. package/src/hooks/useWebSearch.ts +3 -8
  55. package/src/search/exa.test.ts +3 -24
  56. package/src/search/exa.ts +132 -163
  57. package/src/translations.ts +6 -4
  58. package/src/types/index.ts +1 -1
  59. package/dist/lib/browser/intent-resolver-RWC63UGI.mjs +0 -22
  60. package/dist/lib/browser/react-surface-TJYKAIR5.mjs.map +0 -7
  61. /package/dist/lib/browser/{chunk-VMEXQBHE.mjs.map → chunk-JVMYGOKS.mjs.map} +0 -0
  62. /package/dist/lib/browser/{chunk-ARZYMSFF.mjs.map → chunk-KNS62YL2.mjs.map} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/plugin-search",
3
- "version": "0.8.3-staging.0fa589b",
3
+ "version": "0.8.4-main.1da679c",
4
4
  "description": "Braneframe sketch plugin",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -10,6 +10,7 @@
10
10
  "type": "module",
11
11
  "exports": {
12
12
  ".": {
13
+ "source": "./src/index.ts",
13
14
  "types": "./dist/types/src/index.d.ts",
14
15
  "browser": "./dist/lib/browser/index.mjs"
15
16
  }
@@ -26,52 +27,50 @@
26
27
  "@preact-signals/safe-react": "^0.9.0",
27
28
  "exa-js": "^1.5.12",
28
29
  "main-thread-scheduling": "^14.1.1",
29
- "@dxos/ai": "0.8.3-staging.0fa589b",
30
- "@dxos/artifact": "0.8.3-staging.0fa589b",
31
- "@dxos/assistant": "0.8.3-staging.0fa589b",
32
- "@dxos/debug": "0.8.3-staging.0fa589b",
33
- "@dxos/echo": "0.8.3-staging.0fa589b",
34
- "@dxos/app-framework": "0.8.3-staging.0fa589b",
35
- "@dxos/echo-schema": "0.8.3-staging.0fa589b",
36
- "@dxos/effect": "0.8.3-staging.0fa589b",
37
- "@dxos/echo-protocol": "0.8.3-staging.0fa589b",
38
- "@dxos/invariant": "0.8.3-staging.0fa589b",
39
- "@dxos/live-object": "0.8.3-staging.0fa589b",
40
- "@dxos/log": "0.8.3-staging.0fa589b",
41
- "@dxos/plugin-client": "0.8.3-staging.0fa589b",
42
- "@dxos/plugin-deck": "0.8.3-staging.0fa589b",
43
- "@dxos/plugin-graph": "0.8.3-staging.0fa589b",
44
- "@dxos/react-client": "0.8.3-staging.0fa589b",
45
- "@dxos/react-ui-searchlist": "0.8.3-staging.0fa589b",
46
- "@dxos/schema": "0.8.3-staging.0fa589b",
47
- "@dxos/plugin-space": "0.8.3-staging.0fa589b",
48
- "@dxos/react-ui-stack": "0.8.3-staging.0fa589b",
49
- "@dxos/util": "0.8.3-staging.0fa589b"
30
+ "@dxos/ai": "0.8.4-main.1da679c",
31
+ "@dxos/app-framework": "0.8.4-main.1da679c",
32
+ "@dxos/assistant": "0.8.4-main.1da679c",
33
+ "@dxos/debug": "0.8.4-main.1da679c",
34
+ "@dxos/blueprints": "0.8.4-main.1da679c",
35
+ "@dxos/echo-protocol": "0.8.4-main.1da679c",
36
+ "@dxos/echo": "0.8.4-main.1da679c",
37
+ "@dxos/effect": "0.8.4-main.1da679c",
38
+ "@dxos/echo-schema": "0.8.4-main.1da679c",
39
+ "@dxos/live-object": "0.8.4-main.1da679c",
40
+ "@dxos/invariant": "0.8.4-main.1da679c",
41
+ "@dxos/log": "0.8.4-main.1da679c",
42
+ "@dxos/plugin-client": "0.8.4-main.1da679c",
43
+ "@dxos/plugin-deck": "0.8.4-main.1da679c",
44
+ "@dxos/react-client": "0.8.4-main.1da679c",
45
+ "@dxos/react-ui-searchlist": "0.8.4-main.1da679c",
46
+ "@dxos/plugin-graph": "0.8.4-main.1da679c",
47
+ "@dxos/react-ui-stack": "0.8.4-main.1da679c",
48
+ "@dxos/schema": "0.8.4-main.1da679c",
49
+ "@dxos/util": "0.8.4-main.1da679c",
50
+ "@dxos/plugin-space": "0.8.4-main.1da679c"
50
51
  },
51
52
  "devDependencies": {
52
- "@effect-rx/rx-react": "^0.34.1",
53
- "@effect/platform": "0.80.12",
54
- "@phosphor-icons/react": "^2.1.5",
53
+ "@effect-rx/rx-react": "0.38.0",
54
+ "@effect/platform": "0.90.2",
55
55
  "@types/react": "~18.2.0",
56
56
  "@types/react-dom": "~18.2.0",
57
- "effect": "3.14.21",
57
+ "effect": "3.17.7",
58
58
  "react": "~18.2.0",
59
59
  "react-dom": "~18.2.0",
60
- "vite": "5.4.7",
61
- "@dxos/random": "0.8.3-staging.0fa589b",
62
- "@dxos/react-ui": "0.8.3-staging.0fa589b",
63
- "@dxos/storybook-utils": "0.8.3-staging.0fa589b",
64
- "@dxos/react-ui-theme": "0.8.3-staging.0fa589b"
60
+ "vite": "7.1.1",
61
+ "@dxos/random": "0.8.4-main.1da679c",
62
+ "@dxos/react-ui-theme": "0.8.4-main.1da679c",
63
+ "@dxos/react-ui": "0.8.4-main.1da679c",
64
+ "@dxos/storybook-utils": "0.8.4-main.1da679c"
65
65
  },
66
66
  "peerDependencies": {
67
67
  "@effect-rx/rx-react": "^0.34.1",
68
- "@effect/platform": "0.80.12",
69
- "@phosphor-icons/react": "^2.1.5",
68
+ "@effect/platform": "^0.80.12",
70
69
  "effect": "^3.13.3",
71
70
  "react": "~18.2.0",
72
71
  "react-dom": "~18.2.0",
73
- "@dxos/react-ui-theme": "0.8.3-staging.0fa589b",
74
- "@dxos/react-ui": "0.8.3-staging.0fa589b"
72
+ "@dxos/react-ui": "0.8.4-main.1da679c",
73
+ "@dxos/react-ui-theme": "0.8.4-main.1da679c"
75
74
  },
76
75
  "publishConfig": {
77
76
  "access": "public"
@@ -2,11 +2,11 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { contributes, Events, defineModule, definePlugin, Capabilities } from '@dxos/app-framework';
5
+ import { Capabilities, Events, contributes, defineModule, definePlugin } from '@dxos/app-framework';
6
6
 
7
7
  import { AppGraphBuilder, IntentResolver, ReactSurface } from './capabilities';
8
- import { meta, SEARCH_RESULT } from './meta';
9
- import translations from './translations';
8
+ import { SEARCH_RESULT, meta } from './meta';
9
+ import { translations } from './translations';
10
10
  import { type SearchResult } from './types';
11
11
 
12
12
  export const SearchPlugin = () =>
@@ -5,10 +5,10 @@
5
5
  import { Rx } from '@effect-rx/rx-react';
6
6
  import { Option, pipe } from 'effect';
7
7
 
8
- import { Capabilities, contributes, createIntent, type PluginContext } from '@dxos/app-framework';
8
+ import { Capabilities, type PluginContext, contributes, createIntent } from '@dxos/app-framework';
9
9
  import { ClientCapabilities } from '@dxos/plugin-client';
10
10
  import { ATTENDABLE_PATH_SEPARATOR, DECK_COMPANION_TYPE } from '@dxos/plugin-deck/types';
11
- import { createExtension, ROOT_ID, rxFromSignal } from '@dxos/plugin-graph';
11
+ import { ROOT_ID, createExtension, rxFromSignal } from '@dxos/plugin-graph';
12
12
  import { parseId } from '@dxos/react-client/echo';
13
13
 
14
14
  import { SEARCH_PLUGIN } from '../meta';
@@ -2,7 +2,7 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { contributes, Capabilities, createResolver, LayoutAction, createIntent } from '@dxos/app-framework';
5
+ import { Capabilities, LayoutAction, contributes, createIntent, createResolver } from '@dxos/app-framework';
6
6
 
7
7
  import { SearchAction } from '../types';
8
8
 
@@ -6,7 +6,7 @@ import React from 'react';
6
6
 
7
7
  import { Capabilities, contributes, createSurface } from '@dxos/app-framework';
8
8
  import { useActiveSpace } from '@dxos/plugin-space';
9
- import { isSpace, type Space } from '@dxos/react-client/echo';
9
+ import { type Space, isSpace } from '@dxos/react-client/echo';
10
10
 
11
11
  import { SEARCH_DIALOG, SearchDialog, type SearchDialogProps, SearchMain } from '../components';
12
12
  import { SearchContextProvider } from '../hooks';
@@ -4,16 +4,17 @@
4
4
 
5
5
  import '@dxos-theme';
6
6
 
7
- import { type Meta, type Decorator, type StoryFn } from '@storybook/react';
7
+ import { type Decorator, type Meta, type StoryFn, type StoryObj } from '@storybook/react-vite';
8
8
  import React, { useState } from 'react';
9
9
 
10
10
  import { faker } from '@dxos/random';
11
11
  import { withLayout, withTheme } from '@dxos/storybook-utils';
12
12
 
13
- import { SearchResults } from './SearchResults';
14
- import { Searchbar, type SearchbarProps } from './Searchbar';
15
13
  import { SearchContextProvider, useGlobalSearch, useGlobalSearchResults } from '../hooks';
16
14
 
15
+ import { Searchbar, type SearchbarProps } from './Searchbar';
16
+ import { SearchResults } from './SearchResults';
17
+
17
18
  faker.seed(1);
18
19
 
19
20
  type StoryProps = SearchbarProps & {
@@ -43,7 +44,7 @@ const SearchContextDecorator = (): Decorator => {
43
44
  );
44
45
  };
45
46
 
46
- export const Default = {
47
+ export const Default: Story = {
47
48
  args: {
48
49
  objects: Array.from({ length: 8 }).map(() => ({
49
50
  id: faker.string.uuid(),
@@ -53,14 +54,22 @@ export const Default = {
53
54
  },
54
55
  };
55
56
 
56
- const meta: Meta<typeof Searchbar> = {
57
+ const meta = {
57
58
  title: 'plugins/plugin-search/Search',
58
59
  component: Searchbar,
59
60
  render: DefaultStory,
60
- decorators: [withTheme, withLayout({ fullscreen: true }), SearchContextDecorator()],
61
+ decorators: [
62
+ withTheme,
63
+ withLayout({
64
+ fullscreen: true,
65
+ }),
66
+ SearchContextDecorator(),
67
+ ],
61
68
  parameters: {
62
69
  layout: 'fullscreen',
63
70
  },
64
- };
71
+ } satisfies Meta<typeof Searchbar>;
65
72
 
66
73
  export default meta;
74
+
75
+ type Story = StoryObj<typeof meta>;
@@ -6,16 +6,17 @@ import React, { type FC, useState } from 'react';
6
6
 
7
7
  import { log } from '@dxos/log';
8
8
  import { useClient } from '@dxos/react-client';
9
- import { Filter, useQuery, type Space } from '@dxos/react-client/echo';
9
+ import { Filter, type Space, useQuery } from '@dxos/react-client/echo';
10
10
  import { type ThemedClassName, useTranslation } from '@dxos/react-ui';
11
11
  import { activeSurface, mx } from '@dxos/react-ui-theme';
12
12
 
13
- import { SearchResults } from './SearchResults';
14
- import { Searchbar } from './Searchbar';
15
13
  import { useGlobalSearch, useGlobalSearchResults } from '../hooks';
16
14
  import { useWebSearch } from '../hooks/useWebSearch';
17
15
  import { SEARCH_PLUGIN } from '../meta';
18
16
 
17
+ import { Searchbar } from './Searchbar';
18
+ import { SearchResults } from './SearchResults';
19
+
19
20
  export const SearchMain: FC<ThemedClassName<{ space: Space }>> = ({ classNames, space }) => {
20
21
  const { t } = useTranslation(SEARCH_PLUGIN);
21
22
  const client = useClient();
@@ -4,24 +4,25 @@
4
4
 
5
5
  import '@dxos-theme';
6
6
 
7
- import { type Meta } from '@storybook/react';
7
+ import { type Meta, type StoryObj } from '@storybook/react-vite';
8
8
  import React, { useState } from 'react';
9
9
 
10
10
  import { faker } from '@dxos/random';
11
11
  import { withLayout, withTheme } from '@dxos/storybook-utils';
12
12
 
13
- import { SearchResults, type SearchResultsProps } from './SearchResults';
14
13
  import { filterObjectsSync } from '../../hooks';
15
14
 
15
+ import { SearchResults, type SearchResultsProps } from './SearchResults';
16
+
16
17
  faker.seed(1);
17
18
 
18
- const DefaultStory = (args: SearchResultsProps) => {
19
+ const DefaultStory = (props: SearchResultsProps) => {
19
20
  const [selected, setSelected] = useState<string>();
20
21
 
21
22
  return (
22
23
  <div className='flex grow justify-center overflow-hidden'>
23
24
  <div className='flex w-[300px] m-4 overflow-hidden'>
24
- <SearchResults {...args} selected={selected} onSelect={setSelected} />
25
+ <SearchResults {...props} selected={selected} onSelect={setSelected} />
25
26
  </div>
26
27
  </div>
27
28
  );
@@ -37,14 +38,7 @@ const objects = Array.from({ length: 100 }).map((_, i) => ({
37
38
 
38
39
  const match = new RegExp(word, 'i');
39
40
 
40
- export const Default = {
41
- args: {
42
- items: filterObjectsSync(objects, match),
43
- match,
44
- },
45
- };
46
-
47
- const meta: Meta<typeof SearchResults> = {
41
+ const meta = {
48
42
  title: 'plugins/plugin-search/SearchResults',
49
43
  component: SearchResults,
50
44
  render: DefaultStory,
@@ -52,6 +46,15 @@ const meta: Meta<typeof SearchResults> = {
52
46
  parameters: {
53
47
  layout: 'fullscreen',
54
48
  },
55
- };
49
+ } satisfies Meta<typeof SearchResults>;
56
50
 
57
51
  export default meta;
52
+
53
+ type Story = StoryObj<typeof meta>;
54
+
55
+ export const Default: Story = {
56
+ args: {
57
+ items: filterObjectsSync(objects, match),
58
+ match,
59
+ },
60
+ };
@@ -43,21 +43,19 @@ export const SearchItem = forwardRef<HTMLDivElement, SearchItemProps>((item, for
43
43
  const { id, objectType, label, snippet, match, selected, onSelect } = item;
44
44
 
45
45
  return (
46
- <Card.Root>
47
- <Card.Content
48
- ref={forwardRef}
49
- classNames={['mx-2 mt-2 cursor-pointer', selected && '!bg-activeSurface', ghostHover]}
50
- onClick={() => onSelect?.(id)}
51
- >
52
- {objectType && (
53
- <>
54
- <div className='text-xs text-neutral-400 ml-4'>{objectType}</div>
55
- </>
56
- )}
57
- <Card.Heading>{label ?? 'Untitled'}</Card.Heading>
58
- {snippet && <Snippet text={snippet} match={match} />}
59
- </Card.Content>
60
- </Card.Root>
46
+ <Card.StaticRoot
47
+ ref={forwardRef}
48
+ classNames={['mx-2 mt-2 cursor-pointer', selected && '!bg-activeSurface', ghostHover]}
49
+ onClick={() => onSelect?.(id)}
50
+ >
51
+ {objectType && (
52
+ <>
53
+ <div className='text-xs text-neutral-400 ml-4'>{objectType}</div>
54
+ </>
55
+ )}
56
+ <Card.Heading>{label ?? 'Untitled'}</Card.Heading>
57
+ {snippet && <Snippet text={snippet} match={match} />}
58
+ </Card.StaticRoot>
61
59
  );
62
60
  });
63
61
 
@@ -4,24 +4,26 @@
4
4
 
5
5
  import '@dxos-theme';
6
6
 
7
- import { type Meta } from '@storybook/react';
7
+ import { type Meta, type StoryObj } from '@storybook/react-vite';
8
8
 
9
9
  import { withTheme } from '@dxos/storybook-utils';
10
10
 
11
- import { Searchbar, type SearchbarProps } from './Searchbar';
11
+ import { Searchbar } from './Searchbar';
12
12
 
13
- const meta: Meta<SearchbarProps> = {
13
+ const meta = {
14
14
  title: 'plugins/plugin-search/Searchbar',
15
15
  component: Searchbar,
16
16
  decorators: [withTheme],
17
17
  parameters: {
18
18
  layout: 'centered',
19
19
  },
20
- };
20
+ } satisfies Meta<typeof Searchbar>;
21
21
 
22
22
  export default meta;
23
23
 
24
- export const Default = {
24
+ type Story = StoryObj<typeof meta>;
25
+
26
+ export const Default: Story = {
25
27
  args: {
26
28
  placeholder: 'Search...',
27
29
  },
@@ -2,11 +2,9 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { MagnifyingGlass } from '@phosphor-icons/react';
6
5
  import React, { type KeyboardEvent, useEffect, useRef, useState } from 'react';
7
6
 
8
- import { Input, type TextInputProps } from '@dxos/react-ui';
9
- import { getSize, mx } from '@dxos/react-ui-theme';
7
+ import { Icon, Input, type TextInputProps } from '@dxos/react-ui';
10
8
 
11
9
  export type SearchbarProps = Pick<TextInputProps, 'variant' | 'placeholder'> & {
12
10
  classes?: {
@@ -54,14 +52,14 @@ export const Searchbar = ({ classes, variant, placeholder, value, onChange, onSu
54
52
  placeholder={placeholder}
55
53
  variant={variant}
56
54
  value={text ?? ''}
57
- classNames={mx('pl-3 pr-10', classes?.input)}
55
+ classNames={['pl-3 pr-10', classes?.input]}
58
56
  onChange={({ target }) => handleChange(target.value)}
59
57
  onKeyDown={handleKeyDown}
60
58
  />
61
59
 
62
60
  {/* TODO(burdon): Margin should be density specific. */}
63
61
  <div role='button' className='-ml-7 p-0 cursor-pointer' onClick={handleReset}>
64
- <MagnifyingGlass className={getSize(5)} />
62
+ <Icon icon='ph--magnifying-glass--regular' size={5} />
65
63
  </div>
66
64
  </Input.Root>
67
65
  </div>
@@ -5,7 +5,7 @@
5
5
  import { describe, expect, test } from 'vitest';
6
6
 
7
7
  import { Client } from '@dxos/client';
8
- import { Obj, Filter, Type } from '@dxos/echo';
8
+ import { Filter, Obj, Type } from '@dxos/echo';
9
9
  import { faker } from '@dxos/random';
10
10
 
11
11
  import { filterObjectsSync } from './sync';
package/src/hooks/sync.ts CHANGED
@@ -63,7 +63,7 @@ export const filterObjectsSync = <T extends Record<string, any>>(objects: T[], m
63
63
  match,
64
64
  // TODO(burdon): Truncate.
65
65
  // TODO(burdon): Issue with sketch documents.
66
- snippet: value !== label ? value : fields.content ?? fields.description ?? undefined,
66
+ snippet: value !== label ? value : (fields.content ?? fields.description ?? undefined),
67
67
  object,
68
68
  });
69
69
 
@@ -2,13 +2,14 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import React, { createContext, type PropsWithChildren, useContext, useMemo, useState } from 'react';
5
+ import React, { type PropsWithChildren, createContext, useContext, useMemo, useState } from 'react';
6
6
 
7
7
  import { raise } from '@dxos/debug';
8
8
 
9
- import { filterObjectsSync, queryStringToMatch } from './sync';
10
9
  import { type SearchResult } from '../types';
11
10
 
11
+ import { filterObjectsSync, queryStringToMatch } from './sync';
12
+
12
13
  type SearchContextType = {
13
14
  match?: RegExp;
14
15
  setMatch?: (text?: string) => void;
@@ -47,14 +47,14 @@ export const useSearchResults = <T extends Record<string, any>>(
47
47
 
48
48
  useEffect(() => {
49
49
  setPending(!!(objects && queryString));
50
- const timeoutId = setTimeout(async () => {
50
+ const timeout = setTimeout(async () => {
51
51
  const nextResults =
52
52
  objects && queryString ? await filterObjects(objects, queryStringToMatch(queryString)) : new Map();
53
53
  setResults(nextResults);
54
54
  setPending(false);
55
55
  }, delay);
56
56
 
57
- return () => clearTimeout(timeoutId);
57
+ return () => clearTimeout(timeout);
58
58
  }, [queryString, objects]);
59
59
 
60
60
  return [pending, results];
@@ -4,23 +4,19 @@
4
4
 
5
5
  import { useState } from 'react';
6
6
 
7
- import { EdgeAiServiceClient } from '@dxos/ai';
8
- import { AI_SERVICE_ENDPOINT, EXA_API_KEY } from '@dxos/ai/testing';
7
+ import { EXA_API_KEY } from '@dxos/ai/testing';
9
8
  import { Obj } from '@dxos/echo';
10
9
  import { type DXN } from '@dxos/keys';
11
10
  import { log } from '@dxos/log';
12
11
  import { getIconAnnotation } from '@dxos/schema';
13
12
  import { Testing } from '@dxos/schema/testing';
14
13
 
15
- import { getStringProperty } from './sync';
16
14
  import { search } from '../search';
17
15
  import { type SearchResult } from '../types';
18
16
 
19
- export const useWebSearch = ({ query, context }: { query?: string; context?: string }) => {
20
- const AiService = new EdgeAiServiceClient({
21
- endpoint: AI_SERVICE_ENDPOINT.REMOTE,
22
- });
17
+ import { getStringProperty } from './sync';
23
18
 
19
+ export const useWebSearch = ({ query, context }: { query?: string; context?: string }) => {
24
20
  const [results, setResults] = useState<SearchResult[]>([]);
25
21
  const [isLoading, setIsLoading] = useState(false);
26
22
 
@@ -32,7 +28,6 @@ export const useWebSearch = ({ query, context }: { query?: string; context?: str
32
28
  query,
33
29
  context,
34
30
  schema: [Testing.Project, Testing.Organization, Testing.Contact],
35
- AiService,
36
31
  exaApiKey: EXA_API_KEY,
37
32
  });
38
33
 
@@ -4,32 +4,19 @@
4
4
 
5
5
  import { describe, test } from 'vitest';
6
6
 
7
- import { EdgeAiServiceClient, OllamaAiServiceClient } from '@dxos/ai';
8
- import { AI_SERVICE_ENDPOINT, EXA_API_KEY } from '@dxos/ai/testing';
7
+ import { EXA_API_KEY } from '@dxos/ai/testing';
9
8
  import { log } from '@dxos/log';
10
9
  import { Testing } from '@dxos/schema/testing';
10
+ import { trim } from '@dxos/util';
11
11
 
12
12
  import { search } from './exa';
13
13
 
14
- const REMOTE_AI = true;
15
-
16
- const AiService = REMOTE_AI
17
- ? new EdgeAiServiceClient({
18
- endpoint: AI_SERVICE_ENDPOINT.REMOTE,
19
- })
20
- : new OllamaAiServiceClient({
21
- overrides: {
22
- model: 'llama3.1:8b',
23
- },
24
- });
25
-
26
14
  describe.skip('Search', () => {
27
15
  describe('Query-based', () => {
28
16
  test.skip('contacts', { timeout: 60_000 }, async () => {
29
17
  const objects = await search({
30
18
  query: 'top executives at google',
31
19
  schema: [Testing.Contact],
32
- AiService,
33
20
  exaApiKey: EXA_API_KEY,
34
21
  });
35
22
 
@@ -40,7 +27,6 @@ describe.skip('Search', () => {
40
27
  const objects = await search({
41
28
  query: 'top executives at google',
42
29
  schema: [Testing.Contact, Testing.Project, Testing.Organization],
43
- AiService,
44
30
  exaApiKey: EXA_API_KEY,
45
31
  });
46
32
 
@@ -51,7 +37,6 @@ describe.skip('Search', () => {
51
37
  const objects = await search({
52
38
  query: 'a19z org, projects they invest in and team',
53
39
  schema: [Testing.Project, Testing.Organization, Testing.Contact],
54
- AiService,
55
40
  exaApiKey: EXA_API_KEY,
56
41
  });
57
42
 
@@ -62,7 +47,6 @@ describe.skip('Search', () => {
62
47
  const objects = await search({
63
48
  query: 'companies building CRDTs',
64
49
  schema: [Testing.Project, Testing.Organization, Testing.Contact],
65
- AiService,
66
50
  exaApiKey: EXA_API_KEY,
67
51
  });
68
52
 
@@ -75,7 +59,6 @@ describe.skip('Search', () => {
75
59
  const objects = await search({
76
60
  context: COMPOSER_DXOS_DOC,
77
61
  schema: [Testing.Project, Testing.Organization, Testing.Contact],
78
- AiService,
79
62
  exaApiKey: EXA_API_KEY,
80
63
  });
81
64
 
@@ -86,7 +69,6 @@ describe.skip('Search', () => {
86
69
  const objects = await search({
87
70
  context: EDGE_ARCHITECTURE_DOC,
88
71
  schema: [Testing.Project, Testing.Organization, Testing.Contact],
89
- AiService,
90
72
  exaApiKey: EXA_API_KEY,
91
73
  });
92
74
 
@@ -96,8 +78,7 @@ describe.skip('Search', () => {
96
78
  });
97
79
 
98
80
  // TODO(dmaretskyi): Import as txt.
99
- const COMPOSER_DXOS_DOC = `
100
-
81
+ const COMPOSER_DXOS_DOC = trim`
101
82
  ![img](https://dxos.network/dxos-logotype-blue.png)
102
83
  # Welcome to Composer by DXOS
103
84
 
@@ -231,6 +212,4 @@ const EDGE_ARCHITECTURE_DOC = `
231
212
  - given the fq id of the deployment object, anyone in the space should be able to invoke the function even if they don't have access to the object itself
232
213
 
233
214
  ### Service Side
234
-
235
-
236
215
  `;