@dxos/shell 0.3.11-main.0ac3ef5 → 0.3.11-main.0b0bfb1

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 (51) hide show
  1. package/dist/bundle/shell.mjs +6607 -6455
  2. package/dist/bundle/shell.mjs.map +1 -1
  3. package/dist/bundle/shell.umd.js +59 -59
  4. package/dist/bundle/shell.umd.js.map +1 -1
  5. package/dist/bundle/style.css +1 -1
  6. package/dist/lib/browser/meta.json +1 -1
  7. package/dist/lib/browser/react.mjs +653 -414
  8. package/dist/lib/browser/react.mjs.map +4 -4
  9. package/dist/types/src/components/Panel/Action.js +1 -1
  10. package/dist/types/src/components/Panel/Action.js.map +1 -1
  11. package/dist/types/src/composites/Shell/Shell.d.ts.map +1 -1
  12. package/dist/types/src/composites/Shell/Shell.js +5 -1
  13. package/dist/types/src/composites/Shell/Shell.js.map +1 -1
  14. package/dist/types/src/panels/IdentityPanel/IdentityPanel.d.ts.map +1 -1
  15. package/dist/types/src/panels/IdentityPanel/IdentityPanel.js +12 -8
  16. package/dist/types/src/panels/IdentityPanel/IdentityPanel.js.map +1 -1
  17. package/dist/types/src/panels/IdentityPanel/IdentityPanelProps.d.ts +3 -1
  18. package/dist/types/src/panels/IdentityPanel/IdentityPanelProps.d.ts.map +1 -1
  19. package/dist/types/src/panels/IdentityPanel/identityMachine.d.ts +1 -1
  20. package/dist/types/src/panels/IdentityPanel/identityMachine.d.ts.map +1 -1
  21. package/dist/types/src/panels/IdentityPanel/identityMachine.js +10 -2
  22. package/dist/types/src/panels/IdentityPanel/identityMachine.js.map +1 -1
  23. package/dist/types/src/panels/IdentityPanel/steps/AgentPanel.d.ts +19 -0
  24. package/dist/types/src/panels/IdentityPanel/steps/AgentPanel.d.ts.map +1 -0
  25. package/dist/types/src/panels/IdentityPanel/steps/AgentPanel.js +122 -0
  26. package/dist/types/src/panels/IdentityPanel/steps/AgentPanel.js.map +1 -0
  27. package/dist/types/src/panels/IdentityPanel/steps/IdentityActionChooser.js +5 -1
  28. package/dist/types/src/panels/IdentityPanel/steps/IdentityActionChooser.js.map +1 -1
  29. package/dist/types/src/panels/IdentityPanel/steps/SignOutChooser.d.ts +16 -0
  30. package/dist/types/src/panels/IdentityPanel/steps/SignOutChooser.d.ts.map +1 -0
  31. package/dist/types/src/panels/IdentityPanel/steps/SignOutChooser.js +40 -0
  32. package/dist/types/src/panels/IdentityPanel/steps/SignOutChooser.js.map +1 -0
  33. package/dist/types/src/panels/IdentityPanel/steps/index.d.ts +2 -0
  34. package/dist/types/src/panels/IdentityPanel/steps/index.d.ts.map +1 -1
  35. package/dist/types/src/panels/IdentityPanel/steps/index.js +2 -0
  36. package/dist/types/src/panels/IdentityPanel/steps/index.js.map +1 -1
  37. package/dist/types/src/translations/locales/en-US.d.ts +5 -0
  38. package/dist/types/src/translations/locales/en-US.d.ts.map +1 -1
  39. package/dist/types/src/translations/locales/en-US.js +5 -0
  40. package/dist/types/src/translations/locales/en-US.js.map +1 -1
  41. package/package.json +18 -17
  42. package/src/components/Panel/Action.tsx +1 -1
  43. package/src/composites/Shell/Shell.tsx +7 -1
  44. package/src/panels/IdentityPanel/IdentityPanel.tsx +21 -9
  45. package/src/panels/IdentityPanel/IdentityPanelProps.ts +9 -1
  46. package/src/panels/IdentityPanel/identityMachine.ts +11 -3
  47. package/src/panels/IdentityPanel/steps/AgentPanel.tsx +165 -0
  48. package/src/panels/IdentityPanel/steps/IdentityActionChooser.tsx +7 -7
  49. package/src/panels/IdentityPanel/steps/SignOutChooser.tsx +82 -0
  50. package/src/panels/IdentityPanel/steps/index.ts +2 -0
  51. package/src/translations/locales/en-US.ts +5 -0
