Commit 2c88b1d
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>1 parent b0d77a8 commit 2c88b1d
File tree
5 files changed
+120
-53
lines changed- frontend
- app/view/webview
- preview
- mock
- previews
5 files changed
+120
-53
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
4 | 6 | | |
5 | 7 | | |
6 | | - | |
| 8 | + | |
| 9 | + | |
7 | 10 | | |
8 | 11 | | |
9 | 12 | | |
| |||
17 | 20 | | |
18 | 21 | | |
19 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
20 | 59 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | 6 | | |
8 | | - | |
9 | 7 | | |
10 | | - | |
| 8 | + | |
11 | 9 | | |
12 | 10 | | |
13 | 11 | | |
14 | 12 | | |
15 | 13 | | |
16 | 14 | | |
17 | 15 | | |
18 | | - | |
| 16 | + | |
| 17 | + | |
19 | 18 | | |
20 | 19 | | |
21 | 20 | | |
22 | 21 | | |
23 | 22 | | |
24 | 23 | | |
25 | 24 | | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| 75 | + | |
75 | 76 | | |
76 | | - | |
| 77 | + | |
77 | 78 | | |
78 | 79 | | |
79 | 80 | | |
80 | 81 | | |
| 82 | + | |
81 | 83 | | |
82 | | - | |
| 84 | + | |
83 | 85 | | |
84 | | - | |
| 86 | + | |
85 | 87 | | |
86 | 88 | | |
87 | 89 | | |
| |||
97 | 99 | | |
98 | 100 | | |
99 | 101 | | |
100 | | - | |
| 102 | + | |
101 | 103 | | |
102 | 104 | | |
103 | | - | |
| 105 | + | |
104 | 106 | | |
105 | 107 | | |
106 | 108 | | |
| |||
199 | 201 | | |
200 | 202 | | |
201 | 203 | | |
202 | | - | |
| 204 | + | |
203 | 205 | | |
204 | 206 | | |
205 | 207 | | |
| |||
280 | 282 | | |
281 | 283 | | |
282 | 284 | | |
283 | | - | |
| 285 | + | |
284 | 286 | | |
285 | 287 | | |
286 | 288 | | |
| |||
369 | 371 | | |
370 | 372 | | |
371 | 373 | | |
372 | | - | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
373 | 380 | | |
374 | 381 | | |
375 | 382 | | |
| |||
415 | 422 | | |
416 | 423 | | |
417 | 424 | | |
418 | | - | |
| 425 | + | |
419 | 426 | | |
420 | 427 | | |
421 | 428 | | |
| |||
437 | 444 | | |
438 | 445 | | |
439 | 446 | | |
440 | | - | |
| 447 | + | |
441 | 448 | | |
442 | 449 | | |
443 | 450 | | |
| |||
477 | 484 | | |
478 | 485 | | |
479 | 486 | | |
480 | | - | |
481 | | - | |
| 487 | + | |
| 488 | + | |
482 | 489 | | |
483 | 490 | | |
484 | 491 | | |
485 | 492 | | |
486 | | - | |
487 | | - | |
488 | | - | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
489 | 496 | | |
490 | | - | |
| 497 | + | |
491 | 498 | | |
492 | 499 | | |
493 | 500 | | |
| |||
537 | 544 | | |
538 | 545 | | |
539 | 546 | | |
540 | | - | |
| 547 | + | |
541 | 548 | | |
542 | 549 | | |
543 | 550 | | |
| |||
583 | 590 | | |
584 | 591 | | |
585 | 592 | | |
586 | | - | |
587 | | - | |
| 593 | + | |
| 594 | + | |
588 | 595 | | |
589 | 596 | | |
590 | 597 | | |
| |||
632 | 639 | | |
633 | 640 | | |
634 | 641 | | |
635 | | - | |
636 | | - | |
| 642 | + | |
| 643 | + | |
637 | 644 | | |
638 | 645 | | |
639 | 646 | | |
| |||
645 | 652 | | |
646 | 653 | | |
647 | 654 | | |
648 | | - | |
649 | | - | |
| 655 | + | |
| 656 | + | |
650 | 657 | | |
651 | 658 | | |
652 | 659 | | |
| |||
658 | 665 | | |
659 | 666 | | |
660 | 667 | | |
661 | | - | |
662 | | - | |
| 668 | + | |
| 669 | + | |
663 | 670 | | |
664 | 671 | | |
665 | 672 | | |
| |||
696 | 703 | | |
697 | 704 | | |
698 | 705 | | |
699 | | - | |
700 | | - | |
| 706 | + | |
| 707 | + | |
701 | 708 | | |
702 | 709 | | |
703 | 710 | | |
| |||
735 | 742 | | |
736 | 743 | | |
737 | 744 | | |
| 745 | + | |
738 | 746 | | |
739 | 747 | | |
740 | | - | |
| 748 | + | |
741 | 749 | | |
742 | 750 | | |
743 | 751 | | |
744 | 752 | | |
745 | 753 | | |
746 | 754 | | |
747 | | - | |
| 755 | + | |
748 | 756 | | |
749 | 757 | | |
750 | 758 | | |
| |||
824 | 832 | | |
825 | 833 | | |
826 | 834 | | |
| 835 | + | |
827 | 836 | | |
828 | 837 | | |
829 | | - | |
| 838 | + | |
830 | 839 | | |
831 | 840 | | |
832 | 841 | | |
833 | 842 | | |
834 | 843 | | |
835 | 844 | | |
836 | | - | |
| 845 | + | |
837 | 846 | | |
838 | | - | |
| 847 | + | |
839 | 848 | | |
840 | 849 | | |
841 | 850 | | |
| |||
1027 | 1036 | | |
1028 | 1037 | | |
1029 | 1038 | | |
1030 | | - | |
| 1039 | + | |
1031 | 1040 | | |
1032 | 1041 | | |
1033 | 1042 | | |
1034 | | - | |
| 1043 | + | |
1035 | 1044 | | |
1036 | 1045 | | |
1037 | 1046 | | |
| |||
1086 | 1095 | | |
1087 | 1096 | | |
1088 | 1097 | | |
1089 | | - | |
| 1098 | + | |
1090 | 1099 | | |
1091 | 1100 | | |
1092 | 1101 | | |
| |||
1104 | 1113 | | |
1105 | 1114 | | |
1106 | 1115 | | |
1107 | | - | |
| 1116 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
| 102 | + | |
106 | 103 | | |
107 | 104 | | |
108 | 105 | | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
| 106 | + | |
113 | 107 | | |
114 | 108 | | |
115 | 109 | | |
| |||
345 | 339 | | |
346 | 340 | | |
347 | 341 | | |
348 | | - | |
| 342 | + | |
349 | 343 | | |
350 | 344 | | |
351 | 345 | | |
| |||
0 commit comments