-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Description
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:
-
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.
-
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 beWorkspaceHash -> "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.tsto 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 insrc/utils/storage.ts. This function will callgetWorkspaceHashand use the resulting hash to construct the storage path. -
Update Core Logic: The
getStorageBasePathfunction insrc/utils/storage.tswill be updated to use the newgetWorkspaceStoragePathfunction. 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 theworkspaceproperty of theHistoryItem.
- 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".
- Refine the existing filter logic in
-
Sprint 2: Core Logic
- Objective: Implement the backend logic for re-linking.
- Actions:
- Create a new
relinkHistoryIPC message handled insrc/core/webview/webviewMessageHandler.ts. - Implement the
handleRelinkHistorymethod insrc/core/webview/ClineProvider.tsto handle the "Update Path" and "Import (Create a Copy)" options.
- Create a new
-
Sprint 3: User Feedback
- Objective: Provide clear feedback to the user.
- Actions:
- Create a
relinkHistoryResultIPC message to send the outcome from the backend to the webview. - Implement a non-modal
Toastnotification component in thewebview-uito display success or error messages inHistoryView.tsx.
- Create a
Metadata
Metadata
Assignees
Labels
Type
Projects
Status