| 132 | } |
| 133 | |
| 134 | async fn handle_show(os: &Os, session: &mut ChatSession) -> Result<(), std::io::Error> { |
| 135 | let agent_name = Self::get_agent(session).map(|a| a.name.clone()); |
| 136 | |
| 137 | // Show agent-specific knowledge |
| 138 | if let Some(agent) = agent_name { |
| 139 | queue!( |
| 140 | session.stderr, |
| 141 | style::SetAttribute(crossterm::style::Attribute::Bold), |
| 142 | StyledText::emphasis_fg(), |
| 143 | style::Print(format!("👤 Agent ({}):\n", agent)), |
| 144 | StyledText::reset_attributes(), |
| 145 | )?; |
| 146 | |
| 147 | match KnowledgeStore::get_async_instance(os, Self::get_agent(session)).await { |
| 148 | Ok(store) => { |
| 149 | let store = store.lock().await; |
| 150 | let contexts = store.get_all().await.unwrap_or_default(); |
| 151 | let status_data = store.get_status_data().await.ok(); |
| 152 | |
| 153 | // Show contexts if any exist |
| 154 | if !contexts.is_empty() { |
| 155 | Self::format_knowledge_entries_with_indent(session, &contexts, " ")?; |
| 156 | } |
| 157 | |
| 158 | // Show operations if any exist |
| 159 | if let Some(status) = &status_data { |
| 160 | if !status.operations.is_empty() { |
| 161 | let formatted_status = Self::format_status_display(status); |
| 162 | if !formatted_status.is_empty() { |
| 163 | queue!(session.stderr, style::Print(format!("{}\n", formatted_status)))?; |
| 164 | } |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | // Only show <none> if both contexts and operations are empty |
| 169 | if contexts.is_empty() |
| 170 | && (status_data.is_none() || status_data.as_ref().unwrap().operations.is_empty()) |
| 171 | { |
| 172 | queue!( |
| 173 | session.stderr, |
| 174 | StyledText::secondary_fg(), |
| 175 | style::Print(" <none>\n\n"), |
| 176 | StyledText::reset(), |
| 177 | )?; |
| 178 | } |
| 179 | }, |
| 180 | Err(_) => { |
| 181 | queue!( |
| 182 | session.stderr, |
| 183 | StyledText::secondary_fg(), |
| 184 | style::Print(" <none>\n\n"), |
| 185 | StyledText::reset(), |
| 186 | )?; |
| 187 | }, |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | Ok(()) |