Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add *.md support for plugin's details #2204

Open
wants to merge 7 commits into
base: plugins_support
Choose a base branch
from

Conversation

DmitryAstafyev
Copy link
Collaborator

@DmitryAstafyev DmitryAstafyev commented Feb 13, 2025

Added

  • Plugins Manager makes an attempt to read README.md file in plugin's folder.
  • If README.md has been found, it would be rendered in details frame

Change

  • Introduce PluginRunData entity to store run, load and checks data

Copy link
Member

@AmmarAbouZor AmmarAbouZor left a comment

Choose a reason for hiding this comment

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

This looks great.

We will still need to deliver the path of the md file from the backend, to keep all loading logic in one place and having the front end knowing less as possible.
I'll create another PR for that once I'm done with changes on the plugins manager

@DmitryAstafyev DmitryAstafyev marked this pull request as draft February 17, 2025 17:29
@DmitryAstafyev DmitryAstafyev marked this pull request as ready for review February 20, 2025 09:33
Copy link
Member

@AmmarAbouZor AmmarAbouZor left a comment

Choose a reason for hiding this comment

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

Great work nicely done @DmitryAstafyev

I still found some points mainly regarding the naming of some fields like ts or rd. Also we may need to extend the proptests and protocol test

@@ -90,19 +93,24 @@ async fn load_plugin(
plug_dir: PathBuf,
plug_type: PluginType,
) -> Result<PluginEntityState, InitError> {
let mut rd = PluginRunData::default();
Copy link
Member

Choose a reason for hiding this comment

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

I really like the names to be more expressive. Can we change this to run_data or rdata

Comment on lines -33 to +40
pub fn installed_plugins(&self) -> &[PluginEntity] {
&self.installed_plugins
pub fn installed_plugins(&self) -> Vec<&PluginEntity> {
self.installed_plugins
.iter()
.map(|en| en.into())
.collect::<Vec<&PluginEntity>>()
Copy link
Member

Choose a reason for hiding this comment

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

We can return an iterator here without having to collect into vector inside the function

    /// Provide full infos of all loaded and valid plugins.
    pub fn installed_plugins(&self) -> impl Iterator<Item = &PluginEntity> {
        self.installed_plugins.iter().map(|en| en.into())
    }

Comment on lines -52 to +66
pub fn invalid_plugins(&self) -> &[InvalidPluginEntity] {
&self.invalid_plugins
pub fn invalid_plugins(&self) -> Vec<&InvalidPluginEntity> {
self.invalid_plugins
.iter()
.map(|en| en.into())
.collect::<Vec<&InvalidPluginEntity>>()
Copy link
Member

Choose a reason for hiding this comment

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

Returning an iterator is more flexible here as well

    pub fn invalid_plugins(&self) -> impl Iterator<Item = &InvalidPluginEntity> {
        self.invalid_plugins.iter().map(|en| en.into())
    }

/// The core entity representing the plugin.
pub entity: PluginEntity,
/// Runtime data associated with the plugin.
pub rd: PluginRunData,
Copy link
Member

Choose a reason for hiding this comment

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

Can we please rename this to more meaningful name like run_data.
I think rust LSP is really efficient for mass renaming 😉

/// The core entity representing an invalid plugin.
pub entity: InvalidPluginEntity,
/// Runtime data associated with the invalid plugin.
pub rd: PluginRunData,
Copy link
Member

Choose a reason for hiding this comment

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

Same for renaming here 🙏

Comment on lines +177 to +204
pub fn debug<S: AsRef<str>>(msg: S) -> Self {
Self {
msg: msg.as_ref().to_string(),
level: PluginLogLevel::Debug,
tm: Self::tm(),
}
}
pub fn info<S: AsRef<str>>(msg: S) -> Self {
Self {
msg: msg.as_ref().to_string(),
level: PluginLogLevel::Info,
tm: Self::tm(),
}
}
pub fn err<S: AsRef<str>>(msg: S) -> Self {
Self {
msg: msg.as_ref().to_string(),
level: PluginLogLevel::Err,
tm: Self::tm(),
}
}
pub fn warn<S: AsRef<str>>(msg: S) -> Self {
Self {
msg: msg.as_ref().to_string(),
level: PluginLogLevel::Warn,
tm: Self::tm(),
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Also the optional removing generic bound with deref coercion + Short docs

/// The severity level of the log message.
pub level: PluginLogLevel,
/// The timestamp of when the log message was generated, represented as a Unix timestamp.
pub tm: u64,
Copy link
Member

Choose a reason for hiding this comment

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

Also renaming this to timestamp would be great 🙏

dir_path,
plugin_type,
error_msgs,
})
.boxed()
}
Copy link
Member

Choose a reason for hiding this comment

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

I think we need a proptest for PluginRunData here

@@ -137,6 +137,7 @@ gen_encode_decode_fns!(PluginConfigValue);
gen_encode_decode_fns!(PluginConfigSchemaType);
gen_encode_decode_fns!(PluginConfigSchemaItem);
gen_encode_decode_fns!(PluginEntity);
gen_encode_decode_fns!(PluginRunData);
Copy link
Member

Choose a reason for hiding this comment

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

I think we need to extend the tests in ts-bindings/spec/session.protocol.spec.ts

@@ -154,6 +155,7 @@ gen_encode_decode_fns!(CommandOutcome<InvalidPluginsList>);
gen_encode_decode_fns!(CommandOutcome<PluginsPathsList>);
gen_encode_decode_fns!(CommandOutcome<Option<PluginEntity>>);
gen_encode_decode_fns!(CommandOutcome<Option<InvalidPluginEntity>>);
gen_encode_decode_fns!(CommandOutcome<Option<PluginRunData>>);
Copy link
Member

Choose a reason for hiding this comment

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

Protocol tests in ts-bindings here as well.

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