Skip to content

Conversation

@eulicesl
Copy link
Owner

This PR adds an email import plugin under plugins/example/import/email-import.

The plugin provides a Flask web interface to connect to an IMAP mailbox (or use a local .eml file), extract actionable "memories" from messages via rule-based heuristics, and submit them to the OMI API. It includes:

  • README.md with setup and usage details
  • app.py Flask backend to fetch emails, extract memories, and post to OMI
  • index.html UI for entering IMAP credentials and selecting messages
  • requirements.txt listing required Python packages
  • sample.eml example email for testing

The memory extraction heuristics look for lines starting with bullets, numbers, TODO, or Action prefixes, cleaning up the text and limiting to 500 characters.

This addresses issue BasedHardware#1895 (Import data from email).

eulicesl and others added 6 commits August 18, 2025 09:39
- Add native iOS AppleCalendarService.swift for EventKit integration
- Add Dart AppleCalendarService wrapper for Flutter platform channels
- Add ActionItemIntegration enum with Apple Calendar support
- Add preferences extension for export destination persistence
- Update ActionItemTileWidget with dropdown export selection and Calendar export functionality
- Add Apple Calendar logo asset
- Update AppDelegate.swift with Calendar method channel registration

This enables users to export action items directly to Apple Calendar with permission handling, event creation, and user feedback.
Copilot AI review requested due to automatic review settings August 26, 2025 14:52
Copy link

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 a new email import plugin that allows users to fetch emails from an IMAP mailbox, extract actionable memories from them, and submit them to the OMI API. The plugin provides a Flask-based web interface for email credential management and selective memory extraction.

Key changes include:

  • Implementation of a Flask backend with IMAP connectivity and memory extraction logic
  • HTML frontend for user interaction with email fetching and memory submission
  • Rule-based heuristics for extracting actionable items from email content

Reviewed Changes

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

Show a summary per file
File Description
app.py Flask backend implementing IMAP connectivity, email parsing, and OMI API integration
index.html Frontend interface for IMAP credentials and email message selection
README.md Documentation with setup instructions and feature overview
requirements.txt Python dependencies including Flask and email parsing libraries
sample.eml Example email file for testing without IMAP connection

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

import time
import json
import imaplib
import email
Copy link

Copilot AI Aug 26, 2025

Choose a reason for hiding this comment

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

The code imports the standard library 'email' module but requirements.txt specifies 'email-parser==0.1.5' which is not used anywhere in the code. This creates confusion about dependencies. Remove the unused email-parser dependency from requirements.txt.

Copilot uses AI. Check for mistakes.

<form id="fetch-form">
<label for="host">IMAP Host</label>
<input type="text" id="host" placeholder="imap.example.com" autocomplete="username">
Copy link

Copilot AI Aug 26, 2025

Choose a reason for hiding this comment

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

The autocomplete attribute 'username' is incorrect for an IMAP host field. It should be 'off' or removed entirely, as this field contains server hostnames, not usernames.

Suggested change
<input type="text" id="host" placeholder="imap.example.com" autocomplete="username">
<input type="text" id="host" placeholder="imap.example.com">

Copilot uses AI. Check for mistakes.
Comment on lines 118 to 119
try:
imap = imaplib.IMAP4_SSL(host, port) if port == 993 else imaplib.IMAP4(host, port)
Copy link

Copilot AI Aug 26, 2025

Choose a reason for hiding this comment

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

Using plain IMAP4 connection for non-993 ports creates a security vulnerability by transmitting credentials in plain text. Consider using STARTTLS for non-SSL connections or restricting to SSL-only connections.

Suggested change
try:
imap = imaplib.IMAP4_SSL(host, port) if port == 993 else imaplib.IMAP4(host, port)
if port == 993:
imap = imaplib.IMAP4_SSL(host, port)
else:
imap = imaplib.IMAP4(host, port)
imap.starttls()

Copilot uses AI. Check for mistakes.
"""
memories = []
lines = body.splitlines()
action_pattern = re.compile(r'^\s*(?:\d+[\).]|[-*\u2022]|todo|action[:\-])', re.IGNORECASE)
Copy link

Copilot AI Aug 26, 2025

Choose a reason for hiding this comment

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

[nitpick] The regex pattern uses a Unicode bullet character (\u2022) but doesn't handle other common bullet characters like '►', '⦁', or '‣' that might appear in emails. Consider expanding the pattern or documenting the limitation.

Suggested change
action_pattern = re.compile(r'^\s*(?:\d+[\).]|[-*\u2022]|todo|action[:\-])', re.IGNORECASE)
action_pattern = re.compile(r'^\s*(?:\d+[\).]|[-*\u2022\u2023\u25BA\u2981]|todo|action[:\-])', re.IGNORECASE)

Copilot uses AI. Check for mistakes.
eulicesl pushed a commit that referenced this pull request Oct 24, 2025
closes BasedHardware#3241

before:


https://github.com/user-attachments/assets/d00d815c-8419-4c1b-96fb-ec20365fba44

logs:

```
flutter: ----------------FIREBASE CRASHLYTICS----------------
flutter: Bad state: No element
flutter: 
#0      ListBase.firstWhere (dart:collection/list.dart:132:5)
#1      SharedPreferencesUtil.disableApp (package:omi/backend/preferences.dart:255:22)
#2      _AppDetailPageState._toggleApp (package:omi/pages/apps/app_detail/app_detail.dart:1129:13)
#3      _AppDetailPageState.build.<anonymous closure> (package:omi/pages/apps/app_detail/app_detail.dart:576:48)
#4      _AnimatedLoadingButtonState._handleOnPressed (package:omi/widgets/animated_loading_button.dart:38:27)
#5      _InkResponseState.handleTap (package:flutter/src/material/ink_well.dart:1204:21)
#6      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:345:24)
#7      TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:758:11)
#8      BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:383:5)
#9      BaseTapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:353:7)
#10     GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:173:27)
#11
```

after:


https://github.com/user-attachments/assets/26ea5c91-e73a-44f4-ba76-4b804876c5df

<img width="1032" height="257" alt="Screenshot 2025-10-18 at 11 15
52 PM"
src="https://github.com/user-attachments/assets/44e4e46b-b654-4599-84ee-8ee0920b1cd3"
/>
@eulicesl eulicesl closed this Oct 24, 2025
@eulicesl eulicesl deleted the email-import-plugin branch October 24, 2025 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants