Modern Apps git
git clone https://git.maproj.org/Modern-Apps.git
main ▾

Modern-Apps.git / web / AGENTS.md

AGENTS.md8.1 KiBRenderedCodeRaw
1# AGENTS.md — web/ (':web')
2
3> Scoped supplement. Global rules in root `AGENTS.md` apply. Stay inside `web/` + allowed shared modules. Do not root-scan.
4
5_Install: ./install web (dev by default)._
6- Gradle: :web / dir: web/
7- Package roots present: ui, data, domain, platform
8- Entry files: MainActivity.kt, Route.kt, Navigation.kt
9- Deps: :library:room, :library:image, :library:network
10- Metadata: metadata_data/web.md (present)
11- Rust: yes / screenshotTest: yes
12
13## Overview
14**Purpose:** Privacy browser — WebView with bundled-filter Shields (ad/tracker blocking), fingerprint randomization, per-site controls, PWA install, private tabs. User-host browsing pins `TrustBundle.SYSTEM` (deliberate exception to the narrowest-bundle rule).
15**Key features:**
16- Shields engine (`platform/shields/`: request filter, WebView clients, JS injection, service-worker client) over the Rust core (`shields/ShieldsNative`) with `domain/shields/` URL cleaning; per-site panel + fingerprint controls
17- Tabs with thumbnails, bookmarks/history/downloads, installed-site PWAs in a standalone `PwaActivity`, desktop-mode toggle
18- The tab switcher never leaves the browser at zero tabs: closing the last tab (tile X, flick, or "Clear all tabs") replaces it with one fresh new tab; the grid insets its last row clear of the bottom navigation area
19- Search engines are `SearchEngine` entries in `platform/BrowserState.kt`; "MA Search" (`SELF_HOSTED`) is selectable in every build and renders `GET https://api.maproj.org/api/search` results natively
20- LAN safety policy (`domain/LanPolicy`, `LocalNetwork`) + per-site permissions/storage (`WebPermissions`, permission sheets)
21**Architecture / data-flow:** `ui/` chrome (omnibox, menu, tab switcher, panels) → `platform/WebViewModel` (+ split `Permissions`/`SiteData` helpers, `BrowserState`) → `data/WebRepository` over Room (bookmarks/history/tabs/favicons) + `platform/shields/ShieldsEngine` on the network path; `platform/ContentFilters` + `ThumbnailCapture` + `WindowLauncher` support.
22**Entry points + reading order:** `Route` → `MainActivity.kt` → `Navigation.kt` → `ui/BrowserPage.kt` → `platform/WebViewModel.kt` → `platform/shields/ShieldsEngine.kt` → `domain/shields/UrlCleaner.kt`.
23**Gotchas:**
24- Backup/restore goes through `platform/AppBackupAgent` + `SqlCipherDbCodec`, never a raw copy of `web-browser-db` or `secure_prefs.xml`: the SQLCipher passphrase is wrapped by a non-exportable AndroidKeyStore key, so a raw restored database cannot be opened. `app_webview/` is excluded on both backup channels — its cookies are live session credentials and must not be transplanted; users sign in again after a restore
25- `SYSTEM` trust bundle is intentional here (arbitrary user hosts) — do NOT "fix" it to a narrower bundle
26- Shields filtering runs on the request path — regressions break all browsing; test with Shields on AND off
27- PWA windows run outside the browser chrome (`PwaActivity` + `PwaHelper`); window-launch bugs live there, not in `BrowserPage`
28- The omnibox is browser navigation chrome, not screen-level search: the read-only address pill (`BrowserChrome`) and the editable address field anchored to its suggestions overlay (`BrowserOmniboxEditor`) carry `// SCAFFOLD SEARCH EXCEPTION:` markers — do not migrate them to `ScaffoldSearch` (String-typed top-title filter field; it cannot host the pill's read-only display, the editor's `TextFieldValue` selection control/Uri IME navigation submit, or bottom docking)
29- Dialogs are `Route` destinations (`NewFolderDialog`, `DeleteBookmarkDialog`, `DeleteFolderDialog`, `ClearHistoryDialog`, `CacheModeDialog`, `SearchEngineDialog`, `ClearBrowsingDataDialog`) with `DialogPage()` entries in `ui/WebDialogEntries.kt`; pages request them via callbacks (default: push the route) and never hold dialog state. Every `Route` leaf has a deterministic capture in `src/screenshotTest` (`<n>-<route-kebab>` in `MetadataPreviews`), rendered from stateless slices (`HistoryContent`, `DownloadsContent`, `InstalledSitesContent`, `SiteDataContent`, `SettingsContent`, `ShieldsContent`, `BookmarksScreen`) or the library dialog primitives
30
31## Key files
32### Root — entry + navigation
33- com/vayunmathur/web/MainActivity.kt
34- com/vayunmathur/web/Navigation.kt
35- com/vayunmathur/web/Route.kt
36### data/ — Room (bookmarks/history/tabs/permissions)
37- com/vayunmathur/web/data/WebDatabase.kt — `DB_NAME` + `webDbConfigs()` (backup passphrase config; mints the passphrase on a fresh restore target)
38- com/vayunmathur/web/data/WebRepository.kt
39- com/vayunmathur/web/data/Bookmark.kt
40- com/vayunmathur/web/data/HistoryEntry.kt
41- com/vayunmathur/web/data/InstalledSite.kt
42- com/vayunmathur/web/data/TabThumbnailStore.kt
43- com/vayunmathur/web/data/FaviconStore.kt
44- com/vayunmathur/web/data/ShieldSetting.kt
45- com/vayunmathur/web/data/SitePermission.kt
46### domain/ + domain/shields/ — pure LAN policy + shields rules (no Android)
47- com/vayunmathur/web/domain/LanPolicy.kt
48- com/vayunmathur/web/domain/LocalNetwork.kt
49- com/vayunmathur/web/domain/ShieldsSettings.kt
50- com/vayunmathur/web/domain/shields/UrlCleaner.kt
51- com/vayunmathur/web/domain/shields/ResourceTypes.kt
52### platform/ + platform/shields/ — ViewModel, PWA, permissions, engine
53- com/vayunmathur/web/platform/WebViewModel.kt
54- com/vayunmathur/web/platform/WebViewModelFactory.kt
55- com/vayunmathur/web/platform/AppBackupAgent.kt — stock-OS backup agent (`BaseBackupAgent` + `SqlCipherDbCodec`): carries the re-keyed database and `web_prefs`; `app_webview/` (cookies/cache/session state), `secure_prefs.xml`, the raw database files, `shields/` and `favicons/` are excluded in `res/xml/data_extraction_rules.xml` on both channels
56- com/vayunmathur/web/platform/WebViewModelPermissions.kt
57- com/vayunmathur/web/platform/WebViewModelSiteData.kt
58- com/vayunmathur/web/platform/BrowserState.kt
59- com/vayunmathur/web/platform/ContentFilters.kt
60- com/vayunmathur/web/platform/WebPermissions.kt
61- com/vayunmathur/web/platform/PermissionPrompt.kt
62- com/vayunmathur/web/platform/ExternalIntents.kt
63- com/vayunmathur/web/platform/PwaActivity.kt
64- com/vayunmathur/web/platform/PwaHelper.kt
65- com/vayunmathur/web/platform/WindowLauncher.kt
66- com/vayunmathur/web/platform/ThumbnailCapture.kt
67- com/vayunmathur/web/platform/shields/ShieldsEngine.kt
68- com/vayunmathur/web/platform/shields/ShieldsRequestFilter.kt
69- com/vayunmathur/web/platform/shields/ShieldsWebViewClient.kt
70- com/vayunmathur/web/platform/shields/ShieldsServiceWorkerClient.kt
71- com/vayunmathur/web/platform/shields/ShieldsInjection.kt
72- com/vayunmathur/web/platform/shields/InetHostResolver.kt
73### shields/ — Rust bridge
74- com/vayunmathur/web/shields/ShieldsNative.kt — JNI bridge into the filter core
75### ui/ + ui/components/ — chrome, tabs, panels, settings
76- com/vayunmathur/web/ui/BrowserPage.kt
77- com/vayunmathur/web/ui/BrowserChrome.kt
78- com/vayunmathur/web/ui/BrowserOmnibox.kt
79- com/vayunmathur/web/ui/BrowserOmniboxEditor.kt
80- com/vayunmathur/web/ui/BrowserMenu.kt
81- com/vayunmathur/web/ui/BrowserOverlays.kt
82- com/vayunmathur/web/ui/WebViewBrowser.kt
83- com/vayunmathur/web/ui/WebViewClients.kt
84- com/vayunmathur/web/ui/WebViewSettings.kt
85- com/vayunmathur/web/ui/TabSwitcher.kt
86- com/vayunmathur/web/ui/LinkContextMenu.kt
87- com/vayunmathur/web/ui/BookmarksPage.kt
88- com/vayunmathur/web/ui/HistoryPage.kt, HistoryContent.kt, DownloadsPage.kt, DownloadsContent.kt, InstalledSitesPage.kt, InstalledSitesContent.kt — page hosts + stateless screenshot slices
89- com/vayunmathur/web/ui/PermissionSheets.kt, SiteDataContent.kt — permission sheets + stateless site-data slice
90- com/vayunmathur/web/ui/SearchResultsPage.kt — MA Search sibling routes (`Route.SearchText/SearchImages/SearchNews` over one query, nested nav host under the Browser tab; per-kind fetch slots in `SearchKindStates`)
91- com/vayunmathur/web/ui/SettingsPage.kt, SettingsContent.kt, ShieldsPanel.kt, ShieldsContent.kt — settings/shields hosts + stateless slices
92- com/vayunmathur/web/ui/WebDialogEntries.kt — `DialogPage()` entries for the seven dialog routes
93- com/vayunmathur/web/ui/components/SiteIcon.kt
94- com/vayunmathur/web/ui/components/TabTile.kt
95
96## Verify (this module only)
97```
98./gradlew :web:compileDevKotlin
99./gradlew :web:lint
100./gradlew :web:checkMetadata
101```