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

+29
View File
@@ -0,0 +1,29 @@
"""A stand-in for a real AI, for testing Stitch in the emulator without paying for a key.
It answers every chat request with "Fake AI reply to: <your message> (I can see N messages and M tools)",
which is enough to check that chats are saved, that the right history is sent, and how many tools
Stitch offers (70 for a cloud AI, 33 for a model on the phone).
python3 tools-dev/fake-ai/fake_ai.py # listens on port 8099
# In the emulator, the PC is 10.0.2.2: use http://10.0.2.2:8099/v1 as a Custom provider.
# To pretend to be Thinai on the phone itself: adb reverse tcp:11434 tcp:8099
"""
import json, http.server
class H(http.server.BaseHTTPRequestHandler):
def _send(self, obj):
b = json.dumps(obj).encode(); self.send_response(200)
self.send_header("Content-Type", "application/json"); self.send_header("Content-Length", str(len(b))); self.end_headers(); self.wfile.write(b)
def do_GET(self):
self._send({"data": [{"id": "fake-model"}]})
def do_POST(self):
body = json.loads(self.rfile.read(int(self.headers["Content-Length"])))
msgs = body.get("messages", [])
user = [m for m in msgs if m.get("role") == "user"]
last = user[-1]["content"] if user else ""
if isinstance(last, list): last = " ".join(p.get("text", "") for p in last if isinstance(p, dict))
n_tools = len(body.get("tools") or [])
reply = f"Fake AI reply to: {last} (I can see {len(msgs)} messages and {n_tools} tools)"
self._send({"id": "x", "object": "chat.completion", "model": "fake-model",
"choices": [{"index": 0, "finish_reason": "stop", "message": {"role": "assistant", "content": reply}}]})
def log_message(self, *a): pass
http.server.ThreadingHTTPServer(("0.0.0.0", 8099), H).serve_forever()