diff --git a/src/Simplex/Chat.hs b/src/Simplex/Chat.hs index 2ad92b4ef..cf3767b5c 100644 --- a/src/Simplex/Chat.hs +++ b/src/Simplex/Chat.hs @@ -6073,8 +6073,9 @@ chatCommandP = ("/help groups" <|> "/help group" <|> "/hg") $> ChatHelp HSGroups, ("/help contacts" <|> "/help contact" <|> "/hc") $> ChatHelp HSContacts, ("/help address" <|> "/ha") $> ChatHelp HSMyAddress, - "/help incognito" $> ChatHelp HSIncognito, + ("/help incognito" <|> "/hi") $> ChatHelp HSIncognito, ("/help messages" <|> "/hm") $> ChatHelp HSMessages, + ("/help remote" <|> "/hr") $> ChatHelp HSRemote, ("/help settings" <|> "/hs") $> ChatHelp HSSettings, ("/help db" <|> "/hd") $> ChatHelp HSDatabase, ("/help" <|> "/h") $> ChatHelp HSMain, @@ -6181,7 +6182,6 @@ chatCommandP = "/set disappear " *> (SetUserTimedMessages <$> (("yes" $> True) <|> ("no" $> False))), ("/incognito" <* optional (A.space *> onOffP)) $> ChatHelp HSIncognito, "/set device name " *> (SetLocalDeviceName <$> textP), - -- "/create remote host" $> CreateRemoteHost, "/list remote hosts" $> ListRemoteHosts, "/switch remote host " *> (SwitchRemoteHost <$> ("local" $> Nothing <|> (Just <$> A.decimal))), "/start remote host " *> (StartRemoteHost <$> ("new" $> Nothing <|> (Just <$> ((,) <$> A.decimal <*> (" multicast=" *> onOffP <|> pure False))))), diff --git a/src/Simplex/Chat/Controller.hs b/src/Simplex/Chat/Controller.hs index d40810167..3c0054ec1 100644 --- a/src/Simplex/Chat/Controller.hs +++ b/src/Simplex/Chat/Controller.hs @@ -203,7 +203,7 @@ data ChatController = ChatController contactMergeEnabled :: TVar Bool } -data HelpSection = HSMain | HSFiles | HSGroups | HSContacts | HSMyAddress | HSIncognito | HSMarkdown | HSMessages | HSSettings | HSDatabase +data HelpSection = HSMain | HSFiles | HSGroups | HSContacts | HSMyAddress | HSIncognito | HSMarkdown | HSMessages | HSRemote | HSSettings | HSDatabase deriving (Show) data ChatCommand diff --git a/src/Simplex/Chat/Help.hs b/src/Simplex/Chat/Help.hs index c2a572063..5d0548ca3 100644 --- a/src/Simplex/Chat/Help.hs +++ b/src/Simplex/Chat/Help.hs @@ -10,6 +10,7 @@ module Simplex.Chat.Help myAddressHelpInfo, incognitoHelpInfo, messagesHelpInfo, + remoteHelpInfo, markdownInfo, settingsInfo, databaseHelpInfo, @@ -87,7 +88,7 @@ chatHelpInfo = green "Create your address: " <> highlight "/address", "", green "Other commands:", - indent <> highlight "/help " <> " - help on: " <> listHighlight ["groups", "contacts", "messages", "files", "address", "settings", "db"], + indent <> highlight "/help " <> " - help on: " <> listHighlight ["groups", "contacts", "messages", "files", "address", "incognito", "remote", "settings", "db"], indent <> highlight "/profile " <> " - show / update user profile", indent <> highlight "/delete " <> " - delete contact and all messages with them", indent <> highlight "/chats " <> " - most recent chats", @@ -272,6 +273,34 @@ messagesHelpInfo = indent <> highlight "! #team (hi) " <> " - to edit your message in the group #team" ] +remoteHelpInfo :: [StyledString] +remoteHelpInfo = + map + styleMarkdown + [ green "Remote control", + "You can use CLI as a remote controller for a mobile app or as a remote host for a desktop app (or another CLI).", + "For example, you can run CLI on a server and use it from a desktop computer, connecting via SSH port forwarding.", + "", + indent <> highlight "/set device name " <> " - set CLI name for remote connections", + "", + green "Using as remote controller", + indent <> highlight "/start remote host new " <> " - pair and connect a new remote host", + indent <> highlight "/start remote host [multicast=on] " <> " - start connection with a known (paired) remote host", + indent <> highlight "/stop remote host new " <> " - cancel pairing with a new remote host", + indent <> highlight "/stop remote host " <> " - stop connection with connected remote host", + indent <> highlight "/switch remote host local " <> " - switch to using local database", + indent <> highlight "/switch remote host " <> " - switch to connected remote host", + indent <> highlight "/list remote hosts " <> " - list known remote hosts", + indent <> highlight "/delete remote host " <> " - delete (unpair) known remote hosts - also deletes all host files from controller", + "", + green "Using as remote host", + indent <> highlight "/connect remote ctrl " <> " - connect to remote controller via the adress from /start remote host", + indent <> highlight "/stop remote ctrl " <> " - stop connection with remote controller", + indent <> highlight "/find remote ctrl " <> " - find known remote controller on the local network (it should be started with multicast=on)", + indent <> highlight "/list remote ctrls " <> " - list known remote controllers", + indent <> highlight "/delete remote ctrl " <> " - delete known remote controller" + ] + markdownInfo :: [StyledString] markdownInfo = map diff --git a/src/Simplex/Chat/View.hs b/src/Simplex/Chat/View.hs index 9cd26650f..4dbda6da6 100644 --- a/src/Simplex/Chat/View.hs +++ b/src/Simplex/Chat/View.hs @@ -136,6 +136,7 @@ responseToView hu@(currentRH, user_) ChatConfig {logLevel, showReactions, showRe HSIncognito -> incognitoHelpInfo HSMessages -> messagesHelpInfo HSMarkdown -> markdownInfo + HSRemote -> remoteHelpInfo HSSettings -> settingsInfo HSDatabase -> databaseHelpInfo CRWelcome user -> chatWelcome user @@ -310,6 +311,7 @@ responseToView hu@(currentRH, user_) ChatConfig {logLevel, showReactions, showRe [ "remote controller " <> sShow remoteCtrlId <> " found: " <> maybe (deviceName <> "not compatible") (\info -> viewRemoteCtrl info appVersion compatible) ctrlAppInfo_ ] + <> [ "use " <> highlight ("/confirm remote ctrl " <> show remoteCtrlId) <> " to connect" | isJust ctrlAppInfo_ && compatible] where deviceName = if T.null ctrlDeviceName then "" else plain ctrlDeviceName <> ", " CRRemoteCtrlConnecting {remoteCtrl_, ctrlAppInfo, appVersion} -> diff --git a/tests/RemoteTests.hs b/tests/RemoteTests.hs index 9f77245d9..147f1d939 100644 --- a/tests/RemoteTests.hs +++ b/tests/RemoteTests.hs @@ -460,6 +460,7 @@ startRemoteDiscover mobile desktop = do mobile ##> "/find remote ctrl" mobile <## "ok" mobile <## ("remote controller 1 found: My desktop, v" <> versionNumber) + mobile <## "use /confirm remote ctrl 1 to connect" mobile ##> "/confirm remote ctrl 1" mobile <## ("connecting remote controller 1: My desktop, v" <> versionNumber)