feat: Implement lesson generation feature and update status display

- Added functionality to generate lessons based on code reviews, including prompts and instructions for the reviewer.
- Updated the `.gitignore` to exclude lesson documentation files.
- Removed the `/lesson` command from the help menu and command parsing.
- Enhanced the status bar to display a message when a lesson is being generated.
- Introduced a new `lesson_running` state to track lesson generation progress.
- Updated various components to handle the new lesson generation workflow, including subagent events and token usage tracking.
This commit is contained in:
asepharyana
2026-07-15 03:11:55 +07:00
parent f87ab133f1
commit 1c08b8e4e9
18 changed files with 468 additions and 256 deletions
+12 -4
View File
@@ -358,6 +358,7 @@ pub fn apply_action(state: &mut AppStateRest, action: Action) {
trigger_review(state);
}
} else if kind == "review" {
state.misc.lesson_running = false;
let counted = if let Some(ref mut rt) = state.session_runtime {
refresh_lesson_counters(&state.memory_dir, rt);
true
@@ -485,6 +486,14 @@ pub fn apply_action(state: &mut AppStateRest, action: Action) {
rt.usage.api_calls += 1;
}
}
TurnEvent::ReviewUsage { tokens_in, tokens_out } => {
if let Some(ref mut rt) = state.session_runtime {
rt.usage.tokens_in += tokens_in;
rt.usage.tokens_out += tokens_out;
rt.usage.review_tokens += tokens_in + tokens_out;
rt.usage.api_calls += 1;
}
}
TurnEvent::Error(msg) => {
state.misc.api_connected = false;
let long_toast = Toast {
@@ -1341,10 +1350,9 @@ fn run_agent_turn(
}
};
if let Some((tok_in, tok_out)) = final_usage {
if let Ok(mut q) = events_q.lock() {
q.push_back(TurnEvent::Usage { tokens_in: tok_in, tokens_out: tok_out });
}
let (tok_in, tok_out) = final_usage.unwrap_or((0, 0));
if let Ok(mut q) = events_q.lock() {
q.push_back(TurnEvent::Usage { tokens_in: tok_in, tokens_out: tok_out });
}
let has_tool_calls = response.tool_calls.is_some()
-3
View File
@@ -21,9 +21,6 @@ pub fn apply_command(command: Command) -> Vec<Action> {
Command::Quit => {
vec![Action::QuitConfirm]
}
Command::LessonInteractive => {
vec![Action::OpenOverlay(Overlay::Learning)]
}
Command::McpOpen => {
vec![Action::OpenOverlay(Overlay::Mcp)]
}
+1 -1
View File
@@ -16,7 +16,7 @@ use serde_json::Value;
/// sequence), remove it; if inside a string, append `"`; then close
/// every unclosed opener in reverse (LIFO) order.
///
/// Why: LLM responses can be cut off (max_tokens, network) midJSON
/// Why: LLM responses can be cut off (`max_tokens`, network) midJSON
/// string, but we want tools to receive whatever arguments were already
/// emitted so the partial work can proceed.
///