chore: update ui

This commit is contained in:
nathan 2024-07-02 10:28:17 +08:00
parent e1c68c1b72
commit e7877af643
5 changed files with 7 additions and 8 deletions

View File

@ -53,7 +53,7 @@ class SettingsAIView extends StatelessWidget {
AIModelSelection(), AIModelSelection(),
_AISearchToggle(value: false), _AISearchToggle(value: false),
// Disable local AI configuration for now. It's not ready for production. // Disable local AI configuration for now. It's not ready for production.
// LocalAIConfiguration(), LocalAIConfiguration(),
], ],
); );
}, },

View File

@ -72,8 +72,6 @@ impl LocalAITest {
) -> String { ) -> String {
let plugin = self.manager.get_plugin(plugin_id).await.unwrap(); let plugin = self.manager.get_plugin(plugin_id).await.unwrap();
let operation = ChatPluginOperation::new(plugin); let operation = ChatPluginOperation::new(plugin);
operation.send_message(chat_id, message).await.unwrap() operation.send_message(chat_id, message).await.unwrap()
} }
@ -95,7 +93,6 @@ impl LocalAITest {
) -> Vec<serde_json::Value> { ) -> Vec<serde_json::Value> {
let plugin = self.manager.get_plugin(plugin_id).await.unwrap(); let plugin = self.manager.get_plugin(plugin_id).await.unwrap();
let operation = ChatPluginOperation::new(plugin); let operation = ChatPluginOperation::new(plugin);
operation.get_related_questions(chat_id).await.unwrap() operation.get_related_questions(chat_id).await.unwrap()
} }

View File

@ -20,7 +20,7 @@ impl MessageReader {
self.0.clear(); self.0.clear();
let _ = reader.read_line(&mut self.0)?; let _ = reader.read_line(&mut self.0)?;
if self.0.is_empty() { if self.0.is_empty() {
Err(ReadError::Disconnect) Err(ReadError::Disconnect("Empty line".to_string()))
} else { } else {
self.parse(&self.0) self.parse(&self.0)
} }

View File

@ -164,6 +164,7 @@ impl<W: Write + Send> RpcLoop<W> {
Ok(json) => json, Ok(json) => json,
Err(err) => { Err(err) => {
if self.peer.0.is_blocking() { if self.peer.0.is_blocking() {
error!("[RPC] {:?}, disconnecting peer", err);
self.peer.disconnect(); self.peer.disconnect();
} }
self.peer.put_rpc_object(Err(err)); self.peer.put_rpc_object(Err(err));
@ -201,6 +202,7 @@ impl<W: Write + Send> RpcLoop<W> {
let json = match read_result { let json = match read_result {
Ok(json) => json, Ok(json) => json,
Err(err) => { Err(err) => {
error!("[RPC] error reading message: {:?}, disconnecting peer", err);
peer.disconnect(); peer.disconnect();
return err; return err;
}, },

View File

@ -33,7 +33,7 @@ pub enum ReadError {
/// The the method and params were not recognized by the handler. /// The the method and params were not recognized by the handler.
UnknownRequest(serde_json::Error), UnknownRequest(serde_json::Error),
/// The peer closed the connection. /// The peer closed the connection.
Disconnect, Disconnect(String),
} }
#[derive(Debug, Clone, thiserror::Error)] #[derive(Debug, Clone, thiserror::Error)]
@ -68,7 +68,7 @@ pub enum RemoteError {
impl ReadError { impl ReadError {
/// Returns `true` iff this is the `ReadError::Disconnect` variant. /// Returns `true` iff this is the `ReadError::Disconnect` variant.
pub fn is_disconnect(&self) -> bool { pub fn is_disconnect(&self) -> bool {
matches!(*self, ReadError::Disconnect) matches!(*self, ReadError::Disconnect(_))
} }
} }
@ -79,7 +79,7 @@ impl fmt::Display for ReadError {
ReadError::Json(ref err) => write!(f, "JSON Error: {:?}", err), ReadError::Json(ref err) => write!(f, "JSON Error: {:?}", err),
ReadError::NotObject(s) => write!(f, "Expected JSON object, found: {}", s), ReadError::NotObject(s) => write!(f, "Expected JSON object, found: {}", s),
ReadError::UnknownRequest(ref err) => write!(f, "Unknown request: {:?}", err), ReadError::UnknownRequest(ref err) => write!(f, "Unknown request: {:?}", err),
ReadError::Disconnect => write!(f, "Peer closed the connection."), ReadError::Disconnect(reason) => write!(f, "Peer closed the connection, reason: {}", reason),
} }
} }
} }