---
name: pwa-mobile-app
description: "Use when a web platform shall be an installable iPhone app."
version: 0.1.0
author: Nexus
license: MIT
platforms: [linux]
metadata:
  hermes:
    tags: [pwa, ios, iphone, mobile, chat-ui]
    related_skills: [vps-domain-hosting]
---

# PWA / installable mobile app (iPhone-first)

Turn a web platform on our own domain into an "app" the owner and his colleagues
install on the iPhone home screen, with a chat-app style UI (ChatGPT-like when the
platform is a chat assistant). The owner hands out the URL + a demo login and expects
it to feel native — no Safari bars, correct icon, no zoom glitches.

## When to Use

- "Mache es mir als App", "auf dem iPhone Home-Bildschirm", "Kollegen sollen es so
  nutzen können", "wie ChatGPT aussehen".

## Procedure

1. **PWA shell:**
   - `manifest.json`: `name`, `short_name`, `display: "standalone"`,
     `theme_color`/`background_color` matching the dark design, `start_url: "/"`,
     icons 192px + 512px (plus a `"purpose": "maskable"` variant).
   - `apple-touch-icon.png` (180×180, opaque background — iOS composites it onto
     the home screen; transparent icons render black).
   - Meta tags in every page: `apple-mobile-web-app-capable`,
     `apple-mobile-web-app-status-bar-style: black-translucent`, `theme-color`,
     `viewport-fit=cover`.
   - Basic service worker (cache icons/manifest + offline fallback page), register
     it from the main UI. iOS ignores most SW features but Chrome/Android uses them.
2. **App-like UI (mobile-first, test at 390×844):**
   - Chat layout: history sidebar (slide-over with backdrop below ~900 px, fixed
     above), message bubbles (user right, assistant left), input bar pinned to the
     bottom, auto-scroll, typing indicator, "+ New chat" button.
   - `env(safe-area-inset-bottom)` padding on the fixed input bar so it clears the
     iPhone home indicator; same for the status bar top under black-translucent.
3. **Persistence:** server-side chat/session table + list/create/delete/rename
   endpoints; group existing messages into a first chat on migration so nothing is
   lost (the owner checks old data survives an UI overhaul).
4. **Verify before reporting done:** manifest + every icon + sw.js return HTTP 200
   via curl; a full user flow (login → new chat → send message → tool chip visible →
   switch/delete chat); admin panel unaffected; no horizontal overflow at 390 px.
5. **Hand the owner a 4-step install instruction** (he forwards it to colleagues
   verbatim): Safari → open the URL → Share button (square with arrow) → "Zum
   Home-Bildschirm hinzufügen" — app then starts fullscreen from the home screen.

## Pitfalls

- **iOS zooms the page when an input has font-size < 16 px** — Safari auto-zooms on
  focus and never zooms back out. Set every text input/textarea to at least 16 px.
- **iOS has no install banner — the Share → "Add to Home Screen" path is the ONLY
  way to install** — a manifest alone never surfaces a prompt like on Android; put
  the Share-menu instruction in the handout, and test the flow once on a device.
- **Do not break existing features for the redesign** — tool chips, mic/TTS buttons,
  limits pill, admin link must all survive the UI overhaul; run the old test battery
  plus the new ones before deploy, and snapshot code + DB (`backup_<date>/`) first.
- **Viewport height lies on iOS Safari** — use `100dvh`/`-webkit-fill-available`
  patterns or the fixed input bar floats above/below the keyboard area.
- **Never run a multi-minute agent turn as one synchronous fetch** — iOS Safari kills
  long-running requests (screen lock, backgrounding, watchdogs) and the user sees
  "Verbindungsfehler" with the typed message lost. Use an async job model: POST
  returns a job_id immediately, the client polls status every 2–3 s, running jobs
  survive an app restart and are re-attached when the chat is reopened, and polling
  auto-reconnects with backoff so a network blip never requires retyping.
- **Auto-scroll: never rely on `scroll-behavior:smooth` + `scrollTop=` assignment** —
  smooth scroll animations run on rAF and silently stall in background/headless tabs,
  leaving the chat stuck mid-history. Use `el.scrollTo({top:…, behavior:'instant'})`
  (ChatGPT also jumps instantly to the latest message).
- **When replacing large CSS blocks in a served HTML string, verify the tag balance
  (`<style>`/`</style>`, `<script>`/`</script>`) and test in a real browser** — a lost
  closing `</style>` makes the parser swallow the whole page as CSS text; curl/grep
  marker checks still pass because the text is present, only the DOM is gone.
  DOM-level checks (`getElementById(...)` non-null, `scrollWidth<=viewport`) catch it.
- **iOS speech requires a user gesture** — dictation (SpeechRecognition) and TTS only
  fire after a tap; wire press-to-talk explicitly with a visible recording
  indicator, and piggyback a spoken login greeting on the login-tap gesture.
