Skip to content

Commit b095906

Browse files
authored
fix: use blocking thread to readline (#1085)
1 parent f8d5e27 commit b095906

4 files changed

Lines changed: 7 additions & 53 deletions

File tree

crates/forge_main/src/input.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ use std::sync::Arc;
44
use forge_api::Environment;
55
use forge_display::TitleFormat;
66
use tokio::fs;
7+
use tokio::sync::Mutex;
8+
use tokio::task::block_in_place;
79

810
use crate::editor::{ForgeEditor, ReadResult};
911
use crate::model::{Command, ForgeCommandManager};
@@ -34,10 +36,12 @@ impl Console {
3436
}
3537

3638
pub async fn prompt(&self, prompt: ForgePrompt) -> anyhow::Result<Command> {
37-
let mut engine = ForgeEditor::new(self.env.clone(), self.command.clone());
39+
let engine = Mutex::new(ForgeEditor::new(self.env.clone(), self.command.clone()));
40+
3841
loop {
39-
let result = engine.prompt(&prompt)?;
40-
match result {
42+
let user_input =
43+
block_in_place(|| async { engine.lock().await.prompt(&prompt) }).await?;
44+
match user_input {
4145
ReadResult::Continue => continue,
4246
ReadResult::Exit => return Ok(Command::Exit),
4347
ReadResult::Empty => continue,

crates/forge_provider/src/forge_provider/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
mod model;
2-
mod parameters;
32
mod request;
43
mod response;
54
mod tool_choice;

crates/forge_provider/src/forge_provider/parameters.rs

Lines changed: 0 additions & 36 deletions
This file was deleted.

crates/forge_provider/src/forge_provider/request.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,6 @@ use serde::{Deserialize, Serialize};
1111
use super::response::{FunctionCall, ToolCall};
1212
use super::tool_choice::{FunctionType, ToolChoice};
1313

14-
#[derive(Debug, Deserialize, Serialize, Clone)]
15-
pub struct TextContent {
16-
// TODO: could be an enum
17-
pub r#type: String,
18-
pub text: String,
19-
}
20-
21-
#[derive(Debug, Deserialize, Serialize, Clone)]
22-
pub struct ImageContentPart {
23-
pub r#type: String,
24-
pub image_url: ImageUrl,
25-
}
26-
2714
#[derive(Debug, Deserialize, Serialize, Clone)]
2815
pub struct ImageUrl {
2916
pub url: String,

0 commit comments

Comments
 (0)