Stitch 0.4.4: saved chats, model guide, Thinai, sturdier web search

Ideas ported from Thinai (github.com/Aravindargutus/Thinai, MIT); none of
its Flutter code is used directly.

- Chats panel: every conversation saved (ChatStore); new chat, switch,
  search, rename, delete, delete all. Fixes B-38: AI replies were never
  saved and the chat screen started empty after every restart.
- Model guide: 20 real .litertlm models, the phone's RAM/CPU/storage,
  use-case chips, fit and speed estimates (ModelGuide).
- Thinai preset; any AI server on 127.0.0.1 gets short instructions and
  the 33 phone tools instead of 70.
- Web search: DuckDuckGo Lite/HTML then Bing, challenge-page detection,
  10-minute engine rest, relevance filter (B-37).
- Other people's text wrapped with a random id and control tokens
  defused (B-40).
- Wake-phrase service no longer crashes the app after an update or
  reboot; a one-tap notice resumes it (B-39, pre-existing since 0.4.0).
- 37 new tests (87 -> 124); fake AI test server kept in tools-dev/.
- Docs: DEVELOPMENT_HISTORY, README, STAGE_A2_CHECKLIST section 6.
This commit is contained in:
thekhalidsha committed 2026-09-28 11:19:58 +05:30
1 parent a1d593a4cc
commit 372190f8ec
29 files changed
+2436 -167

No files matched your search

