Skip to content

manager: add external link warning for WebUI#3553

Draft
u9521 wants to merge 4 commits into
tiann:mainfrom
u9521:webui-extlink-1
Draft

manager: add external link warning for WebUI#3553
u9521 wants to merge 4 commits into
tiann:mainfrom
u9521:webui-extlink-1

Conversation

@u9521

@u9521 u9521 commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

refactor WebUI, add a warning before opening links outside the module WebUI, and provide an opt-in setting for loading external WebUI content

This comment was marked as outdated.

@5ec1cff
5ec1cff requested review from KOWX712 and YuKongA July 4, 2026 06:16
@u9521
u9521 force-pushed the webui-extlink-1 branch from 8060dfc to 991b23a Compare July 4, 2026 11:52
@u9521
u9521 marked this pull request as ready for review July 4, 2026 11:57
@YuKongA
YuKongA requested a review from Copilot July 4, 2026 12:31

This comment was marked as outdated.

@u9521
u9521 force-pushed the webui-extlink-1 branch from e62ee1d to 511d7df Compare July 7, 2026 05:05
@YuKongA

YuKongA commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator

改的有点多,我不想看,下面是 claude code 的 review:

image

@KOWX712

KOWX712 commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator

restructure 和功能改动参在一起不好 review, 另外就是个人觉得弹窗有点多余了

@u9521

u9521 commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

改的有点多,我不想看,下面是 claude code 的 review:

image

1,2点iframe跳转是不受ShouldOverrideUrlLoading影响的,只有miuix的组件有点击穿透的效果。

@u9521

u9521 commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

restructure 和功能改动参在一起不好 review, 另外就是个人觉得弹窗有点多余了

关于重构的问题,之前试过直接改,问题有点多。

弹窗功能确实值得商榷,主要是有人提了个webui跳转外链ksu接口暴露的问题,就写了个弹窗,但是还有一点问题,页面内的iframe也是能用到接口的。跳转外链去接口也会有一些问题。弹窗也算是个折中的方案。

最后的想法是把外部内容全禁掉,设置里面加个开关允许webui加载外部内容,再后续把开关删了。
毕竟webui要是遇上xss不是一般的问题

@u9521
u9521 marked this pull request as draft July 20, 2026 03:14
u9521 added 4 commits July 22, 2026 14:01
clean Model-View-Intent (MVI) architecture with unidirectional data
flow.

Architecture changes:
- Introduce WebUIViewModel as the single owner of state and effects
- Replace mutable WebUIState with an @immutable data class driven by
  StateFlow, ensuring correct Compose recomposition skipping
- Define WebUIIntent as a sealed interface for all user/system actions
- Define WebUIEffect (SharedFlow) for one-shot side effects such as
  Toast, finish, file chooser launch, and JS evaluation
- Extract WebUIRuntime to hold platform objects (WebView, Shell,
  FileCallback) that cannot be part of immutable state

Package restructuring:
- bridge/   - WebViewInterface (JS bridge)
- model/    - Insets, WebUIState, WebUIIntent, WebUIEffect, WebUIOverlay
- runtime/  - WebUIRuntime
- ui/       - WebUIScreen, WebUILoading, WebUIEventHandler,
              WebUIEventsMaterial, WebUIEventsMiuix, WebUILifecycle,
              WebViewContainer
- util/     - MimeUtil, WebUIExtensions
- viewmodel/ - WebUIViewModel
- webview/  - WebViewClients, WebViewConstants, WebViewFactory,
              WebViewPreparer
- webview/asset/ - MonetColorsProvider, SuFilePathHandler

Other improvements:
- Add displayCutout union to systemBars insets for better cutout
  handling
- Wrap WebUI content in theme-aware Surface (Material3 / Miuix) so
  the background color is provided by the theme instead of being
  manually set on each composable
- Move JS dialog state (alert/confirm/prompt) from JsResult stored
  in state to pending fields in ViewModel, keeping only display data
  in the overlay sealed interface
- Move file chooser flow from UI event to effect, launching via
  ActivityResultLauncher from the Activity's effect collector
- Extract LoadingContent into standalone WebUILoading composable
- Extract WebView creation, constants, and client setup into
  dedicated files under webview/

Signed-off-by: u9521 <63995396+u9521@users.noreply.github.com>
Intercept navigation away from trusted WebUI and local loopback origins
instead of loading external destinations in the embedded WebView.

Present a localized warning screen in both Material and Miuix modes, allowing
users to return to the WebUI or explicitly open the URL in an external browser.
Track the flow through WebUI state, intents, and effects, pause the WebView
while the warning is displayed, and make the system back action dismiss it
first.

Handle missing browser applications with a toast and read the WebView
debugging preference through SettingsRepository.
Use a buffered channel for one-shot effects, reset transient state when a
module becomes ready, and allow local URL schemes inside the WebView. Also
make WebView assignment observable and clean up external-link warning state
after its exit animation.

Signed-off-by: u9521 <63995396+u9521@users.noreply.github.com>
Signed-off-by: u9521 <63995396+u9521@users.noreply.github.com>
@u9521
u9521 force-pushed the webui-extlink-1 branch from ba6c57d to c9af68a Compare July 22, 2026 06:03
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.

4 participants