Skip to content

Reload web view when reopening different inline button#30725

Open
eav93 wants to merge 1 commit into
telegramdesktop:devfrom
eav93:fix/inline-webapp-reopen
Open

Reload web view when reopening different inline button#30725
eav93 wants to merge 1 commit into
telegramdesktop:devfrom
eav93:fix/inline-webapp-reopen

Conversation

@eav93
Copy link
Copy Markdown

@eav93 eav93 commented May 24, 2026

Problem

Fixes #29475.

When two inline keyboard buttons in the same chat point to different web app URLs of the same bot, clicking the second one while the first web app panel is still open silently does nothing — the new URL is not loaded and no event (themeChanged, viewportChanged, etc.) is fired inside the running web app.

Root cause

AttachWebView::open() deduplicates by (bot, source):

for (const auto &instance : _instances) {
    if (instance->bot() == descriptor.bot
        && instance->source() == descriptor.source) {
        instance->activate();
        return;
    }
}

For inline buttons the source is built in api/api_bot.cpp as

.source = InlineBots::WebViewSourceButton{ .simple = false },

WebViewSourceButton only stores the simple flag, so two different inline buttons of the same bot always compare equal. The match succeeds and activate() just calls _panel->requestActivate() on the existing panel, ignoring the new URL entirely.

Fix

Include the button URL in WebViewSourceButton so distinct URLs produce distinct sources, and a fresh WebViewInstance is created (matching how, e.g., MainMenu and InlineButton already coexist for the same bot).

  • Telegram/SourceFiles/inline_bots/bot_attach_web_view.h — add QByteArray url to WebViewSourceButton, switch the defaulted operator== to by-const-ref since the struct is no longer trivial enough to pass by value cleanly.
  • Telegram/SourceFiles/api/api_bot.cpp — pass button->data as the new url field in both ButtonType::WebView and ButtonType::SimpleWebView paths.

Clicking the same button twice still hits the dedup path (URL is identical) and only re-activates the existing panel — previous behavior preserved.

Out of scope

The original issue also mentions the deactivated event not firing when tapping outside the panel. That lives in Ui::BotWebView::Panel and is a separate change.

Test plan

  • Open inline web app A from bot, then click inline button opening web app B of the same bot — B should load in its own panel.
  • Click the same inline button twice — second click should just re-focus the existing panel, no reload.
  • Regression: open Main Menu web app, then open inline button web app of the same bot — both should keep working independently as before.

WebViewSourceButton compared only the `simple` flag, so two different
inline keyboard buttons opening different URLs produced equal sources.
AttachWebView::open() then just activated the previously opened panel
for the same bot and dropped the new URL on the floor, with no events
fired in the running web app.

Include the button URL in WebViewSourceButton so that distinct URLs
produce distinct sources and a fresh WebViewInstance is created.

Fixes telegramdesktop#29475.
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 24, 2026

CLA assistant check
All committers have signed the CLA.

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.

Missing events and reload on opening second Web App via InlineKeyboard

2 participants