Skip to content

[Compose] Migrate VSCode DevInInput features to mpp-ui Compose #35

@phodal

Description

@phodal

Summary

Migrate VSCode DevInInput features to mpp-ui Compose for feature parity across all platforms.

Implementation Status

Phase 1: File Context Management ✅

  • Create SelectedFileItem.kt - Data class for selected files
  • Create FileChip.kt - File chip component with remove button
  • Create TopToolbar.kt - Top toolbar with file context management
  • Integrate TopToolbar into DevInEditorInput
  • Add FileContext to EditorCallbacks.onSubmit

Phase 2: Bottom Toolbar Enhancement ✅

  • Add Prompt Enhancement button (AutoAwesome icon)
  • Add isEnhancing state indicator
  • Connect to existing enhanceCurrentInput() function

Phase 3: FileSearchPopup Implementation ✅

  • Create FileSearchPopup.kt - File search popup component
  • Create FileSearchProvider interface for platform-specific implementations
  • Integrate FileSearchPopup into DevInEditorInput
  • Add fileSearchProvider parameter to DevInEditorInput

Phase 4: Platform Integration ✅

  • Create WorkspaceFileSearchProvider.kt - Uses WorkspaceManager's ProjectFileSystem
  • Create RecentFilesProvider interface for tracking recent files
  • Create InMemoryRecentFilesProvider for in-memory recent files tracking
  • Default to WorkspaceFileSearchProvider when no provider is specified

Files Created/Modified

New Files

  • mpp-ui/src/commonMain/kotlin/cc/unitmesh/devins/ui/compose/editor/context/SelectedFileItem.kt
  • mpp-ui/src/commonMain/kotlin/cc/unitmesh/devins/ui/compose/editor/context/FileChip.kt
  • mpp-ui/src/commonMain/kotlin/cc/unitmesh/devins/ui/compose/editor/context/TopToolbar.kt
  • mpp-ui/src/commonMain/kotlin/cc/unitmesh/devins/ui/compose/editor/context/FileSearchPopup.kt
  • mpp-ui/src/commonMain/kotlin/cc/unitmesh/devins/ui/compose/editor/context/WorkspaceFileSearchProvider.kt

Modified Files

  • mpp-core/src/commonMain/kotlin/cc/unitmesh/devins/editor/EditorCallbacks.kt - Added FileContext data class and onSubmit(text, files) overload
  • mpp-ui/src/commonMain/kotlin/cc/unitmesh/devins/ui/compose/editor/DevInEditorInput.kt - Integrated TopToolbar, FileSearchPopup and file context
  • mpp-ui/src/commonMain/kotlin/cc/unitmesh/devins/ui/compose/editor/BottomToolbar.kt - Added Prompt Enhancement button
  • mpp-ui/src/commonMain/kotlin/cc/unitmesh/devins/ui/compose/icons/AutoDevComposeIcons.kt - Added AutoAwesome icon

Component Mapping

VSCode (TypeScript) mpp-ui (Compose)
ChatInput.tsx DevInEditorInput.kt (enhanced)
TopToolbar.tsx TopToolbar.kt (NEW)
FileChip.tsx FileChip.kt (NEW)
FileSearchPopup.tsx FileSearchPopup.kt (NEW)
DevInInput.tsx BasicTextField + DevInSyntaxHighlighter
CompletionPopup.tsx CompletionPopup.kt (exists)
Bottom toolbar BottomToolbar.kt (enhanced)

Usage

The file search functionality now works out of the box using WorkspaceFileSearchProvider:

// Default usage - uses WorkspaceFileSearchProvider automatically
DevInEditorInput(
    // ... other params
)

// Custom provider
DevInEditorInput(
    // ... other params
    fileSearchProvider = myCustomProvider
)

Custom Recent Files Tracking

val recentFilesProvider = InMemoryRecentFilesProvider(maxSize = 20)
val searchProvider = WorkspaceFileSearchProvider(recentFilesProvider)

DevInEditorInput(
    fileSearchProvider = searchProvider
)

Architecture

FileSearchProvider (interface)
    ├── DefaultFileSearchProvider (empty implementation)
    └── WorkspaceFileSearchProvider (uses ProjectFileSystem)
            └── RecentFilesProvider (optional)
                    └── InMemoryRecentFilesProvider

Future Enhancements

  • Persistent recent files storage (SQLDelight)
  • File type filtering
  • Folder-only search mode
  • Search result highlighting

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions