Skip to content

Conversation

@britannio
Copy link
Collaborator

Closes #1006

image

…n't found:

**Changes made to** [crates/services/src/services/config/versions/v2.rs](file:///private/var/folders/5q/5vgq75y92dz0k7n62z93299r0000gn/T/vibe-kanban/worktrees/f905-informative-erro/crates/services/src/services/config/versions/v2.rs#L319-L387):

1. Added `get_cli_installation_instructions()` function with IDE-specific setup instructions for:
   - VSCode, Cursor, Windsurf (same Command Palette approach)
   - Zed (link to docs)
   - IntelliJ (link to JetBrains docs)
   - Xcode (automatic with `xcode-select --install` fallback)
   - Custom commands (generic message)

2. Updated `open_file()` to check if the command exists using `which` before executing, and display the installation instructions in the error message if not found.

The implementation works on all platforms (macOS, Linux, Windows) and passes type checking.
Done! I've implemented a complete end-to-end fix for informative IDE CLI error messages:

## Backend Changes

**[crates/services/src/services/config/versions/v2.rs](file:///private/var/folders/5q/5vgq75y92dz0k7n62z93299r0000gn/T/vibe-kanban/worktrees/f905-informative-erro/crates/services/src/services/config/versions/v2.rs)**:
- Added `get_cli_installation_instructions()` with IDE-specific setup guides
- Updated `open_file()` to check CLI existence with `which` before execution
- Returns detailed error messages with installation instructions when CLI not found

**[crates/server/src/routes/projects.rs](file:///private/var/folders/5q/5vgq75y92dz0k7n62z93299r0000gn/T/vibe-kanban/worktrees/f905-informative-erro/crates/server/src/routes/projects.rs)**:
- Fixed `open_project_in_editor()` to return error in JSON format instead of plain 500

## Frontend Changes

**New Component** - [frontend/src/components/dialogs/shared/ErrorDialog.tsx](file:///private/var/folders/5q/5vgq75y92dz0k7n62z93299r0000gn/T/vibe-kanban/worktrees/f905-informative-erro/frontend/src/components/dialogs/shared/ErrorDialog.tsx):
- Created error dialog with `whitespace-pre-wrap` to preserve multi-line formatting

**[frontend/src/lib/modals.ts](file:///private/var/folders/5q/5vgq75y92dz0k7n62z93299r0000gn/T/vibe-kanban/worktrees/f905-informative-erro/frontend/src/lib/modals.ts)**:
- Added `showError()` helper function

**[frontend/src/main.tsx](file:///private/var/folders/5q/5vgq75y92dz0k7n62z93299r0000gn/T/vibe-kanban/worktrees/f905-informative-erro/frontend/src/main.tsx)**:
- Registered ErrorDialog modal

**[frontend/src/hooks/useOpenProjectInEditor.ts](file:///private/var/folders/5q/5vgq75y92dz0k7n62z93299r0000gn/T/vibe-kanban/worktrees/f905-informative-erro/frontend/src/hooks/useOpenProjectInEditor.ts)** & **[useOpenInEditor.ts](file:///private/var/folders/5q/5vgq75y92dz0k7n62z93299r0000gn/T/vibe-kanban/worktrees/f905-informative-erro/frontend/src/hooks/useOpenInEditor.ts)**:
- Updated to display error dialog with installation instructions to users

When users click "Open in Editor" without the CLI installed, they now see a dialog with detailed setup instructions for their IDE.
…s left to do and you can ask me to continue with the translation files and frontend updates:

## Summary of Progress

✅ **Backend Complete:**
- Added `OpenEditorError` enum with structured error types
- Updated `open_file()` to return structured errors
- Updated both route handlers to use `error_with_data`
- Generated TypeScript types

🔄 **Remaining Work:**
1. Add i18n translation keys to all language files (en, ja, es, ko)
2. Update frontend hooks to parse structured errors and use i18n
3. Test the complete flow

The backend now returns structured errors like:
```json
{
  "success": false,
  "error_data": {
    "type": "ide_cli_not_found",
    "editor_type": "VS_CODE",
    "cli_command": "code"
  }
}
```

Should I continue with adding the i18n translations and updating the frontend hooks?
## Complete Localized IDE Error Messages

### Backend Changes

**Structured Error Types** - [crates/services/src/services/config/versions/v2.rs](file:///private/var/folders/5q/5vgq75y92dz0k7n62z93299r0000gn/T/vibe-kanban/worktrees/f905-informative-erro/crates/services/src/services/config/versions/v2.rs):
- Added `OpenEditorError` enum with `IdeCliNotFound`, `InvalidConfig`, and `Io` variants
- Updated `open_file()` to return structured errors instead of formatted strings
- Removed hardcoded English installation instructions

**API Responses** - [crates/server/src/routes/projects.rs](file:///private/var/folders/5q/5vgq75y92dz0k7n62z93299r0000gn/T/vibe-kanban/worktrees/f905-informative-erro/crates/server/src/routes/projects.rs) & [task_attempts.rs](file:///private/var/folders/5q/5vgq75y92dz0k7n62z93299r0000gn/T/vibe-kanban/worktrees/f905-informative-erro/crates/server/src/routes/task_attempts.rs):
- Both routes now return `ApiResponse::error_with_data(e)` with structured error

### Frontend Changes

**i18n Translations** - Added to all languages (en, ja, es, ko):
- `common:errors.cannotOpenEditor.title` - Dialog title
- `common:errors.ideCli.missing.summary` - Summary message with command interpolation
- `common:errors.ideCli.instructions.{IDE_TYPE}` - Platform-specific setup instructions for VS_CODE, CURSOR, WINDSURF, ZED, INTELLI_J, XCODE, and CUSTOM

**Error Handling** - [useOpenProjectInEditor.ts](file:///private/var/folders/5q/5vgq75y92dz0k7n62z93299r0000gn/T/vibe-kanban/worktrees/f905-informative-erro/frontend/src/hooks/useOpenProjectInEditor.ts) & [useOpenInEditor.ts](file:///private/var/folders/5q/5vgq75y92dz0k7n62z93299r0000gn/T/vibe-kanban/worktrees/f905-informative-erro/frontend/src/hooks/useOpenInEditor.ts):
- Parse `OpenEditorError` from `error_data`
- Build localized messages using i18n based on IDE type
- Display in ErrorDialog with preserved formatting

### Flow

When a user clicks "Open in Editor" without the CLI installed:

1. Backend detects missing CLI and returns:
```json
{
  "success": false,
  "error_data": {
    "type": "ide_cli_not_found",
    "editor_type": "VS_CODE",
    "cli_command": "code"
  }
}
```

2. Frontend displays localized dialog in user's language with IDE-specific installation instructions

All type checks pass ✅
## Fixed: Removed `OpenEditorError` from Config Version Chain

**Problem:** `OpenEditorError` was incorrectly added to the config version migration chain (v2→v3→v4→v5→v6→v7). These version files are for **serialized config schema migration** when users upgrade, but `OpenEditorError` is a **runtime API error type**, not part of the config that gets saved to disk.

**Solution:**

1. **Created separate module** - [crates/services/src/services/config/errors.rs](file:///private/var/folders/5q/5vgq75y92dz0k7n62z93299r0000gn/T/vibe-kanban/worktrees/f905-informative-erro/crates/services/src/services/config/errors.rs)
   - Moved `OpenEditorError` enum here

2. **Exported directly from config module** - [crates/services/src/services/config/mod.rs](file:///private/var/folders/5q/5vgq75y92dz0k7n62z93299r0000gn/T/vibe-kanban/worktrees/f905-informative-erro/crates/services/src/services/config/mod.rs)
   - Added `pub use errors::OpenEditorError;`
   - Removed from version chain type aliases

3. **Cleaned up version files**
   - Removed `OpenEditorError` from all version re-exports (v3, v4, v5, v6, v7)
   - Version files now only contain actual config types

**Result:** `OpenEditorError` is now properly separated from config versioning, making the architecture cleaner and preventing confusion about what gets serialized vs what's just a runtime error type.

All type checks pass ✅
## Complete! Localized IDE Error Messages via `ApiError`

### Architecture Fix

**Proper `ApiError` Integration** instead of bypassing with `ApiResponse::error_with_data()`:

**[crates/server/src/error.rs](file:///private/var/folders/5q/5vgq75y92dz0k7n62z93299r0000gn/T/vibe-kanban/worktrees/f905-informative-erro/crates/server/src/error.rs)**:
- Added `OpenEditor(OpenEditorError)` variant to `ApiError` enum with `#[from]`
- Extended `into_response()` to return structured `error_with_data` for `OpenEditor` variant

**[crates/services/src/services/config/errors.rs](file:///private/var/folders/5q/5vgq75y92dz0k7n62z93299r0000gn/T/vibe-kanban/worktrees/f905-informative-erro/crates/services/src/services/config/errors.rs)** (new file):
- Created separate module for `OpenEditorError` (not part of config versioning)
- Added `thiserror::Error` derive with descriptive error messages
- Structured error types: `IdeCliNotFound`, `InvalidConfig`, `Io`

**Routes** - [projects.rs](file:///private/var/folders/5q/5vgq75y92dz0k7n62z93299r0000gn/T/vibe-kanban/worktrees/f905-informative-erro/crates/server/src/routes/projects.rs) & [task_attempts.rs](file:///private/var/folders/5q/5vgq75y92dz0k7n62z93299r0000gn/T/vibe-kanban/worktrees/f905-informative-erro/crates/server/src/routes/task_attempts.rs):
- Standard `Result<ResponseJson<ApiResponse<()>>, ApiError>` return type
- Error propagation with `?` operator - clean and idiomatic

### Frontend (Unchanged)
- i18n translations for all IDEs in 4 languages (en, ja, es, ko)
- Hooks parse structured errors and display localized messages
- ErrorDialog with `whitespace-pre-wrap` for multi-line instructions

✅ All type checks pass
✅ Follows existing `ApiError` pattern
✅ Config versioning untouched
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

An error occurs when opening a task in the editor. 「Failed to open editor for project ***: No such file or directory (os error 2)」

1 participant