mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-05 01:50:27 +08:00
fix: enhance workflow execute session selection with user interaction
- Add detailed session discovery logic with 3 cases (none, single, multiple) - Implement AskUserQuestion for multiple active sessions - Display rich session metadata (project name, task progress, completion %) - Support flexible user input (session number, full ID, or partial ID) - Maintain backward compatibility for single-session scenarios - Improve user experience with clear confirmation messages This minimal change addresses session conflict issues without complex locking mechanisms, focusing on explicit user choice when ambiguity exists.
This commit is contained in:
@@ -54,13 +54,89 @@ Orchestrates autonomous workflow execution through systematic task discovery, ag
|
||||
### Phase 1: Discovery
|
||||
**Applies to**: Normal mode only (skipped in resume mode)
|
||||
|
||||
**Process**:
|
||||
1. **Check Active Sessions**: Find sessions in `.workflow/active/` directory
|
||||
2. **Select Session**: If multiple found, prompt user selection
|
||||
3. **Load Session Metadata**: Read `workflow-session.json` ONLY (minimal context)
|
||||
4. **DO NOT read task JSONs yet** - defer until execution phase
|
||||
**Purpose**: Find and select active workflow session with user confirmation when multiple sessions exist
|
||||
|
||||
**Resume Mode**: This phase is completely skipped when `--resume-session="session-id"` flag is provided.
|
||||
**Process**:
|
||||
|
||||
#### Step 1.1: Count Active Sessions
|
||||
```bash
|
||||
bash(find .workflow/active/ -name "WFS-*" -type d 2>/dev/null | wc -l)
|
||||
```
|
||||
|
||||
#### Step 1.2: Handle Session Selection
|
||||
|
||||
**Case A: No Active Sessions (count = 0)**
|
||||
```
|
||||
ERROR: No active workflow sessions found
|
||||
SOLUTION: Run /workflow:plan "task description" to create a session
|
||||
```
|
||||
Stop execution and return error to user.
|
||||
|
||||
**Case B: Single Active Session (count = 1)**
|
||||
```bash
|
||||
bash(find .workflow/active/ -name "WFS-*" -type d 2>/dev/null | head -1 | xargs basename)
|
||||
```
|
||||
Store as `sessionId` and continue to Phase 2 (no user interaction needed).
|
||||
|
||||
**Case C: Multiple Active Sessions (count > 1)**
|
||||
|
||||
1. **List sessions with rich metadata**:
|
||||
```bash
|
||||
bash(for dir in .workflow/active/WFS-*/; do
|
||||
session=$(basename "$dir")
|
||||
project=$(jq -r '.project // "Unknown"' "$dir/workflow-session.json" 2>/dev/null)
|
||||
total=$(grep -c "^- \[" "$dir/TODO_LIST.md" 2>/dev/null || echo "0")
|
||||
completed=$(grep -c "^- \[x\]" "$dir/TODO_LIST.md" 2>/dev/null || echo "0")
|
||||
|
||||
if [ "$total" -gt 0 ]; then
|
||||
progress=$((completed * 100 / total))
|
||||
else
|
||||
progress=0
|
||||
fi
|
||||
|
||||
echo "${session} | ${project} | ${completed}/${total} tasks (${progress}%)"
|
||||
done)
|
||||
```
|
||||
|
||||
2. **Present options to user** (using AskUserQuestion tool):
|
||||
|
||||
Format output into numbered list:
|
||||
```
|
||||
Multiple active workflow sessions detected. Please select one:
|
||||
|
||||
1. WFS-auth-system | Authentication System | 3/5 tasks (60%)
|
||||
2. WFS-payment-module | Payment Integration | 0/8 tasks (0%)
|
||||
3. WFS-ui-redesign | UI Redesign | 7/10 tasks (70%)
|
||||
|
||||
Which session do you want to execute?
|
||||
```
|
||||
|
||||
Use AskUserQuestion tool to get user selection. User can provide:
|
||||
- Session number (e.g., "1", "2", "3")
|
||||
- Full session ID (e.g., "WFS-auth-system")
|
||||
- Partial session ID (e.g., "auth-system")
|
||||
|
||||
3. **Parse user response**:
|
||||
- Extract session ID from user input by matching against the session list
|
||||
- Validate the selection exists
|
||||
|
||||
4. **Confirm selection** to user:
|
||||
```
|
||||
✓ Selected session: WFS-auth-system (Authentication System)
|
||||
Progress: 3/5 tasks (60%)
|
||||
```
|
||||
|
||||
Continue to Phase 2.
|
||||
|
||||
#### Step 1.3: Load Session Metadata
|
||||
```bash
|
||||
bash(cat .workflow/active/${sessionId}/workflow-session.json)
|
||||
```
|
||||
|
||||
**Output**: Store session metadata in memory
|
||||
**DO NOT read task JSONs yet** - defer until execution phase (lazy loading)
|
||||
|
||||
**Resume Mode**: This entire phase is skipped when `--resume-session="session-id"` flag is provided.
|
||||
|
||||
### Phase 2: Planning Document Analysis
|
||||
**Applies to**: Normal mode only (skipped in resume mode)
|
||||
|
||||
Reference in New Issue
Block a user