@@ -1 +1 @@
1
- {"version":3,"file":"en-US.js","sourceRoot":"","sources":["../../../../../src/translations/locales/en-US.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;;;AAEW,QAAA,EAAE,GAAG;IAChB,sBAAsB,EAAE,iBAAiB;IACzC,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A2B,EAAE,SAAS;IACtC,qBAAqB,EAAE,kBAAkB;IACzC,mBAAmB,EAAE,sDAAsD;IAC3E,0BAA0B,EAAE,cAAc;IAC1C,gCAAgC,EAAE,sBAAsB;IACxD,kBAAkB,EAAE,YAAY;IAChC,wBAAwB,EAAE,yBAAyB;IACnD,qBAAqB,EAAE,YAAY;IACnC,4BAA4B,EAAE,8BAA8B;IAC5D,mBAAmB,EAAE,aAAa;IAClC,yBAAyB,EAAE,gCAAgC;IAC3D,sBAAsB,EAAE,cAAc;IACtC,6BAA6B,EAAE,gCAAgC;IAC/D,sBAAsB,EAAE,kCAAkC;IAC1D,eAAe,EAAE,SAAS;IAC1B,4BAA4B,EAC1B,0GAA0G;IAC5G,kCAAkC,EAAE,2BAA2B;IAC/D,oBAAoB,EAAE,SAAS;IAC/B,wBAAwB,EAAE,aAAa;IACvC,0BAA0B,EAAE,yEAAyE;IACrG,yBAAyB,EAAE,qBAAqB;IAChD,oBAAoB,EAAE,cAAc;IACpC,8BAA8B,EAAE,oEAAoE;CACrG,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/shell",
3
- "version": "0.3.11-main.0ac3ef5",
3
+ "version": "0.3.11-main.0b0bfb1",
4
4
  "description": "DXOS’s OS experiences",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -39,18 +39,19 @@
39
39
  "react-qr-rounded": "^1.0.0",
40
40
  "url-join": "^5.0.0",
41
41
  "xstate": "^4.37.0",
42
- "@dxos/client-services": "0.3.11-main.0ac3ef5",
43
- "@dxos/debug": "0.3.11-main.0ac3ef5",
44
- "@dxos/client-protocol": "0.3.11-main.0ac3ef5",
45
- "@dxos/display-name": "0.3.11-main.0ac3ef5",
46
- "@dxos/async": "0.3.11-main.0ac3ef5",
47
- "@dxos/log": "0.3.11-main.0ac3ef5",
48
- "@dxos/react-client": "0.3.11-main.0ac3ef5",
49
- "@dxos/react-ui": "0.3.11-main.0ac3ef5",
50
- "@dxos/react-ui-theme": "0.3.11-main.0ac3ef5",
51
- "@dxos/react-ui-types": "0.3.11-main.0ac3ef5",
52
- "@dxos/rpc-tunnel": "0.3.11-main.0ac3ef5",
53
- "@dxos/util": "0.3.11-main.0ac3ef5"
42
+ "@dxos/async": "0.3.11-main.0b0bfb1",
43
+ "@dxos/client-protocol": "0.3.11-main.0b0bfb1",
44
+ "@dxos/client-services": "0.3.11-main.0b0bfb1",
45
+ "@dxos/display-name": "0.3.11-main.0b0bfb1",
46
+ "@dxos/debug": "0.3.11-main.0b0bfb1",
47
+ "@dxos/log": "0.3.11-main.0b0bfb1",
48
+ "@dxos/react-client": "0.3.11-main.0b0bfb1",
49
+ "@dxos/react-ui": "0.3.11-main.0b0bfb1",
50
+ "@dxos/react-ui-theme": "0.3.11-main.0b0bfb1",
51
+ "@dxos/react-ui-types": "0.3.11-main.0b0bfb1",
52
+ "@dxos/rpc-tunnel": "0.3.11-main.0b0bfb1",
53
+ "@dxos/util": "0.3.11-main.0b0bfb1",
54
+ "@dxos/invariant": "0.3.11-main.0b0bfb1"
54
55
  },
55
56
  "devDependencies": {
56
57
  "@faker-js/faker": "^8.0.2",
@@ -63,10 +64,10 @@
63
64
  "react-dom": "^18.2.0",
64
65
  "vite": "^4.3.9",
65
66
  "vite-plugin-turbosnap": "^1.0.2",
66
- "@dxos/react-async": "0.3.11-main.0ac3ef5",
67
- "@dxos/config": "0.3.11-main.0ac3ef5",
68
- "@dxos/react-ui-theme": "0.3.11-main.0ac3ef5",
69
- "@dxos/storybook-utils": "0.3.11-main.0ac3ef5"
67
+ "@dxos/config": "0.3.11-main.0b0bfb1",
68
+ "@dxos/react-async": "0.3.11-main.0b0bfb1",
69
+ "@dxos/react-ui-theme": "0.3.11-main.0b0bfb1",
70
+ "@dxos/storybook-utils": "0.3.11-main.0b0bfb1"
70
71
  },
71
72
  "peerDependencies": {
72
73
  "@phosphor-icons/react": "^2.0.5",
@@ -132,7 +132,7 @@ export const Action = forwardRef<HTMLButtonElement, LargeButtonProps>((props, fo
132
132
  return (
133
133
  <Button
134
134
  {...rest}
135
- classNames={[isFull && 'is-full', 'bs-11 flex gap-2 mbs-2', classNames, ...buttonColorFragment(props)]}
135
+ classNames={[isFull && 'is-full', 'bs-11 flex gap-2 mbs-2', ...buttonColorFragment(props), classNames]}
136
136
  ref={forwardedRef}
137
137
  variant={variant}
138
138
  >
@@ -5,7 +5,7 @@
5
5
  import React, { useEffect, useState } from 'react';
6
6
 
7
7
  import { log } from '@dxos/log';
8
- import { type LayoutRequest, ShellDisplay, ShellLayout, type ShellRuntime } from '@dxos/react-client';
8
+ import { type LayoutRequest, ShellDisplay, ShellLayout, type ShellRuntime, useClient } from '@dxos/react-client';
9
9
  import { useSpace } from '@dxos/react-client/echo';
10
10
 
11
11
  import { IdentityDialog } from '../IdentityDialog';
@@ -20,6 +20,7 @@ export const Shell = ({ runtime, origin }: { runtime: ShellRuntime; origin: stri
20
20
  target: runtime.target,
21
21
  });
22
22
 
23
+ const client = useClient();
23
24
  const space = useSpace(spaceKey);
24
25
 
25
26
  useEffect(() => {
@@ -59,6 +60,11 @@ export const Shell = ({ runtime, origin }: { runtime: ShellRuntime; origin: stri
59
60
  return (
60
61
  <IdentityDialog
61
62
  createInvitationUrl={(invitationCode) => `${origin}?deviceInvitationCode=${invitationCode}`}
63
+ onResetDevice={async () => {
64
+ await client.reset();
65
+ await runtime.setAppContext({ display: ShellDisplay.NONE, reload: true });
66
+ }}
67
+ onJoinNewIdentity={() => runtime.setLayout({ layout: ShellLayout.INITIALIZE_IDENTITY })}
62
68
  onDone={async () => {
63
69
  await runtime.setAppContext({ display: ShellDisplay.NONE });
64
70
  runtime.setLayout({ layout: ShellLayout.DEFAULT });
@@ -17,7 +17,7 @@ import {
17
17
  type IdentityPanelProps,
18
18
  } from './IdentityPanelProps';
19
19
  import { useIdentityMachine } from './identityMachine';
20
- import { DeviceManager, IdentityActionChooser, ProfileForm } from './steps';
20
+ import { AgentForm, DeviceManager, IdentityActionChooser, ProfileForm, SignOutChooser } from './steps';
21
21
  import { Viewport, Heading, CloseButton } from '../../components';
22
22
  import { InvitationManager } from '../../steps';
23
23
 
@@ -45,6 +45,8 @@ export const IdentityPanelImpl = (props: IdentityPanelImplProps) => {
45
45
  titleId,
46
46
  activeView,
47
47
  onUpdateProfile,
48
+ onResetDevice,
49
+ onJoinNewIdentity,
48
50
  IdentityActionChooser: IdentityActionChooserComponent = IdentityActionChooser,
49
51
  InvitationManager: InvitationManagerComponent = InvitationManager,
50
52
  onDone,
@@ -53,15 +55,15 @@ export const IdentityPanelImpl = (props: IdentityPanelImplProps) => {
53
55
  const { t } = useTranslation('os');
54
56
  const title = useMemo(() => {
55
57
  switch (activeView) {
56
- case 'device manager':
57
- return t('choose devices label');
58
+ case 'agent manager':
59
+ return 'Manage Agent';
58
60
  case 'device invitation manager':
59
61
  return t('choose add device label');
60
62
  default:
61
63
  return t('identity heading');
62
64
  }
63
65
  }, [activeView, t]);
64
- console.log('[IdentityPanelImpl]', { activeView });
66
+
65
67
  return (
66
68
  <DensityProvider density='fine'>
67
69
  <IdentityHeading {...{ identity, titleId, title, onDone }} />
@@ -88,7 +90,17 @@ export const IdentityPanelImpl = (props: IdentityPanelImplProps) => {
88
90
  onUpdateProfile={onUpdateProfile}
89
91
  />
90
92
  </Viewport.View>
91
- {/* <Viewport.View id='signing out'></Viewport.View> */}
93
+ <Viewport.View classNames={viewStyles} id='signing out'>
94
+ <SignOutChooser
95
+ send={rest.send}
96
+ active={activeView === 'signing out'}
97
+ onResetDevice={onResetDevice}
98
+ onJoinNewIdentity={onJoinNewIdentity}
99
+ />
100
+ </Viewport.View>
101
+ <Viewport.View classNames={viewStyles} id='agent manager'>
102
+ <AgentForm send={rest.send} active={activeView === 'agent manager'} identity={identity} />
103
+ </Viewport.View>
92
104
  </Viewport.Views>
93
105
  </Viewport.Root>
94
106
  </DensityProvider>
@@ -136,15 +148,15 @@ export const IdentityPanel = ({
136
148
  return 'device manager';
137
149
  case [{ managingProfile: 'idle' }, { managingProfile: 'pending' }].some(identityState.matches):
138
150
  return 'update profile form';
139
- // case identityState.matches('signingOut'):
140
- // return 'identity exit';
151
+ case identityState.matches('signingOut'):
152
+ return 'signing out';
153
+ case [{ managingAgent: 'idle' }, { managingAgent: 'pending' }].some(identityState.matches):
154
+ return 'agent manager';
141
155
  default:
142
156
  return 'identity action chooser';
143
157
  }
144
158
  }, [identityState]);
145
159
 
146
- console.log({ activeView, identityState });
147
-
148
160
  const onUpdateProfile = async (profile: NonNullable<Identity['profile']>) => {
149
161
  identitySend({ type: 'updateProfile' });
150
162
  await client.halo.updateProfile(profile);
@@ -13,10 +13,18 @@ import type { InvitationManagerProps } from '../../steps';
13
13
 
14
14
  export type IdentityPanelImplProps = {
15
15
  titleId: string;
16
- activeView: 'device manager' | 'update profile form' | 'device invitation manager' | 'identity action chooser';
16
+ activeView:
17
+ | 'device manager'
18
+ | 'agent manager'
19
+ | 'update profile form'
20
+ | 'device invitation manager'
21
+ | 'identity action chooser'
22
+ | 'signing out';
17
23
  identity: Identity;
18
24
  devices: Device[];
19
25
  onUpdateProfile?: (profile: NonNullable<Identity['profile']>) => Promise<void>;
26
+ onResetDevice?: () => Promise<void>;
27
+ onJoinNewIdentity?: () => void;
20
28
  createInvitationUrl: (invitationCode: string) => string;
21
29
  send?: (event: SingleOrArray<Event<IdentityEvent>>) => void;
22
30
  onDone?: () => void;
@@ -19,7 +19,7 @@ type IdentityMachineContext = {
19
19
  };
20
20
 
21
21
  type IdentityChooseActionEvent = {
22
- type: 'chooseDevices' | 'chooseProfile' | /* 'chooseSignOut' | */ 'unchooseAction';
22
+ type: 'chooseDevices' | 'chooseAgent' | 'chooseProfile' | 'chooseSignOut' | 'sigingOut' | 'unchooseAction';
23
23
  };
24
24
 
25
25
  type IdentitySelectDeviceInvitationEvent = {
@@ -58,6 +58,13 @@ const identityMachine = createMachine<IdentityMachineContext, IdentityEvent>(
58
58
  states: {
59
59
  choosingAction: {},
60
60
  managingDeviceInvitation: {},
61
+ managingAgent: {
62
+ initial: 'idle',
63
+ states: {
64
+ idle: {},
65
+ pending: {},
66
+ },
67
+ },
61
68
  managingDevices: {},
62
69
  managingProfile: {
63
70
  initial: 'idle',
@@ -70,7 +77,7 @@ const identityMachine = createMachine<IdentityMachineContext, IdentityEvent>(
70
77
  updateProfile: { target: '.pending', actions: 'log' },
71
78
  },
72
79
  },
73
- // signingOut: {},
80
+ signingOut: {},
74
81
  },
75
82
  on: {
76
83
  unchooseAction: { target: '.choosingAction', actions: ['unsetInvitation', 'log'] },
@@ -78,7 +85,8 @@ const identityMachine = createMachine<IdentityMachineContext, IdentityEvent>(
78
85
  selectInvitation: { target: '.managingDeviceInvitation', actions: ['setInvitation', 'log'] },
79
86
  chooseDevices: { target: '.managingDevices', actions: 'log' },
80
87
  chooseProfile: { target: '.managingProfile', actions: 'log' },
81
- // chooseSignOut: { target: '.signingOut', actions: 'log' },
88
+ chooseSignOut: { target: '.signingOut', actions: 'log' },
89
+ chooseAgent: { target: '.managingAgent', actions: 'log' },
82
90
  },
83
91
  },
84
92
  {
@@ -0,0 +1,165 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import React, { useState, useCallback, useEffect } from 'react';
6
+ import { type Event, type SingleOrArray } from 'xstate';
7
+
8
+ import { invariant } from '@dxos/invariant';
9
+ import { useClient, useAgentHostingProviderClient } from '@dxos/react-client';
10
+ import { type Identity, useHaloInvitations } from '@dxos/react-client/halo';
11
+ import { Invitation, InvitationEncoder } from '@dxos/react-client/invitations';
12
+ import { useTranslation } from '@dxos/react-ui';
13
+
14
+ import { Action, Actions, StepHeading, Input } from '../../../components';
15
+ import { type IdentityPanelStepProps } from '../IdentityPanelProps';
16
+ import { type IdentityEvent } from '../identityMachine';
17
+
18
+ export interface AgentFormProps extends Omit<IdentityPanelStepProps, 'send'> {
19
+ send?: (event: SingleOrArray<Event<IdentityEvent>>) => void;
20
+ onAgentCreate?: () => Promise<void>;
21
+ onAgentDestroy?: () => Promise<void>;
22
+ identity?: Identity;
23
+ }
24
+
25
+ export type AgentFormImplProps = AgentFormProps & {
26
+ agentStatus?: string;
27
+ agentActive?: boolean;
28
+ agentProviderDisabled?: boolean;
29
+ validationMessage?: string;
30
+ };
31
+
32
+ export const AgentForm = (props: AgentFormProps) => {
33
+ const { identity } = props;
34
+ // const { t } = useTranslation('os');
35
+ const [validationMessage, setValidationMessage] = useState('');
36
+ const [agentStatus, setAgentStatus] = useState('');
37
+ const [agentActive, setAgentActive] = useState(false);
38
+ const client = useClient();
39
+ const invitations = useHaloInvitations();
40
+ const agentHostingProviderClient = useAgentHostingProviderClient(client.config);
41
+
42
+ useEffect(() => {
43
+ const fetchAgentStatus = async () => {
44
+ // TODO(nf): if agent exists, subscribe to updates instead of oneshot status
45
+ if (agentHostingProviderClient) {
46
+ const agentStatus = await agentHostingProviderClient?.getAgent(identity?.identityKey.truncate() ?? 'foo');
47
+ if (agentStatus) {
48
+ setAgentActive(true);
49
+ setAgentStatus(agentStatus);
50
+ } else {
51
+ setAgentActive(false);
52
+ setValidationMessage('No agent deployed via provider.');
53
+ }
54
+ } else {
55
+ setValidationMessage('No agent provider configured.');
56
+ }
57
+ };
58
+ void fetchAgentStatus();
59
+ }, []);
60
+
61
+ const onAgentCreateEvent = useCallback(async (invitation: Invitation) => {
62
+ const invitationCode = InvitationEncoder.encode(invitation);
63
+ if (invitation.state === Invitation.State.CONNECTING) {
64
+ console.log(JSON.stringify({ invitationCode, authCode: invitation.authCode }));
65
+ invariant(identity, 'Identity not found');
66
+ if (agentHostingProviderClient) {
67
+ try {
68
+ const res = await agentHostingProviderClient?.createAgent(invitationCode, identity.identityKey.truncate());
69
+ // TODO(nf): human-consumable response from API
70
+ setAgentStatus(res);
71
+ setAgentActive(true);
72
+ setValidationMessage('');
73
+ } catch (err: any) {
74
+ setValidationMessage(`error creating agent: ${err.message}`);
75
+ }
76
+ }
77
+ }
78
+ }, []);
79
+
80
+ const handleAgentCreate = async () => {
81
+ invitations.forEach((invitation) => invitation.cancel());
82
+
83
+ // TODO(nf): do this work in the hosting provider client?
84
+ const invitation = client.halo.share({ type: Invitation.Type.MULTIUSE, authMethod: Invitation.AuthMethod.NONE });
85
+
86
+ invitation.subscribe(onAgentCreateEvent);
87
+ };
88
+
89
+ const handleAgentDestroy = async () => {
90
+ const identity = client.halo.identity.get();
91
+ invariant(identity, 'Identity not found');
92
+ try {
93
+ await agentHostingProviderClient?.destroyAgent(identity.identityKey.truncate());
94
+ setValidationMessage('No agent deployed via provider.');
95
+ setAgentStatus('');
96
+ setAgentActive(false);
97
+ } catch (err: any) {
98
+ setValidationMessage(`error destroying agent: ${err.message}`);
99
+ }
100
+ };
101
+
102
+ return (
103
+ <AgentFormImpl
104
+ {...props}
105
+ onAgentCreate={handleAgentCreate}
106
+ onAgentDestroy={handleAgentDestroy}
107
+ validationMessage={validationMessage}
108
+ agentStatus={agentStatus}
109
+ agentActive={agentActive}
110
+ agentProviderDisabled={!agentHostingProviderClient}
111
+ />
112
+ );
113
+ };
114
+
115
+ // TODO(zhenyasav): impl shouldn't need send()
116
+ export const AgentFormImpl = (props: AgentFormImplProps) => {
117
+ const {
118
+ active,
119
+ onAgentCreate,
120
+ onAgentDestroy,
121
+ send,
122
+ validationMessage,
123
+ agentStatus,
124
+ agentActive,
125
+ agentProviderDisabled,
126
+ } = props;
127
+ const disabled = !active;
128
+ const { t } = useTranslation('os');
129
+ return (
130
+ <>
131
+ <div role='none' className='grow flex flex-col justify-center'>
132
+ <Input
133
+ {...{ validationMessage }}
134
+ label={<StepHeading>Agent Status</StepHeading>}
135
+ disabled={disabled}
136
+ data-testid='agent-status'
137
+ value={agentStatus}
138
+ />
139
+ </div>
140
+ <Actions>
141
+ <Action
142
+ disabled={agentActive || agentProviderDisabled}
143
+ onClick={() => onAgentCreate?.()}
144
+ data-testid={'create-agent'}
145
+ >
146
+ Create Agent
147
+ </Action>
148
+ <Action
149
+ disabled={!agentActive || agentProviderDisabled}
150
+ onClick={() => onAgentDestroy?.()}
151
+ data-testid={'destroy-agent'}
152
+ >
153
+ Destroy Agent
154
+ </Action>
155
+ <Action
156
+ disabled={disabled}
157
+ onClick={() => send?.({ type: 'unchooseAction' })}
158
+ data-testid={'update-profile-form-back'}
159
+ >
160
+ {t('back label')}
161
+ </Action>
162
+ </Actions>
163
+ </>
164
+ );
165
+ };
@@ -2,7 +2,7 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { CaretRight, Devices, Plus, Power, UserGear } from '@phosphor-icons/react';
5
+ import { CaretRight, Devices, Plus, Power, UserGear, HardDrive } from '@phosphor-icons/react';
6
6
  import React, { useCallback } from 'react';
7
7
 
8
8
  import { useClient } from '@dxos/react-client';
@@ -63,6 +63,11 @@ export const IdentityActionChooserImpl = ({
63
63
  <div role='none' className='grow flex flex-col gap-1'>
64
64
  <DensityProvider density='coarse'>
65
65
  <div className='grow justify-center flex flex-col gap-1'>
66
+ <Action data-testid='manage-agent' onClick={() => send?.({ type: 'chooseAgent' })} classNames='plb-4'>
67
+ <HardDrive className={getSize(6)} />
68
+ <span className='grow mli-3'>Manage Agent</span>
69
+ <CaretRight weight='bold' className={getSize(4)} />
70
+ </Action>
66
71
  <Action
67
72
  disabled={!active}
68
73
  data-testid='devices-panel.create-invitation'
@@ -83,12 +88,7 @@ export const IdentityActionChooserImpl = ({
83
88
  <span className='grow mli-3'>{t('choose profile label')}</span>
84
89
  <CaretRight weight='bold' className={getSize(4)} />
85
90
  </Action>
86
- <Action
87
- disabled
88
- data-testid='sign-out'
89
- onClick={() => {} /* send({ type: 'chooseSignOut' }) */}
90
- classNames='plb-4'
91
- >
91
+ <Action data-testid='sign-out' onClick={() => send?.({ type: 'chooseSignOut' })} classNames='plb-4'>
92
92
  <Power className={getSize(6)} />
93
93
  <span className='grow mli-3'>{t('choose sign out label')}</span>
94
94
  <CaretRight weight='bold' className={getSize(4)} />
@@ -0,0 +1,82 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { Warning } from '@phosphor-icons/react';
6
+ import React from 'react';
7
+ import { type Event, type SingleOrArray } from 'xstate';
8
+
9
+ import { Message, useTranslation } from '@dxos/react-ui';
10
+ import { getSize, mx } from '@dxos/react-ui-theme';
11
+
12
+ import { Action, Actions } from '../../../components';
13
+ import { type IdentityPanelStepProps } from '../IdentityPanelProps';
14
+ import { type IdentityEvent } from '../identityMachine';
15
+
16
+ export interface SignOutChooserProps extends Omit<IdentityPanelStepProps, 'send'> {
17
+ send?: (event: SingleOrArray<Event<IdentityEvent>>) => void;
18
+ onResetDevice?: () => Promise<void>;
19
+ onJoinNewIdentity?: () => void;
20
+ }
21
+
22
+ export const SignOutChooser = (props: SignOutChooserProps) => {
23
+ const { t } = useTranslation('os');
24
+ const onResetDevice = () => {
25
+ if (window.confirm(t('reset device confirm message'))) {
26
+ void props.onResetDevice?.();
27
+ }
28
+ };
29
+ return (
30
+ <SignOutChooserImpl
31
+ disabled={!props.active}
32
+ onBack={() => props.send?.({ type: 'unchooseAction' })}
33
+ onResetDevice={onResetDevice}
34
+ onJoinNewIdentity={props.onJoinNewIdentity}
35
+ />
36
+ );
37
+ };
38
+
39
+ export type SignOutChooserImplProps = {
40
+ disabled?: boolean;
41
+ onResetDevice?: () => void;
42
+ onJoinNewIdentity?: () => void;
43
+ onBack?: () => void;
44
+ };
45
+
46
+ const SignOutChooserImpl = ({ disabled, onResetDevice, onJoinNewIdentity, onBack }: SignOutChooserImplProps) => {
47
+ const { t } = useTranslation('os');
48
+ return (
49
+ <>
50
+ <div role='none' className='grow flex flex-col justify-center'>
51
+ <Message.Root valence='error'>
52
+ <Message.Title>
53
+ <Warning className={mx(getSize(6), 'inline mie-2')} />
54
+ {t('sign out chooser title')}
55
+ </Message.Title>
56
+ <Message.Body>{t('sign out chooser message')}</Message.Body>
57
+ </Message.Root>
58
+ </div>
59
+ <Actions>
60
+ <Action disabled={disabled} onClick={onBack}>
61
+ {t('back label')}
62
+ </Action>
63
+ <Action
64
+ variant='primary'
65
+ classNames='!bg-error-500 hover:!bg-error-550'
66
+ disabled={disabled}
67
+ onClick={onJoinNewIdentity}
68
+ >
69
+ {t('join new identity label')}
70
+ </Action>
71
+ <Action
72
+ variant='primary'
73
+ classNames='!bg-error-500 hover:!bg-error-550'
74
+ disabled={disabled}
75
+ onClick={onResetDevice}
76
+ >
77
+ {t('reset device label')}
78
+ </Action>
79
+ </Actions>
80
+ </>
81
+ );
82
+ };
@@ -2,6 +2,8 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
+ export * from './AgentPanel';
5
6
  export * from './DeviceManager';
6
7
  export * from './IdentityActionChooser';
7
8
  export * from './ProfileForm';
9
+ export * from './SignOutChooser';
@@ -99,4 +99,9 @@ export const os = {
99
99
  'This will clear this device and all associated data. Type {{confirmationValue}} and confirm to continue.',
100
100
  'failed to reset identity message': 'Failed to reset identity.',
101
101
  'confirmation value': 'CONFIRM',
102
+ 'sign out chooser title': 'DANGER ZONE',
103
+ 'sign out chooser message': 'Proceeding with either action below will erase all data on this device.',
104
+ 'join new identity label': 'Join a new identity',
105
+ 'reset device label': 'Reset device',
106
+ 'reset device confirm message': 'Are you sure you want to reset your device? All data will be lost.',
102
107
  };