Skip to content

Commit 3d19123

Browse files
committed
Merge branch 'main' of github.com:cline/cline
2 parents 4f6605c + b4e67af commit 3d19123

File tree

6 files changed

+46
-2
lines changed

6 files changed

+46
-2
lines changed

.changeset/yellow-paws-chew.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"claude-dev": minor
3+
---
4+
5+
ADD IS_DEV and Hot Reloading to debug

.vscode/launch.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@
1111
"request": "launch",
1212
"args": ["--extensionDevelopmentPath=${workspaceFolder}"],
1313
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
14-
"preLaunchTask": "${defaultBuildTask}"
14+
"preLaunchTask": "${defaultBuildTask}",
15+
"env": {
16+
"IS_DEV": "true",
17+
"DEV_WORKSPACE_FOLDER": "${workspaceFolder}"
18+
}
1519
}
1620
]
1721
}

.vscode/tasks.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@
2424
"presentation": {
2525
"group": "watch",
2626
"reveal": "never"
27+
},
28+
"options": {
29+
"env": {
30+
"IS_DEV": "true"
31+
}
2732
}
2833
},
2934
{

src/extension.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { Logger } from "./services/logging/Logger"
77
import { createClineAPI } from "./exports"
88
import "./utils/path" // necessary to have access to String.prototype.toPosix
99
import { DIFF_VIEW_URI_SCHEME } from "./integrations/editor/DiffViewProvider"
10+
import assert from "node:assert"
1011

1112
/*
1213
Built using https://github.com/microsoft/vscode-webview-ui-toolkit
@@ -190,3 +191,22 @@ export function activate(context: vscode.ExtensionContext) {
190191
export function deactivate() {
191192
Logger.log("Cline extension deactivated")
192193
}
194+
195+
// TODO: Find a solution for automatically removing DEV related content from production builds.
196+
// This type of code is fine in production to keep. We just will want to remove it from production builds
197+
// to bring down built asset sizes.
198+
//
199+
// This is a workaround to reload the extension when the source code changes
200+
// since vscode doesn't support hot reload for extensions
201+
const { IS_DEV, DEV_WORKSPACE_FOLDER } = process.env
202+
203+
if (IS_DEV && IS_DEV !== "false") {
204+
assert(DEV_WORKSPACE_FOLDER, "DEV_WORKSPACE_FOLDER must be set in development")
205+
const watcher = vscode.workspace.createFileSystemWatcher(new vscode.RelativePattern(DEV_WORKSPACE_FOLDER, "src/**/*"))
206+
207+
watcher.onDidChange(({ scheme, path }) => {
208+
console.info(`${scheme} ${path} changed. Reloading VSCode...`)
209+
210+
vscode.commands.executeCommand("workbench.action.reloadWindow")
211+
})
212+
}

webview-ui/scripts/build-react-no-split.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
const rewire = require("rewire")
1313
const defaults = rewire("react-scripts/scripts/build.js")
1414
const config = defaults.__get__("config")
15+
const webpack = require("webpack")
1516

1617
/* Modifying Webpack Configuration for 'shared' dir
1718
This section uses Rewire to modify Create React App's webpack configuration without ejecting. Rewire allows us to inject and alter the internal build scripts of CRA at runtime. This allows us to maintain a flexible project structure that keeps shared code outside the webview-ui/src directory, while still adhering to CRA's security model that typically restricts imports to within src/.
@@ -119,6 +120,15 @@ config.output = {
119120
filename: "static/js/[name].js",
120121
}
121122

123+
// Adjust build environment variables for dev/debug builds.
124+
config.plugins[4] = new webpack.DefinePlugin({
125+
"process.env": {
126+
...config.plugins[4].definitions["process.env"],
127+
NODE_ENV: JSON.stringify(process.env.IS_DEV ? "development" : "production"),
128+
IS_DEV: JSON.stringify(process.env.IS_DEV),
129+
},
130+
})
131+
122132
// Rename main.{hash}.css to main.css
123133
config.plugins[5].options.filename = "static/css/[name].css"
124134
config.plugins[5].options.moduleFilename = () => "static/css/main.css"

webview-ui/src/components/settings/SettingsView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { validateApiConfiguration, validateModelId } from "../../utils/validate"
55
import { vscode } from "../../utils/vscode"
66
import ApiOptions from "./ApiOptions"
77
import SettingsButton from "../common/SettingsButton"
8-
const IS_DEV = false // FIXME: use flags when packaging
8+
const { IS_DEV } = process.env
99

1010
type SettingsViewProps = {
1111
onDone: () => void

0 commit comments

Comments
 (0)