Skip to content
Closed

# v #44

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
161 changes: 161 additions & 0 deletions go-version/INTERACTION_UPDATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
# Interaction Update - PR Editor Feature

## 🎯 Changes Made

### Improved User Experience

Changed the prompt for adding description/screenshots from a simple Yes/No confirmation to a more intuitive selection interface.

### Before ❌

```bash
? Would you like to add detailed description with images/videos? (y/N): _
```

User needs to:
- Type `y` or `n`
- Remember the convention
- Default behavior not obvious

### After ✅

```bash
? Add detailed description with images/videos?
> ⏭️ Skip (default)
✅ Yes, continue
```

User can:
- **Press Enter** → Skip immediately (default)
- **Press ↓ or Space** → Toggle to "Yes, continue"
- **Press Enter** → Confirm selection

## 🎨 Benefits

1. **Faster Workflow**
- Want to skip? Just press Enter once
- No need to think about y/n

2. **More Intuitive**
- Visual selection with icons
- Clear indication of default option
- Familiar interaction pattern

3. **Less Error-Prone**
- Can't accidentally select wrong option
- Visual feedback before confirming

4. **Better Discoverability**
- New users immediately understand their options
- Icons make it more approachable

## 📝 Technical Implementation

### New Function

Added `PromptOptional()` in `internal/ui/prompt.go`:

```go
// PromptOptional prompts for an optional action with space to select, enter to skip
// This provides better UX: Space = Yes, Enter = Skip (default)
func PromptOptional(message string) (bool, error) {
options := []string{
"⏭️ Skip (default)",
"✅ Yes, continue",
}

prompt := &survey.Select{
Message: message,
Options: options,
Default: options[0], // Default to Skip
}

var result string
if err := survey.AskOne(prompt, &result); err != nil {
return false, err
}

// Check if user selected "Yes"
return result == options[1], nil
}
```

### Usage

Updated `pr_create.go` to use the new function:

```go
// 询问是否添加说明/截图 (空格选择,Enter 跳过)
var editorResult *editor.EditorResult
addDescription, err := ui.PromptOptional("Add detailed description with images/videos?")
if err == nil && addDescription {
// ... open editor
}
```

## 📊 Comparison

| Aspect | Before | After |
|--------|--------|-------|
| **Skip Action** | Type 'n' + Enter | Just Enter |
| **Select Action** | Type 'y' + Enter | Space/↓ + Enter |
| **Visual Feedback** | None | Icons + Highlight |
| **Default Clear** | (y/N) text hint | "⏭️ Skip (default)" |
| **Keystrokes (skip)** | 2 | 1 |
| **Keystrokes (select)** | 2 | 2 |

## 🔄 Workflow Example

### Typical Usage (Skip)

```bash
$ qkflow pr create NA-9245

✓ Found Jira issue: Fix login button
✓ Select type(s): Bug fix

? Add detailed description with images/videos?
> ⏭️ Skip (default) ← User presses Enter
✅ Yes, continue

✓ Generated title: fix: ...
# Continues with PR creation
```

### With Description (Select)

```bash
$ qkflow pr create NA-9245

✓ Found Jira issue: Fix login button
✓ Select type(s): Bug fix

? Add detailed description with images/videos?
⏭️ Skip (default) ← User presses ↓ or Space
> ✅ Yes, continue ← Now highlighted
← User presses Enter

🌐 Opening editor in your browser...
# Editor opens
```

## ✅ Testing

- [x] Build succeeds
- [x] No compilation errors
- [x] Documentation updated
- [x] User-friendly interaction
- [x] Default behavior preserved (skip)

## 📚 Documentation Updated

- ✅ `README.md` - Added interaction example
- ✅ `PR_EDITOR_FEATURE.md` - Updated workflow example
- ✅ Code comments - Explained new behavior

---

**Date**: 2024-11-18
**Impact**: User Experience Enhancement
**Breaking Changes**: None (maintains backward compatibility in behavior)

Loading
Loading