Skip to content

Commit 590257d

Browse files
committed
Fix nodepty process resize bug for powershell
1 parent 34eb0bb commit 590257d

File tree

15 files changed

+138
-112
lines changed

15 files changed

+138
-112
lines changed

.changeset/crisp-impalas-search.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@pulse-editor/shared-utils": patch
3+
"@pulse-editor/react-api": patch
4+
---
5+
6+
Revert debug information

.changeset/pre.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"clean-mangos-swim",
2323
"cold-shrimps-give",
2424
"crazy-cities-stand",
25+
"crisp-impalas-search",
2526
"cruel-waves-double",
2627
"cruel-zoos-play",
2728
"curvy-places-wash",

desktop/lib/node-pty-server.js

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import http from "http";
2-
import { WebSocketServer } from "ws";
3-
import os from "os";
42
import pty from "node-pty";
3+
import os from "os";
4+
import { WebSocketServer } from "ws";
55

66
let sharedPtyProcess = null;
77
let sharedTerminalMode = false;
@@ -25,14 +25,20 @@ const setSharedTerminalMode = (useSharedTerminal) => {
2525
const handleTerminalConnection = (ws) => {
2626
let ptyProcess = sharedTerminalMode ? sharedPtyProcess : spawnShell();
2727

28-
ws.on("message", (command) => {
29-
const processedCommand = commandProcessor(command);
30-
ptyProcess.write(processedCommand);
28+
ws.on("message", (data) => {
29+
const dataObj = JSON.parse(data);
30+
31+
if (dataObj.type === "input") {
32+
const command = dataObj.payload;
33+
ptyProcess.write(command);
34+
} else if (dataObj.type === "resize") {
35+
const { cols, rows } = dataObj.payload;
36+
ptyProcess.resize(cols, rows);
37+
}
3138
});
3239

3340
ptyProcess.on("data", (rawOutput) => {
34-
const processedOutput = outputProcessor(rawOutput);
35-
ws.send(processedOutput);
41+
ws.send(JSON.stringify({ type: "output", payload: rawOutput }));
3642
});
3743

3844
ws.on("close", () => {
@@ -42,16 +48,6 @@ const handleTerminalConnection = (ws) => {
4248
});
4349
};
4450

45-
// Utility function to process commands
46-
const commandProcessor = (command) => {
47-
return command;
48-
};
49-
50-
// Utility function to process output
51-
const outputProcessor = (output) => {
52-
return output;
53-
};
54-
5551
/* Host ws node-pty server */
5652
setSharedTerminalMode(false); // Set this to false to allow a shared session
5753
const port = 6060;

npm-packages/react-api/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# @pulse-editor/react-api
22

3+
## 0.1.1-alpha.50
4+
5+
### Patch Changes
6+
7+
- Revert debug information
8+
- Updated dependencies
9+
- @pulse-editor/shared-utils@0.1.1-alpha.50
10+
311
## 0.1.1-alpha.49
412

513
### Patch Changes

npm-packages/react-api/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pulse-editor/react-api",
3-
"version": "0.1.1-alpha.49",
3+
"version": "0.1.1-alpha.50",
44
"main": "dist/main.js",
55
"files": [
66
"dist"
@@ -38,7 +38,7 @@
3838
"typescript-eslint": "^8.30.1"
3939
},
4040
"peerDependencies": {
41-
"@pulse-editor/shared-utils": "0.1.1-alpha.49",
41+
"@pulse-editor/shared-utils": "0.1.1-alpha.50",
4242
"react": "^19.0.0",
4343
"react-dom": "^19.0.0"
4444
}

npm-packages/shared-utils/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @pulse-editor/shared-utils
22

3+
## 0.1.1-alpha.50
4+
5+
### Patch Changes
6+
7+
- Revert debug information
8+
39
## 0.1.1-alpha.49
410

511
### Patch Changes

npm-packages/shared-utils/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pulse-editor/shared-utils",
3-
"version": "0.1.1-alpha.49",
3+
"version": "0.1.1-alpha.50",
44
"main": "dist/main.js",
55
"files": [
66
"dist"

npm-packages/shared-utils/src/imc/inter-module-communication.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ export class InterModuleCommunication {
7676
const message = event.data;
7777
if (message.from !== undefined) {
7878
console.log(
79-
`Module ${this.thisWindowId} received message from module ${message.from}:\n ${message}`
79+
`Module ${this.thisWindowId} received message from module ${
80+
message.from
81+
}:\n ${JSON.stringify(message)}`
8082
);
8183
}
8284

package-lock.json

Lines changed: 4 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

remote-instance/src/servers/node-pty/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import http from "http";
22
import https from "https";
3-
import { WebSocket, WebSocketServer } from "ws";
4-
import os from "os";
53
import { IPty, spawn } from "node-pty";
4+
import os from "os";
5+
import { WebSocket, WebSocketServer } from "ws";
66

77
let sharedPtyProcess: IPty | null = null;
88
let sharedTerminalMode = false;

0 commit comments

Comments
 (0)