Skip to content

feat(desktop): add curl import dialog to explorer#94

Merged
andrewmelchor merged 2 commits intomainfrom
feat(desktop)/curl-importer
Feb 27, 2026
Merged

feat(desktop): add curl import dialog to explorer#94
andrewmelchor merged 2 commits intomainfrom
feat(desktop)/curl-importer

Conversation

@andrewmelchor
Copy link
Copy Markdown
Member

Summary

What

Introduces a cURL import feature in the desktop explorer that lets users paste curl commands and convert them into HTTP request files within their workspace.

How it works

  • Users click the new "Import" button in the explorer toolbar
  • A dialog opens with a textarea for the curl command and options for output directory
  • Advanced options include conflict policy selection, custom filenames, request naming, variable merging, and force-apply for error cases
  • Preview phase validates the command and shows what files would be created, skipped, renamed, or failed
  • Apply phase writes the files and refreshes the explorer, automatically selecting the first created request
  • Comprehensive diagnostics display with severity badges (error/warning/info) helps users fix malformed commands

Key behaviors

  • Conflict policies: fail (default), skip, overwrite, or rename with suffix
  • Smart directory selection defaults to the currently selected directory or its parent
  • Preview key caching prevents stale applies when inputs change
  • Force checkbox allows applying even when diagnostics contain errors
  • Partial success handling for multi-request imports with mixed results

Testing

Unit tests cover input resolution, preview key generation, and API response normalization for both preview and apply endpoints.

Adds a modal dialog to the desktop explorer allowing users to paste
curl commands and import them as HTTP request files. Features a
preview/apply workflow, configurable conflict policies (fail, skip,
overwrite, rename), variable merging, and comprehensive diagnostics
for validation errors.
@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Feb 27, 2026

Greptile Summary

Implemented a comprehensive curl import feature that allows users to paste curl commands and convert them into HTTP request files within their workspace. The implementation follows a well-structured preview/apply workflow with extensive validation and error handling.

Key implementation details

  • Dialog component provides a clean UI with textarea for curl commands, output directory selection, and advanced options (conflict policies, custom filenames, variable merging)
  • Preview phase validates commands and shows what files would be created, with comprehensive diagnostics for malformed commands
  • Apply phase writes files and automatically selects the first created request, with partial success handling for multi-request imports
  • Security includes directory traversal prevention via input validation
  • State management uses preview key caching to prevent stale applies when inputs change
  • Error handling displays diagnostics with severity badges (error/warning/info) and provides force checkbox to override error blocks

Strengths

  • Well-tested utility functions with comprehensive test coverage
  • Proper state management prevents race conditions and stale data
  • Good separation of concerns between UI, business logic, and API calls
  • Clear user feedback through busy states, error messages, and preview results
  • Defensive programming with input validation and preview key matching

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The implementation is well-architected with proper error handling, security considerations, comprehensive testing, and careful state management. No critical issues or bugs were identified during review.
  • No files require special attention

Important Files Changed

Filename Overview
packages/desktop/src/features/explorer/components/CurlImportDialog.tsx Well-structured modal dialog component with comprehensive UI for curl import workflow including preview/apply phases, diagnostics display, and various configuration options
packages/desktop/src/features/explorer/utils/curl-import.ts Core utility module providing input validation, directory traversal prevention, preview key generation, and API response normalization for curl import feature
packages/desktop/src/features/explorer/utils/curl-import.test.ts Comprehensive test suite covering input resolution, directory traversal prevention, preview key generation, and response normalization for both preview and apply operations
packages/desktop/src/features/explorer/components/ExplorerScreen.tsx Integrated curl import dialog with sophisticated state management, preview/apply workflow orchestration, preview key validation to prevent stale applies, and automatic file selection after successful import

Sequence Diagram

sequenceDiagram
    participant User
    participant ExplorerToolbar
    participant ExplorerScreen
    participant CurlImportDialog
    participant CurlImportUtils
    participant API

    User->>ExplorerToolbar: Click Import button
    ExplorerToolbar->>ExplorerScreen: onImport()
    ExplorerScreen->>ExplorerScreen: openCurlImportDialog()
    ExplorerScreen->>CurlImportDialog: Render dialog with initial state
    
    User->>CurlImportDialog: Enter curl command
    CurlImportDialog->>ExplorerScreen: onCommandChange()
    ExplorerScreen->>ExplorerScreen: clearCurlImportPreviewOutcome()
    
    User->>CurlImportDialog: Click Preview button
    CurlImportDialog->>ExplorerScreen: onPreview()
    ExplorerScreen->>CurlImportUtils: resolveCurlImportInput()
    CurlImportUtils->>CurlImportUtils: Validate input, check directory traversal
    CurlImportUtils-->>ExplorerScreen: {previewKey, previewRequest, applyRequest}
    
    ExplorerScreen->>API: importCurlPreview(previewRequest)
    API-->>ExplorerScreen: Preview result with diagnostics
    ExplorerScreen->>CurlImportUtils: normalizeCurlImportPreviewOutcome()
    CurlImportUtils-->>ExplorerScreen: Normalized outcome
    ExplorerScreen->>CurlImportDialog: Update preview state
    
    User->>CurlImportDialog: Click Apply button
    CurlImportDialog->>ExplorerScreen: onApply()
    ExplorerScreen->>ExplorerScreen: Validate preview key matches
    ExplorerScreen->>ExplorerScreen: Check diagnostics not blocked
    
    ExplorerScreen->>API: importCurlApply(applyRequest)
    API-->>ExplorerScreen: Apply result with file paths
    ExplorerScreen->>CurlImportUtils: normalizeCurlImportApplyOutcome()
    CurlImportUtils-->>ExplorerScreen: Normalized outcome
    
    ExplorerScreen->>ExplorerScreen: explorer.refresh()
    ExplorerScreen->>ExplorerScreen: handleSelectFile(firstWritten)
    ExplorerScreen->>CurlImportDialog: Close dialog
    CurlImportDialog-->>User: Show imported file selected
Loading

Last reviewed commit: 77bb723

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 77bb723b29

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@andrewmelchor andrewmelchor merged commit 9ff7294 into main Feb 27, 2026
1 check passed
@andrewmelchor andrewmelchor deleted the feat(desktop)/curl-importer branch February 27, 2026 05:31
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.

1 participant