[Beta] Using URL arguments confuses IDE

When I run an app from the IDE in a new tab and append an argument to the URL (like ?users=ZZZ) the IDE thinks the app is not running anymore (Stop and Focus buttons disappear).

I can understand why this happens (the UI is reloaded in the browser), but still might be confusing to the user.

Anvil doesn’t manage the query string starting with ?.

You can use the hash and start it with #, which is ignored by the server and only interpreted by the client.

See this and this, which is also included in Anvil Extras.

I should have been clearer. I use hash routing (from anvil extras). However in addition I want to pass arguments to the page, which I can successfully do by adding ?user=something.
My point was, that when testing the app in the IDE, the IDE gets confused and interprets the app as being terminated.

It is the first time I hear about this working… are you sure about this?

As far as I know the query string in Anvil has always caused the server not to recognize the app. In fact, this is the very reason why you will find many requests about SEO optimization, which are impossible in Anvil for that very reason.

Very sure. I have code like this:

from anvil_extras import routing

@routing.route('notifier')
@routing.route('notifier', url_keys=['users'])
class Notifier(NotifierTemplate):
:

and then

  def form_show(self, **event_args):
    args = self.url_dict.get('users', '')
    :

Works fine.

All that code works with #?, not with ? alone.

1 Like

Works with url like https://my.site.com#notifier?users=mm

It works because the app url is followed by #.

In your post you said you were adding ?users=ZZZ.
This will not work.

Now you are saying you are adding #notifier?users=mm, which will work because the app url is followed by #.

The app will work, because the server will ignore the part after the # character. Whether the routing module or the get_url_hash() will work, that’s another story.

The whole point of my post is not to get it working (it already does), but point out that when running the app in the IDE to test the arguments (ie add ?users=xx to the url which already includes #notifier), the IDE cannot track the app’s run status.

I’m sorry, I still don’t understand your question.

Adding ?users=ZZZ to the app url has never worked.
Adding #?users=ZZZ works.
Adding #notifier?users=mm also works.

I work running the app on its own tab and I often edit the hash query string and it works just fine.

Can you try to add more details to your question?

Run app in new tab.
Observe buttons in IDE:

Add #notifier (or #notifier?users=XX) to url (which looks like https://wnsqxxmeprz7xfda.anvil.app/debug/....%3D3VC7CXKYZNOZJDUGVHERHLNO/_/debug) . Press enter. App navigates to notifier route.

Observe buttons in IDE:

So as far as the IDE is concerned, the app has finshed, whereas, in actuality it is running.

I just tried and it works just fine.

That’s my daily workflow.

I edit the app on the IDE, then press F5 on the external tab and the app reloads and runs.
The IDE doesn’t even know the app has been refreshed, indeed the buttons that you show don’t change and the “Running App Console” shows the output under the output of the previous session.

Does it happen only with one app/browser/OS?

Ah that’s it:
Safari: fails
Firefox: works
Chrome: works

All on macOS 12.0.1

4 Likes

Can somebody move this to bug reports? TIA

Safari isn’t one of our supported browsers for the IDE.

For the IDE, we only support Chrome and Firefox.
We’ll make sure we update our documentation to mention this.

2 Likes

A shame that the snappiest browser on the Mac is excluded, especially since the IDE mostly works in Safari. It would also mean that the resulting app is less frequently tested on Safari.