Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: forbid .exit role if the session is not empty #963

Merged
merged 1 commit into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()?;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 => {
Expand Down
2 changes: 1 addition & 1 deletion src/config/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ impl Session {

pub fn guard_empty(&self) -> Result<()> {
if !self.is_empty() {
bail!("This action cannot be performed in a session with messages.")
bail!("Cannot perform this operation because the session has messages, please `.empty session` first.");
}
Ok(())
}
Expand Down