Skip to content

Commit 45636c3

Browse files
committed
✨ feat(extension): add auto-reload for core changes in dev mode
Previously, devs would need to restart the extension host to see core changes. Now, with this change, we monitor the files within the core directory. If any changes are detected, we trigger a reload command within the extension, effectively enabling auto-reloading within the extension Dev notes I was originally going to make this a new env var something like ENABLE_CORE_AUTO_RESTART, but instead just based it on the NODE_ENV. Let me know if you think the env var would be better! (or something else!) - enhance development experience by eliminating manual restarts - implement file system watcher for core files - automatically reload extension host on changes Test plan: Verified running the extension locally that changes to `src` reload the window in dev.
1 parent 6f90d4c commit 45636c3

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ Follow these steps for coding and submitting your work.
178178
3. **Run Webview (Dev Mode)**: `npm run dev` (for Vite/React app with HMR)
179179
4. **Debug Extension**: Press `F5` in VS Code (or **Run****Start Debugging**) to open a new Extension Development Host window with Roo Code loaded.
180180

181-
Webview changes (in `webview-ui`) will appear immediately with Hot Module Replacement. Changes to the core extension (in `src`) will require a restart of the Extension Development Host.
181+
Webview changes (in `webview-ui`) will appear immediately with Hot Module Replacement.
182+
In development mode (NODE_ENV="development"), changing the core code (in `src`) will trigger a `workbench.action.reloadWindow` command, so it is no longer necessary to manually restart the Extension Development Host.
182183

183184
Alternatively, to build and install a `.vsix` package:
184185

src/extension.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,21 @@ export async function activate(context: vscode.ExtensionContext) {
123123
// Implements the `RooCodeAPI` interface.
124124
const socketPath = process.env.ROO_CODE_IPC_SOCKET_PATH
125125
const enableLogging = typeof socketPath === "string"
126+
127+
// Watch the core files and automatically reload the extension host
128+
const enableCoreAutoReload = process.env?.NODE_ENV === "development"
129+
if (enableCoreAutoReload) {
130+
console.log(`♻️♻️♻️ Core auto-reloading is ENABLED!`)
131+
const watcher = vscode.workspace.createFileSystemWatcher(
132+
new vscode.RelativePattern(context.extensionPath, "src/**/*.ts"),
133+
)
134+
watcher.onDidChange((uri) => {
135+
console.log(`♻️ File changed: ${uri.fsPath}. Reloading host…`)
136+
vscode.commands.executeCommand("workbench.action.reloadWindow")
137+
})
138+
context.subscriptions.push(watcher)
139+
}
140+
126141
return new API(outputChannel, provider, socketPath, enableLogging)
127142
}
128143

0 commit comments

Comments
 (0)