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

Python Apps - Terminal size can interfere with URL matching #5407

Open
jonvanausdeln opened this issue Nov 18, 2024 · 2 comments
Open

Python Apps - Terminal size can interfere with URL matching #5407

jonvanausdeln opened this issue Nov 18, 2024 · 2 comments
Labels
area: run app bug Something isn't working
Milestone

Comments

@jonvanausdeln
Copy link
Contributor

System details:

Positron and OS details:

Current main branch
Windows (but probably not a windows only issue)

Interpreter details:

Python 3.12.1

Describe the issue:

When running smoke tests on windows, the screen can be small enough that when the URL is off screen, the Run App URL matching gets confused.

Image

Image

@sharon-wang has some insight to provide context

Steps to reproduce the issue:

  1. Run the Python Apps test on windows CI

Test fails as the app is not displayed in Viewer.

Expected or desired behavior:

Test to pass

Were there any error messages in the UI, Output panel, or Developer Tools console?

@sharon-wang
Copy link
Member

I believe the new URL() call here is the one that's failing. My hunch is that the URL was not correctly parsed from the Terminal because the URL appears on two lines, but it's hard to say without logging out what exactly got matched. It's also possible that we returned the wrong match group, but were able to detect the URL in the Terminal output.

// Check if the app url is found in the terminal output.
if (!appUrl) {
const match = extractAppUrlFromString(dataCleaned, options.appUrlStrings);
if (match) {
appUrl = new URL(match);
log.debug(`Found app URL in terminal output: ${appUrl.toString()}`);
// If the app is ready, we're done!
if (appReady) {
return appUrl;
}
}
}

Some things we can try:

  • add log.debug(`Matched URL in terminal output: ${match}`); right after if (match) so we can see what string was matched before trying to construct a url
    • it's possible that the match group was incorrect and we matched a different part of the terminal output instead of the URL
  • if the size of the Terminal is the culprit here, we should still be able to parse out the URL. We may need to keep a buffer/string of all terminal output and check if the URL can be found in the full output as opposed to checking against the most recent data in the terminal output stream

@sharon-wang sharon-wang added area: run app bug Something isn't working labels Nov 18, 2024
jonvanausdeln added a commit that referenced this issue Nov 18, 2024
### Intent

Due to #5407 , the console pane needs to be bigger for windows CI Tests

### Approach

In gradio test, added minimizing both sidebars before running app, then bringing them back before viewer is checked.

### QA Notes

Python app test should pass.
https://github.com/posit-dev/positron/actions/runs/11900458691
@petetronic petetronic added this to the Future milestone Nov 18, 2024
@seeM
Copy link
Contributor

seeM commented Nov 20, 2024

We may need to keep a buffer/string of all terminal output and check if the URL can be found in the full output as opposed to checking against the most recent data in the terminal output stream

@sharon-wang In case it's helpful, I did notice while initially working on Python app support that terminal shell integration sometimes unexpectedly created a new "execution", so suspect your suggestion is the way to go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: run app bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants