(&self, os: &Os, session: &mut ChatSession)
| 124 | } |
| 125 | |
| 126 | async fn handle_init(&self, os: &Os, session: &mut ChatSession) -> Result<ChatState, ChatError> { |
| 127 | if session.conversation.checkpoint_manager.is_some() { |
| 128 | execute!( |
| 129 | session.stderr, |
| 130 | StyledText::info_fg(), |
| 131 | style::Print( |
| 132 | "✓ Checkpoints are already enabled for this session! Use /checkpoint list to see current checkpoints.\n" |
| 133 | ), |
| 134 | StyledText::reset(), |
| 135 | )?; |
| 136 | } else { |
| 137 | let path = PathResolver::new(os) |
| 138 | .global() |
| 139 | .shadow_repo_dir() |
| 140 | .map_err(|e| ChatError::Custom(e.to_string().into()))? |
| 141 | .join(session.conversation.conversation_id()); |
| 142 | |
| 143 | let start = std::time::Instant::now(); |
| 144 | session.conversation.checkpoint_manager = Some( |
| 145 | CheckpointManager::manual_init(os, path, session.conversation.history()) |
| 146 | .await |
| 147 | .map_err(|e| ChatError::Custom(format!("Checkpoints could not be initialized: {e}").into()))?, |
| 148 | ); |
| 149 | |
| 150 | execute!( |
| 151 | session.stderr, |
| 152 | StyledText::info_fg(), |
| 153 | style::SetAttribute(Attribute::Bold), |
| 154 | style::Print(format!( |
| 155 | "📷 Checkpoints are enabled! (took {:.2}s)\n", |
| 156 | start.elapsed().as_secs_f32() |
| 157 | )), |
| 158 | StyledText::reset(), |
| 159 | StyledText::reset_attributes(), |
| 160 | )?; |
| 161 | } |
| 162 | |
| 163 | Ok(ChatState::PromptUser { |
| 164 | skip_printing_tools: true, |
| 165 | }) |
| 166 | } |
| 167 | |
| 168 | async fn handle_restore( |
| 169 | &self, |
no test coverage detected