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

PWA icon customization #10341

Merged
merged 13 commits into from
Jan 16, 2025
Merged

PWA icon customization #10341

merged 13 commits into from
Jan 16, 2025

Conversation

whitphx
Copy link
Member

@whitphx whitphx commented Jan 13, 2025

@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Jan 13, 2025

🪼 branch checks and previews

Name Status URL
Spaces ready! Spaces preview
Website building...
Storybook ready! Storybook preview
🦄 Changes detected! Details

Install Gradio from this PR

pip install https://gradio-pypi-previews.s3.amazonaws.com/01322940db1b16c8e56716dbca563a634eef7018/gradio-5.12.0-py3-none-any.whl

Install Gradio Python Client from this PR

pip install "gradio-client @ git+https://github.com/gradio-app/gradio@01322940db1b16c8e56716dbca563a634eef7018#subdirectory=client/python"

Install Gradio JS Client from this PR

npm install https://gradio-npm-previews.s3.amazonaws.com/01322940db1b16c8e56716dbca563a634eef7018/gradio-client-1.10.0.tgz

Use Lite from this PR

<script type="module" src="https://gradio-lite-previews.s3.amazonaws.com/01322940db1b16c8e56716dbca563a634eef7018/dist/lite.js""></script>

@whitphx whitphx changed the title Flexibile pwa icon PWA icon customization Jan 13, 2025
@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Jan 13, 2025

🦄 change detected

This Pull Request includes changes to the following packages.

Package Version
@gradio/core minor
@self/spa minor
gradio minor
  • Maintainers can select this checkbox to manually select packages to update.

With the following changelog entry.

PWA icon customization

Maintainers or the PR author can modify the PR title to modify this entry.

Something isn't right?

  • Maintainers can change the version label to modify the version bump.
  • If the bot has failed to detect any changes, or if this pull request needs to update multiple packages to different versions or requires a more comprehensive changelog entry, maintainers can update the changelog file directly.

@whitphx whitphx marked this pull request as ready for review January 13, 2025 03:58
gradio/blocks.py Outdated
@@ -2450,6 +2452,7 @@ def reverse(text):
block.key = f"__{block._id}__"

self.pwa = utils.get_space() is not None if pwa is None else pwa
self.pwa_icon = pwa_icon
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the original comment, the user specifically asks for the pwa icon to reflect the value of favicon_path. It would be cumbersome to expect users to put the same path twice for two separate parameters. I think we should just set the pwa_icon to be the favicon and remove the pwa_icon parameter.

Copy link
Member

@abidlabs abidlabs Jan 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, if we get request for further customization, then I suggest we let developers specify a complete manifest.json file via a parameter. Anything else seems too specific of a parameter.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, that's correct.
I updated the code.

@abidlabs
Copy link
Member

I tested this here, and I'm no longer seeing the PWA installation. Checking the application debugging console:

image

@abidlabs
Copy link
Member

Side note, we don't have much documentation about pwa. Might be good to add a section here: https://www.gradio.app/guides/sharing-your-app

@whitphx
Copy link
Member Author

whitphx commented Jan 15, 2025

I tested this here, and I'm no longer seeing the PWA installation. Checking the application debugging console:

Thanks,
hmm the /pwa_icon/192 endpoint returns 308 redirect. Will see it.

* Request completely sent off
< HTTP/2 308
< date: Wed, 15 Jan 2025 03:40:10 GMT
< server: uvicorn
< location: /
< x-proxied-host: http://10.27.86.25
< x-proxied-path: /pwa_icon/192
< link: <https://huggingface.co/spaces/abidlabs/pwa-test>;rel="canonical"
< x-request-id: VF2w_1
< vary: origin, access-control-request-method, access-control-request-headers
< access-control-allow-credentials: true

@whitphx
Copy link
Member Author

whitphx commented Jan 15, 2025

@abidlabs
Copy link
Member

But I thought we enable it automatically on Spaces?

@whitphx
Copy link
Member Author

whitphx commented Jan 15, 2025

Sorry that's true.

@whitphx
Copy link
Member Author

whitphx commented Jan 15, 2025

We need to configure the SSR server to proxy ./pwa_icon path.
At this moment, PWA with a custom icon is working as https://whitphx-gradio-pwa-test.hf.space/ if ssr_mode=False.
Will make the change.

@whitphx
Copy link
Member Author

whitphx commented Jan 15, 2025

Please try the latest wheel build.

Maybe ignoring cache is needed since the /pwa_icon endpoint was redirected permanently (308)
CleanShot 2025-01-15 at 19 05 59@2x

Copy link
Member

@abidlabs abidlabs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing @whitphx, works great!

Just a nit: in order to reduce the repo size, can you put the gif and image in this Hugging Face Dataset instead? https://huggingface.co/datasets/huggingface/documentation-images/tree/main/gradio-guides

And load the images from there. That's what we do throughout our guides, e.g.

![](https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/df-highlight.png)

@whitphx whitphx enabled auto-merge (squash) January 16, 2025 13:34
@whitphx whitphx merged commit b0cf92f into main Jan 16, 2025
23 checks passed
@whitphx whitphx deleted the flexibile-pwa-icon branch January 16, 2025 14:00
@whitphx
Copy link
Member Author

whitphx commented Jan 16, 2025

Thanks, done!

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

Successfully merging this pull request may close these issues.

PWA should reflect the favicon_path option for its icon
4 participants