monarch icon indicating copy to clipboard operation
monarch copied to clipboard

DevTools attach to main monarch app instead of a story

Open ezmegy opened this issue 2 years ago • 3 comments

I can't seem to debug any stories in DevTools. Not sure yet if this is a bug or just me missing something though...

Whenever I press the "Launch DevTools..." button, it seems to attach to the main Monarch app instead of the story and I can only debug that but not stories.

I have monarch v3.7.0 flutter package and v2.2.2 binary installed on a Mac.

Minimal repro:

  • monarch run
  • select "primary" from the sample_button_stories
  • press Launch DevTools...

In DevTools, Flutter Inspector

  • the console says the active story id was set properly to sample_button_stories.dart
  • but the Widget Tree that was loaded is the MonarchControllerApp's in and Switching to the Debugger tab
  • the monarch_controller_main.dart file is loaded and
  • can't open the story's file (cmd + P and then searching for "sample_button")

See the screenshots of these below.

I've tried restarting/reloading the stories and DevTools, didn't seem to help.

Any pointers what could be wrong?

Screenshot 2023-11-07 at 11 12 15

Screenshot 2023-11-07 at 11 13 07

ezmegy avatar Nov 07 '23 10:11 ezmegy

Can you quit Monarch ⌃C on your terminal and then run it again? I remember seeing this issue in older Flutter versions. However, this issue was not consistent. You may need to try a couple of times until DevTools attaches to your stories.

I just tried it on Flutter 3.13.6 on macOS without issues. Attaching and debugging stories worked as expected.

fertrig avatar Nov 07 '23 16:11 fertrig

Thanks for the quick response!

Looks like the Flutter version does matter indeed.

v3.13.6 -> works fine v3.13.7 -> issue - was on this originally, quitting/restarting monarch didn't help v3.13.9 -> same issue

Will try and test/dig a bit more...

ezmegy avatar Nov 08 '23 11:11 ezmegy

I had documented this issue and its workaround on the code:

https://github.com/Dropsource/monarch/blob/c36e271a93ba484171146c08a54449e85665b266/platform/macos/monarch_macos/WindowManager.swift#L121-L130

The workaround had been working but I think it is time to look into a proper fix.

fertrig avatar Nov 08 '23 15:11 fertrig