Skip to content

Add WebViewEnv and wire web preview to the mock WaveEnv contract#3064

Open
Copilot wants to merge 3 commits intomainfrom
copilot/add-webview-env-mock
Open

Add WebViewEnv and wire web preview to the mock WaveEnv contract#3064
Copilot wants to merge 3 commits intomainfrom
copilot/add-webview-env-mock

Conversation

Copy link
Contributor

Copilot AI commented Mar 14, 2026

The webview preview existed, but the webview feature was still reading key dependencies from global helpers instead of a narrowed WaveEnv, which left the preview without a proper mock environment contract. This change introduces a dedicated WebViewEnv and routes the webview model/view through it so preview/test mocks can supply the same dependencies explicitly.

  • WaveEnv narrowing for webview

    • Added frontend/app/view/webview/webviewenv.ts
    • Declares the exact webview dependencies used by the feature:
      • electron: openExternal, getWebviewPreload, clearWebviewStorage, getConfigDir, setWebviewFocus
      • rpc: FetchSuggestionsCommand, SetMetaCommand, SetConfigCommand
      • wos, createBlock
      • getSettingsKeyAtom("web:defaulturl" | "web:defaultsearch")
      • getBlockMetaKeyAtom("web:hidenav" | "web:useragenttype" | "web:zoom" | "web:partition")
  • WebView model/view now consume env-provided dependencies

    • WebViewModel now stores and uses waveEnv instead of reaching into global singletons for WOS, settings, block meta, RPC, and Electron APIs.
    • The React view now reads web:defaultsearch, web:zoom, and web:partition from useWaveEnv<WebViewEnv>().
    • Webview event paths that create blocks / manage focus / use Electron preload are now driven by the env contract.
  • Preview/mock behavior aligned with production semantics

    • Updated the web preview mock search template to use {query}, matching the webview search-template substitution logic.
    • Fixed mock SetConfigCommand behavior so settings updates remain observable through getSettingsKeyAtom, which is required for env-driven preview behavior.
    • Clearing block homepage now removes pinnedurl via null, matching the mock RPC meta-deletion semantics.
  • Focused coverage

    • Extended the existing webview test to verify that homepage resolution and config updates flow through the supplied mock env rather than global helpers.
export type WebViewEnv = WaveEnvSubset<{
    electron: {
        openExternal: WaveEnv["electron"]["openExternal"];
        getWebviewPreload: WaveEnv["electron"]["getWebviewPreload"];
        clearWebviewStorage: WaveEnv["electron"]["clearWebviewStorage"];
        getConfigDir: WaveEnv["electron"]["getConfigDir"];
        setWebviewFocus: WaveEnv["electron"]["setWebviewFocus"];
    };
    rpc: {
        FetchSuggestionsCommand: WaveEnv["rpc"]["FetchSuggestionsCommand"];
        SetMetaCommand: WaveEnv["rpc"]["SetMetaCommand"];
        SetConfigCommand: WaveEnv["rpc"]["SetConfigCommand"];
    };
    wos: WaveEnv["wos"];
    createBlock: WaveEnv["createBlock"];
    getSettingsKeyAtom: SettingsKeyAtomFnType<"web:defaulturl" | "web:defaultsearch">;
    getBlockMetaKeyAtom: BlockMetaKeyAtomFnType<
        "web:hidenav" | "web:useragenttype" | "web:zoom" | "web:partition"
    >;
}>;

📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.

Co-authored-by: sawka <2722291+sawka@users.noreply.github.com>
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Mar 14, 2026

Deploying waveterm with  Cloudflare Pages  Cloudflare Pages

Latest commit: c2fe9d4
Status: ✅  Deploy successful!
Preview URL: https://d514e4df.waveterm.pages.dev
Branch Preview URL: https://copilot-add-webview-env-mock.waveterm.pages.dev

View logs

Copilot AI changed the title [WIP] Add mock environment for webview widget Add WebViewEnv and wire web preview to the mock WaveEnv contract Mar 14, 2026
Copilot AI requested a review from sawka March 14, 2026 19:33
@sawka sawka marked this pull request as ready for review March 15, 2026 00:31
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.

2 participants