TUI: enforce core boundary (#17399)

Problem: The TUI still depended on `codex-core` directly in a number of
places, and we had no enforcement from keeping this problem from getting
worse.

Solution: Route TUI core access through
`codex-app-server-client::legacy_core`, add CI enforcement for that
boundary, and re-export this legacy bridge inside the TUI as
`crate::legacy_core` so the remaining call sites stay readable. There is
no functional change in this PR — just changes to import targets.

Over time, we can whittle away at the remaining symbols in this legacy
namespace with the eventual goal of removing them all. In the meantime,
this linter rule will prevent us from inadvertently importing new
symbols from core.
This commit is contained in:
Eric Traut authored and GitHub committed 2026-04-10 20:25:31 -07:00
1 parent 37aac89a6d
commit 66e13efd9c
35 files changed
+414 -225

No files matched your search

+35 -30
View File
@@ -52,6 +52,16 @@ use crate::bottom_pane::StatusLinePreviewData;
use crate::bottom_pane::StatusLineSetupView;
use crate::bottom_pane::TerminalTitleItem;
use crate::bottom_pane::TerminalTitleSetupView;
use crate::legacy_core::DEFAULT_PROJECT_DOC_FILENAME;
use crate::legacy_core::config::Config;
use crate::legacy_core::config::Constrained;
use crate::legacy_core::config::ConstraintResult;
use crate::legacy_core::config_loader::ConfigLayerStackOrdering;
use crate::legacy_core::find_thread_name_by_id;
use crate::legacy_core::plugins::PluginsManager;
use crate::legacy_core::skills::model::SkillMetadata;
#[cfg(target_os = "windows")]
use crate::legacy_core::windows_sandbox::WindowsSandboxLevelExt;
use crate::mention_codec::LinkedMention;
use crate::mention_codec::encode_history_mentions;
use crate::model_catalog::ModelCatalog;
@@ -95,16 +105,6 @@ use codex_chatgpt::connectors;
use codex_config::types::ApprovalsReviewer;
use codex_config::types::Notifications;
use codex_config::types::WindowsSandboxModeToml;
use codex_core::DEFAULT_PROJECT_DOC_FILENAME;
use codex_core::config::Config;
use codex_core::config::Constrained;
use codex_core::config::ConstraintResult;
use codex_core::config_loader::ConfigLayerStackOrdering;
use codex_core::find_thread_name_by_id;
use codex_core::plugins::PluginsManager;
use codex_core::skills::model::SkillMetadata;
#[cfg(target_os = "windows")]
use codex_core::windows_sandbox::WindowsSandboxLevelExt;
use codex_features::FEATURES;
use codex_features::Feature;
#[cfg(test)]
@@ -4893,7 +4893,7 @@ impl ChatWidget {
.set_queued_message_edit_binding(widget.queued_message_edit_binding);
#[cfg(target_os = "windows")]
widget.bottom_pane.set_windows_degraded_sandbox_active(
codex_core::windows_sandbox::ELEVATED_SANDBOX_NUX_ENABLED
crate::legacy_core::windows_sandbox::ELEVATED_SANDBOX_NUX_ENABLED
&& matches!(
WindowsSandboxLevel::from_config(&widget.config),
WindowsSandboxLevel::RestrictedToken
@@ -5330,7 +5330,7 @@ impl ChatWidget {
let windows_degraded_sandbox_enabled =
matches!(windows_sandbox_level, WindowsSandboxLevel::RestrictedToken);
if !windows_degraded_sandbox_enabled
|| !codex_core::windows_sandbox::ELEVATED_SANDBOX_NUX_ENABLED
|| !crate::legacy_core::windows_sandbox::ELEVATED_SANDBOX_NUX_ENABLED
{
// This command should not be visible/recognized outside degraded mode,
// but guard anyway in case something dispatches it directly.
@@ -5573,7 +5573,8 @@ impl ChatWidget {
else {
return;
};
let Some(name) = codex_core::util::normalize_thread_name(&prepared_args) else {
let Some(name) = crate::legacy_core::util::normalize_thread_name(&prepared_args)
else {
self.add_error_message("Thread name cannot be empty.".to_string());
return;
};
@@ -5670,7 +5671,7 @@ impl ChatWidget {
"Type a name and press Enter".to_string(),
/*context_label*/ None,
Box::new(move |name: String| {
let Some(name) = codex_core::util::normalize_thread_name(&name) else {
let Some(name) = crate::legacy_core::util::normalize_thread_name(&name) else {
tx.send(AppEvent::InsertHistoryCell(Box::new(
history_cell::new_error_event("Thread name cannot be empty.".to_string()),
)));
@@ -5904,7 +5905,7 @@ impl ChatWidget {
let app_mentions = find_app_mentions(&mentions, apps, &skill_names_lower);
for app in app_mentions {
let slug = codex_core::connectors::connector_mention_slug(&app);
let slug = crate::legacy_core::connectors::connector_mention_slug(&app);
if bound_names.contains(&slug) || !selected_app_ids.insert(app.id.clone()) {
continue;
}
@@ -7340,16 +7341,17 @@ impl ChatWidget {
#[cfg(test)]
fn on_entered_review_mode(&mut self, review: ReviewRequest, from_replay: bool) {
let hint = review
.user_facing_hint
.unwrap_or_else(|| codex_core::review_prompts::user_facing_hint(&review.target));
let hint = review.user_facing_hint.unwrap_or_else(|| {
crate::legacy_core::review_prompts::user_facing_hint(&review.target)
});
self.enter_review_mode_with_hint(hint, from_replay);
}
#[cfg(test)]
fn on_exited_review_mode(&mut self, review: ExitedReviewModeEvent) {
if let Some(output) = review.review_output {
let review_markdown = codex_core::review_format::render_review_output_text(&output);
let review_markdown =
crate::legacy_core::review_format::render_review_output_text(&output);
self.record_agent_markdown(&review_markdown);
self.flush_answer_stream_with_separator();
self.flush_interrupt_queue();
@@ -7623,7 +7625,7 @@ impl ChatWidget {
}
fn open_theme_picker(&mut self) {
let codex_home = codex_core::config::find_codex_home().ok();
let codex_home = crate::legacy_core::config::find_codex_home().ok();
let terminal_width = self
.last_rendered_width
.get()
@@ -8741,9 +8743,10 @@ impl ChatWidget {
#[cfg(not(target_os = "windows"))]
let windows_degraded_sandbox_enabled = false;
let show_elevate_sandbox_hint = codex_core::windows_sandbox::ELEVATED_SANDBOX_NUX_ENABLED
&& windows_degraded_sandbox_enabled
&& presets.iter().any(|preset| preset.id == "auto");
let show_elevate_sandbox_hint =
crate::legacy_core::windows_sandbox::ELEVATED_SANDBOX_NUX_ENABLED
&& windows_degraded_sandbox_enabled
&& presets.iter().any(|preset| preset.id == "auto");
let guardian_disabled_reason = |enabled: bool| {
let mut next_features = self.config.features.get().clone();
@@ -8799,8 +8802,8 @@ impl ChatWidget {
== WindowsSandboxLevel::Disabled
{
let preset_clone = preset.clone();
if codex_core::windows_sandbox::ELEVATED_SANDBOX_NUX_ENABLED
&& codex_core::windows_sandbox::sandbox_setup_is_complete(
if crate::legacy_core::windows_sandbox::ELEVATED_SANDBOX_NUX_ENABLED
&& crate::legacy_core::windows_sandbox::sandbox_setup_is_complete(
self.config.codex_home.as_path(),
)
{
@@ -9256,7 +9259,7 @@ impl ChatWidget {
pub(crate) fn open_windows_sandbox_enable_prompt(&mut self, preset: ApprovalPreset) {
use ratatui_macros::line;
if !codex_core::windows_sandbox::ELEVATED_SANDBOX_NUX_ENABLED {
if !crate::legacy_core::windows_sandbox::ELEVATED_SANDBOX_NUX_ENABLED {
// Legacy flow (pre-NUX): explain the experimental sandbox and let the user enable it
// directly (no elevation prompts).
let mut header = ColumnRenderable::new();
@@ -9542,7 +9545,7 @@ impl ChatWidget {
self.config.permissions.windows_sandbox_mode = mode;
#[cfg(target_os = "windows")]
self.bottom_pane.set_windows_degraded_sandbox_active(
codex_core::windows_sandbox::ELEVATED_SANDBOX_NUX_ENABLED
crate::legacy_core::windows_sandbox::ELEVATED_SANDBOX_NUX_ENABLED
&& matches!(
WindowsSandboxLevel::from_config(&self.config),
WindowsSandboxLevel::RestrictedToken
@@ -9593,7 +9596,7 @@ impl ChatWidget {
Feature::WindowsSandbox | Feature::WindowsSandboxElevated
) {
self.bottom_pane.set_windows_degraded_sandbox_active(
codex_core::windows_sandbox::ELEVATED_SANDBOX_NUX_ENABLED
crate::legacy_core::windows_sandbox::ELEVATED_SANDBOX_NUX_ENABLED
&& matches!(
WindowsSandboxLevel::from_config(&self.config),
WindowsSandboxLevel::RestrictedToken
@@ -10095,7 +10098,9 @@ impl ChatWidget {
}
}
fn plugins_for_mentions(&self) -> Option<&[codex_core::plugins::PluginCapabilitySummary]> {
fn plugins_for_mentions(
&self,
) -> Option<&[crate::legacy_core::plugins::PluginCapabilitySummary]> {
if !self.config.features.enabled(Feature::Plugins) {
return None;
}
@@ -10165,7 +10170,7 @@ impl ChatWidget {
}
fn rename_confirmation_cell(name: &str, thread_id: Option<ThreadId>) -> PlainHistoryCell {
let resume_cmd = codex_core::util::resume_command(Some(name), thread_id)
let resume_cmd = crate::legacy_core::util::resume_command(Some(name), thread_id)
.unwrap_or_else(|| format!("codex resume {name}"));
let name = name.to_string();
let line = vec![