fix: Resolve runtime panic when initializing browser manager

- Fix 'Cannot start runtime from within runtime' panic
- Revert to creating browser manager directly in TUI
- Browser manager sync between TUI and core still pending

The application no longer crashes on startup. The dual browser instance
issue remains but can be addressed separately.
This commit is contained in:
James Peter
2025-08-12 14:49:43 +10:00
parent b8f6bcbf73
commit 756e4eaf43
+6 -5
View File
@@ -60,7 +60,7 @@ use crate::history_cell::PatchEventType;
use crate::live_wrap::RowBuilder;
use crate::text_block::TextBlock;
use crate::user_approval_widget::ApprovalRequest;
use codex_browser::BrowserManager;
use codex_browser::{BrowserManager, config::BrowserConfig};
use codex_file_search::FileMatch;
use ratatui::style::Stylize;
@@ -374,10 +374,11 @@ impl ChatWidget<'_> {
}
});
// Use the global browser manager singleton to ensure consistency
// between TUI and core session
let browser_manager = tokio::runtime::Handle::current()
.block_on(codex_browser::global::get_or_create_browser_manager());
// Initialize browser manager - will be synced with core session later
// We can't use the global async function here because we're in a sync context
// The core session will use the same global manager when browser tools are invoked
let browser_config = codex_browser::config::BrowserConfig::default();
let browser_manager = Arc::new(BrowserManager::new(browser_config));
// Add initial animated welcome message to history
let mut history_cells = Vec::new();