Repository navigation
feat(debug): allow setting values of watch expressions - #18393
KevinGruber2001 wants to merge 4 commits into
Conversation
|
Hi @KevinGruber2001, Thanks for your pull request! This is how we review it:
See the review flow for details. |
EclipseSourceAI
left a comment
There was a problem hiding this comment.
Note
Autonomous AI review. May contain mistakes.
Useful comment? React 👍. Disagree? React 👎 to reject it for follow-up reviews. A reply explaining why helps too.
Agent approval means no blocking issues found. Unrelated and Follow-up comments are non-blocking. A maintainer must still sign off.
Only a maintainer can re-request a review from this agent.
Powered by Eclipse Enclave via review-guard-mcp
| Issues | Follow-ups | Unrelated |
|---|---|---|
| 1 | 1 | 0 |
Summary
The PR adds a "Set Value" item (debug.watch.setValue) to the Watch view's context menu. It is visible when the adapter supports setExpression, and disabled when the expression is unavailable or readOnly.
DebugWatchExpression.setValuesendssetExpressionin the current frame and then re-evaluates the expression. It also drops the frame's cached scopes through the newDebugStackFrame.forgetScopes()and fires a session change.- The input dialog and the
readOnlygetter move fromDebugVariabletoExpressionContainer, so the Variables view and the Watch view share them.
Checks:
npm ci && npm run build:browsersucceeds.- The new
debug-watch-expression.spec.ts(6 tests) and the existing console specs pass. - ESLint reports nothing on the changed files.
UI check in the browser app with ms-vscode.js-debug:
- On an available watch, the menu item shows and is enabled. On an unavailable watch (
doesNotExist), it shows but is disabled. - The dialog opens prefilled with the current value. After submitting, the watch shows the new value, and the debuggee uses it after continuing (
counter is 77 ... local is 9).
Notes for maintainers
- Variables view still shows the old value with js-debug. This contradicts step 4 of the PR's test instructions. After a watch Set Value, the view kept the value from the pause, both for a
Localvariable and for aClosurevariable. That held even when a scope was expanded for the first time after the set.- On the Theia side the scopes are re-fetched:
forgetScopes()runs, and the tree refreshes expanded nodes. - js-debug caches the scope variable containers per pause (
_scopeVariablestores them int.variables[e]). That cache looks like the source of the stale values. - So this looks like adapter behavior rather than a bug in this PR. A maintainer could confirm whether VS Code behaves the same with js-debug, and the PR description should not promise this behavior.
- On the Theia side the scopes are re-fetched:
- Child variables of a watch expression (the expanded nodes in the Watch view) still cannot be set. Only top-level watch expressions get the new item.
- Not tested: Electron, and adapters other than js-debug.
| await session.sendRequest('setExpression', { expression: this.expression, value, frameId: frame.raw.id }); | ||
| await this.evaluate(); | ||
| frame.forgetScopes(); | ||
| session['fireDidChange'](); |
There was a problem hiding this comment.
session['fireDidChange']() already re-evaluates every watch expression through the view model (session manager, refreshWatchExpressions), so the explicit await this.evaluate() sends a second evaluate for this expression. The setExpression response already carries value, type, variablesReference etc., so apply it with setResult like DebugVariable.setValue does with the setVariable response (link).
There was a problem hiding this comment.
Makes sense, i removed now the second evaluate function, and apply the response from setExpression directly via setResult
EclipseSourceAI
left a comment
There was a problem hiding this comment.
Note
Autonomous AI review. May contain mistakes.
Useful comment? React 👍. Disagree? React 👎 to reject it for follow-up reviews. A reply explaining why helps too.
Agent approval means no blocking issues found. Unrelated and Follow-up comments are non-blocking. A maintainer must still sign off.
Only a maintainer can re-request a review from this agent.
Powered by Eclipse Enclave via review-guard-mcp
| Issues | Follow-ups | Unrelated | Fixed since last review | Still open from last review |
|---|---|---|---|---|
| 0 | 0 | 0 | 1 | 0 |
Changes since last review
Since the last review (commit 0dcf5444c), the only substantive change is commit 32c43bc1f ("apply setExpression response instead of re-evaluating watch"), plus a merge of origin/master that brought in unrelated upstream commits (no conflicts touching this PR's files).
DebugWatchExpression.setValue now maps the setExpression response body directly into setResult({ result: response.body.value, type, variablesReference, namedVariables, indexedVariables, presentationHint }) instead of awaiting a redundant evaluate(). This reuses ExpressionItem.setResult, which sets _value/_type/_available/variablesReference/etc. and clears the cached elements for re-expansion, exactly like a fresh evaluate response would.
- Double evaluate / use setResult with the setExpression response: fixed.
setValueno longer callsthis.evaluate(); it applies thesetExpressionresponse viasetResultdirectly, matching the suggested approach.
Verified:
npm ci && npm run build:browser: succeeds (0 errors, browser + node bundles built).tsc --buildinpackages/debug: succeeds.nyc mochafordebug-watch-expression.spec.tsand the console specs: 25/25 passing.eslinton the changed file: clean.
Notes for maintainers
The remaining open note from the last review (Variables view keeping a stale value after Set Value with ms-vscode.js-debug, likely caused by the adapter caching scope variable containers per pause) wasn't re-tested this round since nothing changed in that area; it's still worth a maintainer's confirmation against VS Code's own behavior before merging, but it looked like adapter behavior rather than a bug in this PR.
Suggested squash commit message
feat(debug): allow setting values of watch expressions
These previous comments can be resolved as they are now handled:
I can't resolve them myself as I would need write permission on this repository.
| if (!this.supportSetExpression || !this.available || this.readOnly) { | ||
| return; | ||
| } | ||
| await this.openSetValueDialog(nls.localizeByDefault('Set Value'), this.value, value => this.setValue(value)); |
There was a problem hiding this comment.
Minor: The Variables view dialog names the variable. We could reuse the key with the expression:
| await this.openSetValueDialog(nls.localizeByDefault('Set Value'), this.value, value => this.setValue(value)); | |
| await this.openSetValueDialog(nls.localize('theia/debug/debugVariableInput', 'Set {0} Value', this.expression), this.value, value => this.setValue(value)); |
Do you want to adapt this?
There was a problem hiding this comment.
Yes looks good, i will add it in the next commit
|
Struct members where already changeable on double click, I added now the Set Value element to |
What it does
Adds a "Set Value" context menu action to the Watch view. It is shown when the debug adapter supports
setExpressionand is disabled when the expression is unavailable or the adapter marks the result asreadOnly. The new value is sent with asetExpressionrequest in the current frame. The expression is then re-evaluated and the frame's cached scopes are dropped, so the Variables view shows the new value too.The input dialog and the
readOnlycheck move fromDebugVariableup toExpressionContainerso both the Variables view and the Watch view use them.How to test
setExpression(e.g. the built-in JS debugger).Follow-ups
None
Breaking changes
Review checklist
nlsservice (for details, please see the Internationalization/Localization section in the Coding Guidelines)Reminder for reviewers