mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Stop TUI chats on misalignment policy violations (#39261)
## Why When the app server reports a misalignment policy violation, the TUI must stop the affected chat rather than allow more work to continue in it. ## What changed - Finalize the active turn, clear queued and draft input, disable the composer, and reject further operations and interactive requests for the stopped chat. - Interrupt an active side conversation when its parent reports the violation, and prevent queued turns, forks, approvals, or goal resumption from restarting work. - Show a non-dismissible precaution view that directs users to start a new chat or resume another one, with agent command center navigation for remote sessions. ## Testing Added coverage for stopped-chat behavior, parent/side-thread handling, blocked goal resumption, navigation actions, and narrow and remote-session rendering. GitOrigin-RevId: 0268c46a19294a17765ea4099f389f15ffaaf030
This commit is contained in:
1 parent
3006151ad4
commit
785ecd7452
16 files changed
+452
-3
No files matched your search
@@ -346,6 +346,10 @@ impl App {
|
||||
}
|
||||
|
||||
pub(super) fn push_thread_interactive_request(&mut self, request: ThreadInteractiveRequest) {
|
||||
if self.chat_widget.has_misalignment_policy_violation() {
|
||||
return;
|
||||
}
|
||||
|
||||
match request {
|
||||
ThreadInteractiveRequest::AppLink(params) => {
|
||||
self.chat_widget.open_app_link_view(params);
|
||||
@@ -444,6 +448,10 @@ impl App {
|
||||
thread_id: ThreadId,
|
||||
op: AppCommand,
|
||||
) -> Result<()> {
|
||||
if self.chat_widget.rejects_misalignment_policy_op(&op) {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
crate::session_log::log_outbound_op(&op);
|
||||
|
||||
if self
|
||||
@@ -960,6 +968,24 @@ impl App {
|
||||
if self.abandoned_side_threads.contains(&thread_id) {
|
||||
return Ok(());
|
||||
}
|
||||
let misalignment_policy_violation =
|
||||
match ¬ification {
|
||||
ServerNotification::Error(notification) if !notification.will_retry => {
|
||||
notification.error.codex_error_info.as_ref()
|
||||
}
|
||||
ServerNotification::TurnCompleted(notification) => notification
|
||||
.turn
|
||||
.error
|
||||
.as_ref()
|
||||
.and_then(|error| error.codex_error_info.as_ref()),
|
||||
_ => None,
|
||||
} == Some(&AppServerCodexErrorInfo::MisalignmentPolicyViolation);
|
||||
if misalignment_policy_violation && self.active_side_parent_thread_id() == Some(thread_id) {
|
||||
if self.chat_widget.is_user_turn_pending_or_running() {
|
||||
self.chat_widget.submit_op(AppCommand::Interrupt);
|
||||
}
|
||||
self.chat_widget.on_misalignment_policy_violation();
|
||||
}
|
||||
if matches!(
|
||||
notification,
|
||||
ServerNotification::ThreadSettingsUpdated(_) | ServerNotification::ThreadArchived(_)
|
||||
|
||||
Reference in new issue
Block a user