Problem
DailyMotivation.ps1 (the popup script) assumes %APPDATA%\DailyMotivationBrainHelper\ already exists and never calls Initialize-AppData. If the popup is triggered by Task Scheduler before MainApp.ps1 has ever run, all config files are missing and the script exits silently.
Symptoms
- Popup never appears when triggered by Task Scheduler
- Debug log shows: "Config file not found - using defaults" (line 116)
- Script exits silently at line 127: "No folder configured in popup_config.json -- exiting silently"
- User gets no feedback about what went wrong
Root Cause
DailyMotivation.ps1 loads ConfigManager module (line 85) but never calls Initialize-AppData. The script assumes:
- User ran MainApp.ps1 first
- MainApp created all necessary files
- Task Scheduler will only fire after manual setup
This assumption breaks if:
- User manually creates a scheduled task without running MainApp
- Files get deleted after initial setup
- Multiple user profiles on same machine
- Portable installation moved to new machine
Current Behavior (DailyMotivation.ps1)
# Line 85: Capture module path
$script:ModulesPath = Join-Path $PSScriptRoot "Modules"
# ... later ...
# Lines 88-90: Hardcode paths
$appDataDir = Join-Path $env:APPDATA "DailyMotivationBrainHelper"
$configPath = Join-Path $appDataDir "popup_config.json"
# Lines 104-117: Try to load config
if (Test-Path $configPath) {
# load it
} else {
Write-DLog "Config file not found - using defaults" "WARN"
}
# Lines 125-129: Exit if no folder configured
if (-not $config.explorer_path -or $config.explorer_path -eq "") {
Write-DLog "No folder configured in popup_config.json -- exiting silently" "WARN"
exit 0
}
Expected Behavior
DailyMotivation.ps1 should be self-sufficient:
- Import ConfigManager module
- Call
Initialize-AppData to ensure directory structure exists
- If popup_config.json still doesn't exist or is empty, show user-facing error dialog
- Log the issue clearly in debug log
Proposed Fix
# After loading module
Import-Module (Join-Path $script:ModulesPath "ConfigManager.psm1") -Force
# Ensure directory structure exists
Initialize-AppData
# Now load config
$config = Get-PopupConfig
if (-not $config -or -not $config.explorer_path) {
Show-ErrorDialog "No scheduled task configuration found. Please run the main application first to schedule a folder."
exit 1
}
Acceptance Criteria
Files Affected
- src/DailyMotivation.ps1 (add Initialize-AppData call after line 85)
- src/DailyMotivation.ps1 (replace silent exit at line 125 with error dialog)
Related Issues
Problem
DailyMotivation.ps1 (the popup script) assumes
%APPDATA%\DailyMotivationBrainHelper\already exists and never callsInitialize-AppData. If the popup is triggered by Task Scheduler before MainApp.ps1 has ever run, all config files are missing and the script exits silently.Symptoms
Root Cause
DailyMotivation.ps1 loads ConfigManager module (line 85) but never calls
Initialize-AppData. The script assumes:This assumption breaks if:
Current Behavior (DailyMotivation.ps1)
Expected Behavior
DailyMotivation.ps1 should be self-sufficient:
Initialize-AppDatato ensure directory structure existsProposed Fix
Acceptance Criteria
Files Affected
Related Issues