Silent resize cmds & Auto resize terminal #1
This commit is contained in:
19
.idea/workspace.xml
generated
19
.idea/workspace.xml
generated
@@ -4,9 +4,10 @@
|
||||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="8497df64-d86b-4c98-ac58-c157d9d3fb1e" name="Changes" comment="Terminal size fix #18 (rows & cols fix)">
|
||||
<change beforePath="$PROJECT_DIR$/.github/workflows/docker-image.yml" beforeDir="false" afterPath="$PROJECT_DIR$/.github/workflows/docker-image.yml" afterDir="false" />
|
||||
<list default="true" id="8497df64-d86b-4c98-ac58-c157d9d3fb1e" name="Changes" comment="Test ntfy build notification system">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/backend/server.js" beforeDir="false" afterPath="$PROJECT_DIR$/backend/server.js" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/frontend/src/App.jsx" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/src/App.jsx" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/info.txt" beforeDir="false" afterPath="$PROJECT_DIR$/info.txt" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
@@ -116,6 +117,7 @@
|
||||
<updated>1733439468142</updated>
|
||||
<workItem from="1733439479708" duration="5489000" />
|
||||
<workItem from="1733448523969" duration="3535000" />
|
||||
<workItem from="1733549186397" duration="3022000" />
|
||||
</task>
|
||||
<task id="LOCAL-00001" summary="Nano zoom fix #11">
|
||||
<option name="closed" value="true" />
|
||||
@@ -197,7 +199,15 @@
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1733538097802</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="11" />
|
||||
<task id="LOCAL-00011" summary="Test ntfy build notification system">
|
||||
<option name="closed" value="true" />
|
||||
<created>1733539381433</created>
|
||||
<option name="number" value="00011" />
|
||||
<option name="presentableId" value="LOCAL-00011" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1733539381433</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="12" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
@@ -233,6 +243,7 @@
|
||||
<MESSAGE value="Nano zoom fix #16 (ssh-2-promise)" />
|
||||
<MESSAGE value="Full return back to old code with minor fixes" />
|
||||
<MESSAGE value="Terminal size fix #18 (rows & cols fix)" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Terminal size fix #18 (rows & cols fix)" />
|
||||
<MESSAGE value="Test ntfy build notification system" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Test ntfy build notification system" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -50,8 +50,8 @@ wss.on('connection', (ws) => {
|
||||
}
|
||||
|
||||
// Set the terminal size dynamically based on the WebSocket message
|
||||
const sttyCommand = `export TERM=xterm && stty rows ${data.rows} cols ${data.cols}`;
|
||||
stream.write(sttyCommand + '\n'); // Send the stty command to set terminal size
|
||||
const sttyCommand = `stty -echo rows ${data.rows} cols ${data.cols}\n`;
|
||||
stream.write(sttyCommand);
|
||||
|
||||
// Handle data from SSH session
|
||||
stream.on('data', (data) => {
|
||||
@@ -66,9 +66,14 @@ wss.on('connection', (ws) => {
|
||||
});
|
||||
|
||||
// When the WebSocket client sends a message (from terminal input), forward it to the SSH stream
|
||||
ws.on('message', (message) => {
|
||||
console.log(`Received message from WebSocket: ${message}`);
|
||||
stream.write(message); // Write the message (input) to the SSH shell
|
||||
ws.on('message', (msg) => {
|
||||
const input = JSON.parse(msg);
|
||||
if (input.type === 'resize') {
|
||||
const resizeCommand = `stty rows ${input.rows} cols ${input.cols}\n`;
|
||||
stream.write(resizeCommand);
|
||||
} else {
|
||||
stream.write(input);
|
||||
}
|
||||
});
|
||||
});
|
||||
}).on('error', (err) => {
|
||||
|
||||
@@ -39,25 +39,22 @@ const App = () => {
|
||||
fitAddon.current.fit();
|
||||
|
||||
// Adjust terminal size on window resize
|
||||
const resizeListener = () => {
|
||||
const handleResize = () => {
|
||||
fitAddon.current.fit();
|
||||
};
|
||||
window.addEventListener('resize', resizeListener);
|
||||
|
||||
// Monitor terminal data (activity)
|
||||
terminal.current.onData((data) => {
|
||||
if (socket.current && socket.current.readyState === WebSocket.OPEN) {
|
||||
socket.current.send(data);
|
||||
socket.current.send(JSON.stringify({
|
||||
type: 'resize',
|
||||
rows: terminal.current.rows,
|
||||
cols: terminal.current.cols,
|
||||
}));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// Cleanup on component unmount
|
||||
window.addEventListener('resize', handleResize);
|
||||
return () => {
|
||||
terminal.current.dispose();
|
||||
if (socket.current) {
|
||||
socket.current.close();
|
||||
}
|
||||
window.removeEventListener('resize', resizeListener);
|
||||
if (socket.current) socket.current.close();
|
||||
window.removeEventListener('resize', handleResize);
|
||||
};
|
||||
}, []);
|
||||
|
||||
|
||||
3
info.txt
3
info.txt
@@ -1,7 +1,8 @@
|
||||
Currently:
|
||||
make the cmds run at start not show up
|
||||
see if it auto resizes the terminal via cmds after the browser window size has changed or +/- clicked (does not)
|
||||
ntfy notifcation after build push (I think I did)
|
||||
before release, call this version 1.0 (don't do beta and shit/come uip with naming scheme like 1.1 or just increment by 1 and when to go to next version)
|
||||
fix all the giuthub workflow problems
|
||||
|
||||
Overall Features:
|
||||
SSH/RDP(?)/VNC(?)
|
||||
|
||||
Reference in New Issue
Block a user