Skip to content

Release v2.3.1

Choose a tag to compare

@newfpv newfpv released this 19 Oct 21:11

AI Twin Context, Recovery & Natural Replies Update 🧠

This update improves the AI Twin's handling of large attachment batches, adds reliable date and time awareness, and makes short clock replies sound conversational. It also adds manual reply controls, persistent recovery checkpoints, and clearer processing status. It includes all changes since v2.3.0.

✨ New Features

  • 100-Message Conversation Context: Automatic and manually triggered AI Twin replies now collect up to 100 recent messages, including text and supported media descriptions.
  • Multi-Pass Attachment Processing: Photos, videos, voice messages, video notes, and audio are processed in sequential batches of three. Completed descriptions and transcriptions are cached and combined into the conversation context before the reply is generated.
  • Manual Reply Control: Added an Answer Latest Messages button to chat settings, with admin authorization, duplicate-launch protection, and checks for newer or already answered messages.
  • Live Date & Time Awareness: Each AI Twin response receives a fresh server-generated clock in the configured timezone, including the local date, time, weekday, and UTC offset. This clock takes precedence over outdated dates in the conversation.

🔧 AI Twin & Media Improvements

  • Natural Clock Replies: Simple date and time questions now request a short, casual, slightly reluctant answer in the conversation's existing style. Weekdays, years, seconds, and timezone details are omitted unless requested or needed; time uses ordinary digits instead of spelling out each digit.
  • Voice Playback Receipts: Successfully processed incoming voice messages and video notes are marked as played through Telegram's separate media-content receipt, clearing the unplayed indicator.
  • Album Arrival Buffer: Automatic replies briefly wait for the rest of a Telegram album before starting recognition. New incoming messages can replace an in-progress reply while retaining completed media results in the cache.
  • Per-Batch Deadlines: Each media batch has its own processing deadline instead of sharing one timeout across the entire attachment collection. History loading remains bounded separately.
  • Processing Status in Chat Settings: Added localized status snapshots for context collection, generation, reading delays, typing, sending, completion, cancellation, and API or Telegram limits.
  • Explicit Manual Replies: A manual launch bypasses configured sleep hours, humanized delays, and random ignoring, while still respecting Telegram rate limits and avoiding reaction-only replies being reported as sent text.

🛡️ Stability & Protection

  • Persistent Reply Checkpoints: Reply stages and retry deadlines are stored in SQLite so recovery can inspect unfinished work after restarts or connection problems.
  • Connection Probes & Recovery: Added background connection checks and recovery of eligible recent incoming messages in active chats, with owner notifications when connectivity is lost or restored.
  • Duplicate & Stale Reply Protection: Per-chat scheduling locks, task replacement checks, terminal reply states, and retry backoff reduce duplicate launches and prevent replaying old or already answered conversations.
  • Telegram FloodWait Handling: Rate-limit deadlines are persisted and respected by both automatic recovery and manual reply controls.
  • Cancellation-Safe Media Cleanup: Temporary context files are removed after each batch, including timeout and cancellation paths; completed cache entries remain available for the next attempt.
  • Clearer AI Failure Handling: Unavailable API responses and missing-key errors are tracked as failures instead of being sent to contacts as generated replies.
  • Regression Coverage: Added 64 automated tests covering reply scheduling, recovery, attachment batches, cache reuse, cancellation, playback receipts, timezone conversion, date rollovers, and runtime-clock injection. Tests use a temporary SQLite database and mocked Telegram/AI requests.

🗂️ Changed Files

  • modules/ai_twin.py

    • Added the 100-message context window, manual reply controls, processing status, per-chat scheduling safeguards, and playback receipts.
    • Added authoritative local clock instructions with conversational date/time formatting.
  • core/services.py

    • Added sequential media batches, separate history and batch deadlines, cache-backed continuation, and temporary-file cleanup.
  • core/ai_recovery.py

    • Added durable reply checkpoints, connection probes, bounded retry backoff, and recovery of eligible recent messages.
  • language_RU.json & language_EN.json

    • Added localized manual reply controls, runtime status messages, connection notifications, and rate-limit feedback.
  • tests/

    • Added the reply-status, media-batch, voice-playback, and runtime-clock regression suites, plus test-running instructions.

Full Changelog: v2.3.0...v2.3.1