mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2025-01-03 15:06:01 +03:00
🔨 Refactor terminal route and connection logic
- Improved terminal experience by handling 'Close' messages and reloading the page - Added logic to send a Close message to the websocket when EOF is reached - Changed the `terminal` function to a reactive declaration and added a `setupTerminal` function call
This commit is contained in:
parent
f7a447ef61
commit
5d7064a6a1
@ -115,6 +115,16 @@ pub async fn accept_connection(
|
||||
Ok(0) => {
|
||||
// EOF
|
||||
log::info!("0 bytes read from pty. EOF.");
|
||||
if let Err(e) = ws_sender
|
||||
.send(tokio_tungstenite::tungstenite::Message::Close(None))
|
||||
.await
|
||||
{
|
||||
log::error!(
|
||||
"{}: error sending data to websocket: {:#}",
|
||||
shared_project_id,
|
||||
e
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
Ok(n) => {
|
||||
|
@ -17,7 +17,7 @@
|
||||
const handleTerminalResize = debounce(() => term?.resize(), 5);
|
||||
const runCommand = (command: string) => term?.run(command);
|
||||
|
||||
const terminal = (target: HTMLElement, params: { project: Project }) => {
|
||||
$: terminal = (target: HTMLElement, params: { project: Project }) => {
|
||||
let setupPromise = setupTerminal(params);
|
||||
setupPromise.then((terminal) => (term = terminal));
|
||||
setupPromise.then((terminal) => terminal.bind(target));
|
||||
|
@ -81,7 +81,10 @@ const newSession = async (params: { project: Project }) => {
|
||||
});
|
||||
|
||||
conn.addListener((message) => {
|
||||
message.type === 'Close' && term.dispose();
|
||||
if (message.type === 'Close') {
|
||||
term.dispose();
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
|
Loading…
Reference in New Issue
Block a user