Skip to content

Invalidate weekplan cache after plan mutations (add/remove/move) #5

@TheTrustedAdvisor

Description

@TheTrustedAdvisor

Problem

After successful plan add, plan remove, or plan move operations, the local weekplan cache (cookidoo_weekplan_raw.json) is not updated. This means:

tmx plan add r123456 --date 2026-04-20  # ✅ Added on server
tmx plan show                            # ❌ Shows stale data without the new recipe
tmx plan sync                            # Must manually sync to see changes

The user sees contradictory output — the add succeeds but the show doesn't reflect it.

Proposed Solution

After each successful mutation in cmd_plan_add, cmd_plan_remove, and cmd_plan_move, either:

Option A (simple): Delete the cache and inform the user:

if success:
    WEEKPLAN_JSON.unlink(missing_ok=True)
    print(f"✅ {message}")
    print("  (Cache gelöscht — 'tmx plan show' wird automatisch neu laden)")

Option B (better UX): Auto-sync after mutation:

if success:
    print(f"✅ {message}")
    cmd_plan_sync(args, quiet=True)

Option A is simpler and triggers a sync only when the user actually runs plan show (which already has auto-sync-on-missing-cache logic at line 1413).

Impact

  • Effort: Trivial (3 lines per command)
  • User impact: Eliminates confusing stale data after mutations

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions