Skip to content

Commit 2f33038

Browse files
author
Akos Kitta
committed
No disconnect/reconnect when DNDing the widget.
- Updated to next Theia, - Added elecron launch config, - Yet another syling for the input + selects, - Close monitor connection on widget close not detach. Signed-off-by: Akos Kitta <kittaakos@typefox.io>
1 parent 6154d1e commit 2f33038

File tree

7 files changed

+932
-508
lines changed

7 files changed

+932
-508
lines changed

.vscode/launch.json

+37-5
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,39 @@
77
{
88
"type": "node",
99
"request": "launch",
10-
"name": "Launch Electron Packager",
11-
"program": "${workspaceRoot}/electron/packager/index.js",
12-
"cwd": "${workspaceFolder}/electron/packager"
10+
"name": "App (Electron)",
11+
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron",
12+
"windows": {
13+
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd"
14+
},
15+
"program": "${workspaceRoot}/electron-app/src-gen/frontend/electron-main.js",
16+
"protocol": "inspector",
17+
"args": [
18+
"--log-level=debug",
19+
"--hostname=localhost",
20+
"--no-cluster",
21+
"--remote-debugging-port=9222",
22+
"--no-app-auto-install",
23+
"--debug-cli=true"
24+
],
25+
"env": {
26+
"NODE_ENV": "development"
27+
},
28+
"sourceMaps": true,
29+
"outFiles": [
30+
"${workspaceRoot}/electron-app/src-gen/backend/*.js",
31+
"${workspaceRoot}/electron-app/src-gen/frontend/*.js",
32+
"${workspaceRoot}/electron-app/lib/**/*.js",
33+
"${workspaceRoot}/arduino-ide-extension/*/lib/**/*.js"
34+
],
35+
"smartStep": true,
36+
"internalConsoleOptions": "openOnSessionStart",
37+
"outputCapture": "std"
1338
},
1439
{
1540
"type": "node",
1641
"request": "launch",
17-
"name": "Launch Backend",
42+
"name": "App (Browser)",
1843
"program": "${workspaceRoot}/browser-app/src-gen/backend/main.js",
1944
"args": [
2045
"--hostname=0.0.0.0",
@@ -38,7 +63,7 @@
3863
{
3964
"type": "node",
4065
"request": "launch",
41-
"name": "Launch Backend (Debug CLI daemon)",
66+
"name": "App (Browser - Debug CLI daemon)",
4267
"program": "${workspaceRoot}/browser-app/src-gen/backend/main.js",
4368
"args": [
4469
"--hostname=0.0.0.0",
@@ -59,6 +84,13 @@
5984
"smartStep": true,
6085
"internalConsoleOptions": "openOnSessionStart",
6186
"outputCapture": "std"
87+
},
88+
{
89+
"type": "node",
90+
"request": "launch",
91+
"name": "Packager",
92+
"program": "${workspaceRoot}/electron/packager/index.js",
93+
"cwd": "${workspaceFolder}/electron/packager"
6294
}
6395
]
6496
}

arduino-ide-extension/src/browser/monitor/monitor-model.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,15 @@ export class MonitorModel implements FrontendApplicationContribution {
7878
this.storeState().then(() => this.onChangeEmitter.fire({ property: 'lineEnding', value: this._lineEnding }));
7979
}
8080

81-
protected restoreState(state: MonitorModel.State) {
81+
protected restoreState(state: MonitorModel.State): void {
8282
this._autoscroll = state.autoscroll;
8383
this._timestamp = state.timestamp;
8484
this._baudRate = state.baudRate;
8585
this._lineEnding = state.lineEnding;
8686
}
8787

8888
protected async storeState(): Promise<void> {
89-
this.localStorageService.setData(MonitorModel.STORAGE_ID, {
89+
return this.localStorageService.setData(MonitorModel.STORAGE_ID, {
9090
autoscroll: this._autoscroll,
9191
timestamp: this._timestamp,
9292
baudRate: this._baudRate,

arduino-ide-extension/src/browser/monitor/monitor-widget.tsx

+10-2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export class MonitorWidget extends ReactWidget {
4141
this.id = MonitorWidget.ID;
4242
this.title.label = 'Serial Monitor';
4343
this.title.iconClass = 'arduino-serial-monitor-tab-icon';
44+
this.title.closable = true;
4445
this.scrollOptions = undefined;
4546
this.toDispose.push(this.clearOutputEmitter);
4647
}
@@ -56,14 +57,21 @@ export class MonitorWidget extends ReactWidget {
5657
this.update();
5758
}
5859

60+
dispose(): void {
61+
super.dispose();
62+
}
63+
5964
protected onAfterAttach(msg: Message): void {
6065
super.onAfterAttach(msg);
6166
this.monitorConnection.autoConnect = true;
6267
}
6368

64-
protected onBeforeDetach(msg: Message): void {
65-
super.onBeforeDetach(msg);
69+
onCloseRequest(msg: Message): void {
6670
this.monitorConnection.autoConnect = false;
71+
if (this.monitorConnection.connected) {
72+
this.monitorConnection.disconnect();
73+
}
74+
super.onCloseRequest(msg);
6775
}
6876

6977
protected onResize(msg: Widget.ResizeMessage): void {

arduino-ide-extension/src/browser/style/monitor.css

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
.serial-monitor .head .send {
2222
display: flex;
2323
flex: 1;
24-
margin-right: 5px;
24+
margin-right: 2px;
2525
}
2626

2727
.serial-monitor .head .send > input {
@@ -42,7 +42,7 @@
4242
}
4343

4444
.serial-monitor .head .config .select {
45-
margin-left: 5px;
45+
margin-left: 3px;
4646
}
4747

4848
.serial-monitor .body {

arduino-ide-extension/src/node/boards-service-impl.ts

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as PQueue from 'p-queue';
22
import { injectable, inject, postConstruct, named } from 'inversify';
33
import { ILogger } from '@theia/core/lib/common/logger';
4+
import { Deferred } from '@theia/core/lib/common/promise-util';
45
import { BoardsService, AttachedSerialBoard, BoardPackage, Board, AttachedNetworkBoard, BoardsServiceClient, Port } from '../common/protocol/boards-service';
56
import {
67
PlatformSearchReq,
@@ -43,6 +44,7 @@ export class BoardsServiceImpl implements BoardsService {
4344
*/
4445
protected attachedBoards: { boards: Board[] } = { boards: [] };
4546
protected availablePorts: { ports: Port[] } = { ports: [] };
47+
protected started = new Deferred<void>();
4648
protected client: BoardsServiceClient | undefined;
4749
protected readonly queue = new PQueue({ autoStart: true, concurrency: 1 });
4850

@@ -74,6 +76,7 @@ export class BoardsServiceImpl implements BoardsService {
7476
if (!this.discoveryInitialized) {
7577
update([], sortedBoards, [], sortedPorts, 'Initialized attached boards and available ports.');
7678
this.discoveryInitialized = true;
79+
this.started.resolve();
7780
} else {
7881
Promise.all([
7982
this.getAttachedBoards(),
@@ -120,10 +123,12 @@ export class BoardsServiceImpl implements BoardsService {
120123
}
121124

122125
async getAttachedBoards(): Promise<{ boards: Board[] }> {
126+
await this.started.promise;
123127
return this.attachedBoards;
124128
}
125129

126130
async getAvailablePorts(): Promise<{ ports: Port[] }> {
131+
await this.started.promise;
127132
return this.availablePorts;
128133
}
129134

arduino-ide-extension/src/node/monitor/monitor-service-impl.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export class MonitorServiceImpl implements MonitorService {
7171

7272
duplex.on('error', ((error: Error) => {
7373
const monitorError = ErrorWithCode.toMonitorError(error, config);
74-
this.disconnect().then(() => {
74+
this.disconnect(monitorError).then(() => {
7575
if (this.client) {
7676
this.client.notifyError(monitorError);
7777
}
@@ -112,7 +112,10 @@ export class MonitorServiceImpl implements MonitorService {
112112
});
113113
}
114114

115-
async disconnect(): Promise<Status> {
115+
async disconnect(reason?: MonitorError): Promise<Status> {
116+
if (!this.connection && reason && reason.code === MonitorError.ErrorCodes.CLIENT_CANCEL) {
117+
return Status.OK;
118+
}
116119
this.logger.info(`>>> Disposing monitor connection...`);
117120
if (!this.connection) {
118121
this.logger.warn(`<<< Not connected. Nothing to dispose.`);

0 commit comments

Comments
 (0)