+36 -10
View File
@@ -6,29 +6,42 @@ Stitch turns what you type or say into actions on your phone.
- **Your AI for everything else:** summaries ("summarize my last 5 calls"), writing ("draft a leave request email"), questions, and multi-step tasks. Supported: Anthropic, OpenAI, OpenRouter, Gemini, Groq, Ollama / LM Studio on your PC, a generic OpenAI-compatible server, and the current generic Hermes Agent provider preset. Your provider key stays on the phone, encrypted with the Android Keystore.
- **Safe by default:** calls and SMS always show a confirmation with the exact recipient and text. After the AI reads other people's messages, every follow-up action needs confirmation too (prompt-injection guard).
**Current release:** Stitch 0.4.3. The live Android registry contains 70 tools, 32 are exposed to Needle, and the current test suite has 87 unit tests. The original [docs/PLAN.md](docs/PLAN.md) is retained as a historical design document; it is not the current implementation contract.
**Current release:** Stitch 0.4.4. The live Android registry contains 70 tools, 32 are exposed to Needle, and the current test suite has 124 unit tests. The original [docs/PLAN.md](docs/PLAN.md) is retained as a historical design document; it is not the current implementation contract.
**Before anything else:** 0.4.2 and 0.4.3 have never been tested on a phone, and between them they
changed the six things that were broken in 0.4.1 plus the provider keys. [docs/STAGE_A2_CHECKLIST.md](docs/STAGE_A2_CHECKLIST.md)
is a 25-minute list to confirm they work.
**Before anything else:** 0.4.2, 0.4.3 and 0.4.4 have never been tested on a phone. Between them they
changed the six things that were broken in 0.4.1, the provider keys, and (0.4.4) saved chats, the model
guide, Thinai and web search. [docs/STAGE_A2_CHECKLIST.md](docs/STAGE_A2_CHECKLIST.md) is a 35-minute
list to confirm they work.
**New in 0.4.4** (several ideas ported from the open-source Thinai app):
- **Chats panel:** tap ☰ on the Chat tab. Every conversation is kept; start a new one, go back to an old
one, search, rename or delete. Conversations now survive restarts, AI replies included.
- **Model guide:** Settings → AI & provider → On this phone shows your phone's RAM and processor, asks
what you want a model for (phone commands, Tamil, writing…) and recommends ones that fit, with a speed
estimate. 20 models to choose from.
- **Thinai** as a provider: runs GGUF models on the phone and Stitch uses them offline.
- **Web search that keeps working:** DuckDuckGo blocks repeated questions, so Bing is now the backup, and
results that aren't about the question are thrown away.
- **Safer reading of other people's text:** a web page or message can no longer fake the end of the
"this is someone else's text" wrapper.
See [docs/UPGRADE_PLAN.md](docs/UPGRADE_PLAN.md) for what happens next: connecting Stitch and Hermes in both directions, so Hermes can use your phone and Stitch can use your server. **None of it is in 0.4.3 yet.** It will all be built **inside Stitch** — there will never be a second app to install. [docs/PLAN.md](docs/PLAN.md) and [docs/HOTWORD_PLAN.md](docs/HOTWORD_PLAN.md) are historical design documents, kept for the reasoning; neither describes current behaviour.
## Install on your phone
1. Copy the newest APK from `dist/` (currently `Stitch-0.4.3.apk`) to your phone and tap it to install. It installs over earlier versions and keeps your settings.
1. Copy the newest APK from `dist/` (currently `Stitch-0.4.4.apk`) to your phone and tap it to install. It installs over earlier versions and keeps your settings.
2. Open **Stitch → ⚙ Settings**. Settings is a list of categories; tap one to open it and use the back arrow to return. Set up the following:
- **AI & provider:** pick a provider, paste your key, and tap **Test connection**.
- **Phone control:** tap **Turn on phone control**, open *Stitch phone control* and switch it on. If Android says "restricted setting", go to **App info → ⋮ → Allow restricted settings** and try again.
- **Permissions & access:** grant permissions (contacts, calls, call log, SMS, calendar, location, notifications, microphone) and special access: Do Not Disturb, "modify system settings" (for brightness and rotation), and read notifications (for WhatsApp replies and music control).
- **Who answers you:** Hybrid (recommended), on-device only, or always your AI. Under *On-device model*.
- The other categories are **Voice & hotword**, **Default apps** and **Backup & restore**.
3. **After every Stitch update,** open Settings → Phone control. If it shows "on but not running", switch it off and on again. Android stops accessibility services when an app is updated.
3. **After every Stitch update,** open Settings → Phone control. If it shows "on but not running", switch it off and on again. Android stops accessibility services when an app is updated. If you use the wake phrase, a "Wake phrase is off" notification appears too: tap it once to turn listening back on (Android doesn't let an app restart the microphone by itself).
## The main screen (0.4.3)
## The main screen (0.4.4)
Four tabs along the bottom:
- **Chat:** talk to Stitch, as before. The settings gear is on this tab.
- **Chat:** talk to Stitch. **☰** (top left, or swipe from the left edge) opens your chats: New chat, search, and a ⋮ menu on each chat to rename or delete it, plus Delete all at the bottom. The **new chat** button and the settings gear are at the top right.
- **Schedule:** your upcoming alarms, reminders and calendar events, soonest first. Timers and alarms set outside Stitch aren't listed.
- **Saved:** your notes and the facts Stitch remembers.
- **Workflows:** coming soon.
@@ -55,8 +68,9 @@ Stitch currently exposes 70 Android tools through the live registry. They cover
⚙ Settings → AI & provider:
- **Cloud:** Anthropic, OpenAI, OpenRouter, OpenCode Zen, OpenCode Go, DeepSeek, Xiaomi MiMo (pay-as-you-go or Token Plan), Google Gemini, Groq.
- **Your own servers:** Ollama / LM Studio on your PC, a local server on the phone, or any OpenAI-compatible server.
- **Thinai (on this phone, offline):** [Thinai](https://github.com/Aravindargutus/Thinai) is a separate free app that runs GGUF models (Qwen, Llama, Gemma, Phi…) and serves them on the phone at `127.0.0.1:11434`. Install it, download a model, start its server, then pick **Thinai** in Stitch and tap ⟳ to choose the model. Any server on the phone itself gets the same treatment as the built-in engine: short instructions and the 33 phone tools rather than all 70, because these are small models. Keep Thinai's LAN mode off, and set an access token in Thinai if you want to stop other apps on the phone from using it.
- **Hermes (current behaviour):** the "Hermes Agent" entry is an ordinary OpenAI-compatible provider connection, nothing more. Two things stop it working as shipped: its address (`192.168.1.10`) is not the build machine, and Hermes' own API server only listens on the PC itself and won't start without a key being set. Both are fixed in Stage C of [docs/UPGRADE_PLAN.md](docs/UPGRADE_PLAN.md).
- **On this phone (offline):** Gemma 4 and other `.litertlm` models, running in the same engine Google AI Edge Gallery uses (LiteRT-LM). Download them in Settings, or import a file. Edge Gallery keeps its own models private to that app, so they can't be shared. Edge Gallery's planned local API server isn't released yet; if it ships, pick "Local server on this phone". On-device models need a 64-bit phone and get a smaller tool set (no screen control).
- **On this phone (offline):** Gemma 4 and other `.litertlm` models, running in the same engine Google AI Edge Gallery uses (LiteRT-LM). **"Which model should I get?"** reads your phone's RAM, processor and free storage, asks what you want the model for, and recommends models that do that well *and* fit, each with "Runs well / Tight fit / Too big" and a speed estimate. "Show all 20 models" lists the whole catalogue. Ratings are editorial (what each model's makers claim, plus its size), not tests; only Gemma 4 (the default) and Granite 350M have been run in Stitch — others are marked "Not tried in Stitch yet". Or import a file. Edge Gallery keeps its own models private to that app, so they can't be shared. Edge Gallery's planned local API server isn't released yet; if it ships, pick "Local server on this phone". On-device models need a 64-bit phone and get a smaller tool set (no screen control).
- **Every provider keeps its own settings.** Its key, address and model are saved separately, so you can set up several and switch between them without retyping anything. A ✓ in the list marks the ones you've set up, and the eye icon next to the key field shows what you typed. (Before 0.4.3 they shared one slot, so a second provider overwrote the first.)
- **Models:** type any model name, or tap ⟳ to download the provider's model list and pick from it. Typing filters the list. The chosen model is remembered per provider too.
- **OpenCode:** each model is automatically sent to the right API format (Claude/Qwen → Messages, GPT/Grok → Responses, others → Chat Completions; MiniMax on Go → Messages). Gemini models on OpenCode aren't supported yet.
@@ -79,8 +93,11 @@ Requirements: JDK 17, Android SDK (platform 35, build-tools 35.0.0), NDK `30.0.1
./scripts/fetch-needle.sh # prebuilt Needle 2 engine (only needed on a fresh checkout)
./gradlew assembleRelease # → app/build/outputs/apk/release/app-release.apk
./gradlew testDebugUnitTest # unit tests; also writes app/build/needle-tools.json
STITCH_LIVE=1 ./gradlew testDebugUnitTest --tests app.stitch.WebSearchTest # also asks the real search engines
```
For emulator tests without a paid key, `python3 tools-dev/fake-ai/fake_ai.py` runs a stand-in AI on port 8099 (use `http://10.0.2.2:8099/v1` as a Custom provider in the emulator).
To test on-device models in an x86_64 emulator, build with `./gradlew -Pemulator assembleDebug`. It adds x86_64 native libraries, with a stand-in for Needle, which has no Android x86 build. Without that flag, the emulator runs the ARM engine through translation and crashes.
The release APK is signed with the local debug key so it installs directly. Keep building on the same machine so updates install over the old version. A proper release key now exists at `~/.stitch-release-key/` and is used only when you pass `-PreleaseKey` — switching to it is a one-time move that requires uninstalling first, so read [docs/SIGNING.md](docs/SIGNING.md) before you use that flag.
@@ -108,6 +125,7 @@ app/src/main/kotlin/app/stitch/
notifications/ notification listener (kept in memory only)
ui/ Compose chat + settings
tools-dev/needle/ eval set + runner
tools-dev/fake-ai/ stand-in AI server for emulator tests
```
## Tested so far vs. not yet
@@ -120,10 +138,18 @@ Tested in an Android 14 emulator with a scripted fake AI:
- Weather, web search, and the phone status report
- SMS sending with confirmation, and the ambiguous-contact case
Tested in the emulator for 0.4.4 (fake AI server):
- The chats panel: new chat, switching back with the right history sent to the AI, rename, search, delete, and chats surviving an app update
- Thinai's path (a server on 127.0.0.1:11434, simulated): connect, sync models, and the 33-tool set being sent
- The model guide on a 2.4 GB emulator: it recommends only models that fit and says when better ones are too big
- An update with the wake phrase on no longer crashes the app
- Web search asked the real engines from the build machine: 4 of 4 questions answered while DuckDuckGo was blocking
Not yet tested on real apps:
- WhatsApp auto-send (WhatsApp isn't installed in the emulator)
- Music playback in Spotify, YouTube Music and YMusic
- Cloud providers with a real key (model-list sync was tested live against OpenRouter and OpenCode Zen/Go)
- The real Thinai app (only simulated), and any model in the guide other than Granite 350M
- On-device Gemma 4 on a real phone (the engine, tool calls and downloads were tested in the emulator with the small Granite model)
- Notification replies
- Any run with a real AI model
@@ -134,7 +160,7 @@ Not yet tested on real apps:
- Wi-Fi, Bluetooth, and mobile data can't be switched by apps on Android 10+. The AI can do it through phone control by opening Quick Settings and tapping the toggle.
- Banking apps and other protected screens block screenshots. Screen reading usually still works there.
- **Backups exist but are untested on a phone.** Settings → Backup & restore saves everything to one encrypted file (new in 0.4.2), including every provider's key. Until you've confirmed a backup actually restores, treat uninstalling as permanent — installing a new APK over the old one is safe, uninstalling is not. Note that Android never restores the *special* permissions (Phone control, notification access, Do Not Disturb, modify system settings); those are always re-granted by hand after a reinstall.
- Chat history: the current agent persists the last 40 user/assistant text turns in app-private preferences. Tool results, screenshots, notification bodies, and other transient phone data remain in memory for the active session unless a feature explicitly stores them. Remembered facts, notes, and reminders are saved separately.
- Chat history (0.4.4): every conversation is saved separately in app-private storage (up to 1,000 lines each), and included in backups. Only what you and Stitch said is saved; tool results, screenshots, notification bodies and the "Show data" panel stay in memory for the session only, since they hold other people's messages. When you return to a chat, the AI is shown its last ~40 lines. Remembered facts, notes, and reminders are saved separately.
## Wake phrase and the bubble (0.4.2)