Skip to content

[2] Add TUI messages#103

Merged
JonoPrest merged 11 commits into
mainfrom
jp/add-tui-messages
Aug 5, 2024
Merged

[2] Add TUI messages#103
JonoPrest merged 11 commits into
mainfrom
jp/add-tui-messages

Conversation

@JonoPrest

Copy link
Copy Markdown
Collaborator

See screenshots below demoing multiple messages of different types, failure to load message and current message that is deployed with the API

Screenshot 2024-08-02 at 11 18 33
Screenshot 2024-08-02 at 11 14 10
Screenshot 2024-08-02 at 11 15 31

Comment on lines +3 to +6
@as("version") envioVersion: string,
@as("apiToken") hasApiToken: bool,
usesHyperSync: bool,
config: ConfigYAML.t,

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DZakh note I aded "usesHyperSync" field so no extra parsing is needed on the server side yet. I'm still sending across the reduced ConfigYAML (redacted addresses and rpc secrets etc) to allow us to parse info if we need for messaging later on.

@JonoPrest JonoPrest changed the title Add TUI messages [2] Add TUI messages Aug 2, 2024
@JonoPrest JonoPrest requested a review from DZakh August 2, 2024 09:49
Comment on lines +29 to +37
| Err(_) =>
<Message message={kind: Destructive, content: "Failed to load messages from envio server"} />
}}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we actually want to show that there's a failure? It's not important to display if there is but my only concern is it would go by undetected as it would present the same as no messages at all.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should implement something like envio.dev/app/hyperindex/send-error and integrate it with Sentry?

Comment on lines -1 to -2
Dotenv.initialize()

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dotenv now gets initialized in the Env.res file before safe Env.

Comment on lines +45 to +49
S.object(s => {
s.tag("kind", "Rpc")
//Do not share users private rpc details
Rpc(Js.Nullable.Null->Utils.magic)
}),

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DZakh maybe you have some wisdom for how this should look? I want to be able to serialize this to share that it is using an RPC without any of the other values associated with the provider (in this case just a URL)

It's obviously not deserializeable with the same schema but currently don't need deserialization

@JonoPrest JonoPrest force-pushed the jp/add-tui-messages branch 2 times, most recently from 0a0284f to eb25e09 Compare August 2, 2024 12:44
Base automatically changed from jp/init-api-key to main August 2, 2024 13:00
Comment on lines +23 to +26
envioVersion: s.field("version", S.string),
hasApiToken: s.fieldOr("apiToken", S.bool, false),
usesHyperSync: s.field("usesHyperSync", S.bool),
config: s.field("config", ConfigYAML.schema),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
envioVersion: s.field("version", S.string),
hasApiToken: s.fieldOr("apiToken", S.bool, false),
usesHyperSync: s.field("usesHyperSync", S.bool),
config: s.field("config", ConfigYAML.schema),
envioVersion: s.field("version", S.string),
apiToken: s.field("apiToken", S.option<S.string>), // Send the token itself
hyperSync: s.field("hyperSync", S.bool), // I don't like the uses prefix for some reason :) How about simply sending hyperSync or poweredByHyperSync?
// config: s.field("config", ConfigYAML.schema),
// Instead of the schema we decided to send:
ecosystem: s.field("ecosystem", S.union([S.literal("evm"), S.literal("fuel")])),
chainIds: s.field("chainIds", S.array(S.int))

Comment on lines +46 to +48
PersistedState.getPersistedState()->Belt.Result.mapWithDefault("unknown", ps =>
ps.envioVersion
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should better send it as optional?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, it just needs to be updated on the server as well

let makeAppState = (globalState: GlobalState.t): EnvioInkApp.appState => {
open Belt
{
config: globalState.config->ConfigYAML.fromConfig(~shouldRemoveAddresses=true),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not send config and remove all the parsing

@DZakh

DZakh commented Aug 2, 2024

Copy link
Copy Markdown
Member

I think it would be nice to highlight them a little bit more somehow. Either by adding a space below hasura link, or adding a big title saying Notifications/Messages, or maybe adding an icon. I'm not very familiar with Ink

image

@JonoPrest JonoPrest force-pushed the jp/add-tui-messages branch from eb25e09 to 9a1b3eb Compare August 2, 2024 16:17
@JonoPrest

Copy link
Copy Markdown
Collaborator Author

Updated look for notifications:

Screenshot 2024-08-02 at 18 23 42

@DZakh DZakh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. The only think I'd like to have is a white colored message.

And, also I think it's good to design messages compatible to Ink API:

type message = {
  kind: "text"
  color: "primary" | "secondary" | "info" | "danger" | ...
  content: string
}

So it's easier to understand which color the notification will has, and gives us a possibility to add more complex notifications in the future.

And I left a comment on the ecosystem format we want to pass, which will also require change in the PR.

}
}

type messageKind = | @as("warning") Warning | @as("destructive") Destructive | @as("info") Info

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also add a general message to use it as fallback, in case we want to add a new kind in the future. For example, we can have it white.

}

let messageSchema = S.object(s => {
kind: s.field("kind", S.union([S.literal(Warning), S.literal(Destructive), S.literal(Info)])),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
kind: s.field("kind", S.union([S.literal(Warning), S.literal(Destructive), S.literal(Info)])),
kind: s.field("kind", S.union([S.literal(Warning), S.literal(Destructive), S.literal(Info), S.string->S.variant(_ => General)])),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, well, we can handle it on the server, since we know the version. But I think it's still nice to have a white colored message.

Comment on lines +8 to +10
| Warning => Secondary
| Info => Info
| Destructive => Danger

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use the same names as Ink does, so it makes more sense? 🤔

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah lets do that 👍🏼

@JonoPrest JonoPrest force-pushed the jp/add-tui-messages branch from 9a1b3eb to 1c71612 Compare August 5, 2024 09:35
@JonoPrest JonoPrest enabled auto-merge (squash) August 5, 2024 11:04

@DZakh DZakh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 👍

Comment on lines +56 to +57
let toTheme = (color: messageColor): Style.chalkTheme =>
switch color {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does :> work here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are not the same underlying string though...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, different casing or something

@JonoPrest JonoPrest merged commit 97a3a19 into main Aug 5, 2024
@JonoPrest JonoPrest deleted the jp/add-tui-messages branch August 5, 2024 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants