Skip to content

BUG: Silent exit behavior masks real initialization problems #6

Description

@SevWren

Problem

When DailyMotivation.ps1 encounters missing or empty popup_config.json, it exits silently with no user-visible feedback (line 125-129). This is documented as "intentional behavior" (GAP-003b) but it masks real initialization failures and leaves users confused.

Symptoms

  • Popup never appears
  • No error dialogs shown
  • User has no idea what went wrong
  • Debug log shows "No folder configured in popup_config.json -- exiting silently"
  • User thinks app is broken

Current Behavior

# GAP-004: Treat null/empty explorer_path as "never configured" - exit cleanly
#          rather than showing the path-missing panel, which implies a folder
#          was once set but got moved/deleted.
if (-not $config.explorer_path -or $config.explorer_path -eq "") {
    Write-DLog "No folder configured in popup_config.json -- exiting silently" "WARN"
    if ($mutexOwned -and $mutex) { try { $mutex.ReleaseMutex() } catch {} }
    exit 0
}

Design Intent (per GAP-003b)

The silent exit is meant to distinguish:

  • Never configured: User hasn't set up a task yet → exit silently
  • Folder moved/deleted: Task was configured but folder is missing → show path-missing panel

This distinction is reasonable, but the implementation has problems:

  1. Can't distinguish "never configured" from "initialization failed"
  2. Can't distinguish "user hasn't scheduled anything" from "config file missing due to bug"
  3. Silent exit during debugging makes problems invisible

Expected Behavior

Different behavior for different contexts:

Context 1: Launched by Task Scheduler

  • If config file missing → Show error dialog: "Configuration missing. Please run the main app to reschedule."
  • If explorer_path empty → Show error dialog: "Task data corrupted. Please reschedule this folder."
  • Log the issue clearly

Context 2: Manual launch (testing)

  • Always show error dialog with debug info
  • Never exit silently
  • Help developer understand what's wrong

Context 3: After successful config load

  • If explorer_path is empty → Show path-missing panel (current behavior)
  • This is the ONLY case where silent exit makes sense

Proposed Fix

Distinguish different failure modes:

# Check if config file exists
if (-not (Test-Path $configPath)) {
    Show-ErrorDialog "Configuration file not found. Please run the Daily Motivation Brain Helper application to schedule a folder." "Configuration Missing"
    Write-DLog "Config file missing: $configPath" "ERROR"
    exit 1
}

# Load config
$config = Get-PopupConfig

# Check if config is valid
if (-not $config) {
    Show-ErrorDialog "Configuration file is corrupted. Please run the application and reschedule your folder." "Configuration Error"
    Write-DLog "Config parse failed" "ERROR"
    exit 1
}

# Check if task is configured
if (-not $config.explorer_path -or $config.explorer_path -eq "") {
    # This is the ONLY case for silent exit - task exists but no path set
    # (edge case: task fired but MainApp hasn't written config yet)
    Write-DLog "No folder configured yet - task may have fired early" "INFO"
    exit 0
}

# Continue with normal flow...

Acceptance Criteria

  • Missing config file shows error dialog, not silent exit
  • Corrupted config shows error dialog with actionable message
  • Empty explorer_path (only) can exit silently (rare edge case)
  • Debug log clearly distinguishes failure modes
  • Error dialogs guide user to resolution ("run main app")
  • Manual launch never exits silently

Files Affected

  • src/DailyMotivation.ps1 (lines 104-129)
  • src/Modules/ConfigManager.psm1 (may need additional error handling)

Related Issues

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions