You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add WebViewEnv and wire web preview to the mock WaveEnv contract (#3064)
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.
```ts
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"
>;
}>;
```
- **Screenshot**
-
<screenshot>https://github.com/user-attachments/assets/8921737f-490d-4719-8131-15f07c15a74c</screenshot>
<!-- START COPILOT CODING AGENT TIPS -->
---
📍 Connect Copilot coding agent with [Jira](https://gh.io/cca-jira-docs),
[Azure Boards](https://gh.io/cca-azure-boards-docs) or
[Linear](https://gh.io/cca-linear-docs) to delegate work to Copilot in
one click without leaving your project management tool.
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sawka <2722291+sawka@users.noreply.github.com>
Co-authored-by: sawka <mike@commandline.dev>
data-webcontentsid={webContentsId}// needed for emain
1089
-
preload={getWebviewPreloadUrl()}
1098
+
preload={getWebviewPreloadUrl(env)}
1090
1099
// @ts-expect-error This is a discrepancy between the React typing and the Chromium impl for webviewTag. Chrome webviewTag expects a string, while React expects a boolean.
0 commit comments