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)
| 311 | /// Also updates `current_prompt` on every call so the change message |
| 312 | /// reflects this turn's intent, not the session's opening prompt. |
| 313 | pub fn set_first_prompt(&mut self, prompt: &str) { |
| 314 | if prompt.is_empty() { |
| 315 | return; |
| 316 | } |
| 317 | |
| 318 | let stored = if prompt.len() <= Self::MAX_PROMPT_LENGTH { |
| 319 | prompt.to_string() |
| 320 | } else { |
| 321 | let truncated: String = prompt.chars().take(Self::MAX_PROMPT_LENGTH - 3).collect(); |
| 322 | format!("{}...", truncated) |
| 323 | }; |
| 324 | |
| 325 | // first_prompt is set-once (preserves the session's opening prompt) |
| 326 | if self.first_prompt.is_none() { |
| 327 | self.first_prompt = Some(stored.clone()); |
| 328 | } |
| 329 | |
| 330 | // current_prompt is updated every turn so the change message |
| 331 | // reflects THIS turn's intent, not the session's opening prompt. |
| 332 | self.current_prompt = Some(stored); |
| 333 | } |
| 334 | |
| 335 | /// Add files to the accumulated files_touched list (deduplicating). |
| 336 | pub fn add_files_touched(&mut self, files: &[String]) { |