fix(app): terminal no longer hangs on exit or ctrl + D and closes the pane (#9506)
This commit is contained in:
@@ -38,6 +38,21 @@ function createTerminalSession(sdk: ReturnType<typeof useSDK>, dir: string, sess
|
|||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
sdk.event.on("pty.exited", (event) => {
|
||||||
|
const id = event.properties.id
|
||||||
|
if (!store.all.some((x) => x.id === id)) return
|
||||||
|
batch(() => {
|
||||||
|
setStore(
|
||||||
|
"all",
|
||||||
|
store.all.filter((x) => x.id !== id),
|
||||||
|
)
|
||||||
|
if (store.active === id) {
|
||||||
|
const remaining = store.all.filter((x) => x.id !== id)
|
||||||
|
setStore("active", remaining[0]?.id)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
ready,
|
ready,
|
||||||
all: createMemo(() => Object.values(store.all)),
|
all: createMemo(() => Object.values(store.all)),
|
||||||
|
|||||||
@@ -385,6 +385,19 @@ export default function Page() {
|
|||||||
terminal.new()
|
terminal.new()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
createEffect(
|
||||||
|
on(
|
||||||
|
() => terminal.all().length,
|
||||||
|
(count, prevCount) => {
|
||||||
|
if (prevCount !== undefined && prevCount > 0 && count === 0) {
|
||||||
|
if (view().terminal.opened()) {
|
||||||
|
view().terminal.toggle()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
createEffect(
|
createEffect(
|
||||||
on(
|
on(
|
||||||
() => visibleUserMessages().at(-1)?.id,
|
() => visibleUserMessages().at(-1)?.id,
|
||||||
|
|||||||
@@ -147,6 +147,9 @@ export namespace Pty {
|
|||||||
log.info("session exited", { id, exitCode })
|
log.info("session exited", { id, exitCode })
|
||||||
session.info.status = "exited"
|
session.info.status = "exited"
|
||||||
Bus.publish(Event.Exited, { id, exitCode })
|
Bus.publish(Event.Exited, { id, exitCode })
|
||||||
|
for (const ws of session.subscribers) {
|
||||||
|
ws.close()
|
||||||
|
}
|
||||||
state().delete(id)
|
state().delete(id)
|
||||||
})
|
})
|
||||||
Bus.publish(Event.Created, { info })
|
Bus.publish(Event.Created, { info })
|
||||||
|
|||||||
Reference in New Issue
Block a user