mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Add app-server background terminal process APIs (#26041)
## Summary Codex Apps needs app-server as the source of truth for chat-started background terminals instead of guessing from local process trees. This PR adds experimental v2 APIs to list and terminate background terminals for a loaded thread using app-server process ids, so clients can manage background terminals without local PID discovery. ## Changes - `thread/backgroundTerminals/list` returns paginated background terminal records with `itemId`, app-server `processId`, `command`, `cwd`, nullable `osPid`, nullable `cpuPercent`, and nullable `rssKb`. - `thread/backgroundTerminals/terminate` terminates one running background terminal by app-server `processId` and returns whether a process was terminated. - Background terminal list and terminate operations use unified-exec process manager state as their source of truth.
This commit is contained in:
1 parent
2704ecea9a
commit
a1a8807e9d
16 files changed
+773
-36
No files matched your search
@@ -195,9 +195,16 @@ impl UnifiedExecProcess {
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn terminate(&self) {
|
||||
fn finish_termination(&self) {
|
||||
self.output_closed.store(true, Ordering::Release);
|
||||
self.output_closed_notify.notify_waiters();
|
||||
self.cancellation_token.cancel();
|
||||
if let Some(output_task) = &self.output_task {
|
||||
output_task.abort();
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn terminate(&self) {
|
||||
match &self.process_handle {
|
||||
ProcessHandle::Local(process_handle) => process_handle.terminate(),
|
||||
ProcessHandle::ExecServer(process_handle) => {
|
||||
@@ -207,10 +214,22 @@ impl UnifiedExecProcess {
|
||||
});
|
||||
}
|
||||
}
|
||||
self.cancellation_token.cancel();
|
||||
if let Some(output_task) = &self.output_task {
|
||||
output_task.abort();
|
||||
self.finish_termination();
|
||||
}
|
||||
|
||||
pub(super) async fn terminate_confirmed(&self) -> Result<(), UnifiedExecError> {
|
||||
match &self.process_handle {
|
||||
ProcessHandle::Local(process_handle) => process_handle.terminate(),
|
||||
ProcessHandle::ExecServer(process_handle) => {
|
||||
process_handle
|
||||
.terminate()
|
||||
.await
|
||||
.map_err(|err| UnifiedExecError::process_failed(err.to_string()))?;
|
||||
}
|
||||
}
|
||||
self.signal_exit(self.exit_code());
|
||||
self.finish_termination();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) async fn interrupt(&self) -> Result<(), UnifiedExecError> {
|
||||
|
||||
Reference in new issue
Block a user