Repository navigation
Fix TUI shells remaining open after exit #9003
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
9deb085
78361d5
513b0c1
7f37ecb
45ed2c7
01f8275
88ec011
29b0030
83d9c10
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| package com.cmux; | ||
|
|
||
| public record SurfaceEvent(String event, long surface) implements CmuxEvent {} | ||
| public record SurfaceEvent(String event, long surface, Long runtimeMs) implements CmuxEvent {} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -202,8 +202,13 @@ pub enum MuxEvent { | |
| }, | ||
| /// A surface's child exited. Hosted terminals remain in the tree as an | ||
| /// addressable Exited tab until an explicit close tombstones them; local | ||
| /// terminals have already been reaped when this arrives. | ||
| SurfaceExited(SurfaceId), | ||
| /// terminals have already been reaped when this arrives. `runtime_ms` is | ||
| /// present for hosted terminals and lets frontends match Ghostty's normal- | ||
| /// exit versus startup-failure policy. | ||
| SurfaceExited { | ||
| surface: SurfaceId, | ||
| runtime_ms: Option<u64>, | ||
| }, | ||
| TitleChanged { | ||
| surface: SurfaceId, | ||
| title: Arc<str>, | ||
|
|
@@ -3882,7 +3887,7 @@ impl Mux { | |
| old_surface.and_then(|id| self.state.lock().unwrap().surfaces.remove(&id)) | ||
| { | ||
| surface.kill(); | ||
| self.emit(MuxEvent::SurfaceExited(surface.id)); | ||
| self.emit(MuxEvent::SurfaceExited { surface: surface.id, runtime_ms: None }); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -6396,8 +6401,12 @@ impl Mux { | |
| /// terminals remain stable, renderable Exited tabs until an explicit | ||
| /// close; local surfaces are removed immediately. | ||
| pub fn surface_exited(&self, id: SurfaceId) { | ||
| self.surface_exited_with_runtime(id, None); | ||
| } | ||
|
|
||
| pub(crate) fn surface_exited_with_runtime(&self, id: SurfaceId, runtime_ms: Option<u64>) { | ||
| if self.sidebar_surface_exited(id) { | ||
| self.emit(MuxEvent::SurfaceExited(id)); | ||
| self.emit(MuxEvent::SurfaceExited { surface: id, runtime_ms: None }); | ||
| return; | ||
| } | ||
| if let Some(surface) = self.surface(id) | ||
|
|
@@ -6410,11 +6419,16 @@ impl Mux { | |
| return; | ||
| } | ||
| self.emit(MuxEvent::TreeChanged); | ||
| self.emit(MuxEvent::SurfaceExited(id)); | ||
| self.emit(MuxEvent::SurfaceExited { | ||
| surface: id, | ||
| // Hosts predating runtime metadata still represent a process | ||
| // that reached the live stream, not a local/browser reap. | ||
| runtime_ms: Some(runtime_ms.unwrap_or(u64::MAX)), | ||
| }); | ||
| return; | ||
| } | ||
| self.remove_surface_after_registry(id); | ||
| self.emit(MuxEvent::SurfaceExited(id)); | ||
| self.emit(MuxEvent::SurfaceExited { surface: id, runtime_ms: None }); | ||
|
Comment on lines
+6422
to
+6431
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value Consider naming the Hosts predating runtime metadata still represent a process that reached the live stream, not a local/browser reap. The logic is correct, but the bare 🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| fn mark_hosted_surface_exited( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The server and Rust binding add
runtime_ms, but the Go, Python, TypeScript, and Java typedsurface-exitedmodels and conformance fixtures remain unchanged. Those consumers silently lose the metadata and cannot implement the documented established-shell versus startup-failure policy without bypassing their typed APIs.Knowledge Base Used: cmux-tui
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 78361d5. runtime_ms now exists in the canonical spec and Rust, Go, Python, TypeScript, and Java event models, with parser/type coverage in every binding.