mojira.dev
MC-240502

JFR links copy the path to the report when clicked, inconsistent with other functions

The Bug

Upon clicking the link given in the chat after generating a JFR report, the path to the report is copied. This is inconsistent with the screenshot function and the debug tick profiling function, which both either open a file or open a file explorer to view the file.

How to Reproduce

  1. Run /jfr start

  2. Run /jfr stop

  3. Click the link given in the chat to the JFR report
    ❌ Nothing opens

Observed Behavior

The link didn't bring up any file, but instead copied the file's path to the clipboard.

Expected Behavior

The File Explorer (Finder on macOS) would open to the JFR report generated, or the JFR report would open in a default application. This would be consistent with other functions.

Linked issues

Comments 7

I can confirm this behavior. 

Clicking on links to files doesn't usually open the file explorer (think: screenshots), so you'll need a default application selected for .jfr files for the links to open

That's true, thank you. I do have TextEdit set as my default application, and it still does not open there. I've adjusted the report accordingly.

Code analysis using yarn mappings:
In the executeStop method of JfrCommand, it can be seen that this command is not supposed to open a file explorer or a file for the user. Instead, it is supposed to copy a file path to the clipboard:

MutableText lv = new LiteralText(file.getName()).formatted(Formatting.UNDERLINE).styled(arg -> arg.withClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, file.getAbsolutePath())));

This may still be considered an inconsistency with the screenshot function and the debug tick profiling function.

Note: A fix for this would likely include adding an "Open File" clickevent to JSON Chat Components, or somehow making the message purely client-side (which would also fix MC-240534)

Thanks for the report. This is WAI since it's a command used on both client and server.
Also, since there are no sensible defaults for how to open .jfr files a clipbboard copy makes more sense.

This was changed to add hover text indicating that by clicking the link, rather than going to a file, you are copying text to the clipboard. 🙂

[Mod] markderickson

billysjoberg

Confirmed

Normal

UI

21w44a

Retrieved