Add context filter to Tasks TUI and fix calendar UI bugs

Tasks TUI:
- Add context support to TaskBackend interface (get_context, set_context,
  get_contexts methods)
- Implement context methods in DstaskClient
- Add Context section to FilterSidebar (above projects/tags)
- Context changes persist via backend CLI

Calendar TUI:
- Remove duplicate header from InvitesPanel (use border_title instead)
- Fix border_title color to use $primary
- Fix WeekGrid to always scroll to work day start (7am) on mount
This commit is contained in:
Bendt
2025-12-19 11:51:53 -05:00
parent be2f67bb7b
commit 3629757e70
6 changed files with 205 additions and 34 deletions

View File

@@ -349,3 +349,43 @@ class DstaskClient(TaskBackend):
# This needs to run without capturing output
result = self._run_command(["note", task_id], capture_output=False)
return result.returncode == 0
def get_context(self) -> Optional[str]:
"""Get the current context filter.
Returns:
Current context string, or None if no context is set
"""
result = self._run_command(["context"])
if result.returncode == 0:
context = result.stdout.strip()
return context if context else None
return None
def set_context(self, context: Optional[str]) -> bool:
"""Set the context filter.
Args:
context: Context string (e.g., "+work", "project:foo") or None to clear
Returns:
True if successful
"""
if context is None or context.lower() == "none" or context == "":
result = self._run_command(["context", "none"])
else:
result = self._run_command(["context", context])
return result.returncode == 0
def get_contexts(self) -> list[str]:
"""Get available contexts based on tags.
For dstask, contexts are typically tag-based filters like "+work".
We derive available contexts from the existing tags.
Returns:
List of context strings (tag-based)
"""
# Get all tags and convert to context format
tags = self.get_tags()
return [f"+{tag}" for tag in tags if tag]