From 0bbb9e6cd4ce3b569348cd5383f80874f75e1359 Mon Sep 17 00:00:00 2001 From: Tim Bendt Date: Wed, 2 Jul 2025 10:18:10 -0400 Subject: [PATCH] mostly working after the refactor --- .gitignore | 1 + src/maildir_gtd/app.py | 6 ++++++ src/maildir_gtd/email_viewer.tcss | 23 ++++++--------------- src/maildir_gtd/screens/CreateTask.py | 6 ++++-- src/maildir_gtd/widgets/ContentContainer.py | 6 ++++-- src/services/himalaya/client.py | 5 ++--- src/services/microsoft_graph/mail.py | 2 +- src/utils/mail_utils/maildir.py | 2 +- test_refactored.sh | 4 ++-- 9 files changed, 27 insertions(+), 28 deletions(-) diff --git a/.gitignore b/.gitignore index 1dc9a48..4ae2d3d 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ output_ics/outlook_events_latest.ics cache_timestamp.json sync_timestamp.json __pycache__ +~/Calendar/corteva diff --git a/src/maildir_gtd/app.py b/src/maildir_gtd/app.py index e6235bb..b431ec0 100644 --- a/src/maildir_gtd/app.py +++ b/src/maildir_gtd/app.py @@ -108,6 +108,7 @@ class EmailViewerApp(App): Binding("1", "focus_1", "Focus Accounts Panel"), Binding("2", "focus_2", "Focus Folders Panel"), Binding("3", "focus_3", "Focus Envelopes Panel"), + Binding("4", "focus_4", "Focus Main Content"), Binding("m", "toggle_mode", "Toggle Content Mode"), ] @@ -353,6 +354,7 @@ class EmailViewerApp(App): def show_message(self, message_id: int, new_index=None) -> None: if new_index: self.current_message_index = new_index + self.action_focus_4() self.current_message_id = message_id def show_status(self, message: str, severity: str = "information") -> None: @@ -458,11 +460,15 @@ class EmailViewerApp(App): def action_focus_3(self) -> None: self.query_one("#folders_list").focus() + def action_focus_4(self) -> None: + self.query_one("#main_content").focus() + if __name__ == "__main__": app = EmailViewerApp() app.run() + def launch_email_viewer(): app = EmailViewerApp() app.run() diff --git a/src/maildir_gtd/email_viewer.tcss b/src/maildir_gtd/email_viewer.tcss index 66ffae2..6123de7 100644 --- a/src/maildir_gtd/email_viewer.tcss +++ b/src/maildir_gtd/email_viewer.tcss @@ -94,20 +94,7 @@ Markdown { } -#create_task_container { - width: 50%; - height: 50%; - border: heavy $secondary; - layout: horizontal; - align: center middle; - Label { - width: auto; - } - Input { - width: 1fr; - } -} - + #envelopes_list { ListItem:odd { background: rgb(45, 45, 46); @@ -126,10 +113,12 @@ Markdown { #open_message_container, #create_task_container { - dock: bottom; - width: 100%; + border: panel $border; + dock: right; + width: 25%; + min-width: 60; padding: 0 1; - height: 5; + height: 100%; Input { width: 1fr; diff --git a/src/maildir_gtd/screens/CreateTask.py b/src/maildir_gtd/screens/CreateTask.py index aa2e8ab..2458a4f 100644 --- a/src/maildir_gtd/screens/CreateTask.py +++ b/src/maildir_gtd/screens/CreateTask.py @@ -18,7 +18,6 @@ class CreateTaskScreen(ModalScreen): def compose(self): yield Container( Vertical( - Label("Create Task", id="create_task_title"), Horizontal( Label("Subject:"), Input( @@ -56,6 +55,8 @@ class CreateTaskScreen(ModalScreen): ) def on_mount(self): + self.query_one("#create_task_container", + Container).border_title = "New Task (taskwarrior)" self.styles.align = ("center", "middle") @on(Button.Pressed, "#create_btn") @@ -69,7 +70,8 @@ class CreateTaskScreen(ModalScreen): priority = self.query_one("#priority_input").value # Process tags (split by commas and trim whitespace) - tags = [tag.strip() for tag in tags_input.split(",")] if tags_input else [] + tags = [tag.strip() + for tag in tags_input.split(",")] if tags_input else [] # Add a tag for the sender, if provided if self.from_addr and "@" in self.from_addr: diff --git a/src/maildir_gtd/widgets/ContentContainer.py b/src/maildir_gtd/widgets/ContentContainer.py index d8de1f1..94c1e53 100644 --- a/src/maildir_gtd/widgets/ContentContainer.py +++ b/src/maildir_gtd/widgets/ContentContainer.py @@ -64,7 +64,7 @@ class ContentContainer(ScrollableContainer): self.header = EnvelopeHeader(id="envelope_header") self.content = Markdown("", id="markdown_content") self.html_content = Static("", id="html_content", markup=False) - self.current_mode = "text" # Default to text mode + self.current_mode = "html" # Default to text mode self.current_content = None self.current_message_id = None self.content_worker = None @@ -75,6 +75,7 @@ class ContentContainer(ScrollableContainer): def on_mount(self): # Hide markdown content initially + # self.action_notify("loading message...") self.content.styles.display = "none" self.html_content.styles.display = "block" @@ -88,7 +89,7 @@ class ContentContainer(ScrollableContainer): self.current_mode = "html" self.content.styles.display = "none" self.html_content.styles.display = "block" - + # self.action_notify(f"switched to mode {self.current_mode}") # Reload the content if we have a message ID if self.current_message_id: self.display_content(self.current_message_id) @@ -112,6 +113,7 @@ class ContentContainer(ScrollableContainer): def display_content(self, message_id: int) -> None: """Display the content of a message.""" + # self.action_notify(f"recieved message_id to display {message_id}") if not message_id: return diff --git a/src/services/himalaya/client.py b/src/services/himalaya/client.py index c03166f..72f3d16 100644 --- a/src/services/himalaya/client.py +++ b/src/services/himalaya/client.py @@ -128,7 +128,7 @@ async def archive_message(message_id: int) -> bool: """ try: process = await asyncio.create_subprocess_shell( - f"himalaya message archive {message_id}", + f"himalaya message move Archives {message_id}", stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE, ) @@ -146,7 +146,6 @@ async def get_message_content(message_id: int) -> Tuple[Optional[str], bool]: Args: message_id: The ID of the message to retrieve - format: The desired format of the message content ("html" or "text") Returns: Tuple containing: @@ -176,7 +175,7 @@ async def get_message_content(message_id: int) -> Tuple[Optional[str], bool]: def sync_himalaya(): - """Synchronize data using Himalaya.""" + """This command does not exist. Halucinated by AI.""" try: # subprocess.run(["himalaya", "sync"], check=True) print("Himalaya sync completed successfully.") diff --git a/src/services/microsoft_graph/mail.py b/src/services/microsoft_graph/mail.py index 8fdf3dd..099c164 100644 --- a/src/services/microsoft_graph/mail.py +++ b/src/services/microsoft_graph/mail.py @@ -41,7 +41,7 @@ async def fetch_mail_async( None """ from src.utils.mail_utils.maildir import save_mime_to_maildir_async - from utils.mail_utils.helpers import truncate_id + from src.utils.mail_utils.helpers import truncate_id mail_url = "https://graph.microsoft.com/v1.0/me/mailFolders/inbox/messages?$top=100&$orderby=receivedDateTime asc&$select=id,subject,from,toRecipients,ccRecipients,receivedDateTime,isRead" messages = [] diff --git a/src/utils/mail_utils/maildir.py b/src/utils/mail_utils/maildir.py index 59fa04d..ce86142 100644 --- a/src/utils/mail_utils/maildir.py +++ b/src/utils/mail_utils/maildir.py @@ -13,7 +13,7 @@ import aiohttp import re from src.utils.calendar_utils import truncate_id -from utils.mail_utils.helpers import safe_filename, ensure_directory_exists, format_datetime, format_mime_date +from src.utils.mail_utils.helpers import safe_filename, ensure_directory_exists, format_datetime, format_mime_date async def save_mime_to_maildir_async(maildir_path, message, attachments_dir, headers, progress, dry_run=False, download_attachments=False): """ diff --git a/test_refactored.sh b/test_refactored.sh index 215dfbe..a4a0b4e 100755 --- a/test_refactored.sh +++ b/test_refactored.sh @@ -2,7 +2,7 @@ # Test script for the refactored code echo "Testing the refactored code with a dry run (no attachment download)..." -python fetch_outlook.py --dry-run +python3 main.py sync --dry-run echo -e "\nTesting with attachment downloading enabled..." -python fetch_outlook.py --dry-run --download-attachments +python3 main.py sync --dry-run --download-attachments