Skip to content

Conversation

HarukiToreda
Copy link
Contributor

Overview

This PR introduces multi-message storage and threaded conversation view support to BaseUI, improving how messages are displayed, stored, and preserved across sessions.

Features

  • Message Storage

    • Stores the last 20 messages in RAM.
    • Persists the last 20 messages to flash on properly initiated reboot/shutdown
      (not hard power cut or reset button press).
    • Automatically restores saved messages from flash into RAM on boot.
    • Added debug logs showing the exact space used when saving to flash and the
      space restored on boot.
  • Conversation Threads

    • Messages are displayed newest to oldest with timestamps in an auto-scrollable thread view.
    • Sent messages are labeled as “Me”.
    • Incoming messages are automatically sorted into the correct thread (DM or Channel broadcast).
    • Auto-focuses on the last active conversation when a new message arrives.
    • Uses boot time counter if no RTC is available, and once valid time is obtained,
      messages are updated and written with the corrected timestamp for persistence.
    • Conversation Menu Options:
      • Switch between conversation views (Channels, DMs, or All).
      • Reply directly to the currently focused conversation.
      • Dismiss Last: remove the oldest message in the current conversation.
      • Dismiss All: clear all messages (when in View All).
  • Message Status Indicators (for sent messages)

    • Checkmark = confirmed ACK.
    • X = failed or timed-out.
    • ⚠️ Exclamation mark = relayed but no ACK.
  • Client Integration

    • Messages created on other clients (phone/web) are captured and added into the correct thread.

Additional Changes

  • Removed legacy message handling from Screen.cpp.
  • Cleaned up CannedMessageModule by removing legacy message sending and temporary message logic.
  • Fixed Emote screen rendering issues.
  • Added autofocus to message screen after sending a new message.

@Xaositek Xaositek added the enhancement New feature or request label Oct 3, 2025
@Xaositek Xaositek added the baseui Issues directly related to BaseUI label Oct 3, 2025
@thebentern thebentern requested a review from Copilot October 3, 2025 17:15
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces comprehensive multi-message storage and threaded conversation view capabilities to BaseUI. It transforms how messages are displayed, stored, and preserved across device sessions.

  • Implements persistent message storage (last 20 messages in RAM + flash persistence)
  • Adds threaded conversation views with automatic sorting and status indicators
  • Modernizes message handling by centralizing logic in MessageStore and MessageRenderer

Reviewed Changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/MessageStore.h/.cpp New central message storage system with persistence and filtering
src/graphics/draw/MessageRenderer.h/.cpp Enhanced renderer with thread modes and conversation switching
src/graphics/draw/MenuHandler.h/.cpp New conversation management UI with view modes and reply options
src/modules/TextMessageModule.h/.cpp Updated to use centralized storage instead of direct display
src/modules/CannedMessageModule.h/.cpp Improved message sending with storage integration and ACK tracking
src/graphics/Screen.h/.cpp Refactored to remove legacy message handling and add persistence
src/modules/SystemCommandsModule.cpp Added message persistence on reboot
src/Power.cpp Added message persistence on shutdown

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +657 to +663
if (idx == 0 || _line.find("ago") != std::string::npos || _line.rfind("me ", 0) == 0) {
isHeader = true;
}

// Look ahead to see if next line is a header → this is the last line of a message
bool beforeHeader =
(idx + 1 < lines.size() && (lines[idx + 1].find("ago") != std::string::npos || lines[idx + 1].rfind("me ", 0) == 0));
Copy link
Preview

Copilot AI Oct 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The header detection logic using string searches for 'ago' and 'me ' is fragile and could produce false positives. Consider using a more robust approach like explicit header marking or enum-based line types.

Copilot uses AI. Check for mistakes.

Comment on lines +1039 to +1041
this->runState = CANNED_MESSAGE_RUN_STATE_SENDING_ACTIVE;
this->payload = wantReplies ? 1 : 0;
requestFocus(); // focus only after event is dispatched
Copy link
Preview

Copilot AI Oct 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code block is duplicated at lines 1029-1031. The state assignment and focus request logic should be consolidated to avoid duplication.

Copilot uses AI. Check for mistakes.

Comment on lines +340 to 342
// Values are always 0–255, no need to check
TFT_MESH = COLOR565(TFT_MESH_r, TFT_MESH_g, TFT_MESH_b);
}
Copy link
Preview

Copilot AI Oct 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the condition check but kept the closing brace, creating unmatched braces that will cause compilation errors.

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
baseui Issues directly related to BaseUI enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants