@dxos/shell 0.4.10-main.eedd150 → 0.4.10-main.f15a546

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 (145) hide show
  1. package/dist/bundle/index-AqScakhe.mjs +110 -0
  2. package/dist/bundle/index-AqScakhe.mjs.map +1 -0
  3. package/dist/bundle/index-ClYj8no6.mjs +96625 -0
  4. package/dist/bundle/index-ClYj8no6.mjs.map +1 -0
  5. package/dist/bundle/shell.mjs +9 -81813
  6. package/dist/bundle/shell.mjs.map +1 -1
  7. package/dist/bundle/shell.umd.js +152 -89
  8. package/dist/bundle/shell.umd.js.map +1 -1
  9. package/dist/bundle/style.css +1 -1
  10. package/dist/lib/browser/meta.json +1 -1
  11. package/dist/lib/browser/react.mjs +864 -821
  12. package/dist/lib/browser/react.mjs.map +4 -4
  13. package/dist/lib/browser/testing/index.mjs +7 -4
  14. package/dist/lib/browser/testing/index.mjs.map +3 -3
  15. package/dist/types/src/components/AgentConfig.d.ts +3 -0
  16. package/dist/types/src/components/AgentConfig.d.ts.map +1 -0
  17. package/dist/types/src/components/AgentConfig.js +37 -0
  18. package/dist/types/src/components/AgentConfig.js.map +1 -0
  19. package/dist/types/src/components/DeviceList/DeviceList.d.ts +3 -0
  20. package/dist/types/src/components/DeviceList/DeviceList.d.ts.map +1 -0
  21. package/dist/types/src/components/DeviceList/DeviceList.js +29 -0
  22. package/dist/types/src/components/DeviceList/DeviceList.js.map +1 -0
  23. package/dist/types/src/components/DeviceList/DeviceListItem.d.ts +6 -0
  24. package/dist/types/src/components/DeviceList/DeviceListItem.d.ts.map +1 -0
  25. package/dist/types/src/components/DeviceList/DeviceListItem.js +72 -0
  26. package/dist/types/src/components/DeviceList/DeviceListItem.js.map +1 -0
  27. package/dist/types/src/components/DeviceList/DeviceListProps.d.ts +27 -0
  28. package/dist/types/src/components/DeviceList/DeviceListProps.d.ts.map +1 -0
  29. package/dist/types/src/components/DeviceList/DeviceListProps.js +6 -0
  30. package/dist/types/src/components/DeviceList/DeviceListProps.js.map +1 -0
  31. package/dist/types/src/components/DeviceList/index.d.ts +3 -0
  32. package/dist/types/src/components/DeviceList/index.d.ts.map +1 -0
  33. package/dist/types/src/components/DeviceList/index.js +22 -0
  34. package/dist/types/src/components/DeviceList/index.js.map +1 -0
  35. package/dist/types/src/components/EmojiPicker.d.ts +10 -4
  36. package/dist/types/src/components/EmojiPicker.d.ts.map +1 -1
  37. package/dist/types/src/components/EmojiPicker.js +57 -3
  38. package/dist/types/src/components/EmojiPicker.js.map +1 -1
  39. package/dist/types/src/components/HuePicker.d.ts +10 -4
  40. package/dist/types/src/components/HuePicker.d.ts.map +1 -1
  41. package/dist/types/src/components/HuePicker.js +75 -6
  42. package/dist/types/src/components/HuePicker.js.map +1 -1
  43. package/dist/types/src/components/IdentityList/index.d.ts +0 -1
  44. package/dist/types/src/components/IdentityList/index.d.ts.map +1 -1
  45. package/dist/types/src/components/IdentityList/index.js +0 -1
  46. package/dist/types/src/components/IdentityList/index.js.map +1 -1
  47. package/dist/types/src/components/InvitationList/InvitationListItem.js +5 -5
  48. package/dist/types/src/components/InvitationList/InvitationListItem.js.map +1 -1
  49. package/dist/types/src/components/Panel/Action.d.ts +2 -2
  50. package/dist/types/src/components/Viewport/Viewport.d.ts +1 -1
  51. package/dist/types/src/components/index.d.ts +2 -0
  52. package/dist/types/src/components/index.d.ts.map +1 -1
  53. package/dist/types/src/components/index.js +2 -0
  54. package/dist/types/src/components/index.js.map +1 -1
  55. package/dist/types/src/composites/Shell/Shell.d.ts.map +1 -1
  56. package/dist/types/src/composites/Shell/Shell.js +1 -5
  57. package/dist/types/src/composites/Shell/Shell.js.map +1 -1
  58. package/dist/types/src/panels/IdentityPanel/IdentityPanel.d.ts.map +1 -1
  59. package/dist/types/src/panels/IdentityPanel/IdentityPanel.js +85 -40
  60. package/dist/types/src/panels/IdentityPanel/IdentityPanel.js.map +1 -1
  61. package/dist/types/src/panels/IdentityPanel/IdentityPanel.stories.d.ts +0 -3
  62. package/dist/types/src/panels/IdentityPanel/IdentityPanel.stories.d.ts.map +1 -1
  63. package/dist/types/src/panels/IdentityPanel/IdentityPanel.stories.js +1 -43
  64. package/dist/types/src/panels/IdentityPanel/IdentityPanel.stories.js.map +1 -1
  65. package/dist/types/src/panels/IdentityPanel/IdentityPanelProps.d.ts +8 -11
  66. package/dist/types/src/panels/IdentityPanel/IdentityPanelProps.d.ts.map +1 -1
  67. package/dist/types/src/panels/IdentityPanel/identityMachine.d.ts +1 -1
  68. package/dist/types/src/panels/IdentityPanel/identityMachine.d.ts.map +1 -1
  69. package/dist/types/src/panels/IdentityPanel/identityMachine.js +0 -24
  70. package/dist/types/src/panels/IdentityPanel/identityMachine.js.map +1 -1
  71. package/dist/types/src/panels/IdentityPanel/steps/IdentityActionChooser.d.ts +4 -4
  72. package/dist/types/src/panels/IdentityPanel/steps/IdentityActionChooser.d.ts.map +1 -1
  73. package/dist/types/src/panels/IdentityPanel/steps/IdentityActionChooser.js +9 -43
  74. package/dist/types/src/panels/IdentityPanel/steps/IdentityActionChooser.js.map +1 -1
  75. package/dist/types/src/panels/IdentityPanel/steps/ProfileForm.d.ts +1 -1
  76. package/dist/types/src/panels/IdentityPanel/steps/ProfileForm.d.ts.map +1 -1
  77. package/dist/types/src/panels/IdentityPanel/steps/ProfileForm.js +2 -2
  78. package/dist/types/src/panels/IdentityPanel/steps/ProfileForm.js.map +1 -1
  79. package/dist/types/src/panels/IdentityPanel/steps/index.d.ts +0 -2
  80. package/dist/types/src/panels/IdentityPanel/steps/index.d.ts.map +1 -1
  81. package/dist/types/src/panels/IdentityPanel/steps/index.js +0 -2
  82. package/dist/types/src/panels/IdentityPanel/steps/index.js.map +1 -1
  83. package/dist/types/src/panels/IdentityPanel/useAgentHandlers.d.ts.map +1 -1
  84. package/dist/types/src/panels/IdentityPanel/useAgentHandlers.js +5 -1
  85. package/dist/types/src/panels/IdentityPanel/useAgentHandlers.js.map +1 -1
  86. package/dist/types/src/panels/SpacePanel/steps/SpaceManager.d.ts.map +1 -1
  87. package/dist/types/src/panels/SpacePanel/steps/SpaceManager.js +3 -1
  88. package/dist/types/src/panels/SpacePanel/steps/SpaceManager.js.map +1 -1
  89. package/dist/types/src/playwright/invitations.spec.js +3 -1
  90. package/dist/types/src/playwright/invitations.spec.js.map +1 -1
  91. package/dist/types/src/steps/InvitationManager.d.ts +1 -1
  92. package/dist/types/src/steps/InvitationManager.d.ts.map +1 -1
  93. package/dist/types/src/steps/InvitationManager.js +3 -4
  94. package/dist/types/src/steps/InvitationManager.js.map +1 -1
  95. package/dist/types/src/stories/Invitations.e2e-stories.d.ts.map +1 -1
  96. package/dist/types/src/stories/Invitations.e2e-stories.js +5 -2
  97. package/dist/types/src/stories/Invitations.e2e-stories.js.map +1 -1
  98. package/dist/types/src/testing/shell-manager.d.ts.map +1 -1
  99. package/dist/types/src/testing/shell-manager.js +7 -4
  100. package/dist/types/src/testing/shell-manager.js.map +1 -1
  101. package/dist/types/src/translations/locales/en-US.d.ts +12 -2
  102. package/dist/types/src/translations/locales/en-US.d.ts.map +1 -1
  103. package/dist/types/src/translations/locales/en-US.js +12 -2
  104. package/dist/types/src/translations/locales/en-US.js.map +1 -1
  105. package/package.json +22 -21
  106. package/src/components/AgentConfig.tsx +66 -0
  107. package/src/components/DeviceList/DeviceList.tsx +54 -0
  108. package/src/components/DeviceList/DeviceListItem.tsx +120 -0
  109. package/src/components/DeviceList/DeviceListProps.ts +33 -0
  110. package/src/components/DeviceList/index.ts +6 -0
  111. package/src/components/EmojiPicker.tsx +102 -5
  112. package/src/components/HuePicker.tsx +100 -6
  113. package/src/components/IdentityList/index.ts +0 -1
  114. package/src/components/InvitationList/InvitationListItem.tsx +5 -5
  115. package/src/components/index.ts +2 -0
  116. package/src/composites/Shell/Shell.tsx +1 -7
  117. package/src/panels/IdentityPanel/IdentityPanel.stories.tsx +0 -63
  118. package/src/panels/IdentityPanel/IdentityPanel.tsx +129 -34
  119. package/src/panels/IdentityPanel/IdentityPanelProps.ts +10 -14
  120. package/src/panels/IdentityPanel/identityMachine.ts +1 -31
  121. package/src/panels/IdentityPanel/steps/IdentityActionChooser.tsx +23 -76
  122. package/src/panels/IdentityPanel/steps/ProfileForm.tsx +12 -4
  123. package/src/panels/IdentityPanel/steps/index.ts +0 -2
  124. package/src/panels/IdentityPanel/useAgentHandlers.ts +5 -1
  125. package/src/panels/SpacePanel/steps/SpaceManager.tsx +3 -1
  126. package/src/playwright/invitations.spec.ts +3 -1
  127. package/src/steps/InvitationManager.tsx +4 -4
  128. package/src/stories/Invitations.e2e-stories.tsx +6 -3
  129. package/src/testing/shell-manager.ts +7 -4
  130. package/src/translations/locales/en-US.ts +13 -2
  131. package/dist/types/src/components/IdentityList/DeviceList.d.ts +0 -7
  132. package/dist/types/src/components/IdentityList/DeviceList.d.ts.map +0 -1
  133. package/dist/types/src/components/IdentityList/DeviceList.js +0 -34
  134. package/dist/types/src/components/IdentityList/DeviceList.js.map +0 -1
  135. package/dist/types/src/panels/IdentityPanel/steps/AgentForm.d.ts +0 -3
  136. package/dist/types/src/panels/IdentityPanel/steps/AgentForm.d.ts.map +0 -1
  137. package/dist/types/src/panels/IdentityPanel/steps/AgentForm.js +0 -26
  138. package/dist/types/src/panels/IdentityPanel/steps/AgentForm.js.map +0 -1
  139. package/dist/types/src/panels/IdentityPanel/steps/DeviceManager.d.ts +0 -10
  140. package/dist/types/src/panels/IdentityPanel/steps/DeviceManager.d.ts.map +0 -1
  141. package/dist/types/src/panels/IdentityPanel/steps/DeviceManager.js +0 -23
  142. package/dist/types/src/panels/IdentityPanel/steps/DeviceManager.js.map +0 -1
  143. package/src/components/IdentityList/DeviceList.tsx +0 -49
  144. package/src/panels/IdentityPanel/steps/AgentForm.tsx +0 -61
  145. package/src/panels/IdentityPanel/steps/DeviceManager.tsx +0 -41
@@ -8,7 +8,6 @@ import React from 'react';
8
8
 
9
9
  import { faker } from '@dxos/random';
10
10
  import { PublicKey } from '@dxos/react-client';
11
- import { Device, DeviceKind } from '@dxos/react-client/halo';
12
11
  import { Invitation } from '@dxos/react-client/invitations';
13
12
  import { withTheme } from '@dxos/storybook-utils';
14
13
 
@@ -53,58 +52,6 @@ export const IdentityActionChooser = () => {
53
52
  );
54
53
  };
55
54
 
56
- export const UpdateProfileForm = () => {
57
- return (
58
- <StorybookDialog inOverlayLayout>
59
- <IdentityPanelImpl
60
- {...noOpProps}
61
- activeView='update profile form'
62
- IdentityActionChooser={IdentityActionChooserImpl}
63
- />
64
- </StorybookDialog>
65
- );
66
- };
67
-
68
- export const DeviceManager = () => {
69
- return (
70
- <StorybookDialog inOverlayLayout>
71
- <IdentityPanelImpl
72
- {...{
73
- ...noOpProps,
74
- // TODO(nf): update
75
- devices: [
76
- {
77
- deviceKey: PublicKey.random(),
78
- kind: DeviceKind.CURRENT,
79
- presence: Device.PresenceState.ONLINE,
80
- },
81
- {
82
- deviceKey: PublicKey.random(),
83
- kind: DeviceKind.TRUSTED,
84
- presence: Device.PresenceState.ONLINE,
85
- },
86
- {
87
- deviceKey: PublicKey.random(),
88
- kind: DeviceKind.TRUSTED,
89
- presence: Device.PresenceState.OFFLINE,
90
- },
91
- ],
92
- }}
93
- activeView='device manager'
94
- IdentityActionChooser={IdentityActionChooserImpl}
95
- />
96
- </StorybookDialog>
97
- );
98
- };
99
-
100
- export const DeviceManagerEmpty = () => {
101
- return (
102
- <StorybookDialog inOverlayLayout>
103
- <IdentityPanelImpl {...noOpProps} activeView='device manager' IdentityActionChooser={IdentityActionChooserImpl} />
104
- </StorybookDialog>
105
- );
106
- };
107
-
108
55
  const DeviceInvitationManagerWithState = (extraProps: InvitationManagerProps) => (
109
56
  <StorybookDialog inOverlayLayout>
110
57
  <IdentityPanelImpl
@@ -156,13 +103,3 @@ export const DeviceInvitationManagerCancelled = () =>
156
103
  DeviceInvitationManagerWithState({
157
104
  status: Invitation.State.CANCELLED,
158
105
  });
159
-
160
- // export const IdentityActionChooser = {
161
- // decorators: [ClientDecorator()],
162
- // args: { activeView: 'identity action chooser' },
163
- // };
164
-
165
- // export const DeviceManager = {
166
- // decorators: [ClientDecorator()],
167
- // args: { activeView: 'device manager' },
168
- // };
@@ -1,7 +1,8 @@
1
1
  //
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
- import React, { useEffect, useMemo } from 'react';
4
+ import { CopySimple, Plugs, PlugsConnected } from '@phosphor-icons/react';
5
+ import React, { useEffect, useMemo, useState } from 'react';
5
6
 
6
7
  import { generateName } from '@dxos/display-name';
7
8
  import { log } from '@dxos/log';
@@ -9,8 +10,10 @@ import { useClient } from '@dxos/react-client';
9
10
  import { type Identity, useIdentity, useDevices, useHaloInvitations } from '@dxos/react-client/halo';
10
11
  import { useInvitationStatus } from '@dxos/react-client/invitations';
11
12
  import type { CancellableInvitationObservable } from '@dxos/react-client/invitations';
12
- import { Avatar, DensityProvider, useId, useTranslation } from '@dxos/react-ui';
13
- import { keyToFallback } from '@dxos/util';
13
+ import { useNetworkStatus, ConnectionState } from '@dxos/react-client/mesh';
14
+ import { Avatar, DensityProvider, Input, Toolbar, Tooltip, useId, useTranslation } from '@dxos/react-ui';
15
+ import { getSize } from '@dxos/react-ui-theme';
16
+ import { hexToEmoji, hexToHue, keyToFallback } from '@dxos/util';
14
17
 
15
18
  import {
16
19
  type IdentityPanelHeadingProps,
@@ -18,24 +21,128 @@ import {
18
21
  type IdentityPanelProps,
19
22
  } from './IdentityPanelProps';
20
23
  import { useIdentityMachine } from './identityMachine';
21
- import { AgentForm, DeviceManager, IdentityActionChooser, ProfileForm } from './steps';
24
+ import { IdentityActionChooser } from './steps';
22
25
  import { useAgentHandlers } from './useAgentHandlers';
23
- import { Viewport, Heading, CloseButton } from '../../components';
26
+ import {
27
+ Viewport,
28
+ Heading,
29
+ CloseButton,
30
+ EmojiPickerToolbarButton,
31
+ useClipboardContext,
32
+ HuePickerToolbarButton,
33
+ } from '../../components';
24
34
  import { ConfirmReset, InvitationManager } from '../../steps';
25
35
 
26
36
  const viewStyles = 'pbs-1 pbe-3 pli-3';
27
37
 
28
- const IdentityHeading = ({ titleId, title, identity, onDone }: IdentityPanelHeadingProps) => {
38
+ // TODO(thure): Factor out?
39
+ const getHueValue = (identity?: Identity) =>
40
+ identity?.profile?.data?.hue || hexToHue(identity?.identityKey.toHex() ?? '0');
41
+ const getEmojiValue = (identity?: Identity) =>
42
+ identity?.profile?.data?.emoji || hexToEmoji(identity?.identityKey.toHex() ?? '0');
43
+
44
+ const IdentityHeading = ({
45
+ titleId,
46
+ title,
47
+ identity,
48
+ onDone,
49
+ onUpdateProfile,
50
+ connectionState,
51
+ onChangeConnectionState,
52
+ }: IdentityPanelHeadingProps) => {
29
53
  const fallbackValue = keyToFallback(identity.identityKey);
54
+ const { t } = useTranslation('os');
55
+ const [displayName, setDisplayName] = useState(identity.profile?.displayName ?? '');
56
+ const [emoji, setEmojiDirectly] = useState<string>(getEmojiValue(identity));
57
+ const [hue, setHueDirectly] = useState<string>(getHueValue(identity));
58
+ const { textValue, setTextValue } = useClipboardContext();
59
+ const identityHex = identity.identityKey.toHex();
60
+ const copied = textValue === identityHex;
61
+
62
+ const handleUpdateProfile = async () => {
63
+ const nextProfile = {
64
+ ...(displayName && { displayName }),
65
+ ...((emoji || hue) && { data: { ...(emoji && { emoji }), ...(hue && { hue }) } }),
66
+ };
67
+ return onUpdateProfile?.(nextProfile);
68
+ };
69
+
70
+ const setEmoji = (nextEmoji: string) => {
71
+ setEmojiDirectly(nextEmoji);
72
+ void handleUpdateProfile();
73
+ };
74
+
75
+ const setHue = (nextHue: string) => {
76
+ setHueDirectly(nextHue);
77
+ void handleUpdateProfile();
78
+ };
79
+
80
+ const isConnected = connectionState === ConnectionState.ONLINE;
81
+
30
82
  return (
31
83
  <Heading titleId={titleId} title={title} corner={<CloseButton onDone={onDone} />}>
32
- <Avatar.Root size={12} variant='circle' status='active' hue={identity.profile?.data?.hue || fallbackValue.hue}>
33
- <Avatar.Frame classNames='block mbs-4 mbe-2 mli-auto chromatic-ignore'>
34
- <Avatar.Fallback text={identity.profile?.data?.emoji || fallbackValue.emoji} />
35
- </Avatar.Frame>
36
- <Avatar.Label classNames='block text-center font-light text-xl' data-testid='identityHeading.displayName'>
84
+ <Avatar.Root size={16} variant='circle' status={isConnected ? 'active' : 'error'} hue={hue || fallbackValue.hue}>
85
+ <Toolbar.Root classNames='grid grid-cols-[1fr_var(--rail-action)_min-content_var(--rail-action)_1fr] items-center gap-2'>
86
+ <Tooltip.Root>
87
+ <Tooltip.Trigger asChild>
88
+ <Toolbar.Button
89
+ classNames='bs-[--rail-action] is-[--rail-action] justify-self-end'
90
+ onClick={() =>
91
+ onChangeConnectionState?.(isConnected ? ConnectionState.OFFLINE : ConnectionState.ONLINE)
92
+ }
93
+ >
94
+ <span className='sr-only'>{t(isConnected ? 'disconnect label' : 'connect label')}</span>
95
+ {isConnected ? <PlugsConnected className={getSize(5)} /> : <Plugs className={getSize(5)} />}
96
+ </Toolbar.Button>
97
+ </Tooltip.Trigger>
98
+ <Tooltip.Portal>
99
+ <Tooltip.Content side='bottom' classNames='z-50'>
100
+ {t(isConnected ? 'disconnect label' : 'connect label')}
101
+ <Tooltip.Arrow />
102
+ </Tooltip.Content>
103
+ </Tooltip.Portal>
104
+ </Tooltip.Root>
105
+ <EmojiPickerToolbarButton emoji={emoji} onChangeEmoji={setEmoji} classNames='bs-[--rail-action]' />
106
+ <Avatar.Frame classNames='relative z-[2] -mli-4 chromatic-ignore'>
107
+ <Avatar.Fallback text={emoji || fallbackValue.emoji} />
108
+ </Avatar.Frame>
109
+ <HuePickerToolbarButton hue={hue} onChangeHue={setHue} classNames='bs-[--rail-action]' />
110
+ <Tooltip.Root>
111
+ <Tooltip.Trigger asChild>
112
+ <Toolbar.Button
113
+ classNames='bs-[--rail-action] justify-self-start'
114
+ data-testid='update-profile-form-copy-key'
115
+ onClick={() => setTextValue(identityHex)}
116
+ >
117
+ <span className='sr-only'>{t(copied ? 'copy success label' : 'copy self public key label')}</span>
118
+ <CopySimple className={getSize(5)} />
119
+ </Toolbar.Button>
120
+ </Tooltip.Trigger>
121
+ <Tooltip.Portal>
122
+ <Tooltip.Content side='bottom' classNames='z-50'>
123
+ {t(copied ? 'copy success label' : 'copy self public key label')}
124
+ <Tooltip.Arrow />
125
+ </Tooltip.Content>
126
+ </Tooltip.Portal>
127
+ </Tooltip.Root>
128
+ </Toolbar.Root>
129
+ <Avatar.Label classNames='sr-only' data-testid='identityHeading.displayName'>
37
130
  {identity.profile?.displayName ?? generateName(identity.identityKey.toHex())}
38
131
  </Avatar.Label>
132
+ <Input.Root>
133
+ <Input.Label srOnly>{t('display name input label')}</Input.Label>
134
+ <Input.TextInput
135
+ variant='subdued'
136
+ data-testid='display-name-input'
137
+ placeholder={t('display name input placeholder')}
138
+ classNames='mbs-2 text-center font-light text-xl'
139
+ value={displayName}
140
+ onChange={({ target: { value } }) => {
141
+ setDisplayName(value);
142
+ }}
143
+ onBlur={handleUpdateProfile}
144
+ />
145
+ </Input.Root>
39
146
  </Avatar.Root>
40
147
  </Heading>
41
148
  );
@@ -51,14 +158,14 @@ export const IdentityPanelImpl = (props: IdentityPanelImplProps) => {
51
158
  onJoinNewIdentity,
52
159
  IdentityActionChooser: IdentityActionChooserComponent = IdentityActionChooser,
53
160
  InvitationManager: InvitationManagerComponent = InvitationManager,
161
+ connectionState,
162
+ onChangeConnectionState,
54
163
  onDone,
55
164
  ...rest
56
165
  } = props;
57
166
  const { t } = useTranslation('os');
58
167
  const title = useMemo(() => {
59
168
  switch (activeView) {
60
- case 'agent manager':
61
- return 'Manage Agent';
62
169
  case 'device invitation manager':
63
170
  return t('choose add device label');
64
171
  default:
@@ -70,7 +177,9 @@ export const IdentityPanelImpl = (props: IdentityPanelImplProps) => {
70
177
 
71
178
  return (
72
179
  <DensityProvider density='fine'>
73
- <IdentityHeading {...{ identity, titleId, title, onDone }} />
180
+ <IdentityHeading
181
+ {...{ identity, titleId, title, onDone, onUpdateProfile, connectionState, onChangeConnectionState }}
182
+ />
74
183
  <Viewport.Root activeView={activeView}>
75
184
  <Viewport.Views>
76
185
  <Viewport.View id='identity action chooser' classNames={viewStyles}>
@@ -83,20 +192,6 @@ export const IdentityPanelImpl = (props: IdentityPanelImplProps) => {
83
192
  invitationUrl={rest.createInvitationUrl(rest.invitationCode!)}
84
193
  />
85
194
  </Viewport.View>
86
- <Viewport.View id='device manager' classNames={viewStyles}>
87
- <DeviceManager active={activeView === 'device manager'} {...rest} />
88
- </Viewport.View>
89
- <Viewport.View classNames={viewStyles} id='update profile form'>
90
- <ProfileForm
91
- send={rest.send}
92
- active={activeView === 'update profile form'}
93
- identity={identity}
94
- onUpdateProfile={onUpdateProfile}
95
- />
96
- </Viewport.View>
97
- <Viewport.View classNames={viewStyles} id='agent manager'>
98
- <AgentForm send={rest.send} active={activeView === 'agent manager'} {...rest} />
99
- </Viewport.View>
100
195
  <Viewport.View classNames={viewStyles} id='confirm join new identity'>
101
196
  <ConfirmReset
102
197
  active={activeView === 'confirm join new identity'}
@@ -149,6 +244,10 @@ export const IdentityPanel = ({
149
244
  context: { initialDisposition },
150
245
  });
151
246
 
247
+ const { swarm: connectionState } = useNetworkStatus();
248
+
249
+ const handleChangeConnectionState = async (nextState: ConnectionState) => client?.mesh.updateConfig(nextState);
250
+
152
251
  useEffect(() => {
153
252
  const subscription = identityService.subscribe((state) => {
154
253
  log('[state]', state);
@@ -163,16 +262,10 @@ export const IdentityPanel = ({
163
262
  return 'identity action chooser';
164
263
  case identityState.matches('managingDeviceInvitation'):
165
264
  return 'device invitation manager';
166
- case identityState.matches('managingDevices'):
167
- return 'device manager';
168
- case [{ managingProfile: 'idle' }, { managingProfile: 'pending' }].some(identityState.matches):
169
- return 'update profile form';
170
265
  case identityState.matches('confirmingResetStorage'):
171
266
  return 'confirm reset storage';
172
267
  case identityState.matches('confirmingJoinNewIdentity'):
173
268
  return 'confirm join new identity';
174
- case [{ managingAgent: 'idle' }, { managingAgent: 'pending' }].some(identityState.matches):
175
- return 'agent manager';
176
269
  default:
177
270
  return 'identity action chooser';
178
271
  }
@@ -192,6 +285,8 @@ export const IdentityPanel = ({
192
285
  titleId,
193
286
  createInvitationUrl,
194
287
  onUpdateProfile,
288
+ connectionState,
289
+ onChangeConnectionState: handleChangeConnectionState,
195
290
  ...agentProps,
196
291
  } satisfies IdentityPanelImplProps;
197
292
 
@@ -7,27 +7,17 @@ import type { Event, SingleOrArray } from 'xstate';
7
7
 
8
8
  import type { Device, Identity } from '@dxos/react-client/halo';
9
9
  import type { InvitationStatus } from '@dxos/react-client/invitations';
10
+ import type { ConnectionState } from '@dxos/react-client/mesh';
10
11
 
11
12
  import type { IdentityEvent } from './identityMachine';
13
+ import { type AgentFormProps } from '../../components';
12
14
  import type { InvitationManagerProps } from '../../steps';
13
15
 
14
- export type IdentityPanelInitialDisposition = 'default' | 'manage-device-invitation' | 'manage-profile';
15
-
16
- export type AgentFormProps = {
17
- onAgentCreate?: () => Promise<void>;
18
- onAgentDestroy?: () => Promise<void>;
19
- agentStatus?: string;
20
- agentActive?: boolean;
21
- agentProviderDisabled?: boolean;
22
- validationMessage?: string;
23
- };
16
+ export type IdentityPanelInitialDisposition = 'default' | 'manage-device-invitation';
24
17
 
25
18
  export type IdentityPanelImplProps = {
26
19
  titleId: string;
27
20
  activeView:
28
- | 'device manager'
29
- | 'agent manager'
30
- | 'update profile form'
31
21
  | 'device invitation manager'
32
22
  | 'identity action chooser'
33
23
  | 'confirm join new identity'
@@ -35,6 +25,8 @@ export type IdentityPanelImplProps = {
35
25
  initialDisposition?: IdentityPanelInitialDisposition;
36
26
  identity: Identity;
37
27
  devices: Device[];
28
+ connectionState?: ConnectionState;
29
+ onChangeConnectionState?: (nextState: ConnectionState) => Promise<void>;
38
30
  onUpdateProfile?: (profile: NonNullable<Identity['profile']>) => Promise<void>;
39
31
  onResetStorage?: () => Promise<void>;
40
32
  onJoinNewIdentity?: () => Promise<void>;
@@ -50,11 +42,15 @@ export type IdentityPanelImplProps = {
50
42
 
51
43
  export type IdentityPanelProps = Partial<Omit<IdentityPanelImplProps, 'send' | 'activeView' | 'identity'>>;
52
44
 
53
- export type IdentityPanelHeadingProps = Pick<IdentityPanelImplProps, 'titleId' | 'identity' | 'onDone'> & {
45
+ export type IdentityPanelHeadingProps = Pick<
46
+ IdentityPanelImplProps,
47
+ 'titleId' | 'identity' | 'onDone' | 'onUpdateProfile' | 'connectionState' | 'onChangeConnectionState'
48
+ > & {
54
49
  title: string;
55
50
  };
56
51
 
57
52
  export type IdentityPanelStepProps = Pick<IdentityPanelImplProps, 'send' | 'onDone' | 'doneActionParent'> & {
58
53
  active?: boolean;
59
54
  agentHostingEnabled?: boolean;
55
+ devices: Device[];
60
56
  };
@@ -21,13 +21,7 @@ type IdentityMachineContext = {
21
21
  };
22
22
 
23
23
  type IdentityChooseActionEvent = {
24
- type:
25
- | 'chooseDevices'
26
- | 'chooseAgent'
27
- | 'chooseProfile'
28
- | 'chooseResetStorage'
29
- | 'chooseJoinNewIdentity'
30
- | 'unchooseAction';
24
+ type: 'chooseResetStorage' | 'chooseJoinNewIdentity' | 'unchooseAction';
31
25
  };
32
26
 
33
27
  type IdentitySelectDeviceInvitationEvent = {
@@ -67,31 +61,11 @@ const identityMachine = createMachine<IdentityMachineContext, IdentityEvent>(
67
61
  unknown: {
68
62
  always: [
69
63
  { cond: 'initiallyManagingDeviceInvitation', target: 'managingDeviceInvitation', actions: 'log' },
70
- { cond: 'initiallyManagingProfile', target: 'managingProfile', actions: 'log' },
71
64
  { target: 'choosingAction', actions: 'log' },
72
65
  ],
73
66
  },
74
67
  choosingAction: {},
75
68
  managingDeviceInvitation: {},
76
- managingAgent: {
77
- initial: 'idle',
78
- states: {
79
- idle: {},
80
- pending: {},
81
- },
82
- },
83
- managingDevices: {},
84
- managingProfile: {
85
- initial: 'idle',
86
- states: {
87
- idle: {},
88
- pending: {},
89
- },
90
- on: {
91
- setIdentity: { target: 'choosingAction', actions: ['setIdentity', 'log'] },
92
- updateProfile: { target: '.pending', actions: 'log' },
93
- },
94
- },
95
69
  confirmingResetStorage: {},
96
70
  confirmingJoinNewIdentity: {},
97
71
  },
@@ -99,18 +73,14 @@ const identityMachine = createMachine<IdentityMachineContext, IdentityEvent>(
99
73
  unchooseAction: { target: '.choosingAction', actions: ['unsetInvitation', 'log'] },
100
74
  deselectInvitation: { target: '.choosingAction', actions: ['unsetInvitation', 'log'] },
101
75
  selectInvitation: { target: '.managingDeviceInvitation', actions: ['setInvitation', 'log'] },
102
- chooseDevices: { target: '.managingDevices', actions: 'log' },
103
- chooseProfile: { target: '.managingProfile', actions: 'log' },
104
76
  chooseJoinNewIdentity: { target: '.confirmingJoinNewIdentity', actions: 'log' },
105
77
  chooseResetStorage: { target: '.confirmingResetStorage', actions: 'log' },
106
- chooseAgent: { target: '.managingAgent', actions: 'log' },
107
78
  },
108
79
  },
109
80
  {
110
81
  guards: {
111
82
  initiallyManagingDeviceInvitation: ({ initialDisposition }, _event) =>
112
83
  initialDisposition === 'manage-device-invitation',
113
- initiallyManagingProfile: ({ initialDisposition }, _event) => initialDisposition === 'manage-profile',
114
84
  },
115
85
  actions: {
116
86
  setIdentity: assign<IdentityMachineContext, IdentityEvent>({
@@ -2,17 +2,14 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { CaretRight, Devices, Plus, Power, UserGear, HardDrive, Intersect } from '@phosphor-icons/react';
6
5
  import React, { useCallback } from 'react';
7
6
 
8
7
  import { log } from '@dxos/log';
9
8
  import { useAgentHostingProviderClient, useClient } from '@dxos/react-client';
10
9
  import { useHaloInvitations } from '@dxos/react-client/halo';
11
10
  import { Invitation, InvitationEncoder } from '@dxos/react-client/invitations';
12
- import { DensityProvider, useTranslation } from '@dxos/react-ui';
13
- import { getSize } from '@dxos/react-ui-theme';
14
11
 
15
- import { Action } from '../../../components';
12
+ import { AgentConfig, type AgentFormProps, DeviceList } from '../../../components';
16
13
  import { type IdentityPanelStepProps } from '../IdentityPanelProps';
17
14
 
18
15
  export type IdentityActionChooserProps = IdentityPanelStepProps;
@@ -28,13 +25,10 @@ export const IdentityActionChooser = (props: IdentityPanelStepProps) => {
28
25
  log.info(JSON.stringify({ invitationCode, authCode: invitation.authCode }));
29
26
  }
30
27
  }, []);
31
- const createInvitation = (e: React.MouseEvent) => {
32
- const testing = e.altKey && e.shiftKey;
28
+ const createInvitation = () => {
33
29
  invitations.forEach((invitation) => invitation.cancel());
34
30
  // TODO(nf): allow user to make invitations non-persistent?
35
- const invitation = client.halo.share(
36
- testing ? { type: Invitation.Type.MULTIUSE, authMethod: Invitation.AuthMethod.NONE } : undefined,
37
- );
31
+ const invitation = client.halo.share();
38
32
  // TODO(wittjosiah): Don't depend on NODE_ENV.
39
33
  if (process.env.NODE_ENV !== 'production') {
40
34
  invitation.subscribe(onInvitationEvent);
@@ -44,83 +38,36 @@ export const IdentityActionChooser = (props: IdentityPanelStepProps) => {
44
38
  return (
45
39
  <IdentityActionChooserImpl
46
40
  {...props}
47
- onCreateInvitationClick={(e) => createInvitation(e)}
41
+ onCreateInvitationClick={createInvitation}
48
42
  agentHostingEnabled={!!agentHostingProviderClient}
49
43
  />
50
44
  );
51
45
  };
52
46
 
53
- export type IdentityActionChooserImplProps = IdentityActionChooserProps & {
54
- onCreateInvitationClick?: (e: React.MouseEvent) => void;
55
- };
47
+ export type IdentityActionChooserImplProps = IdentityActionChooserProps &
48
+ Partial<AgentFormProps> & {
49
+ onCreateInvitationClick?: () => void;
50
+ };
56
51
 
57
52
  export const IdentityActionChooserImpl = ({
58
- onCreateInvitationClick,
59
- active,
60
53
  send,
61
- onDone,
62
- doneActionParent,
54
+ onCreateInvitationClick,
55
+ devices,
56
+ onAgentDestroy,
57
+ onAgentCreate,
58
+ agentStatus,
59
+ agentActive,
63
60
  agentHostingEnabled,
64
61
  }: IdentityActionChooserImplProps) => {
65
- const { t } = useTranslation('os');
66
-
67
- // const doneAction = (
68
- // <PanelAction aria-label={t('done label')} onClick={onDone} disabled={!active} data-testid='identity-panel-done'>
69
- // <Check weight='light' className={getSize(6)} />
70
- // </PanelAction>
71
- // );
72
62
  return (
73
- <div role='none' className='grow flex flex-col gap-1'>
74
- <DensityProvider density='coarse'>
75
- <div className='grow justify-center flex flex-col gap-1'>
76
- <Action data-testid='manage-profile' onClick={() => send?.({ type: 'chooseProfile' })} classNames='plb-4'>
77
- <UserGear className={getSize(6)} />
78
- <span className='grow mli-3'>{t('choose profile label')}</span>
79
- <CaretRight weight='bold' className={getSize(4)} />
80
- </Action>
81
- {agentHostingEnabled && (
82
- <Action data-testid='manage-agent' onClick={() => send?.({ type: 'chooseAgent' })} classNames='plb-4'>
83
- <HardDrive className={getSize(6)} />
84
- <span className='grow mli-3'>Manage Agent</span>
85
- <CaretRight weight='bold' className={getSize(4)} />
86
- </Action>
87
- )}
88
- <Action
89
- disabled={!active}
90
- data-testid='devices-panel.create-invitation'
91
- onClick={onCreateInvitationClick}
92
- classNames='plb-4'
93
- >
94
- <Plus className={getSize(6)} />
95
- <span className='grow mli-3'>{t('choose add device label')}</span>
96
- <CaretRight weight='bold' className={getSize(4)} />
97
- </Action>
98
- <Action
99
- data-testid='devices-panel.join-new-identity'
100
- onClick={() => send?.({ type: 'chooseJoinNewIdentity' })}
101
- classNames='plb-4'
102
- >
103
- <Intersect className={getSize(6)} />
104
- <span className='grow mli-3'>{t('choose join new identity label')}</span>
105
- <CaretRight weight='bold' className={getSize(4)} />
106
- </Action>
107
- <Action data-testid='manage-devices' onClick={() => send?.({ type: 'chooseDevices' })} classNames='plb-4'>
108
- <Devices className={getSize(6)} />
109
- <span className='grow mli-3'>{t('choose devices label')}</span>
110
- <CaretRight weight='bold' className={getSize(4)} />
111
- </Action>
112
- <Action
113
- data-testid='devices-panel.sign-out'
114
- onClick={() => send?.({ type: 'chooseResetStorage' })}
115
- classNames='plb-4'
116
- >
117
- <Power className={getSize(6)} />
118
- <span className='grow mli-3'>{t('choose sign out label')}</span>
119
- <CaretRight weight='bold' className={getSize(4)} />
120
- </Action>
121
- </div>
122
- </DensityProvider>
123
- {/* <PanelActions>{doneActionParent ? cloneElement(doneActionParent, {}, doneAction) : doneAction}</PanelActions> */}
124
- </div>
63
+ <>
64
+ <DeviceList
65
+ devices={devices}
66
+ onClickAdd={onCreateInvitationClick}
67
+ onClickJoinExisting={() => send?.({ type: 'chooseJoinNewIdentity' })}
68
+ onClickReset={() => send?.({ type: 'chooseResetStorage' })}
69
+ />
70
+ {agentHostingEnabled && <AgentConfig {...{ agentActive, agentStatus, onAgentDestroy, onAgentCreate }} />}
71
+ </>
125
72
  );
126
73
  };
@@ -10,11 +10,19 @@ import { type Identity } from '@dxos/react-client/halo';
10
10
  import { useTranslation } from '@dxos/react-ui';
11
11
  import { hexToEmoji, hexToHue } from '@dxos/util';
12
12
 
13
- import { Action, Actions, StepHeading, Input, useClipboardContext, EmojiPicker, HuePicker } from '../../../components';
13
+ import {
14
+ Action,
15
+ Actions,
16
+ StepHeading,
17
+ Input,
18
+ useClipboardContext,
19
+ EmojiPickerBlock,
20
+ HuePickerBlock,
21
+ } from '../../../components';
14
22
  import { type IdentityPanelStepProps } from '../IdentityPanelProps';
15
23
  import { type IdentityEvent } from '../identityMachine';
16
24
 
17
- export interface ProfileFormProps extends Omit<IdentityPanelStepProps, 'send'> {
25
+ export interface ProfileFormProps extends Omit<IdentityPanelStepProps, 'send' | 'devices'> {
18
26
  send?: (event: SingleOrArray<Event<IdentityEvent>>) => void;
19
27
  onUpdateProfile?: (profile: NonNullable<Identity['profile']>) => Promise<void>;
20
28
  identity?: Identity;
@@ -68,13 +76,13 @@ const ProfileFormImpl = (props: ProfileFormImplProps) => {
68
76
  />
69
77
  <StepHeading className='mbe-2'>{t('emoji and color label')}</StepHeading>
70
78
  <div role='none' className='grid grid-cols-[1fr_min-content] gap-y-2'>
71
- <EmojiPicker
79
+ <EmojiPickerBlock
72
80
  emoji={emoji}
73
81
  onChangeEmoji={setEmoji}
74
82
  disabled={disabled}
75
83
  onClickClear={() => setEmoji(getEmojiValue(identity))}
76
84
  />
77
- <HuePicker
85
+ <HuePickerBlock
78
86
  hue={hue}
79
87
  onChangeHue={setHue}
80
88
  disabled={disabled}
@@ -2,7 +2,5 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- export * from './AgentForm';
6
- export * from './DeviceManager';
7
5
  export * from './IdentityActionChooser';
8
6
  export * from './ProfileForm';
@@ -67,7 +67,11 @@ export const useAgentHandlers = ({
67
67
  invitations.forEach((invitation) => invitation.cancel());
68
68
 
69
69
  // TODO(nf): do this work in the hosting provider client?
70
- const invitation = client.halo.share({ type: Invitation.Type.MULTIUSE, authMethod: Invitation.AuthMethod.NONE });
70
+ const invitation = client.halo.share({
71
+ type: Invitation.Type.INTERACTIVE,
72
+ authMethod: Invitation.AuthMethod.NONE,
73
+ multiUse: true,
74
+ });
71
75
 
72
76
  invitation.subscribe(handleAgentCreate);
73
77
  };
@@ -59,6 +59,7 @@ export const SpaceManager = (props: SpaceManagerProps) => {
59
59
  const invitation = space.share?.({
60
60
  type: Invitation.Type.INTERACTIVE,
61
61
  authMethod: Invitation.AuthMethod.SHARED_SECRET,
62
+ multiUse: false,
62
63
  target,
63
64
  });
64
65
  if (invitation && config.values.runtime?.app?.env?.DX_ENVIRONMENT !== 'production') {
@@ -72,8 +73,9 @@ export const SpaceManager = (props: SpaceManagerProps) => {
72
73
  icon: UsersThree,
73
74
  onClick: useCallback(() => {
74
75
  const invitation = space.share?.({
75
- type: Invitation.Type.MULTIUSE,
76
+ type: Invitation.Type.INTERACTIVE,
76
77
  authMethod: Invitation.AuthMethod.NONE,
78
+ multiUse: true,
77
79
  target,
78
80
  });
79
81
  if (invitation && config.values.runtime?.app?.env?.DX_ENVIRONMENT !== 'production') {