82 lines
7.6 KiB
Markdown
82 lines
7.6 KiB
Markdown
# Keep her safe, inside the apps (G-T4)
|
|
|
|
Status: built on `feature/keep-her-safe-apps`, 2026-11-17. Closes the release blocker found in
|
|
[`tauri-platforms.md`](tauri-platforms.md) G-T4 and, if a round trip is seen, G-T5. Builds on
|
|
[`keep-her-safe.md`](keep-her-safe.md). Review:
|
|
[`feature-keep-her-safe-apps.md`](../reviews/feature-keep-her-safe-apps.md).
|
|
|
|
## 1. Why and what, in the player's terms
|
|
|
|
*Keep her safe* is how a player makes sure their rose cannot be lost, and how she moves to another
|
|
device. In the browser it tells the truth about the browser. In the Android and desktop apps it
|
|
said the same words, and they were wrong there: *This browser may clear her if the garden is not
|
|
opened for a long time* — there is no browser, and an app's own storage is not cleared for being
|
|
left alone. It offered *Ask the browser to keep her*, which always answers no in an app. And on
|
|
Android, *Save her to a file* did nothing at all (measured on the tablet). A player was told she
|
|
might be lost, and the one remedy failed without a word.
|
|
|
|
Now, in the apps:
|
|
|
|
- She says where she lives, truly and calmly: *She lives in this app, on this device, until the app
|
|
is removed. A saved file keeps her anywhere.* No button that cannot work.
|
|
- *Save her to a file* opens Android's own *save* screen; the player chooses where (the phone, a
|
|
memory card, a cloud folder they already use). When the file is written, the garden says
|
|
*She is in that file now.* If they step back, nothing is said.
|
|
- *Bring her back from a file* opens Android's own file picker, as before.
|
|
|
|
The PWA is unchanged.
|
|
|
|
## 2. Technical architecture
|
|
|
|
```mermaid
|
|
flowchart LR
|
|
ks["packages/ui<br/>KeepSafe.svelte"] -->|"wiring.saveFile(name, text)<br/>wiring.keeping.where"| app["apps/rosea<br/>App.svelte"]
|
|
app -->|"PWA / Windows: <a download>"| browser["browser / WebView2 download"]
|
|
app -->|"Android: window.roseaFile.save(name, text)"| bridge["apps/rosea-tauri/android/java<br/>MainActivity.kt (copied into gen/)"]
|
|
bridge -->|"ACTION_CREATE_DOCUMENT"| saf["Android's save screen<br/>(Storage Access Framework)"]
|
|
saf -->|"uri"| bridge
|
|
bridge -->|"write, then event 'rosea-file-saved' (true|false)"| app
|
|
```
|
|
|
|
| # | Decision | Why |
|
|
|:--|:--|:--|
|
|
| A1 | **The words follow where she lives**: `RoseWiring.keeping.where` is `'browser'` or `'app'`, set in `App.svelte` from `__ROSEA_SHELL__`. In an app, `KeepSafe` shows `safe.app` and never asks `persist()`. | The words state facts about the platform; the platform decides which facts are true (lessons/design.md). The package chooses among its own words; the app only says where it is. |
|
|
| A2 | **Android saves through a small Kotlin bridge**, not a Tauri plugin: `MainActivity` adds one JavaScript interface, `roseaFile.save(name, text)`, which opens `ACTION_CREATE_DOCUMENT` through Tauri's own `launchActivityForResult` and writes the text to the chosen place. | No new dependency, no download, no IPC and no capability: the shell still grants the page nothing through Tauri. The Storage Access Framework needs **no permission** on any Android version (the APK check still demands none). A plugin (dialog + fs) would bring IPC, a capability, a CSP change and two packages for one file. iOS will need its own answer (G-T1). |
|
|
| A3 | **The bridge takes only what a rose file is**: a name like `rose-2026-11-17.json` and text up to 8 MB; anything else is refused before the picker opens. One save at a time. | The interface is reachable by any script in the page; the page is our own and has no network, but the bridge stays as narrow as the job. |
|
|
| A4 | **The answer comes back as a window event** (`rosea-file-saved`, `true` or `false`), dispatched by `evaluateJavascript`; `saveFile` returns a promise of it. The garden says *She is in that file now.* only on `true`. | The player sees the system screen close; without a word they cannot know whether it worked. A cancelled save is the player's choice and is not commented on. |
|
|
| A5 | `MainActivity.kt` lives in `apps/rosea-tauri/android/java/` and is copied over the generated one by `scripts/android.ts apply`; `check` refuses an APK build without it. The bridge class carries `@Keep` so a minified release build cannot strip it. | `gen/` is never committed (D6 in tauri-platforms.md). |
|
|
| A7 | **The page is kept between Android's system bars**, which show the garden's paper (light or dark with the system). Added after the tablet's screenshot showed the clock over the title and the navigation bar over *Bring her back from a file*. | Tauri's stock activity draws edge to edge, and the WebView does not reliably report the bars as `env(safe-area-inset-*)` (Culina measured the same). The colours are `--paper` from `tokens.css`, held equal by a test. |
|
|
| A6 | Windows keeps `<a download>`: WebView2 saves to *Downloads* and shows its own download flyout (measured in the platform review). | It works; the browser's own feedback is the confirmation there, as in the PWA. |
|
|
|
|
## 3. Risk analysis
|
|
|
|
| Risk | Answer |
|
|
|:--|:--|
|
|
| **Fear**: words that say she may be lost. | Removed in the apps (A1). The new sentence says the one true condition (removing the app) and the remedy. |
|
|
| **A broken promise**: a save that does nothing. | Fixed on Android (A2) and confirmed to the player (A4). |
|
|
| **Location in the file.** | Unchanged: the file never holds the town (keep-her-safe.md K4). |
|
|
| **Bytes leaving the device.** | Only where the player chooses in Android's save screen. If they choose a cloud folder, that app uploads it — their choice, made in the system's own screen. The game still has no `INTERNET`. |
|
|
| **A script calling the bridge.** | Only the game's own page runs in the WebView (no network, `'self'` CSP). The bridge refuses any other name or a huge text, and it can only open a screen the player must confirm. |
|
|
| **Reachability, guilt, counting.** | None: nothing new reaches anyone or counts anything. |
|
|
|
|
## 4. Gap analysis
|
|
|
|
Closes G-T4 for Android and Windows, and G-T5 on Android: the round trip (save through Android's
|
|
screen, bring her back from that file) passed on the tablet twice, 2026-11-17. Bringing her back on
|
|
Windows was not driven. iOS stays G-T1: WKWebView will need its own save (a share sheet or a document picker).
|
|
|
|
## 5. Verification matrix
|
|
|
|
| Case | Kind | Where |
|
|
|:--|:--|:--|
|
|
| In an app: the app sentence, no *Ask*, no install hint, `persisted()` and `persist()` never called | unit | `packages/ui/test/rose.test.ts` |
|
|
| The app words never speak of a browser | unit | same |
|
|
| In a browser: the browser sentences as before | unit | same (existing cases) and the e2e suite |
|
|
| `saveFile` answering `true` → *She is in that file now.*; `false` → the word goes; a browser download → nothing said | unit | same |
|
|
| The bridge's contract with the game: package = identifier, interface name `roseaFile`, event `rosea-file-saved` with `.detail === true`, the file-name rule accepts `rose-<day>.json` and refuses five wrong names, `@Keep` on the class and method, no permission asked | unit (reads both sources) | `apps/rosea-tauri/test/android-bridge.test.ts` |
|
|
| The size limit (8 MB) and one-save-at-a-time | — | Kotlin only, not tested off the device |
|
|
| `android.ts check` refuses a project with Tauri's own `MainActivity` | script | seen: exit 1, then 0 after `apply` (review) |
|
|
| The APK still asks for no permission | artefact | `pnpm tauri:android` → aapt2 |
|
|
| Windows: the app words; *Save her to a file* starts a download | device | `e2e/apps/check-garden.ts desktop` |
|
|
| Android: the app words; save through Android's screen, *She is in that file now.*; bring her back from that file, *Everything in that file is already here.*; the file removed afterwards | device | `e2e/apps/check-garden.ts android` (uiautomator presses the system screens) |
|