Skip to content

Improve robustness of auto-detection by using list properties instead of index-based mapping #3

@skempken

Description

@skempken

Problem

The detect_list_names() function in things_jxa.py currently assumes that Things 3 lists are returned in a fixed order and maps them by index:

# things_jxa.py:69-77
english_keys = ["inbox", "today", "upcoming", "anytime", "someday", "logbook"]

detected_mapping = {}
for i, english_key in enumerate(english_keys):
    if i < len(list_names):
        detected_mapping[english_key] = list_names[i]

Risks:

  • If Things 3 changes the list order in a future update, mappings will be incorrect
  • If a list is missing or hidden, all subsequent mappings shift
  • No way to verify that the detected list actually corresponds to the expected type

Current Implementation

Location: things_jxa.py:42-105

The function queries all lists via JXA and assumes:

  1. Lists are always returned in order: Inbox, Today, Upcoming, Anytime, Someday, Logbook
  2. All 6 lists are always present
  3. The order never changes

Proposed Solution

Option 1: Use list IDs or properties (Recommended)

Query additional properties from Things 3 lists to identify them reliably:

const things = Application("Things3");
const lists = things.lists();
const result = [];
for (let i = 0; i < lists.length; i++) {
    result.push({
        name: lists[i].name(),
        id: lists[i].id(),  // If available
        // Or other distinguishing properties
    });
}

Then match lists by their stable IDs rather than position.

Option 2: Match by known translations

Build a comprehensive translation database and match detected names:

KNOWN_TRANSLATIONS = {
    "inbox": ["Inbox", "Eingang", "Bandeja", "Boîte de réception", ...],
    "today": ["Today", "Heute", "Hoy", "Aujourd'hui", ...],
    # ...
}

def detect_list_names():
    # Query list names
    # Match each name against KNOWN_TRANSLATIONS
    # Build mapping

Pros: Works even if order changes
Cons: Requires maintaining translation database for all supported languages

Option 3: Hybrid approach

  1. Try to use IDs/properties first (most reliable)
  2. Fall back to translation matching
  3. Fall back to index-based mapping as last resort

Impact

Priority: High - affects reliability of auto-detection for all users

Affected code: things_jxa.py:42-105

Breaking changes: None (internal implementation only)

Acceptance Criteria

  • Auto-detection works even if list order changes
  • Detection validates that found lists match expected types
  • Clear error messages if detection fails
  • No breaking changes to user-facing API
  • Tests verify detection with different list orders

Additional Context

This issue was identified during post-implementation review of #1 (multi-locale support).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestrefactoringOptimization of the present structure while maintaining functionality

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions