Set the first prompt if not already set. Truncates to MAX_PROMPT_LENGTH. Also updates `current_prompt` on every call so the change message reflects this turn's intent, not the session's opening prompt.
(&mut self, prompt: &str)
| 442 | /// Also updates `current_prompt` on every call so the change message |
| 443 | /// reflects this turn's intent, not the session's opening prompt. |
| 444 | pub fn set_first_prompt(&mut self, prompt: &str) { |
| 445 | if prompt.is_empty() { |
| 446 | return; |
| 447 | } |
| 448 | |
| 449 | let stored = if prompt.len() <= Self::MAX_PROMPT_LENGTH { |
| 450 | prompt.to_string() |
| 451 | } else { |
| 452 | let truncated: String = prompt.chars().take(Self::MAX_PROMPT_LENGTH - 3).collect(); |
| 453 | format!("{}...", truncated) |
| 454 | }; |
| 455 | |
| 456 | // first_prompt is set-once (preserves the session's opening prompt) |
| 457 | if self.first_prompt.is_none() { |
| 458 | self.first_prompt = Some(stored.clone()); |
| 459 | } |
| 460 | |
| 461 | // current_prompt is updated every turn so the change message |
| 462 | // reflects THIS turn's intent, not the session's opening prompt. |
| 463 | self.current_prompt = Some(stored); |
| 464 | } |
| 465 | |
| 466 | /// Add files to the accumulated files_touched list (deduplicating). |
| 467 | pub fn add_files_touched(&mut self, files: &[String]) { |