mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
fix: preserve task state when extension host restarts in new window
- Modified ClineProvider.ts to check if tasks exist before clearing them - Only clear task stack on fresh start, not on webview restoration - Added logging to indicate when task state is preserved - Updated webviewMessageHandler to log when restoring active tasks This fixes the issue where prompts were lost after extension host restart in a new window. Fixes #8035
This commit is contained in:
parent
2263d86a20
commit
517896ef7d
2 changed files with 25 additions and 2 deletions
|
|
@ -134,6 +134,7 @@ export class ClineProvider
|
|||
private taskCreationCallback: (task: Task) => void
|
||||
private taskEventListeners: WeakMap<Task, Array<() => void>> = new WeakMap()
|
||||
private currentWorkspacePath: string | undefined
|
||||
private isWebviewRestored: boolean = false // Track if webview is being restored after restart
|
||||
|
||||
private recentTasksCache?: string[]
|
||||
private pendingOperations: Map<string, PendingEditOperation> = new Map()
|
||||
|
|
@ -686,6 +687,9 @@ export class ClineProvider
|
|||
}
|
||||
|
||||
async resolveWebviewView(webviewView: vscode.WebviewView | vscode.WebviewPanel) {
|
||||
// Check if we already have a task stack (indicating a restore after extension host restart)
|
||||
const hasExistingTasks = this.clineStack.length > 0
|
||||
|
||||
this.view = webviewView
|
||||
const inTabMode = "onDidChangeViewState" in webviewView
|
||||
|
||||
|
|
@ -695,6 +699,9 @@ export class ClineProvider
|
|||
setPanel(webviewView, "sidebar")
|
||||
}
|
||||
|
||||
// Mark that we're restoring if we have existing tasks
|
||||
this.isWebviewRestored = hasExistingTasks
|
||||
|
||||
// Initialize out-of-scope variables that need to receive persistent
|
||||
// global state values.
|
||||
this.getState().then(
|
||||
|
|
@ -810,8 +817,17 @@ export class ClineProvider
|
|||
})
|
||||
this.webviewDisposables.push(configDisposable)
|
||||
|
||||
// If the extension is starting a new session, clear previous task state.
|
||||
await this.removeClineFromStack()
|
||||
// Only clear task state if this is a fresh start, not when restoring after extension host restart
|
||||
// When the extension host restarts in a new window, we want to preserve the task state
|
||||
if (!hasExistingTasks) {
|
||||
// This is a fresh start, clear any previous task state
|
||||
await this.removeClineFromStack()
|
||||
} else {
|
||||
// We're restoring after an extension host restart, preserve the task state
|
||||
this.log("Preserving task state after extension host restart")
|
||||
// Post the current state to the webview so it can restore the UI
|
||||
await this.postStateToWebview()
|
||||
}
|
||||
}
|
||||
|
||||
public async createTaskWithHistoryItem(historyItem: HistoryItem & { rootTask?: Task; parentTask?: Task }) {
|
||||
|
|
|
|||
|
|
@ -443,6 +443,13 @@ export const webviewMessageHandler = async (
|
|||
provider.postMessageToWebview({ type: "mcpServers", mcpServers: mcpHub.getAllServers() })
|
||||
}
|
||||
|
||||
// If we have an active task (after extension host restart), notify the webview to restore it
|
||||
const activeTask = provider.getCurrentTask()
|
||||
if (activeTask) {
|
||||
provider.log("Restoring active task after extension host restart")
|
||||
// The state will be posted by postStateToWebview() above, which includes the current task
|
||||
}
|
||||
|
||||
provider.providerSettingsManager
|
||||
.listConfig()
|
||||
.then(async (listApiConfig) => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue