@@ -101,10 +101,10 @@ fn format_mcp_headers(server: &forge_domain::McpServerConfig) -> Option<String>
101101 }
102102}
103103
104- pub struct UI < A : ConsoleWriter , F : Fn ( ForgeConfig ) -> A > {
104+ pub struct UI < A : ConsoleWriter , F : Fn ( ForgeConfig ) -> anyhow :: Result < A > > {
105105 markdown : MarkdownFormat ,
106106 state : UIState ,
107- api : Arc < F :: Output > ,
107+ api : Arc < A > ,
108108 new_api : Arc < F > ,
109109 console : Console ,
110110 command : Arc < ForgeCommandManager > ,
@@ -115,7 +115,7 @@ pub struct UI<A: ConsoleWriter, F: Fn(ForgeConfig) -> A> {
115115 _guard : forge_tracker:: Guard ,
116116}
117117
118- impl < A : API + ConsoleWriter + ' static , F : Fn ( ForgeConfig ) -> A + Send + Sync > UI < A , F > {
118+ impl < A : API + ConsoleWriter + ' static , F : Fn ( ForgeConfig ) -> anyhow :: Result < A > + Send + Sync > UI < A , F > {
119119 /// Writes a line to the console output
120120 /// Takes anything that implements ToString trait
121121 fn writeln < T : ToString > ( & mut self , content : T ) -> anyhow:: Result < ( ) > {
@@ -161,7 +161,7 @@ impl<A: API + ConsoleWriter + 'static, F: Fn(ForgeConfig) -> A + Send + Sync> UI
161161 async fn on_new ( & mut self ) -> Result < ( ) > {
162162 let config = forge_config:: ForgeConfig :: read ( ) . unwrap_or_default ( ) ;
163163 self . config = config. clone ( ) ;
164- self . api = Arc :: new ( ( self . new_api ) ( config) ) ;
164+ self . api = Arc :: new ( ( self . new_api ) ( config) ? ) ;
165165 self . init_state ( false ) . await ?;
166166
167167 // Set agent if provided via CLI
@@ -216,7 +216,7 @@ impl<A: API + ConsoleWriter + 'static, F: Fn(ForgeConfig) -> A + Send + Sync> UI
216216 /// from `forge config set` are reflected in new conversations
217217 pub fn init ( cli : Cli , config : ForgeConfig , f : F ) -> Result < Self > {
218218 // Parse CLI arguments first to get flags
219- let api = Arc :: new ( f ( config. clone ( ) ) ) ;
219+ let api = Arc :: new ( f ( config. clone ( ) ) ? ) ;
220220 let env = api. environment ( ) ;
221221 let command = Arc :: new ( ForgeCommandManager :: default ( ) ) ;
222222 let spinner = SharedSpinner :: new ( SpinnerManager :: new ( api. clone ( ) ) ) ;
0 commit comments