summaryrefslogtreecommitdiffstats
path: root/src/repl/prompt.rs
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2023-10-28 21:39:17 +0800
committerGitHub <noreply@github.com>2023-10-28 21:39:17 +0800
commitbc44026ff8828f532e9eba138e2ba35f7c247271 (patch)
tree98c55ad31a543ff3cd56e297751d32ee9ca960a7 /src/repl/prompt.rs
parent1575d441724a27854c8f9fe1510a47a3050ae28d (diff)
downloadaichat-bc44026ff8828f532e9eba138e2ba35f7c247271.tar.gz
feat: enhance session/conversation (#162)
* feat: enhance session/conversation * updates * updates * cut version v0.9.0-rc2 * add .session name completion
Diffstat (limited to 'src/repl/prompt.rs')
-rw-r--r--src/repl/prompt.rs16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/repl/prompt.rs b/src/repl/prompt.rs
index 1d92407..be3763b 100644
--- a/src/repl/prompt.rs
+++ b/src/repl/prompt.rs
@@ -69,15 +69,17 @@ impl ReplPrompt {
impl Prompt for ReplPrompt {
fn render_prompt_left(&self) -> Cow<str> {
- self.config
- .read()
- .role
- .as_ref()
- .map_or(Cow::Borrowed(""), |role| Cow::Owned(role.name.clone()))
+ if let Some(session) = &self.config.read().session {
+ Cow::Owned(session.name.clone())
+ } else if let Some(role) = &self.config.read().role {
+ Cow::Owned(role.name.clone())
+ } else {
+ Cow::Borrowed("")
+ }
}
fn render_prompt_right(&self) -> Cow<str> {
- if self.config.read().conversation.is_none() {
+ if self.config.read().session.is_none() {
Cow::Borrowed("")
} else {
self.config.read().get_reamind_tokens().to_string().into()
@@ -85,7 +87,7 @@ impl Prompt for ReplPrompt {
}
fn render_prompt_indicator(&self, _prompt_mode: reedline::PromptEditMode) -> Cow<str> {
- if self.config.read().conversation.is_some() {
+ if self.config.read().session.is_some() {
Cow::Borrowed(")")
} else {
Cow::Borrowed("〉")