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

Display a link for Rust Playground whenever AI replies with rust code #247

Open
joulei opened this issue Sep 10, 2024 · 1 comment
Open
Assignees

Comments

@joulei
Copy link
Collaborator

joulei commented Sep 10, 2024

Whenever AI replies with a rust code block, we want to add a link/button to the Rust Playground website attaching the given code. (Later on to be expanded to support other languages/websites).

Requirements to display the button:

  1. Message must be markdown
    In chat_line.rs the following heuristic is used to determine if the message is markdown (perhaps this can be reused):
        let to_markdown = parse_markdown(&text);
        let is_plain_text = to_markdown.nodes.len() <= 3;
  1. Message must include a rust code block ```rs ... ``` or ```rust ... ```

Opening the playground

We should open the Rust Playground URL by using robius-open, e.g. robius_open::Uri::new(&some_url).open(). This is already being used in Moxin.

The Rust Playground website allows attaching code to its URL: https://play.rust-lang.org/?code=<your-encoded-code-here>.

For example, opening a Rust Playground including a simple hello world, can be done with the following URL:
https://play.rust-lang.org/?code=fn%20main()%20%7B%0A%20%20%20%20println!%28%22Hello%2C%20world!%22%29%3B%0A%7D

Design is up for discussion, but I would suggest using something like a small ferris (rust mascot) PNG. It can be gray, and turn orange (the ferris color) on hover.

@joulei joulei changed the title Add a link for Rust Playground whenever AI replied with rust code Add a link for Rust Playground whenever AI replies with rust code Sep 10, 2024
@joulei joulei changed the title Add a link for Rust Playground whenever AI replies with rust code Display a link for Rust Playground whenever AI replies with rust code Sep 10, 2024
@joulei joulei added the enhancement New feature or request label Sep 10, 2024
@Guocork
Copy link
Collaborator

Guocork commented Sep 19, 2024

#254

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants