Fix bugs: MeshMessage position field, summary loading, Google system prompt, import placement, cleanup timer

- 1a: Declare _position as proper dataclass field with field(default=None, init=False)
  so hasattr() check isn't needed and the attribute always exists
- 1b: Load persisted conversation summaries from DB into memory cache on startup
  via new _load_summaries() method called after backend creation
- 1c: Use Gemini's system_instruction parameter on GenerativeModel instead of
  only prepending to first message, so system prompt persists across all turns
- 1d: Move 'import os' from line 198 to top of main.py with other imports
- 1e: Replace unreliable modulo-based cleanup timer with _last_cleanup timestamp
  comparison that won't miss hours due to async sleep jitter

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Ubuntu 2026-02-23 20:11:46 +00:00
commit c1f2c48494
3 changed files with 53 additions and 13 deletions

View file

@ -2,7 +2,7 @@
import asyncio
import logging
from dataclasses import dataclass
from dataclasses import dataclass, field
from typing import Callable, Optional
import meshtastic
@ -26,13 +26,12 @@ class MeshMessage:
channel: int # Channel index
is_dm: bool # True if direct message to us
packet: dict # Raw packet for additional data
_position: Optional[tuple[float, float]] = field(default=None, repr=False, init=False)
@property
def sender_position(self) -> Optional[tuple[float, float]]:
"""Get sender's GPS position if available (lat, lon)."""
# Position comes from node info, not the message itself
# This will be populated by the connector if available
return self._position if hasattr(self, "_position") else None
return self._position
class MeshConnector: