()
| 122 | |
| 123 | impl AppContext { |
| 124 | pub fn new() -> Self { |
| 125 | let ui_kv = UiKv::load(); |
| 126 | let default_theme_name = format!("opencode@{}", detect_terminal_theme_mode()); |
| 127 | let default_theme = Theme::by_name(&default_theme_name).unwrap_or_else(Theme::dark); |
| 128 | Self { |
| 129 | theme: RwLock::new(default_theme), |
| 130 | theme_name: RwLock::new(default_theme_name), |
| 131 | router: RwLock::new(Router::new()), |
| 132 | keybind: RwLock::new(KeybindRegistry::new()), |
| 133 | session: RwLock::new(SessionContext::new()), |
| 134 | providers: RwLock::new(Vec::new()), |
| 135 | mcp_servers: RwLock::new(Vec::new()), |
| 136 | lsp_status: RwLock::new(Vec::new()), |
| 137 | event_bus: EventBus::new(), |
| 138 | current_agent: RwLock::new("build".to_string()), |
| 139 | current_model: RwLock::new(None), |
| 140 | current_provider: RwLock::new(None), |
| 141 | current_variant: RwLock::new(None), |
| 142 | directory: RwLock::new(String::new()), |
| 143 | show_sidebar: RwLock::new(true), |
| 144 | show_header: RwLock::new(ui_kv.get_bool("header_visible", true)), |
| 145 | show_scrollbar: RwLock::new(ui_kv.get_bool("scrollbar_visible", false)), |
| 146 | tips_hidden: RwLock::new(ui_kv.get_bool("tips_hidden", false)), |
| 147 | sidebar_mode: RwLock::new(SidebarMode::Auto), |
| 148 | animations_enabled: RwLock::new(true), |
| 149 | pending_permissions: RwLock::new(0), |
| 150 | show_timestamps: RwLock::new(ui_kv.get_timestamps()), |
| 151 | show_thinking: RwLock::new(ui_kv.get_bool("thinking_visibility", true)), |
| 152 | show_tool_details: RwLock::new(ui_kv.get_bool("tool_details_visibility", true)), |
| 153 | message_density: RwLock::new(MessageDensity::from_str_lossy( |
| 154 | &ui_kv.get_string("message_density", "compact"), |
| 155 | )), |
| 156 | semantic_highlight: RwLock::new(ui_kv.get_bool("semantic_highlight", true)), |
| 157 | has_connected_provider: RwLock::new(false), |
| 158 | ui_kv: RwLock::new(ui_kv), |
| 159 | api_client: RwLock::new(None), |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | pub fn navigate(&self, route: crate::router::Route) { |
| 164 | self.router.write().navigate(route); |
nothing calls this directly
no test coverage detected