summaryrefslogtreecommitdiffstats
path: root/src/config/mod.rs
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2024-11-02 07:13:35 +0800
committerGitHub <noreply@github.com>2024-11-02 07:13:35 +0800
commitf5cdd0f136d1d5ba9944135f714edf3979bb7d45 (patch)
treef8c69922ac24711d4cf9a0b27cf53c2f7e972fc6 /src/config/mod.rs
parent9749369bf4f1bcc46091f9dacd07144553c7b4f6 (diff)
downloadaichat-f5cdd0f136d1d5ba9944135f714edf3979bb7d45.tar.gz
refactor: forbid `.exit role` if the session is not empty (#963)
Diffstat (limited to 'src/config/mod.rs')
-rw-r--r--src/config/mod.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/config/mod.rs b/src/config/mod.rs
index b1a1d2e..8f3d96c 100644
--- a/src/config/mod.rs
+++ b/src/config/mod.rs
@@ -833,7 +833,7 @@ impl Config {
pub fn use_role_obj(&mut self, role: Role) -> Result<()> {
if self.agent.is_some() {
- bail!("Cannot perform this action because you are using a agent")
+ bail!("Cannot perform this operation because you are using a agent")
}
if let Some(session) = self.session.as_mut() {
session.guard_empty()?;
@@ -861,6 +861,7 @@ impl Config {
pub fn exit_role(&mut self) -> Result<()> {
if let Some(session) = self.session.as_mut() {
+ session.guard_empty()?;
session.clear_role();
} else if self.role.is_some() {
self.role = None;
@@ -1193,7 +1194,7 @@ impl Config {
abort_signal: AbortSignal,
) -> Result<()> {
if config.read().agent.is_some() {
- bail!("Cannot perform this action because you are using a agent")
+ bail!("Cannot perform this operation because you are using a agent")
}
let rag = match rag {
None => {