diff --git a/unison-cli/src/Unison/Codebase/Editor/HandleInput.hs b/unison-cli/src/Unison/Codebase/Editor/HandleInput.hs index d15136a14..b7988c431 100644 --- a/unison-cli/src/Unison/Codebase/Editor/HandleInput.hs +++ b/unison-cli/src/Unison/Codebase/Editor/HandleInput.hs @@ -83,6 +83,7 @@ import Unison.Codebase.Editor.HandleInput.Pull (doPullRemoteBranch, mergeBranchA import Unison.Codebase.Editor.HandleInput.Push (handleGist, handlePushRemoteBranch) import Unison.Codebase.Editor.HandleInput.ReleaseDraft (handleReleaseDraft) import Unison.Codebase.Editor.HandleInput.TermResolution (resolveCon, resolveMainRef, resolveTermRef) +import Unison.Codebase.Editor.HandleInput.UI (openUI) import Unison.Codebase.Editor.HandleInput.Update (doSlurpAdds, handleUpdate) import Unison.Codebase.Editor.Input import Unison.Codebase.Editor.Input qualified as Input @@ -286,9 +287,9 @@ loop e = do P.lines [ "The API information is as follows:", P.newline, - P.indentN 2 (P.hiBlue ("UI: " <> fromString (Server.urlFor (Server.UI Path.absoluteEmpty Nothing) baseUrl))), + P.indentN 2 (P.hiBlue ("UI: " <> Pretty.text (Server.urlFor (Server.LooseCodeUI Path.absoluteEmpty Nothing) baseUrl))), P.newline, - P.indentN 2 (P.hiBlue ("API: " <> fromString (Server.urlFor Server.Api baseUrl))) + P.indentN 2 (P.hiBlue ("API: " <> Pretty.text (Server.urlFor Server.Api baseUrl))) ] CreateMessage pretty -> Cli.respond $ PrintMessage pretty diff --git a/unison-cli/src/Unison/Codebase/Editor/HandleInput/UI.hs b/unison-cli/src/Unison/Codebase/Editor/HandleInput/UI.hs index f042058f4..fdaae7962 100644 --- a/unison-cli/src/Unison/Codebase/Editor/HandleInput/UI.hs +++ b/unison-cli/src/Unison/Codebase/Editor/HandleInput/UI.hs @@ -4,6 +4,7 @@ import Control.Lens qualified as Lens import Control.Monad.Reader (ask) import Data.Map qualified as Map import Data.Set qualified as Set +import Data.Text qualified as Text import U.Codebase.Branch.Type qualified as V2Branch import U.Codebase.Reference qualified as V2 (Reference) import U.Codebase.Referent qualified as V2 (Referent) @@ -16,7 +17,6 @@ import Unison.Cli.Monad (Cli) import Unison.Cli.Monad qualified as Cli import Unison.Cli.MonadUtils qualified as Cli import Unison.Cli.ProjectUtils qualified as Project -import Unison.Cli.ProjectUtils qualified as ProjectUtils import Unison.Codebase (Codebase) import Unison.Codebase qualified as Codebase import Unison.Codebase.Path qualified as Path @@ -25,7 +25,6 @@ import Unison.ConstructorType qualified as ConstructorType import Unison.HashQualified qualified as HQ import Unison.Name (Name) import Unison.Name qualified as Name -import Unison.NameSegment (NameSegment) import Unison.Parser.Ann (Ann (..)) import Unison.Prelude import Unison.Project (ProjectAndBranch) @@ -49,16 +48,14 @@ openUIForProject :: Server.BaseUrl -> ProjectAndBranch Sqlite.Project Sqlite.Pro openUIForProject url projectAndBranch pathFromProjectRoot = do Cli.Env {codebase} <- ask mayDefinitionRef <- getDefinitionRef codebase - let projectBranchNames = bimap Project.projectName ProjectBranch.branchName projectAndBranch - _success <- liftIO (openBrowser (Server.urlFor (Server.ProjectBranchUI projectBranchNames mayDefinitionRef) url)) + let projectBranchNames = bimap Project.name ProjectBranch.name projectAndBranch + _success <- liftIO . openBrowser . Text.unpack $ Server.urlFor (Server.ProjectBranchUI projectBranchNames mayDefinitionRef) url pure () where - projectRootPath :: Path.Absolute - projectRootPath = ProjectUtils.projectBranchPath (bimap Project.projectId ProjectBranch.branchId projectAndBranch) -- If the provided ui path matches a definition, find it. getDefinitionRef :: Codebase m Symbol Ann -> Cli (Maybe (Server.DefinitionReference)) getDefinitionRef codebase = runMaybeT $ do - (pathToDefinitionNamespace, nameSeg) <- hoistMaybe $ Lens.unsnoc pathFromProjectRoot + (pathToDefinitionNamespace, _nameSeg) <- hoistMaybe $ Lens.unsnoc pathFromProjectRoot namespaceBranch <- lift $ Cli.runTransaction (Codebase.getShallowBranchAtPath pathToDefinitionNamespace Nothing) let fqn = Path.unsafeToName pathFromProjectRoot getTermOrTypeRef codebase namespaceBranch fqn @@ -81,7 +78,7 @@ openUIForLooseCode url path' = do Cli.Env {codebase} <- ask (perspective, definitionRef) <- getUIUrlParts codebase - _success <- liftIO (openBrowser (Server.urlFor (Server.LooseCodeUI perspective definitionRef) url)) + _success <- liftIO . openBrowser . Text.unpack $ Server.urlFor (Server.LooseCodeUI perspective definitionRef) url pure () where getUIUrlParts :: Codebase m Symbol Ann -> Cli (Path.Absolute, Maybe (Server.DefinitionReference)) diff --git a/unison-cli/unison/Main.hs b/unison-cli/unison/Main.hs index 4e6761e80..4a6284790 100644 --- a/unison-cli/unison/Main.hs +++ b/unison-cli/unison/Main.hs @@ -278,9 +278,9 @@ main = withCP65001 . runInUnboundThread . Ki.scoped $ \scope -> do PT.putPrettyLn $ P.lines [ "I've started the Codebase API server at", - P.string $ Server.urlFor Server.Api baseUrl, + P.text $ Server.urlFor Server.Api baseUrl, "and the Codebase UI at", - P.string $ Server.urlFor (Server.UI Path.absoluteEmpty Nothing) baseUrl + P.text $ Server.urlFor (Server.LooseCodeUI Path.absoluteEmpty Nothing) baseUrl ] PT.putPrettyLn $ P.string "Running the codebase manager headless with " diff --git a/unison-share-api/src/Unison/Server/CodebaseServer.hs b/unison-share-api/src/Unison/Server/CodebaseServer.hs index c9108d615..5dfd6f196 100644 --- a/unison-share-api/src/Unison/Server/CodebaseServer.hs +++ b/unison-share-api/src/Unison/Server/CodebaseServer.hs @@ -198,7 +198,8 @@ instance Show BaseUrl where -- -- >>> import qualified Unison.Syntax.Name as Name -- >>> let service = ProjectBranchUI (ProjectAndBranch (ProjectName "base") (ProjectBranchName "main")) (Just (TermReference (NameOnly (Name.unsafeFromText "List.map")))) --- >>> urlFor +-- >>> let baseUrl = (BaseUrl{ urlHost = "https://localhost", urlToken = "asdf", urlPort = 1234 }) +-- >>> urlFor service baseUrl urlFor :: Service -> BaseUrl -> Text urlFor service baseUrl = case service of