# Bug Fix #11: Modal Action Dispatch Issues

**Date:** 2025-02-04
**Severity:** Medium
**Status:** FIXED ✅

## Issues Fixed

### 1. Profile Modal Selection Not Working
**Symptom:** Selecting a profile in the `/profile` modal did nothing - modal closed but profile didn't change.

**Root Cause:** The modal action dispatch in `plugin.py` checked `hasattr(handler, "handle_modal_action")` which always returned `True` since all handlers inherit the method from `BaseCommandHandler`. The base class stub just logs "Unhandled modal action" and returns.

**Fix:** Added check to verify the method is actually overridden:
```python
if (hasattr(handler, "handle_modal_action") and
    type(handler).handle_modal_action is not BaseCommandHandler.handle_modal_action):
```

**Files Modified:**
- `kollabor/commands/system_commands/plugin.py`

### 2. CWD Widget Directory Changes Not Working
**Symptom:** Selecting a directory from the CWD widget (via `/cd` command) would close the modal but the directory wouldn't change and the widget wouldn't update.

**Root Causes:**
1. Missing routing for cwd actions (`cwd_parent`, `cwd_home`, `cwd_custom`, `select_directory`)
2. `DirectoryCommandHandler.handle_modal_action` had wrong signature `(action, data)` instead of `(data, event)`
3. Modal renderer only copied specific fields when building `_triggered_action`, missing `target_path`

**Fixes:**
1. Added routing for cwd actions in `plugin.py`
2. Fixed `DirectoryCommandHandler.handle_modal_action` signature to `(data, event)`
3. Changed modal renderer to preserve ALL fields: `self._triggered_action = dict(selected_cmd)`

**Files Modified:**
- `kollabor/commands/system_commands/plugin.py`
- `kollabor/commands/system_commands/handlers/directory.py`
- `kollabor/ui/modal_renderer.py`

## Testing

Verified via tmux automated testing:
```bash
tmux new-session -d -s test "python main.py"
tmux send-keys -t test "/cd Enter"
tmux send-keys -t test "Down Enter"
# Verify directory changed and CWD widget updated
tmux capture-pane -t test -p | grep cwd
```

## Impact

- Profile switching now works correctly
- Directory navigation via status widgets now works
- Modal action dispatch is more robust for all future handlers
