fix: auto-close terminal tab/window when shell exits (#15448)

This commit is contained in:
alonginwind
2026-07-02 16:43:27 +08:00
committed by GitHub
parent dce221be5a
commit a2b79462ab
4 changed files with 48 additions and 3 deletions

View File

@@ -95,6 +95,13 @@ class _TerminalPageState extends State<TerminalPage>
// Register this terminal model with FFI for event routing
_ffi.registerTerminalModel(widget.terminalId, _terminalModel);
// Auto-close tab when shell exits
_terminalModel.onClosed = () {
if (mounted) {
widget.tabController.closeBy(widget.tabKey);
}
};
// Initialize terminal connection
WidgetsBinding.instance.addPostFrameCallback((_) {
widget.tabController.onSelected?.call(widget.id);