Skip to content

Feature Proposal: Implement a Hybrid System for Portable Conversation History #6398

@VooDisss

Description

@VooDisss

What specific problem does this solve?

Roo's conversation history is currently tied to the absolute path of a project folder. If a user moves a project, or if the workspace URI changes for any reason (e.g., using remote development), the conversation history becomes disconnected and is effectively lost. This makes project reorganization difficult and risks the loss of valuable context.

Proposed Solution: A Hybrid Approach

To solve this robustly, we will implement a hybrid system:

  1. Primary Mechanism (Automatic): We will use the stable workspace hash generated by VS Code as the primary identifier for a project's history. This will automatically handle most cases where a project folder is moved or renamed.

  2. Secondary Mechanism (Manual Fallback): For edge cases where the workspace hash changes (e.g., switching to a multi-root workspace, using remote development), we will provide a UI-driven workflow in the "History" panel to allow users to manually re-link orphaned history to the current workspace.

This hybrid approach provides a seamless, automatic solution for the common case, and a powerful, user-friendly tool for the exceptions.

Additional context

Technical Implementation Plan

This technical plan is provided to guide an automated AI developer in creating a pull request.

Part 1: Workspace Hash Implementation (Primary Mechanism)

  • Core Concept: The fundamental change is to switch the storage mapping from being based on a file path to being based on the stable workspace identifier that VS Code itself uses. The current mapping is Path -> "db", and the new mapping will be WorkspaceHash -> "db". This hash is the same one VS Code uses to manage its own workspace storage (e.g., in $APPDATA\Code\User\workspaceStorage).

  • Core Function: The following function will be implemented in src/utils/storage.ts to generate the stable workspace hash:

    import * as vscode from 'vscode';
    import * as crypto from 'crypto';
    
    function getWorkspaceHash() {
        const folderUri = vscode.workspace.workspaceFolders?.[0].uri.toString();
        if (!folderUri) return null;
        return crypto.createHash('sha1').update(folderUri).digest('hex');
    }
  • Path Generation: A new function, getWorkspaceStoragePath, will be created in src/utils/storage.ts. This function will call getWorkspaceHash and use the resulting hash to construct the storage path.

  • Update Core Logic: The getStorageBasePath function in src/utils/storage.ts will be updated to use the new getWorkspaceStoragePath function. This will ensure all dependent functions automatically use the new hash-based path.

  • Migration Plan:

    • A one-time, automatic migration will be implemented. On extension startup, it will detect old, path-based history, calculate the new workspace hash, and rename the old history directory to the new hash.

Part 2: UI-Driven Re-linking (Manual Fallback)

This will be implemented in three sprints.

  • Sprint 1: UI Foundation

    • Objective: Enhance the "History" panel UI.
    • Actions:
      • Refine the existing filter logic in webview-ui/src/components/history/useTaskSearch.ts.
      • The single text input will be modified to handle two search types:
        • Default: Fuzzy search on conversation content (current behavior).
        • Path Search: If the input is prefixed with path:, it will perform an exact match on the workspace property of the HistoryItem.
      • Update Placeholder Text: The placeholder text for the filter input should be updated from "Fuzzy search history..." to something more descriptive, like "Search history or use 'path:' to filter by workspace".
  • Sprint 2: Core Logic

    • Objective: Implement the backend logic for re-linking.
    • Actions:
      • Create a new relinkHistory IPC message handled in src/core/webview/webviewMessageHandler.ts.
      • Implement the handleRelinkHistory method in src/core/webview/ClineProvider.ts to handle the "Update Path" and "Import (Create a Copy)" options.
  • Sprint 3: User Feedback

    • Objective: Provide clear feedback to the user.
    • Actions:
      • Create a relinkHistoryResult IPC message to send the outcome from the backend to the webview.
      • Implement a non-modal Toast notification component in the webview-ui to display success or error messages in HistoryView.tsx.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue/PR - TriageNew issue. Needs quick review to confirm validity and assign labels.enhancementNew feature or request

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions