Skip to content

update vscode extension to support hotreload - #993

Open
schultek wants to merge 1 commit into
mainfrom
next-code-extension
Open

schultek wants to merge 1 commit into
mainfrom
next-code-extension

Conversation

@schultek

Copy link
Copy Markdown
Owner

Description

Update VSCode Extension to support hotreload and latest Jaspr version.

Type of Change

Ready Checklist

  • I've read the Contribution Guide.
  • In case this PR changes one of the core packages, I've modified the respective CHANGELOG.md file using
    the semantic_changelog format.
  • I updated/added relevant documentation (doc comments with ///).
  • I added myself to the AUTHORS file (optional, if you want to).

@github-actions

Copy link
Copy Markdown

Package Version Report

The following packages have been updated:
jaspr_test : 0.24.0-beta.0 -> 0.24.0-beta.1
jaspr : 0.24.0-beta.0 -> 0.24.0-beta.1
jaspr_builder : 0.24.0-beta.0 -> 0.24.0-beta.1
jaspr_cli : 0.24.0-beta.0 -> 0.24.0-beta.1
jaspr_router : 0.10.0-beta.0 -> 0.10.0-beta.1

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Hot reload is handled by both the Dart adapter and daemon for attached Server sessions, causing duplicate and potentially overlapping operations on the same VM.

5 open issues
What changed in this PR

This PR adds hot reload and hot restart controls to the Jaspr VS Code extension, connecting editor actions to the CLI development workflow.

Changes:

  • Adds commands, keybindings, terminal controls, and debug-request tracking.
  • Tracks running daemons and their associated debug sessions.
  • Connects daemon reload/restart requests to workflow actions and adds protocol response tests.
File Description
packages/​jaspr_cli/​test/​src/​commands/​daemon_command_test.dart Adds reload and restart response assertions.
packages/​jaspr_cli/​lib/​src/​dev/​client_domain.dart Adds reload handling and workflow callbacks with progress reporting.
packages/​jaspr_cli/​lib/​src/​commands/​dev_command.dart Extracts shared reload/restart triggers and build queueing.
packages/​jaspr_cli/​lib/​src/​commands/​daemon_command.dart Connects client-domain requests to workflow triggers.
modules/​jaspr-code/​src/​jaspr/​serve_daemon.ts Adds daemon tracking, request sending, and terminal controls.
modules/​jaspr-code/​src/​extension.ts Registers reload/restart commands and the debug tracker.
modules/​jaspr-code/​src/​debug.ts Forwards observed debug reload/restart requests to the daemon.
modules/​jaspr-code/​package.json Declares commands, conditional menu entries, and keybindings.

Review effort: Balanced

Comment on lines +132 to +133
if (message.command === "hotReload") {
daemon.reload();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does seem accurate.

Comment on lines +45 to +56
if (this.activeDaemon && this.activeDaemon.status === "running") {
return this.activeDaemon;
}
const activeSession = vscode.debug.activeDebugSession;
if (activeSession?.configuration?._processId) {
const daemon = this.getDaemonByProcessId(
activeSession.configuration._processId
);
if (daemon && daemon.status === "running") {
return daemon;
}
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems valid.

return;
}
this.lastReloadTime = now;
this.sendRequest("client.restart", { fullRestart: false });

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems valid. Would be unfortunate to drop support for earlier versions already though. Perhaps can use and check the protocolVersion from the CLI's DaemonDomain?

Comment on lines +276 to +278
if (this.status !== "running" || !this.process) {
return;
}
'appId': ?appId,
'log': '${fullRestart ? 'Restarted' : 'Reloaded'} application in ${stopwatch.elapsedMilliseconds}ms',
});
return {'code': 0};

@parlough parlough left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool!

Comment on lines +105 to +110
"when": "inDebugMode && jaspr:isRunning && !editorTextFocus"
},
{
"command": "jaspr.hotRestart",
"key": "shift+r",
"when": "inDebugMode && jaspr:isRunning && !editorTextFocus"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these conditions be inputFocus instead of editorTextFocus, so they don't trigger in other inputs like "Find"?

Suggested change
"when": "inDebugMode && jaspr:isRunning && !editorTextFocus"
},
{
"command": "jaspr.hotRestart",
"key": "shift+r",
"when": "inDebugMode && jaspr:isRunning && !editorTextFocus"
"when": "inDebugMode && jaspr:isRunning && !inputFocus"
},
{
"command": "jaspr.hotRestart",
"key": "shift+r",
"when": "inDebugMode && jaspr:isRunning && !inputFocus"

Comment on lines +132 to +133
if (message.command === "hotReload") {
daemon.reload();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does seem accurate.

Comment on lines +45 to +56
if (this.activeDaemon && this.activeDaemon.status === "running") {
return this.activeDaemon;
}
const activeSession = vscode.debug.activeDebugSession;
if (activeSession?.configuration?._processId) {
const daemon = this.getDaemonByProcessId(
activeSession.configuration._processId
);
if (daemon && daemon.status === "running") {
return daemon;
}
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems valid.

return;
}
this.lastReloadTime = now;
this.sendRequest("client.restart", { fullRestart: false });

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems valid. Would be unfortunate to drop support for earlier versions already though. Perhaps can use and check the protocolVersion from the CLI's DaemonDomain?

Comment on lines +29 to +30
final Future<void> Function()? onReload;
final Future<void> Function()? onRestart;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any time these won't exist/be specified? At least currently it seems they're always specified and a lot of code in _restart could be simplified if they become required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants